admin
2019-11-03 788deca1b4a24f8a24e49c24f7d89975a1d74bbe
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserSystemCouponActivateServiceImpl.java
@@ -1,7 +1,5 @@
package com.yeshi.fanli.service.impl.user;
import java.util.Date;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
@@ -21,32 +19,15 @@
   private ConfigService configService;
   
   
   @Override
   public boolean addActivateCount(Long cpid, int limitNum) {
      UserSystemCouponActivate coupon = userSystemCouponActivateMapper.selectByPrimaryKey(cpid);
      if (coupon != null) {
         userSystemCouponActivateMapper.addCount(cpid, 1);
         coupon.setCount(coupon.getCount() + 1);
      } else {
         coupon = new UserSystemCouponActivate();
         coupon.setId(cpid);
         coupon.setCount(1);
         coupon.setState(UserSystemCouponActivate.STATE_INIT);
         coupon.setCreateTime(new Date());
         coupon.setUpdateTime(new Date());
         userSystemCouponActivateMapper.insertSelective(coupon);
      }
      // 是否满足激活条件
      Integer state = coupon.getState();
      if (state != UserSystemCouponActivate.STATE_END && coupon.getCount().intValue() >= limitNum) {
         UserSystemCouponActivate record = new UserSystemCouponActivate();
         record.setId(coupon.getId());
         record.setState(UserSystemCouponActivate.STATE_END);
         userSystemCouponActivateMapper.updateByPrimaryKeySelective(record);
         return true;
      }
      return false;
   public UserSystemCouponActivate selectForUpdate(Long id) {
      return userSystemCouponActivateMapper.selectForUpdate(id);
   }
   @Override
   public void updateByPrimaryKeySelective(UserSystemCouponActivate record) {
      userSystemCouponActivateMapper.updateByPrimaryKeySelective(record);
   }
   
   @Override