|
|
@@ -261,29 +261,32 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
throw BusinessRuntimeException.getInstance("下单商品价格异常");
|
|
|
}
|
|
|
//是否是特定价格 且是否满足
|
|
|
- Boolean isSpecificPrice = false;
|
|
|
+ Boolean isSpecificPrice = Optional.ofNullable(payRequest.getIsSpecificPrice()).orElse(false);
|
|
|
String specificGoodsIds = sku.getSpecificGoodsIds();
|
|
|
BigDecimal specificPrice = BigDecimal.ZERO;
|
|
|
- if (StrUtil.isNotEmpty(specificGoodsIds)) {
|
|
|
+ if (isSpecificPrice) {
|
|
|
+ if (StrUtil.isEmpty(specificGoodsIds)) {
|
|
|
+ throw BusinessRuntimeException.getInstance("系统异常,请刷新页面重试");
|
|
|
+ }
|
|
|
if (payRequest.getDonMoney().compareTo(sku.getSpecificPrice()) <= 0) {
|
|
|
payRequest.setDonMoney(sku.getSpecificPrice());
|
|
|
}
|
|
|
List<Long> specificGoodsList = Jsons.parseList(specificGoodsIds, Long.class);
|
|
|
- if (CollUtil.isNotEmpty(specificGoodsList)) {
|
|
|
- if (user.getId() == 0) throw BusinessRuntimeException.getGatewayApiCode(GatewayApiCode.CMS_TOKEN_VALID);
|
|
|
- Number count = beanSearcher.searchCount(OrderDon.class, MapUtils.builder().field(OrderDon::getGoodsId, specificGoodsIds).op(Operator.InList)
|
|
|
- .field(OrderDon::getUserId, user.getId())
|
|
|
- .field(OrderDon::getStatus, Constant.noOrderAllStatus).op(Operator.NotIn)
|
|
|
- .build());
|
|
|
- if (count.intValue() <= 0) {
|
|
|
- throw BusinessRuntimeException.getInstance("你不满足该商品特定价格条件");
|
|
|
- }
|
|
|
- isSpecificPrice = true;
|
|
|
- specificPrice = sku.getPrice();
|
|
|
+ if (CollUtil.isEmpty(specificGoodsList)) {
|
|
|
+ throw BusinessRuntimeException.getInstance("系统异常,请刷新页面重试");
|
|
|
+ }
|
|
|
+ if (user.getId() == 0) throw BusinessRuntimeException.getGatewayApiCode(GatewayApiCode.CMS_TOKEN_VALID);
|
|
|
+ Number count = beanSearcher.searchCount(OrderDon.class, MapUtils.builder().field(OrderDon::getGoodsId, specificGoodsIds).op(Operator.InList)
|
|
|
+ .field(OrderDon::getUserId, user.getId())
|
|
|
+ .field(OrderDon::getStatus, Constant.noOrderAllStatus).op(Operator.NotIn)
|
|
|
+ .build());
|
|
|
+ if (count.intValue() <= 0) {
|
|
|
+ throw BusinessRuntimeException.getInstance("你不满足该商品特定价格条件");
|
|
|
}
|
|
|
+ specificPrice = sku.getPrice();
|
|
|
}
|
|
|
|
|
|
- if (payRequest.getDonMoney().compareTo(sku.getPrice()) < 0) {
|
|
|
+ if (payRequest.getDonMoney().compareTo(sku.getPrice()) < 0 && !isSpecificPrice) {
|
|
|
log.info("规格:{}支付金额:{}异常,调整用户userId:{}支付金额为:{}", sku.getSpecVal(), payRequest.getDonMoney(), user.getId(), sku.getPrice());
|
|
|
payRequest.setDonMoney(sku.getPrice());
|
|
|
}
|
|
|
@@ -324,6 +327,10 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
//扣除使用优惠券、余额的订单金额
|
|
|
deductOrderMoney(orderDon, couponUser, payRequest.getBalance(), user, sku.getPrice(), goodsDon.getType());
|
|
|
|
|
|
+ if (isSpecificPrice && (orderDon.getMoney().compareTo(BigDecimal.ZERO) == 0 || orderDon.getMoney().compareTo(specificPrice) != 0)) {
|
|
|
+ throw BusinessRuntimeException.getInstance("专属价格不支持使用其他优惠");
|
|
|
+ }
|
|
|
+
|
|
|
orderDon.setSkuId(payRequest.getSkuId());
|
|
|
orderDon.setRelationId(relationId);
|
|
|
orderDon.setNum(payRequest.getNum());
|