|
@@ -12,16 +12,26 @@ class OrderCategory extends Model{
|
|
protected $deleteTime='delete_time';
|
|
protected $deleteTime='delete_time';
|
|
|
|
|
|
public static function checkInfo($code,$orderType,$info){
|
|
public static function checkInfo($code,$orderType,$info){
|
|
- $isT=self::where(['code'=>$code,'orderType'=>$orderType])->findOrEmpty();
|
|
|
|
- if($isT->isEmpty()){
|
|
|
|
- $isT->code = $code;
|
|
|
|
- $isT->orderType = $orderType;
|
|
|
|
- $isT->cat_code=$info['cat_code'];
|
|
|
|
- $isT->cat_name=$info['cat_name'];
|
|
|
|
- $isT->tax=$info['tax'];
|
|
|
|
- $isT->inv_good_name = $info['inv_good_name'];
|
|
|
|
- $save=$isT->save();
|
|
|
|
- if(!$save)throw new \Exception('订单类目保存失败');
|
|
|
|
|
|
+ if(!empty($info)){
|
|
|
|
+ $save=[];
|
|
|
|
+ foreach ($info as $key=>$value){
|
|
|
|
+ $ist = self::where(["code"=>$code,"order_type"=>$orderType,"spuCode"=>$value['spuCode']])->findOrEmpty();
|
|
|
|
+ if($ist->isEmpty()){
|
|
|
|
+ $Temp=[
|
|
|
|
+ "code"=>$code,
|
|
|
|
+ "order_type"=>$orderType,
|
|
|
|
+ "spuCode"=>$value['spuCode'],
|
|
|
|
+ "cat_code"=>$value['cat_code'],
|
|
|
|
+ "cat_name"=>$value['cat_name'],
|
|
|
|
+ "tax"=>$value['tax'],
|
|
|
|
+ "inv_good_name"=>$value['inv_good_name']
|
|
|
|
+ ];
|
|
|
|
+ $save[]=$Temp;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(!empty($save)){
|
|
|
|
+ self::insertAll($save);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|