10、问诊订单退款
11、药品订单退款 12、问诊订单模拟退款 13、药品订单模拟退款
This commit is contained in:
@@ -21,6 +21,7 @@ use App\Model\OrderInquiryCase;
|
||||
use App\Model\OrderInquiryCoupon;
|
||||
use App\Model\OrderInquiryRefund;
|
||||
use App\Model\OrderPrescription;
|
||||
use App\Model\OrderProductCoupon;
|
||||
use App\Model\PatientFamily;
|
||||
use App\Model\PatientFamilyHealth;
|
||||
use App\Model\PatientFamilyPersonal;
|
||||
@@ -1264,8 +1265,21 @@ class InquiryService extends BaseService
|
||||
|
||||
// 模拟退款时手动退还优惠卷
|
||||
if (!empty($order_inquiry['coupon_amount_total']) && $order_inquiry['coupon_amount_total'] > 0) {
|
||||
$InquiryService = new InquiryService();
|
||||
$InquiryService->returnInquiryCoupon($order_inquiry['order_inquiry_id'], $order_inquiry['user_id']);
|
||||
// 获取该订单全部优惠卷数据
|
||||
$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']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1378,17 +1392,20 @@ class InquiryService extends BaseService
|
||||
|
||||
// 处理订单优惠卷
|
||||
if (!empty($order_inquiry['coupon_amount_total']) && $order_inquiry['coupon_amount_total'] > 0) {
|
||||
$InquiryService = new InquiryService();
|
||||
$InquiryService->returnInquiryCoupon($order_inquiry['order_inquiry_id'], $order_inquiry['user_id']);
|
||||
|
||||
// 获取用户优惠卷信息
|
||||
// 获取该订单全部优惠卷数据
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
$order_inquiry_coupon = OrderInquiryCoupon::getOne($params);
|
||||
if (!empty($order_inquiry_coupon)) {
|
||||
// 发送站内消息-优惠卷退还
|
||||
$MessagePush = new MessagePush($order_inquiry['user_id'], $order_inquiry['order_inquiry_id']);
|
||||
$MessagePush->patientRefundCoupon($order_inquiry_coupon['coupon_name']);
|
||||
$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']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1456,58 +1473,6 @@ class InquiryService extends BaseService
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 退还问诊订单优惠卷
|
||||
* @param string $order_inquiry_id 问诊订单id
|
||||
* @param string $patient_user_id 患者用户id
|
||||
* @return bool
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function returnInquiryCoupon(string $order_inquiry_id, string $patient_user_id): bool
|
||||
{
|
||||
try {
|
||||
// 获取用户优惠卷信息
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_inquiry_id;
|
||||
$order_inquiry_coupon = OrderInquiryCoupon::getOne($params);
|
||||
if (empty($order_inquiry_coupon)) {
|
||||
// 订单未使用优惠卷,无需退还
|
||||
return true;
|
||||
}
|
||||
|
||||
// 获取用户优惠卷数据
|
||||
$params = array();
|
||||
$params['user_coupon_id'] = $order_inquiry_coupon['user_coupon_id'];
|
||||
$user_coupon = UserCoupon::getOne($params);
|
||||
if (empty($user_coupon)) {
|
||||
// 无该优惠卷数据,无需处理
|
||||
return true;
|
||||
}
|
||||
|
||||
// 恢复优惠卷
|
||||
$data = array();
|
||||
|
||||
// 检测优惠卷过期时间。判断是否需要退还
|
||||
if (strtotime($user_coupon['valid_end_time']) <= time()) {
|
||||
// 超出过期时间,置为已过期
|
||||
$data['user_coupon_status'] = 3;
|
||||
} else {
|
||||
$data['user_coupon_status'] = 0;
|
||||
$data['coupon_use_date'] = null;
|
||||
}
|
||||
|
||||
$params = array();
|
||||
$params['user_coupon_id'] = $order_inquiry_coupon['user_coupon_id'];
|
||||
UserCoupon::edit($params, $data);
|
||||
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Log::getInstance()->error("退还用户优惠卷失败" . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测当前是否符合系统问诊时间
|
||||
* @param string $inquiry_type 接诊类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药)
|
||||
|
||||
Reference in New Issue
Block a user