From 8287f743a1ac2fd5330f6dd7ca08255df193ae03 Mon Sep 17 00:00:00 2001
From: jyy <jyy>
Date: Fri, 09 Jul 2021 20:50:16 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/score_shop' into score_shop
---
zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java | 41 +++++++++++++++++++++++++++++++++++++++--
1 files changed, 39 insertions(+), 2 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 1e80f7f..0e85cd7 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
@@ -498,8 +498,10 @@
throw new GlobleException("该订单已经收过款,请刷新页面再试!");
}
- //交易业绩设置是否合理
+ //检查交易限制调整
+ checkSealLimit(pageOrder);
+ //交易业绩设置是否合理
checkAchieveIsOk(pageOrder);
@@ -535,6 +537,41 @@
//设置会员积分
addVipScore(pageOrder);
+
+ }
+
+ /**
+ * 检查产品销售次数
+ */
+ 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+"次");
+ }
+ }
+
+ });
}
@@ -780,7 +817,7 @@
// 最大发卡数量为0代表不做限制
if (maxNum != null && maxNum != 0) {
// 查询该商品已经被购买的次数
- Integer buyNum = orderItemDao.selectByGoodsId(shopGoods.getId());
+ Integer buyNum = orderItemDao.selectByGoodsId(shopGoods.getId(),null);
buyNum = (buyNum == null ? 0 : buyNum);
if ((buyNum + carItem.getCount()) > maxNum) {
throw new GlobleException(shopGoods.getName() + "已超过最大销售数量");
--
Gitblit v1.9.1