cqp před 20 hodinami
rodič
revize
fcfb7f31dd
1 změnil soubory, kde provedl 23 přidání a 63 odebrání
  1. 23 63
      app/Service/U8ThirdPartyService.php

+ 23 - 63
app/Service/U8ThirdPartyService.php

@@ -158,11 +158,12 @@ class U8ThirdPartyService extends Service
             $newRow['iMoney']       = round($unitLocalMoney * $newQty, 2);
             $newRow['iMoney']       = round($unitLocalMoney * $newQty, 2);
             $newRow['iSum']         = round($unitLocalSum * $newQty, 2);
             $newRow['iSum']         = round($unitLocalSum * $newQty, 2);
             $newRow['iTaxPrice']    = round(($unitLocalSum - $unitLocalMoney) * $newQty, 2);
             $newRow['iTaxPrice']    = round(($unitLocalSum - $unitLocalMoney) * $newQty, 2);
-            $newRow['cBatch']       = $value['lot'] ?? null;
+            // 统一使用 empty 判定,最保险
+            $newRow['cBatch'] = !empty($value['lot']) ? $value['lot'] : null;
             $newRow['dPDate'] = !empty($value['productDate']) ? $this->formatAndValidateDate($value['productDate']) : null;
             $newRow['dPDate'] = !empty($value['productDate']) ? $this->formatAndValidateDate($value['productDate']) : null;
             $newRow['dVDate'] = !empty($value['failureDate']) ? $this->formatAndValidateDate($value['failureDate']) : null;
             $newRow['dVDate'] = !empty($value['failureDate']) ? $this->formatAndValidateDate($value['failureDate']) : null;
-            $newRow['cFree1'] = $value['param_one'] ?? null; //锥入度
-            $newRow['cFree2'] = $value['param_two'] ?? null; //包装规格
+            $newRow['cFree1'] = !empty($value['param_one']) ? $value['param_one'] : null;
+            $newRow['cFree2'] = !empty($value['param_two']) ? $value['param_two'] : null;
 
 
             $insertData[] = $newRow;
             $insertData[] = $newRow;
         }
         }
@@ -266,13 +267,15 @@ class U8ThirdPartyService extends Service
             unset($newRow['AutoID']);
             unset($newRow['AutoID']);
             $newRow['iQuantity'] = $newQty;             // 申请数量
             $newRow['iQuantity'] = $newQty;             // 申请数量
             $newRow['irowno'] = $rowNo++;          // 重新排序行号
             $newRow['irowno'] = $rowNo++;          // 重新排序行号
-            $newRow['cBatch'] = $value['lot'] ?? null;     // 批号
 
 
             // 生产日期与失效日期 (U8 领料申请单通常字段名为 dMadeDate 和 dVDate 或 dmadedate)
             // 生产日期与失效日期 (U8 领料申请单通常字段名为 dMadeDate 和 dVDate 或 dmadedate)
             $newRow['dMadeDate'] = !empty($value['productDate']) ? $this->formatAndValidateDate($value['productDate']) : null;
             $newRow['dMadeDate'] = !empty($value['productDate']) ? $this->formatAndValidateDate($value['productDate']) : null;
             $newRow['dVDate'] = !empty($value['failureDate']) ? $this->formatAndValidateDate($value['failureDate']) : null;
             $newRow['dVDate'] = !empty($value['failureDate']) ? $this->formatAndValidateDate($value['failureDate']) : null;
-            $newRow['cFree1'] = $value['param_one'] ?? null; //锥入度
-            $newRow['cFree2'] = $value['param_two'] ?? null; //包装规格
+
+            // 统一使用 empty 判定,最保险
+            $newRow['cBatch'] = !empty($value['lot']) ? $value['lot'] : null;
+            $newRow['cFree1'] = !empty($value['param_one']) ? $value['param_one'] : null;//锥入度
+            $newRow['cFree2'] = !empty($value['param_two']) ? $value['param_two'] : null;//包装规格
 
 
             $insertData[] = $newRow;
             $insertData[] = $newRow;
         }
         }
@@ -326,8 +329,8 @@ class U8ThirdPartyService extends Service
                 "iMaIDs"       => $item['AutoID'],
                 "iMaIDs"       => $item['AutoID'],
                 "dMadeDate"    => $item['dMadeDate'] ?? null,   // 生产日期
                 "dMadeDate"    => $item['dMadeDate'] ?? null,   // 生产日期
                 "dVDate"       => $item['dVDate'] ?? null,      // 失效日期
                 "dVDate"       => $item['dVDate'] ?? null,      // 失效日期
-                'cFree1' => $item['cFree1'],
-                'cFree2' => $item['cFree2'],
+                'cFree1' => $item['cFree1'] ?? null,
+                'cFree2' => $item['cFree2'] ?? null,
             ];
             ];
         }
         }
 
 
@@ -461,7 +464,7 @@ class U8ThirdPartyService extends Service
 
 
            // --- 核心字段修正 (报检单子表字段通常为大写) ---
            // --- 核心字段修正 (报检单子表字段通常为大写) ---
            $newRow['FQUANTITY'] = $newQty;             // 报检数量
            $newRow['FQUANTITY'] = $newQty;             // 报检数量
-           $newRow['CBATCH']    = $value['lot'] ?? null;        // 批号
+           $newRow['CBATCH']    = !empty($value['lot']) ? $value['lot'] : null;        // 批号
 
 
            // 报检单的日期字段通常是 DPRODATE (生产日期) 和 DVDATE (失效日期)
            // 报检单的日期字段通常是 DPRODATE (生产日期) 和 DVDATE (失效日期)
            $newRow['DPRODATE'] = !empty($value['productDate']) ? $this->formatAndValidateDate($value['productDate']) : null;
            $newRow['DPRODATE'] = !empty($value['productDate']) ? $this->formatAndValidateDate($value['productDate']) : null;
@@ -474,49 +477,6 @@ class U8ThirdPartyService extends Service
        list($status, $msg) = $service->rebuildBjDetails($mainId, $insertData);
        list($status, $msg) = $service->rebuildBjDetails($mainId, $insertData);
        if (!$status) return [false, $msg];
        if (!$status) return [false, $msg];
 
 
-//       $service = new U8ThirtyPartyDatabaseServerService();
-//       $result = $service->getBjOrder($data['orderId']);
-//
-//       $tmp = $update = $insert = [];
-//       foreach ($data['detail'] as $key => $value) {
-//            if(empty($value['lineNum'])) return [false, '行号不能为空'];
-//            if(! is_numeric($value['lineNum'])) return [false, '行号错误'];
-//            if(empty($value['materialCode'])) return [false, '存货编码不能为空'];
-//            if(empty($value['productDate'])) return [false, '生产日期不能为空'];
-//            $return = $this->formatAndValidateDate($value['productDate']);
-//            if(! $return) return [false, '生产日期格式错误'];
-//            $productDate = $return;
-//            if(empty($value['failureDate'])) return [false, '失效日期不能为空'];
-//            $return = $this->formatAndValidateDate($value['failureDate']);
-//            if(! $return) return [false, '生产日期格式错误'];
-//            $failureDate= $return;
-//            if(empty($value['lot'])) return [false, '批号不能为空'];
-//            if(empty($value['iQuantity']) || ! is_numeric($value['iQuantity'])) return [false, '存货数量错误'];
-//
-//            if(isset($result[$value['materialCode']])){
-//                $map = $result[$value['materialCode']];
-//                $update_detail = [
-//                    'CBATCH' => $value['lot'],
-//                    'FQUANTITY' => $value['iQuantity'],
-//                    'DPRODATE' => $productDate,
-//                    'DVDATE' => $failureDate,
-//                ];
-//                if(! isset($tmp[$value['materialCode']])){
-//                    $update[$map['AUTOID']] = $update_detail;
-//                    $tmp[$value['materialCode']] = $value['materialCode'];
-//                }else{
-//                    $map['AUTOID'] = null;
-//                    $insert[] = array_merge($map, $update_detail);
-//                }
-//            }
-//       }
-//
-//       list($status,$msg) = $service->checkInventoryControl(array_values(array_column($data['detail'],'materialCode')));
-//       if(! $status) return [false, $msg];
-//
-//       list($status, $msg) = $service->updateBjOrder($update, $insert);
-//       if(! $status) return [false, $msg];
-
        return [true, ''];
        return [true, ''];
     }
     }
 
 
@@ -549,7 +509,7 @@ class U8ThirdPartyService extends Service
            $detail_map[$value['materialCode']][] = [
            $detail_map[$value['materialCode']][] = [
 //               'productDate' => $productDate,
 //               'productDate' => $productDate,
                'failureDate' => $failureDate ?? null,
                'failureDate' => $failureDate ?? null,
-               'lot' => $value['lot'] ?? null,
+               'lot' => !empty($value['lot']) ? $value['lot'] : null,
                'iQuantity' => $value['iQuantity'],
                'iQuantity' => $value['iQuantity'],
            ];
            ];
        }
        }
@@ -625,8 +585,8 @@ class U8ThirdPartyService extends Service
 //                   "dMDate"          => (string)$value['productDate'],
 //                   "dMDate"          => (string)$value['productDate'],
                    "iSOsID"        => (int)$item['iSOsID'], // 强制转整型,去掉引号
                    "iSOsID"        => (int)$item['iSOsID'], // 强制转整型,去掉引号
                    "cBatch"        => $value['lot'],
                    "cBatch"        => $value['lot'],
-                   'cFree1' => $item['cFree1'],
-                   'cFree2' => $item['cFree2'],
+                   'cFree1' => !empty($item['cFree1']) ? $item['cFree1'] : null,
+                   'cFree2' => !empty($item['cFree2']) ? $item['cFree2'] : null,
                ];
                ];
            }
            }
        }
        }
@@ -1006,9 +966,9 @@ class U8ThirdPartyService extends Service
             "iNum"         => 0,                                   // 辅计数量
             "iNum"         => 0,                                   // 辅计数量
             "iNNum"        => 0,                                   // 生产订单辅计总数量
             "iNNum"        => 0,                                   // 生产订单辅计总数量
             "iMPoIds"      => (int)($order['SOURCEAUTOID'] ?? 0),   // 生产订单子表ID,必须是整型
             "iMPoIds"      => (int)($order['SOURCEAUTOID'] ?? 0),   // 生产订单子表ID,必须是整型
-            "cBatch"       => (string)($order['CBATCH'] ?? ''),
-            "dMadeDate"    => (string)($order['DPRODATE'] ?? ''),
-            "dVDate"       => (string)($order['DVDATE'] ?? ''),
+            "cBatch"       => $order['CBATCH'] ?? null,
+            "dMadeDate"    => $order['DPRODATE'] ?? null,
+            "dVDate"       => $order['DVDATE'] ?? null,
             'cFree1' => $order['CFREE1'] ?? null,
             'cFree1' => $order['CFREE1'] ?? null,
             'cFree2' => $order['CFREE2'] ?? null,
             'cFree2' => $order['CFREE2'] ?? null,
         ];
         ];
@@ -1071,8 +1031,8 @@ class U8ThirdPartyService extends Service
            "cBatch"       => $order['CBATCH'] ?? '',
            "cBatch"       => $order['CBATCH'] ?? '',
            "iinvexchrate" => $order['FCHANGRATE'] ?? 0,
            "iinvexchrate" => $order['FCHANGRATE'] ?? 0,
            "iQuantity"    => $num,   // 数量
            "iQuantity"    => $num,   // 数量
-           "dMadeDate"    => $order['DPRODATE'] ?? '', // 生产日期
-           "dVDate"       => $order['DVDATE'] ?? '',
+           "dMadeDate"    => $order['DPRODATE'] ?? null, // 生产日期
+           "dVDate"       => $order['DVDATE'] ?? null,
            'cFree1' => $order['CFREE1'] ?? null,
            'cFree1' => $order['CFREE1'] ?? null,
            'cFree2' => $order['CFREE2'] ?? null,
            'cFree2' => $order['CFREE2'] ?? null,
        ];
        ];
@@ -1169,9 +1129,9 @@ class U8ThirdPartyService extends Service
                         "fNatMoney"     => (float)$iMoney,       // 本币无税金额
                         "fNatMoney"     => (float)$iMoney,       // 本币无税金额
                         "fNatTax"       => (float)$iTax,         // 本币税额
                         "fNatTax"       => (float)$iTax,         // 本币税额
                         "fNatSum"       => (float)$iSum,         // 本币价税合计
                         "fNatSum"       => (float)$iSum,         // 本币价税合计
-                        "cBatch"        => (string)($order['CBATCH'] ?? ''),
-                        "dMadeDate"     => (string)($order['DPRODATE'] ?? ''),
-                        "dVDate"        => (string)($order['DVDATE'] ?? ''),
+                        "cBatch"        => $order['CBATCH'] ?? null,
+                        "dMadeDate"     => $order['DPRODATE'] ?? null,
+                        "dVDate"        => $order['DVDATE'] ?? null,
                         'cFree1' => $order['CFREE1'] ?? null,
                         'cFree1' => $order['CFREE1'] ?? null,
                         'cFree2' => $order['CFREE2'] ?? null,
                         'cFree2' => $order['CFREE2'] ?? null,
                     ]
                     ]