转账功能优化
This commit is contained in:
@@ -163,13 +163,19 @@ class AccountWithdrawService
|
||||
AccountService::updateData($userId, 0, -$amount, 0,0, $log_res->id);
|
||||
|
||||
if($type == AccountWithdrawService::TYPE_WECHAT){
|
||||
//发起微信商家转账到用户零钱(v3,原 v2 企业付款已停用)
|
||||
$payRes = (new EasyWeChatService())->mchPay($withdraw_record->apply_sn, $user->openid, $user->username, $amount);
|
||||
if (empty($payRes['batch_id'])) {
|
||||
//免确认收款授权校验:未授权无法以授权单发起转账
|
||||
$auth = TransferAuthorizationService::getByUserId($userId);
|
||||
if (!TransferAuthorizationService::isAuthorized($userId)) {
|
||||
throw new \Exception('该用户未完成免确认收款授权,无法发起转账,请通知用户在小程序余额页完成授权后重新审核');
|
||||
}
|
||||
//发起微信商家转账到用户零钱(v3授权转账:以授权单定位收款人,免用户确认收款)
|
||||
$payRes = (new EasyWeChatService())->mchPay($withdraw_record->apply_sn, $user->username, $amount, $auth->out_authorization_no);
|
||||
//以 transfer_bill_no(微信转账单号) 判断单据是否创建成功
|
||||
if (empty($payRes['transfer_bill_no'])) {
|
||||
throw new \Exception($payRes['message'] ?? '商家转账发起失败');
|
||||
}
|
||||
//批次受理成功(资金到账以微信侧为准,可通过 queryBalance 查询批次状态)
|
||||
$withdraw_record->result_status = 'SUCCESS';
|
||||
//授权转账免用户确认,状态记为微信返回的 state,最终以回调/查单为准
|
||||
$withdraw_record->result_status = $payRes['state'] ?? '';
|
||||
$withdraw_record->save();
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user