| | |
| | | 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 addActivateRecord(Long id) {
|
| | | UserSystemCouponActivate record = new UserSystemCouponActivate();
|
| | | record.setId(id);
|
| | | record.setCount(0);
|
| | | record.setState(UserSystemCouponActivate.STATE_INIT);
|
| | | record.setCreateTime(new Date());
|
| | | record.setUpdateTime(new Date());
|
| | | userSystemCouponActivateMapper.insertSelective(record);
|
| | | }
|
| | | |
| | | @Override
|
| | | public void updateByPrimaryKeySelective(UserSystemCouponActivate record) {
|
| | | userSystemCouponActivateMapper.updateByPrimaryKeySelective(record);
|
| | | }
|
| | |
|
| | | @Override
|