修改订单为金额0时的退款报错问题
This commit is contained in:
parent
a5599a5bc1
commit
b6a1eb8b7d
@ -885,42 +885,52 @@ class InquiryService extends BaseService
|
|||||||
throw new BusinessException("订单支付状态错误");
|
throw new BusinessException("订单支付状态错误");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 发起退款
|
|
||||||
$WechatPay = new WechatPay(1, 1);
|
|
||||||
|
|
||||||
$generator = $this->container->get(IdGeneratorInterface::class);
|
|
||||||
|
|
||||||
// 系统退款编号
|
// 系统退款编号
|
||||||
|
$generator = $this->container->get(IdGeneratorInterface::class);
|
||||||
$inquiry_refund_no = $generator->generate();
|
$inquiry_refund_no = $generator->generate();
|
||||||
|
|
||||||
$options = array();
|
// 检测订单金额
|
||||||
$options['transaction_id'] = $order_inquiry['escrow_trade_no'];
|
if ($order_inquiry['payment_amount_total'] > 0){
|
||||||
$options['out_refund_no'] = (string)$inquiry_refund_no;
|
// 发起退款
|
||||||
$options['reason'] = $refund_reason;
|
$WechatPay = new WechatPay(1, 1);
|
||||||
$options['amount'] = [
|
|
||||||
'refund' => (int)($order_inquiry['payment_amount_total'] * 100),
|
|
||||||
'total' => (int)($order_inquiry['payment_amount_total'] * 100),
|
|
||||||
'currency' => "CNY",
|
|
||||||
];
|
|
||||||
|
|
||||||
$result = $WechatPay->refund($options);
|
$options = array();
|
||||||
|
$options['transaction_id'] = $order_inquiry['escrow_trade_no'];
|
||||||
|
$options['out_refund_no'] = (string)$inquiry_refund_no;
|
||||||
|
$options['reason'] = $refund_reason;
|
||||||
|
$options['amount'] = [
|
||||||
|
'refund' => (int)($order_inquiry['payment_amount_total'] * 100),
|
||||||
|
'total' => (int)($order_inquiry['payment_amount_total'] * 100),
|
||||||
|
'currency' => "CNY",
|
||||||
|
];
|
||||||
|
|
||||||
// 处理订单退款状态
|
$result = $WechatPay->refund($options);
|
||||||
// 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭)
|
|
||||||
if ($result['status'] == "SUCCESS") {
|
// 处理订单退款状态
|
||||||
// 退款成功
|
// 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭)
|
||||||
|
if ($result['status'] == "SUCCESS") {
|
||||||
|
// 退款成功
|
||||||
|
$inquiry_refund_status = 3;
|
||||||
|
} elseif ($result['status'] == "CLOSED") {
|
||||||
|
// 退款关闭
|
||||||
|
$inquiry_refund_status = 5;
|
||||||
|
} elseif ($result['status'] == "PROCESSING") {
|
||||||
|
// 退款处理中
|
||||||
|
$inquiry_refund_status = 2;
|
||||||
|
} elseif ($result['status'] == "ABNORMAL") {
|
||||||
|
// 退款异常,此情况不处理,进行短信通知
|
||||||
|
throw new BusinessException("订单退款状态异常");
|
||||||
|
} else {
|
||||||
|
throw new BusinessException("订单退款状态错误");
|
||||||
|
}
|
||||||
|
|
||||||
|
$refund_id = $result['refund_id'];
|
||||||
|
$success_time = $result['success_time'];
|
||||||
|
}else{
|
||||||
|
// 模拟退款
|
||||||
$inquiry_refund_status = 3;
|
$inquiry_refund_status = 3;
|
||||||
} elseif ($result['status'] == "CLOSED") {
|
$refund_id = "模拟退款:" . $generator->generate();
|
||||||
// 退款关闭
|
$success_time = date("Y-m-d H:i:s", time());
|
||||||
$inquiry_refund_status = 5;
|
|
||||||
} elseif ($result['status'] == "PROCESSING") {
|
|
||||||
// 退款处理中
|
|
||||||
$inquiry_refund_status = 2;
|
|
||||||
} elseif ($result['status'] == "ABNORMAL") {
|
|
||||||
// 退款异常,此情况不处理,进行短信通知
|
|
||||||
throw new BusinessException("订单退款状态异常");
|
|
||||||
} else {
|
|
||||||
throw new BusinessException("订单退款状态错误");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 新增退款表
|
// 新增退款表
|
||||||
@ -929,13 +939,13 @@ class InquiryService extends BaseService
|
|||||||
$data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
$data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||||
$data['inquiry_no'] = $order_inquiry['inquiry_no'];
|
$data['inquiry_no'] = $order_inquiry['inquiry_no'];
|
||||||
$data['inquiry_refund_no'] = $inquiry_refund_no;
|
$data['inquiry_refund_no'] = $inquiry_refund_no;
|
||||||
$data['refund_id'] = $result['refund_id'];
|
$data['refund_id'] = $refund_id;
|
||||||
$data['inquiry_refund_status'] = $inquiry_refund_status;
|
$data['inquiry_refund_status'] = $inquiry_refund_status;
|
||||||
$data['refund_total'] = $order_inquiry['payment_amount_total'];
|
$data['refund_total'] = $order_inquiry['payment_amount_total'];
|
||||||
$data['refund_reason'] = $refund_reason;
|
$data['refund_reason'] = $refund_reason;
|
||||||
|
|
||||||
if ($inquiry_refund_status == 3 && !empty($result['success_time'])) {
|
if ($inquiry_refund_status == 3 && !empty($success_time)) {
|
||||||
$data['success_time'] = date("Y-m-d H:i:s", strtotime($result['success_time'])); // 退款成功时间
|
$data['success_time'] = date("Y-m-d H:i:s", strtotime($success_time)); // 退款成功时间
|
||||||
}
|
}
|
||||||
|
|
||||||
$order_inquiry_refund = OrderInquiryRefund::addOrderInquiryRefund($data);
|
$order_inquiry_refund = OrderInquiryRefund::addOrderInquiryRefund($data);
|
||||||
|
|||||||
@ -1137,6 +1137,8 @@ class MessagePush extends BaseService
|
|||||||
|
|
||||||
$link_params = array();
|
$link_params = array();
|
||||||
$link_params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id'];
|
$link_params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id'];
|
||||||
|
$link_params['inquiry_type'] = $this->order_inquiry['inquiry_type'];
|
||||||
|
$link_params['patient_user_id'] = $this->order_inquiry['user_id'];
|
||||||
$data['link_params'] = json_encode($link_params,JSON_UNESCAPED_UNICODE);// 跳转参数
|
$data['link_params'] = json_encode($link_params,JSON_UNESCAPED_UNICODE);// 跳转参数
|
||||||
|
|
||||||
$message = new SendStationMessageProducer($data);
|
$message = new SendStationMessageProducer($data);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user