From f7d7da8cf5c3f310d2aac143523dae3000d2b395 Mon Sep 17 00:00:00 2001
From: 935090232@qq.com <ak473600000>
Date: Tue, 08 Mar 2022 00:27:56 +0800
Subject: [PATCH] refactor:重构商品限制销售检测
---
zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java | 54 +++++++++++++++++++-----------------------------------
1 files changed, 19 insertions(+), 35 deletions(-)
diff --git a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java
index 8660274..2619287 100644
--- a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java
+++ b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java
@@ -1,6 +1,8 @@
package com.matrix.system.hive.service.imp;
+import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
+import com.google.common.collect.Lists;
import com.matrix.component.asyncmessage.AsyncMessageManager;
import com.matrix.core.constance.MatrixConstance;
import com.matrix.core.exception.GlobleException;
@@ -26,6 +28,8 @@
import com.matrix.system.enums.OperationFunctionEnum;
import com.matrix.system.hive.bean.*;
import com.matrix.system.hive.dao.*;
+import com.matrix.system.hive.dto.GoodsSealLimitDto;
+import com.matrix.system.hive.dto.OrderItemDto;
import com.matrix.system.hive.plugin.util.CollectionUtils;
import com.matrix.system.hive.plugin.util.MoneyUtil;
import com.matrix.system.hive.pojo.CzXkVo;
@@ -553,6 +557,8 @@
addVipScore(pageOrder);
+
+
}
/**
@@ -601,11 +607,22 @@
}
private void checkOrder(SysOrder pageOrder) {
- //检查交易限制调整
- checkSealLimit(pageOrder);
+ //检查交易限制调整 jyytodo 测试一下
+ GoodsSealLimitDto goodsSealLimitDto = new GoodsSealLimitDto();
+ goodsSealLimitDto.setVipId(pageOrder.getVipId());
+ goodsSealLimitDto.setOrderItemDtoList(Lists.newArrayList());
+ pageOrder.getItems().forEach(e->{
+ goodsSealLimitDto.getOrderItemDtoList().add(BeanUtil.copyProperties(e, OrderItemDto.class));
+ });
+ shoppingGoodsService.checkGoodsSealLimit(goodsSealLimitDto);
+
//检查业绩设置
checkOrderAchieve(pageOrder);
}
+
+
+
+
/**
* 检查业绩设置是否合理
@@ -638,40 +655,7 @@
}
- /**
- * 检查产品销售次数
- */
- private void checkSealLimit(SysOrder pageOrder) {
- pageOrder.getItems().forEach(item -> {
- ShoppingGoods shopGoods = shoppingGoodsDao.selectById(item.getGoodsId());
- //最大销售次数检测
- Integer maxNum = shopGoods.getCarMaxSaleCount();
- if (maxNum != null && maxNum != 0) {
- Integer buyNum = orderItemDao.selectByGoodsId(shopGoods.getId(), null);
- if ((buyNum + item.getCount()) > maxNum) {
- throw new GlobleException(shopGoods.getName() + "已超过最大销售数量");
- }
- if ((buyNum + item.getCount()) == maxNum) {
- if (!shopGoods.getStaus().equals(Dictionary.BUSINESS_STATE_DOWN)) {
- shopGoods.setStaus(Dictionary.BUSINESS_STATE_DOWN);
- shoppingGoodsDao.update(shopGoods);
- }
- }
- }
- //每人限购次数检测
- Integer onceCount = shopGoods.getIsOnce();
- if (onceCount != null && onceCount != 0) {
- Integer buyOnceCount = orderItemDao.selectByGoodsId(shopGoods.getId(), pageOrder.getVipId());
-
- if ((buyOnceCount + item.getCount()) > onceCount) {
- throw new GlobleException(shopGoods.getName() + "每人限购" + onceCount + "次");
- }
- }
-
- });
-
- }
/**
--
Gitblit v1.9.1