| | |
| | | import com.matrix.system.hive.bean.SysShopInfo; |
| | | 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.dto.SysOrderItemDto; |
| | | import com.matrix.system.hive.service.ShoppingGoodsService; |
| | | import org.apache.commons.collections.CollectionUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | //校验参数不能为空 |
| | | checkGoodsSelLimtParam(goodsSealLimitDto); |
| | | |
| | | goodsSealLimitDto.getOrderItemDtoList().forEach(item -> { |
| | | goodsSealLimitDto.getSysOrderItemDtoList().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) { |
| | | if (buyNum.equals(maxNum)) { |
| | | if (!shopGoods.getStaus().equals(Dictionary.BUSINESS_STATE_DOWN)) { |
| | | shopGoods.setStaus(Dictionary.BUSINESS_STATE_DOWN); |
| | | shoppingGoodsDao.update(shopGoods); |
| | | LogUtil.info("{}商品达到最大销售数量自动下架",shopGoods.getName()); |
| | | LogUtil.info("商品达到最大销售数量自动下架:{}", shopGoods.getName()); |
| | | } |
| | | } else if ((buyNum + item.getCount()) > maxNum) { |
| | | throw new GlobleException(shopGoods.getName() + "已超过最大销售数量"); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | private void checkGoodsSelLimtParam(GoodsSealLimitDto goodsSealLimitDto) { |
| | | ParamCheckUtil.requireNonNulls(goodsSealLimitDto, |
| | | goodsSealLimitDto.getVipId(), |
| | | goodsSealLimitDto.getOrderItemDtoList()); |
| | | goodsSealLimitDto.getSysOrderItemDtoList()); |
| | | |
| | | |
| | | ParamCheckUtil.requireListElementNonNull(goodsSealLimitDto.getOrderItemDtoList(), |
| | | Arrays.asList(OrderItemDto::getCount, OrderItemDto::getGoodsId)); |
| | | ParamCheckUtil.requireListElementNonNull(goodsSealLimitDto.getSysOrderItemDtoList(), |
| | | Arrays.asList(SysOrderItemDto::getCount, SysOrderItemDto::getGoodsId)); |
| | | } |
| | | |
| | | |
| | |
| | | shoppingGoods.setIsAssemble(Dictionary.FLAG_NO); |
| | | break; |
| | | case Dictionary.SHOPPING_GOODS_TYPE_TC: |
| | | shoppingGoods.setIsAssemble(Dictionary.FLAG_YES); |
| | | break; |
| | | case Dictionary.SHOPPING_GOODS_TYPE_ZHK: |
| | | shoppingGoods.setIsAssemble(Dictionary.FLAG_YES); |
| | | break; |
| | | } |