From 8ffcd58118fe2deefbfdac3acbf7dd0b8ba71a0f Mon Sep 17 00:00:00 2001 From: qiuxiang <394405259@qq.com> Date: Thu, 8 Oct 2026 11:26:40 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=8D=E8=8F=9C=E9=87=91=E9=A2=9D=E5=8F=A3?= =?UTF-8?q?=E5=BE=84=E6=94=B9=E4=B8=BA=E3=80=8C=E6=88=96=E3=80=8D=EF=BC=9A?= =?UTF-8?q?=E7=A7=8D=E8=8F=9C=E6=98=8E=E7=BB=86=E8=A1=A8=20=E2=88=AA=20?= =?UTF-8?q?=E8=81=9A=E6=B0=B4=E6=BD=AD=E7=A7=8D=E8=8F=9C=E6=A0=87=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 之前两个条件是「与」(交集),导致聚水潭没打种菜标签的淘系订单全部为空。按业务确认改成或:订单号在「种菜明细表」或「聚水潭订单标签明细(是否种菜订单=是)」任意一边出现过,就取该订单的收入金额。同步更新页面描述与迁移注释。 --- .../Commands/SyncStoreReceiptOrderMatches.php | 24 +++++++++---------- config/business_navigation.php | 2 +- ...ount_to_store_receipt_order_match_rows.php | 4 ++-- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/app/Console/Commands/SyncStoreReceiptOrderMatches.php b/app/Console/Commands/SyncStoreReceiptOrderMatches.php index 79746ee6..c8d71398 100644 --- a/app/Console/Commands/SyncStoreReceiptOrderMatches.php +++ b/app/Console/Commands/SyncStoreReceiptOrderMatches.php @@ -262,7 +262,7 @@ class SyncStoreReceiptOrderMatches extends Command $incomeTotal = 0.0; $discountTotal = 0.0; $offsetTotal = 0.0; - // 种菜订单号:种菜明细表的订单号 ∩ 聚水潭订单标签明细里「是否种菜订单=是」的订单号。 + // 种菜订单号:种菜明细表的订单号 ∪ 聚水潭订单标签明细里「是否种菜订单=是」的订单号(或的关系)。 $plantingCores = $this->plantingOrderCores(); $plantingTotal = 0.0; $plantingRows = 0; @@ -744,8 +744,9 @@ class SyncStoreReceiptOrderMatches extends Command } /** - * 种菜订单号集合:种菜明细表的订单号 ∩ 聚水潭订单标签明细里「是否种菜订单=是」的订单号。 + * 种菜订单号集合:种菜明细表的订单号 ∪ 聚水潭订单标签明细里「是否种菜订单=是」的订单号。 * + * 两个条件是「或」:订单号在任意一边出现过就算种菜订单(业务口径已确认)。 * 两边都按键清洗后的「核心单号」比较(去掉日期前缀、空格、横杠),与账单侧同一套口径。 * * @return array @@ -763,31 +764,28 @@ class SyncStoreReceiptOrderMatches extends Command return []; } - // 聚水潭订单标签明细:命中种菜映射的订单号 - $labelled = DB::table('jst_order_labels') + // 并集的第一部分:聚水潭订单标签明细里命中种菜映射的订单号 + $cores = []; + foreach (DB::table('jst_order_labels') ->where('company_id', $companyId) ->whereIn('label', $positiveLabels) ->distinct() - ->pluck('order_no'); - - $cores = []; - foreach ($labelled as $orderNo) { + ->pluck('order_no') as $orderNo) { $core = self::orderCoreNo((string) $orderNo); if ($core !== '') { $cores[$core] = true; } } - // 种菜明细表:只有两边都出现才算种菜订单 - $matched = []; + // 并集的第二部分:种菜明细表里的订单号 foreach (DB::table('planting_details')->where('company_id', $companyId)->distinct()->pluck('order_no') as $orderNo) { $core = self::orderCoreNo((string) $orderNo); - if ($core !== '' && isset($cores[$core])) { - $matched[$core] = true; + if ($core !== '') { + $cores[$core] = true; } } - return $matched; + return $cores; } private static function orderCoreNo(string $value): string diff --git a/config/business_navigation.php b/config/business_navigation.php index 6e34ff5d..31d4ba43 100644 --- a/config/business_navigation.php +++ b/config/business_navigation.php @@ -787,7 +787,7 @@ $navigation = [ 'directory' => [ 'icon' => 'receipt_long', 'status' => '共享镜像', - 'description' => '覆盖店铺收款账户账单各平台页签(总账备注=订单收入),按「店铺 + 订单号」匹配订单侧商品金额;一行 = 一个店铺的一个订单,商品金额只挂一次。「优惠金额」「冲减金额」另取总账备注=优惠收入 / 冲减收入的账单金额,不计入收入金额;「种菜金额」是订单号同时出现在种菜明细表和聚水潭订单标签明细(是否种菜订单=是)里时该订单的收入金额,只是收入金额里的一部分,不参与差额;差额=(收入金额+优惠金额+冲减金额)−商品金额,只反映真正对不上的部分。', + 'description' => '覆盖店铺收款账户账单各平台页签(总账备注=订单收入),按「店铺 + 订单号」匹配订单侧商品金额;一行 = 一个店铺的一个订单,商品金额只挂一次。「优惠金额」「冲减金额」另取总账备注=优惠收入 / 冲减收入的账单金额,不计入收入金额;「种菜金额」是订单号在种菜明细表或聚水潭订单标签明细(是否种菜订单=是)任意一边出现过时,该订单的收入金额(两个条件是或的关系),只是收入金额里的一部分,不参与差额;差额=(收入金额+优惠金额+冲减金额)−商品金额,只反映真正对不上的部分。', 'empty' => '店铺收款匹配订单明细尚未同步,请先执行 store-receipt:order-match:sync。', 'fields' => [ ['name' => 'platform', 'label' => '平台'], diff --git a/database/migrations/2026_10_08_100000_add_planting_amount_to_store_receipt_order_match_rows.php b/database/migrations/2026_10_08_100000_add_planting_amount_to_store_receipt_order_match_rows.php index ab9b2d93..887d10ee 100644 --- a/database/migrations/2026_10_08_100000_add_planting_amount_to_store_receipt_order_match_rows.php +++ b/database/migrations/2026_10_08_100000_add_planting_amount_to_store_receipt_order_match_rows.php @@ -6,8 +6,8 @@ use Illuminate\Support\Facades\Schema; /** * 业绩明细新增「种菜金额」列(放在冲减金额后面): - * 订单号同时出现在「种菜明细表」和「聚水潭订单标签明细(是否种菜订单=是)」里时, - * 该订单的收入金额就是种菜金额;只展示,不参与差额计算(差额口径保持 + * 订单号在「种菜明细表」或「聚水潭订单标签明细(是否种菜订单=是)」任意一边出现过时, + * 该订单的收入金额就是种菜金额(两个条件是或的关系);只展示,不参与差额计算(差额口径保持 * (收入金额+优惠金额+冲减金额)−商品金额,种菜金额本身就是收入金额的一部分)。 */ return new class extends Migration