|
@@ -87,8 +87,10 @@ import static cn.newfeifan.mall.framework.common.exception.util.ServiceException
|
|
|
import static cn.newfeifan.mall.framework.common.util.collection.CollectionUtils.*;
|
|
|
import static cn.newfeifan.mall.framework.common.util.date.LocalDateTimeUtils.minusTime;
|
|
|
import static cn.newfeifan.mall.framework.common.util.servlet.ServletUtils.getClientIP;
|
|
|
+import static cn.newfeifan.mall.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
|
|
import static cn.newfeifan.mall.framework.web.core.util.WebFrameworkUtils.getTerminal;
|
|
|
import static cn.newfeifan.mall.module.trade.enums.ErrorCodeConstants.*;
|
|
|
+import static cn.newfeifan.mall.module.trade.enums.delivery.DeliveryTypeEnum.VIRTUAL_PRODUCT;
|
|
|
|
|
|
|
|
|
|
|
@@ -273,6 +275,11 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
|
|
shopNameMap.put(shopDO.getId(), shopDO.getName());
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ if(Objects.equals(settlementReqVO.getDeliveryType(), VIRTUAL_PRODUCT.getType())){
|
|
|
+ return getSettlement(settlementReqVO.getItems());
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
add by Ben 20240402
|
|
@@ -346,6 +353,95 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
|
|
return respVO;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 虚拟商品自走程序
|
|
|
+ * @param items 商品项数组
|
|
|
+ * @return AppTradeOrderSettlementRespVO
|
|
|
+ */
|
|
|
+ private AppTradeOrderSettlementRespVO getSettlement(List<AppTradeOrderSettlementReqVO.Item> items){
|
|
|
+
|
|
|
+
|
|
|
+ List<AppTradeOrderSettlementReqVO.Item> productSkuList = items;
|
|
|
+ List<Long> productSkuIdList = new ArrayList<>();
|
|
|
+ Map<Long, AppTradeOrderSettlementReqVO.Item> itemMap = new HashMap<>();
|
|
|
+ for (AppTradeOrderSettlementReqVO.Item skuItem : productSkuList) {
|
|
|
+ productSkuIdList.add(skuItem.getSkuId());
|
|
|
+ itemMap.put(skuItem.getSkuId(), skuItem);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ProductSkuDO> productSkuDOList = productSkuMapper.selectListBySKuId(productSkuIdList);
|
|
|
+
|
|
|
+
|
|
|
+ Map<Long, List<Long>> shopSkuIds = new HashMap<>();
|
|
|
+
|
|
|
+ Map<Long, List<AppTradeOrderSettlementReqVO.Item>> shopSkuItemMap = new HashMap<>();
|
|
|
+
|
|
|
+ for (ProductSkuDO sku : productSkuDOList) {
|
|
|
+ Long skuId = sku.getId();
|
|
|
+ Long shopId = sku.getShopId();
|
|
|
+
|
|
|
+ List<AppTradeOrderSettlementReqVO.Item> itemList = shopSkuItemMap.get(shopId);
|
|
|
+ if (itemList == null) {
|
|
|
+ itemList = new ArrayList<>();
|
|
|
+ shopSkuItemMap.put(shopId, itemList);
|
|
|
+ }
|
|
|
+
|
|
|
+ itemList.add(itemMap.get(skuId));
|
|
|
+
|
|
|
+ List<Long> shopSkuList = shopSkuIds.get(shopId);
|
|
|
+ if (shopSkuList == null) {
|
|
|
+ shopSkuList = new ArrayList<>();
|
|
|
+ shopSkuIds.put(shopId, shopSkuList);
|
|
|
+ }
|
|
|
+ shopSkuList.add(skuId);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ List<Long> shopIds = new ArrayList<>();
|
|
|
+ for (Long shopid : shopSkuIds.keySet()) {
|
|
|
+ shopIds.add(shopid);
|
|
|
+ }
|
|
|
+ List<ShopDO> shopDOList = shopMapper.selectListById(shopIds);
|
|
|
+ Map<Long, String> shopNameMap = new HashMap<>();
|
|
|
+ for (ShopDO shopDO : shopDOList) {
|
|
|
+ shopNameMap.put(shopDO.getId(), shopDO.getName());
|
|
|
+ }
|
|
|
+
|
|
|
+ AppTradeOrderSettlementRespVO respVO = new AppTradeOrderSettlementRespVO();
|
|
|
+ respVO.setShopNameMap(shopNameMap);
|
|
|
+ respVO.setShopSkuIds(shopSkuIds);
|
|
|
+ IntegralDO integralDO = integralMapper.selectOne("user_id", getLoginUserId());
|
|
|
+ Long currentQuota = integralDO.getCurrentQuota();
|
|
|
+ respVO.setCurrentQuota(currentQuota);
|
|
|
+
|
|
|
+
|
|
|
+ Map<Long, AppTradeOrderSettlementRespVO> shopRespVOMap = new HashMap<>();
|
|
|
+
|
|
|
+ AppTradeOrderSettlementRespVO.Price shopCalculateRespBO = new AppTradeOrderSettlementRespVO.Price();
|
|
|
+
|
|
|
+
|
|
|
+ for (Long shopId : shopSkuItemMap.keySet()) {
|
|
|
+ List<AppTradeOrderSettlementReqVO.Item> orderItems = shopSkuItemMap.get(shopId);
|
|
|
+
|
|
|
+
|
|
|
+ shopRespVOMap.put(shopId, respVO);
|
|
|
+ ProductSkuDO productSkuDO = productSkuMapper.selectById(orderItems.get(0).getSkuId());
|
|
|
+ shopCalculateRespBO.setVirtualPayPrice(productSkuDO.getHighPrecisionPrice().doubleValue() * orderItems.get(0).getCount());
|
|
|
+ shopCalculateRespBO.setVirtualTotalPrice(productSkuDO.getHighPrecisionPrice().doubleValue() * orderItems.get(0).getCount());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ for (Long shopId : shopRespVOMap.keySet()) {
|
|
|
+ AppTradeOrderSettlementRespVO a = shopRespVOMap.get(shopId);
|
|
|
+ a.setAddress(null);
|
|
|
+ }
|
|
|
+
|
|
|
+ respVO.setShopRespVOMap(shopRespVOMap);
|
|
|
+ respVO.setPrice(shopCalculateRespBO);
|
|
|
+ return respVO;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
* 获得用户地址
|
|
|
*
|
|
@@ -777,7 +873,7 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
|
|
} else if (Objects.equals(createReqVO.getDeliveryType(), DeliveryTypeEnum.PICK_UP.getType())) {
|
|
|
order.setReceiverName(createReqVO.getReceiverName()).setReceiverMobile(createReqVO.getReceiverMobile());
|
|
|
order.setPickUpVerifyCode(RandomUtil.randomNumbers(8));
|
|
|
- } else if(Objects.equals(createReqVO.getDeliveryType(), DeliveryTypeEnum.VIRTUAL_PRODUCT.getType())){
|
|
|
+ } else if(Objects.equals(createReqVO.getDeliveryType(), VIRTUAL_PRODUCT.getType())){
|
|
|
MemberAddressRespDTO address = addressApi.getAddress(createReqVO.getAddressId(), userId,2);
|
|
|
order.setReceiverName(address.getName()).setReceiverMobile(address.getMobile())
|
|
|
.setReceiverDetailAddress(address.getDetailAddress());
|