|
|
@ -409,6 +409,7 @@ public class HighOrderController { |
|
|
|
totalPrice = totalPrice.add(childOrder.getTotalPrice()); |
|
|
|
totalPrice = totalPrice.add(childOrder.getTotalPrice()); |
|
|
|
totalActualPrice = totalActualPrice.add(childOrder.getGoodsActualPrice()); |
|
|
|
totalActualPrice = totalActualPrice.add(childOrder.getGoodsActualPrice()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 积分抵扣金额
|
|
|
|
// 积分抵扣金额
|
|
|
|
BigDecimal integralDeductionPrice = new BigDecimal(0); |
|
|
|
BigDecimal integralDeductionPrice = new BigDecimal(0); |
|
|
|
if (buyPoints && highOrder.getPayGold() != null) { |
|
|
|
if (buyPoints && highOrder.getPayGold() != null) { |
|
|
@ -447,6 +448,11 @@ public class HighOrderController { |
|
|
|
log.error("HighOrderController --> addOrder() error!", "此优惠券只能充值话费中使用"); |
|
|
|
log.error("HighOrderController --> addOrder() error!", "此优惠券只能充值话费中使用"); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.UN_MEMBER_ERROR, "此优惠券只能充值话费中使用"); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.UN_MEMBER_ERROR, "此优惠券只能充值话费中使用"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else if (highDiscountUserRel.getHighDiscount().getUseScope().equals(DiscountUseScope.type3.getType())) { |
|
|
|
|
|
|
|
if (!highOrder.getHighChildOrderList().get(0).getGoodsType().equals(3)) { |
|
|
|
|
|
|
|
log.error("HighOrderController --> addOrder() error!", "此优惠券只能充值话费中使用"); |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.UN_MEMBER_ERROR, "此优惠券只能充值话费中使用"); |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
log.error("HighOrderController --> addOrder() error!", "暂时无法使用此优惠券"); |
|
|
|
log.error("HighOrderController --> addOrder() error!", "暂时无法使用此优惠券"); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.UN_MEMBER_ERROR, "暂时无法使用此优惠券"); |
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.UN_MEMBER_ERROR, "暂时无法使用此优惠券"); |
|
|
@ -619,70 +625,4 @@ public class HighOrderController { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/orderCanUseDiscount",method = RequestMethod.POST) |
|
|
|
|
|
|
|
@ResponseBody |
|
|
|
|
|
|
|
@ApiOperation(value = "订单可以使用的优惠券") |
|
|
|
|
|
|
|
public ResponseData orderCanUseDiscount(@RequestBody JSONObject body) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
// 用户
|
|
|
|
|
|
|
|
HighUserModel userInfoModel = userCenter.getSessionModel(HighUserModel.class); |
|
|
|
|
|
|
|
if (userInfoModel == null) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, ""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (body == null |
|
|
|
|
|
|
|
|| body.getInteger("goodsType") == null |
|
|
|
|
|
|
|
|| body.getLong("goodsId") == null |
|
|
|
|
|
|
|
|| body.getBigDecimal("goodsPrice") == null |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 商品类型
|
|
|
|
|
|
|
|
OrderChildGoodsTypeEnum goodsType = OrderChildGoodsTypeEnum.getDataByType(body.getInteger("goodsType")); |
|
|
|
|
|
|
|
if (goodsType == null) { |
|
|
|
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的商品类型"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String,Object> map = new HashMap<>(); |
|
|
|
|
|
|
|
map.put("userId", userInfoModel.getHighUser().getId()); |
|
|
|
|
|
|
|
map.put("status", 1); |
|
|
|
|
|
|
|
// 查询用户的优惠券
|
|
|
|
|
|
|
|
List<HighDiscountUserRel> userDiscountList = highDiscountUserRelService.getDiscountList(map); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<HighDiscountUserRel> list = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (userDiscountList.size() > 0) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (goodsType.getType().equals(OrderChildGoodsTypeEnum.type1.getType())) { |
|
|
|
|
|
|
|
// 查询当前卡券有哪些优惠券
|
|
|
|
|
|
|
|
List<HighDiscountCouponRel> discountCouponRelList = highDiscountCouponRelService.getRelByCoupon(body.getLong("goodsId")); |
|
|
|
|
|
|
|
if (discountCouponRelList.size() > 0) { |
|
|
|
|
|
|
|
for (HighDiscountCouponRel highDiscountCouponRel : discountCouponRelList) { |
|
|
|
|
|
|
|
List<HighDiscountUserRel> collect = userDiscountList.stream().filter(o -> o.getDiscountId().equals(highDiscountCouponRel.getDiscountId())).collect(Collectors.toList()); |
|
|
|
|
|
|
|
if (collect != null && collect.size() > 0) { |
|
|
|
|
|
|
|
for (HighDiscountUserRel discountUser : collect) { |
|
|
|
|
|
|
|
list.add(discountUser); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (goodsType.getType().equals(OrderChildGoodsTypeEnum.type3.getType())) { |
|
|
|
|
|
|
|
// 过滤出加油服务的加油券
|
|
|
|
|
|
|
|
List<HighDiscountUserRel> collect = userDiscountList.stream().filter(o -> o.getHighDiscount().getUseScope().equals(DiscountUseScope.type7.getType())).collect(Collectors.toList()); |
|
|
|
|
|
|
|
for (HighDiscountUserRel userDiscount : collect) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
list.sort(Comparator.comparing(o -> o.getUseEndTime())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return ResponseMsgUtil.success(list); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
log.error("HighDiscountController -> getDiscountListByCoupon() error!",e); |
|
|
|
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|