feat(shopro_wechat_trade): 新增微信发货一律自提功能 - 添加 shipping_force_self_pickup 配置项,默认开启,用于控制 upload_shipping_info 时固定使用 logistics_type=4(用户自提) - 修改 WxShippingPayload 类,新增 resolveLogisticsType 和 shouldUseExpressTracking 方法处理自提逻辑 - 更新配置页面添加自提开关组件及说明 - 修改数据库操作逻辑,支持配置项不存在时的插入操作 - 在 README.md 中补充相关命令行工具使用说明和配置说明 - 更新安装脚本添加默认配置值 ```
77 行
1.7 KiB
PHP
77 行
1.7 KiB
PHP
<?php
|
|
|
|
namespace addons\shopro_wechat_trade\library;
|
|
|
|
use think\Db;
|
|
|
|
class WxTradeConfig
|
|
{
|
|
protected static $instance;
|
|
protected $values = [];
|
|
|
|
public static function getInstance()
|
|
{
|
|
if (!self::$instance) {
|
|
self::$instance = new self();
|
|
}
|
|
return self::$instance;
|
|
}
|
|
|
|
public static function reload()
|
|
{
|
|
self::$instance = null;
|
|
return self::getInstance();
|
|
}
|
|
|
|
protected function __construct()
|
|
{
|
|
try {
|
|
$rows = Db::name('shopro_wechat_trade_config')->select();
|
|
foreach ($rows as $row) {
|
|
$this->values[$row['name']] = $row['value'];
|
|
}
|
|
} catch (\Exception $e) {
|
|
$this->values = [];
|
|
}
|
|
}
|
|
|
|
public function get($name, $default = '')
|
|
{
|
|
return array_key_exists($name, $this->values) ? $this->values[$name] : $default;
|
|
}
|
|
|
|
public function all()
|
|
{
|
|
return $this->values;
|
|
}
|
|
|
|
public function getOrderDetailPath()
|
|
{
|
|
$path = trim($this->get('order_detail_path', WxOrderPathService::defaultPath()));
|
|
if ($path === '') {
|
|
$path = WxOrderPathService::defaultPath();
|
|
}
|
|
return $path;
|
|
}
|
|
|
|
public function getMaxRetry()
|
|
{
|
|
$v = intval($this->get('max_retry', 5));
|
|
return $v > 0 ? $v : 5;
|
|
}
|
|
|
|
public function getRetryInterval()
|
|
{
|
|
$v = intval($this->get('retry_interval', 300));
|
|
return $v > 0 ? $v : 300;
|
|
}
|
|
|
|
/**
|
|
* upload_shipping_info 是否一律按「用户自提」(logistics_type=4),与商城 dispatch_type 无关
|
|
*/
|
|
public function shippingForceSelfPickup()
|
|
{
|
|
return $this->get('shipping_force_self_pickup', '1') === '1';
|
|
}
|
|
}
|