feat(shopro_wechat_trade): 新增微信发货一律自提功能 - 添加 shipping_force_self_pickup 配置项,默认开启,用于控制 upload_shipping_info 时固定使用 logistics_type=4(用户自提) - 修改 WxShippingPayload 类,新增 resolveLogisticsType 和 shouldUseExpressTracking 方法处理自提逻辑 - 更新配置页面添加自提开关组件及说明 - 修改数据库操作逻辑,支持配置项不存在时的插入操作 - 在 README.md 中补充相关命令行工具使用说明和配置说明 - 更新安装脚本添加默认配置值 ```
79 行
2.5 KiB
PHP
79 行
2.5 KiB
PHP
<?php
|
|
|
|
namespace app\admin\controller\shopro_wechat_trade;
|
|
|
|
use addons\shopro_wechat_trade\library\WxOrderPathService;
|
|
use addons\shopro_wechat_trade\library\WxTradeConfig;
|
|
use app\common\controller\Backend;
|
|
use think\Db;
|
|
|
|
class Config extends Backend
|
|
{
|
|
public function index()
|
|
{
|
|
if ($this->request->isAjax()) {
|
|
$list = Db::name('shopro_wechat_trade_config')->select();
|
|
$data = [];
|
|
foreach ($list as $item) {
|
|
$data[$item['name']] = $item['value'];
|
|
}
|
|
$mini = Db::name('shopro_config')->where('name', 'wxMiniProgram')->value('value');
|
|
$mini = json_decode($mini, true);
|
|
$data['mini_program_app_id'] = $mini['app_id'] ?? '';
|
|
return $this->success('操作成功', null, $data);
|
|
}
|
|
return $this->view->fetch();
|
|
}
|
|
|
|
public function save()
|
|
{
|
|
$params = $this->request->post('row/a');
|
|
if (!$params) {
|
|
$this->error('参数错误');
|
|
}
|
|
foreach ($params as $name => $value) {
|
|
if ($name === 'mini_program_app_id') {
|
|
continue;
|
|
}
|
|
$exists = Db::name('shopro_wechat_trade_config')->where('name', $name)->find();
|
|
if ($exists) {
|
|
Db::name('shopro_wechat_trade_config')->where('name', $name)->update(['value' => $value]);
|
|
} else {
|
|
Db::name('shopro_wechat_trade_config')->insert([
|
|
'name' => $name,
|
|
'value' => $value,
|
|
'group' => 'basic',
|
|
'description' => '',
|
|
]);
|
|
}
|
|
}
|
|
WxTradeConfig::reload();
|
|
$this->success('保存成功');
|
|
}
|
|
|
|
public function check()
|
|
{
|
|
try {
|
|
$pathService = new WxOrderPathService();
|
|
$managed = $pathService->isTradeManaged();
|
|
$path = $pathService->getPath();
|
|
$this->success('检测完成', null, [
|
|
'is_trade_managed' => $managed,
|
|
'order_detail_path' => $path,
|
|
]);
|
|
} catch (\Exception $e) {
|
|
$this->error('检测失败:' . $e->getMessage());
|
|
}
|
|
}
|
|
|
|
public function initPath()
|
|
{
|
|
try {
|
|
$result = (new WxOrderPathService())->updatePath();
|
|
$this->success('订单详情路径已配置', null, $result);
|
|
} catch (\Exception $e) {
|
|
$this->error('配置失败:' . $e->getMessage());
|
|
}
|
|
}
|
|
}
|