|
@@ -92,7 +92,7 @@ public class OrderController {
|
|
|
}
|
|
|
}
|
|
|
String userId = SecurityUtils.getUser().getUserId();
|
|
|
- orderParam.setDvyType(1);
|
|
|
+// orderParam.setDvyType(1);
|
|
|
|
|
|
// 订单的地址信息
|
|
|
UserAddr userAddr = userAddrService.getUserAddrByUserId(orderParam.getAddrId(), userId);
|
|
@@ -109,7 +109,7 @@ public class OrderController {
|
|
|
|
|
|
// 将要返回给前端的完整的订单信息
|
|
|
ShopCartOrderMergerDto shopCartOrderMergerDto = new ShopCartOrderMergerDto();
|
|
|
- shopCartOrderMergerDto.setDvyType(orderParam.getDvyType());
|
|
|
+// shopCartOrderMergerDto.setDvyType(orderParam.getDvyType());
|
|
|
shopCartOrderMergerDto.setUserAddr(userAddrDto);
|
|
|
shopCartOrderMergerDto.setIsScorePay(orderParam.getIsScorePay());
|
|
|
// 所有店铺的订单信息
|
|
@@ -142,46 +142,46 @@ public class OrderController {
|
|
|
|
|
|
shopCartOrder.setShopCartItemDiscounts(shopCartItemDiscounts);
|
|
|
allCartItem.addAll(shopAllShopCartItems);
|
|
|
- // TODO wangjian 计算积分抵现和分摊,报错
|
|
|
+
|
|
|
applicationContext.publishEvent(new ConfirmOrderEvent(shopCartOrder, orderParam, shopAllShopCartItems));
|
|
|
|
|
|
total = Arith.add(total, shopCartOrder.getTotal());
|
|
|
totalCount = totalCount + shopCartOrder.getTotalCount();
|
|
|
allOrderReduce = Arith.add(allOrderReduce, shopCartOrder.getShopReduce());
|
|
|
-
|
|
|
+ //TODO wangjian 计算配送方式,和运费
|
|
|
totalTransfee = Arith.add(totalTransfee, shopCartOrder.getTransfee());
|
|
|
weight = Arith.add(weight, shopCartOrder.getTotalWeight());
|
|
|
shopCartOrders.add(shopCartOrder);
|
|
|
}
|
|
|
|
|
|
-// //根据价格进行店铺、满减、商品项的价格升序操作
|
|
|
-// for (int n = 0; n < shopCartOrders.size(); n++) {
|
|
|
-// shopCartOrders = shopCartOrders.stream().sorted(Comparator.comparing(ShopCartOrderDto::getActualTotal)).collect(Collectors.toList());
|
|
|
-// ShopCartOrderDto shopCartOrderDto = shopCartOrders.get(n);
|
|
|
-//
|
|
|
-// List<ShopCartItemDiscountDto> shopCartItemDiscounts = shopCartOrderDto.getShopCartItemDiscounts();
|
|
|
-// for (ShopCartItemDiscountDto shopCartItemDiscount : shopCartItemDiscounts) {
|
|
|
-// List<ShopCartItemDto> sortShopCartItems = shopCartItemDiscount.getShopCartItems();
|
|
|
-// sortShopCartItems = sortShopCartItems.stream().sorted(Comparator.comparing(ProductItemDto::getActualTotal)).collect(Collectors.toList());
|
|
|
-// shopCartItemDiscount.setShopCartItems(sortShopCartItems);
|
|
|
-// double totalAmount = shopCartItemDiscount.getShopCartItems().stream().mapToDouble(ProductItemDto::getActualTotal).sum();
|
|
|
-// //TODO 计算真实总库存
|
|
|
-// shopCartItemDiscount.setTotalAmount(totalAmount);
|
|
|
-// }
|
|
|
-// // 如果是折扣特别小的情况下,导致实际金额为0是,改变最小支付金额为0.01元,并且优惠金额减去0.01。
|
|
|
-// if (shopCartOrderDto.getActualTotal() <= 0) {
|
|
|
-// shopCartOrderDto.setActualTotal(0.01);
|
|
|
-// shopCartOrderDto.setShopReduce(Arith.sub(shopCartOrderDto.getShopReduce(), 0.01));
|
|
|
-// List<ShopCartItemDto> sortItems = shopCartItemDiscounts.get(shopCartItemDiscounts.size() - 1).getShopCartItems();
|
|
|
-// ShopCartItemDto shopCartItemDto = sortItems.get(sortItems.size() - 1);
|
|
|
-// shopCartItemDto.setActualTotal(0.01);
|
|
|
-// shopCartItemDto.setShareReduce(Arith.sub(shopCartItemDto.getShareReduce(), 0.01));
|
|
|
-// }
|
|
|
-// shopCartItemDiscounts = shopCartItemDiscounts.stream().sorted(Comparator.comparing(ShopCartItemDiscountDto::getTotalAmount)).collect(Collectors.toList());
|
|
|
-// shopCartOrders.get(n).setShopCartItemDiscounts(shopCartItemDiscounts);
|
|
|
-// //TODO 计算真实总库存
|
|
|
-// actualTotal = Arith.add(actualTotal, shopCartOrderDto.getActualTotal());
|
|
|
-// }
|
|
|
+ //根据价格进行店铺、满减、商品项的价格升序操作
|
|
|
+ for (int n = 0; n < shopCartOrders.size(); n++) {
|
|
|
+ shopCartOrders = shopCartOrders.stream().sorted(Comparator.comparing(ShopCartOrderDto::getActualTotal)).collect(Collectors.toList());
|
|
|
+ ShopCartOrderDto shopCartOrderDto = shopCartOrders.get(n);
|
|
|
+
|
|
|
+ List<ShopCartItemDiscountDto> shopCartItemDiscounts = shopCartOrderDto.getShopCartItemDiscounts();
|
|
|
+ for (ShopCartItemDiscountDto shopCartItemDiscount : shopCartItemDiscounts) {
|
|
|
+ List<ShopCartItemDto> sortShopCartItems = shopCartItemDiscount.getShopCartItems();
|
|
|
+ sortShopCartItems = sortShopCartItems.stream().sorted(Comparator.comparing(ProductItemDto::getActualTotal)).collect(Collectors.toList());
|
|
|
+ shopCartItemDiscount.setShopCartItems(sortShopCartItems);
|
|
|
+ double totalAmount = shopCartItemDiscount.getShopCartItems().stream().mapToDouble(ProductItemDto::getActualTotal).sum();
|
|
|
+ //TODO 计算真实总库存
|
|
|
+ shopCartItemDiscount.setTotalAmount(totalAmount);
|
|
|
+ }
|
|
|
+ // 如果是折扣特别小的情况下,导致实际金额为0是,改变最小支付金额为0.01元,并且优惠金额减去0.01。
|
|
|
+ if (shopCartOrderDto.getActualTotal() <= 0) {
|
|
|
+ shopCartOrderDto.setActualTotal(0.01);
|
|
|
+ shopCartOrderDto.setShopReduce(Arith.sub(shopCartOrderDto.getShopReduce(), 0.01));
|
|
|
+ List<ShopCartItemDto> sortItems = shopCartItemDiscounts.get(shopCartItemDiscounts.size() - 1).getShopCartItems();
|
|
|
+ ShopCartItemDto shopCartItemDto = sortItems.get(sortItems.size() - 1);
|
|
|
+ shopCartItemDto.setActualTotal(0.01);
|
|
|
+ shopCartItemDto.setShareReduce(Arith.sub(shopCartItemDto.getShareReduce(), 0.01));
|
|
|
+ }
|
|
|
+ shopCartItemDiscounts = shopCartItemDiscounts.stream().sorted(Comparator.comparing(ShopCartItemDiscountDto::getTotalAmount)).collect(Collectors.toList());
|
|
|
+ shopCartOrders.get(n).setShopCartItemDiscounts(shopCartItemDiscounts);
|
|
|
+ //TODO 计算真实总库存
|
|
|
+ actualTotal = Arith.add(actualTotal, shopCartOrderDto.getActualTotal());
|
|
|
+ }
|
|
|
|
|
|
shopCartOrderMergerDto.setActualTotal(actualTotal);
|
|
|
shopCartOrderMergerDto.setTotal(total);
|
|
@@ -246,6 +246,7 @@ public class OrderController {
|
|
|
@PostMapping("/submit")
|
|
|
@ApiOperation(value = "提交订单,返回支付流水号", notes = "根据传入的参数判断是否为购物车提交订单,同时对购物车进行删除,用户开始进行支付")
|
|
|
public ResponseEntity<OrderNumbersDto> submitOrders(@Valid @RequestBody SubmitOrderParam submitOrderParam) {
|
|
|
+ //TODO wangjian 扣减积分
|
|
|
String userId = SecurityUtils.getUser().getUserId();
|
|
|
ShopCartOrderMergerDto mergerOrder = orderService.getConfirmOrderCache(userId + submitOrderParam.getUuid());
|
|
|
|