|
|
@@ -354,7 +354,7 @@ class DouYinService
|
|
|
'total_amount'=>$params['total_amount'],
|
|
|
'discount_amount'=>$params['discount_amount'],
|
|
|
]);
|
|
|
- //$payNotifyUrl = 'payTailNotify';
|
|
|
+ $payNotifyUrl = 'https://weixiudev.kyjlkj.com/api/dou_yin/payTailNotify';
|
|
|
}else{
|
|
|
// 创建首单 goods_id user_info.mobile user_id quantity
|
|
|
$order_number = self::submitOrder([
|
|
|
@@ -365,6 +365,7 @@ class DouYinService
|
|
|
'mobile'=>$user['mobile']??'',
|
|
|
'quantity'=>$params['cp_extra']['quantity']
|
|
|
]);
|
|
|
+ $payNotifyUrl = 'https://weixiudev.kyjlkj.com/api/dou_yin/payNotify';
|
|
|
}
|
|
|
return [
|
|
|
"out_order_no" => $order_number,
|
|
|
@@ -372,7 +373,7 @@ class DouYinService
|
|
|
"path" => "pages/order/detail",
|
|
|
"params" => json_encode(['order_number' => $order_number])
|
|
|
],
|
|
|
- //"payNotifyUrl" => $payNotifyUrl??''
|
|
|
+ "payNotifyUrl" => $payNotifyUrl
|
|
|
];
|
|
|
} catch (\Exception $e) {
|
|
|
throw new \Exception($e->getMessage());
|
|
|
@@ -402,7 +403,7 @@ class DouYinService
|
|
|
// TODO tmp防抖1m
|
|
|
$isExist = DouyinOrder::where(['user_id'=>$params['user_id'],'goods_id'=>$goods['id']])->where('create_time','>',(time() - 60))->findOrEmpty();
|
|
|
if(!$isExist->isEmpty()){
|
|
|
- throw new \Exception('请勿重复下单!');
|
|
|
+ //throw new \Exception('请勿重复下单!');
|
|
|
}
|
|
|
$quantity = $params['quantity']??1;
|
|
|
//生成订单
|
|
|
@@ -436,7 +437,7 @@ class DouYinService
|
|
|
$transaction_id = $params['order_id']??'';
|
|
|
$paid_amount = bcdiv(bcsub($params['total_amount'] ,$params['discount_amount']), '100', 2)??0;
|
|
|
$out_order_no = $params['out_order_no'];
|
|
|
- $pay_time = $params['event_time']??time();
|
|
|
+ $pay_time = time();
|
|
|
$order = DouyinOrder::where('order_number', $out_order_no)->findOrEmpty();
|
|
|
if(!$order->isEmpty()){
|
|
|
// 更新充值订单状态
|
|
|
@@ -466,6 +467,10 @@ class DouYinService
|
|
|
$order->save();
|
|
|
return true;
|
|
|
}
|
|
|
+ }elseif ($params['status'] === 'CANCEL' && $params['message'] == 'TIME_OUT'){
|
|
|
+ // 超时取消支付
|
|
|
+ Log::info('支付超时取消:order_id'.$params['order_id']."--out_order_no:" .$params['out_order_no']);
|
|
|
+ return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
@@ -481,10 +486,10 @@ class DouYinService
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
$amount = bcdiv(bcsub($params['total_amount'] ,$params['discount_amount']), '100', 2)??0;
|
|
|
- $work_id = DouyinOrder::where(['id'=>$params['douyinOrderId']])->value('work_id');
|
|
|
+ $work_id = DouyinOrder::where(['id'=>$params['douyinOrderId']])->value('work_id')??0;
|
|
|
$sn = '';
|
|
|
$rechargeOrder = RechargeOrder::where(['work_id'=>$work_id,'payment_type'=>2])->findOrEmpty();
|
|
|
- if($rechargeOrder->isEmpty()){
|
|
|
+ if($work_id && $rechargeOrder->isEmpty()){
|
|
|
//新增待支付尾款
|
|
|
$sn = generate_sn(RechargeOrder::class, 'sn');
|
|
|
$order_data = [
|
|
|
@@ -520,9 +525,10 @@ class DouYinService
|
|
|
$transaction_id = $params['order_id']??'';
|
|
|
$paid_amount = bcdiv(bcsub($params['total_amount'] ,$params['discount_amount']), '100', 2)??0;
|
|
|
$out_order_no = $params['out_order_no'];
|
|
|
- $pay_time = $params['event_time']??time();
|
|
|
-
|
|
|
- $rechargeOrder = RechargeOrder::where(['sn'=>$out_order_no,'payment_type'=>2])->findOrEmpty();
|
|
|
+ $pay_time = time();
|
|
|
+ $params['cp_extra'] = json_decode($params['cp_extra'], true);
|
|
|
+ $work_id = DouyinOrder::where(['id'=>$params['cp_extra']['douyinOrderId']])->value('work_id')??0;
|
|
|
+ $rechargeOrder = RechargeOrder::where(['work_id'=>$work_id,'sn'=>$out_order_no,'payment_type'=>2])->findOrEmpty();
|
|
|
if(!$rechargeOrder->isEmpty()){
|
|
|
// 更新充值订单状态
|
|
|
$rechargeOrder->transaction_id = $transaction_id;
|
|
|
@@ -530,8 +536,14 @@ class DouYinService
|
|
|
$rechargeOrder->pay_time = $pay_time;
|
|
|
$rechargeOrder->paid_amount = $paid_amount;
|
|
|
$rechargeOrder->save();
|
|
|
+
|
|
|
+ // 尾款订单支付成功后续操作 fun
|
|
|
return true;
|
|
|
}
|
|
|
+ }elseif ($params['status'] === 'CANCEL' && $params['message'] == 'TIME_OUT'){
|
|
|
+ // 超时取消支付
|
|
|
+ Log::info('支付超时取消:order_id'.$params['order_id']."--out_order_no:" .$params['out_order_no']);
|
|
|
+ return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|