feat(withdraw): 落地方案B一体化商城余额提现与手续费内扣模式,完善多端打款退款与对账闭环
这个提交包含在:
@@ -163,15 +163,41 @@ class Pay extends Common
|
||||
// 微信公众号,小程序支付,必须有 openid
|
||||
if ($payment == 'wechat') {
|
||||
if (in_array($platform, ['WechatOfficialAccount', 'WechatMiniProgram'])) {
|
||||
$targetPlatform = lcfirst(str_replace('Wechat', '', $platform));
|
||||
if (isset($openid) && $openid) {
|
||||
// 如果传的有 openid
|
||||
$order_data['payer']['openid'] = $openid;
|
||||
|
||||
// 自愈绑定:若当前用户在 third_oauth 中尚无对应平台的绑定记录,自动补建
|
||||
if ($platform == 'WechatMiniProgram') {
|
||||
$oauth = \app\admin\model\shopro\ThirdOauth::where([
|
||||
'user_id' => $order->user_id,
|
||||
'provider' => 'wechat',
|
||||
'platform' => $targetPlatform
|
||||
])->find();
|
||||
if (!$oauth) {
|
||||
$existOauth = \app\admin\model\shopro\ThirdOauth::getByOpenid($openid);
|
||||
if (!$existOauth) {
|
||||
\app\admin\model\shopro\ThirdOauth::create([
|
||||
'user_id' => $order->user_id,
|
||||
'provider' => 'wechat',
|
||||
'platform' => $targetPlatform,
|
||||
'openid' => $openid,
|
||||
'createtime' => time(),
|
||||
'updatetime' => time(),
|
||||
]);
|
||||
} elseif ($existOauth->user_id == 0) {
|
||||
$existOauth->user_id = $order->user_id;
|
||||
$existOauth->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 没有 openid 默认拿下单人的 openid
|
||||
$oauth = \app\admin\model\shopro\ThirdOauth::where([
|
||||
'user_id' => $order->user_id,
|
||||
'provider' => 'Wechat',
|
||||
'platform' => lcfirst(str_replace('Wechat', '', $platform))
|
||||
'user_id' => $order->user_id,
|
||||
'provider' => 'wechat',
|
||||
'platform' => $targetPlatform
|
||||
])->find();
|
||||
|
||||
$order_data['payer']['openid'] = $oauth ? $oauth->openid : '';
|
||||
|
||||
在新工单中引用
屏蔽一个用户