feat: 新增地址选择插件及订阅消息等多项功能优化

- 新增地址选择插件,支持地图位置选择并返回地址和经纬度
- 新增微信订阅消息发送功能,支持审核结果、提现通知等场景
- 新增订单支付状态查询、提现收款人姓名保存等接口
- 新增服务区域管理,支持按省市区划分并同步到信息发布
- 新增资金流水和营收报表导出功能
- 新增可用优惠券查询、订单退款拆分处理等功能
- 优化后台角标显示、首页数据统计、UI配置下发等
- 修复订单支付并发问题、地区管理逻辑等
这个提交包含在:
2026-10-22 17:14:56 +08:00
父节点 088a08d43a
当前提交 cb12bf5fc8
共有 180 个文件被更改,包括 9695 次插入 和 1680 次删除

查看文件

@@ -13,6 +13,13 @@ use think\Db;
*/
class AdminOrder extends V1
{
/** 管理端接口必须校验管理员身份(V1 默认关闭了 URI 权限校验) */
public function _initialize()
{
parent::_initialize();
$this->adminOnly();
}
/**
* AO1 订单列表
* GET /api/v1/admin/orders 入参 {type?,page,size}
@@ -63,28 +70,24 @@ class AdminOrder extends V1
public function refund()
{
$id = (int)$this->request->param('id', 0);
$amount = round((float)$this->input('amount', 0), 2);
$amount = $this->input('amount', null);
$reason = trim((string)$this->input('reason', ''));
$amount = ($amount === null || $amount === '') ? null : (float)$amount;
if ($amount <= 0) {
$this->fail('退款金额需大于 0');
try {
$res = \app\common\library\OrderRefund::refund($id, $amount, $reason);
} catch (\Throwable $e) {
$this->fail($e->getMessage());
}
$order = Db::name('fc_order')->where('id', $id)->find();
if (!$order) {
$this->fail('订单不存在', 404);
}
$this->adminLog('订单退款 #' . $id . ' 金额' . $res['amount'] . ' 退款单号' . $res['refundNo']);
Db::name('fc_order')->where('id', $id)->update([
'status' => 'refunded',
'refund_amount' => $amount,
'refund_reason' => $reason,
$this->ok([
'id' => $id,
'refunded' => true,
'refundNo' => $res['refundNo'],
'amount' => $res['amount'],
]);
$this->notify($order['user_id'], 'system', '订单已退款', '您的订单「' . $order['title'] . '」已退款 ' . $amount . ' 元。');
$this->adminLog('订单退款 #' . $id . ' 金额' . $amount);
$this->ok(['id' => (int)$id, 'refunded' => true]);
}
/**
@@ -104,15 +107,44 @@ class AdminOrder extends V1
$this->fail('订单不存在', 404);
}
if ($order['status'] !== 'paid') {
Db::name('fc_order')->where('id', $order['id'])->update([
'status' => 'paid',
'paytime' => time(),
]);
$this->flow('income', '订单补单', $order['amount'], 0, $order['id']);
$this->adminLog('订单补单 #' . $orderNo);
if ((string)$order['status'] === 'paid') {
$this->ok(['orderNo' => (string)$orderNo, 'supplemented' => false], '订单已支付,无需补单');
}
if ((string)$order['status'] !== 'pending') {
$this->fail('订单状态不支持补单(当前:' . $order['status'] . ')');
}
$this->ok(['orderNo' => (string)$orderNo, 'supplemented' => true]);
$now = time();
$handled = false;
try {
Db::transaction(function () use ($order, $now, &$handled) {
$locked = Db::name('fc_order')->where('id', (int)$order['id'])->lock(true)->find();
if (!$locked || (string)$locked['status'] !== 'pending') {
return;
}
$affected = Db::name('fc_order')
->where('id', (int)$order['id'])
->where('status', 'pending')
->update(['status' => 'paid', 'paytime' => $now, 'updatetime' => $now]);
if (!$affected) {
return;
}
$locked['status'] = 'paid';
$locked['paytime'] = $now;
$handled = true;
// 补单必须真正发货:会员发放 / 余额入账 / 付费查看解锁,不能只改状态
\app\common\library\OrderFulfill::handle($locked);
});
} catch (\Throwable $e) {
\think\Log::record('补单失败:订单 ' . $orderNo . ',' . $e->getMessage(), 'error');
$this->fail('补单失败:' . $e->getMessage());
}
$this->adminLog('订单补单 #' . $orderNo . ($handled ? '' : '(幂等命中)'));
$this->ok(['orderNo' => (string)$orderNo, 'supplemented' => $handled]);
}
}