This commit is contained in:
2023-11-09 16:07:23 +08:00
parent 39f88f3e1b
commit 6c3970ec5c
5 changed files with 168 additions and 63 deletions
+39 -62
View File
@@ -279,70 +279,47 @@ class OrderProductService extends BaseService
$product_refund_no = $generator->generate();
// 检测订单金额
if ($order_product['payment_amount_total'] > 0){
// 发起退款
$WechatPay = new WechatPay(1, 2);
$options = array();
$options['transaction_id'] = $order_product['escrow_trade_no'];
$options['out_refund_no'] = (string)$product_refund_no;
$options['reason'] = $refund_reason;
$options['amount'] = [
'refund' => (int)($order_product['payment_amount_total'] * 100),
'total' => (int)($order_product['payment_amount_total'] * 100),
'currency' => "CNY",
];
$result = $WechatPay->refund($options);
// 处理订单退款状态
// 商品订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)
$success_time = "";
if ($result['status'] == "SUCCESS") {
// 退款成功
$refund_status = 3;
$success_time = $result['success_time'];
} elseif ($result['status'] == "CLOSED") {
// 退款关闭
$refund_status = 5;
} elseif ($result['status'] == "PROCESSING") {
// 退款处理中
$refund_status = 2;
} elseif ($result['status'] == "ABNORMAL") {
// 退款异常,此情况不处理,进行短信通知
throw new BusinessException("订单退款状态异常");
} else {
throw new BusinessException("订单退款状态错误");
}
$refund_id = $result['refund_id'];
}else{
// 模拟退款
$refund_status = 3;
$refund_id = "模拟退款:" . $generator->generate();
$success_time = date("Y-m-d H:i:s", time());
// 模拟退款时手动退还优惠卷
if (!empty($order_product['coupon_amount_total']) && $order_product['coupon_amount_total'] > 0) {
// 获取该订单全部优惠卷数据
$params = array();
$params['order_product_id'] = $order_product['order_product_id'];
$order_product_coupons = OrderProductCoupon::getList($params);
if (!empty($order_product_coupons)){
$userCouponService = new UserCouponService();
foreach ($order_product_coupons as $order_product_coupon){
// 退还优惠卷
$userCouponService->returnUserCoupon($order_product_coupon['user_coupon_id']);
// 发送站内消息-优惠卷退还
$MessagePush = new MessagePush($user_patient['user_id']);
$MessagePush->patientRefundCoupon($order_product_coupon['coupon_name']);
}
}
}
if ($order_product['payment_amount_total'] <= 0){
throw new BusinessException("订单金额错误");
}
// 发起退款
$WechatPay = new WechatPay(1, 2);
$options = array();
$options['transaction_id'] = $order_product['escrow_trade_no'];
$options['out_refund_no'] = (string)$product_refund_no;
$options['reason'] = $refund_reason;
$options['amount'] = [
'refund' => (int)($order_product['payment_amount_total'] * 100),
'total' => (int)($order_product['payment_amount_total'] * 100),
'currency' => "CNY",
];
$result = $WechatPay->refund($options);
// 处理订单退款状态
// 商品订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)
$success_time = "";
if ($result['status'] == "SUCCESS") {
// 退款成功
$refund_status = 3;
$success_time = $result['success_time'];
} elseif ($result['status'] == "CLOSED") {
// 退款关闭
$refund_status = 5;
} elseif ($result['status'] == "PROCESSING") {
// 退款处理中
$refund_status = 2;
} elseif ($result['status'] == "ABNORMAL") {
// 退款异常,此情况不处理,进行短信通知
throw new BusinessException("订单退款状态异常");
} else {
throw new BusinessException("订单退款状态错误");
}
$refund_id = $result['refund_id'];
// 新增退款表
$data = array();
$data['patient_id'] = $order_product['patient_id'];
+1 -1
View File
@@ -45,7 +45,7 @@ class UserPatientService extends BaseService
}
// 获取福利数据
$coupon = $this->getPatientAvailableCouponList($user_patient['user_id'],1);
$coupon = UserCoupon::getUserObjectTypeCoupon($user_patient['user_id'],2);
// 获取问诊数量-待支付
$InquiryService = new InquiryService();