| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | addVipScore(pageOrder); |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | 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); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 检查业绩设置是否合理 |
| | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 检查产品销售次数 |
| | | */ |
| | | 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 + "次"); |
| | | } |
| | | } |
| | | |
| | | }); |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | |
| | | * @date 2016年9月19日 |
| | | */ |
| | | public void addMoneyCardUse(SysOrder sourceOrder) { |
| | | |
| | | SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); |
| | | List<SysOrderItem> orderItemList = sourceOrder.getItems(); |
| | | for (SysOrderItem sysOrderItem : orderItemList) { |
| | | // 如果购买的是充值卡 |
| | |
| | | moneyCardUse.setFailTime(invalidTime); |
| | | |
| | | moneyCardUseDao.insert(moneyCardUse); |
| | | |
| | | } |
| | | } |
| | | } |