From 28cfa033f4c9e7e8639d9acb8f3c75688a3e539d Mon Sep 17 00:00:00 2001 From: jyy <jyy> Date: Mon, 02 Aug 2021 16:37:59 +0800 Subject: [PATCH] 优化需求 --- zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java | 125 +++++++++++++++++++++++++---------------- 1 files changed, 76 insertions(+), 49 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..2b11597 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 @@ -401,8 +401,6 @@ //获取折扣----- Double zk = zk = 1.0; - //验证商品是否只购买了一次 - checkBuyOnce(car, info.getId()); SysOrder order = new SysOrder(); SysUsers user = (SysUsers) WebUtil.getSession().getAttribute(MatrixConstance.LOGIN_KEY); @@ -433,8 +431,7 @@ int count = 0; // 设置订单条目 for (ShoppingCarItem carItem : car.getCarItems()) { - // 检测最大销售数量 - checkIsArrivedMax(carItem); + SysOrderItem orderItem = new SysOrderItem(); orderItem.setOrderId(order.getId()); orderItem.setCount(carItem.getCount()); @@ -472,20 +469,6 @@ } - /** - * 验证商品是否购买过一次 - * - * @Title: checkBuyOnce @author:jyy @param car void 返回类型 @date - * 2016年9月22日 上午10:05:33 @throws - */ - private void checkBuyOnce(ShoppingCarItemsVo car, Long vipId) { - for (ShoppingCarItem carItem : car.getCarItems()) { - if (shoppingGoodsDao.selectBuyCount(carItem.getGoodsId(), vipId) > 0) { - ShoppingGoods goods = shoppingGoodsDao.selectById(carItem.getGoodsId()); - throw new GlobleException(goods.getName() + "只能购买一次!"); - } - } - } /** * jyy 收款 @@ -498,9 +481,8 @@ throw new GlobleException("该订单已经收过款,请刷新页面再试!"); } - //交易业绩设置是否合理 - - checkAchieveIsOk(pageOrder); + //检查交易限制调整 + checkSealLimit(pageOrder); // 更新收款时间 @@ -539,26 +521,41 @@ } /** - * 交易业绩设置是否合理 - * @param pageOrder + * 检查产品销售次数 */ - private void checkAchieveIsOk(SysOrder pageOrder) { - double huakouSum = pageOrder.getItems().stream() - .mapToDouble( - item -> - item.getAchieveList().stream() - .filter(achieveNew -> "划扣".equals(achieveNew.getPayMethod())) - .mapToDouble(achieve -> achieve.getGoodsCash()).sum() - ).sum(); + private void checkSealLimit(SysOrder pageOrder) { + pageOrder.getItems().forEach(item->{ + ShoppingGoods shopGoods = shoppingGoodsDao.selectById(item.getGoodsId()); - double czkPay= pageOrder.getFlows().stream() - .filter(sysOrderFlow -> "储值卡".equals(sysOrderFlow.getPayMethod())) - .mapToDouble(sysOrderFlow ->sysOrderFlow.getAmount().doubleValue()).sum(); + //最大销售次数检测 + 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(czkPay!=huakouSum){ - throw new GlobleException("划扣业绩不等于储值卡扣款金额,请修改业绩设置!"); - } + if ((buyOnceCount + item.getCount()) > onceCount) { + throw new GlobleException(shopGoods.getName() + "每人限购"+onceCount+"次"); + } + } + + }); + } + + /** * 设置会员消费积分 @@ -780,7 +777,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() + "已超过最大销售数量"); @@ -944,7 +941,6 @@ moneyCardUse.setGiftMoney(moneyCar.getReferencePice()); moneyCardUse.setRealMoney(moneyCar.getSealPice()); moneyCardUse.setGoodsId(moneyCar.getId()); - moneyCardUse.setIsOver(Dictionary.FLAG_NO_N); moneyCardUse.setOrderItemId(sysOrderItem.getId()); moneyCardUse.setSource(Dictionary.TAOCAN_SOURCE_GM); moneyCardUse.setStatus(Dictionary.MONEYCARD_STATUS_YX); @@ -1243,11 +1239,20 @@ //赠送项目是否计算消耗业绩否则 赠送产品按原价计算消耗 boolean zsConsumeAchieve = projServicesService.skipServiceOrderStep(Dictionary.ZS_CONSUME_ACHIEVE); if(zsConsumeAchieve){ - if (taocanId == null) { - puse.setPrice(goodsAssemble.getShoppingGoods().getPrice() ); - } else { - puse.setPrice(goodsAssemble.getPrice()); + if(sysOrderItem.getPrice()>0){ + + + + + }else{ + //等于0取原价 + if (taocanId == null) { + puse.setPrice(goodsAssemble.getShoppingGoods().getPrice() ); + } else { + puse.setPrice(goodsAssemble.getPrice()); + } } + }else{ puse.setPrice(0D); } @@ -1287,7 +1292,7 @@ taocanProjUse.setIsCourse(taocanShoppingGoods.getIsCourse()); taocanProjUse.setIsInfinite(taocanShoppingGoods.getIsInfinite()); // 赠送和打折后金额为0的都视为赠送项目 - if (sysOrderItem.getIsFree().equals(Dictionary.FLAG_NO) && sysOrderItem.getZkPrice() > 0) { + if (sysOrderItem.getIsFree().equals(Dictionary.FLAG_NO) && sysOrderItem.getZkPrice() > 0 && !isGiftMoneyPay(order)) { taocanProjUse.setSource(Dictionary.TAOCAN_SOURCE_GM); } else { taocanProjUse.setSource(Dictionary.TAOCAN_SOURCE_ZS); @@ -1340,8 +1345,10 @@ puse.setProjName(sysOrderItem.getShoppingGoods().getName()); + + // 赠送和打折后金额为0的都视为赠送项目 - if (sysOrderItem.getIsFree().equals(Dictionary.FLAG_NO) && sysOrderItem.getZkPrice() > 0) { + if (sysOrderItem.getIsFree().equals(Dictionary.FLAG_NO) && sysOrderItem.getZkPrice() > 0 && !isGiftMoneyPay(order)) { puse.setSource(Dictionary.TAOCAN_SOURCE_GM); puse.setPrice(sysOrderItem.getZkPrice()); } else { @@ -1349,7 +1356,11 @@ //赠送项目是否计算消耗业绩否则 赠送产品按原价计算消耗 boolean zsConsumeAchieve = projServicesService.skipServiceOrderStep(Dictionary.ZS_CONSUME_ACHIEVE); if(zsConsumeAchieve){ - puse.setPrice(sysOrderItem.getShoppingGoods().getSealPice()); + if(sysOrderItem.getPrice()>0){ + puse.setPrice(sysOrderItem.getZkPrice()); + }else{ + puse.setPrice(sysOrderItem.getShoppingGoods().getSealPice()); + } }else{ puse.setPrice(0D); } @@ -1361,6 +1372,23 @@ puse.setFailTime(invalidTime); puse.setBalance(sysOrderItem.getShoppingGoods().getSealPice()*puse.getSurplusCount()); sysProjUseDao.insert(puse); + } + + /** + * 全是赠送金额,且配置了赠送金额购买计算为赠送 + * @param order + * @return + */ + private boolean isGiftMoneyPay(SysOrder order) { + BusParameterSettings giftiIsfree = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.SHOP_MANAGE_GIFTISFREE, order.getCompanyId()); + if(giftiIsfree.getParamValue().equals("是")){ + return order.getFlows().stream().allMatch(item -> SysOrderFlow.IS_GIFT_Y.equals(item.getIsGift()) + && item.getAmount().doubleValue() >0D); + }else{ + return false; + } + + } @@ -1512,7 +1540,7 @@ sourceOrder.setIsHasRefund(SysOrder.IS_HAS_REFUND_Y); // sourceOrder.setStatu(Dictionary.ORDER_STATU_TK); sysOrderDao.update(sourceOrder); - SysOrder oldOrder=sysOrderDao.selectById( sysOrder.getOldOrderId()); + SysOrder oldOrder=sysOrderDao.selectById(sysOrder.getOldOrderId()); sysOrder.setId(null); sysOrder.setStaffId(user.getSuId()); @@ -1685,7 +1713,7 @@ List<SysProjUse> sysProjUses = sysProjUseDao.selectByModel(queryProjUse); - for (int i = 0; i < item.getCount(); i++) { + for (int i = 0; i < sysProjUses.size(); i++) { SysProjUse sysProjUse = sysProjUses.get(i); sysProjUse.setIsOver(Dictionary.FLAG_YES_Y); @@ -1702,7 +1730,6 @@ if (Dictionary.SHOPPING_GOODS_TYPE_CZK.equals(item.getType())) { MoneyCardUse queryCardUse = new MoneyCardUse(); - queryCardUse.setIsOver(Dictionary.FLAG_NO_N); queryCardUse.setStatus(Dictionary.TAOCAN_STATUS_YX); queryCardUse.setOrderItemId(item.getOldItemId()); -- Gitblit v1.9.1