wugg 7 miesięcy temu
rodzic
commit
d36e8fe78f
2 zmienionych plików z 35 dodań i 2 usunięć
  1. 27 0
      app/admin/model/OrderCategory.php
  2. 8 2
      app/command/handleCxData.php

+ 27 - 0
app/admin/model/OrderCategory.php

@@ -0,0 +1,27 @@
+<?php
+
+
+namespace app\admin\model;
+
+
+use think\Model;
+use think\model\concern\SoftDelete;
+class OrderCategory extends Model{
+    use SoftDelete;
+    protected $createTime = 'createTime';
+    protected $deleteTime='delete_time';
+
+    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('订单类目保存失败');
+        }
+    }
+}

+ 8 - 2
app/command/handleCxData.php

@@ -2,7 +2,7 @@
 
 namespace app\command;
 
-use app\admin\model\ComonOrder;use think\console\Command;
+use app\admin\model\ComonOrder;use app\admin\model\OrderCategory;use think\console\Command;
 use think\console\Input;
 use think\console\Output;
 use think\Exception;
@@ -49,6 +49,11 @@ class handleCxData extends command
 					    $output->writeln("[$date]:{$result['id']}数据解析失败");
 				    	continue;
 				    }
+				    if(isset($data['inv_cat_info']) && !empty($data['inv_cat_info'])){
+                        $orderCode= $result['order_type']==1?$data['orderCode']:$data['cgdNo'];
+                        OrderCategory::checkInfo($orderCode,$result['order_type'],$data['inv_cat_info']);
+				    }
+
 				    $qrd_insert_data=$wait_insert_data=$cgd_insert_data=[];
 				    $data['cat_name']=is_array($data['cat_name']) ? $data['cat_name'] : json_decode($data['cat_name'],true);
 				    if ($result['order_type'] == 1) {
@@ -304,7 +309,8 @@ class handleCxData extends command
 								(['qrdSend'=>$data['send_status']]);
 							}
 					
-				    } else {
+				    }
+				    else {
 					    //已存在
 					    $data['total_fee']=round($data['total_fee'],2) - $data['th_fee'] - $data['diff_fee'];
 					    $exitReport=Db::name('report_code')->where('cgdNo' , $data['cgdNo'])->findOrEmpty();