問題說明:
分銷傭金打款開啟微信自動打款后,前端提現有銀行卡提現和微信提現,用戶選擇銀行卡提現,財務銀行卡打完款后,后臺點擊確認打款,結果微信又自動給他打過去了一筆錢
修改文件: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;
}