Commit 61d36d52 authored by wanjilong's avatar wanjilong

add: fix bug

parent c6f6a040
......@@ -35,7 +35,10 @@ class PayException extends BaseException
21 => '保存核销单失败,请重试',
22 => '保存核销子单失败,请重试',
23 => '保存核销结算失败,请重试',
24 => '更新子单结算状态失败,请管理员关注',
24 => '更新结算状态失败,请管理员关注',
25 => '更新子单结算状态失败,请管理员关注',
26 => '同步商户资产失败',
27 => '同步商户资产失败',
100=>'支付渠道错误,暂不支持该渠道',
101=>'该订单已经支付,请稍后刷新',
......
......@@ -46,6 +46,10 @@ class Sdk {
FileLog::info('sdk api:', json_encode(['url'=>$url, 'req'=>$params, 'res'=>$data]));
if(!isset($data['response']['code'])) {
throw new BaseException(['msg'=>$data['response']['reason']??'', 'code'=>3031]);
}
if(!empty($data['response']['code'])) {
throw new BaseException(['msg'=>$data['response']['reason']??'', 'code'=>$data['response']['code']]);
}
......
......@@ -130,8 +130,8 @@ class PayService
'pay_channel' => $pay_method_id,
'third_order_id' => '',
'expire_time' => date('Y-m-d H:i:s', $pay_expiration_time),
'source_name' => 10,
'service_name' => 1,
'source_name' => 1,
'service_name' => 10,
'business_from' => $order['business_from'],
'extra' => json_encode([]),
];
......@@ -472,6 +472,8 @@ class PayService
'writeoff_order_id'=>$writeOff_order_id,
'user_id'=>$pay_order['user_id'],
'order_id'=>$pay_order['order_id'],
'source_name'=>$pay_order['source_name'],
'service_name'=>$pay_order['service_name'],
'writeoff_status'=>0,
], ['rowCount' => true]);
if($cnt == false) {
......@@ -495,6 +497,12 @@ class PayService
if($cnt == false) {
throw new PayException(['cus'=>23]);
}
$cnt = $cnt && WriteOffOrder::update([
'writeoff_status'=>2,
],['writeoff_order_id'=>$writeOff_order_id]);
if($cnt == false) {
throw new PayException(['cus'=>24]);
}
PayOrderItem::update([
'notify_account_status' => 0,
......@@ -504,7 +512,7 @@ class PayService
$err = PayOrderItem::getMaster('*', ['order_item_id' => $item_ids, 'can_notify_account'=>0, 'refund_order_status'=>0]);
if($err) {
throw new PayException(['cus'=>24]);
throw new PayException(['cus'=>25]);
}
PayOrderItem::commit();
......@@ -534,16 +542,15 @@ class PayService
public function sync_account_wallet($writeOff_order_id) {
$p_cnt = $u_cnt = $m_cnt = true;
/*
/**/
//修改状态为执行中
$cnt = WriteOffOrder::update([
'notify_account_status'=>1,
], ['writeoff_order_id'=>$writeOff_order_id, 'writeoff_status' => 2, 'notify_account_status'=>0]);
if(!$cnt) {//乐观锁,不满足条件不处理
return true;
}
*/
//平台收入入账
$p = WriteOffPlatformRecord::getMaster('*',
['writeoff_order_id'=>$writeOff_order_id, 'notify_account_status[<]'=>2]);
......@@ -563,8 +570,8 @@ class PayService
foreach ($us as $u) {
$w_list[] = [
'user_id' => $u['account_id'],
'service_name' => 10,
'source_name' => 1,
'source_name'=>$u['source_name'],
'service_name'=>$u['service_name'],
'amount' => $u['payment'],
'third_order_id' => $u['writeoff_personal_id'],
'third_order_id_type' => 105,
......@@ -580,6 +587,7 @@ class PayService
], ['writeoff_order_id'=>$writeOff_order_id]);
}catch (\Exception $e) {
FileLog::error('bp-pay', json_encode(['writeoff_order_id'=>$writeOff_order_id,'error'=>'同步钱包失败']));
$u_cnt = false;
}
}
......@@ -595,29 +603,33 @@ class PayService
'source_name'=>$m['source_name'],
'service_name'=>$m['service_name'],
'writeoff_order_id'=>$m['writeoff_order_id'],
'order_id'=>$m['order_id'],
'third_order_title'=>$m['title'],
'third_order_desc'=>$m['desc'],
'third_order_type'=>$m['business_from'],
'amount'=>$m['payment'],
]);
$m_cnt = $m_cnt && WriteOffPlatformRecord::update([
$m_cnt = $m_cnt && WriteOffMerchantRecord::update([
'notify_account_status'=>2,
'notify_account_success_time'=>date('Y-m-d H:i:s'),
], ['writeoff_order_id'=>$writeOff_order_id]);
}catch (\Exception $e) {
FileLog::error('bp-pay', json_encode(['writeoff_order_id'=>$writeOff_order_id,'error'=>'同步商户钱包失败']));
$m_cnt = false;
}
}
var_dump($m_cnt , $u_cnt , $p_cnt);
if($m_cnt && $u_cnt && $p_cnt) {
WriteOffOrder::update([
'notify_account_status'=>2,
'notify_account_success_time'=>date('Y-m-d H:i:s'),
], ['writeoff_order_id'=>$writeOff_order_id, 'notify_account_status'=>1]);
} else {
$info = WriteOffOrder::getMaster('*', ['writeoff_order_id'=>$writeOff_order_id]);
$next = $this->getNextTime($info['notify_account_times']);
......@@ -649,6 +661,8 @@ class PayService
'pay_order_id'=>$r['pay_order_id'],
'order_id'=>$r['order_id'],
'user_id'=>$r['account_id'],
'source_name'=>$pay_order['source_name'],
'service_name'=>$pay_order['service_name'],
'payment'=>0,
];
}
......@@ -1116,28 +1130,6 @@ class PayService
return $this->gen_ids;
}
private function get_merchant_account($params)
{
/*
///account/account/get_account
$url = config('interface', 'merchant.lifeaccount.get_life_account_by_id');
if (!$url) {
throw new CodeSpecialException("failed" . __METHOD__);
}
*/
$url = 'http://account.dev.yidian-inc.com' . "/account/account/get_account";
$ret = Sdk::call($url, [
'life_account_id'=>$params['life_account_id'],
'shop_id'=>$params['shop_id'],
'source_name'=>$params['source_name'],
'service_name'=>$params['service_name'],
]);
if(empty($ret['result'])) {
throw new PayException(['cus'=>9]);
}
return $ret['result'];
}
private function getNextTime($times = 0) {
return time() + pow(3, $times + 1);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment