| | |
| | | import com.ks.vip.pojo.DO.UserLijinRecord; |
| | | import com.ks.vip.service.LijinBalanceService; |
| | | import org.apache.dubbo.config.annotation.Service; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.yeshi.utils.TimeUtil; |
| | | |
| | |
| | | |
| | | @Service(version = "1.0") |
| | | public class LijinBalanceServiceImpl implements LijinBalanceService { |
| | | |
| | | Logger logger = LoggerFactory.getLogger(LijinBalanceService.class); |
| | | |
| | | @Resource |
| | | private LijinBalanceMapper lijinBalanceMapper; |
| | |
| | | userLijinRecordDao.save(record); |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public void consumeLijin(String uid, BigDecimal money, String title, String category, String identifyCode) throws LijinBalanceException { |
| | | logger.info("开始扣除礼金"); |
| | | //添加记录 |
| | | LijinBalance lijinBalance = lijinBalanceMapper.selectByPrimaryKeyForUpdate(uid); |
| | | logger.info("用户礼金锁定成功"); |
| | | if (lijinBalance == null) { |
| | | throw new LijinBalanceException(LijinBalanceException.CODE_NOT_INIT, "余额未初始化"); |
| | | } |
| | |
| | | update.setBalance(lijinBalance.getBalance().subtract(money)); |
| | | update.setUpdateTime(new Date()); |
| | | lijinBalanceMapper.updateByPrimaryKeySelective(update); |
| | | logger.info("减余额成功"); |
| | | //增加记录 |
| | | UserLijinRecord record = new UserLijinRecord(); |
| | | record.setMoney(money); |
| | |
| | | record.setCreateTime(new Date()); |
| | | record.setIdentifyCode(identifyCode); |
| | | userLijinRecordDao.save(record); |
| | | |
| | | logger.info("增加记录成功"); |
| | | } |
| | | |
| | | @Override |