feat: 新增地址选择插件及订阅消息等多项功能优化
- 新增地址选择插件,支持地图位置选择并返回地址和经纬度 - 新增微信订阅消息发送功能,支持审核结果、提现通知等场景 - 新增订单支付状态查询、提现收款人姓名保存等接口 - 新增服务区域管理,支持按省市区划分并同步到信息发布 - 新增资金流水和营收报表导出功能 - 新增可用优惠券查询、订单退款拆分处理等功能 - 优化后台角标显示、首页数据统计、UI配置下发等 - 修复订单支付并发问题、地区管理逻辑等
这个提交包含在:
@@ -23,10 +23,11 @@ class Distribution extends V1
|
||||
$user = $this->auth();
|
||||
$uid = (int)$user['id'];
|
||||
|
||||
$total = (float)Db::name('fc_commission')->where('user_id', $uid)->sum('amount');
|
||||
$total = (float)Db::name('fc_commission')->where('user_id', $uid)->where('status', '<>', 2)->sum('amount');
|
||||
$settled = (float)Db::name('fc_commission')->where('user_id', $uid)->where('status', 1)->sum('amount');
|
||||
$pending = (float)Db::name('fc_commission')->where('user_id', $uid)->where('status', 0)->sum('amount');
|
||||
$applied = (float)Db::name('fc_withdraw')->where('user_id', $uid)
|
||||
->where('status', 'in', ['auditing', 'paid'])->sum('amount');
|
||||
->where('status', 'in', ['auditing', 'paying', 'paid'])->sum('amount');
|
||||
$withdrawable = $settled - $applied;
|
||||
|
||||
$todayStart = strtotime(date('Y-m-d'));
|
||||
@@ -38,10 +39,15 @@ class Distribution extends V1
|
||||
|
||||
$ext = $this->ext($uid);
|
||||
|
||||
// 商家转账确认收款页需要的商户号与小程序 AppID(非敏感,可下发)
|
||||
$epay = (array)get_addon_config('epay');
|
||||
$wx = isset($epay['wechat']) && is_array($epay['wechat']) ? $epay['wechat'] : [];
|
||||
|
||||
$this->ok([
|
||||
'totalCommission' => round($total, 2),
|
||||
'settled' => round($settled, 2),
|
||||
'withdrawable' => round($withdrawable, 2),
|
||||
'pendingCommission' => round($pending, 2),
|
||||
'withdrawable' => round(max(0, $withdrawable), 2),
|
||||
'todayCommission' => round($todayCommission, 2),
|
||||
'teamCount' => $l1 + $l2,
|
||||
'l1Count' => $l1,
|
||||
@@ -50,6 +56,10 @@ class Distribution extends V1
|
||||
'posterUrl' => '',
|
||||
// 最低提现金额(后台「分销设置」下发,替代前端写死的 50)
|
||||
'minWithdraw' => (float)$this->cfg('dist.minWithdraw', 50),
|
||||
// 提现收款人实名(未填写时前端需先采集)
|
||||
'realname' => isset($ext['realname']) ? (string)$ext['realname'] : '',
|
||||
'transferMchId' => isset($wx['mch_id']) ? (string)$wx['mch_id'] : '',
|
||||
'transferAppId' => isset($wx['miniapp_id']) ? (string)$wx['miniapp_id'] : '',
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -107,33 +117,54 @@ class Distribution extends V1
|
||||
{
|
||||
$user = $this->auth();
|
||||
$uid = (int)$user['id'];
|
||||
$amount = (float)$this->input('amount', 0);
|
||||
$this->rateLimit('withdraw:' . $uid, 3, 60);
|
||||
|
||||
$amount = round((float)$this->input('amount', 0), 2);
|
||||
$min = (float)$this->cfg('dist.minWithdraw', 50);
|
||||
|
||||
if ($amount <= 0) {
|
||||
$this->fail('提现金额不合法');
|
||||
}
|
||||
if ($amount > $this->withdrawable($uid)) {
|
||||
$this->fail('提现金额超过可提现余额');
|
||||
if ($min > 0 && $amount < $min) {
|
||||
$this->fail('最低提现金额为 ' . $min . ' 元');
|
||||
}
|
||||
|
||||
// 微信商家转账会校验收款人实名,未填写姓名不允许提现
|
||||
$ext = $this->ext($uid);
|
||||
if (trim((string)(isset($ext['realname']) ? $ext['realname'] : '')) === '') {
|
||||
$this->fail('请先填写收款人真实姓名(需与微信实名一致)');
|
||||
}
|
||||
|
||||
$channel = trim((string)$this->input('channel', ''));
|
||||
if ($channel === '') {
|
||||
$channel = 'wxpay';
|
||||
}
|
||||
$amount = round($amount, 2);
|
||||
$withdrawNo = $this->orderNo('WD');
|
||||
|
||||
Db::name('fc_withdraw')->insert([
|
||||
'withdraw_no' => $withdrawNo,
|
||||
'user_id' => $uid,
|
||||
'amount' => $amount,
|
||||
'channel' => $channel,
|
||||
'status' => 'auditing',
|
||||
'reason' => '',
|
||||
'paytime' => null,
|
||||
'createtime' => time(),
|
||||
'updatetime' => time(),
|
||||
]);
|
||||
try {
|
||||
Db::transaction(function () use ($uid, $amount, $channel, $withdrawNo) {
|
||||
// 用户扩展行加锁:同一用户的提现申请串行化,避免并发双花
|
||||
Db::name('fc_user_ext')->where('user_id', $uid)->lock(true)->find();
|
||||
|
||||
if ($amount > $this->withdrawable($uid)) {
|
||||
throw new \RuntimeException('提现金额超过可提现余额');
|
||||
}
|
||||
|
||||
Db::name('fc_withdraw')->insert([
|
||||
'withdraw_no' => $withdrawNo,
|
||||
'user_id' => $uid,
|
||||
'amount' => $amount,
|
||||
'channel' => $channel,
|
||||
'status' => 'auditing',
|
||||
'reason' => '',
|
||||
'paytime' => null,
|
||||
'createtime' => time(),
|
||||
'updatetime' => time(),
|
||||
]);
|
||||
});
|
||||
} catch (\Throwable $e) {
|
||||
$this->fail($e->getMessage() ?: '提现申请失败,请重试');
|
||||
}
|
||||
|
||||
$this->notify($uid, 'system', '提现申请已提交', '提现 ¥' . $amount . ' 已提交,预计 T+7 到账');
|
||||
|
||||
@@ -153,11 +184,14 @@ class Distribution extends V1
|
||||
$list = [];
|
||||
foreach ($rows as $row) {
|
||||
$list[] = [
|
||||
'id' => (int)$row['id'],
|
||||
'withdrawNo' => (string)$row['withdraw_no'],
|
||||
'amount' => round((float)$row['amount'], 2),
|
||||
'status' => (string)$row['status'],
|
||||
'createdAt' => $this->iso($row['createtime']),
|
||||
'id' => (int)$row['id'],
|
||||
'withdrawNo' => (string)$row['withdraw_no'],
|
||||
'amount' => round((float)$row['amount'], 2),
|
||||
'status' => (string)$row['status'],
|
||||
'transferStatus' => (string)(isset($row['transfer_status']) ? $row['transfer_status'] : ''),
|
||||
'packageInfo' => (string)(isset($row['package_info']) ? $row['package_info'] : ''),
|
||||
'failReason' => (string)(isset($row['fail_reason']) ? $row['fail_reason'] : ''),
|
||||
'createdAt' => $this->iso($row['createtime']),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -171,7 +205,7 @@ class Distribution extends V1
|
||||
{
|
||||
$settled = (float)Db::name('fc_commission')->where('user_id', $uid)->where('status', 1)->sum('amount');
|
||||
$applied = (float)Db::name('fc_withdraw')->where('user_id', $uid)
|
||||
->where('status', 'in', ['auditing', 'paid'])->sum('amount');
|
||||
->where('status', 'in', ['auditing', 'paying', 'paid'])->sum('amount');
|
||||
return $settled - $applied;
|
||||
}
|
||||
}
|
||||
|
||||
在新工单中引用
屏蔽一个用户