浏览代码

得润宝

cqp 14 小时之前
父节点
当前提交
968cc9dab9

+ 2 - 1
app/Console/Commands/U8Settle.php

@@ -52,6 +52,7 @@ class U8Settle extends Command
     //]
     public function settle(){
         $service = new U8ThirtyPartyDatabaseServerService();
+//        $a =$service->insertUnAccountVouch('接口生成');dd($a);
 //        $minPeriods = $this->getYjData();
 //        if(empty($minPeriods['pu_date']) || empty($minPeriods['st_date']) || empty($minPeriods['sa_date'])) {
 //            Log::channel('u8_daily')->info('月结数据为空', ['msg' => $minPeriods]);
@@ -98,7 +99,7 @@ class U8Settle extends Command
                 'son_field' => [
                     'detail.ID as id',
 //                    'detail.ivouchrowno as lineNum',
-//                    'detail.cWhCode as warehouseCode',
+                    'detail.cWhCode as warehouseCode',
                     'detail.cInvCode as materialCode',
                     'detail.iQuantity as planQty',
                     'detail.cDefine23',

+ 9 - 1
app/Http/Controllers/Api/TestController.php

@@ -7,6 +7,14 @@ use App\Model\Record;
 
 class TestController extends BaseController
 {
-    public function aa(){
+    public function aa(){dd(2);
+        $result = Record::where('del_time',2)
+            ->where('result', 'LIKE', '%'.'数据库连接'.'%')
+            ->get()->toArray();
+        foreach ($result as $value){
+            ProcessDataJob::dispatch($value)->onQueue(Record::$job);
+        }
+
+        dd(1);
     }
 }

+ 1 - 0
app/Jobs/ProcessWMSDataJob.php

@@ -110,6 +110,7 @@ class ProcessWMSDataJob implements ShouldQueue
                     $jsonBody['details'][] = [
                         'lineNum'       => $item['lineNum'] ?? 0,
                         'materialCode'  => $item['materialCode'] ?? '',
+                        'warehouseCode'  => $item['warehouseCode'] ?? '', //采购到货有仓库编码
                         'planQty'       => (float)abs($item['planQty']),
                         'productDate'       => $productDate,
                         'validTime'       => $validTime,

+ 4 - 0
app/Service/U8ThirdPartyService.php

@@ -161,6 +161,8 @@ class U8ThirdPartyService extends Service
             $newRow['cBatch']       = $value['lot'] ?? null;
             $newRow['dPDate'] = !empty($value['productDate']) ? $this->formatAndValidateDate($value['productDate']) : null;
             $newRow['dVDate'] = !empty($value['failureDate']) ? $this->formatAndValidateDate($value['failureDate']) : null;
+            $newRow['cFree1'] = $value['param_one'] ?? null; //锥入度
+            $newRow['cFree2'] = $value['param_two'] ?? null; //包装规格
 
             $insertData[] = $newRow;
         }
@@ -269,6 +271,8 @@ class U8ThirdPartyService extends Service
             // 生产日期与失效日期 (U8 领料申请单通常字段名为 dMadeDate 和 dVDate 或 dmadedate)
             $newRow['dMadeDate'] = !empty($value['productDate']) ? $this->formatAndValidateDate($value['productDate']) : null;
             $newRow['dVDate'] = !empty($value['failureDate']) ? $this->formatAndValidateDate($value['failureDate']) : null;
+            $newRow['cFree1'] = $value['param_one'] ?? null; //锥入度
+            $newRow['cFree2'] = $value['param_two'] ?? null; //包装规格
 
             $insertData[] = $newRow;
         }

+ 50 - 0
app/Service/U8ThirtyPartyDatabaseServerService.php

@@ -36,6 +36,56 @@ class U8ThirtyPartyDatabaseServerService extends Service
         return $conn;
     }
 
+    /**
+     * 写入分期收款发出商品未记账表 (IA_SA_UnAccountVouch)
+     * @param string $cMemo 对应发货单备注中的接口标识
+     * @return array
+     */
+    public function insertUnAccountVouch($cMemo)
+    {
+        try {
+            $db = $this->safeDb();
+
+            return $db->transaction(function () use ($db, $cMemo) {
+                // 1. 模拟查询:关联发货单主子表,找到需要处理的数据
+                // U8 中 DispatchList 是发货单主表,DispatchLists 是子表
+                $pendingData = $db->table('DispatchList as H')
+                    ->join('DispatchLists as D', 'H.DLID', '=', 'D.DLID')
+                    ->where('H.cMemo', $cMemo)
+                    ->where('H.dDate', '<=', '2026-03-31')
+                    ->select([
+                        'H.DLID as IDUN',       // 发货单主表ID
+                        'D.iDLsid as IDSUN',    // 发货单子表ID
+                    ])
+                    ->get();
+
+                if ($pendingData->isEmpty()) {
+                    return [false, "未找到备注为 {$cMemo} 的发货单数据"];
+                }
+
+                $insertData = [];
+                foreach ($pendingData as $row) {
+                    $insertData[] = [
+                        'IDUN'       => $row->IDUN,
+                        'IDSUN'      => $row->IDSUN,
+                        'cVouTypeUN' => '05',       // 写死固定值
+                        'cBustypeUN' => '分期收款',  // 写死固定值
+                        // 如果该表有其他必填字段(如日期、仓库等),请在此补充
+                    ];
+                }
+
+                // 2. 执行批量插入
+                if (!empty($insertData)) {
+                    $db->table('IA_SA_UnAccountVouch')->insert($insertData);
+                }
+
+                return [true, "成功写入 " . count($insertData) . " 条数据"];
+            });
+        } catch (\Throwable $e) {
+            return [false, "写入 IA_SA_UnAccountVouch 失败: " . $e->getMessage()];
+        }
+    }
+
     // Service 内部查询
     public function getPendingBills($config, $lastId)
     {