```
feat(shopro_wechat_trade): 新增微信发货一律自提功能 - 添加 shipping_force_self_pickup 配置项,默认开启,用于控制 upload_shipping_info 时固定使用 logistics_type=4(用户自提) - 修改 WxShippingPayload 类,新增 resolveLogisticsType 和 shouldUseExpressTracking 方法处理自提逻辑 - 更新配置页面添加自提开关组件及说明 - 修改数据库操作逻辑,支持配置项不存在时的插入操作 - 在 README.md 中补充相关命令行工具使用说明和配置说明 - 更新安装脚本添加默认配置值 ```
这个提交包含在:
@@ -18,6 +18,24 @@ class WxShippingPayload
|
||||
return self::$logisticsMap[$dispatchType] ?? 1;
|
||||
}
|
||||
|
||||
/** 同步微信发货时使用的 logistics_type(1 快递 2 同城 3 虚拟 4 自提) */
|
||||
public static function resolveLogisticsType($dispatchType)
|
||||
{
|
||||
if (WxTradeConfig::getInstance()->shippingForceSelfPickup()) {
|
||||
return 4;
|
||||
}
|
||||
return self::mapLogisticsType($dispatchType);
|
||||
}
|
||||
|
||||
public static function shouldUseExpressTracking(array $item)
|
||||
{
|
||||
if (WxTradeConfig::getInstance()->shippingForceSelfPickup()) {
|
||||
return false;
|
||||
}
|
||||
$dispatchType = $item['dispatch_type'] ?? 'express';
|
||||
return in_array($dispatchType, ['express', 'store'], true);
|
||||
}
|
||||
|
||||
public static function buildUploadPayload($order, array $items, $triggerItem = null)
|
||||
{
|
||||
$transactionId = WxOrderContext::resolveTransactionId($order);
|
||||
@@ -37,7 +55,8 @@ class WxShippingPayload
|
||||
$allItems = self::filterAllActiveItems($items);
|
||||
$deliveryMode = count($shippableItems) >= count($allItems) ? 1 : 2;
|
||||
|
||||
$logisticsType = self::mapLogisticsType($triggerItem['dispatch_type'] ?? ($shippableItems[0]['dispatch_type'] ?? 'express'));
|
||||
$dispatchHint = $triggerItem['dispatch_type'] ?? ($shippableItems[0]['dispatch_type'] ?? 'express');
|
||||
$logisticsType = self::resolveLogisticsType($dispatchHint);
|
||||
$shippingList = [];
|
||||
foreach ($shippableItems as $item) {
|
||||
$shippingList[] = self::buildShippingListItem($item, $order);
|
||||
@@ -93,11 +112,10 @@ class WxShippingPayload
|
||||
|
||||
protected static function buildShippingListItem(array $item, $order)
|
||||
{
|
||||
$dispatchType = $item['dispatch_type'] ?? 'express';
|
||||
$desc = mb_substr($item['goods_title'] ?? '商城商品', 0, 120);
|
||||
$entry = ['item_desc' => $desc];
|
||||
|
||||
if (in_array($dispatchType, ['express', 'store'], true)) {
|
||||
if (self::shouldUseExpressTracking($item)) {
|
||||
$trackingNo = trim((string) ($item['express_no'] ?? ''));
|
||||
$expressCode = WxExpressMapper::toWechatCode($item['express_code'] ?? '');
|
||||
if ($trackingNo === '') {
|
||||
|
||||
在新工单中引用
屏蔽一个用户