gogs 1 年之前
父节点
当前提交
f6ad8d6319
共有 1 个文件被更改,包括 133 次插入2 次删除
  1. 133 2
      app/Service/DwyService.php

+ 133 - 2
app/Service/DwyService.php

@@ -23,7 +23,7 @@ class DwyService extends Service
         return self::$instance;
     }
 
-    public function setBoxData($token,$dv,$data,$box_list){
+    public function setBoxData($token,$dv,$data,$box_list,$old_data){
         //
         $this->num = 0;
 //        $token = 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI1NjYxNTc5MjMwMDUzNzAzNjgiLCJhdXRoIjoiUk9MRV9CUkFORF9TVVBQTElFUixST0xFX1VTRV9CUkFORF9TVVBQTElFUixST0xFX0lOTkVSX1VTRVIsUk9MRV9JTlRFUkZBQ0UsUk9MRV9TRU5EX0JSQU5EX1NVUFBMSUVSIiwidG9rZW5JZCI6IjQiLCJleHAiOjE3MTk2NzI1OTN9.VKDLhTILWHe6MIAlzNvxCk4pBQaV-Et1UFYb12xTxl-QcVWpYaWLZnk6_QJ2bDXMplp75DuIKADmjuHDjDFSWQ';
@@ -69,12 +69,143 @@ class DwyService extends Service
         //补全数据
         $data = $this->setBoxFake($new_data);
 
-        return $data;
+        //把数据拼回去
+
+        list($lind_bind,$lead_out) = $this->setNewData($old_data,$data);
+        return [$lind_bind,$lead_out];
 
     }
 
+    // 获取指定数量的值,并从原数组中删除这些值
+    function getValues(&$array, $count) {
+
+        // 获取前$count个值
+        $result = array_slice($array, 0, $count);
+
+        // 从原数组中删除这些值
+        $array = array_slice($array, $count);
+
+        return $result;
+    }
+
+    private function setNewData($old_data,$data){
+        $code_key_data = [];
+        foreach ($data as $v){
+            if(!isset($code_key_data[$v['material_code']])) $code_key_data[$v['material_code']] = [];
+            $code_key_data[$v['material_code']] = array_merge($code_key_data[$v['material_code']],$v['detail']);
+        }
+        $lind_bind = $old_data['lead_bind'];
+        foreach ($lind_bind['material_list'] as &$l){
+            unset($l['brand_qr_code_list']);
+            $l['brand_qr_code_list'] = $this->getValues( $code_key_data[$l['material_code']],$l['fake_qty']);
+        }
+
+        $lead_out = $old_data['brand_out_stock_list'];
+        foreach ($lead_out as &$ll){
+            unset($ll['brand_qr_code_list']);
+            $ll['brand_qr_code_list'] = $data[$ll['send_box_code']];
+        }
+
+        return [$lind_bind,$lead_out];
+        //{
+        //    "key": "DV00001",
+        //    "lead_bind": {
+        //        "device_code": "DV00001",
+        //        "material_list": [
+        //            {
+        //                "product_code": "BC020202000999",
+        //                "product_code_show": "\u4fe1\u606f\u90e8\u6d4b\u8bd51800\u9999\u6749\u6728",
+        //                "order_item_id": "581732116677795840",
+        //                "order_item_id_show": "SO202405240088",
+        //                "material_code": "40010101000999",
+        //                "material_code_show": "E0\u6279\u96f6\u514d\u6f06\uff08\u6d4b\u8bd5\u767d\u6807\uff09",
+        //                "process_title": null,
+        //                "process_title_two": null,
+        //                "color": null,
+        //                "fake_qty": 20,
+        //                "color_two": null,
+        //                "brand_qr_code_list": [
+        //                    "DN2EYGAT3XJJRGMHJ5CL",
+        //                ],
+        //                "order_no_list": "SO202405240088"
+        //            },
+        //            {
+        //                "product_code": "BC020202000999",
+        //                "product_code_show": "\u4fe1\u606f\u90e8\u6d4b\u8bd51800\u9999\u6749\u6728",
+        //                "order_item_id": "581732116677795840",
+        //                "order_item_id_show": "SO202405240088",
+        //                "material_code": "40010101000999",
+        //                "material_code_show": "E0\u6279\u96f6\u514d\u6f06\uff08\u6d4b\u8bd5\u767d\u6807\uff09",
+        //                "process_title": null,
+        //                "process_title_two": null,
+        //                "color": null,
+        //                 "fake_qty": 10,
+        //                "color_two": null,
+        //                "brand_qr_code_list": [
+        //                    "13NMKBBM8O8JBRWDJHW3",
+        //                ],
+        //                "order_no_list": "SO202405240088"
+        //            }
+        //        ]
+        //    },
+        //    "lead_out": {
+        //        "brand_out_stock_list": [
+        //            {
+        //                "in_out_type_code": "CK00004",
+        //                "in_out_type_code_show": "\u5546\u6807\u4ed3\u6b63\u5e38\u9886\u6807\u51fa\u5e93",
+        //                "send_box_code": "CK00014",
+        //                "send_box_code_show": "\u5546\u6807\u5341\u4e00\u53f7\u4ed3",
+        //                "device_code": "DV00001",
+        //                "get_brand_source_dk": "SALE_ORDER",
+        //                "brand_out_stock_dtl": [
+        //                    {
+        //                        "item_no": 10,
+        //                        "brand_qr_code_list": "",
+        //                        "material_code": "40010101000999",
+        //                        "restock_qty": 0,
+        //                        "material_code_show": "E0\u6279\u96f6\u514d\u6f06\uff08\u6d4b\u8bd5\u767d\u6807\uff09",
+        //                        "unit_code": "ST",
+        //                        "unit_code_show": "\u5f20",
+        //                        "qty": "24",
+        //                        "bus_type_dk": "SALE_ORDER",
+        //                        "bus_type_dk_show": "\u9500\u552e\u8ba2\u5355",
+        //                        "bus_no": "581732116677795840",
+        //                        "bus_no_show": "SO202405240088"
+        //                    }
+        //                ]
+        //            },
+        //            {
+        //                "in_out_type_code": "CK00004",
+        //                "in_out_type_code_show": "\u5546\u6807\u4ed3\u6b63\u5e38\u9886\u6807\u51fa\u5e93",
+        //                "send_box_code": "CK00012",
+        //                "send_box_code_show": "\u5546\u6807\u4e5d\u53f7\u4ed3",
+        //                "device_code": "DV00001",
+        //                "get_brand_source_dk": "SALE_ORDER",
+        //                "brand_out_stock_dtl": [
+        //                    {
+        //                        "item_no": 10,
+        //                        "brand_qr_code_list": "13NMKBBM8O8JBRWDJHW3",
+        //                        "material_code": "40010101000999",
+        //                        "restock_qty": 0,
+        //                        "material_code_show": "E0\u6279\u96f6\u514d\u6f06\uff08\u6d4b\u8bd5\u767d\u6807\uff09",
+        //                        "unit_code": "ST",
+        //                        "unit_code_show": "\u5f20",
+        //                        "qty": "5",
+        //                        "bus_type_dk": "SALE_ORDER",
+        //                        "bus_type_dk_show": "\u9500\u552e\u8ba2\u5355",
+        //                        "bus_no": "581732116677795840",
+        //                        "bus_no_show": "SO202405240088"
+        //                    }
+        //                ]
+        //            }
+        //        ]
+        //    }
+        //}
+    }
+
 
     private function setBoxFake($data){
+
         foreach ($data as $k=>$v){
             if($v['fake_qty'] > count($v['detail'])){
                 $diff = $v['fake_qty'] - count($v['detail']);