yujian
2020-01-18 f4a0f2acc63d7785eab108419a4e16f5f688cb95
fanli/src/main/java/com/yeshi/fanli/service/impl/shop/BanLiShopGoodsSetPayServiceImpl.java
@@ -34,7 +34,7 @@
      return banLiShopGoodsSetsPayMapper.selectByPrimaryKey(id);
   }
   @Transactional
   @Transactional(rollbackFor=Exception.class)
   @Override
   public void addSetPay(BanLiShopGoodsSetsPay pay) throws BanLiShopGoodsSetPayException {
      if (pay.getId() == null)// 新增
@@ -73,6 +73,50 @@
         updateSelectiveByPrimaryKey(pay);
      }
   }
   @Override
   public void saveObject(BanLiShopGoodsSetsPay record) throws BanLiShopGoodsSetPayException {
      // 判断参数是否齐全
      if (record.getGoodsSet() == null || record.getGoodsSet().getId() == null)
         throw new BanLiShopGoodsSetPayException(1, "套餐不存在");
      if (record.getPayType() == null)
         throw new BanLiShopGoodsSetPayException(1, "请指定支付方式");
      if (record.getPayType() == BanLiShopGoodsSetsPay.PAY_TYPE_HONGBAO) {
         if (record.getHongBaoPrice() == null)
            throw new BanLiShopGoodsSetPayException(1, "请指定红包支付价格");
      } else if (record.getPayType() == BanLiShopGoodsSetsPay.PAY_TYPE_BALANCE) {
         if (record.getBalancePrice() == null)
            throw new BanLiShopGoodsSetPayException(1, "请指定余额支付价格");
      } else if (record.getPayType() == BanLiShopGoodsSetsPay.PAY_TYPE_HONGBAO_MONEY) {
         if (record.getHongBaoPrice() == null || record.getMoneyPrice() == null)
            throw new BanLiShopGoodsSetPayException(1, "请指定红包、现金支付价格");
      } else if (record.getPayType() == BanLiShopGoodsSetsPay.PAY_TYPE_MONEY) {
         if (record.getMoneyPrice() == null)
            throw new BanLiShopGoodsSetPayException(1, "请指定现金支付价格");
      }
      record.setUpdateTime(new Date());
      if (record.getId() == null) {
         record.setCreateTime(new Date());
         banLiShopGoodsSetsPayMapper.insertSelective(record);
         if (record.getWeight() == null) {// 权重更新
            BanLiShopGoodsSetsPay update = new BanLiShopGoodsSetsPay();
            update.setId(record.getId());
            update.setWeight((int) record.getId().longValue());
            banLiShopGoodsSetsPayMapper.updateByPrimaryKeySelective(update);
         }
      } else {
         BanLiShopGoodsSetsPay resultObj = banLiShopGoodsSetsPayMapper.selectByPrimaryKey(record.getId());
         if (resultObj == null)
            throw new BanLiShopGoodsSetPayException(1, "修改内容已不存在");
         record.setCreateTime(resultObj.getCreateTime());
         banLiShopGoodsSetsPayMapper.updateByPrimaryKey(record);
      }
   }
   @Override
   public void updateSelectiveByPrimaryKey(BanLiShopGoodsSetsPay pay) {
@@ -97,4 +141,16 @@
      banLiShopGoodsSetsPayMapper.deleteByPrimaryKey(id);
   }
   @Override
   public List<BanLiShopGoodsSetsPay> listQuery(int page, int pageSize, String key, Integer payType, Long setId) {
      return banLiShopGoodsSetsPayMapper.listQuery((page - 1) * pageSize, pageSize, key, payType, setId);
   }
   @Override
   public long countQuery(String key, Integer payType, Long setId) {
      return banLiShopGoodsSetsPayMapper.countQuery(key, payType, setId);
   }
}