问题说明:
分销佣金打款开启微信自动打款后,前端提现有银行卡提现和微信提现,用户选择银行卡提现,财务银行卡打完款后,后台点击确认打款,结果微信又自动给他打过去了一笔钱
修改文件:app/services/user/UserExtractServices.php
修复方法:changeSuccess
public function changeSuccess(int $id, $userExtract)
{
$extractNumber = $userExtract['extract_price'];
$this->transaction(function () use ($id, $userExtract, $extractNumber) {
if (!$this->dao->update($id, ['status' => 1])) {
throw new AdminException('修改失败');
}
//配置开启自动到零钱
if (sys_config('brokerage_type', 0) && $userExtract['extract_type'] == 'weixin') {
/** @var WechatUserServices $wechatServices */
$wechatServices = app()->make(WechatUserServices::class);
$openid = $wechatServices->getWechatOpenid((int)$userExtract['uid'], 'wechat');
if ($openid) {//公众号用户
$type = Payment::WEB;
} else {//小程序用户
$openid = $wechatServices->getWechatOpenid((int)$userExtract['uid'], 'routine');
$type = Payment::MINI;
}
//app微信用户
if (!$openid) {
$openid = $wechatServices->getWechatOpenid((int)$userExtract['uid'], 'app');
$type = Payment::APP;
}
if ($openid) {
/** @var StoreOrderCreateServices $services */
$services = app()->make(StoreOrderCreateServices::class);
$wechat_order_id = $services->getNewOrderId();
$res = Payment::merchantPay($openid, $wechat_order_id, $extractNumber, '提现佣金到零钱', $type);
if (!$res) {
throw new ValidateException('企业付款到零钱失败,请稍后再试');
}
} else {
throw new ValidateException('该用户暂不支持企业付款到零钱,请手动转账');
}
}
});
/** @var UserServices $userServices */
$userServices = app()->make(UserServices::class);
$userType = $userServices->value(['uid' => $userExtract['uid']], 'user_type');
$nickname = $userServices->value(['uid' => $userExtract['uid']], 'nickname');
$phone = $userServices->value(['uid' => $userExtract['uid']], 'phone');
switch ($userExtract['extract_type']) {
case 'bank':
$order_id = $userExtract['bank_code'];
break;
case 'weixin':
$order_id = $userExtract['wechat'];
break;
case 'alipay':
$order_id = $userExtract['alipay_code'];
break;
default:
$order_id = '';
break;
}
//记录资金流水队列
CapitalFlowJob::dispatch([['order_id' => $order_id, 'store_id' => 0, 'uid' => $userExtract['uid'], 'nickname' => $nickname, 'phone' => $phone, 'price' => $extractNumber, 'pay_type' => $userExtract['extract_type']], 'extract']);
//消息推送
event('notice.notice', [['uid' => $userExtract['uid'], 'userType' => strtolower($userType), 'extractNumber' => $extractNumber, 'nickname' => $nickname], 'user_extract']);
return true;
}