|
@@ -22,6 +22,7 @@ import com.kmall.admin.dao.vip.Mall2PointsRulesDao;
|
|
import com.kmall.admin.dto.*;
|
|
import com.kmall.admin.dto.*;
|
|
import com.kmall.admin.entity.*;
|
|
import com.kmall.admin.entity.*;
|
|
import com.kmall.admin.entity.kmall2eccs.KtoEccsEntity;
|
|
import com.kmall.admin.entity.kmall2eccs.KtoEccsEntity;
|
|
|
|
+import com.kmall.admin.entity.mk.MkActivitiesEntity;
|
|
import com.kmall.admin.entity.mk.store.MkStorePromOrderRealEntity;
|
|
import com.kmall.admin.entity.mk.store.MkStorePromOrderRealEntity;
|
|
import com.kmall.admin.entity.record.NewRetailOrderRestoreStockRecordEntity;
|
|
import com.kmall.admin.entity.record.NewRetailOrderRestoreStockRecordEntity;
|
|
import com.kmall.admin.entity.vip.Mall2MemberConsumptionRecordsEntity;
|
|
import com.kmall.admin.entity.vip.Mall2MemberConsumptionRecordsEntity;
|
|
@@ -29,6 +30,8 @@ import com.kmall.admin.entity.vip.Mall2MemberPointsEntity;
|
|
import com.kmall.admin.entity.vip.Mall2PointsRulesEntity;
|
|
import com.kmall.admin.entity.vip.Mall2PointsRulesEntity;
|
|
import com.kmall.admin.fromcomm.dao.SysConfigDao;
|
|
import com.kmall.admin.fromcomm.dao.SysConfigDao;
|
|
import com.kmall.admin.fromcomm.entity.SysUserEntity;
|
|
import com.kmall.admin.fromcomm.entity.SysUserEntity;
|
|
|
|
+import com.kmall.admin.haikong.constant.Constants;
|
|
|
|
+import com.kmall.admin.haikong.dto.WareQueryStockResponseDTO;
|
|
import com.kmall.admin.haikong.utils.ListUtils;
|
|
import com.kmall.admin.haikong.utils.ListUtils;
|
|
import com.kmall.admin.haikong.vo.QueryGoodsVo;
|
|
import com.kmall.admin.haikong.vo.QueryGoodsVo;
|
|
import com.kmall.admin.haikong.client.HaiKongMemberTemplate;
|
|
import com.kmall.admin.haikong.client.HaiKongMemberTemplate;
|
|
@@ -38,6 +41,7 @@ import com.kmall.admin.haikong.dto.MemberInfoDTO;
|
|
import com.kmall.admin.haikong.utils.Response;
|
|
import com.kmall.admin.haikong.utils.Response;
|
|
import com.kmall.admin.service.*;
|
|
import com.kmall.admin.service.*;
|
|
import com.kmall.admin.service.kmall2eccs.KtoEccsService;
|
|
import com.kmall.admin.service.kmall2eccs.KtoEccsService;
|
|
|
|
+import com.kmall.admin.service.mk.MkActivitiesService;
|
|
import com.kmall.admin.service.mk.store.MkStoreCampMinusService;
|
|
import com.kmall.admin.service.mk.store.MkStoreCampMinusService;
|
|
import com.kmall.admin.service.mk.store.MkStoreTicketDiscountService;
|
|
import com.kmall.admin.service.mk.store.MkStoreTicketDiscountService;
|
|
import com.kmall.admin.service.record.NewRetailOrderRestoreStockRecordService;
|
|
import com.kmall.admin.service.record.NewRetailOrderRestoreStockRecordService;
|
|
@@ -48,6 +52,7 @@ import com.kmall.admin.utils.data.response.ResponseMessageData;
|
|
import com.kmall.admin.utils.jackson.JacksonUtil;
|
|
import com.kmall.admin.utils.jackson.JacksonUtil;
|
|
import com.kmall.admin.utils.oms.OmsSign;
|
|
import com.kmall.admin.utils.oms.OmsSign;
|
|
import com.kmall.admin.utils.pdf.BarcodeUtil;
|
|
import com.kmall.admin.utils.pdf.BarcodeUtil;
|
|
|
|
+import com.kmall.admin.vo.CalculateOrderDiscountPriceVo;
|
|
import com.kmall.admin.websocket.WebSocketServer;
|
|
import com.kmall.admin.websocket.WebSocketServer;
|
|
import com.kmall.api.entity.OrderGoodsRestoreVo;
|
|
import com.kmall.api.entity.OrderGoodsRestoreVo;
|
|
import com.kmall.api.entity.OrderGoodsVo;
|
|
import com.kmall.api.entity.OrderGoodsVo;
|
|
@@ -77,6 +82,7 @@ import com.kmall.manager.manager.redis.JedisUtil;
|
|
import com.kmall.manager.manager.wechat.WechatUtil;
|
|
import com.kmall.manager.manager.wechat.WechatUtil;
|
|
import com.kmall.manager.manager.wechat.wxglobal.dto.WechatGlobalRefundApiResult;
|
|
import com.kmall.manager.manager.wechat.wxglobal.dto.WechatGlobalRefundApiResult;
|
|
import okhttp3.Request;
|
|
import okhttp3.Request;
|
|
|
|
+import org.apache.shiro.crypto.hash.Hash;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
@@ -95,6 +101,7 @@ import java.text.SimpleDateFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.concurrent.*;
|
|
import java.util.concurrent.*;
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
|
+import java.util.concurrent.atomic.AtomicReference;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@@ -194,9 +201,6 @@ public class OrderServiceImpl implements OrderService {
|
|
private Mall2LowPriceWarningDao lowPriceWarningDao;
|
|
private Mall2LowPriceWarningDao lowPriceWarningDao;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
- private MkActivitiesCouponService mkActivitiesCouponService;
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
private OrderRefundService orderRefundService;
|
|
private OrderRefundService orderRefundService;
|
|
@Autowired
|
|
@Autowired
|
|
private OrderExceptionRecordService orderExceptionRecordService;
|
|
private OrderExceptionRecordService orderExceptionRecordService;
|
|
@@ -220,6 +224,26 @@ public class OrderServiceImpl implements OrderService {
|
|
@Autowired
|
|
@Autowired
|
|
private HaiKongProperties haiKongProperties;
|
|
private HaiKongProperties haiKongProperties;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private MkActivitiesService mkActivitiesService;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 满赠
|
|
|
|
+ */
|
|
|
|
+ @Autowired
|
|
|
|
+ private MkActivitiesFullGiftService mkActivitiesFullGiftService;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 优惠券
|
|
|
|
+ */
|
|
|
|
+ @Autowired
|
|
|
|
+ private MkActivitiesCouponService mkActivitiesCouponService;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 限时特价
|
|
|
|
+ */
|
|
|
|
+ @Autowired
|
|
|
|
+ private MkActivitiesPromotionService mkActivitiesPromotionService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public OrderEntity queryObject(Long id) {
|
|
public OrderEntity queryObject(Long id) {
|
|
@@ -2036,9 +2060,23 @@ public class OrderServiceImpl implements OrderService {
|
|
LOGGER.error("调用库存系统接口出现错误!返回结果为空!");
|
|
LOGGER.error("调用库存系统接口出现错误!返回结果为空!");
|
|
throw new ServiceException("调用库存系统接口出现错误!");
|
|
throw new ServiceException("调用库存系统接口出现错误!");
|
|
}
|
|
}
|
|
- // TODO 解析xml,组装成map key=>sku value=>库存
|
|
|
|
|
|
+ WareQueryStockResponseDTO wareQueryStockResponseDTO = JacksonUtil.fromStringJson(queryWarehouseStockResponse, WareQueryStockResponseDTO.class);
|
|
|
|
+ if (Objects.isNull(wareQueryStockResponseDTO)) {
|
|
|
|
+ throw new ServiceException("解析一步达库存系统响应数据出现错误!");
|
|
|
|
+ }
|
|
|
|
+ List<WareQueryStockResponseDTO.WareQueryStockResponseItemDTO> items = wareQueryStockResponseDTO.getItems();
|
|
|
|
+ // 解析xml,组装成map key=>sku value=>库存
|
|
Map<String, Integer> stockMap = new HashMap<>(16);
|
|
Map<String, Integer> stockMap = new HashMap<>(16);
|
|
-
|
|
|
|
|
|
+ items.forEach(item -> {
|
|
|
|
+ String itemCode = item.getItemCode();
|
|
|
|
+ Integer quantity = item.getQuantity();
|
|
|
|
+ if (stockMap.containsKey(itemCode)) {
|
|
|
|
+ // 避免出现sku相同情况
|
|
|
|
+ stockMap.put(itemCode, stockMap.get(itemCode) + quantity);
|
|
|
|
+ } else {
|
|
|
|
+ stockMap.put(itemCode, quantity);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
// 订单总价格(含税价)
|
|
// 订单总价格(含税价)
|
|
BigDecimal orderPrice = BigDecimal.ZERO;
|
|
BigDecimal orderPrice = BigDecimal.ZERO;
|
|
// 商品总价格(不含税)
|
|
// 商品总价格(不含税)
|
|
@@ -2047,6 +2085,7 @@ public class OrderServiceImpl implements OrderService {
|
|
BigDecimal totalTax = BigDecimal.ZERO;
|
|
BigDecimal totalTax = BigDecimal.ZERO;
|
|
|
|
|
|
List<OrderGoodsEntity> orderGoodsEntities = new ArrayList<>();
|
|
List<OrderGoodsEntity> orderGoodsEntities = new ArrayList<>();
|
|
|
|
+ List<GoodsEntity> goodsEntities = new ArrayList<>();
|
|
|
|
|
|
// TODO 根据商品条码、sku、门店id查询相对应的商品信息,并组装成对象
|
|
// TODO 根据商品条码、sku、门店id查询相对应的商品信息,并组装成对象
|
|
List<QueryGoodsVo> queryGoodsVoList = new ArrayList<>();
|
|
List<QueryGoodsVo> queryGoodsVoList = new ArrayList<>();
|
|
@@ -2057,7 +2096,7 @@ public class OrderServiceImpl implements OrderService {
|
|
queryGoodsVo.setStoreId(storeId);
|
|
queryGoodsVo.setStoreId(storeId);
|
|
queryGoodsVo.setSellVolume((Integer) map.get("sellVolume"));
|
|
queryGoodsVo.setSellVolume((Integer) map.get("sellVolume"));
|
|
queryGoodsVo.setRetailPrice(new BigDecimal(String.valueOf(map.get("retailPrice"))));
|
|
queryGoodsVo.setRetailPrice(new BigDecimal(String.valueOf(map.get("retailPrice"))));
|
|
- queryGoodsVo.setGoodstaxes(new BigDecimal(String.valueOf(map.get("goodstaxes"))));
|
|
|
|
|
|
+ queryGoodsVo.setGoodsTaxes(new BigDecimal(String.valueOf(map.get("goodstaxes"))));
|
|
queryGoodsVo.setDisCountedPrice(new BigDecimal(String.valueOf(map.get("disCountedPrice"))));
|
|
queryGoodsVo.setDisCountedPrice(new BigDecimal(String.valueOf(map.get("disCountedPrice"))));
|
|
queryGoodsVoList.add(queryGoodsVo);
|
|
queryGoodsVoList.add(queryGoodsVo);
|
|
});
|
|
});
|
|
@@ -2066,6 +2105,9 @@ public class OrderServiceImpl implements OrderService {
|
|
// 复制集合数据
|
|
// 复制集合数据
|
|
ListUtils listUtils = BeanUtils.instantiate(ListUtils.class);
|
|
ListUtils listUtils = BeanUtils.instantiate(ListUtils.class);
|
|
listUtils.copyList(goodsEntityList, queryGoodsVoList);
|
|
listUtils.copyList(goodsEntityList, queryGoodsVoList);
|
|
|
|
+ // 用来存储是否达到满赠条件的map
|
|
|
|
+ Map<String, BigDecimal> categoryConditionMap = new HashMap<>();
|
|
|
|
+ Map<String, BigDecimal> brandConditionMap = new HashMap<>();
|
|
|
|
|
|
for (QueryGoodsVo goodsEntity : queryGoodsVoList) {
|
|
for (QueryGoodsVo goodsEntity : queryGoodsVoList) {
|
|
OrderGoodsEntity orderGoodsEntity = new OrderGoodsEntity();
|
|
OrderGoodsEntity orderGoodsEntity = new OrderGoodsEntity();
|
|
@@ -2078,7 +2120,7 @@ public class OrderServiceImpl implements OrderService {
|
|
// 订单金额(含税价),订单总金额,用户支付的金额
|
|
// 订单金额(含税价),订单总金额,用户支付的金额
|
|
BigDecimal retailPrice = goodsEntity.getRetailPrice();
|
|
BigDecimal retailPrice = goodsEntity.getRetailPrice();
|
|
// 商品预估税率
|
|
// 商品预估税率
|
|
- BigDecimal goodsTaxes = goodsEntity.getGoodstaxes();
|
|
|
|
|
|
+ BigDecimal goodsTaxes = goodsEntity.getGoodsTaxes();
|
|
// 商品优惠金额
|
|
// 商品优惠金额
|
|
BigDecimal disCountedPrice = goodsEntity.getDisCountedPrice();
|
|
BigDecimal disCountedPrice = goodsEntity.getDisCountedPrice();
|
|
// 商品金额(不包含税的价格),推送海关电子订单需要
|
|
// 商品金额(不包含税的价格),推送海关电子订单需要
|
|
@@ -2089,29 +2131,91 @@ public class OrderServiceImpl implements OrderService {
|
|
totalTax = totalTax.add(goodsTaxes);
|
|
totalTax = totalTax.add(goodsTaxes);
|
|
// 当前sku
|
|
// 当前sku
|
|
String currentSku = goodsEntity.getSku();
|
|
String currentSku = goodsEntity.getSku();
|
|
- // TODO 判断库存。。
|
|
|
|
- if (!stockMap.containsKey(currentSku)) {
|
|
|
|
- LOGGER.error("库存系统中不包含此sku:【{}】,校验库存出错!下单失败!", currentSku);
|
|
|
|
- throw new ServiceException(String.format("不包含此sku:【%s】", currentSku));
|
|
|
|
- }
|
|
|
|
// 仓库库存
|
|
// 仓库库存
|
|
Integer warehouseStock = stockMap.get(currentSku);
|
|
Integer warehouseStock = stockMap.get(currentSku);
|
|
- // 当前出区数
|
|
|
|
- Integer exitRegionNumber = goodsEntity.getExitRegionNumber();
|
|
|
|
// 门店库存
|
|
// 门店库存
|
|
Integer stockNum = goodsEntity.getStockNum();
|
|
Integer stockNum = goodsEntity.getStockNum();
|
|
- // 保税仓库存 + 门店库存 - 出区数 >= 购买数
|
|
|
|
- if (!((warehouseStock + stockNum) - exitRegionNumber >= sellVolume)) {
|
|
|
|
- // 库存不足
|
|
|
|
- LOGGER.error("sku【{}】库存不足!商品条码:【{}】,门店库存:【{}】,保税仓库存:【{}】,当前出区数:【{}】", currentSku, prodBarcode, stockNum, warehouseStock, exitRegionNumber);
|
|
|
|
- throw new ServiceException(String.format("sku【%s】库存不足!商品条码:【%s】,门店库存:【%s】,保税仓库存:【%s】,当前出区数:【%s】", currentSku, prodBarcode, stockNum, warehouseStock, exitRegionNumber));
|
|
|
|
|
|
+ // 判断库存。。
|
|
|
|
+ if (!stockMap.containsKey(currentSku)) {
|
|
|
|
+ LOGGER.error("库存系统中不包含此sku:【{}】,校验库存出错!下单失败!", currentSku);
|
|
|
|
+ throw new ServiceException(String.format("不包含此sku:【%s】", currentSku));
|
|
|
|
+ } else {
|
|
|
|
+ // 保税仓库存 + 展销店库存 - 出区数 >= 购买数
|
|
|
|
+ // 当前出区数
|
|
|
|
+ Integer exitRegionNumber = goodsEntity.getExitRegionNumber();
|
|
|
|
+ // 保税仓库存 + 门店库存 - 出区数 >= 购买数
|
|
|
|
+ if (!((warehouseStock + stockNum) - exitRegionNumber >= sellVolume)) {
|
|
|
|
+ // 库存不足
|
|
|
|
+ LOGGER.error("sku【{}】库存不足!商品条码:【{}】,门店库存:【{}】,保税仓库存:【{}】,当前出区数:【{}】", currentSku, prodBarcode, stockNum, warehouseStock, exitRegionNumber);
|
|
|
|
+ throw new ServiceException(String.format("sku【%s】库存不足!商品条码:【%s】,门店库存:【%s】,保税仓库存:【%s】,当前出区数:【%s】", currentSku, prodBarcode, stockNum, warehouseStock, exitRegionNumber));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
// 设置订单详情信息
|
|
// 设置订单详情信息
|
|
GoodsEntity entity = new GoodsEntity(goodsEntity);
|
|
GoodsEntity entity = new GoodsEntity(goodsEntity);
|
|
- orderGoodsEntity = wrapOrderGoods(orderGoodsEntity, entity);
|
|
|
|
|
|
+ wrapOrderGoods(orderGoodsEntity, entity);
|
|
orderGoodsEntities.add(orderGoodsEntity);
|
|
orderGoodsEntities.add(orderGoodsEntity);
|
|
|
|
+
|
|
|
|
+ // 设置条件信息,暂不支持门店满赠活动
|
|
|
|
+ String categoryId = String.valueOf(entity.getCategoryId());
|
|
|
|
+ String brandId = String.valueOf(entity.getBrandId());
|
|
|
|
+ if (!categoryConditionMap.containsKey(categoryId)) {
|
|
|
|
+ categoryConditionMap.put(categoryId, retailPrice);
|
|
|
|
+ } else {
|
|
|
|
+ categoryConditionMap.put(categoryId, categoryConditionMap.get(categoryId).add(retailPrice));
|
|
|
|
+ }
|
|
|
|
+// if (!brandConditionMap.containsKey(brandId)) {
|
|
|
|
+// brandConditionMap.put(brandId, retailPrice);
|
|
|
|
+// } else {
|
|
|
|
+// brandConditionMap.put(brandId, brandConditionMap.get(brandId).add(retailPrice));
|
|
|
|
+// }
|
|
}
|
|
}
|
|
- // 2. 校验是否是会员,调用会员系统查询会员信息,查询接口:
|
|
|
|
|
|
+ // 2. 判断购买的商品是否能参与满减活动
|
|
|
|
+ // 2.1 查询当前门店是否有满赠的活动
|
|
|
|
+ List<MkActivitiesEntity> activitiesEntities = mkActivitiesService.queryByNowByMz(String.valueOf(storeId), DateUtils.format(new Date(), "yyyy-MM-dd"));
|
|
|
|
+ if (CollectionUtils.isEmpty(activitiesEntities)) {
|
|
|
|
+ LOGGER.error("----- 该门店【{}】暂无满赠活动! -----", storeId);
|
|
|
|
+ } else {
|
|
|
|
+ // 当前门店的活动编号
|
|
|
|
+ List<Long> activitiesSnList = activitiesEntities.stream().map(MkActivitiesEntity::getMkaId).collect(Collectors.toList());
|
|
|
|
+ // 活动
|
|
|
|
+ List<MkActivitiesFullGiftEntity> mkActivitiesFullGiftEntities = mkActivitiesFullGiftService.queryByMkaIdList(activitiesSnList);
|
|
|
|
+ if (CollectionUtils.isEmpty(mkActivitiesFullGiftEntities)) {
|
|
|
|
+ LOGGER.error("----- 该门店【{}】暂无满赠活动! -----", storeId);
|
|
|
|
+ } else {
|
|
|
|
+ mkActivitiesFullGiftEntities.forEach(mkActivitiesFullGiftEntity -> {
|
|
|
|
+ // 存在品牌满赠活动,暂不支持品牌满赠活动
|
|
|
|
+// String brandId = String.valueOf(mkActivitiesFullGiftEntity.getBrandId());
|
|
|
|
+// if (brandConditionMap.containsKey(brandId)) {
|
|
|
|
+// if (brandConditionMap.get(brandId).compareTo(mkActivitiesFullGiftEntity.getQualifiedAmount()) > 0) {
|
|
|
|
+// // 该品牌满足满赠条件
|
|
|
|
+//
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+ // 存在分类满赠活动
|
|
|
|
+ String categoryId = String.valueOf(mkActivitiesFullGiftEntity.getCategoryId());
|
|
|
|
+ if (!CollectionUtils.isEmpty(categoryConditionMap) && categoryConditionMap.containsKey(categoryId)) {
|
|
|
|
+ if (categoryConditionMap.get(categoryId).compareTo(mkActivitiesFullGiftEntity.getQualifiedAmount()) > 0) {
|
|
|
|
+ // 该分类满足满赠条件
|
|
|
|
+ String giftBarcode = mkActivitiesFullGiftEntity.getGiftBarcode();
|
|
|
|
+ String giftGoodsSn = mkActivitiesFullGiftEntity.getGiftGoodsSn();
|
|
|
|
+ String shopSn = mkActivitiesFullGiftEntity.getShopSn();
|
|
|
|
+ GoodsEntity goodsEntity = goodsService.queryGoodsStockByBarcodeAndStoreIdAndSku(giftBarcode, Integer.parseInt(shopSn), giftGoodsSn);
|
|
|
|
+ // 存储赠送数
|
|
|
|
+ goodsEntity.setGoodsNumber(mkActivitiesFullGiftEntity.getGiftNumber());
|
|
|
|
+ OrderGoodsEntity orderGoodsEntity = new OrderGoodsEntity();
|
|
|
|
+ wrapOrderGoods(orderGoodsEntity, goodsEntity);
|
|
|
|
+ orderGoodsEntity.setRetailPrice(BigDecimal.ZERO);
|
|
|
|
+ orderGoodsEntity.setDiscountedPrice(BigDecimal.ZERO);
|
|
|
|
+ orderGoodsEntity.setActualPaymentAmount(BigDecimal.ZERO);
|
|
|
|
+ orderGoodsEntities.add(orderGoodsEntity);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // 3. 校验是否是会员,调用会员系统查询会员信息,查询接口:
|
|
// 优惠后价格
|
|
// 优惠后价格
|
|
BigDecimal afterDiscountPrice;
|
|
BigDecimal afterDiscountPrice;
|
|
if (org.springframework.util.StringUtils.isEmpty(couponBarCode)) {
|
|
if (org.springframework.util.StringUtils.isEmpty(couponBarCode)) {
|
|
@@ -2136,6 +2240,7 @@ public class OrderServiceImpl implements OrderService {
|
|
afterDiscountPrice = calculatePreferentialPrice(orderPrice, 0, goodsList, storeId, userInfo);
|
|
afterDiscountPrice = calculatePreferentialPrice(orderPrice, 0, goodsList, storeId, userInfo);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
|
|
+ LOGGER.error("查询会员信息失败!响应结果:{}", queryMemberInfoResponse);
|
|
throw new ServiceException("查询会员信息失败!请重新下单!");
|
|
throw new ServiceException("查询会员信息失败!请重新下单!");
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -2143,7 +2248,7 @@ public class OrderServiceImpl implements OrderService {
|
|
throw new ServiceException("查询会员信息失败!请重新下单!");
|
|
throw new ServiceException("查询会员信息失败!请重新下单!");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- // 3. 调用付款接口
|
|
|
|
|
|
+ // 4. 调用付款接口
|
|
// 判断是微信的支付码还是支付宝的支付码
|
|
// 判断是微信的支付码还是支付宝的支付码
|
|
if (parCode.startsWith("28")) {
|
|
if (parCode.startsWith("28")) {
|
|
// 支付宝支付
|
|
// 支付宝支付
|
|
@@ -2163,9 +2268,9 @@ public class OrderServiceImpl implements OrderService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- // 4. 扣减库存
|
|
|
|
|
|
+ // 5. 扣减库存
|
|
|
|
|
|
- // 5. 推送订单到免税mall
|
|
|
|
|
|
+ // 6. 订单入库
|
|
|
|
|
|
|
|
|
|
return resultObj;
|
|
return resultObj;
|
|
@@ -2181,7 +2286,9 @@ public class OrderServiceImpl implements OrderService {
|
|
// 设置商品信息
|
|
// 设置商品信息
|
|
BeanUtils.copyProperties(goodsEntity, orderGoodsEntity);
|
|
BeanUtils.copyProperties(goodsEntity, orderGoodsEntity);
|
|
// 设置订单信息
|
|
// 设置订单信息
|
|
-
|
|
|
|
|
|
+ // 销售数
|
|
|
|
+ orderGoodsEntity.setNumber(goodsEntity.getGoodsNumber());
|
|
|
|
+ // TODO other...
|
|
return orderGoodsEntity;
|
|
return orderGoodsEntity;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -3873,6 +3980,278 @@ public class OrderServiceImpl implements OrderService {
|
|
return TicketPrintUtil.print(head, goodsList, cashInfo, cusListing, mailInfo);
|
|
return TicketPrintUtil.print(head, goodsList, cashInfo, cusListing, mailInfo);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 计算优惠价格,活动价格
|
|
|
|
+ *
|
|
|
|
+ * @param calculateOrderDiscountPriceVo 请求参数
|
|
|
|
+ * @return 商品集合
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public List<GoodsDetailsDto> calculateOrderDiscountPrice(CalculateOrderDiscountPriceVo calculateOrderDiscountPriceVo) {
|
|
|
|
+ if (Objects.isNull(calculateOrderDiscountPriceVo)) {
|
|
|
|
+ LOGGER.error("计算活动优惠价格,请求参数为null!");
|
|
|
|
+ throw new ServiceException("计算活动优惠价格,请求参数为null!");
|
|
|
|
+ }
|
|
|
|
+ String storeId = calculateOrderDiscountPriceVo.getStoreId();
|
|
|
|
+ List<GoodsDetailsDto> goodsDetailsDtos = calculateOrderDiscountPriceVo.getGoodsList();
|
|
|
|
+ List<QueryGoodsVo> goodsVos = goodsDetailsDtos.stream().map(good -> {
|
|
|
|
+ QueryGoodsVo queryGoodsVo = new QueryGoodsVo();
|
|
|
|
+ BeanUtils.copyProperties(good, queryGoodsVo);
|
|
|
|
+ queryGoodsVo.setSku(good.getGoodsSn());
|
|
|
|
+ queryGoodsVo.setStoreId(Integer.parseInt(storeId));
|
|
|
|
+ return queryGoodsVo;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ // 查询商品表
|
|
|
|
+ List<GoodsEntity> goodsEntities = goodsService.queryGoodsStockByQueryGoodsVoList(goodsVos);
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ * 2.查询当前时间,该门店是否有活动,如果有活动,查询开启了哪些营销方式
|
|
|
|
+ * 参数: 当前时间 门店id
|
|
|
|
+ */
|
|
|
|
+ List<MkActivitiesEntity> mkActivitiesEntityList = mkActivitiesService.queryByNow(storeId, DateUtils.format(new Date(), "yyyy-MM-dd"));
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ * 活动相关规则:
|
|
|
|
+ * 1. 优先优惠券再去计算积分
|
|
|
|
+ * 2. 满赠的赠品商品在推送定时时零售价为0
|
|
|
|
+ * 3. 任何活动都优先于积分计算
|
|
|
|
+ * 4. 活动之间具有互斥性
|
|
|
|
+ */
|
|
|
|
+ if (CollectionUtils.isEmpty(mkActivitiesEntityList)) {
|
|
|
|
+ LOGGER.info("当前时间门店【{}】,无相关活动信息!", storeId);
|
|
|
|
+ for (GoodsDetailsDto goodsDetailsDto : goodsDetailsDtos) {
|
|
|
|
+ GoodsEntity goodsEntity = new GoodsEntity();
|
|
|
|
+ BeanUtils.copyProperties(goodsDetailsDto, goodsEntity);
|
|
|
|
+ goodsEntity.setGoodsRate(new BigDecimal(goodsDetailsDto.getGoodsRate()));
|
|
|
|
+ // 无活动情况,实际支付价 = 零售价
|
|
|
|
+ BigDecimal tax = CalculateTax.calculateFinalTax(goodsEntity , goodsEntity.getRetailPrice(), goodsService).setScale(3,RoundingMode.HALF_UP);
|
|
|
|
+ // 预估税
|
|
|
|
+ goodsDetailsDto.setGoodstaxes(String.valueOf(tax));
|
|
|
|
+ // TODO 测试用
|
|
|
|
+ goodsDetailsDto.setActualPaymentAmount(BigDecimal.ZERO);
|
|
|
|
+ }
|
|
|
|
+ return goodsDetailsDtos;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<Integer> brandIdList = goodsEntities.stream().map(GoodsEntity::getBrandId).collect(Collectors.toList());
|
|
|
|
+ List<Integer> categoryIdList = goodsEntities.stream().map(GoodsEntity::getCategoryId).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ AtomicBoolean activityFlag = new AtomicBoolean(false);
|
|
|
|
+ // 判断活动类型,并确定购物栏中商品是否满足活动条件
|
|
|
|
+ mkActivitiesEntityList.forEach(mkActivitiesEntity -> {
|
|
|
|
+ String mkaStoreId = mkActivitiesEntity.getMkaStoreId();
|
|
|
|
+ Long mkaId = mkActivitiesEntity.getMkaId();
|
|
|
|
+ String mkaTopic = mkActivitiesEntity.getMkaTopic();
|
|
|
|
+ Constants.ActivityTopicEnum activityTopicEnum = Constants.ActivityTopicEnum.valueOf(mkaTopic);
|
|
|
|
+ switch (activityTopicEnum) {
|
|
|
|
+ case MZ:
|
|
|
|
+ // 判断商品是否符合满赠活动要求
|
|
|
|
+ MkActivitiesFullGiftEntity mkActivitiesFullGiftEntity = mkActivitiesFullGiftService.queryObjectByMkaIdAndStoreId(mkaId.intValue(), storeId);
|
|
|
|
+ if (Objects.isNull(mkActivitiesFullGiftEntity)) {
|
|
|
|
+ LOGGER.error("查询满赠活动信息结果为空!mka_id:{}, store_id:{}", mkaId, storeId);
|
|
|
|
+ throw new ServiceException(String.format("查询满赠活动信息结果为空!mka_id:%s, store_id:%s", mkaId, storeId));
|
|
|
|
+ }
|
|
|
|
+ Long brandId = mkActivitiesFullGiftEntity.getBrandId();
|
|
|
|
+ Long categoryId = mkActivitiesFullGiftEntity.getCategoryId();
|
|
|
|
+ Constants.ActivityType fullGiftActivityType = Constants.ActivityType.valueOf(mkActivitiesFullGiftEntity.getFullGiftType());
|
|
|
|
+ switch (fullGiftActivityType) {
|
|
|
|
+ case BRAND:
|
|
|
|
+ if (brandIdList.contains(brandId.intValue())) {
|
|
|
|
+ // 活动包含该商品品牌,此次订单该品牌商品
|
|
|
|
+ List<GoodsEntity> goodsEntityList = goodsEntities.stream().filter(goodsEntity -> brandId.intValue() == goodsEntity.getBrandId()).collect(Collectors.toList());
|
|
|
|
+ AtomicReference<BigDecimal> brandTotalPrice = new AtomicReference<>(BigDecimal.ZERO);
|
|
|
|
+ goodsEntityList.forEach(goodsEntity -> {
|
|
|
|
+ brandTotalPrice.set(brandTotalPrice.get().add(goodsEntity.getRetailPrice()));
|
|
|
|
+ });
|
|
|
|
+ if (brandTotalPrice.get().compareTo(mkActivitiesFullGiftEntity.getQualifiedAmount()) >= 0) {
|
|
|
|
+ // 满足满赠条件
|
|
|
|
+ String giftGoodsSn = mkActivitiesFullGiftEntity.getGiftGoodsSn();
|
|
|
|
+ String giftBarcode = mkActivitiesFullGiftEntity.getGiftBarcode();
|
|
|
|
+ GoodsEntity goodsEntity = goodsService.queryGoodsStockByBarcodeAndStoreIdAndSku(giftBarcode, Integer.parseInt(mkaStoreId), giftGoodsSn);
|
|
|
|
+ GoodsDetailsDto goodsDetailsDto = new GoodsDetailsDto();
|
|
|
|
+ BeanUtils.copyProperties(goodsEntity, goodsDetailsDto);
|
|
|
|
+ // 除了限时促销(需要向海关备案),其它活动都拿海关备案价来算税款
|
|
|
|
+ BigDecimal tax = CalculateTax.calculateFinalTax(goodsEntity, goodsEntity.getRetailPrice(), goodsService).setScale(3, RoundingMode.HALF_UP);
|
|
|
|
+ goodsDetailsDto.setGoodstaxes(String.valueOf(tax));
|
|
|
|
+ goodsDetailsDto.setActualPaymentAmount(BigDecimal.ZERO);
|
|
|
|
+ goodsDetailsDto.setActivity("满赠商品");
|
|
|
|
+ goodsDetailsDto.setGiftNumber(mkActivitiesFullGiftEntity.getGiftNumber());
|
|
|
|
+ goodsDetailsDto.setDiscountedPrice(goodsEntity.getRetailPrice());
|
|
|
|
+ // 添加进商品详情列表
|
|
|
|
+ goodsDetailsDtos.add(goodsDetailsDto);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case CATEGORY:
|
|
|
|
+ if (categoryIdList.contains(categoryId.intValue())) {
|
|
|
|
+ // 活动包含该商品分类
|
|
|
|
+ List<GoodsEntity> goodsEntityList = goodsEntities.stream().filter(goodsEntity -> brandId.equals(mkActivitiesFullGiftEntity.getCategoryId())).collect(Collectors.toList());
|
|
|
|
+ AtomicReference<BigDecimal> categoryTotalPrice = new AtomicReference<>(BigDecimal.ZERO);
|
|
|
|
+ goodsEntityList.forEach(goodsEntity -> {
|
|
|
|
+ categoryTotalPrice.set(categoryTotalPrice.get().add(goodsEntity.getRetailPrice()));
|
|
|
|
+ });
|
|
|
|
+ if (categoryTotalPrice.get().compareTo(mkActivitiesFullGiftEntity.getQualifiedAmount()) >= 0) {
|
|
|
|
+ // 满足满赠条件
|
|
|
|
+ String giftGoodsSn = mkActivitiesFullGiftEntity.getGiftGoodsSn();
|
|
|
|
+ String giftBarcode = mkActivitiesFullGiftEntity.getGiftBarcode();
|
|
|
|
+ GoodsEntity goodsEntity = goodsService.queryGoodsStockByBarcodeAndStoreIdAndSku(giftBarcode, Integer.parseInt(mkaStoreId), giftGoodsSn);
|
|
|
|
+ GoodsDetailsDto goodsDetailsDto = new GoodsDetailsDto();
|
|
|
|
+ BeanUtils.copyProperties(goodsEntity, goodsDetailsDto);
|
|
|
|
+ // 除了限时促销(需要向海关备案),其它活动都拿海关备案价来算税款
|
|
|
|
+ BigDecimal tax = CalculateTax.calculateFinalTax(goodsEntity, goodsEntity.getRetailPrice(), goodsService).setScale(3, RoundingMode.HALF_UP);
|
|
|
|
+ goodsDetailsDto.setGoodstaxes(String.valueOf(tax));
|
|
|
|
+ goodsDetailsDto.setActualPaymentAmount(BigDecimal.ZERO);
|
|
|
|
+ goodsDetailsDto.setActivity("满赠商品");
|
|
|
|
+ goodsDetailsDto.setGiftNumber(mkActivitiesFullGiftEntity.getGiftNumber());
|
|
|
|
+ goodsDetailsDto.setDiscountedPrice(goodsEntity.getRetailPrice());
|
|
|
|
+ // 添加进商品详情列表
|
|
|
|
+ goodsDetailsDtos.add(goodsDetailsDto);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ LOGGER.error("未知满赠类型【{},{}】!请联系管理员!", fullGiftActivityType.getActivityType(), fullGiftActivityType.getActivityTypeCode());
|
|
|
|
+ throw new ServiceException(String.format("未知满赠类型【%s,%s】!请联系管理员!", fullGiftActivityType.getActivityType(), fullGiftActivityType.getActivityTypeCode()));
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case YHJ:
|
|
|
|
+ // 判断商品是否符合优惠券活动要求
|
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
|
+ params.put("shop_sn", storeId);
|
|
|
|
+ params.put("mka_id", mkaId);
|
|
|
|
+ List<MkActivitiesCouponEntity> mkActivitiesCouponEntities = mkActivitiesCouponService.queryList(params);
|
|
|
|
+ if (CollectionUtils.isEmpty(mkActivitiesCouponEntities)) {
|
|
|
|
+ LOGGER.error("查询优惠券活动信息结果为空!mka_id:{}, store_id:{}", mkaId, storeId);
|
|
|
|
+ throw new ServiceException(String.format("查询优惠券活动信息结果为空!mka_id:%s, store_id:%s", mkaId, storeId));
|
|
|
|
+ }
|
|
|
|
+ MkActivitiesCouponEntity mkActivitiesCouponEntity = mkActivitiesCouponEntities.get(0);
|
|
|
|
+ Integer couponEntityBrandId = mkActivitiesCouponEntity.getBrandId();
|
|
|
|
+ Integer couponEntityCategoryId = mkActivitiesCouponEntity.getCategoryId();
|
|
|
|
+ Integer couponEntityStoreId = Integer.parseInt(mkActivitiesCouponEntity.getShopSn());
|
|
|
|
+ BigDecimal couponPrice = mkActivitiesCouponEntity.getCouponPrice();
|
|
|
|
+ Constants.ActivityType couponActivityType = Constants.ActivityType.valueOf(mkActivitiesCouponEntity.getActivityType());
|
|
|
|
+ switch (couponActivityType) {
|
|
|
|
+ case BRAND:
|
|
|
|
+ goodsEntities.forEach(goodsEntity -> {
|
|
|
|
+ if (couponEntityBrandId.equals(goodsEntity.getBrandId())) {
|
|
|
|
+ BigDecimal retailPrice = goodsEntity.getRetailPrice();
|
|
|
|
+ String sku = goodsEntity.getSku();
|
|
|
|
+ String prodBarcode = goodsEntity.getProdBarcode();
|
|
|
|
+ if (couponPrice.compareTo(retailPrice) <= 0) {
|
|
|
|
+ LOGGER.error("优惠券优惠金额【{}】大于或等于商品【条码:{},sku:{}】的零售价【{}】,请检查优惠券金额设置!", couponPrice, prodBarcode, sku, retailPrice);
|
|
|
|
+ throw new ServiceException(String.format("优惠券优惠金额【%s】大于或等于商品【条码:%s,sku:%s】的零售价【%s】,请检查优惠券金额设置!", couponPrice, prodBarcode, sku, retailPrice));
|
|
|
|
+ }
|
|
|
|
+ BigDecimal discountAfterPrice = retailPrice.subtract(couponPrice);
|
|
|
|
+ GoodsDetailsDto goodsDetailsDto = new GoodsDetailsDto();
|
|
|
|
+ BeanUtils.copyProperties(goodsEntity, goodsDetailsDto);
|
|
|
|
+ // 除了限时促销(需要向海关备案),其它活动都拿海关备案价来算税款
|
|
|
|
+ BigDecimal tax = CalculateTax.calculateFinalTax(goodsEntity, goodsEntity.getRetailPrice(), goodsService).setScale(3, RoundingMode.HALF_UP);
|
|
|
|
+ goodsDetailsDto.setActualPaymentAmount(discountAfterPrice);
|
|
|
|
+ goodsDetailsDto.setGoodstaxes(String.valueOf(tax));
|
|
|
|
+ goodsDetailsDto.setActivity("优惠券活动");
|
|
|
|
+ goodsDetailsDto.setDiscountedPrice(retailPrice.subtract(discountAfterPrice));
|
|
|
|
+ goodsDetailsDtos.add(goodsDetailsDto);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ break;
|
|
|
|
+ case CATEGORY:
|
|
|
|
+ goodsEntities.forEach(goodsEntity -> {
|
|
|
|
+ if (couponEntityCategoryId.equals(goodsEntity.getCategoryId())) {
|
|
|
|
+ BigDecimal retailPrice = goodsEntity.getRetailPrice();
|
|
|
|
+ String sku = goodsEntity.getSku();
|
|
|
|
+ String prodBarcode = goodsEntity.getProdBarcode();
|
|
|
|
+ if (couponPrice.compareTo(retailPrice) <= 0) {
|
|
|
|
+ LOGGER.error("优惠券优惠金额【{}】大于或等于商品【条码:{},sku:{}】的零售价【{}】,请检查优惠券金额设置!", couponPrice, prodBarcode, sku, retailPrice);
|
|
|
|
+ throw new ServiceException(String.format("优惠券优惠金额【%s】大于或等于商品【条码:%s,sku:%s】的零售价【%s】,请检查优惠券金额设置!", couponPrice, prodBarcode, sku, retailPrice));
|
|
|
|
+ }
|
|
|
|
+ BigDecimal discountAfterPrice = retailPrice.subtract(couponPrice);
|
|
|
|
+ GoodsDetailsDto goodsDetailsDto = new GoodsDetailsDto();
|
|
|
|
+ BeanUtils.copyProperties(goodsEntity, goodsDetailsDto);
|
|
|
|
+ // 除了限时促销(需要向海关备案),其它活动都拿海关备案价来算税款
|
|
|
|
+ BigDecimal tax = CalculateTax.calculateFinalTax(goodsEntity, goodsEntity.getRetailPrice(), goodsService).setScale(3, RoundingMode.HALF_UP);
|
|
|
|
+ goodsDetailsDto.setActualPaymentAmount(discountAfterPrice);
|
|
|
|
+ goodsDetailsDto.setGoodstaxes(String.valueOf(tax));
|
|
|
|
+ goodsDetailsDto.setActivity("优惠券活动");
|
|
|
|
+ goodsDetailsDto.setDiscountedPrice(retailPrice.subtract(discountAfterPrice));
|
|
|
|
+ goodsDetailsDtos.add(goodsDetailsDto);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ break;
|
|
|
|
+ case PRODUCT:
|
|
|
|
+ mkActivitiesCouponEntities.forEach(mkActivitiesCouponEntity1 -> {
|
|
|
|
+ // 单个商品优惠券,有多条记录
|
|
|
|
+ String activityProductBarcode = mkActivitiesCouponEntity1.getBarcode();
|
|
|
|
+ String activitySku = mkActivitiesCouponEntity1.getGoodsSn();
|
|
|
|
+ goodsEntities.forEach(goodsEntity -> {
|
|
|
|
+ String sku = goodsEntity.getSku();
|
|
|
|
+ String prodBarcode = goodsEntity.getProdBarcode();
|
|
|
|
+ // 条码、sku、门店都需一致
|
|
|
|
+ if (activitySku.equals(sku) && activityProductBarcode.equals(prodBarcode) && couponEntityStoreId.equals(goodsEntity.getStoreId())) {
|
|
|
|
+ BigDecimal retailPrice = goodsEntity.getRetailPrice();
|
|
|
|
+ if (couponPrice.compareTo(retailPrice) <= 0) {
|
|
|
|
+ LOGGER.error("优惠券优惠金额【{}】大于或等于商品【条码:{},sku:{}】的零售价【{}】,请检查优惠券金额设置!", couponPrice, prodBarcode, sku, retailPrice);
|
|
|
|
+ throw new ServiceException(String.format("优惠券优惠金额【%s】大于或等于商品【条码:%s,sku:%s】的零售价【%s】,请检查优惠券金额设置!", couponPrice, prodBarcode, sku, retailPrice));
|
|
|
|
+ }
|
|
|
|
+ BigDecimal discountAfterPrice = retailPrice.subtract(couponPrice);
|
|
|
|
+ GoodsDetailsDto goodsDetailsDto = new GoodsDetailsDto();
|
|
|
|
+ BeanUtils.copyProperties(goodsEntity, goodsDetailsDto);
|
|
|
|
+ // 除了限时促销(需要向海关备案),其它活动都拿海关备案价来算税款
|
|
|
|
+ BigDecimal tax = CalculateTax.calculateFinalTax(goodsEntity, goodsEntity.getRetailPrice(), goodsService).setScale(3, RoundingMode.HALF_UP);
|
|
|
|
+ goodsDetailsDto.setActualPaymentAmount(discountAfterPrice);
|
|
|
|
+ goodsDetailsDto.setGoodstaxes(String.valueOf(tax));
|
|
|
|
+ goodsDetailsDto.setActivity("优惠券活动");
|
|
|
|
+ goodsDetailsDto.setDiscountedPrice(retailPrice.subtract(discountAfterPrice));
|
|
|
|
+ goodsDetailsDtos.add(goodsDetailsDto);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ LOGGER.error("未知的优惠券活动分类类型:【{},{}】,请联系管理员!", activityTopicEnum.getTopicCode(), activityTopicEnum.getTopicName());
|
|
|
|
+ throw new ServiceException(String.format("未知的优惠券活动分类类型:【%s,%s】,请联系管理员!", activityTopicEnum.getTopicCode(), activityTopicEnum.getTopicName()));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ break;
|
|
|
|
+ case LSCX:
|
|
|
|
+ // 判断商品是否符合限时特价活动要求
|
|
|
|
+ List<MkActivitiesPromotionEntity> mkActivitiesPromotionEntities = mkActivitiesPromotionService.queryListByMkaIdAndStoreId(mkaId.intValue(), storeId);
|
|
|
|
+ if (CollectionUtils.isEmpty(mkActivitiesPromotionEntities)) {
|
|
|
|
+ LOGGER.error("查询临时促销活动信息结果为空!mka_id:{}, store_id:{}", mkaId, storeId);
|
|
|
|
+ throw new ServiceException(String.format("查询临时促销活动信息结果为空!mka_id:%s, store_id:%s", mkaId, storeId));
|
|
|
|
+ }
|
|
|
|
+ // 限时特价,直接替换实际支付价即可,并且拿特价计算税款
|
|
|
|
+ mkActivitiesPromotionEntities.forEach(mkActivitiesPromotionEntity -> {
|
|
|
|
+ String entityBarcode = mkActivitiesPromotionEntity.getBarcode();
|
|
|
|
+ String entityGoodsSn = mkActivitiesPromotionEntity.getGoodsSn();
|
|
|
|
+ BigDecimal activityPrice = mkActivitiesPromotionEntity.getActivityPrice();
|
|
|
|
+ String shopSn = mkActivitiesPromotionEntity.getShopSn();
|
|
|
|
+ goodsEntities.forEach(goodsEntity -> {
|
|
|
|
+ String sku = goodsEntity.getSku();
|
|
|
|
+ String prodBarcode = goodsEntity.getProdBarcode();
|
|
|
|
+ String storeId2 = String.valueOf(goodsEntity.getStoreId());
|
|
|
|
+ BigDecimal retailPrice = goodsEntity.getRetailPrice();
|
|
|
|
+ if (entityBarcode.equals(prodBarcode) && entityGoodsSn.equals(sku) && shopSn.equals(storeId2)) {
|
|
|
|
+ GoodsDetailsDto goodsDetailsDto = new GoodsDetailsDto();
|
|
|
|
+ BigDecimal tax = CalculateTax.calculateFinalTax(goodsEntity, activityPrice, goodsService).setScale(3, RoundingMode.HALF_UP);
|
|
|
|
+ BeanUtils.copyProperties(goodsDetailsDto, goodsEntity);
|
|
|
|
+ goodsDetailsDto.setActualPaymentAmount(activityPrice);
|
|
|
|
+ goodsDetailsDto.setGoodstaxes(String.valueOf(tax));
|
|
|
|
+ goodsDetailsDto.setActivity("限时促销");
|
|
|
|
+ goodsDetailsDto.setDiscountedPrice(retailPrice.subtract(activityPrice));
|
|
|
|
+ goodsDetailsDtos.add(goodsDetailsDto);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ LOGGER.error("未知的满赠活动分类类型:【{},{}】,请联系管理员!", activityTopicEnum.getTopicCode(), activityTopicEnum.getTopicName());
|
|
|
|
+ throw new ServiceException(String.format("未知的满赠活动分类类型:【%s,%s】,请联系管理员!", activityTopicEnum.getTopicCode(), activityTopicEnum.getTopicName()));
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ return goodsDetailsDtos;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
* 设置订单数据
|
|
* 设置订单数据
|