From e6764831a890de26fcfebb4fb8f3a22e9f8cc816 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 27 八月 2019 16:09:42 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/div' into div

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/integral/IntegralGetServiceImpl.java |   54 +++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 43 insertions(+), 11 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..a7d15d5 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,14 +4,16 @@
 
 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.IntegralTaskRank;
 import com.yeshi.fanli.entity.integral.IntegralTask.FrequencyEnum;
 import com.yeshi.fanli.entity.integral.IntegralTask.TaskUniqueKeyEnum;
 import com.yeshi.fanli.entity.integral.IntegralTaskRecord;
@@ -19,9 +21,12 @@
 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
@@ -39,13 +44,19 @@
 
 	@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();
@@ -68,10 +79,31 @@
 			if (count > 0)
 				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 {
@@ -111,7 +143,7 @@
 		return null;
 	}
 
-	@Cacheable(value = "integralGetCache", key = "'addShareInvite-'+#uid")
+	@IntegralGetFrequencyLimit(key = "'addShareInvite-'+#uid")
 	@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 {

--
Gitblit v1.8.0