简化了患者端药品微信支付回调的再次发放优惠卷的方法调用、增加了发放优惠卷时数量的判断、增加了再次发放订单优惠卷的方法
This commit is contained in:
@@ -1181,6 +1181,15 @@ class PatientOrderService extends BaseService
|
||||
$order_type = $this->request->input('order_type');
|
||||
$order_no = $this->request->input('order_no');
|
||||
|
||||
// 获取订单数据
|
||||
$params = array();
|
||||
$params['order_no'] = $order_no;
|
||||
$order = Order::getOne($params);
|
||||
if (empty($order))
|
||||
{
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "非法订单");
|
||||
}
|
||||
|
||||
Db::beginTransaction();
|
||||
try {
|
||||
switch ($order_type) {
|
||||
@@ -1347,50 +1356,6 @@ class PatientOrderService extends BaseService
|
||||
$params['order_no'] = $order_product['order_product_no'];
|
||||
Order::edit($params, $data);
|
||||
|
||||
try {
|
||||
if ($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)) {
|
||||
foreach ($order_product_coupons as $order_product_coupon) {
|
||||
// 获取用户优惠卷数据
|
||||
$params = array();
|
||||
$params['user_coupon_id'] = $order_product_coupon['user_coupon_id'];
|
||||
$user_coupon = UserCoupon::getOne($params);
|
||||
if (!empty($user_coupon)) {
|
||||
// 获取优惠卷数据
|
||||
$params = array();
|
||||
$params['coupon_id'] = $user_coupon['coupon_id'];
|
||||
$coupon = Coupon::getOne($params);
|
||||
if (!empty($coupon)) {
|
||||
if ($coupon['reissue_interval_days'] > 0) {
|
||||
$data = array();
|
||||
$data['coupon_id'] = $coupon['coupon_id'];
|
||||
$data['user_id'] = $user_coupon['user_id'];
|
||||
|
||||
$time = $coupon['reissue_interval_days'] * 24 * 60 * 60 * 1000;
|
||||
$message = new GrantUserCouponDelayDirectProducer($data);
|
||||
$message->setDelayMs($time);
|
||||
$producer = $this->container->get(Producer::class);
|
||||
$res = $producer->produce($message);
|
||||
if (!$res) {
|
||||
Log::getInstance("PatientOrderService-addPatientOrderPay")->error("再次发放优惠卷失败");
|
||||
}
|
||||
|
||||
Log::getInstance("PatientOrderService-addPatientOrderPay")->info("再次发放优惠卷成功");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
// 此处异常不做处理
|
||||
Log::getInstance("PatientOrderService-addPatientOrderPay")->error($e->getMessage());
|
||||
}
|
||||
|
||||
break;
|
||||
case 3: // 检测订单
|
||||
Db::rollBack();
|
||||
@@ -1414,6 +1379,19 @@ class PatientOrderService extends BaseService
|
||||
return fail(HttpEnumCode::SERVER_ERROR, $e->getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
if ($order['coupon_amount_total'] > 0) {
|
||||
$couponService = new CouponService();
|
||||
$res = $couponService->againGrantOrderCoupon($order['order_id']);
|
||||
if (!$res){
|
||||
Log::getInstance("PatientOrderService-addPatientOrderPay")->error("再次发放优惠卷失败");
|
||||
}
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
// 此处异常不做处理
|
||||
Log::getInstance("PatientOrderService-addPatientOrderPay")->error($e->getMessage());
|
||||
}
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user