From 972d3bc71115ec977dccf835fbcd148da3bcc86c Mon Sep 17 00:00:00 2001 From: yujian <yujian@123.com> Date: 星期二, 03 九月 2019 16:41:49 +0800 Subject: [PATCH] 统计可用的免单券数量-countUsableFreeCouponForBuy --- fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralGetServiceImpl.java | 85 +++++++++++++++++++++++++++++++----------- 1 files changed, 63 insertions(+), 22 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralGetServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralGetServiceImpl.java index e78a478..aebac99 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralGetServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralGetServiceImpl.java @@ -4,24 +4,29 @@ import javax.annotation.Resource; -import org.springframework.cache.annotation.Cacheable; import org.springframework.context.annotation.Lazy; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import com.yeshi.fanli.dao.mybatis.ThreeSaleMapper; import com.yeshi.fanli.entity.bus.user.UserInfo; +import com.yeshi.fanli.entity.bus.user.UserInfoExtra; +import com.yeshi.fanli.entity.bus.user.UserRank; import com.yeshi.fanli.entity.integral.IntegralTask; import com.yeshi.fanli.entity.integral.IntegralTask.FrequencyEnum; import com.yeshi.fanli.entity.integral.IntegralTask.TaskUniqueKeyEnum; +import com.yeshi.fanli.entity.integral.IntegralTaskRank; import com.yeshi.fanli.entity.integral.IntegralTaskRecord; import com.yeshi.fanli.exception.integral.IntegralGetException; import com.yeshi.fanli.exception.integral.IntegralTaskRecordException; import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.integral.IntegralGetService; +import com.yeshi.fanli.service.inter.integral.IntegralTaskRankService; import com.yeshi.fanli.service.inter.integral.IntegralTaskRecordService; import com.yeshi.fanli.service.inter.integral.IntegralTaskService; +import com.yeshi.fanli.service.inter.user.UserInfoExtraService; import com.yeshi.fanli.util.RedisManager; +import com.yeshi.fanli.util.annotation.integral.IntegralGetFrequencyLimit; import com.yeshi.fanli.util.annotation.integral.IntegralGetVersionLimit; @Lazy @@ -40,12 +45,18 @@ @Resource private RedisManager redisManager; + @Resource + private UserInfoExtraService userInfoExtraService; + + @Resource + private IntegralTaskRankService integralTaskRankService; + // TODO 鏈塨ug private UserInfo getBossByUid(Long uid) { return threeSaleMapper.selectBoss(uid); } - @IntegralGetVersionLimit(uid="#uid") + @IntegralGetVersionLimit(uid = "#uid") @Override public IntegralTaskRecord addEventStatistic(Long uid, String event) throws IntegralGetException { Date nowDate = new Date(); @@ -69,9 +80,30 @@ throw new IntegralGetException(2, "浜嬩欢瑙﹀彂杈惧埌涓婇檺"); } + UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid); + if (userInfoExtra == null) + throw new IntegralGetException(2, "棰濆淇℃伅涓嶅瓨鍦�"); + + UserRank userRank = userInfoExtra.getUserRank(); + if (userRank == null) + throw new IntegralGetException(2, "绛夌骇淇℃伅涓嶅瓨鍦�"); + int goldCoin = task.getGoldCoin(); if (task.getDoubleNum() != null && task.getDoubleNum() > 0) goldCoin = task.getDoubleNum() * goldCoin; + + Long taskId = task.getId(); + IntegralTaskRank traskRank = integralTaskRankService.getByTsakIdAndRankId(taskId, userRank.getId()); + if (traskRank != null) { + Integer addCoin = traskRank.getAddCoin(); + if (addCoin != null && addCoin > 0) + goldCoin += addCoin; + + Integer doubleNum = traskRank.getDoubleNum(); + if (doubleNum != null && doubleNum > 0) { + goldCoin = goldCoin * doubleNum; + } + } IntegralTaskRecord record = new IntegralTaskRecord(); record.setCid(task.getTaskClass().getId()); @@ -88,7 +120,7 @@ } } - @Cacheable(value = "integralGetCache", key = "'addRecommendSearch-'+#uid") + @IntegralGetFrequencyLimit(key = "'addRecommendSearch-'+#uid") @Override public IntegralTaskRecord addRecommendSearch(Long uid) { try { @@ -99,7 +131,7 @@ return null; } - @Cacheable(value = "integralGetCache", key = "'addSearchResultScan-'+#uid+'-'+#kw") + @IntegralGetFrequencyLimit(key = "'addSearchResultScan-'+#uid+'-'+#kw") @Override public IntegralTaskRecord addSearchResultScan(Long uid, String kw) { try { @@ -110,8 +142,8 @@ return null; } - - @Cacheable(value = "integralGetCache", key = "'addShareInvite-'+#uid") + + @IntegralGetFrequencyLimit(key = "'addShareInvite-'+#uid", time = 30) @Override public IntegralTaskRecord addShareInvite(Long uid) { try { @@ -122,7 +154,7 @@ return null; } - @Cacheable(value = "integralGetCache", key = "'addIntoShop-'+#uid+'-'+#shopUrlMD5") + @IntegralGetFrequencyLimit(key = "'addIntoShop-'+#uid+'-'+#shopUrlMD5") @Override public IntegralTaskRecord addIntoShop(Long uid, String shopUrlMD5) { try { @@ -157,7 +189,7 @@ } } - @Cacheable(value = "integralGetCache", key = "'addScanPushHistory-'+#uid") + @IntegralGetFrequencyLimit(key = "'addScanPushHistory-'+#uid") @Override public IntegralTaskRecord addScanPushHistory(Long uid) { try { @@ -168,7 +200,7 @@ return null; } - @Cacheable(value = "integralGetCache", key = "'addScanGoodsDetail-'+#uid+'-'+#goodsType+'-'+#goodsId") + @IntegralGetFrequencyLimit(key = "'addScanGoodsDetail-'+#uid+'-'+#goodsType+'-'+#goodsId") @Override public IntegralTaskRecord addScanGoodsDetail(Long uid, int goodsType, Long goodsId) { try { @@ -179,7 +211,7 @@ return null; } - @Cacheable(value = "integralGetCache", key = "'addScanRecommendBanner-'+#uid+'-'+#id") + @IntegralGetFrequencyLimit(key = "'addScanRecommendBanner-'+#uid+'-'+#id") @Override public IntegralTaskRecord addScanRecommendBanner(Long uid, String id) { try { @@ -190,7 +222,7 @@ return null; } - @Cacheable(value = "integralGetCache", key = "'addScanRecommendSpecial-'+#uid+'-'+#id") + @IntegralGetFrequencyLimit(key = "'addScanRecommendSpecial-'+#uid+'-'+#id") @Override public IntegralTaskRecord addScanRecommendSpecial(Long uid, String id) { try { @@ -202,7 +234,7 @@ return null; } - @Cacheable(value = "integralGetCache", key = "'addScanTaoBaoCart-'+#uid") + @IntegralGetFrequencyLimit(key = "'addScanTaoBaoCart-'+#uid") @Override public IntegralTaskRecord addScanTaoBaoCart(Long uid) { try { @@ -214,6 +246,7 @@ } @IntegralGetVersionLimit(uid = "#uid") + @IntegralGetFrequencyLimit(key = "'taoLiJinBuy-'+#uid", time = 30) @Async() @Override public void addTaoLiJinBuy(Long uid, Long goodsId) { @@ -255,6 +288,7 @@ } @IntegralGetVersionLimit(uid = "#uid") + @IntegralGetFrequencyLimit(key = "'shareSingleGoods-'+#uid", time = 45) @Async() @Override public void addShareSingleGoods(Long uid) { @@ -266,6 +300,7 @@ } @IntegralGetVersionLimit(uid = "#uid") + @IntegralGetFrequencyLimit(key = "'shareMultipleGoods-'+#uid", time = 45) @Async() @Override public void addShareMultipleGoods(Long uid) { @@ -277,6 +312,7 @@ } @IntegralGetVersionLimit(uid = "#uid") + @IntegralGetFrequencyLimit(key = "'shareTLJGoods-'+#uid", time = 45) @Async() @Override public void addShareTLJGoods(Long uid) { @@ -321,6 +357,7 @@ } @IntegralGetVersionLimit(uid = "#uid") + @IntegralGetFrequencyLimit(key = "'closeRecommendGoods-'+#uid", time = 30) @Async() @Override public void addCloseRecommendGoods(Long uid) { @@ -332,6 +369,7 @@ } @IntegralGetVersionLimit(uid = "#uid") + @IntegralGetFrequencyLimit(key = "'couponRebate-'+#uid", time = 30) @Async() @Override public void addCouponRebate(Long uid) { @@ -385,10 +423,6 @@ @Override public void addRebateOrder(Long uid) { try { - UserInfo boss = getBossByUid(uid); - if (boss != null) - addInviteOrderLevelOne(boss.getId()); - addEventStatistic(uid, TaskUniqueKeyEnum.rebateOrder.name()); } catch (Exception e) { LogHelper.errorDetailInfo(e); @@ -402,12 +436,9 @@ */ @IntegralGetVersionLimit(uid = "#uid") @Async() - private void addInviteOrderLevelOne(Long uid) { + @Override + public void addInviteOrderLevelOne(Long uid) { try { - UserInfo boss = getBossByUid(uid); - if (boss != null) - addInviteOrderLevelTwo(boss.getId()); - addEventStatistic(uid, TaskUniqueKeyEnum.inviteOrderLevelOne.name()); } catch (Exception e) { LogHelper.errorDetailInfo(e); @@ -421,7 +452,8 @@ */ @IntegralGetVersionLimit(uid = "#uid") @Async() - private void addInviteOrderLevelTwo(Long uid) { + @Override + public void addInviteOrderLevelTwo(Long uid) { try { addEventStatistic(uid, TaskUniqueKeyEnum.inviteOrderLevelTwo.name()); } catch (Exception e) { @@ -441,6 +473,7 @@ } @IntegralGetVersionLimit(uid = "#uid") + @IntegralGetFrequencyLimit(key = "'bindWeiXin-'+#uid", time = 30) @Async() @Override public void addBindWeiXin(Long uid) { @@ -452,6 +485,7 @@ } @IntegralGetVersionLimit(uid = "#uid") + @IntegralGetFrequencyLimit(key = "'bindPhone-'+#uid", time = 30) @Async() @Override public void addBindPhone(Long uid) { @@ -463,6 +497,7 @@ } @IntegralGetVersionLimit(uid = "#uid") + @IntegralGetFrequencyLimit(key = "'bindTaoBao-'+#uid", time = 30) @Async() @Override public void addBindTaoBao(Long uid) { @@ -474,6 +509,7 @@ } @IntegralGetVersionLimit(uid = "#uid") + @IntegralGetFrequencyLimit(key = "'setWeiXinNum-'+#uid", time = 30) @Async() @Override public void addSetWeiXinNum(Long uid) { @@ -485,6 +521,7 @@ } @IntegralGetVersionLimit(uid = "#uid") + @IntegralGetFrequencyLimit(key = "'setGender-'+#uid", time = 30) @Async() @Override public void addSetGender(Long uid) { @@ -496,6 +533,7 @@ } @IntegralGetVersionLimit(uid = "#uid") + @IntegralGetFrequencyLimit(key = "'setPortrait-'+#uid", time = 30) @Async() @Override public void addSetPortrait(Long uid) { @@ -507,6 +545,7 @@ } @IntegralGetVersionLimit(uid = "#uid") + @IntegralGetFrequencyLimit(key = "'setNickName-'+#uid", time = 30) @Async() @Override public void addSetNickname(Long uid) { @@ -518,6 +557,7 @@ } @IntegralGetVersionLimit(uid = "#uid") + @IntegralGetFrequencyLimit(key = "'bindAlipay-'+#uid", time = 30) @Async() @Override public void addBindAlipay(Long uid) { @@ -529,6 +569,7 @@ } @IntegralGetVersionLimit(uid = "#uid") + @IntegralGetFrequencyLimit(key = "'inviteActivate-'+#uid", time = 30) @Async() @Override public void addInviteActivate(Long uid) { -- Gitblit v1.8.0