diff --git a/app/Console/Commands/SyncStoreReceiptOrderMatches.php b/app/Console/Commands/SyncStoreReceiptOrderMatches.php index 1e3b0a98..944d5d0a 100644 --- a/app/Console/Commands/SyncStoreReceiptOrderMatches.php +++ b/app/Console/Commands/SyncStoreReceiptOrderMatches.php @@ -1124,7 +1124,8 @@ class SyncStoreReceiptOrderMatches extends Command /** * 种菜订单号集合:种菜明细表的订单号 ∪ 聚水潭订单标签明细里「是否种菜订单=是」的订单号。 * - * 两个条件是「或」:订单号在任意一边出现过就算种菜订单(业务口径已确认)。 + * 「是否种菜订单=是」与页面同一规则:命中种菜标签映射,或订单货号含信誉订单虚拟条码(X00006)。 + * 三个条件是「或」:订单号在任意一边出现过就算种菜订单(业务口径已确认)。 * 两边都按键清洗后的「核心单号」比较(去掉日期前缀、空格、横杠),与账单侧同一套口径。 * * @return array @@ -1138,15 +1139,19 @@ class SyncStoreReceiptOrderMatches extends Command $positiveLabels[] = $label; } } - if ($positiveLabels === []) { - return []; - } - // 并集的第一部分:聚水潭订单标签明细里命中种菜映射的订单号 $cores = []; + + // 并集的第一部分:聚水潭订单标签明细里「是否种菜订单=是」的订单号 + // (命中种菜标签映射,或货号含信誉订单虚拟条码 X00006,与页面同一规则) foreach (DB::table('jst_order_labels') ->where('company_id', $companyId) - ->whereIn('label', $positiveLabels) + ->where(function ($query) use ($positiveLabels): void { + if ($positiveLabels !== []) { + $query->whereIn('label', $positiveLabels); + } + $query->orWhereRaw('FIND_IN_SET(?, item_code) > 0', [JstOrderLabelPlantingRules::PLANTING_ITEM_CODE]); + }) ->distinct() ->pluck('order_no') as $orderNo) { $core = self::orderCoreNo((string) $orderNo);