| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.matrix.core.exception.GlobleException; |
| | | import com.matrix.core.pojo.PaginationVO; |
| | | import com.matrix.core.pojo.VerificationResult; |
| | | import com.matrix.core.tools.DateUtil; |
| | | import com.matrix.system.constance.Dictionary; |
| | | import com.matrix.system.hive.bean.MoneyCardUse; |
| | | import com.matrix.system.hive.bean.MoneyCardUseFreeze; |
| | | import com.matrix.system.hive.bean.SysOrderItem; |
| | | import com.matrix.system.hive.bean.SysVipInfo; |
| | | import com.matrix.system.hive.bean.*; |
| | | import com.matrix.system.hive.dao.*; |
| | | import com.matrix.system.hive.dto.MoneyCardChangeDto; |
| | | import com.matrix.system.hive.service.MoneyCardUseService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | @Autowired |
| | | private SysVipLevelDao viplevelDao; |
| | | |
| | | @Autowired |
| | | ShoppingGoodsDao shoppingGoodsDao; |
| | | |
| | | @Autowired |
| | | MoneyCardAssembleDao moneyCardAssembleDao; |
| | | |
| | | @Override |
| | | public void changeMoneyCard(List<MoneyCardChangeDto> moneyCardChangeDtoList) { |
| | | |
| | | // 判断商品是否在充值卡的限制购买,判断分类 |
| | | moneyCardChangeDtoList.forEach(cardUse->{ |
| | | VerificationResult verificationResult = checkIsBangding(cardUse, cardUse.getGoodsIds()); |
| | | if (!verificationResult.isJudgeResult()) { |
| | | throw new GlobleException(verificationResult.getMsg()); |
| | | } |
| | | }); |
| | | |
| | | moneyCardChangeDtoList.get().forEach(item -> { |
| | | if (!isInBangding(moneyCardUse, item.getGoodsId())) { |
| | | throw new GlobleException(shoppingGoodsDao.selectById(item.getGoodsId()).getName() + "不在" + moneyCardUse.getCardName() + "优惠中"); |
| | | } |
| | | }); |
| | | |
| | | |
| | | } |
| | | |
| | | private VerificationResult checkIsBangding(MoneyCardChangeDto moneyCardUse, List<Long> goodsIds) { |
| | | // 如果是一卡通则肯定在绑定范围内 |
| | | |
| | | if (moneyCardUse.getIsVipCar().equals(Dictionary.FLAG_YES_Y)) { |
| | | return true; |
| | | } else { |
| | | // 不是一卡通, |
| | | // 判断卡是否可应用于所有产品 |
| | | ShoppingGoods cardGoods = shoppingGoodsDao.selectById(moneyCardUse.getGoodsId()); |
| | | if (cardGoods != null) { |
| | | if (Dictionary.FLAG_YES.equals(cardGoods.getCarIsAll())) { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | // 比较分类 |
| | | MoneyCardAssemble moneyCardAssemble = new MoneyCardAssemble(); |
| | | moneyCardAssemble.setCardId(moneyCardUse.getGoodsId()); |
| | | List<MoneyCardAssemble> cardAssembleList = moneyCardAssembleDao.selectByModel(moneyCardAssemble); |
| | | ShoppingGoods yhGoods = shoppingGoodsDao.selectById(goodsId); |
| | | boolean flag = false; |
| | | for (MoneyCardAssemble cardAssemble : cardAssembleList) { |
| | | // 比较类型 |
| | | if (cardAssemble.getType().equals(Dictionary.CZK_ASSEMBLE_FL)) { |
| | | if (yhGoods.getCateId().equals(cardAssemble.getCateId())) { |
| | | flag = true; |
| | | break; |
| | | } |
| | | } else { |
| | | // 比较绑定 |
| | | if (yhGoods.getId().equals(cardAssemble.getGoodsId())) { |
| | | flag = true; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | return flag; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public int add(MoneyCardUse moneyCardUse) { |