|
|
@@ -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)
|
|
|
{
|