|
|
@@ -148,6 +148,8 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
|
|
|
private final GroupsRelationNetflixService groupsRelationNetflixService;
|
|
|
|
|
|
+ private final OrderDonLocationRelateMapper orderDonLocationRelateMapper;
|
|
|
+
|
|
|
@Transactional(rollbackFor = Throwable.class)
|
|
|
@Override
|
|
|
public OrderDon submit(OrderPayRequest payRequest) throws Exception {
|
|
|
@@ -199,7 +201,35 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
if (sku.getPrice() == null || sku.getPrice().compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("sku_price_error"));
|
|
|
}
|
|
|
- if (payRequest.getDonMoney().compareTo(sku.getPrice()) < 0) {
|
|
|
+
|
|
|
+ //是否是特定价格 且是否满足
|
|
|
+ Boolean isSpecificPrice = Optional.ofNullable(payRequest.getIsSpecificPrice()).orElse(false);
|
|
|
+ String specificGoodsIds = null;
|
|
|
+ BigDecimal specificPrice = BigDecimal.ZERO;
|
|
|
+ if (isSpecificPrice) {
|
|
|
+ specificGoodsIds = sku.getSpecificGoodsIds();
|
|
|
+ if (StrUtil.isEmpty(specificGoodsIds)) {
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("sys_error"));
|
|
|
+ }
|
|
|
+ if (payRequest.getDonMoney().compareTo(sku.getSpecificPrice()) <= 0) {
|
|
|
+ payRequest.setDonMoney(sku.getSpecificPrice());
|
|
|
+ }
|
|
|
+ List<Long> specificGoodsList = Jsons.parseList(specificGoodsIds, Long.class);
|
|
|
+ if (CollUtil.isEmpty(specificGoodsList)) {
|
|
|
+ throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("sys_error"));
|
|
|
+ }
|
|
|
+ if (user.getId() == 0) throw BusinessRuntimeException.getGatewayApiCode(GatewayApiCode.CMS_TOKEN_VALID);
|
|
|
+ Number count = beanSearcher.searchCount(OrderDon.class, MapUtils.builder().field(OrderDon::getGoodsId, specificGoodsList).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.getSpecificPrice();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (sku != null && payRequest.getDonMoney().compareTo(sku.getPrice()) < 0 && !isSpecificPrice) {
|
|
|
log.info("规格:{}支付金额:{}异常,调整用户userId:{}支付金额为:{}", sku.getSpecVal(), payRequest.getDonMoney(), user.getId(), sku.getPrice());
|
|
|
payRequest.setDonMoney(sku.getPrice());
|
|
|
}
|
|
|
@@ -211,9 +241,6 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
orderDon.setRate(payRequest.getRate());
|
|
|
List<Long> dpSkuIds = payRequest.getDpSkuIds();
|
|
|
if (CollUtil.isNotEmpty(dpSkuIds)) {
|
|
|
- if (dpSkuIds.size() > 1) {
|
|
|
- throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("dp_one_goods_pay_error"));
|
|
|
- }
|
|
|
//是否满足关联
|
|
|
List<GoodsDiscountPlusPurchaseRelation> ds_relations = discountPlusPurchaseRelationMapper.selectList(Wrappers.lambdaQuery(GoodsDiscountPlusPurchaseRelation.class)
|
|
|
.eq(GoodsDiscountPlusPurchaseRelation::getSkuId, sku.getId())
|
|
|
@@ -226,6 +253,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
for (GoodsDiscountPlusPurchaseRelation re : ds_relations) {
|
|
|
goods_discount_plus_pay = goods_discount_plus_pay.add(re.getDisPrice());
|
|
|
dsSkuIds.add(re.getDisSid());
|
|
|
+ orderDon.setDpMoney(goods_discount_plus_pay);
|
|
|
}
|
|
|
BigDecimal pay_money = sku.getPrice().add(goods_discount_plus_pay);
|
|
|
if (pay_money.compareTo(orderDon.getMoney()) > 0) {
|
|
|
@@ -260,21 +288,8 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
}
|
|
|
}
|
|
|
orderDon.setPayDesc(goodsDon.getPayDesc());
|
|
|
- StringBuilder payTitle = new StringBuilder();
|
|
|
- payTitle.append(goodsDon.getTitle());
|
|
|
- payTitle.append(sku.getSpecVal());
|
|
|
- if (orderDon.getIsDp()) {
|
|
|
- List<GoodsDonSkuView> dp_skuViewList = beanSearcher.searchAll(GoodsDonSkuView.class, MapUtils.builder().field(GoodsDonSkuView::getSkuId, dpSkuIds).op(Operator.InList).build());
|
|
|
- if (dp_skuViewList.size() != dpSkuIds.size()) {
|
|
|
- throw BusinessRuntimeException.getInstance(I18nMessageUtil.getI18nMsg("sys_error"));
|
|
|
- }
|
|
|
- dp_skuViewList.forEach(dp_SkuView -> {
|
|
|
- payTitle.append(" + ");
|
|
|
- payTitle.append(dp_SkuView.getGoodsTitle());
|
|
|
- payTitle.append(dp_SkuView.getSpecVal());
|
|
|
- });
|
|
|
- }
|
|
|
- orderDon.setPayTitle(payTitle.toString());
|
|
|
+ //设置订单支付商品信息
|
|
|
+ setOrderDonPayTile(orderDon, goodsDon, sku, dpSkuIds);
|
|
|
if ("TWD".equals(payRequest.getCurrency())){
|
|
|
orderDon.setMoney(orderDon.getMoney().setScale(-2, RoundingMode.HALF_UP));
|
|
|
}
|
|
|
@@ -316,6 +331,8 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
}
|
|
|
}
|
|
|
orderDon.setSpecialType(goodsDon.getSpecialType());
|
|
|
+ //记录订单ip关联
|
|
|
+ recordOrderDonLocationRelate(orderDon.getId(), payRequest.getIp());
|
|
|
return orderDon;
|
|
|
}
|
|
|
|
|
|
@@ -1169,4 +1186,34 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
userBenefitsService.recordBalanceBySource(orderDon.getUserId(), orderDon.getBalance().negate(), UserBalanceSourceRecord.Source.payment, orderDon.getId(), goodsDon.getTitle() + UserBalanceSourceRecord.Source.payment.getDesc());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置订单支付商品属性
|
|
|
+ */
|
|
|
+ public void setOrderDonPayTile(OrderDon orderDon, GoodsDon goodsDon, GoodsDonSku sku, List<Long> dpSkuIds) {
|
|
|
+ StringBuilder payTitle = new StringBuilder();
|
|
|
+ payTitle.append(goodsDon.getTitle());
|
|
|
+ if (sku != null) {
|
|
|
+ payTitle.append(sku.getSpecVal());
|
|
|
+ }
|
|
|
+ if (orderDon.getIsDp()) {
|
|
|
+ List<GoodsDonSkuView> dp_skuViewList = beanSearcher.searchAll(GoodsDonSkuView.class, MapUtils.builder().field(GoodsDonSkuView::getSkuId, dpSkuIds).op(Operator.InList).build());
|
|
|
+ if (dp_skuViewList.size() != dpSkuIds.size()) {
|
|
|
+ throw BusinessRuntimeException.getInstance("系统异常,请刷新页面重新下单");
|
|
|
+ }
|
|
|
+ dp_skuViewList.forEach(dp_SkuView -> {
|
|
|
+ payTitle.append(" + ");
|
|
|
+ payTitle.append(dp_SkuView.getGoodsTitle());
|
|
|
+ payTitle.append(dp_SkuView.getSpecVal());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ orderDon.setPayTitle(payTitle.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ private void recordOrderDonLocationRelate(Long orderId, String ip) {
|
|
|
+ OrderDonLocationRelate orderDonLocationRelate = new OrderDonLocationRelate();
|
|
|
+ orderDonLocationRelate.setOrderId(orderId);
|
|
|
+ orderDonLocationRelate.setIp(ip);
|
|
|
+ orderDonLocationRelateMapper.insert(orderDonLocationRelate);
|
|
|
+ }
|
|
|
}
|