|
@@ -235,6 +235,24 @@ class Product extends Auth{
|
|
|
if( $attr && !$skuList ) return json_send(['code'=>'error','msg'=>'规格属性存在时,请填写SKU','data'=>['error'=>'规格属性存在时,请填写SKU']]);
|
|
|
// 限购提示
|
|
|
if( $data['quota'] && ( !$data['quota_start'] || !$data['quota_end'] )) return json_send(['code'=>'error','msg'=>'限购必填限购时间','data'=>['error'=>'限购必填限购时间']]);
|
|
|
+ // 限购提示
|
|
|
+ if( $data['min_quota'] > $data['quota'] ) return json_send(['code'=>'error','msg'=>'起购数量请勿大于限购数量','data'=>['error'=>'起购数量请勿大于限购数量']]);
|
|
|
+ // SKU存在的时候,判断限购数量
|
|
|
+ if( $skuList ) {
|
|
|
+ // 循环处理
|
|
|
+ foreach ($skuList as $attrNames => $value) {
|
|
|
+ // SKU限购,所以限购时间也必须填
|
|
|
+ if( $value['quota'] && ( !$data['quota_start'] || !$data['quota_end'] )) return json_send(['code'=>'error','msg'=>'SKU限购时,请填限购时间','data'=>['error'=>'SKU限购时,请填限购时间']]);
|
|
|
+ // 限购提示
|
|
|
+ if( $value['min_quota'] > $value['quota'] ) return json_send(['code'=>'error','msg'=>$attrNames.'起购数量请勿大于限购数量','data'=>['error'=>$attrNames.'起购数量请勿大于限购数量']]);
|
|
|
+ // 提示起购数量异常,如果总起购数量小于SKU起购数量,提示
|
|
|
+ if( $data['min_quota'] && $value['min_quota'] < $data['min_quota'] ) return json_send(['code'=>'error','msg'=>'SKU的起购数量不能小于总起购数量','data'=>['error'=>'SKU的起购数量不能小于总起购数量']]);
|
|
|
+ }
|
|
|
+ // 限购数量
|
|
|
+ $quota = array_sum(array_column($skuList,'quota'));
|
|
|
+ // 提示限购数量异常
|
|
|
+ if( $data['quota']&& $data['quota'] < $quota ) return json_send(['code'=>'error','msg'=>'总限购数量不能小于SKU的限购数量','data'=>['error'=>'总限购数量不能小于SKU的限购数量']]);
|
|
|
+ }
|
|
|
// 上下架
|
|
|
if( $data['puton_time'] ) {
|
|
|
// 下架时间必填
|
|
@@ -438,6 +456,24 @@ class Product extends Auth{
|
|
|
if( $attr && !$skuList ) return json_send(['code'=>'error','msg'=>'规格属性存在时,请填写SKU','data'=>['error'=>'规格属性存在时,请填写SKU']]);
|
|
|
// 限购提示
|
|
|
if( $data['quota'] && ( !$data['quota_start'] || !$data['quota_end'] )) return json_send(['code'=>'error','msg'=>'限购必填限购时间','data'=>['error'=>'限购必填限购时间']]);
|
|
|
+ // 限购提示
|
|
|
+ if( $data['min_quota'] > $data['quota'] ) return json_send(['code'=>'error','msg'=>'起购数量请勿大于限购数量','data'=>['error'=>'起购数量请勿大于限购数量']]);
|
|
|
+ // SKU存在的时候,判断限购数量
|
|
|
+ if( $skuList ) {
|
|
|
+ // 循环处理
|
|
|
+ foreach ($skuList as $attrNames => $value) {
|
|
|
+ // SKU限购,所以限购时间也必须填
|
|
|
+ if( $value['quota'] && ( !$data['quota_start'] || !$data['quota_end'] )) return json_send(['code'=>'error','msg'=>'SKU限购时,请填限购时间','data'=>['error'=>'SKU限购时,请填限购时间']]);
|
|
|
+ // 限购提示
|
|
|
+ if( $value['min_quota'] > $value['quota'] ) return json_send(['code'=>'error','msg'=>$attrNames.'起购数量请勿大于限购数量','data'=>['error'=>$attrNames.'起购数量请勿大于限购数量']]);
|
|
|
+ // 提示起购数量异常,如果总起购数量小于SKU起购数量,提示
|
|
|
+ if( $data['min_quota'] && $value['min_quota'] < $data['min_quota'] ) return json_send(['code'=>'error','msg'=>'SKU的起购数量不能小于总起购数量','data'=>['error'=>'SKU的起购数量不能小于总起购数量']]);
|
|
|
+ }
|
|
|
+ // 限购数量
|
|
|
+ $quota = array_sum(array_column($skuList,'quota'));
|
|
|
+ // 提示限购数量异常
|
|
|
+ if( $data['quota']&& $data['quota'] < $quota ) return json_send(['code'=>'error','msg'=>'总限购数量不能小于SKU的限购数量','data'=>['error'=>'总限购数量不能小于SKU的限购数量']]);
|
|
|
+ }
|
|
|
// 上下架
|
|
|
if( $data['puton_time'] ) {
|
|
|
// 下架时间必填
|
|
@@ -670,8 +706,26 @@ class Product extends Auth{
|
|
|
if( $attr && !$skuList ) return json_send(['code'=>'error','msg'=>'规格属性存在时,请填写SKU','data'=>['error'=>'规格属性存在时,请填写SKU']]);
|
|
|
// 限购提示
|
|
|
if( $data['quota'] && ( !$data['quota_start'] || !$data['quota_end'] )) return json_send(['code'=>'error','msg'=>'限购必填限购时间','data'=>['error'=>'限购必填限购时间']]);
|
|
|
+ // 限购提示
|
|
|
+ if( $data['min_quota'] > $data['quota'] ) return json_send(['code'=>'error','msg'=>'起购数量请勿大于限购数量','data'=>['error'=>'起购数量请勿大于限购数量']]);
|
|
|
// 总库存
|
|
|
if( $skuList ) $data['stock'] = array_sum(array_column($skuList,'stock'));
|
|
|
+ // SKU存在的时候,判断限购数量
|
|
|
+ if( $skuList ) {
|
|
|
+ // 循环处理
|
|
|
+ foreach ($skuList as $attrNames => $value) {
|
|
|
+ // SKU限购,所以限购时间也必须填
|
|
|
+ if( $value['quota'] && ( !$data['quota_start'] || !$data['quota_end'] )) return json_send(['code'=>'error','msg'=>'SKU限购时,请填限购时间','data'=>['error'=>'SKU限购时,请填限购时间']]);
|
|
|
+ // 限购提示
|
|
|
+ if( $value['min_quota'] > $value['quota'] ) return json_send(['code'=>'error','msg'=>$attrNames.'起购数量请勿大于限购数量','data'=>['error'=>$attrNames.'起购数量请勿大于限购数量']]);
|
|
|
+ // 提示起购数量异常,如果总起购数量小于SKU起购数量,提示
|
|
|
+ if( $data['min_quota'] && $value['min_quota'] < $data['min_quota'] ) return json_send(['code'=>'error','msg'=>'SKU的起购数量不能小于总起购数量','data'=>['error'=>'SKU的起购数量不能小于总起购数量']]);
|
|
|
+ }
|
|
|
+ // 限购数量
|
|
|
+ $quota = array_sum(array_column($skuList,'quota'));
|
|
|
+ // 提示限购数量异常
|
|
|
+ if( $data['quota'] && $data['quota'] < $quota ) return json_send(['code'=>'error','msg'=>'总限购数量不能小于SKU的限购数量','data'=>['error'=>'总限购数量不能小于SKU的限购数量']]);
|
|
|
+ }
|
|
|
// 总库存
|
|
|
$data['stock_total'] = $data['stock'];
|
|
|
// 获取规格属性
|