|
@@ -2108,6 +2108,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public synchronized Map offlineRetailSubmit(Map param, SysUserEntity user) {
|
|
|
+ long start = System.currentTimeMillis();
|
|
|
// 解析订单数据 List
|
|
|
List<LinkedHashMap> goodsList = (List<LinkedHashMap>) param.get("goodsList");
|
|
|
// 解析用户信息 LinkedHashMap
|
|
@@ -2161,6 +2162,12 @@ public class OrderServiceImpl implements OrderService {
|
|
|
queryGoodsVo.setTotalPrice(new BigDecimal(String.valueOf(map.get("actualPaymentAmount"))));
|
|
|
queryGoodsVo.setActivity((String) map.get("activity"));
|
|
|
queryGoodsVo.setDeductionScore((Integer) map.get("deductionScore"));
|
|
|
+ Object deductionPriceObj = map.get("deductionPrice");
|
|
|
+ BigDecimal deductionPrice = BigDecimal.ZERO;
|
|
|
+ if (Objects.nonNull(deductionPriceObj)) {
|
|
|
+ deductionPrice = new BigDecimal(deductionPriceObj.toString());
|
|
|
+ }
|
|
|
+ queryGoodsVo.setDeductionPrice(deductionPrice);
|
|
|
queryGoodsVOList.add(queryGoodsVo);
|
|
|
});
|
|
|
// 将在循环中查询数据库改为一次性查询
|
|
@@ -2355,14 +2362,15 @@ public class OrderServiceImpl implements OrderService {
|
|
|
goodsEntity.setListPicUrl(goodsDto.getListPicUrl());
|
|
|
GoodsEntity goodsEntity1 = goodsEntityMap.get(sku);
|
|
|
if (Objects.nonNull(goodsEntity1)) {
|
|
|
- goodsEntity.setNetWeight(goodsEntity1.getNetWeight());
|
|
|
goodsEntity.setWarehouseSn(goodsEntity1.getWarehouseSn());
|
|
|
goodsEntity.setConsignorSn(goodsEntity1.getConsignorSn());
|
|
|
goodsEntity.setWarehousSysGoodId(goodsEntity1.getWarehousSysGoodId());
|
|
|
goodsEntity.setInventoryType(goodsEntity1.getInventoryType());
|
|
|
goodsEntity.setDefectiveProductsGrade(goodsEntity1.getDefectiveProductsGrade());
|
|
|
- weight = weight.add(goodsEntity1.getNetWeight().multiply(new BigDecimal(goodsEntity.getSellVolume())));
|
|
|
+ goodsEntity.setCategoryId(goodsEntity1.getCategoryId());
|
|
|
}
|
|
|
+ goodsEntity.setDeductionScore(goodsDto.getDeductionScore());
|
|
|
+ goodsEntity.setDeductionPrice(goodsDto.getDeductionPrice());
|
|
|
goodsEntities.add(goodsEntity);
|
|
|
} else {
|
|
|
// sku不存在
|
|
@@ -2437,7 +2445,6 @@ public class OrderServiceImpl implements OrderService {
|
|
|
order.setMerchOrderSn(merchOrderSn);
|
|
|
order.setCoupon_name(couponSn); // 借用这个字段来记录是否使用优惠券
|
|
|
order.setIdCard(userEntity.getIdNo());
|
|
|
- order.setWeight(weight);
|
|
|
//插入订单信息和订单商品
|
|
|
orderDao.saveOrderVo(order);
|
|
|
|
|
@@ -2731,6 +2738,9 @@ public class OrderServiceImpl implements OrderService {
|
|
|
// 推单
|
|
|
sendOrderInfoToVmcShop(order, orderGoodsVoList);
|
|
|
|
|
|
+ LOGGER.info("----------------------------------------------------------------------------");
|
|
|
+ LOGGER.info("下单耗时:{}ms", (System.currentTimeMillis()) - start);
|
|
|
+ LOGGER.info("----------------------------------------------------------------------------");
|
|
|
return resultObj;
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
@@ -2872,7 +2882,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 组装推送订单数据:跨境数据
|
|
|
+ * 组装推送订单数据:订单数据
|
|
|
* @param order 订单数据
|
|
|
* @return 订单数据
|
|
|
*/
|
|
@@ -2890,12 +2900,6 @@ public class OrderServiceImpl implements OrderService {
|
|
|
orderInfoDTO.setConsigneeTel("0756-8800000");
|
|
|
orderInfoDTO.setConsigneeEmail("hk@greedc.com");
|
|
|
orderInfoDTO.setConsigneeMobile(order.getMobile());
|
|
|
- BigDecimal weight = order.getWeight();
|
|
|
- if (Objects.nonNull(weight)) {
|
|
|
- orderInfoDTO.setWeight(weight.toString());
|
|
|
- } else {
|
|
|
- orderInfoDTO.setWeight("0");
|
|
|
- }
|
|
|
orderInfoDTO.setQuantity(order.getNumber());
|
|
|
orderInfoDTO.setOrderTotal(order.getActual_price());
|
|
|
orderInfoDTO.setPlatform("store");
|
|
@@ -3170,6 +3174,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
LOGGER.info("请求会员系统同步消费订单接口!请求体:{}", body);
|
|
|
// 发送请求
|
|
|
String memberOrderSyncResponseJson = haiKongMemberTemplate.memberOrderSync(body);
|
|
|
+ LOGGER.info("请求会员系统同步消费订单接口!响应:{}", memberOrderSyncResponseJson);
|
|
|
Response<Long> response = JacksonUtil.fromListJson(memberOrderSyncResponseJson, new TypeReference<Response<Long>>() {});
|
|
|
if (Objects.nonNull(response) && response.getSuccess()) {
|
|
|
haiKongMemberOrderSyncResendEntity.setMemberSysOrderId(response.getData());
|
|
@@ -3178,7 +3183,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
haiKongMemberOrderSyncResendEntity.setResendStatus(HaiKongMemberOrderResendStatusEnum.WAIT_RESEND.getStatus());
|
|
|
}
|
|
|
haiKongMemberOrderSyncResendService.save(haiKongMemberOrderSyncResendEntity);
|
|
|
- LOGGER.info("请求会员系统同步消费订单接口成功!响应数据:{}", memberOrderSyncResponseJson);
|
|
|
+ LOGGER.info("请求会员系统同步消费订单接口成功!");
|
|
|
} catch (Exception e) {
|
|
|
LOGGER.error("请求会员系统同步消费订单接口出现异常!准备新增发送失败记录,等待重发!异常信息:", e);
|
|
|
// 没有请求成功,写表,重发
|
|
@@ -3221,6 +3226,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
String body = JacksonUtil.toJson(memberScoreChangeDTO);
|
|
|
LOGGER.info("请求会员系统积分变动接口!请求体:{}", body);
|
|
|
String changeMemberScoreResponseJson = haiKongMemberTemplate.changeMemberScore(body);
|
|
|
+ LOGGER.info("请求会员系统积分变动接口!响应数据:{}", changeMemberScoreResponseJson);
|
|
|
Response<MemberScoreChangeResponseDTO> response = JacksonUtil.fromListJson(changeMemberScoreResponseJson, new TypeReference<Response<MemberScoreChangeResponseDTO>>() {});
|
|
|
if (Objects.nonNull(response) && response.getSuccess()) {
|
|
|
MemberScoreChangeResponseDTO responseData = response.getData();
|
|
@@ -3230,7 +3236,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
haiKongMemberScoreChangeRecordEntity.setResendStatus(HaiKongMemberOrderResendStatusEnum.WAIT_RESEND.getStatus());
|
|
|
}
|
|
|
haiKongMemberScoreChangeRecordService.save(haiKongMemberScoreChangeRecordEntity);
|
|
|
- LOGGER.info("请求会员系统积分变动接口成功!响应数据:{}", changeMemberScoreResponseJson);
|
|
|
+ LOGGER.info("请求会员系统积分变动接口成功!");
|
|
|
} catch (Exception e) {
|
|
|
LOGGER.error("请求会员系统积分变动接口出现异常!准备新增发送失败记录,等待重发!异常信息:", e);
|
|
|
// 失败重发
|
|
@@ -4260,6 +4266,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
goodsDetailsDto.setGoodstaxes(String.valueOf(tax.multiply(new BigDecimal(goodsDetailsDto.getSellVolume()))));
|
|
|
goodsDetailsDto.setActivity(Constants.ActivityTopicEnum.LSCX.getTopicName());
|
|
|
goodsDetailsDto.setDiscountedPrice(retailPrice.subtract(activityPrice));
|
|
|
+ goodsDetailsDto.setDeductionPrice(retailPrice.subtract(activityPrice));
|
|
|
activityFlag.set(false);
|
|
|
promotionActivityFlag.set(true);
|
|
|
}
|
|
@@ -4509,7 +4516,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
Integer score = memberInfoDTO.getScore();
|
|
|
if (Objects.nonNull(score) && score > 0) {
|
|
|
// 有积分
|
|
|
- afterDiscountPrice = calculatePreferentialPrice(orderTotalPrice, score, memberCode, activityFlag, calculateOrderDiscountPriceResponseVO, goodsDetailsDtos, promotionSkuList);
|
|
|
+ afterDiscountPrice = calculatePreferentialPrice(orderTotalPrice, score, memberCode, storeId, calculateOrderDiscountPriceResponseVO, goodsDetailsDtos, promotionSkuList, mkActivitiesEntityList);
|
|
|
LOGGER.info("会员【{}】,当前积分:{},积分抵扣后的订单金额:{},积分抵扣前的订单金额:{}", memberCode, score, afterDiscountPrice, orderTotalPrice);
|
|
|
calculateOrderDiscountPriceResponseVO.setOrderTotalPrice(afterDiscountPrice);
|
|
|
calculateOrderDiscountPriceResponseVO.setGoodsDetailsDtos(goodsDetailsDtos);
|
|
@@ -4551,30 +4558,43 @@ public class OrderServiceImpl implements OrderService {
|
|
|
private BigDecimal calculatePreferentialPrice(BigDecimal orderTotalPrice,
|
|
|
Integer score,
|
|
|
String memberCode,
|
|
|
- AtomicBoolean activityFlag,
|
|
|
+ String storeId,
|
|
|
CalculateOrderDiscountPriceResponseVO calculateOrderDiscountPriceResponseVO,
|
|
|
List<GoodsDetailsDto> goodsDetailsDtos,
|
|
|
- List<String> promotionSkuList) {
|
|
|
+ List<String> promotionSkuList,
|
|
|
+ List<MkActivitiesEntity> mkActivitiesEntityList) {
|
|
|
// 1. 判断是否有积分,是否需要计算积分抵扣后的价格
|
|
|
AtomicBoolean isCalculateScorePrice = new AtomicBoolean(false);
|
|
|
if (Objects.nonNull(score) && score > 0) {
|
|
|
isCalculateScorePrice.set(true);
|
|
|
}
|
|
|
- // 参与了积分抵扣的sku集合
|
|
|
- Date date = new Date();
|
|
|
- List<MkActivitiesScoreEntity> mkActivitiesScoreEntities = mkActivitiesScoreService.queryDetailByTime(date);
|
|
|
- if (CollectionUtils.isEmpty(mkActivitiesScoreEntities)) {
|
|
|
- LOGGER.error("当前时间【{}】无积分抵扣活动!", date);
|
|
|
+ // 参与了积分抵扣的活动id
|
|
|
+ List<Long> mkaIdList = mkActivitiesEntityList.stream().filter(mkActivitiesEntity -> Constants.ActivityTopicEnum.JFDK.getTopicCode().equals(mkActivitiesEntity.getMkaTopic()))
|
|
|
+ .map(MkActivitiesEntity::getMkaId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (CollectionUtils.isEmpty(mkaIdList)) {
|
|
|
+ LOGGER.error("当前时间【{}】无积分抵扣活动!", new Date());
|
|
|
return orderTotalPrice;
|
|
|
}
|
|
|
+
|
|
|
+ List<MkActivitiesScoreEntity> mkActivitiesScoreEntities = mkActivitiesScoreService.queryActivityInfoByMkaIdList(mkaIdList);
|
|
|
+
|
|
|
+ // 参与了积分抵扣的sku集合
|
|
|
List<String> scoreDeductionSkuList = mkActivitiesScoreEntities.stream()
|
|
|
.filter(m -> Constants.RejectStatus.ALLOW.getCode().equals(m.getReject()))
|
|
|
.map(MkActivitiesScoreEntity::getSku)
|
|
|
.collect(Collectors.toList());
|
|
|
- // 转换成map,保存参与了积分抵扣活动的sku,积分计算比例的数据,key===>sku,value===>比例
|
|
|
+ // 转换成map,保存参与了积分抵扣活动的sku,积分计算比例的数据,key===>sku,value===>最大抵扣比例
|
|
|
Map<String, BigDecimal> skuScoreLimitMap = mkActivitiesScoreEntities.stream()
|
|
|
.filter(m -> Constants.RejectStatus.ALLOW.getCode().equals(m.getReject()))
|
|
|
- .collect(Collectors.toMap(MkActivitiesScoreEntity::getSku, MkActivitiesScoreEntity::getScoreLimit, (k1, k2) -> k2));
|
|
|
+ .collect(Collectors.toMap(MkActivitiesScoreEntity::getSku, mkActivitiesScoreEntity -> {
|
|
|
+ BigDecimal scoreLimit = mkActivitiesScoreEntity.getScoreLimit();
|
|
|
+ if (Objects.isNull(scoreLimit)) {
|
|
|
+ LOGGER.error("商品:【{}】,未设置最大抵扣比例!请设置后在计算优惠价!", mkActivitiesScoreEntity.getSku());
|
|
|
+ throw new ServiceException(String.format("商品:【%s】,未设置最大抵扣比例!请设置后在计算优惠价!", mkActivitiesScoreEntity.getSku()));
|
|
|
+ }
|
|
|
+ return scoreLimit;
|
|
|
+ }, (k1, k2) -> k2));
|
|
|
// 当前订单中参与了积分抵扣活动的sku总支付金额
|
|
|
BigDecimal skuTotalPrice = BigDecimal.ZERO;
|
|
|
for (GoodsDetailsDto goodsDetailsDto : goodsDetailsDtos) {
|
|
@@ -4590,31 +4610,25 @@ public class OrderServiceImpl implements OrderService {
|
|
|
if (isCalculateScorePrice.get()) {
|
|
|
Integer scoreLimit = haiKongProperties.getMemberScoreLimit();
|
|
|
if (score < scoreLimit) {
|
|
|
- LOGGER.warn("用户【{}】的积分数量为:{},最低需要30积分才能抵扣!", memberCode, score);
|
|
|
+ LOGGER.error("用户【{}】的积分数量为:{},最低需要{}积分才能抵扣!", memberCode, score, scoreLimit);
|
|
|
calculateOrderDiscountPriceResponseVO.setAfterScore(score);
|
|
|
- return orderTotalPrice;
|
|
|
+ throw new ServiceException(String.format("用户【%s】的积分数量为:%s,最低需要%s积分才能抵扣!", memberCode, score, scoreLimit));
|
|
|
} else {
|
|
|
// 积分取整
|
|
|
int scoreInteger = score % scoreLimit == 0 ? score : score - (score % scoreLimit);
|
|
|
- // 积分的50%
|
|
|
- int scoreIntegerHalf = scoreInteger * scoreLimit / 100;
|
|
|
- // 3-2. 计算出积分能抵扣的价格
|
|
|
- int scoreMayDeductionPrice = (int) (score / scoreLimit);
|
|
|
- BigDecimal scoreMayDeductionPriceDecimal = new BigDecimal(scoreMayDeductionPrice);
|
|
|
// 过滤掉参与过限时特价并且与积分抵扣互斥的sku,以及未参加积分抵扣活动的sku
|
|
|
goodsDetailsDtos = goodsDetailsDtos.stream().filter(goodsDetailsDto -> {
|
|
|
if (!promotionSkuList.contains(goodsDetailsDto.getSku()) && scoreDeductionSkuList.contains(goodsDetailsDto.getSku())) {
|
|
|
return true;
|
|
|
}
|
|
|
// 满赠商品不参与积分分摊计算
|
|
|
- if (!Constants.ActivityTopicEnum.MZ.getTopicName().equals(goodsDetailsDto.getActivity())) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- return false;
|
|
|
+ return !Constants.ActivityTopicEnum.MZ.getTopicName().equals(goodsDetailsDto.getActivity());
|
|
|
}).collect(Collectors.toList());
|
|
|
// 总分摊积分
|
|
|
BigDecimal shareScore = BigDecimal.ZERO;
|
|
|
+ // 取整后的积分数量
|
|
|
BigDecimal scoreIntegerDecimal = BigDecimal.valueOf(scoreInteger);
|
|
|
+ // 订单详情积分抵扣总金额
|
|
|
BigDecimal goodsDetailScoreDeductionPrice = BigDecimal.ZERO;
|
|
|
int size = goodsDetailsDtos.size();
|
|
|
for (int i = 0; i < size; i++) {
|
|
@@ -4623,62 +4637,75 @@ public class OrderServiceImpl implements OrderService {
|
|
|
int index = size - 1;
|
|
|
goodsDetailsDto.setActivity(org.springframework.util.StringUtils.isEmpty(goodsDetailsDto.getActivity()) ? "积分抵扣" : goodsDetailsDto.getActivity() + ",积分抵扣");
|
|
|
String sku = goodsDetailsDto.getGoodsSn();
|
|
|
+ // 系统设置的最大抵扣比例(最多能抵扣订单金额的比例),导入积分抵扣活动时设置
|
|
|
BigDecimal scoreLimitDecimal = skuScoreLimitMap.get(sku);
|
|
|
String prodBarcode = goodsDetailsDto.getProdBarcode();
|
|
|
- BigDecimal retailPrice = goodsDetailsDto.getRetailPrice();
|
|
|
+ // 此字段 = 零售价 - 其他活动优惠金额
|
|
|
BigDecimal actualPaymentAmount = goodsDetailsDto.getActualPaymentAmount();
|
|
|
+ // 当前商品最大支持抵扣的金额
|
|
|
+ BigDecimal currentSkuMaxDeductionPrice = actualPaymentAmount.multiply(BigDecimal.valueOf(goodsDetailsDto.getSellVolume()))
|
|
|
+ .multiply(scoreLimitDecimal);
|
|
|
+ // 其他活动优惠金额
|
|
|
+ BigDecimal otherDiscountedPrice = Objects.isNull(goodsDetailsDto.getDiscountedPrice()) ? BigDecimal.ZERO : goodsDetailsDto.getDiscountedPrice();
|
|
|
+
|
|
|
+ // 当前商品分摊积分数量,当前商品分摊积分 = 当前商品支付价 / 订单中所有参与积分抵扣商品支付价的和 * 积分取整
|
|
|
+ BigDecimal shareScoreItem = BigDecimal.ZERO;
|
|
|
+ // 当前商品分摊积分抵扣金额,保留两位小数,四舍五入
|
|
|
+ BigDecimal discountedPrice = BigDecimal.ZERO;
|
|
|
// 计算抵扣,当商品不是最后一个商品
|
|
|
if (i < index) {
|
|
|
- // 商品总价
|
|
|
- // 分摊积分
|
|
|
- BigDecimal shareScoreItem = retailPrice.divide(skuTotalPrice, 2, BigDecimal.ROUND_HALF_UP).multiply(scoreIntegerDecimal);
|
|
|
- shareScore = shareScore.add(shareScoreItem);
|
|
|
- // 保留两位小数,四舍五入
|
|
|
- BigDecimal discountedPrice = shareScore.divide(BigDecimal.valueOf(scoreLimit), 2, BigDecimal.ROUND_HALF_UP);
|
|
|
- goodsDetailScoreDeductionPrice = goodsDetailScoreDeductionPrice.add(discountedPrice);
|
|
|
- goodsDetailsDto.setDiscountedPrice(discountedPrice);
|
|
|
- goodsDetailsDto.setDeductionScore(shareScoreItem.intValue());
|
|
|
- goodsDetailsDto.setActualPaymentAmount(actualPaymentAmount.subtract(discountedPrice));
|
|
|
+ shareScoreItem = actualPaymentAmount.divide(skuTotalPrice, 2, BigDecimal.ROUND_HALF_UP).multiply(scoreIntegerDecimal);
|
|
|
+ discountedPrice = shareScoreItem.divide(BigDecimal.valueOf(scoreLimit), 2, BigDecimal.ROUND_HALF_UP);
|
|
|
}
|
|
|
// 订单商品详情最后一个商品并且详情不止一个商品
|
|
|
if (i == index && size > 1) {// 商品总价
|
|
|
- // 分摊积分
|
|
|
- BigDecimal shareScoreItem = scoreIntegerDecimal.subtract(shareScore);
|
|
|
- BigDecimal discountedPrice = shareScoreItem.divide(BigDecimal.valueOf(scoreLimit), 2, BigDecimal.ROUND_HALF_UP);
|
|
|
- goodsDetailScoreDeductionPrice = goodsDetailScoreDeductionPrice.add(discountedPrice);
|
|
|
- goodsDetailsDto.setDiscountedPrice(discountedPrice);
|
|
|
- goodsDetailsDto.setDeductionScore(shareScoreItem.intValue());
|
|
|
- goodsDetailsDto.setActualPaymentAmount(actualPaymentAmount.subtract(discountedPrice));
|
|
|
+ // 最后一个商品分摊积分 = 积分总数 - 已分摊积分
|
|
|
+ shareScoreItem = scoreIntegerDecimal.subtract(shareScore);
|
|
|
+ discountedPrice = shareScoreItem.divide(BigDecimal.valueOf(scoreLimit), 2, BigDecimal.ROUND_HALF_UP);
|
|
|
}
|
|
|
// 订单商品详情只有一个商品的情况下
|
|
|
if (size == 1) {
|
|
|
+ // 总计分为所有积分取整
|
|
|
shareScore = scoreIntegerDecimal;
|
|
|
- // 3-1. 计算总价的50%,百分比可以进行设置,算出整数(向下取整)
|
|
|
- BigDecimal halfPrice = orderTotalPrice.multiply(new BigDecimal("0.5")).setScale(0, BigDecimal.ROUND_FLOOR);
|
|
|
// 3-3. 计算积分抵扣后的价格
|
|
|
- BigDecimal discountedPrice = scoreMayDeductionPriceDecimal;
|
|
|
- if (halfPrice.compareTo(discountedPrice) <= 0) {
|
|
|
- // 积分能抵扣的金额大于订单总额的50%,按50%抵扣
|
|
|
- discountedPrice = halfPrice;
|
|
|
- }
|
|
|
- goodsDetailScoreDeductionPrice = goodsDetailScoreDeductionPrice.add(discountedPrice);
|
|
|
- goodsDetailsDto.setDiscountedPrice(discountedPrice);
|
|
|
- goodsDetailsDto.setDeductionScore(shareScore.intValue());
|
|
|
- goodsDetailsDto.setActualPaymentAmount(actualPaymentAmount.subtract(discountedPrice));
|
|
|
+ discountedPrice = shareScore.divide(BigDecimal.valueOf(scoreLimit), 2, BigDecimal.ROUND_HALF_UP);
|
|
|
}
|
|
|
+ // 当前计算出来的积分抵扣金额如果比最大的还要大,则积分抵扣金额为最大抵扣金额,并且积分需要重新计算
|
|
|
+ if (discountedPrice.compareTo(currentSkuMaxDeductionPrice) > 0) {
|
|
|
+ discountedPrice = currentSkuMaxDeductionPrice;
|
|
|
+ shareScoreItem = discountedPrice.multiply(BigDecimal.valueOf(scoreLimit)).setScale(0, BigDecimal.ROUND_FLOOR);
|
|
|
+ }
|
|
|
+ // 总分摊积分
|
|
|
+ shareScore = shareScore.add(shareScoreItem);
|
|
|
+ // 订单总积分抵扣金额,减去其他优惠金额
|
|
|
+ goodsDetailScoreDeductionPrice = goodsDetailScoreDeductionPrice.add(discountedPrice);
|
|
|
+ // 设置积分的优惠金额
|
|
|
+ goodsDetailsDto.setDeductionPrice(discountedPrice);
|
|
|
+ // 设置实际支付价
|
|
|
+ goodsDetailsDto.setActualPaymentAmount(actualPaymentAmount.subtract(discountedPrice));
|
|
|
+ // 设置抵扣积分数量
|
|
|
+ goodsDetailsDto.setDeductionScore(shareScoreItem.intValue());
|
|
|
+ if (Objects.nonNull(otherDiscountedPrice)) {
|
|
|
+ discountedPrice = discountedPrice.add(otherDiscountedPrice);
|
|
|
+ }
|
|
|
+ // 设置总优惠金额
|
|
|
+ goodsDetailsDto.setDiscountedPrice(discountedPrice);
|
|
|
LOGGER.info("--------------------------------------------------------");
|
|
|
LOGGER.info("【计算优惠价】sku:【{}】,条码:【{}】积分抵扣{}元,抵扣积分{}分", sku, prodBarcode, goodsDetailsDto.getDiscountedPrice(), shareScore.intValue());
|
|
|
LOGGER.info("--------------------------------------------------------");
|
|
|
}
|
|
|
- scoreMayDeductionPriceDecimal = goodsDetailScoreDeductionPrice;
|
|
|
-
|
|
|
- orderTotalPrice = calculateOrderDiscountPriceResponseVO.getOrderTotalPrice().subtract(scoreMayDeductionPriceDecimal);
|
|
|
+ orderTotalPrice = calculateOrderDiscountPriceResponseVO.getOrderTotalPrice().subtract(goodsDetailScoreDeductionPrice);
|
|
|
int afterScore = score - shareScore.intValue();
|
|
|
+ // 抵扣后的积分数量
|
|
|
calculateOrderDiscountPriceResponseVO.setAfterScore(afterScore);
|
|
|
+ // 最大抵扣比例
|
|
|
calculateOrderDiscountPriceResponseVO.setScoreLimit(scoreLimit);
|
|
|
+ // 抵扣的积分数量
|
|
|
calculateOrderDiscountPriceResponseVO.setDeductionScore(score - afterScore);
|
|
|
+ // 订单总价
|
|
|
calculateOrderDiscountPriceResponseVO.setOrderTotalPrice(orderTotalPrice);
|
|
|
- calculateOrderDiscountPriceResponseVO.setScoreDeductionPrice(scoreMayDeductionPriceDecimal);
|
|
|
+ // 积分抵扣的总金额
|
|
|
+ calculateOrderDiscountPriceResponseVO.setScoreDeductionPrice(goodsDetailScoreDeductionPrice);
|
|
|
LOGGER.info("会员【{}】,当前积分:{},抵扣订单金额后剩余积分:{}", memberCode, score, afterScore);
|
|
|
}
|
|
|
} else {
|
|
@@ -4916,7 +4943,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
orderInfo.setPostscript("无");
|
|
|
orderInfo.setAdd_time(new Date());
|
|
|
orderInfo.setGoods_price(actualPrice.subtract(totalTax));
|
|
|
- orderInfo.setOrder_price(orderTotalPrice);
|
|
|
+ orderInfo.setOrder_price(actualPrice);
|
|
|
orderInfo.setActual_price(actualPrice); // 实际支付金额
|
|
|
orderInfo.setOrder_type("1");
|
|
|
orderInfo.setOrder_status(0);
|
|
@@ -4969,6 +4996,8 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
|
orderGoodsVo.setDiscountedPrice(goodsDto.getDiscountedPrice());
|
|
|
orderGoodsVo.setActualPaymentAmount(goodsDto.getActualPaymentAmount());
|
|
|
+ orderGoodsVo.setDeductionScore(goodsDto.getDeductionScore());
|
|
|
+ orderGoodsVo.setDeductionPrice(goodsDto.getDeductionPrice());
|
|
|
|
|
|
orderGoodsVo.setNumber(goodsDto.getSellVolume());
|
|
|
// orderGoodsVo.setGoods_specification_name_value(goodsDto.get);
|
|
@@ -4981,7 +5010,6 @@ public class OrderServiceImpl implements OrderService {
|
|
|
orderGoodsVo.setGoodsRate(goodsDto.getGoodsRate());
|
|
|
orderGoodsVo.setSku(goodsDto.getSku());
|
|
|
|
|
|
- orderGoodsVo.setNetWeight(goodsDto.getNetWeight());
|
|
|
orderGoodsVo.setWarehouseSn(goodsDto.getWarehouseSn());
|
|
|
orderGoodsVo.setConsignorSn(goodsDto.getConsignorSn());
|
|
|
orderGoodsVo.setWarehouseSysGoodId(goodsDto.getWarehousSysGoodId());
|