@Transactional(rollbackFor = Exception.class)
 @Override
 public void reset() {
   int vipSellCount = configService.getInt("vip.sell.count");
   Map<Integer, Integer> map = new HashMap<>();
   List<VipAccount> list = vipAccountMapper.listAll();
   for (VipAccount vipAccount : list) {
     vipAccount.setCount(vipSellCount);
     vipAccountMapper.updateByPrimaryKey(vipAccount);
     Integer count = map.get(vipAccount.getType());
     if (null == count) {
       map.put(vipAccount.getType(), 1);
     } else {
       map.put(vipAccount.getType(), ++count);
     }
   }
   // 更新商品数量
   for (Integer vipType : map.keySet()) {
     Goods goods = new Goods();
     goods.setType(1);
     goods.setVipType(vipType);
     goods = goodsMapper.selectByTypeAndVipType(goods);
     goods.setCount(vipSellCount * map.get(vipType));
     goodsMapper.updateByPrimaryKey(goods);
   }
 }
 @Override
 public VipAccount vote(Integer type) {
   List<VipAccount> list = vipAccountMapper.listByTypeOrderByCountDesc(type);
   if (list == null) return null;
   VipAccount vipAccount = list.get(0);
   if (vipAccount.getCount() == 0) return null;
   return vipAccount;
 }
  @Transactional(rollbackFor = Exception.class)
  @Override
  public int save(VipAccount vipAccount) {

    // 更新商品数量
    Goods goods = new Goods();
    goods.setType(1);
    goods.setVipType(vipAccount.getType());
    goods = goodsMapper.selectByTypeAndVipType(goods);
    if (goods != null) {
      goods.setCount(goods.getCount() + vipAccount.getCount());
      goodsMapper.updateByPrimaryKey(goods);
    }

    return vipAccountMapper.insert(vipAccount);
  }
 @Override
 public int delete(VipAccount vipAccount) {
   return vipAccountMapper.deleteByPrimaryKey(vipAccount.getId());
 }
 @Override
 public VipAccount get(VipAccount vipAccount) {
   return vipAccountMapper.selectByPrimaryKey(vipAccount.getId());
 }