Browse Source

Merge branch 'hotfix_orderonline'

master
Mr. Shuixiang 5 years ago
parent
commit
1f4bc11b3c
  1. 15
      app/Service/v3/Implementations/PaymentService.php

15
app/Service/v3/Implementations/PaymentService.php

@ -169,6 +169,10 @@ class PaymentService implements PaymentServiceInterface
$app = Factory::payment($config); $app = Factory::payment($config);
$app['guzzle_handler'] = CoroutineHandler::class; $app['guzzle_handler'] = CoroutineHandler::class;
// 特殊原因如资金不够等,发短信给老板或者老总
$redis = ApplicationContext::getContainer()->get(Redis::class);
$refuseReasonForSpecialKey = 'send_withdraw_refuse_reson_'.date('Ymd');
$result = $app->transfer->toBalance([ $result = $app->transfer->toBalance([
'partner_trade_no' => $tradeNo, // 商户订单号,需保持唯一性(只能是字母或者数字,不能包含有符号) 'partner_trade_no' => $tradeNo, // 商户订单号,需保持唯一性(只能是字母或者数字,不能包含有符号)
'openid' => $openId, 'openid' => $openId,
@ -192,9 +196,12 @@ class PaymentService implements PaymentServiceInterface
// 如果是商户余额不足等原因,要发送短信给老总 // 如果是商户余额不足等原因,要发送短信给老总
$arr = ['NOTENOUGH','AMOUNT_LIMIT','NO_AUTH']; $arr = ['NOTENOUGH','AMOUNT_LIMIT','NO_AUTH'];
if (in_array($result['err_code'], $arr)) { if (in_array($result['err_code'], $arr)) {
$redis = ApplicationContext::getContainer()->get(Redis::class);
if (!$redis->exists('send_withdraw_refuse_reson_'.date('Ymd'))) {
$this->smsAliSendService->doWithdrawFail($result['err_code'], $result['err_code_des']);
if (!$redis->exists($refuseReasonForSpecialKey)) { // 当天如果没发过就发
$res = $this->smsAliSendService->doWithdrawFail($result['err_code'], $result['err_code_des']);
if (isset($res['Code']) && $res['Code'] == 'OK') {
$redis->set($refuseReasonForSpecialKey, $result['err_code'].'/'.$result['err_code_des']);
}
} }
} }
@ -223,6 +230,8 @@ class PaymentService implements PaymentServiceInterface
throw new ErrorCodeException(ErrorCode::WITHDRAW_PAYMENT_FAIL); throw new ErrorCodeException(ErrorCode::WITHDRAW_PAYMENT_FAIL);
} }
// 一旦有提现成功的,说明没有特殊原因影响,可能临时解除了,比如临时充钱了,去除标志防止再次缺钱的发生
$redis->del($refuseReasonForSpecialKey);
return true; return true;
} }

Loading…
Cancel
Save