cqp пре 2 дана
родитељ
комит
99c0e037fa
3 измењених фајлова са 66 додато и 35 уклоњено
  1. 11 0
      app/Http/Controllers/Api/TestController.php
  2. 54 35
      app/Service/TestService.php
  3. 1 0
      routes/api.php

+ 11 - 0
app/Http/Controllers/Api/TestController.php

@@ -109,6 +109,17 @@ class TestController extends BaseController
         }
     }
 
+    public function otherInAddU8(Request $request){
+        $common_array = $request->common_param;
+        list($bool, $data) = (new TestService())->otherInByZj($request->all(), $common_array);
+
+        if($bool){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
+
     public function dispatchAddU8(Request $request){
         $common_array = $request->common_param;
         list($bool, $data) = (new TestService())->DispatchAddU8($request->all(), $common_array);

+ 54 - 35
app/Service/TestService.php

@@ -760,7 +760,7 @@ class TestService extends Service
                     "cExch_Name"    => "人民币",
                     "cSource"       => "库存",
                     "cBusType"      => "普通采购",
-                    "cMemo"         => "接口生成",
+                    "cMemo"         => $data['cMemo'] ?? "接口生成",
                     "dDate"         => date("Y-m-d"),
                 ],
                 "iBody" => $inventoryEntry
@@ -787,49 +787,67 @@ class TestService extends Service
     }
 
     //检验单(不是用友的检验单 所以不是参照)生成其他入库单
-    public function otherInByZj($data){
-        $record = $data['record'];
-        $payload = $data['payload'];
-        $id = $record['u8_id'];
-        $num = $payload['hg_not_quantity'];
-
-        //获取单据 检验单
-        $service = new U8ThirtyPartyDatabaseServerService();
-        list($status, $order) = $service->getJyOrder($id);
-        if(! $status) return [false, $order];
-
-        //u8 token
-        list($status, $msg) = $this->getToken();
+    public function otherInByZj($data, $common_array){
+        // u8 token 获取
+        list($status, $msg) = $this->getToken($common_array);
         if(! $status) return [false, $msg];
+        $title = $common_array['title'];
+
+        $baseData = [
+            "iRowNo"       => 1,
+            "cInvCode"     => $data['material_code'] ?? '',
+            "cBatch"       => $data['batch'] ?? null,
+            "iinvexchrate" => null,
+            "iQuantity"    => $data['quantity'],   // 数量
+            "dMadeDate"    => $order['made_date'] ?? null, // 生产日期
+            "dVDate"       => $order['valid_date'] ?? null,
+        ];
+
+        if ($common_array['site'] == "LFMY") {
+            // 朗峰结构 (cdefine28 - cdefine33)
+            $extData = [
+                'cdefine28' => $data['brand_name'] ?? null,
+                'cdefine29' => $data['safe'] ?? null,
+                'cdefine30' => $data['decor'] ?? null,
+                'cdefine31' => $data['craft_type_code'] ?? null,
+                'cdefine32' => $data['decor_b'] ?? null,
+                'cdefine33' => $data['craft_type_code_b'] ?? null,
+            ];
+        } elseif ($common_array['site'] == "HCLT") {
+            // 恒昌结构 (cfree + cdefine22/23 + cdefine28-31)
+            $extData = [
+                'cfree1'    => $data['customer_brand'] ?? null,
+                'cfree2'    => $data['color'] ?? null,
+                'cdefine22' => $data['plan_no'] ?? null,
+                'cdefine23' => $data['contract_no'] ?? null,
+                'cdefine28' => $data['technical_require'] ?? null,
+                'cdefine29' => $data['quality_require'] ?? null,
+                'cdefine30' => $data['package_require'] ?? null,
+                'cdefine31' => $data['shipping_mark'] ?? null,
+            ];
+        } else {
+            $extData = [];
+        }
+
+        $inventoryEntry = array_merge($baseData, $extData);
 
         $tmp = [
             "Inum" => "OtherIn",
             "Data" => [
                 "iHead" => [
                     "IsVerify"    => true,
-                    "cWhCode"     => "53", // 成品不良品库
-                    "cRdCode"     => '0109', // 入库类别 其他入库
-                    "cDepCode"    => '',     // 部门
-                    "cMemo"       => "接口生成",
+                    "cWhCode"     => $data['warehouse_code'] ?? "",
+                    "cRdCode"     => $data['cRdCode'] ?? null, // 入库类别
+                    "cDepCode"    => null,     // 部门
+                    "cSource"       => "库存",
+                    "cBusType"      => "其他入库",
+                    "cMemo"         => $data['cMemo'] ?? "接口生成",
                     "dDate"       => date("Y-m-d"),
                 ],
-                "iBody" => []
+                "iBody" => $inventoryEntry
             ]
         ];
-        //一个检验单只有一行
-        $tmp["Data"]["iBody"][] = [
-            "iRowNo"       => 1,
-            "cInvCode"     => $order['CINVCODE'] ?? '',
-            "cAssUnit"     => $order['CUNITID'] ?? '',
-            "cPosition"    => $order['cPosition'] ?? '',
-            "cBatch"       => $order['CBATCH'] ?? '',
-            "iinvexchrate" => $order['FCHANGRATE'] ?? 0,
-            "iQuantity"    => $num,   // 数量
-            "dMadeDate"    => $order['DPRODATE'] ?? '', // 生产日期
-            "dVDate"       => $order['DVDATE'] ?? '',
-            'cFree1' => $order['CFREE1'] ?? null,
-            'cFree2' => $order['CFREE2'] ?? null,
-        ];
+
         $final_data = [$tmp];
 
         //调用所需
@@ -841,10 +859,11 @@ class TestService extends Service
         $url = $host . "/api/OtherIn/Add";
 
         $json = json_encode($final_data);
-        list($status, $result) = $this->post_helper1($url, $json, $header, 30);
+        list($status, $result) = $this->post_helper($url, json_encode($json), $header, 60, $title . '生成其他入库单');
+
         if(! $status) return [false, $result];
 
-        if(! isset($result['code'])) return [false, '其他入库单生成并审核失败'];
+        if(! isset($result['code'])) return [false, '其他入库单生成失败,请重试'];
         if($result['code'] != 0) return [false, $result['msg']];
 
         return [true, ''];

+ 1 - 0
routes/api.php

@@ -73,6 +73,7 @@ Route::group(['middleware'=> ['CheckU8']],function ($route){
     $route->any('materialAddU8', 'Api\TestController@materialAddU8')->middleware('U8Deal');
     $route->any('productInAddU8', 'Api\TestController@productInAddU8')->middleware('U8Deal');
     $route->any('purchaseInAddU8', 'Api\TestController@purchaseInAddU8')->middleware('U8Deal');
+    $route->any('otherInAddU8', 'Api\TestController@otherInAddU8')->middleware('U8Deal');
     $route->any('dispatchAddU8', 'Api\TestController@dispatchAddU8')->middleware('U8Deal');
 });