|
@@ -20,6 +20,7 @@ import com.kmall.admin.dao.vip.Mall2MemberPointsDao;
|
|
|
import com.kmall.admin.dao.vip.Mall2PointsRulesDao;
|
|
|
import com.kmall.admin.dto.*;
|
|
|
import com.kmall.admin.entity.*;
|
|
|
+import com.kmall.admin.entity.haikong.HaiKongMemberOrderSyncResendEntity;
|
|
|
import com.kmall.admin.entity.mk.MkActivitiesEntity;
|
|
|
import com.kmall.admin.entity.mk.store.MkStorePromOrderRealEntity;
|
|
|
import com.kmall.admin.entity.record.NewRetailOrderRestoreStockRecordEntity;
|
|
@@ -29,7 +30,9 @@ import com.kmall.admin.entity.vip.Mall2PointsRulesEntity;
|
|
|
import com.kmall.admin.fromcomm.dao.SysConfigDao;
|
|
|
import com.kmall.admin.fromcomm.entity.SysUserEntity;
|
|
|
import com.kmall.admin.haikong.constant.Constants;
|
|
|
+import com.kmall.admin.haikong.constant.HaiKongMemberOrderResendStatusEnum;
|
|
|
import com.kmall.admin.haikong.constant.VmcconnectUrlEnum;
|
|
|
+import com.kmall.admin.haikong.dto.MemberOrderInfoSyncDTO;
|
|
|
import com.kmall.admin.haikong.dto.WareQueryStockResponseDTO;
|
|
|
import com.kmall.admin.haikong.utils.ListUtils;
|
|
|
import com.kmall.admin.haikong.vo.CalculateOrderDiscountPriceResponseVO;
|
|
@@ -41,6 +44,7 @@ import com.kmall.admin.haikong.config.HaiKongProperties;
|
|
|
import com.kmall.admin.haikong.dto.MemberInfoDTO;
|
|
|
import com.kmall.admin.haikong.utils.Response;
|
|
|
import com.kmall.admin.service.*;
|
|
|
+import com.kmall.admin.service.haikong.HaiKongMemberOrderSyncResendService;
|
|
|
import com.kmall.admin.service.kmall2eccs.KtoEccsService;
|
|
|
import com.kmall.admin.service.mk.MkActivitiesService;
|
|
|
import com.kmall.admin.service.mk.store.MkStoreCampMinusService;
|
|
@@ -91,6 +95,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
+import java.awt.image.LookupOp;
|
|
|
import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
@@ -208,8 +213,8 @@ public class OrderServiceImpl implements OrderService {
|
|
|
@Autowired
|
|
|
private AddressInfoService addressInfoService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private CustomsClearanceTimeliness customsClearanceTimeliness;
|
|
|
+// @Autowired
|
|
|
+// private CustomsClearanceTimeliness customsClearanceTimeliness;
|
|
|
|
|
|
@Autowired
|
|
|
private HaiKongMemberTemplate haiKongMemberTemplate;
|
|
@@ -251,6 +256,11 @@ public class OrderServiceImpl implements OrderService {
|
|
|
@Autowired
|
|
|
private MallVmcSendLogDao mallVmcSendLogDao;
|
|
|
|
|
|
+ /**
|
|
|
+ * 同步订单消费信息,重发业务
|
|
|
+ */
|
|
|
+ private HaiKongMemberOrderSyncResendService haiKongMemberOrderSyncResendService;
|
|
|
+
|
|
|
|
|
|
|
|
|
@Override
|
|
@@ -596,6 +606,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
/**
|
|
|
* 退款
|
|
|
*/
|
|
|
+ @Override
|
|
|
@Transactional
|
|
|
public void refund(OrderEntity order) {
|
|
|
boolean needUpdateStock = true;
|
|
@@ -2012,8 +2023,9 @@ public class OrderServiceImpl implements OrderService {
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional
|
|
|
+ @Deprecated
|
|
|
public synchronized Map offlineRetailSubmitHaiKong(Map param, SysUserEntity user) {
|
|
|
- // 解析订单数据 List
|
|
|
+ /*// 解析订单数据 List
|
|
|
List<LinkedHashMap> goodsList = (List<LinkedHashMap>) param.get("goodsList");
|
|
|
// 解析用户信息 LinkedHashMap
|
|
|
Map userInfo = (Map) param.get("userInfo");
|
|
@@ -2290,78 +2302,8 @@ public class OrderServiceImpl implements OrderService {
|
|
|
// 6. 订单入库
|
|
|
|
|
|
|
|
|
- return resultObj;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 设置订单商品详情数据
|
|
|
- * @param orderGoodsEntity 订单商品详情
|
|
|
- * @param goodsEntity 商品信息
|
|
|
- * @return 订单商品详情
|
|
|
- */
|
|
|
- private OrderGoodsEntity wrapOrderGoods(OrderGoodsEntity orderGoodsEntity, GoodsEntity goodsEntity) {
|
|
|
- // 设置商品信息
|
|
|
- BeanUtils.copyProperties(goodsEntity, orderGoodsEntity);
|
|
|
- // 设置订单信息
|
|
|
- // 销售数
|
|
|
- orderGoodsEntity.setNumber(goodsEntity.getGoodsNumber());
|
|
|
- // TODO other...
|
|
|
- return orderGoodsEntity;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 计算优惠后的价格
|
|
|
- * 1、优惠券优先于积分抵扣
|
|
|
- * 2、限时特价与积分不互斥,虽然海控没说哪个优先,但我觉得应该是限时特价优先于积分
|
|
|
- * 3、优惠券之间互斥
|
|
|
- * 4、活动和优惠券互斥
|
|
|
- * @param orderPrice 订单总价
|
|
|
- * @param score 会员积分
|
|
|
- * @param goodsEntities 订单商品明细
|
|
|
- * @param storeId 门店id
|
|
|
- * @param userInfo 用户信息
|
|
|
- * @return 优惠后的价格
|
|
|
- */
|
|
|
- private BigDecimal calculatePreferentialPrice (BigDecimal orderPrice, Integer score, List<LinkedHashMap> goodsEntities, Integer storeId, Map userInfo) {
|
|
|
- // 优惠后的价格
|
|
|
- BigDecimal preferentialPrice = BigDecimal.ZERO;
|
|
|
- // 1. 判断是否有积分,是否需要计算积分抵扣后的价格
|
|
|
- AtomicBoolean isCalculateScorePrice = new AtomicBoolean(false);
|
|
|
- if (Objects.nonNull(score) && score > 0) {
|
|
|
- isCalculateScorePrice.set(true);
|
|
|
- }
|
|
|
- // 2. 查询订单商品是否有优惠券和参加活动
|
|
|
- goodsEntities.forEach(map -> {
|
|
|
- // 2-1. 判断活动和优惠券之间的互斥关系
|
|
|
-
|
|
|
- // 2-2. 计算优惠、活动后的总价格
|
|
|
-
|
|
|
- });
|
|
|
- // 3. 计算积分抵扣后的总价格
|
|
|
- if (isCalculateScorePrice.get()) {
|
|
|
- // 3-1. 计算总价的50%
|
|
|
- BigDecimal halfPrice = preferentialPrice.multiply(new BigDecimal("0.5")).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- Integer scoreLimit = haiKongProperties.getMemberScoreLimit();
|
|
|
- if (score < scoreLimit) {
|
|
|
- LOGGER.warn("用户【{}】的积分数量为:{},最低需要30积分才能抵扣!", userInfo.get("customName"), score);
|
|
|
- return preferentialPrice;
|
|
|
- } else {
|
|
|
- // 3-2. 计算出积分能抵扣的价格
|
|
|
- int scoreMayDeductionPrice = score % scoreLimit == 0 ? score / scoreLimit : (int) (score / scoreLimit);
|
|
|
- // 3-3. 计算积分抵扣后的价格
|
|
|
- BigDecimal scoreMayDeductionPriceDecimal = new BigDecimal(scoreMayDeductionPrice);
|
|
|
- if (halfPrice.compareTo(scoreMayDeductionPriceDecimal) > 0) {
|
|
|
- preferentialPrice = preferentialPrice.subtract(scoreMayDeductionPriceDecimal);
|
|
|
- } else {
|
|
|
- // 积分能抵扣的金额如果比总价的50%还要多,只能抵扣50%
|
|
|
- // 总价50%的值
|
|
|
- int halfPriceInt = halfPrice.setScale(0, BigDecimal.ROUND_FLOOR).intValue();
|
|
|
- int i = scoreMayDeductionPrice - halfPriceInt;
|
|
|
- preferentialPrice = preferentialPrice.subtract(new BigDecimal(halfPriceInt));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return preferentialPrice;
|
|
|
+ return resultObj;*/
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -2407,10 +2349,35 @@ public class OrderServiceImpl implements OrderService {
|
|
|
machineCode = URLDecoder.decode(machineCode, "UTF-8");
|
|
|
} catch (Exception e) {
|
|
|
// e.printStackTrace();
|
|
|
+ LOGGER.error("decode machine code failed! error message : ", e);
|
|
|
}
|
|
|
|
|
|
Map resultObj = Maps.newHashMap();
|
|
|
-
|
|
|
+ // 海控需求,下单流程修改,收银端接收会员码,付款码,用户信息,订单数据
|
|
|
+ // 1. 校验库存:保税仓库存 + 展销店库存 - 出区数 >= 购买数
|
|
|
+ // 获取保税仓库存
|
|
|
+ String queryWarehouseStockResponse = haiKongWarehouseTemplate.queryWarehouseStock(null);
|
|
|
+ if (org.springframework.util.StringUtils.isEmpty(queryWarehouseStockResponse)) {
|
|
|
+ LOGGER.error("调用库存系统接口出现错误!返回结果为空!");
|
|
|
+ throw new ServiceException("调用库存系统接口出现错误!");
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ });
|
|
|
try {
|
|
|
if (user == null) {
|
|
|
resultObj.put("errno", 400);
|
|
@@ -2433,200 +2400,129 @@ public class OrderServiceImpl implements OrderService {
|
|
|
List<GoodsEntity> goodsEntities = new ArrayList<>();
|
|
|
|
|
|
BigDecimal totalTax = new BigDecimal(0);
|
|
|
-
|
|
|
+ // 根据商品条码、sku、门店id查询相对应的商品信息,并组装成对象
|
|
|
+ List<QueryGoodsVO> queryGoodsVOList = new ArrayList<>();
|
|
|
+ goodsList.forEach(map -> {
|
|
|
+ QueryGoodsVO queryGoodsVo = new QueryGoodsVO();
|
|
|
+ queryGoodsVo.setProdBarcode((String) map.get("prodBarcode"));
|
|
|
+ queryGoodsVo.setSku((String) map.get("goodsSn"));
|
|
|
+ queryGoodsVo.setStoreId(storeId);
|
|
|
+ queryGoodsVo.setSellVolume((Integer) map.get("sellVolume"));
|
|
|
+ queryGoodsVo.setRetailPrice(new BigDecimal(String.valueOf(map.get("retailPrice"))));
|
|
|
+ queryGoodsVo.setGoodsTaxes(new BigDecimal(String.valueOf(map.get("goodstaxes"))));
|
|
|
+ queryGoodsVo.setDisCountedPrice(new BigDecimal(String.valueOf(map.get("disCountedPrice"))));
|
|
|
+ queryGoodsVo.setActivity((String) map.get("activity"));
|
|
|
+ queryGoodsVOList.add(queryGoodsVo);
|
|
|
+ });
|
|
|
+ // 将在循环中查询数据库改为一次性查询
|
|
|
+ List<GoodsEntity> goodsEntityList = goodsService.queryGoodsStockByQueryGoodsVoList(queryGoodsVOList);
|
|
|
+ // 复制集合数据
|
|
|
+ ListUtils listUtils = BeanUtils.instantiate(ListUtils.class);
|
|
|
+ listUtils.copyList(goodsEntityList, queryGoodsVOList);
|
|
|
// 检查库存和更新库存
|
|
|
- for (LinkedHashMap goodsDto : goodsList) {
|
|
|
+ for (QueryGoodsVO goodsDto : queryGoodsVOList) {
|
|
|
// 要购买的数量
|
|
|
- Integer sellVolume = (Integer) goodsDto.get("sellVolume");
|
|
|
-
|
|
|
- Integer goodsSellNumber = (Integer) goodsDto.get("sellVolume");
|
|
|
-
|
|
|
- String prodBarcode = (String) goodsDto.get("prodBarcode");
|
|
|
- String sku = (String) goodsDto.get("goodsSn");
|
|
|
- Map<GoodsEntity, Integer> numberMap = new HashMap<>();
|
|
|
- // 根据商品条码,门店id,sku查找库存
|
|
|
- List<GoodsEntity> queryGoodsList = goodsDao.queryListByBarcode(prodBarcode, storeId,sku);
|
|
|
- if (queryGoodsList != null && queryGoodsList.size() != 0) {
|
|
|
- for (GoodsEntity goodsEntity : queryGoodsList) {
|
|
|
- // 如果当前还有需要购买的
|
|
|
- if (sellVolume > 0) {
|
|
|
- // 当前商品剩余的数量, 门店库存
|
|
|
- Integer remainAmount = Integer.parseInt(goodsEntity.getStockNum());
|
|
|
- if (sellVolume >= remainAmount) {
|
|
|
- // 证明该sku库存不足,需要继续向下个sku消费
|
|
|
- sellVolume -= remainAmount;
|
|
|
- // 记录该商品用了多少个数量
|
|
|
- numberMap.put(goodsEntity, remainAmount);
|
|
|
- } else {
|
|
|
- // 记录该商品用了多少个数量
|
|
|
- numberMap.put(goodsEntity, sellVolume);
|
|
|
- sellVolume = 0;
|
|
|
- }
|
|
|
- }
|
|
|
+ Integer sellVolume = goodsDto.getSellVolume();
|
|
|
+ String prodBarcode = goodsDto.getProdBarcode();
|
|
|
+ String sku = goodsDto.getSku();
|
|
|
+ Integer goodsNumber = goodsDto.getGoodsNumber();
|
|
|
+ // 仓库库存可用库存数
|
|
|
+ Integer warehouseStock = stockMap.get(sku);
|
|
|
+
|
|
|
+ // 判断库存
|
|
|
+ if (stockMap.containsKey(sku)) {
|
|
|
+ // 当前出区数
|
|
|
+ Integer exitRegionNumber = goodsDto.getExitRegionNumber();
|
|
|
+ // 保税仓库存 + 门店库存 - 出区数 >= 购买数
|
|
|
+ if (!((warehouseStock + goodsNumber) - exitRegionNumber >= sellVolume)) {
|
|
|
+ // 库存不足
|
|
|
+ LOGGER.error("sku:【{}】库存不足,门店可用库存:【{}】,仓库可用库存:【{}】,购买数量:【{}】", sku, goodsNumber, warehouseStock, sellVolume);
|
|
|
+ throw new ServiceException(String.format("sku:【%s】库存不足,门店可用库存:【%s】,仓库可用库存:【%s】,购买数量:【%s】", sku, goodsNumber, warehouseStock, sellVolume));
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- // 园区库存是有问题的, 这里去掉校验极端情况下可能会导致园区库存为负数
|
|
|
-// if (sellVolume > 0) {
|
|
|
-// resultObj.put("errno", 400);
|
|
|
-// resultObj.put("errmsg", "订单提交失败:条形码:" + prodBarcode + ",电商门店库存不足");
|
|
|
-// return resultObj;
|
|
|
-// }
|
|
|
-
|
|
|
- Iterator<GoodsEntity> goodsIterator = numberMap.keySet().iterator();
|
|
|
- // 循环购买的商品map,重新计算数量跟价格
|
|
|
- while (goodsIterator.hasNext()) {
|
|
|
- GoodsEntity goodsEntity = goodsIterator.next();
|
|
|
- // 该商品购买数量
|
|
|
- Integer num = numberMap.get(goodsEntity);
|
|
|
- // 取得规格的信息,判断规格库存,门店库存
|
|
|
- ProductStoreRelaEntity productInfo = productStoreRelaDao
|
|
|
- .queryByGoodsIdAndStoreId(Long.valueOf(storeId), Long.valueOf(goodsEntity.getId()));
|
|
|
- // 判断园区库存
|
|
|
- synchronized (productInfo) {
|
|
|
-// if (null == productInfo || null == productInfo.getStockNum() ||
|
|
|
-// productInfo.getStockNum() < (num)) {
|
|
|
-// resultObj.put("errno", 400);
|
|
|
-// resultObj.put("errmsg", "条形码:" + prodBarcode + ",电商门店库存不足,仅剩余" + productInfo.getStockNum());
|
|
|
-// return resultObj;
|
|
|
-// } else {
|
|
|
- // 判断销售价是否低于底线价
|
|
|
-// if(productInfo.getBottomLinePrice() != null){
|
|
|
-// BigDecimal bottomLinePrice = new BigDecimal(productInfo.getBottomLinePrice());
|
|
|
-// if (goodsEntity.getStoreRetailPrice().compareTo(bottomLinePrice) <= -1) {
|
|
|
-// LOGGER.error("销售价格小于底线价格");
|
|
|
-//
|
|
|
-// // 记录该信息,到价格过低日志表中,这里没有活动id
|
|
|
-// Mall2LowPriceWarningEntity lowPriceWarningEntity = new Mall2LowPriceWarningEntity();
|
|
|
-// lowPriceWarningEntity.setSalePrice(goodsEntity.getStoreRetailPrice());
|
|
|
-// lowPriceWarningEntity.setWarningPrice(bottomLinePrice);
|
|
|
-// lowPriceWarningEntity.setSku(goodsEntity.getGoodsSn());
|
|
|
-// lowPriceWarningEntity.setWarningType("00");
|
|
|
-// lowPriceWarningEntity.setStoreId(storeId+"");
|
|
|
-// lowPriceWarningEntity.setCreateTime(new Date());
|
|
|
-//
|
|
|
-// lowPriceWarningDao.save(lowPriceWarningEntity);
|
|
|
-// resultObj.put("errno", 400);
|
|
|
-// resultObj.put("errmsg", "商品"+goodsEntity.getName()+"的销售价格小于底线价格");
|
|
|
-// return resultObj;
|
|
|
-// }
|
|
|
-// }
|
|
|
- // 门店库存变化记录
|
|
|
- StoreMngChangeEntity storeMngChangeEntity = new StoreMngChangeEntity();
|
|
|
- storeMngChangeEntity.setChangeType(Dict.changeType.item_1.getItem());
|
|
|
- storeMngChangeEntity.setChangeReason("商品销售扣减");
|
|
|
- storeMngChangeEntity.setGoodsId(Integer.parseInt(String.valueOf(productInfo.getGoodsId())));
|
|
|
- storeMngChangeEntity.setStoreId(Integer.parseInt(String.valueOf(productInfo.getStoreId())));
|
|
|
- storeMngChangeEntity.setMerchSn(productInfo.getMerchSn());
|
|
|
- storeMngChangeEntity.setStoreChangeNum(num);
|
|
|
- storeMngChangeEntity.setStoreOriginalNum(productInfo.getStockNum());
|
|
|
- storeMngChangeEntity.setStoreValidNum(productInfo.getStockNum() - num);
|
|
|
- storeMngChangeEntity.setCreateTime(new Date());
|
|
|
- storeMngChangeEntity.setModTime(new Date());
|
|
|
- storeMngChangeEntity.setCreaterSn(user.getUsername());
|
|
|
- storeMngChangeEntity.setModerSn(user.getUsername());
|
|
|
- storeMngChangeEntity.setIsValid(0);
|
|
|
- storeMngChangeDao.save(storeMngChangeEntity);
|
|
|
-
|
|
|
- int validNum = productInfo.getStockNum() - num;
|
|
|
- if (goodsEntity != null) {
|
|
|
- MngChangeEntity mngChangeEntity = new MngChangeEntity();
|
|
|
- mngChangeEntity.setThirdPartyMerchCode(goodsEntity.getThirdPartyMerchCode());
|
|
|
- mngChangeEntity.setChangeReason("商品销售扣减");
|
|
|
- mngChangeEntity.setCreateTime(new Date());
|
|
|
- mngChangeEntity.setModTime(new Date());
|
|
|
- mngChangeEntity.setCreaterSn(user.getUsername());
|
|
|
- mngChangeEntity.setModerSn(user.getUsername());
|
|
|
- mngChangeEntity.setIsValid(0);
|
|
|
- mngChangeEntity.setMerchSn(goodsEntity.getMerchSn());
|
|
|
- mngChangeEntity.setOriginalNum(goodsEntity.getGoodsNumber());//原库存数
|
|
|
- mngChangeEntity.setValidNum(goodsEntity.getGoodsNumber() - num);//可用数
|
|
|
- mngChangeEntity.setChangeNum(num);//变化数
|
|
|
- mngChangeEntity.setChangeType(Dict.changeType.item_1.getItem());
|
|
|
- mngChangeEntity.setGoodsId(Integer.parseInt(String.valueOf(goodsEntity.getId())));
|
|
|
-
|
|
|
- mngChangeDao.save(mngChangeEntity);
|
|
|
-
|
|
|
- // 如果园区库存数量小于等于0, 则不更新园区库存, 园区库存只做参考
|
|
|
- int diff = Math.max(goodsEntity.getGoodsNumber() - num, 0);
|
|
|
- goodsEntity.setGoodsNumber(diff);
|
|
|
- goodsEntity.setLastSaleTime(new Date());
|
|
|
- goodsDao.update(goodsEntity);
|
|
|
- }
|
|
|
- // 门店库存
|
|
|
- productInfo.setStockNum(validNum);
|
|
|
- productInfo.setStoreId(Long.valueOf(storeId));
|
|
|
- productInfo.setSellVolume(productInfo.getSellVolume() + num);
|
|
|
- productInfo.setLastSaleTime(new Date());
|
|
|
- productStoreRelaDao.updateStockNum(productInfo);//修改普通商品库存
|
|
|
- }
|
|
|
-
|
|
|
- BigDecimal retailPrice = new BigDecimal(0);
|
|
|
- BigDecimal storeRetailPrice = new BigDecimal(0);
|
|
|
- if (goodsDto.get("retailPrice") instanceof Double) {
|
|
|
-
|
|
|
- retailPrice = new BigDecimal((Double) goodsDto.get("retailPrice")); // 单价
|
|
|
- storeRetailPrice = new BigDecimal((Double) goodsDto.get("retailPrice")); // 单价
|
|
|
- } else if (goodsDto.get("retailPrice") instanceof Integer) {
|
|
|
- retailPrice = new BigDecimal((Integer) goodsDto.get("retailPrice"));
|
|
|
- storeRetailPrice = new BigDecimal((Integer) goodsDto.get("retailPrice"));
|
|
|
- } else if (goodsDto.get("retailPrice") instanceof Float) {
|
|
|
- retailPrice = new BigDecimal((Float) goodsDto.get("retailPrice"));
|
|
|
- storeRetailPrice = new BigDecimal((Float) goodsDto.get("retailPrice"));
|
|
|
- }
|
|
|
-
|
|
|
+ // 门店库存变化记录
|
|
|
+ StoreMngChangeEntity storeMngChangeEntity = new StoreMngChangeEntity();
|
|
|
+ storeMngChangeEntity.setChangeType(Dict.changeType.item_1.getItem());
|
|
|
+ storeMngChangeEntity.setChangeReason("商品销售扣减");
|
|
|
+ storeMngChangeEntity.setGoodsId(goodsDto.getId().intValue());
|
|
|
+ storeMngChangeEntity.setStoreId(Integer.parseInt(String.valueOf(goodsDto.getStoreId())));
|
|
|
+ storeMngChangeEntity.setMerchSn(goodsDto.getMerchSn());
|
|
|
+ storeMngChangeEntity.setStoreChangeNum(sellVolume);
|
|
|
+ storeMngChangeEntity.setStoreOriginalNum(goodsDto.getStockNum());
|
|
|
+ storeMngChangeEntity.setStoreValidNum(goodsDto.getStockNum() - sellVolume);
|
|
|
+ storeMngChangeEntity.setCreateTime(new Date());
|
|
|
+ storeMngChangeEntity.setModTime(new Date());
|
|
|
+ storeMngChangeEntity.setCreaterSn(user.getUsername());
|
|
|
+ storeMngChangeEntity.setModerSn(user.getUsername());
|
|
|
+ storeMngChangeEntity.setIsValid(0);
|
|
|
+ storeMngChangeDao.save(storeMngChangeEntity);
|
|
|
+
|
|
|
+ int validNum = goodsDto.getStockNum() - sellVolume;
|
|
|
+ // 园区库存变化记录
|
|
|
+ MngChangeEntity mngChangeEntity = new MngChangeEntity();
|
|
|
+ mngChangeEntity.setThirdPartyMerchCode(goodsDto.getThirdPartyMerchCode());
|
|
|
+ mngChangeEntity.setChangeReason("商品销售扣减");
|
|
|
+ mngChangeEntity.setCreateTime(new Date());
|
|
|
+ mngChangeEntity.setModTime(new Date());
|
|
|
+ mngChangeEntity.setCreaterSn(user.getUsername());
|
|
|
+ mngChangeEntity.setModerSn(user.getUsername());
|
|
|
+ mngChangeEntity.setIsValid(0);
|
|
|
+ mngChangeEntity.setMerchSn(goodsDto.getMerchSn());
|
|
|
+ mngChangeEntity.setOriginalNum(goodsNumber);//原库存数
|
|
|
+ mngChangeEntity.setValidNum(goodsNumber - sellVolume);//可用数
|
|
|
+ mngChangeEntity.setChangeNum(sellVolume);//变化数
|
|
|
+ mngChangeEntity.setChangeType(Dict.changeType.item_1.getItem());
|
|
|
+ mngChangeEntity.setGoodsId(goodsDto.getId().intValue());
|
|
|
+
|
|
|
+ mngChangeDao.save(mngChangeEntity);
|
|
|
+
|
|
|
+ // 如果园区库存数量小于等于0, 则不更新园区库存, 园区库存只做参考
|
|
|
+ int diff = Math.max(goodsNumber - sellVolume, 0);
|
|
|
+ goodsDto.setGoodsNumber(diff);
|
|
|
+ goodsDto.setLastSaleTime(new Date());
|
|
|
+ GoodsEntity goodsEntity = new GoodsEntity(goodsDto);
|
|
|
+ goodsDao.update(goodsEntity);
|
|
|
+ // 门店库存
|
|
|
+ goodsDto.setStockNum(validNum);
|
|
|
+ goodsDto.setStoreId(storeId);
|
|
|
+ goodsDto.setSellVolume(goodsDto.getSellVolume() + sellVolume);
|
|
|
+ goodsDto.setLastSaleTime(new Date());
|
|
|
+ ProductStoreRelaEntity productStoreRelaEntity = new ProductStoreRelaEntity(goodsDto);
|
|
|
+ productStoreRelaDao.updateStockNum(productStoreRelaEntity);//修改普通商品库存
|
|
|
+
|
|
|
+ BigDecimal retailPrice = goodsDto.getRetailPrice(); // 单价
|
|
|
+ BigDecimal storeRetailPrice = goodsDto.getRetailPrice(); // 单价
|
|
|
// 优惠价
|
|
|
- BigDecimal disCountedPrice = new BigDecimal(0);
|
|
|
+ BigDecimal disCountedPrice = goodsDto.getDisCountedPrice();
|
|
|
// 实际支付价
|
|
|
- BigDecimal actualPaymentAmount = new BigDecimal(0);
|
|
|
-
|
|
|
- if (goodsDto.get("discountedPrice") instanceof Double) {
|
|
|
- disCountedPrice = new BigDecimal((Double) goodsDto.get("discountedPrice")); // 优惠金额
|
|
|
- } else if (goodsDto.get("discountedPrice") instanceof Integer) {
|
|
|
- disCountedPrice = new BigDecimal((Integer) goodsDto.get("discountedPrice"));
|
|
|
- } else if (goodsDto.get("discountedPrice") instanceof Float) {
|
|
|
- disCountedPrice = new BigDecimal((Float) goodsDto.get("discountedPrice"));
|
|
|
- }
|
|
|
- if (goodsDto.get("actualPaymentAmount") instanceof Double) {
|
|
|
- actualPaymentAmount = new BigDecimal((Double) goodsDto.get("actualPaymentAmount")); // 实际支付价格
|
|
|
- } else if (goodsDto.get("actualPaymentAmount") instanceof Integer) {
|
|
|
- actualPaymentAmount = new BigDecimal((Integer) goodsDto.get("actualPaymentAmount"));
|
|
|
- } else if (goodsDto.get("actualPaymentAmount") instanceof Float) {
|
|
|
- actualPaymentAmount = new BigDecimal((Float) goodsDto.get("actualPaymentAmount"));
|
|
|
- }
|
|
|
+ BigDecimal actualPaymentAmount = goodsDto.getTotalPrice();
|
|
|
+
|
|
|
disCountedPrice = disCountedPrice
|
|
|
- .divide(new BigDecimal(goodsSellNumber), 3, RoundingMode.HALF_UP)
|
|
|
- .multiply(new BigDecimal(num))
|
|
|
+ .divide(new BigDecimal(sellVolume), 3, RoundingMode.HALF_UP)
|
|
|
+ .multiply(new BigDecimal(sellVolume))
|
|
|
.setScale(2, RoundingMode.HALF_UP);
|
|
|
actualPaymentAmount = actualPaymentAmount
|
|
|
- .divide(new BigDecimal(goodsSellNumber), 3, RoundingMode.HALF_UP)
|
|
|
- .multiply(new BigDecimal(num))
|
|
|
+ .divide(new BigDecimal(sellVolume), 3, RoundingMode.HALF_UP)
|
|
|
+ .multiply(new BigDecimal(sellVolume))
|
|
|
.setScale(2, RoundingMode.HALF_UP);
|
|
|
|
|
|
-
|
|
|
- goodsEntity.setRetailPrice(retailPrice);
|
|
|
- goodsEntity.setStoreRetailPrice(storeRetailPrice);
|
|
|
- goodsEntity.setDiscountedPrice(disCountedPrice);
|
|
|
- goodsEntity.setActualPaymentAmount(actualPaymentAmount);
|
|
|
+ goodsDto.setRetailPrice(retailPrice);
|
|
|
+ goodsDto.setStoreRetailPrice(storeRetailPrice);
|
|
|
+ goodsDto.setDisCountedPrice(disCountedPrice);
|
|
|
+ goodsDto.setTotalPrice(actualPaymentAmount);
|
|
|
|
|
|
// 借用这个字段来存储购买数
|
|
|
- goodsEntity.setGoodsNumber(num);
|
|
|
- goodsEntity.setActivity((String) goodsDto.get("activity"));
|
|
|
+ goodsDto.setGoodsNumber(sellVolume);
|
|
|
+ goodsDto.setActivity(goodsDto.getActivity());
|
|
|
+ goodsEntity = new GoodsEntity(goodsDto);
|
|
|
goodsEntities.add(goodsEntity);
|
|
|
+ } else {
|
|
|
+ // sku不存在
|
|
|
+ LOGGER.error("库存系统中不包含此sku:【{}】,校验库存出错!下单失败!", sku);
|
|
|
+ throw new ServiceException(String.format("库存系统中不包含此sku:【%s】,下单失败!", sku));
|
|
|
}
|
|
|
|
|
|
// 计算该购物车所需要的所有税费
|
|
|
- Object taxObject = goodsDto.get("goodstaxes");
|
|
|
- BigDecimal tax = new BigDecimal(0);
|
|
|
- if (taxObject instanceof Double) {
|
|
|
- tax = new BigDecimal((Double) taxObject);
|
|
|
- } else if (taxObject instanceof Integer) {
|
|
|
- tax = new BigDecimal((Integer) taxObject);
|
|
|
- } else if (taxObject instanceof Float) {
|
|
|
- tax = new BigDecimal((Float) taxObject);
|
|
|
- } else if (taxObject instanceof String) {
|
|
|
- tax = new BigDecimal((String) taxObject);
|
|
|
- }
|
|
|
+ BigDecimal tax = goodsDto.getGoodsRate();
|
|
|
totalTax = totalTax.add(tax).setScale(2, BigDecimal.ROUND_HALF_DOWN); // 计算总的税额
|
|
|
}
|
|
|
|
|
@@ -2659,21 +2555,8 @@ public class OrderServiceImpl implements OrderService {
|
|
|
userDao.update(userEntity);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- // TODO 查询使用的优惠券,并减扣金额
|
|
|
- String couponSn = (String) userInfo.get("couponSn");
|
|
|
- // 获取当前时间
|
|
|
- String currentTime = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
|
|
- MkActivitiesCouponEntity couponEntity = mkActivitiesCouponService.queryByCouponSn(couponSn, currentTime);
|
|
|
-// // 优惠金额
|
|
|
- BigDecimal disCountAmount = new BigDecimal(0);
|
|
|
- if (couponEntity != null) {
|
|
|
- disCountAmount = couponEntity.getCouponPrice();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
// 判断该用户是否是生日
|
|
|
- Boolean isBirth = false;
|
|
|
+ /*Boolean isBirth = false;
|
|
|
String birthday = "";
|
|
|
if (userEntity.getIdNo().length() == 15) {
|
|
|
birthday = userEntity.getIdNo().substring(8, 10) + "-" + userEntity.getIdNo().substring(10, 12);
|
|
@@ -2685,27 +2568,19 @@ public class OrderServiceImpl implements OrderService {
|
|
|
String today = format.format(new Date());
|
|
|
if (birthday.equalsIgnoreCase(today)) {
|
|
|
isBirth = true;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
+ }*/
|
|
|
// 生成订单
|
|
|
String merchOrderSn = "EMATO" + CommonUtil.generateOrderNumber();
|
|
|
|
|
|
- OrderVo order = setOrderVo(goodsEntities, userEntity, storeId.longValue(), user.getMerchSn(), disCountAmount, totalTax, status, mapAddr);
|
|
|
+ // OrderVo order = setOrderVo(goodsEntities, userEntity, storeId.longValue(), user.getMerchSn(), disCountAmount, totalTax, status, mapAddr);
|
|
|
+ OrderVo order = setOrderVo(goodsEntities, userEntity, storeId.longValue(), user.getMerchSn(), totalTax, status, mapAddr);
|
|
|
order.setStore_id(storeId.longValue());
|
|
|
-// if(storeTopic != null){
|
|
|
-// order.setActivity_id(storeTopic.getId().longValue());
|
|
|
-// }
|
|
|
+ String couponSn = (String) userInfo.get("couponSn");
|
|
|
order.setMerchOrderSn(merchOrderSn);
|
|
|
order.setCoupon_name(couponSn); // 借用这个字段来记录是否使用优惠券
|
|
|
//插入订单信息和订单商品
|
|
|
orderDao.saveOrderVo(order);
|
|
|
|
|
|
-
|
|
|
- // TODO req_2021-07-19 电商端下单时间 req_20210826_001
|
|
|
- customsClearanceTimeliness.send(Arrays.asList(order.getOrder_sn()), "customerOrder");
|
|
|
-
|
|
|
-
|
|
|
// TODO 订单流转表
|
|
|
OrderProcessRecordEntity processRecordEntity = new OrderProcessRecordEntity();
|
|
|
processRecordEntity.setOrderSn(order.getOrder_sn());
|
|
@@ -2721,15 +2596,10 @@ public class OrderServiceImpl implements OrderService {
|
|
|
return resultObj;
|
|
|
}
|
|
|
|
|
|
- List<OrderGoodsVo> orderGoodsVoList = new ArrayList<>();
|
|
|
+ List<OrderGoodsVo> orderGoodsVoList = goodsEntities.stream().map(goodsEntity -> setOrderGoodsVo(order, goodsEntity)).collect(Collectors.toList());
|
|
|
+ // 批量保存订单详情
|
|
|
+ orderGoodsService.saveBatchOrderDetail(orderGoodsVoList);
|
|
|
|
|
|
- for (GoodsEntity goodsDto : goodsEntities) {
|
|
|
-
|
|
|
- OrderGoodsVo orderGoodsVo = setOrderGoodsVo(order, goodsDto);
|
|
|
- //新增订单详情
|
|
|
- orderGoodsDao.saveOrderGoodsVo(orderGoodsVo);
|
|
|
- orderGoodsVoList.add(orderGoodsVo);
|
|
|
- }
|
|
|
//清空预订单商品临时表
|
|
|
Map orderInfoMap = Maps.newHashMap();
|
|
|
orderInfoMap.put("orderInfo", order);
|
|
@@ -2744,10 +2614,6 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
|
StoreEntity store = storeService.queryObject(order.getStore_id().intValue());
|
|
|
|
|
|
- // 设置支付单开始时间
|
|
|
- // TODO req_2021-07-19 顾客付款时间 req_20210826_001
|
|
|
- customsClearanceTimeliness.send(Arrays.asList(order.getOrder_sn()), "customerPay");
|
|
|
-
|
|
|
processRecordEntity.setPaymentStartTime(new Date());
|
|
|
// 判断是微信的支付码还是支付宝的支付码
|
|
|
// if (parCode.startsWith("28")) {
|
|
@@ -2755,7 +2621,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
// try {
|
|
|
// AliPay(user, parCode, order, processRecordEntity, orderWXPayRecordCurrent, store);
|
|
|
// } catch (Exception e) {
|
|
|
-// e.printStackTrace();
|
|
|
+// LOGGER.error("支付宝支付出现异常!订单号:【{}】", order.getOrder_sn(), e);
|
|
|
// throw e;
|
|
|
// }
|
|
|
// } else {
|
|
@@ -2767,8 +2633,6 @@ public class OrderServiceImpl implements OrderService {
|
|
|
// throw e;
|
|
|
// }
|
|
|
// }
|
|
|
- // TODO req_2021-07-19 客户付款完成时间 req_20210826_001
|
|
|
- customsClearanceTimeliness.send(Arrays.asList(order.getOrder_sn()), "customerPayFinished");
|
|
|
|
|
|
processRecordEntity.setPaymentStartTime(new Date());
|
|
|
|
|
@@ -2828,17 +2692,52 @@ public class OrderServiceImpl implements OrderService {
|
|
|
consumptionRecords.setUserId(userEntity.getId() + "");
|
|
|
consumptionRecords.setOrderSn(order.getOrder_sn());
|
|
|
consumptionRecords.setConsumptionTime(new Date());
|
|
|
- consumptionRecords.setShopSn(storeId + "");
|
|
|
- // TODO 判断是否有使用生日优惠
|
|
|
- if (isBirth) {
|
|
|
+ consumptionRecords.setShopSn(String.valueOf(storeId));
|
|
|
+ // 判断是否有使用生日优惠
|
|
|
+ /*if (isBirth) {
|
|
|
consumptionRecords.setIsUseBirthdayOffer("0"); // 使用生日优惠
|
|
|
} else {
|
|
|
consumptionRecords.setIsUseBirthdayOffer("1"); // 没使用生日优惠
|
|
|
- }
|
|
|
+ }*/
|
|
|
+ // 积分消费记录
|
|
|
+ int deductionScore = (Integer) param.get("deductionScore");
|
|
|
+ String memberCode = String.valueOf(param.get("memberCode"));
|
|
|
+ String memberPhone = String.valueOf(param.get("memberPhone"));
|
|
|
+ BigDecimal scoreDeductionPrice = new BigDecimal(String.valueOf(param.get("scoreDeductionPrice")));
|
|
|
+ Integer beforeScore = (Integer) param.get("beforeScore");
|
|
|
+ Integer afterScore = (Integer) param.get("afterScore");
|
|
|
+ consumptionRecords.setBeforeScore(beforeScore);
|
|
|
+ consumptionRecords.setAfterScore(afterScore);
|
|
|
+ consumptionRecords.setOrderTotalPrice(order.getActual_price());
|
|
|
+ consumptionRecords.setScoreDeductionPrice(scoreDeductionPrice);
|
|
|
+ consumptionRecords.setMemberCode(memberCode);
|
|
|
+ consumptionRecords.setMemberPhone(memberPhone);
|
|
|
+ consumptionRecords.setDeductionScore(deductionScore);
|
|
|
consumptionRecords.setCreaterSn(userId + "");
|
|
|
consumptionRecords.setCreateTime(new Date());
|
|
|
memberConsumptionRecordsDao.save(consumptionRecords);
|
|
|
|
|
|
+ // 同步会员订单消费记录
|
|
|
+ HaiKongMemberOrderSyncResendEntity haiKongMemberOrderSyncResendEntity = new HaiKongMemberOrderSyncResendEntity();
|
|
|
+ try {
|
|
|
+ MemberOrderInfoSyncDTO memberOrderInfoSyncDTO = new MemberOrderInfoSyncDTO();
|
|
|
+ memberOrderInfoSyncDTO.setPhone(memberPhone);
|
|
|
+ memberOrderInfoSyncDTO.setOrderNo(order.getOrder_sn());
|
|
|
+ memberOrderInfoSyncDTO.setConsumeDate(new Date());
|
|
|
+ memberOrderInfoSyncDTO.setOrderAmount(order.getActual_price());
|
|
|
+ memberOrderInfoSyncDTO.setOrderScore(deductionScore);
|
|
|
+ BeanUtils.copyProperties(memberOrderInfoSyncDTO, haiKongMemberOrderSyncResendEntity);
|
|
|
+ String body = JacksonUtil.toJson(memberOrderInfoSyncDTO);
|
|
|
+ LOGGER.info("请求会员系统同步消费订单接口!请求体:{}", body);
|
|
|
+ // 发送请求
|
|
|
+ String memberOrderSyncResponseJson = haiKongMemberTemplate.memberOrderSync(body);
|
|
|
+ LOGGER.info("请求会员系统同步消费订单接口成功!响应数据:{}", memberOrderSyncResponseJson);
|
|
|
+ } catch (Exception e) {
|
|
|
+ LOGGER.error("请求会员系统同步消费订单接口失败!准备新增发送失败记录,等待重发!异常信息:", e);
|
|
|
+ // TODO 没有请求成功,写表,重发
|
|
|
+ haiKongMemberOrderSyncResendEntity.setResendStatus(HaiKongMemberOrderResendStatusEnum.WAIT_RESEND.getStatus());
|
|
|
+ haiKongMemberOrderSyncResendService.save(haiKongMemberOrderSyncResendEntity);
|
|
|
+ }
|
|
|
|
|
|
// 生成取票码
|
|
|
PickUpCodeEntity pickUpCodeEntity = new PickUpCodeEntity();
|
|
@@ -2856,32 +2755,6 @@ public class OrderServiceImpl implements OrderService {
|
|
|
WebSocketServer.sendMessage(sessionId, order.getOrder_sn(), order.getStore_id()
|
|
|
+ "");
|
|
|
|
|
|
- // TODO 下单流程完成了,现在将下单的库存明细存入表中,准备发送到中控
|
|
|
-// List<KtoEccsEntity> ktoEccsEntities = new LinkedList<>();
|
|
|
-//// orderGoodsVoList
|
|
|
-// for (OrderGoodsVo orderGoodsVo : orderGoodsVoList) {
|
|
|
-// KtoEccsEntity ktoEccsEntity = new KtoEccsEntity();
|
|
|
-// ktoEccsEntity.setRequestData(JSON.toJSONString(orderGoodsVo));
|
|
|
-// ktoEccsEntity.setRequestType("03");
|
|
|
-// ktoEccsEntity.setSendStatus("00");
|
|
|
-// ktoEccsEntity.setCreaterSn(user.getUserId()+"");
|
|
|
-// ktoEccsEntity.setCreateTime(new Date());
|
|
|
-// ktoEccsEntities.add(ktoEccsEntity);
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// if(ktoEccsEntities.size() > 0){
|
|
|
-// if(ktoEccsEntities.size() > 50){
|
|
|
-// List<List<KtoEccsEntity>> partition = Lists.partition(ktoEccsEntities, 50);
|
|
|
-// for (List<KtoEccsEntity> ktoEccs : partition) {
|
|
|
-// ktoEccsService.saveBatch(ktoEccs);
|
|
|
-// }
|
|
|
-// }else{
|
|
|
-// ktoEccsService.saveBatch(ktoEccsEntities);
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
return resultObj;
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
@@ -2891,99 +2764,6 @@ public class OrderServiceImpl implements OrderService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// private BigDecimal getDisCountAmout(List<GoodsEntity> goodsEntities) {
|
|
|
-// BigDecimal disCountAmount;
|
|
|
-// // TODO 生成订单之前,先查询是否有优惠券或者满减
|
|
|
-// // TODO 20200610 要修改成全部商品
|
|
|
-// // 优惠券的集合
|
|
|
-// List<MkStoreTicketDiscountEntity> mkStoreTicketDiscountEntities = new ArrayList<>();
|
|
|
-// // 满减的集合
|
|
|
-// List<MkStoreCampMinusLevelEntity> mkStoreCampMinusEntities = new ArrayList<>();
|
|
|
-// // 存商品跟金额的关系
|
|
|
-// Map<Long,BigDecimal> moneyMap = new HashMap<>();
|
|
|
-// // 商品总价
|
|
|
-// BigDecimal totalPrice = new BigDecimal(0);
|
|
|
-//
|
|
|
-// for(GoodsEntity goodsEntity : goodsEntities){
|
|
|
-// Long goodsId = goodsEntity.getId();
|
|
|
-// // 计算该商品的价格
|
|
|
-// BigDecimal goodsPrice = goodsEntity.getStoreRetailPrice().multiply(new BigDecimal(goodsEntity.getGoodsNumber())).setScale(2, RoundingMode.HALF_UP);
|
|
|
-// moneyMap.put(goodsId,goodsPrice);
|
|
|
-// totalPrice = totalPrice.add(goodsPrice);
|
|
|
-// // 查询该商品id是否有优惠券
|
|
|
-// List<MkStoreTicketDiscountEntity> mkStoreTicketDiscountEntity = mkStoreTicketDiscountService.queryByGoodsId(goodsId);
|
|
|
-// if(mkStoreTicketDiscountEntity != null) {
|
|
|
-// mkStoreTicketDiscountEntities.addAll(mkStoreTicketDiscountEntity);
|
|
|
-// }
|
|
|
-// // 查询该商品id是否有满减
|
|
|
-// List<MkStoreCampMinusLevelEntity> mkStoreCampMinusEntity = mkStoreCampMinusService.queryByGoodsId(goodsId);
|
|
|
-// if(mkStoreCampMinusEntity != null) {
|
|
|
-// mkStoreCampMinusEntities.addAll(mkStoreCampMinusEntity);
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 满减优惠的金额
|
|
|
-// BigDecimal campDisCountAmount = new BigDecimal(0);
|
|
|
-// if(mkStoreCampMinusEntities.size() > 0){
|
|
|
-// // 上一次所需金额,用于取最大的优惠力度
|
|
|
-// BigDecimal lastAmount = new BigDecimal(0);
|
|
|
-// for (int i = 0 ; i < mkStoreCampMinusEntities.size() ; i++){
|
|
|
-// MkStoreCampMinusLevelEntity mkStoreCampMinusLevelEntity = mkStoreCampMinusEntities.get(i);
|
|
|
-// // TODO 20200610还有满多少件,跟满多少元打折的,逻辑复杂,下次开发
|
|
|
-// BigDecimal discCond = mkStoreCampMinusLevelEntity.getYuanMinusCond();
|
|
|
-// // 判断这次金额是否大于上次金额,如果不大于,直接continue
|
|
|
-// if(discCond.compareTo(lastAmount) > 0){
|
|
|
-// // 如果总金额大于所需金额,则可以使用该优惠券,记录该优惠券的角标,金额跟优惠的钱
|
|
|
-// if(totalPrice.compareTo(discCond) > 0){
|
|
|
-// // 记录上一次金额
|
|
|
-// lastAmount = discCond;
|
|
|
-// campDisCountAmount = mkStoreCampMinusLevelEntity.getYuanMinusPref();
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 优惠券优惠的金额
|
|
|
-// BigDecimal ticketDisCountAmount = new BigDecimal(0);
|
|
|
-// if(mkStoreTicketDiscountEntities.size() > 0){
|
|
|
-// // 上一次所需金额,用于取最大的优惠力度
|
|
|
-// BigDecimal lastAmount = new BigDecimal(0);
|
|
|
-// BigDecimal lastRadio = new BigDecimal(0);
|
|
|
-// for (int i = 0 ; i < mkStoreTicketDiscountEntities.size() ; i++){
|
|
|
-// MkStoreTicketDiscountEntity mkStoreTicketDiscountEntity = mkStoreTicketDiscountEntities.get(i);
|
|
|
-// // 代金券所需金额
|
|
|
-// // TODO 20200610还有折扣券的,逻辑较为复杂,下次在开发
|
|
|
-//
|
|
|
-// if("00".equals(mkStoreTicketDiscountEntity.getApplyType())){
|
|
|
-// BigDecimal discCond = mkStoreTicketDiscountEntity.getVoucherCond();
|
|
|
-// // 判断这次金额是否大于上次金额,如果不大于,直接continue
|
|
|
-// if(discCond.compareTo(lastAmount) > 0){
|
|
|
-// // 如果总金额大于所需金额,则可以使用该优惠券,记录该优惠券的角标,金额跟优惠的钱
|
|
|
-// if(totalPrice.compareTo(discCond) > 0){
|
|
|
-// // 记录上一次金额
|
|
|
-// lastAmount = discCond;
|
|
|
-// ticketDisCountAmount = mkStoreTicketDiscountEntity.getVoucherMoney();
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }else if("01".equals(mkStoreTicketDiscountEntity.getApplyType())){
|
|
|
-// BigDecimal discCond = mkStoreTicketDiscountEntity.getDiscCond();
|
|
|
-// if(totalPrice.compareTo(discCond) > 0){
|
|
|
-// // 打的折扣
|
|
|
-// lastRadio = mkStoreTicketDiscountEntity.getDiscRatio();
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-// disCountAmount = ticketDisCountAmount.compareTo(campDisCountAmount) > 0 ? ticketDisCountAmount : campDisCountAmount;
|
|
|
-// return disCountAmount;
|
|
|
-// }
|
|
|
-
|
|
|
private void AliPay(SysUserEntity user, String parCode, OrderVo order, OrderProcessRecordEntity processRecordEntity, OrderWXPayRecordEntity orderWXPayRecordCurrent, StoreEntity store) throws Exception {
|
|
|
|
|
|
AliPayRequestParams params = new AliPayRequestParams();
|
|
@@ -4029,6 +3809,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
CalculateOrderDiscountPriceResponseVO calculateOrderDiscountPriceResponseVO = new CalculateOrderDiscountPriceResponseVO();
|
|
|
String storeId = calculateOrderDiscountPriceVo.getStoreId();
|
|
|
String memberCode = calculateOrderDiscountPriceVo.getMemberCode();
|
|
|
+ calculateOrderDiscountPriceResponseVO.setMemberCode(memberCode);
|
|
|
List<GoodsDetailsDto> goodsDetailsDtos = calculateOrderDiscountPriceVo.getGoodsList();
|
|
|
BigDecimal orderTotalPrice = BigDecimal.ZERO;
|
|
|
List<QueryGoodsVO> goodsVos = new ArrayList<>();
|
|
@@ -4349,10 +4130,11 @@ public class OrderServiceImpl implements OrderService {
|
|
|
Integer score = memberInfoDTO.getScore();
|
|
|
if (Objects.nonNull(score) && score > 0) {
|
|
|
// 有积分
|
|
|
- afterDiscountPrice = calculatePreferentialPrice(orderTotalPrice, score, storeId, memberCode);
|
|
|
+ afterDiscountPrice = calculatePreferentialPrice(orderTotalPrice, score, storeId, memberCode, calculateOrderDiscountPriceResponseVO);
|
|
|
LOGGER.info("会员【{}】,当前积分:{},积分抵扣后的订单金额:{},积分抵扣前的订单金额:{}", memberCode, score, afterDiscountPrice, orderTotalPrice);
|
|
|
calculateOrderDiscountPriceResponseVO.setOrderTotalPrice(afterDiscountPrice);
|
|
|
calculateOrderDiscountPriceResponseVO.setGoodsDetailsDtos(goodsDetailsDtos);
|
|
|
+ calculateOrderDiscountPriceResponseVO.setBeforeScore(score);
|
|
|
// 订单完成后再添加积分消费记录,以及同步积分信息
|
|
|
return calculateOrderDiscountPriceResponseVO;
|
|
|
} else {
|
|
@@ -4381,7 +4163,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
* @param memberCode 会员码
|
|
|
* @return 积分抵扣后的订单总金额
|
|
|
*/
|
|
|
- private BigDecimal calculatePreferentialPrice(BigDecimal orderTotalPrice, Integer score, String storeId, String memberCode) {
|
|
|
+ private BigDecimal calculatePreferentialPrice(BigDecimal orderTotalPrice, Integer score, String storeId, String memberCode, CalculateOrderDiscountPriceResponseVO calculateOrderDiscountPriceResponseVO) {
|
|
|
// 1. 判断是否有积分,是否需要计算积分抵扣后的价格
|
|
|
AtomicBoolean isCalculateScorePrice = new AtomicBoolean(false);
|
|
|
if (Objects.nonNull(score) && score > 0) {
|
|
@@ -4405,7 +4187,13 @@ public class OrderServiceImpl implements OrderService {
|
|
|
scoreMayDeductionPriceDecimal = halfPrice;
|
|
|
}
|
|
|
orderTotalPrice = orderTotalPrice.subtract(scoreMayDeductionPriceDecimal);
|
|
|
- LOGGER.info("会员【{}】,当前积分:{},抵扣订单金额后剩余积分:{}", memberCode, score, (score - scoreMayDeductionPriceDecimal.multiply(new BigDecimal(scoreLimit)).intValue()));
|
|
|
+ int afterScore = score - scoreMayDeductionPriceDecimal.multiply(new BigDecimal(scoreLimit)).intValue();
|
|
|
+ calculateOrderDiscountPriceResponseVO.setAfterScore(afterScore);
|
|
|
+ calculateOrderDiscountPriceResponseVO.setScoreLimit(scoreLimit);
|
|
|
+ calculateOrderDiscountPriceResponseVO.setDeductionScore(score - afterScore);
|
|
|
+ calculateOrderDiscountPriceResponseVO.setOrderTotalPrice(orderTotalPrice);
|
|
|
+ calculateOrderDiscountPriceResponseVO.setScoreDeductionPrice(scoreMayDeductionPriceDecimal);
|
|
|
+ LOGGER.info("会员【{}】,当前积分:{},抵扣订单金额后剩余积分:{}", memberCode, score, afterScore);
|
|
|
}
|
|
|
} else {
|
|
|
LOGGER.info("会员【{}】的积分为0,不参加积分抵扣!", memberCode);
|
|
@@ -4547,12 +4335,12 @@ public class OrderServiceImpl implements OrderService {
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- public OrderVo setOrderVo(List<GoodsEntity> goodsList, UserEntity loginUser, Long storeId, String merchSn, BigDecimal disCountAmount, BigDecimal totalTax, int status, Map mapAddr) {
|
|
|
+ public OrderVo setOrderVo(List<GoodsEntity> goodsList, UserEntity loginUser, Long storeId, String merchSn, BigDecimal totalTax, int status, Map mapAddr) {
|
|
|
OrderVo orderInfo = new OrderVo();
|
|
|
|
|
|
- BigDecimal goodsTotalPrice = new BigDecimal(0.00);
|
|
|
+ BigDecimal goodsTotalPrice = BigDecimal.ZERO;
|
|
|
BigDecimal fullCutCouponDec = Constant.ZERO; // 非现金抵扣 = 各种优惠价格 +优惠券的价格 暂时借用这个字段去,为了不改动ccnet系统
|
|
|
- BigDecimal couponPrice = disCountAmount;
|
|
|
+ BigDecimal couponPrice = BigDecimal.ZERO;
|
|
|
BigDecimal freightPrice = Constant.ZERO;
|
|
|
BigDecimal actualPrice = Constant.ZERO;
|
|
|
//订单价格计算:订单的总价+运费
|
|
@@ -4563,7 +4351,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
.add(goodsEntity.getDiscountedPrice()).setScale(2, RoundingMode.HALF_UP);
|
|
|
actualPrice = actualPrice
|
|
|
.add(goodsEntity.getActualPaymentAmount()).setScale(2, RoundingMode.HALF_UP);
|
|
|
-
|
|
|
+ couponPrice = couponPrice.add(goodsEntity.getDiscountedPrice()).setScale(2, RoundingMode.HALF_UP);
|
|
|
}
|
|
|
|
|
|
|