| | |
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; |
| | | import org.apache.dubbo.config.annotation.Reference; |
| | | import org.apache.dubbo.config.annotation.Service; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.core.task.TaskExecutor; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | |
| | | @Service(version = "1.0") |
| | | public class LijinCreateServiceImpl implements LijinCreateService { |
| | | |
| | | Logger logger = LoggerFactory.getLogger(LijinCreateService.class); |
| | | |
| | | @Resource(name = "taskExecutor") |
| | | private TaskExecutor executor; |
| | |
| | | return money; |
| | | } |
| | | |
| | | @Override |
| | | public int getTodayLeftCount(String uid, Date registerDate) { |
| | | VipGradePotence potence = vipCenterService.getVipPotence(uid); |
| | | if (potence == null) { |
| | | return 0; |
| | | } |
| | | // 每日最大次数判断 |
| | | Integer numMax = potence.getTaolijinMaxNumber(); |
| | | if (numMax == null || numMax.intValue() <= 0) { |
| | | return 0; |
| | | } |
| | | // 使用次数已经超过最大次数 |
| | | int numExpend = liJinExpendRecordService.countTodayNumByExpend(uid); |
| | | if (registerDate != null) { |
| | | //判断新用户 |
| | | String newerHour = lijinConfigManager.getConfigValue("newer-hour"); |
| | | String dayPlusCount = lijinConfigManager.getConfigValue("newer-everyday-plus-lijin-count"); |
| | | if (!StringUtil.isNullOrEmpty(newerHour) && !StringUtil.isNullOrEmpty(dayPlusCount)) { |
| | | //新用户每日附加次数 |
| | | if (System.currentTimeMillis() - registerDate.getTime() < 1000 * 60 * 60L * Integer.parseInt(dayPlusCount)) { |
| | | numMax += Integer.parseInt(dayPlusCount); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (numMax.intValue() > numExpend) { |
| | | return numMax.intValue() - numExpend; |
| | | } else { |
| | | return 0; |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public boolean userCanCreateTBLijin(String uid, Date registerDate) throws LiJinUserException { |
| | |
| | | if (!StringUtil.isNullOrEmpty(newerHour) && !StringUtil.isNullOrEmpty(dayPlusCount)) { |
| | | //新用户每日附加次数 |
| | | if (System.currentTimeMillis() - registerDate.getTime() < 1000 * 60 * 60L * Integer.parseInt(dayPlusCount)) { |
| | | numExpend += Integer.parseInt(dayPlusCount); |
| | | numMax += Integer.parseInt(dayPlusCount); |
| | | } |
| | | } |
| | | } |
| | |
| | | if (e.getCode() == LiJinGoodsException.CODE_GOODS_CREATED_FULL) { |
| | | lijinGoodsManager.createdFullToday(auctionId, now); |
| | | } |
| | | redisTemplate.delete(key); |
| | | logger.info("淘礼金创建,删除锁定成功1 key:{}",key); |
| | | throw e; |
| | | } finally { |
| | | redisTemplate.delete(key); |
| | | logger.info("淘礼金创建,删除锁定成功2 key:{}",key); |
| | | } |
| | | } else { |
| | | logger.error("淘礼金创建,用户锁定失败 key:{}",key); |
| | | throw new LiJinException(LiJinException.CODE_SERVER_BUSY, "服务器繁忙,请稍后再试"); |
| | | } |
| | | } |
| | |
| | | liJinProviderTaoKeAccountManager.createLijinSuccess(taoLiJinDTO.getAccount().getId(), goodsId, lijinAmount.multiply(new BigDecimal(num)), now); |
| | | //礼金余额扣除 |
| | | try { |
| | | lijinBalanceService.consumeLijin(uid, lijinAmount, "购物抵现", UserLijinRecord.Category.createGoodsLijin.name(), record.getId()+""); |
| | | lijinBalanceService.consumeLijin(uid, lijinAmount, "购物抵现", UserLijinRecord.Category.createGoodsLijin.name(), record.getId() + ""); |
| | | } catch (LijinBalanceException e) { |
| | | e.printStackTrace(); |
| | | } |