Browse Source

报备单转单优化

wufeng 2 years ago
parent
commit
6a88d39199
1 changed files with 37 additions and 7 deletions
  1. 37 7
      app/abutment/logic/Filing.php

+ 37 - 7
app/abutment/logic/Filing.php

@@ -202,6 +202,9 @@ class Filing
 
         try {
 
+            $order_type = 4;//报备商品
+            $order_source = 7;//报备转单
+
             $spuCode = makeNo('SKU');
 
             //商品表
@@ -254,8 +257,8 @@ class Filing
                 'orderCode' => $orderCode,
                 'apply_id' => $filing['apply_id'],
                 'apply_name' => $filing['apply_name'],
-                'order_type' => 4,//报备商品
-                'order_source' => 7,//报备转单
+                'order_type' => $order_type,//报备商品
+                'order_source' => $order_source,//报备转单
                 'platform_id' => $filing['platform_id'],
                 'good_code' => $spuCode,
                 'skuCode' => '',
@@ -303,6 +306,7 @@ class Filing
                 'good_creater' => $filing['apply_name'],
             ]);
 
+
             //仓库
             $wsm = Db::name('warehouse_info')
                 ->field('id,wsm_code')
@@ -364,8 +368,8 @@ class Filing
                 'status' => 0,
                 'lasttime' => $date,
                 'is_del' => 0,
-                'order_type' => 2,
-                'order_source' => 2,
+                'order_type' => $order_type,
+                'order_source' => $order_source,
                 'good_type' => 1,
                 'addtime' => $date,
                 'updatetime' => $date,
@@ -380,8 +384,8 @@ class Filing
                 'sale_id' => $sale_id,
                 'customer_code' => $filing['companyCode'],
                 'supplierNo' => $filing['supplierNo'],
-                'order_type' => 2,
-                'order_source' => 2,
+                'order_type' => $order_type,
+                'order_source' => $order_source,
                 'spuCode' => $spuCode,
                 'addtime' => $date,
                 'updatetime' => $date,
@@ -389,6 +393,7 @@ class Filing
             ];
 
             $i = 0;
+            $order_send_insert = [];
             foreach ($data['addr_list'] as $addr) {
                 //地址addr
                 $addrid = Db::name('order_addr')->insertGetId([
@@ -424,12 +429,21 @@ class Filing
                     'check_num' => 0,
                     'error_num' => 0,
                     'wsm_code' => '',
-                    'order_type' => 2,
+                    'order_type' => $order_type,
                     'status' => 0,
                     'addtime' => $date,
                     'updatetime' => $date,
                 ]);
                 $standing_bood_data['outCode'][] = $outCode;
+                $order_send_insert[] = [
+                    'cgdNo' => $cgdCode,
+                    'outCode' => $outCode,
+                    'send_num' => $addr['receipt_quantity'],
+                    'bnCode' => '',
+                    'status' => 1,
+                    'addtime' => $date,
+                    'updatetime' => $date,
+                ];
                 $i++;
             }
 
@@ -442,6 +456,22 @@ class Filing
             //待办已办先不处理
 
 
+            //关联表
+            Db::name('order_num')
+                ->insert([
+                    'orderCode' => $orderCode,
+                    'cgdNo' => $cgdCode,
+                    'spuCode' => $spuCode,
+                    'companyNo' => $filing['customerCode'],
+                    'good_num' => $filing['num'],
+                    'wsend_num' => $filing['num'],
+                    'send_num' => 0,
+                    'wait_num' => $filing['num'],
+                ]);
+
+            if ($order_send_insert) Db::name('order_send')->insertAll($order_send_insert);
+
+
             //处理台账
             if (isset($standing_bood_data['outCode']) && is_array($standing_bood_data['outCode'])) $standing_bood_data['outCode'] = implode(',', $standing_bood_data['outCode']);