From 2f071296b9e1d7a3aa6b6f3818196aaa40af3300 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期一, 05 七月 2021 19:13:34 +0800 Subject: [PATCH] 礼金bug修复 --- service-lijin/src/main/java/com/ks/lijin/service/remote/LijinCreateServiceImpl.java | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 42 insertions(+), 2 deletions(-) diff --git a/service-lijin/src/main/java/com/ks/lijin/service/remote/LijinCreateServiceImpl.java b/service-lijin/src/main/java/com/ks/lijin/service/remote/LijinCreateServiceImpl.java index a2daa01..82c705c 100644 --- a/service-lijin/src/main/java/com/ks/lijin/service/remote/LijinCreateServiceImpl.java +++ b/service-lijin/src/main/java/com/ks/lijin/service/remote/LijinCreateServiceImpl.java @@ -33,6 +33,8 @@ 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; @@ -51,6 +53,8 @@ @Service(version = "1.0") public class LijinCreateServiceImpl implements LijinCreateService { + + Logger logger = LoggerFactory.getLogger(LijinCreateService.class); @Resource(name = "taskExecutor") private TaskExecutor executor; @@ -195,6 +199,38 @@ 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 { @@ -225,7 +261,7 @@ 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); } } } @@ -364,11 +400,15 @@ 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, "鏈嶅姟鍣ㄧ箒蹇欙紝璇风◢鍚庡啀璇�"); } } @@ -402,7 +442,7 @@ liJinProviderTaoKeAccountManager.createLijinSuccess(taoLiJinDTO.getAccount().getId(), goodsId, lijinAmount.multiply(new BigDecimal(num)), now); //绀奸噾浣欓鎵i櫎 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(); } -- Gitblit v1.8.0