|
@@ -105,7 +105,8 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
ConfirmOrderResult result = new ConfirmOrderResult();
|
|
|
//获取购物车信息
|
|
|
UmsMember currentMember = memberService.getCurrentMember();
|
|
|
- List<CartPromotionItem> cartPromotionItemList = cartItemService.listPromotion(currentMember.getId(), cartIds, true);
|
|
|
+ List<CartPromotionItem> cartPromotionItemList = cartItemService.listPromotion(currentMember.getId(), cartIds,
|
|
|
+ true);
|
|
|
result.setCartPromotionItemList(cartPromotionItemList);
|
|
|
//获取用户收货地址列表
|
|
|
List<UmsMemberReceiveAddress> memberReceiveAddressList = memberReceiveAddressService.list();
|
|
@@ -129,8 +130,8 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
List<OmsOrderItem> orderItemList = new ArrayList<>();
|
|
|
//获取购物车及优惠信息
|
|
|
UmsMember currentMember = memberService.getCurrentMember();
|
|
|
- List<CartPromotionItem> cartPromotionItemList = cartItemService.listPromotion(currentMember.getId(), orderParam.getCartIds(),
|
|
|
- true);
|
|
|
+ List<CartPromotionItem> cartPromotionItemList = cartItemService.listPromotion(currentMember.getId(),
|
|
|
+ orderParam.getCartIds(), true);
|
|
|
for (CartPromotionItem cartPromotionItem : cartPromotionItemList) {
|
|
|
//生成下单商品信息
|
|
|
OmsOrderItem orderItem = new OmsOrderItem();
|
|
@@ -179,13 +180,16 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
} else {
|
|
|
//使用积分
|
|
|
BigDecimal totalAmount = calcTotalAmount(orderItemList);
|
|
|
- BigDecimal integrationAmount = getUseIntegrationAmount(orderParam.getUseIntegration(), totalAmount, currentMember, orderParam.getCouponId() != null);
|
|
|
+ BigDecimal integrationAmount = getUseIntegrationAmount(orderParam.getUseIntegration(), totalAmount,
|
|
|
+ currentMember, orderParam.getCouponId() != null);
|
|
|
if (integrationAmount.compareTo(new BigDecimal(0)) == 0) {
|
|
|
Asserts.fail("积分不可用");
|
|
|
} else {
|
|
|
//可用情况下分摊到可用商品中
|
|
|
for (OmsOrderItem orderItem : orderItemList) {
|
|
|
- BigDecimal perAmount = orderItem.getProductPrice().divide(totalAmount, 3, RoundingMode.HALF_EVEN).multiply(integrationAmount);
|
|
|
+ BigDecimal perAmount = orderItem.getProductPrice()
|
|
|
+ .divide(totalAmount, 3, RoundingMode.HALF_EVEN)
|
|
|
+ .multiply(integrationAmount);
|
|
|
orderItem.setIntegrationAmount(perAmount);
|
|
|
}
|
|
|
}
|
|
@@ -200,11 +204,8 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
|
|
|
//根据商品合计、运费、活动优惠、优惠券、积分计算应付金额
|
|
|
OmsOrder order = new OmsOrder();
|
|
|
- StringBuilder cartIds = new StringBuilder();
|
|
|
- for (Long cartId : orderParam.getCartIds()) {
|
|
|
- cartIds.append(cartId.toString());
|
|
|
- }
|
|
|
- order.setCartIds(cartIds.toString());
|
|
|
+ String cartIds = orderParam.getCartIds().stream().map(String::valueOf).collect(Collectors.joining());
|
|
|
+ order.setCartIds(cartIds);
|
|
|
order.setDiscountAmount(new BigDecimal(0));
|
|
|
order.setTotalAmount(calcTotalAmount(orderItemList));
|
|
|
order.setFreightAmount(new BigDecimal(0));
|
|
@@ -273,7 +274,8 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
//如使用积分需要扣除积分
|
|
|
if (orderParam.getUseIntegration() != null) {
|
|
|
order.setUseIntegration(orderParam.getUseIntegration());
|
|
|
- memberService.updateIntegration(currentMember.getId(), currentMember.getIntegration() - orderParam.getUseIntegration());
|
|
|
+ memberService.updateIntegration(currentMember.getId(),
|
|
|
+ currentMember.getIntegration() - orderParam.getUseIntegration());
|
|
|
}
|
|
|
//删除购物车中的下单商品
|
|
|
deleteCartItemList(cartPromotionItemList, currentMember);
|
|
@@ -306,18 +308,19 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 减商品库存
|
|
|
+ * 减商品库存
|
|
|
*/
|
|
|
private void updateProductStock(OmsOrderDetail orderDetail) {
|
|
|
Map<Long, List<OmsOrderItem>> collect = orderDetail.getOrderItemList()
|
|
|
- .stream().collect(Collectors.groupingBy(OmsOrderItem::getProductId));
|
|
|
+ .stream()
|
|
|
+ .collect(Collectors.groupingBy(OmsOrderItem::getProductId));
|
|
|
|
|
|
List<ProductStock> productStockList = new ArrayList<>();
|
|
|
for (Map.Entry<Long, List<OmsOrderItem>> entry : collect.entrySet()) {
|
|
|
ProductStock stock = new ProductStock();
|
|
|
stock.setProductId(entry.getKey());
|
|
|
List<OmsOrderItem> value = entry.getValue();
|
|
|
- if(CollectionUtils.isEmpty(value)) {
|
|
|
+ if (CollectionUtils.isEmpty(value)) {
|
|
|
continue;
|
|
|
}
|
|
|
int sum = value.stream().mapToInt(OmsOrderItem::getProductQuantity).sum();
|
|
@@ -332,8 +335,8 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
Integer count = 0;
|
|
|
OmsOrderSetting orderSetting = orderSettingMapper.selectByPrimaryKey(1L);
|
|
|
//查询超时、未支付的订单及订单详情
|
|
|
- List<OmsOrderDetail> timeOutOrders = portalOrderDao.getTimeOutOrders(orderSetting.getNormalOrderOvertime()
|
|
|
- , orderSetting.getPayOrderOvertime());
|
|
|
+ List<OmsOrderDetail> timeOutOrders = portalOrderDao.getTimeOutOrders(orderSetting.getNormalOrderOvertime(),
|
|
|
+ orderSetting.getPayOrderOvertime());
|
|
|
if (CollectionUtils.isEmpty(timeOutOrders)) {
|
|
|
return count;
|
|
|
}
|
|
@@ -375,10 +378,11 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
//返还使用积分
|
|
|
if (cancelOrder.getUseIntegration() != null) {
|
|
|
UmsMember member = memberService.getById(cancelOrder.getMemberId());
|
|
|
- memberService.updateIntegration(cancelOrder.getMemberId(), member.getIntegration() + cancelOrder.getUseIntegration());
|
|
|
+ memberService.updateIntegration(cancelOrder.getMemberId(),
|
|
|
+ member.getIntegration() + cancelOrder.getUseIntegration());
|
|
|
}
|
|
|
// 发起关单
|
|
|
- userOrderPaymentService.closePayment(cancelOrder.getOrderSn(),message,data);
|
|
|
+ userOrderPaymentService.closePayment(cancelOrder.getOrderSn(), message, data);
|
|
|
|
|
|
}
|
|
|
}
|
|
@@ -417,8 +421,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
|
OmsOrderExample orderExample = new OmsOrderExample();
|
|
|
OmsOrderExample.Criteria criteria = orderExample.createCriteria();
|
|
|
- criteria.andDeleteStatusEqualTo(0)
|
|
|
- .andMemberIdEqualTo(member.getId());
|
|
|
+ criteria.andDeleteStatusEqualTo(0).andMemberIdEqualTo(member.getId());
|
|
|
if (status != null && !StringUtil.isEmpty(status)) {
|
|
|
List<Long> list = StringUtil.toLongList(status);
|
|
|
List<Integer> collect = list.stream().map(Long::intValue).collect(Collectors.toList());
|
|
@@ -445,7 +448,10 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
for (OmsOrder omsOrder : orderList) {
|
|
|
OmsOrderDetail orderDetail = new OmsOrderDetail();
|
|
|
BeanUtil.copyProperties(omsOrder, orderDetail);
|
|
|
- List<OmsOrderItem> relatedItemList = orderItemList.stream().filter(item -> item.getOrderId().equals(orderDetail.getId())).collect(Collectors.toList());
|
|
|
+ List<OmsOrderItem> relatedItemList = orderItemList.stream()
|
|
|
+ .filter(item -> item.getOrderId()
|
|
|
+ .equals(orderDetail.getId()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
orderDetail.setOrderItemList(relatedItemList);
|
|
|
orderDetailList.add(orderDetail);
|
|
|
}
|
|
@@ -514,8 +520,9 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
orderPayRes.setMessage("订单已付款或已关闭");
|
|
|
return orderPayRes;
|
|
|
}
|
|
|
- UserOrderPayment userOrderPayment = userOrderPaymentService
|
|
|
- .getByOrderNo(detail.getOrderSn(), payReq.getPayChannel(), TradeStatusEnum.pending);
|
|
|
+ UserOrderPayment userOrderPayment = userOrderPaymentService.getByOrderNo(detail.getOrderSn(),
|
|
|
+ payReq.getPayChannel(),
|
|
|
+ TradeStatusEnum.pending);
|
|
|
|
|
|
if (userOrderPayment != null) {
|
|
|
// 拉起原有的支付
|
|
@@ -528,8 +535,8 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
|
|
|
//构建汇付统一下单请求
|
|
|
OpenEnum openType = OpenEnum.valueOf(paymentProperties.getOpenType());
|
|
|
- Payment payment = new Payment(openType,
|
|
|
- PaymentClientEnum.valueOf(payReq.getPaymentClient()), payReq.getPayChannel());
|
|
|
+ Payment payment = new Payment(openType, PaymentClientEnum.valueOf(payReq.getPaymentClient()),
|
|
|
+ payReq.getPayChannel());
|
|
|
payment.setPaymentNo(generateOrderSn(detail));
|
|
|
payment.setOrderNo(payReq.getOrderNo());
|
|
|
payment.setOrderTitle("酷乐秀商城订单编号-" + detail.getOrderSn());
|
|
@@ -539,7 +546,8 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
List<OrderDetil> orderDetails = new ArrayList<>();
|
|
|
for (OmsOrderItem orderDetailVo : detail.getOrderItemList()) {
|
|
|
orderDetails.add(new OrderDetil(orderDetailVo.getId().toString(), orderDetailVo.getProductName(),
|
|
|
- orderDetailVo.getProductQuantity(), orderDetailVo.getRealAmount().toString()));
|
|
|
+ orderDetailVo.getProductQuantity(),
|
|
|
+ orderDetailVo.getRealAmount().toString()));
|
|
|
}
|
|
|
payment.setOrderDetils(orderDetails);
|
|
|
payment.setPayAmt(detail.getPayAmount().setScale(2, RoundingMode.HALF_UP).toString());
|
|
@@ -572,13 +580,15 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
cancelOrder(detail.getId(), executePayment.getMsg(), null);
|
|
|
throw new BizException(executePayment.getMsg());
|
|
|
}
|
|
|
- if (!executePayment.getData().getPayAmt().equals(detail.getPayAmount().setScale(2, RoundingMode.HALF_UP).toString())) {
|
|
|
+ if (!executePayment.getData()
|
|
|
+ .getPayAmt()
|
|
|
+ .equals(detail.getPayAmount().setScale(2, RoundingMode.HALF_UP).toString())) {
|
|
|
cancelOrder(detail.getId(), "订单金额和实际支付金额不符", null);
|
|
|
throw new BizException("订单金额和实际支付金额不符");
|
|
|
}
|
|
|
|
|
|
|
|
|
- saveOrderPayment(executePayment.getData(), detail,payReq.getPaymentClient());
|
|
|
+ saveOrderPayment(executePayment.getData(), detail, payReq.getPaymentClient());
|
|
|
|
|
|
if (executePayment.getStatus()) {
|
|
|
orderPayRes.setPay_amt(detail.getPayAmount().setScale(2, RoundingMode.HALF_UP).toString());
|
|
@@ -596,7 +606,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
}
|
|
|
|
|
|
|
|
|
- private void saveOrderPayment(Payment payment, OmsOrderDetail detail,String paymentClient) {
|
|
|
+ private void saveOrderPayment(Payment payment, OmsOrderDetail detail, String paymentClient) {
|
|
|
UserOrderPayment userOrderPayment;
|
|
|
OmsOrder omsOrder = new OmsOrder();
|
|
|
omsOrder.setId(detail.getId());
|
|
@@ -660,7 +670,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
}
|
|
|
OmsOrderDetail detail = detail(userOrderPayment.getOrderNo());
|
|
|
if (detail.getStatus() == 0) {
|
|
|
- orderSuccess(detail, data,data.getId());
|
|
|
+ orderSuccess(detail, data, data.getId());
|
|
|
} else {
|
|
|
LOG.error("汇付支付回调,订单状态异常。 req is {}", detail.getOrderSn());
|
|
|
}
|
|
@@ -688,7 +698,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
}
|
|
|
if (detail.getStatus() == 0) {
|
|
|
|
|
|
- cancelOrder(detail.getId(), data.getErrMsg(),data);
|
|
|
+ cancelOrder(detail.getId(), data.getErrMsg(), data);
|
|
|
} else {
|
|
|
LOG.error("汇付支付回调,订单状态异常。 req is {}", dataString);
|
|
|
}
|
|
@@ -744,15 +754,17 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
OmsOrderDetail detail = detail(orderPayment.getOrderNo());
|
|
|
try {
|
|
|
Payment param = new Payment(OpenEnum.valueOf(orderPayment.getOpenType()),
|
|
|
- PaymentClientEnum.valueOf(orderPayment.getPaymentClient()), PayChannelEnum.valueOf(orderPayment.getPayChannel()));
|
|
|
+ PaymentClientEnum.valueOf(orderPayment.getPaymentClient()),
|
|
|
+ PayChannelEnum.valueOf(orderPayment.getPayChannel()));
|
|
|
param.setId(orderPayment.getTransNo());
|
|
|
param.setPaymentNo(orderPayment.getAdapayNo());
|
|
|
BaseResult<Payment> res = paymentClient.queryPayment(param);
|
|
|
//支付成功
|
|
|
- if (res.getStatus() && TradeStatusEnum.succeeded.getCode().equals(res.getData().getStatus().getCode())
|
|
|
- && (detail.getStatus() == 0 || detail.getStatus() == 1)
|
|
|
- ) {
|
|
|
- orderSuccess(detail,res.getData().getId());
|
|
|
+ if (res.getStatus() && TradeStatusEnum.succeeded.getCode()
|
|
|
+ .equals(res.getData()
|
|
|
+ .getStatus()
|
|
|
+ .getCode()) && (detail.getStatus() == 0 || detail.getStatus() == 1)) {
|
|
|
+ orderSuccess(detail, res.getData().getId());
|
|
|
return;
|
|
|
}
|
|
|
//支付失败
|
|
@@ -769,7 +781,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
|
|
|
|
|
|
void orderSuccess(OmsOrder detail, String tranId) {
|
|
|
- orderSuccess(detail,null,tranId);
|
|
|
+ orderSuccess(detail, null, tranId);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -794,9 +806,9 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
}
|
|
|
}
|
|
|
if (orderPayment.getPayChannel().equals("alipay") || orderPayment.getPayChannel().equals("ali_app")) {
|
|
|
- paySuccess(detail.getId(),1);
|
|
|
+ paySuccess(detail.getId(), 1);
|
|
|
} else if (orderPayment.getPayChannel().equals("wx_lite") || orderPayment.getPayChannel().equals("wx_app")) {
|
|
|
- paySuccess(detail.getId(),2);
|
|
|
+ paySuccess(detail.getId(), 2);
|
|
|
}
|
|
|
|
|
|
orderPayment.setStatus(TradeStatusEnum.succeeded.getCode());
|
|
@@ -881,8 +893,10 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
if (couponId == null) return;
|
|
|
//查询第一张优惠券
|
|
|
SmsCouponHistoryExample example = new SmsCouponHistoryExample();
|
|
|
- example.createCriteria().andMemberIdEqualTo(memberId)
|
|
|
- .andCouponIdEqualTo(couponId).andUseStatusEqualTo(useStatus == 0 ? 1 : 0);
|
|
|
+ example.createCriteria()
|
|
|
+ .andMemberIdEqualTo(memberId)
|
|
|
+ .andCouponIdEqualTo(couponId)
|
|
|
+ .andUseStatusEqualTo(useStatus == 0 ? 1 : 0);
|
|
|
List<SmsCouponHistory> couponHistoryList = couponHistoryMapper.selectByExample(example);
|
|
|
if (!CollectionUtils.isEmpty(couponHistoryList)) {
|
|
|
SmsCouponHistory couponHistory = couponHistoryList.get(0);
|
|
@@ -896,9 +910,9 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
for (OmsOrderItem orderItem : orderItemList) {
|
|
|
//原价-促销优惠-优惠券抵扣-积分抵扣
|
|
|
BigDecimal realAmount = orderItem.getProductPrice()
|
|
|
- .subtract(orderItem.getPromotionAmount())
|
|
|
- .subtract(orderItem.getCouponAmount())
|
|
|
- .subtract(orderItem.getIntegrationAmount());
|
|
|
+ .subtract(orderItem.getPromotionAmount())
|
|
|
+ .subtract(orderItem.getCouponAmount())
|
|
|
+ .subtract(orderItem.getIntegrationAmount());
|
|
|
orderItem.setRealAmount(realAmount);
|
|
|
}
|
|
|
}
|
|
@@ -938,7 +952,8 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
BigDecimal integrationAmount = new BigDecimal(0);
|
|
|
for (OmsOrderItem orderItem : orderItemList) {
|
|
|
if (orderItem.getIntegrationAmount() != null) {
|
|
|
- integrationAmount = integrationAmount.add(orderItem.getIntegrationAmount().multiply(new BigDecimal(orderItem.getProductQuantity())));
|
|
|
+ integrationAmount = integrationAmount.add(
|
|
|
+ orderItem.getIntegrationAmount().multiply(new BigDecimal(orderItem.getProductQuantity())));
|
|
|
}
|
|
|
}
|
|
|
return integrationAmount;
|
|
@@ -951,7 +966,8 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
BigDecimal couponAmount = new BigDecimal(0);
|
|
|
for (OmsOrderItem orderItem : orderItemList) {
|
|
|
if (orderItem.getCouponAmount() != null) {
|
|
|
- couponAmount = couponAmount.add(orderItem.getCouponAmount().multiply(new BigDecimal(orderItem.getProductQuantity())));
|
|
|
+ couponAmount = couponAmount.add(
|
|
|
+ orderItem.getCouponAmount().multiply(new BigDecimal(orderItem.getProductQuantity())));
|
|
|
}
|
|
|
}
|
|
|
return couponAmount;
|
|
@@ -964,7 +980,8 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
BigDecimal promotionAmount = new BigDecimal(0);
|
|
|
for (OmsOrderItem orderItem : orderItemList) {
|
|
|
if (orderItem.getPromotionAmount() != null) {
|
|
|
- promotionAmount = promotionAmount.add(orderItem.getPromotionAmount().multiply(new BigDecimal(orderItem.getProductQuantity())));
|
|
|
+ promotionAmount = promotionAmount.add(
|
|
|
+ orderItem.getPromotionAmount().multiply(new BigDecimal(orderItem.getProductQuantity())));
|
|
|
}
|
|
|
}
|
|
|
return promotionAmount;
|
|
@@ -996,8 +1013,10 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
return zeroAmount;
|
|
|
}
|
|
|
//是否超过订单抵用最高百分比
|
|
|
- BigDecimal integrationAmount = new BigDecimal(useIntegration).divide(new BigDecimal(integrationConsumeSetting.getUseUnit()), 2, RoundingMode.HALF_EVEN);
|
|
|
- BigDecimal maxPercent = new BigDecimal(integrationConsumeSetting.getMaxPercentPerOrder()).divide(new BigDecimal(100), 2, RoundingMode.HALF_EVEN);
|
|
|
+ BigDecimal integrationAmount = new BigDecimal(useIntegration).divide(
|
|
|
+ new BigDecimal(integrationConsumeSetting.getUseUnit()), 2, RoundingMode.HALF_EVEN);
|
|
|
+ BigDecimal maxPercent = new BigDecimal(integrationConsumeSetting.getMaxPercentPerOrder()).divide(
|
|
|
+ new BigDecimal(100), 2, RoundingMode.HALF_EVEN);
|
|
|
if (integrationAmount.compareTo(totalAmount.multiply(maxPercent)) > 0) {
|
|
|
return zeroAmount;
|
|
|
}
|
|
@@ -1017,11 +1036,13 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
calcPerCouponAmount(orderItemList, coupon);
|
|
|
} else if (coupon.getUseType().equals(1)) {
|
|
|
//指定分类
|
|
|
- List<OmsOrderItem> couponOrderItemList = getCouponOrderItemByRelation(couponHistoryDetail, orderItemList, 0);
|
|
|
+ List<OmsOrderItem> couponOrderItemList = getCouponOrderItemByRelation(couponHistoryDetail, orderItemList,
|
|
|
+ 0);
|
|
|
calcPerCouponAmount(couponOrderItemList, coupon);
|
|
|
} else if (coupon.getUseType().equals(2)) {
|
|
|
//指定商品
|
|
|
- List<OmsOrderItem> couponOrderItemList = getCouponOrderItemByRelation(couponHistoryDetail, orderItemList, 1);
|
|
|
+ List<OmsOrderItem> couponOrderItemList = getCouponOrderItemByRelation(couponHistoryDetail, orderItemList,
|
|
|
+ 1);
|
|
|
calcPerCouponAmount(couponOrderItemList, coupon);
|
|
|
}
|
|
|
}
|
|
@@ -1035,7 +1056,9 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
BigDecimal totalAmount = calcTotalAmount(orderItemList);
|
|
|
for (OmsOrderItem orderItem : orderItemList) {
|
|
|
//(商品价格/可用商品总价)*优惠券面额
|
|
|
- BigDecimal couponAmount = orderItem.getProductPrice().divide(totalAmount, 3, RoundingMode.HALF_EVEN).multiply(coupon.getAmount());
|
|
|
+ BigDecimal couponAmount = orderItem.getProductPrice()
|
|
|
+ .divide(totalAmount, 3, RoundingMode.HALF_EVEN)
|
|
|
+ .multiply(coupon.getAmount());
|
|
|
orderItem.setCouponAmount(couponAmount);
|
|
|
}
|
|
|
}
|
|
@@ -1112,7 +1135,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
if (cartPromotionItem.getProductSkuId() == null) {
|
|
|
continue;
|
|
|
}
|
|
|
- int i = skuStockMapper.lockStock(cartPromotionItem.getProductSkuId(),cartPromotionItem.getQuantity());
|
|
|
+ int i = skuStockMapper.lockStock(cartPromotionItem.getProductSkuId(), cartPromotionItem.getQuantity());
|
|
|
if (i == 0) {
|
|
|
Asserts.fail("库存不足");
|
|
|
}
|
|
@@ -1124,15 +1147,16 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
*/
|
|
|
private void lockProductStock(List<CartPromotionItem> cartPromotionItemList) {
|
|
|
Map<Long, List<CartPromotionItem>> collect = cartPromotionItemList.stream()
|
|
|
- .collect(Collectors.groupingBy(CartPromotionItem::getProductId));
|
|
|
+ .collect(Collectors.groupingBy(
|
|
|
+ CartPromotionItem::getProductId));
|
|
|
for (Map.Entry<Long, List<CartPromotionItem>> entry : collect.entrySet()) {
|
|
|
List<CartPromotionItem> value = entry.getValue();
|
|
|
- if(CollectionUtils.isEmpty(value)) {
|
|
|
+ if (CollectionUtils.isEmpty(value)) {
|
|
|
continue;
|
|
|
}
|
|
|
int sum = value.stream().mapToInt(CartPromotionItem::getQuantity).sum();
|
|
|
- if (sum >0 ) {
|
|
|
- int i = pmsProductMapper.lockStock(entry.getKey(),sum);
|
|
|
+ if (sum > 0) {
|
|
|
+ int i = pmsProductMapper.lockStock(entry.getKey(), sum);
|
|
|
if (i == 0) {
|
|
|
Asserts.fail("库存不足");
|
|
|
}
|
|
@@ -1161,8 +1185,10 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
|
|
|
BigDecimal totalAmount = new BigDecimal("0");
|
|
|
BigDecimal promotionAmount = new BigDecimal("0");
|
|
|
for (CartPromotionItem cartPromotionItem : cartPromotionItemList) {
|
|
|
- totalAmount = totalAmount.add(cartPromotionItem.getPrice().multiply(new BigDecimal(cartPromotionItem.getQuantity())));
|
|
|
- promotionAmount = promotionAmount.add(cartPromotionItem.getReduceAmount().multiply(new BigDecimal(cartPromotionItem.getQuantity())));
|
|
|
+ totalAmount = totalAmount.add(
|
|
|
+ cartPromotionItem.getPrice().multiply(new BigDecimal(cartPromotionItem.getQuantity())));
|
|
|
+ promotionAmount = promotionAmount.add(
|
|
|
+ cartPromotionItem.getReduceAmount().multiply(new BigDecimal(cartPromotionItem.getQuantity())));
|
|
|
}
|
|
|
calcAmount.setTotalAmount(totalAmount);
|
|
|
calcAmount.setPromotionAmount(promotionAmount);
|