提交代码

master
胡锐 6 months ago committed by yuanye
parent b579ff7d8e
commit afd81600d4
  1. 7
      service/src/main/java/com/hfkj/service/discount/CouponDiscountUserRelService.java
  2. 5
      service/src/main/java/com/hfkj/service/discount/impl/CouponDiscountUserRelServiceImpl.java
  3. 20
      service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java

@ -27,4 +27,11 @@ public interface CouponDiscountUserRelService {
* @return java.util.List<com.hfkj.entity.CouponDiscount> * @return java.util.List<com.hfkj.entity.CouponDiscount>
*/ */
List<CouponDiscountUserRel> getList(Map<String , Object> map); List<CouponDiscountUserRel> getList(Map<String , Object> map);
/**
* 查询关系
* @param id
* @return
*/
CouponDiscountUserRel getRel(Long id);
} }

@ -42,5 +42,10 @@ public class CouponDiscountUserRelServiceImpl implements CouponDiscountUserRelSe
return couponDiscountUserRelMapper.selectByExample(example); return couponDiscountUserRelMapper.selectByExample(example);
} }
@Override
public CouponDiscountUserRel getRel(Long id) {
return couponDiscountUserRelMapper.selectByPrimaryKey(id);
}
} }

@ -11,6 +11,8 @@ import com.hfkj.entity.*;
import com.hfkj.model.order.OrderChildModel; import com.hfkj.model.order.OrderChildModel;
import com.hfkj.model.order.OrderModel; import com.hfkj.model.order.OrderModel;
import com.hfkj.mqtopic.OrderTopic; import com.hfkj.mqtopic.OrderTopic;
import com.hfkj.service.discount.CouponDiscountService;
import com.hfkj.service.discount.CouponDiscountUserRelService;
import com.hfkj.service.order.*; import com.hfkj.service.order.*;
import com.hfkj.service.user.UserIntegralService; import com.hfkj.service.user.UserIntegralService;
import com.hfkj.sysenum.UserIntegralRecordOpUserTypeEnum; import com.hfkj.sysenum.UserIntegralRecordOpUserTypeEnum;
@ -67,6 +69,10 @@ public class BsOrderServiceImpl implements BsOrderService {
private OrderPaySuccessService orderPaySuccessService; private OrderPaySuccessService orderPaySuccessService;
@Resource @Resource
private UserIntegralService userIntegralService; private UserIntegralService userIntegralService;
@Resource
private CouponDiscountUserRelService couponDiscountUserRelService;
@Resource
private CouponDiscountService couponDiscountService;
@Override @Override
public BsOrder editData(BsOrder order) { public BsOrder editData(BsOrder order) {
order.setUpdateTime(new Date()); order.setUpdateTime(new Date());
@ -103,8 +109,20 @@ public class BsOrderServiceImpl implements BsOrderService {
deduction.setOrderNo(order.getOrderNo()); deduction.setOrderNo(order.getOrderNo());
deduction.setIntegralDiscountPrice(deduction.getIntegralDiscountPrice()==null?0L: deduction.getIntegralDiscountPrice()); deduction.setIntegralDiscountPrice(deduction.getIntegralDiscountPrice()==null?0L: deduction.getIntegralDiscountPrice());
if (order.getDeduction().getUserCouponDiscountId() != null) { if (order.getDeduction().getUserCouponDiscountId() != null) {
// 查询用户优惠券
CouponDiscountUserRel discountUserRel = couponDiscountUserRelService.getRel(order.getDeduction().getUserCouponDiscountId());
if (discountUserRel == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知优惠券");
}
if (discountUserRel.getStatus() != 1) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券状态不处于待使用");
}
// 查询优惠券
CouponDiscount discount = couponDiscountService.queryDetail(discountUserRel.getDiscountId());
if (discount == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知优惠券");
}
// 计算优惠 // 计算优惠
CouponDiscount discount = new CouponDiscount();
deduction.setCouponDiscountId(discount.getId()); deduction.setCouponDiscountId(discount.getId());
deduction.setCouponDiscountType(discount.getType()); deduction.setCouponDiscountType(discount.getType());
deduction.setCouponDiscountPrice(discount.getPrice()); deduction.setCouponDiscountPrice(discount.getPrice());

Loading…
Cancel
Save