|
|
@@ -553,7 +553,7 @@ class PaymentService extends BaseService
|
|
|
|
|
|
// TODO 场景业务回调处理
|
|
|
$orderUserId = isset($orderInfo['user_id']) ? $orderInfo['user_id'] : 0;
|
|
|
- RedisService::set("caches:payments:notify_{$scene}:catch_{$orderNo}_{$orderUserId}", ['order' => $orderInfo, 'notify' => $data], 7200);
|
|
|
+ $this->saveLog("caches:payments:notify_{$scene}:catch_{$orderNo}_{$orderUserId}", ['order' => $orderInfo, 'notify' => $data]);
|
|
|
switch ($scene) {
|
|
|
case 'store': //
|
|
|
break;
|
|
|
@@ -578,7 +578,9 @@ class PaymentService extends BaseService
|
|
|
$orderInfo['money'] = $amount;
|
|
|
$orderInfo['remark'] = '充值失败退款';
|
|
|
$refundStatus = PaymentService::make()->refund($orderInfo,'pay');
|
|
|
- if(!PayOrdersModel::where(['id'=>$orderId])->update(['refund_status'=> $refundStatus?1:3,'status'=>5,'refund_money'=>$refundStatus?$amount:0,'update_time'=>time()])){
|
|
|
+ $updateData = ['refund_status'=> $refundStatus?1:3,'status'=>5,'remark'=>$this->error,'refund_money'=>$refundStatus?$amount:0,'update_time'=>time()];
|
|
|
+ $this->saveLog("caches:payments:notify_{$scene}:pay_failed_{$orderNo}_{$orderUserId}", ['error'=>$this->error,'update'=>$updateData,'order' => $orderInfo,'result'=>$result, 'notify' => $data]);
|
|
|
+ if(!PayOrdersModel::where(['id'=>$orderId])->update($updateData)){
|
|
|
$this->error = '订单退款状态更新错误~';
|
|
|
return false;
|
|
|
}
|
|
|
@@ -586,9 +588,11 @@ class PaymentService extends BaseService
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- if(!PayOrdersModel::where(['status'=>3,'out_trade_no'=>$order_number,'pay_total'=>$total_price,'remark'=> json_encode($data,256),'update_time'=>time()])){
|
|
|
+ $updateData = ['status'=>3,'out_trade_no'=>$order_number,'pay_total'=>$total_price,'remark'=> json_encode($data,256),'update_time'=>time()];
|
|
|
+ if(!PayOrdersModel::where($updateData)){
|
|
|
DB::commit();
|
|
|
$this->error = '更新充值订单失败';
|
|
|
+ $this->saveLog("caches:payments:notify_{$scene}:pay_failed_{$orderNo}_{$orderUserId}", ['error'=>$this->error,'update'=>$updateData,'order' => $orderInfo,'result'=>$result, 'notify' => $data]);
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
@@ -633,11 +637,13 @@ class PaymentService extends BaseService
|
|
|
$total = isset($orderInfo['total'])? $orderInfo['total'] : 0;
|
|
|
if(empty($orderInfo) || $orderId<=0 || $total<=0){
|
|
|
$this->error = '充值订单不存在';
|
|
|
+ $this->saveLog("caches:payments:payNotify_{$productId}:notify_{$out_trade_num}_error", ['error'=>$this->error,'order' => $orderInfo, 'notify' => $data]);
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
if($status!=3){
|
|
|
$this->error = '充值订单状态错误,状态非充值中';
|
|
|
+ $this->saveLog("caches:payments:payNotify_{$productId}:notify_{$out_trade_num}_error", ['error'=>$this->error,'order' => $orderInfo, 'notify' => $data]);
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
@@ -646,7 +652,6 @@ class PaymentService extends BaseService
|
|
|
$refundAmount = 0;
|
|
|
if($state == 1){
|
|
|
$this->error = '充值成功~';
|
|
|
- return true;
|
|
|
}
|
|
|
//部分成功,退部分
|
|
|
else if($state == 3) {
|
|
|
@@ -662,6 +667,7 @@ class PaymentService extends BaseService
|
|
|
}
|
|
|
|
|
|
// 更新订单状态
|
|
|
+ $this->saveLog("caches:payments:payNotify_{$productId}:notify_{$out_trade_num}", ['error'=>$this->error,'order' => $orderInfo, 'notify' => $data]);
|
|
|
if(!PayOrdersModel::where(['id'=>$orderId])->update(['status'=>$status,'charge_kami'=>$charge_kami,'refund_status'=>$status!=4?2:0,'charge_amount'=>$amount,'update_time'=>time()])){
|
|
|
$this->error = '更新订单状态错误~';
|
|
|
return false;
|
|
|
@@ -673,6 +679,7 @@ class PaymentService extends BaseService
|
|
|
$orderInfo['remark'] = $this->error;
|
|
|
$refundStatus = PaymentService::make()->refund($orderInfo,'pay');
|
|
|
if(!PayOrdersModel::where(['id'=>$orderId])->update(['refund_status'=> $refundStatus?1:3,'refund_money'=>$refundStatus?$refundAmount:0,'update_time'=>time()])){
|
|
|
+ $this->saveLog("caches:payments:payNotify_{$productId}:notify_{$out_trade_num}_error", ['error'=>$this->error,'order' => $orderInfo, 'notify' => $data]);
|
|
|
$this->error = '订单退款状态更新错误~';
|
|
|
return false;
|
|
|
}
|
|
|
@@ -684,6 +691,18 @@ class PaymentService extends BaseService
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 日志
|
|
|
+ * @param $key
|
|
|
+ * @param $data
|
|
|
+ */
|
|
|
+ public function saveLog($key, $data)
|
|
|
+ {
|
|
|
+ if(env('APP_DEBUG')){
|
|
|
+ RedisService::set($key,$data,7200);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 退款请求
|
|
|
* @param $order
|
|
|
* @param string $scene
|