增加了订单主表,修改了所有订单相关,支付相关代码
This commit is contained in:
+236
-199
@@ -17,6 +17,8 @@ use App\Model\DoctorInquiryConfigService;
|
||||
use App\Model\Hospital;
|
||||
use App\Model\InquiryCaseProduct;
|
||||
use App\Model\MessageIm;
|
||||
use App\Model\Order;
|
||||
use App\Model\OrderCoupon;
|
||||
use App\Model\OrderDetection;
|
||||
use App\Model\OrderEvaluation;
|
||||
use App\Model\OrderInquiry;
|
||||
@@ -220,8 +222,31 @@ class InquiryService extends BaseService
|
||||
$payment_amount_total = 0;
|
||||
}
|
||||
|
||||
// 生成订单表
|
||||
$data = array();
|
||||
$data['user_id'] = $user_info['user_id'];
|
||||
$data['patient_id'] = $user_info['client_user_id'];
|
||||
if (isset($request_params['doctor_id'])) {
|
||||
if (!empty($request_params['doctor_id'])) {
|
||||
$data['doctor_id'] = $request_params['doctor_id'];
|
||||
}
|
||||
}
|
||||
$data['order_type'] = 1; // 订单类型(1:问诊订单 2:药品订单 3:检测订单 4:随访包订单 5:健康包订单)
|
||||
$data['inquiry_pay_channel'] = $inquiry_pay_channel ?? 0;// 支付渠道(1:小程序支付 2:微信扫码支付)
|
||||
$data['pay_status'] = 1;// 1:待支付
|
||||
$data['order_no'] = "I" . $generator->generate();// 订单编号
|
||||
$data['amount_total'] = $inquiry_price;// 订单金额
|
||||
$data['coupon_amount_total'] = $coupon_amount_total;// 优惠卷总金额
|
||||
$data['payment_amount_total'] = $payment_amount_total;// 实际付款金额
|
||||
$order = Order::addOrder($data);
|
||||
if (empty($order)) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::SERVER_ERROR, "订单创建失败");
|
||||
}
|
||||
|
||||
// 生成问诊订单
|
||||
$data = array();
|
||||
$data['order_id'] = $order['order_id'];
|
||||
$data['user_id'] = $user_info['user_id'];
|
||||
$data['patient_id'] = $user_info['client_user_id'];
|
||||
if (isset($request_params['doctor_id'])) {
|
||||
@@ -235,7 +260,7 @@ class InquiryService extends BaseService
|
||||
$data['inquiry_mode'] = $request_params['inquiry_mode'];
|
||||
$data['inquiry_status'] = 1;// 1:待支付
|
||||
$data['inquiry_pay_channel'] = $inquiry_pay_channel ?? 0;// 支付渠道(1:小程序支付 2:微信扫码支付)
|
||||
$data['inquiry_no'] = $generator->generate();// 订单编号
|
||||
$data['inquiry_no'] = $order['order_no'];// 订单编号
|
||||
$data['amount_total'] = $inquiry_price;// 订单金额
|
||||
$data['coupon_amount_total'] = $coupon_amount_total;// 优惠卷总金额
|
||||
$data['payment_amount_total'] = $payment_amount_total;// 实际付款金额
|
||||
@@ -383,6 +408,18 @@ class InquiryService extends BaseService
|
||||
// 处理优惠卷数据
|
||||
if (!empty($user_coupons)) {
|
||||
foreach ($user_coupons as $user_coupon) {
|
||||
// 增加订单优惠卷表
|
||||
$data = array();
|
||||
$data['order_id'] = $order['order_id'];// 订单id
|
||||
$data['user_coupon_id'] = $user_coupon['user_coupon_id'];
|
||||
$data['coupon_name'] = $user_coupon['coupon_name'];
|
||||
$data['coupon_use_price'] = $user_coupon['coupon_price'];
|
||||
$order_coupon = OrderCoupon::addOrderCoupon($data);
|
||||
if (empty($order_coupon)) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::SERVER_ERROR, "订单创建失败");
|
||||
}
|
||||
|
||||
// 增加问诊优惠卷表
|
||||
$data = array();
|
||||
$data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];// 订单-问诊id
|
||||
@@ -1663,84 +1700,208 @@ class InquiryService extends BaseService
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function inquiryRefund(string $order_inquiry_id, string $refund_reason): void
|
||||
// public function inquiryRefund(string $order_inquiry_id, string $refund_reason): void
|
||||
// {
|
||||
// // 获取订单数据
|
||||
// $params = array();
|
||||
// $params['order_inquiry_id'] = $order_inquiry_id;
|
||||
// $order_inquiry = OrderInquiry::getOne($params);
|
||||
// if (empty($order_inquiry)) {
|
||||
// throw new BusinessException("订单数据为空");
|
||||
// }
|
||||
//
|
||||
// // 检测问诊订单状态
|
||||
// if (!in_array($order_inquiry['inquiry_status'], [2, 3, 4, 5, 7])) {
|
||||
// // 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||
// throw new BusinessException("订单状态错误");
|
||||
// }
|
||||
//
|
||||
// // 检测订单退款状态
|
||||
// if (in_array($order_inquiry['inquiry_refund_status'], [2, 3, 5])) {
|
||||
// // 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭)
|
||||
// throw new BusinessException("订单退款状态错误");
|
||||
// }
|
||||
//
|
||||
// // 检测支付状态
|
||||
// if ($order_inquiry['inquiry_pay_status'] != 2) {
|
||||
// // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||
// throw new BusinessException("订单支付状态错误");
|
||||
// }
|
||||
//
|
||||
// // 系统退款编号
|
||||
// $generator = $this->container->get(IdGeneratorInterface::class);
|
||||
// $inquiry_refund_no = $generator->generate();
|
||||
//
|
||||
// // 检测订单金额
|
||||
// if ($order_inquiry['payment_amount_total'] > 0) {
|
||||
// // 发起退款
|
||||
// $WechatPay = new WechatPay(1, 1);
|
||||
//
|
||||
// $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)round($order_inquiry['payment_amount_total'] * 100),
|
||||
// 'total' => (int)round($order_inquiry['payment_amount_total'] * 100),
|
||||
// 'currency' => "CNY",
|
||||
// ];
|
||||
//
|
||||
// $result = $WechatPay->refund($options);
|
||||
//
|
||||
// // 处理订单退款状态
|
||||
// // 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭)
|
||||
// $success_time = "";
|
||||
// if ($result['status'] == "SUCCESS") {
|
||||
// // 退款成功
|
||||
// $inquiry_refund_status = 3;
|
||||
// $success_time = $result['success_time'];
|
||||
// } 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'];
|
||||
//
|
||||
// } else {
|
||||
// // 模拟退款
|
||||
// $inquiry_refund_status = 3;
|
||||
// $refund_id = "模拟退款:" . $generator->generate();
|
||||
// $success_time = date("Y-m-d H:i:s", time());
|
||||
//
|
||||
// // 模拟退款时手动退还优惠卷
|
||||
// if (!empty($order_inquiry['coupon_amount_total']) && $order_inquiry['coupon_amount_total'] > 0) {
|
||||
// // 获取该订单全部优惠卷数据
|
||||
// $params = array();
|
||||
// $params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
// $order_inquiry_coupons = OrderInquiryCoupon::getList($params);
|
||||
// if (!empty($order_inquiry_coupons)) {
|
||||
// $userCouponService = new UserCouponService();
|
||||
// foreach ($order_inquiry_coupons as $order_inquiry_coupon) {
|
||||
// // 退还优惠卷
|
||||
// $userCouponService->returnUserCoupon($order_inquiry_coupon['user_coupon_id']);
|
||||
//
|
||||
// // 发送站内消息-优惠卷退还
|
||||
// $MessagePush = new MessagePush($order_inquiry['user_id']);
|
||||
// $MessagePush->patientRefundCoupon($order_inquiry_coupon['coupon_name']);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 新增退款表
|
||||
// $data = array();
|
||||
// $data['patient_id'] = $order_inquiry['patient_id'];
|
||||
// $data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
// $data['inquiry_no'] = $order_inquiry['inquiry_no'];
|
||||
// $data['inquiry_refund_no'] = $inquiry_refund_no;
|
||||
// $data['refund_id'] = $refund_id;
|
||||
// $data['inquiry_refund_status'] = $inquiry_refund_status;
|
||||
// $data['refund_total'] = $order_inquiry['payment_amount_total'];
|
||||
// $data['refund_reason'] = $refund_reason;
|
||||
//
|
||||
// if ($inquiry_refund_status == 3 && !empty($success_time)) {
|
||||
// $data['success_time'] = date("Y-m-d H:i:s", strtotime($success_time)); // 退款成功时间
|
||||
// }
|
||||
//
|
||||
// $order_inquiry_refund = OrderInquiryRefund::addOrderInquiryRefund($data);
|
||||
// if (empty($order_inquiry_refund)) {
|
||||
// throw new BusinessException("添加退款表失败");
|
||||
// }
|
||||
//
|
||||
// // 修改问诊订单表状态
|
||||
// $data = array();
|
||||
// $data['inquiry_refund_status'] = $inquiry_refund_status;
|
||||
//
|
||||
// $params = array();
|
||||
// $params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
// OrderInquiry::edit($params, $data);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 取消未支付的问诊订单
|
||||
* @param string|int $order_no
|
||||
* @param string|int $cancel_reason 取消订单原因(1:医生未接诊 2:主动取消 3:无可分配医生 4:客服取消 5:支付超时)
|
||||
* @param string|int $cancel_remarks 取消订单备注
|
||||
* @return array
|
||||
*/
|
||||
public function cancelUnpayInquiryOrder(string|int $order_no, string|int $cancel_reason, string|int $cancel_remarks): array
|
||||
{
|
||||
// 获取订单数据
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_inquiry_id;
|
||||
$order_inquiry = OrderInquiry::getOne($params);
|
||||
if (empty($order_inquiry)) {
|
||||
throw new BusinessException("订单数据为空");
|
||||
}
|
||||
try {
|
||||
$result = array();
|
||||
$result['status'] = 1;
|
||||
$result['message'] = "成功";
|
||||
|
||||
// 检测问诊订单状态
|
||||
if (!in_array($order_inquiry['inquiry_status'], [2, 3, 4, 5, 7])) {
|
||||
// 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||
throw new BusinessException("订单状态错误");
|
||||
}
|
||||
|
||||
// 检测订单退款状态
|
||||
if (in_array($order_inquiry['inquiry_refund_status'], [2, 3, 5])) {
|
||||
// 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭)
|
||||
throw new BusinessException("订单退款状态错误");
|
||||
}
|
||||
|
||||
// 检测支付状态
|
||||
if ($order_inquiry['inquiry_pay_status'] != 2) {
|
||||
// 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||
throw new BusinessException("订单支付状态错误");
|
||||
}
|
||||
|
||||
// 系统退款编号
|
||||
$generator = $this->container->get(IdGeneratorInterface::class);
|
||||
$inquiry_refund_no = $generator->generate();
|
||||
|
||||
// 检测订单金额
|
||||
if ($order_inquiry['payment_amount_total'] > 0) {
|
||||
// 发起退款
|
||||
$WechatPay = new WechatPay(1, 1);
|
||||
|
||||
$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)round($order_inquiry['payment_amount_total'] * 100),
|
||||
'total' => (int)round($order_inquiry['payment_amount_total'] * 100),
|
||||
'currency' => "CNY",
|
||||
];
|
||||
|
||||
$result = $WechatPay->refund($options);
|
||||
|
||||
// 处理订单退款状态
|
||||
// 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭)
|
||||
$success_time = "";
|
||||
if ($result['status'] == "SUCCESS") {
|
||||
// 退款成功
|
||||
$inquiry_refund_status = 3;
|
||||
$success_time = $result['success_time'];
|
||||
} 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("订单退款状态错误");
|
||||
// 获取问诊订单数据
|
||||
$params = array();
|
||||
$params['order_no'] = $order_no;
|
||||
$order_inquiry = OrderInquiry::getOne($params);
|
||||
if (empty($order_inquiry)) {
|
||||
throw new BusinessException("未查询到对应订单数据");
|
||||
}
|
||||
|
||||
$refund_id = $result['refund_id'];
|
||||
// 检测订单状态
|
||||
if ($order_inquiry['inquiry_status'] == 7) {
|
||||
// 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||
$result['status'] = 0;
|
||||
$result['message'] = "订单已取消";
|
||||
return $result;
|
||||
}
|
||||
|
||||
} else {
|
||||
// 模拟退款
|
||||
$inquiry_refund_status = 3;
|
||||
$refund_id = "模拟退款:" . $generator->generate();
|
||||
$success_time = date("Y-m-d H:i:s", time());
|
||||
if ($order_inquiry['inquiry_status'] != 1) {
|
||||
// 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||
$result['status'] = 0;
|
||||
$result['message'] = "订单取消失败";
|
||||
return $result;
|
||||
}
|
||||
|
||||
// 模拟退款时手动退还优惠卷
|
||||
if (!in_array($order_inquiry['inquiry_refund_status'], [0, 4, 5])) {
|
||||
// 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭)
|
||||
$result['status'] = 0;
|
||||
$result['message'] = "订单正在退款中";
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ($order_inquiry['inquiry_pay_status'] == 2) {
|
||||
// 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||
$result['status'] = 0;
|
||||
$result['message'] = "订单已支付";
|
||||
return $result;
|
||||
}
|
||||
|
||||
// 检测订单删除状态
|
||||
if ($order_inquiry['is_delete'] == 1) {
|
||||
// 删除状态(0:否 1:是)
|
||||
$result['status'] = 0;
|
||||
$result['message'] = "订单已被删除";
|
||||
return $result;
|
||||
}
|
||||
|
||||
// 取消问诊订单
|
||||
$data = array();
|
||||
$data['inquiry_status'] = 7;
|
||||
if ($cancel_reason == 5) {
|
||||
$data['inquiry_pay_status'] = 5; // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||
}
|
||||
|
||||
$data['cancel_time'] = date("Y-m-d H:i:s", time());
|
||||
$data['cancel_reason'] = $cancel_reason; // 取消订单原因(1:医生未接诊 2:主动取消 3:无可分配医生 4:客服取消 5:支付超时)
|
||||
$data['cancel_remarks'] = $cancel_remarks; // 取消订单备注
|
||||
$data['updated_at'] = date("Y-m-d H:i:s", time());
|
||||
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
OrderInquiry::edit($params, $data);
|
||||
|
||||
// 处理订单优惠卷
|
||||
if (!empty($order_inquiry['coupon_amount_total']) && $order_inquiry['coupon_amount_total'] > 0) {
|
||||
// 获取该订单全部优惠卷数据
|
||||
$params = array();
|
||||
@@ -1758,132 +1919,8 @@ class InquiryService extends BaseService
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 新增退款表
|
||||
$data = array();
|
||||
$data['patient_id'] = $order_inquiry['patient_id'];
|
||||
$data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
$data['inquiry_no'] = $order_inquiry['inquiry_no'];
|
||||
$data['inquiry_refund_no'] = $inquiry_refund_no;
|
||||
$data['refund_id'] = $refund_id;
|
||||
$data['inquiry_refund_status'] = $inquiry_refund_status;
|
||||
$data['refund_total'] = $order_inquiry['payment_amount_total'];
|
||||
$data['refund_reason'] = $refund_reason;
|
||||
|
||||
if ($inquiry_refund_status == 3 && !empty($success_time)) {
|
||||
$data['success_time'] = date("Y-m-d H:i:s", strtotime($success_time)); // 退款成功时间
|
||||
}
|
||||
|
||||
$order_inquiry_refund = OrderInquiryRefund::addOrderInquiryRefund($data);
|
||||
if (empty($order_inquiry_refund)) {
|
||||
throw new BusinessException("添加退款表失败");
|
||||
}
|
||||
|
||||
// 修改问诊订单表状态
|
||||
$data = array();
|
||||
$data['inquiry_refund_status'] = $inquiry_refund_status;
|
||||
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
OrderInquiry::edit($params, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消未支付的问诊订单
|
||||
* @param string|int $order_no 系统订单编号
|
||||
* @param string|int $cancel_reason 取消订单原因(1:医生未接诊 2:主动取消 3:无可分配医生 4:客服取消 5:支付超时)
|
||||
* @param string|int $cancel_remarks 取消订单备注
|
||||
* @return array
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function cancelUnpayInquiryOrder(string|int $order_no, string|int $cancel_reason, string|int $cancel_remarks): array
|
||||
{
|
||||
$result = array();
|
||||
$result['status'] = 1;
|
||||
$result['message'] = "成功";
|
||||
|
||||
// 获取订单数据
|
||||
$params = array();
|
||||
$params['inquiry_no'] = $order_no;
|
||||
$order_inquiry = OrderInquiry::getOne($params);
|
||||
if (empty($order_inquiry)) {
|
||||
$result['status'] = 0;
|
||||
$result['message'] = "取消未支付的问诊订单失败:未查询到对应订单数据";
|
||||
return $result;
|
||||
}
|
||||
|
||||
// 检测订单状态
|
||||
if ($order_inquiry['inquiry_status'] == 7) {
|
||||
// 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||
$result['status'] = 2;
|
||||
$result['message'] = "取消未支付的问诊订单:订单已取消";
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ($order_inquiry['inquiry_status'] != 1) {
|
||||
// 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||
$result['status'] = 0;
|
||||
$result['message'] = "取消未支付的问诊订单:订单状态为" . $order_inquiry['inquiry_status'] . "无法执行";
|
||||
return $result;
|
||||
}
|
||||
|
||||
if (!in_array($order_inquiry['inquiry_refund_status'], [0, 4, 5])) {
|
||||
// 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭)
|
||||
$result['status'] = 0;
|
||||
$result['message'] = "取消未支付的问诊订单:订单正在退款中";
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ($order_inquiry['inquiry_pay_status'] == 2) {
|
||||
// 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||
$result['status'] = 2;
|
||||
$result['message'] = "取消未支付的问诊订单:订单已支付";
|
||||
return $result;
|
||||
}
|
||||
|
||||
// 检测订单删除状态
|
||||
if ($order_inquiry['is_delete'] == 1) {
|
||||
// 删除状态(0:否 1:是)
|
||||
$result['status'] = 2;
|
||||
$result['message'] = "取消未支付的问诊订单:订单已被删除";
|
||||
return $result;
|
||||
}
|
||||
|
||||
// 取消问诊订单
|
||||
$data = array();
|
||||
$data['inquiry_status'] = 7;
|
||||
if ($cancel_reason == 5) {
|
||||
$data['inquiry_pay_status'] = 5; // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||
}
|
||||
|
||||
$data['cancel_time'] = date("Y-m-d H:i:s", time());
|
||||
$data['cancel_reason'] = $cancel_reason; // 取消订单原因(1:医生未接诊 2:主动取消 3:无可分配医生 4:客服取消 5:支付超时)
|
||||
$data['cancel_remarks'] = $cancel_remarks; // 取消订单备注
|
||||
$data['updated_at'] = date("Y-m-d H:i:s", time());
|
||||
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
OrderInquiry::edit($params, $data);
|
||||
|
||||
// 处理订单优惠卷
|
||||
if (!empty($order_inquiry['coupon_amount_total']) && $order_inquiry['coupon_amount_total'] > 0) {
|
||||
// 获取该订单全部优惠卷数据
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
$order_inquiry_coupons = OrderInquiryCoupon::getList($params);
|
||||
if (!empty($order_inquiry_coupons)) {
|
||||
$userCouponService = new UserCouponService();
|
||||
foreach ($order_inquiry_coupons as $order_inquiry_coupon) {
|
||||
// 退还优惠卷
|
||||
$userCouponService->returnUserCoupon($order_inquiry_coupon['user_coupon_id']);
|
||||
|
||||
// 发送站内消息-优惠卷退还
|
||||
$MessagePush = new MessagePush($order_inquiry['user_id']);
|
||||
$MessagePush->patientRefundCoupon($order_inquiry_coupon['coupon_name']);
|
||||
}
|
||||
}
|
||||
}catch (\Throwable $e){
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
Reference in New Issue
Block a user