| | |
| | | import com.matrix.core.constance.MatrixConstance; |
| | | import com.matrix.core.exception.GlobleException; |
| | | import com.matrix.core.pojo.PaginationVO; |
| | | import com.matrix.core.tools.DateUtil; |
| | | import com.matrix.core.tools.StringUtils; |
| | | import com.matrix.core.tools.WebUtil; |
| | | import com.matrix.core.tools.*; |
| | | import com.matrix.system.app.dto.ShoppingGoodsListDto; |
| | | import com.matrix.system.app.vo.ShoppingGoodsDetailVo; |
| | | import com.matrix.system.app.vo.ShoppingGoodsListVo; |
| | |
| | | import com.matrix.system.hive.bean.ShoppingGoodsAssemble; |
| | | import com.matrix.system.hive.bean.ShoppingGoodsCategory; |
| | | import com.matrix.system.hive.bean.SysShopInfo; |
| | | import com.matrix.system.hive.dao.MoneyCardAssembleDao; |
| | | import com.matrix.system.hive.dao.ShoppingGoodsAssembleDao; |
| | | import com.matrix.system.hive.dao.ShoppingGoodsDao; |
| | | import com.matrix.system.hive.dao.SysShopInfoDao; |
| | | 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.service.ShoppingGoodsService; |
| | | import org.apache.commons.collections.CollectionUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import javax.validation.constraints.NotNull; |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | |
| | | @Autowired |
| | | private SysShopInfoDao shopInfoDao; |
| | | |
| | | @Autowired |
| | | private SysOrderItemDao orderItemDao; |
| | | |
| | | @Override |
| | | public void checkGoodsSealLimit(GoodsSealLimitDto goodsSealLimitDto) { |
| | | LogUtil.info("开始检测商品销售限制:{}", goodsSealLimitDto.toString()); |
| | | //校验参数不能为空 |
| | | checkGoodsSelLimtParam(goodsSealLimitDto); |
| | | |
| | | goodsSealLimitDto.getOrderItemDtoList().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 (!shopGoods.getStaus().equals(Dictionary.BUSINESS_STATE_DOWN)) { |
| | | shopGoods.setStaus(Dictionary.BUSINESS_STATE_DOWN); |
| | | shoppingGoodsDao.update(shopGoods); |
| | | LogUtil.info("{}商品达到最大销售数量自动下架",shopGoods.getName()); |
| | | } |
| | | } else if ((buyNum + item.getCount()) > maxNum) { |
| | | throw new GlobleException(shopGoods.getName() + "已超过最大销售数量"); |
| | | } |
| | | } |
| | | //每人限购次数检测 |
| | | Integer onceCount = shopGoods.getIsOnce(); |
| | | if (onceCount != null && onceCount != 0) { |
| | | Integer buyOnceCount = orderItemDao.selectByGoodsId(shopGoods.getId(), goodsSealLimitDto.getVipId()); |
| | | if ((buyOnceCount + item.getCount()) > onceCount) { |
| | | throw new GlobleException(shopGoods.getName() + "每人限购" + onceCount + "次"); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | private void checkGoodsSelLimtParam(GoodsSealLimitDto goodsSealLimitDto) { |
| | | ParamCheckUtil.requireNonNulls(goodsSealLimitDto, |
| | | goodsSealLimitDto.getVipId(), |
| | | goodsSealLimitDto.getOrderItemDtoList()); |
| | | |
| | | |
| | | ParamCheckUtil.requireListElementNonNull(goodsSealLimitDto.getOrderItemDtoList(), |
| | | Arrays.asList(OrderItemDto::getCount, OrderItemDto::getGoodsId)); |
| | | } |
| | | |
| | | |
| | | @Override |
| | |
| | | public int add(ShoppingGoods shoppingGoods) { |
| | | SysUsers sysUsers = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); |
| | | SysShopInfo shopInfo = shopInfoDao.selectById(sysUsers.getShopId()); |
| | | |
| | | |
| | | |
| | | if(shopInfo.getShopType()==SysShopInfo.SHOP_TYPE_ZONGBU){ |
| | |
| | | } else { |
| | | setGoodsAssembles(shoppingGoods); |
| | | } |
| | | |
| | | |
| | | |
| | | return i; |
| | |
| | | shoppingGoods.setWeiImg(Dictionary.DEFAULT_IMG); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |