From f1a2d46aaa612253afba7b1d61ad04a2f0ef7eed Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期三, 21 八月 2019 11:55:52 +0800
Subject: [PATCH] 金币获得客户端事件添加

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/v2/IntegralControllerV2.java |   93 ++++++++++++++++++++++++++--------------------
 1 files changed, 53 insertions(+), 40 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/IntegralControllerV2.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/IntegralControllerV2.java
index ce38a85..4b21c10 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/IntegralControllerV2.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/IntegralControllerV2.java
@@ -34,11 +34,10 @@
 import com.yeshi.fanli.entity.integral.CodePublishRecord;
 import com.yeshi.fanli.entity.integral.IntegralExchange;
 import com.yeshi.fanli.entity.integral.IntegralTask;
-import com.yeshi.fanli.entity.integral.IntegralTaskClass;
-import com.yeshi.fanli.entity.integral.IntegralTaskRank;
 import com.yeshi.fanli.entity.integral.IntegralTaskClass.UniqueKeyEnum;
 import com.yeshi.fanli.entity.integral.IntegralTaskRecord;
 import com.yeshi.fanli.exception.integral.IntegralExchangeException;
+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.config.ConfigService;
@@ -46,6 +45,7 @@
 import com.yeshi.fanli.service.inter.integral.IntegralDetailService;
 import com.yeshi.fanli.service.inter.integral.IntegralExchangeRecordService;
 import com.yeshi.fanli.service.inter.integral.IntegralExchangeService;
+import com.yeshi.fanli.service.inter.integral.IntegralGetService;
 import com.yeshi.fanli.service.inter.integral.IntegralTaskClassService;
 import com.yeshi.fanli.service.inter.integral.IntegralTaskRankService;
 import com.yeshi.fanli.service.inter.integral.IntegralTaskRecordService;
@@ -87,18 +87,21 @@
 
 	@Resource
 	private IntegralExchangeRecordService integralExchangeRecordService;
-	
+
 	@Resource
 	private IntegralDetailService integralDetailService;
-	
+
 	@Resource
 	private IntegralTaskRankService integralTaskRankService;
 
 	@Resource
 	private CodePublishRecordService codePublishRecordService;
-	
+
 	@Resource
 	private IntegralTaskService integralTaskService;
+
+	@Resource
+	private IntegralGetService integralGetService;
 
 	/**
 	 * 鑾峰彇浠诲姟鍒楄〃
@@ -130,19 +133,19 @@
 				list = new ArrayList<IntegralTaskClassVO>();
 			}
 			long count = integralTaskClassService.countTaskClass();
-			
+
 			// 鐢ㄦ埛绛惧埌
 			Integer signState = 0;
 			int signDays = 1;
 			if (page == 1) {
-				
+
 				// 绛惧埌
-				try { 
+				try {
 					signState = integralTaskClassService.finishedDailySign(uid);
 				} catch (Exception e) {
 					e.printStackTrace();
 				}
-				
+
 				UserInfoExtraVO extraVO = userInfoExtraService.getInfoExtraVOByUid(uid);
 				if (extraVO == null) {
 					out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛鐩稿叧淇℃伅涓嶅瓨鍦�"));
@@ -160,15 +163,15 @@
 					out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛绛夌骇涓嶅瓨鍦�"));
 					return;
 				}
-				
+
 				// 绛惧埌鏃ユ湡淇℃伅
 				DailySignVO dailySignVO = integralTaskClassService.getDailySignList(uid, userRank.getId());
 				if (dailySignVO != null) {
 					signDays = dailySignVO.getDays();
 				}
-				
+
 				boolean ejectSign = false;
-				if (signState == 1) 
+				if (signState == 1)
 					ejectSign = true;
 
 				data.put("signState", ejectSign);
@@ -178,12 +181,11 @@
 				data.put("dailySign", dailySignVO);
 			}
 
-			
 			for (IntegralTaskClassVO taskClassVO : list) {
 				String progress = taskClassVO.getProgress();
 				if (StringUtil.isNullOrEmpty(progress))
 					continue;
-				
+
 				Integer taskNum = taskClassVO.getTaskNum();
 				if (taskNum == null)
 					continue;
@@ -200,9 +202,10 @@
 
 					// 鏍规嵁澶╂暟鍙樺寲鏇存敼绛惧埌閲戦
 					Integer num = integralTaskRecordService.getNowdaySignNum(uid, taskClassVO.getId());
-					
+
 					String uniqueKeyTask = UniqueKeyEnum.dailySign.name() + num;
-					IntegralTask integralTask = integralTaskService.getByCidAndUniqueKey(taskClassVO.getId(), uniqueKeyTask);
+					IntegralTask integralTask = integralTaskService.getByCidAndUniqueKey(taskClassVO.getId(),
+							uniqueKeyTask);
 					Integer goldCoin = 0;
 					if (integralTask != null) {
 						goldCoin = integralTask.getGoldCoin();
@@ -214,7 +217,7 @@
 				} else {
 					taskClassVO.setLightUp(true);
 				}
-				
+
 				Integer dateType = 1; // 鏌ヨ褰撴棩
 				if (uniqueKey == UniqueKeyEnum.orderReward)
 					dateType = null; // 鏌ヨ鍘嗗彶
@@ -228,14 +231,14 @@
 						countFinished = integralTaskRecordService.countFinished(uid, id, dateType);
 				}
 				progress = progress.replace("{宸插畬鎴恾", countFinished + "").replace("{鎬讳换鍔", taskNum + "");
-				
+
 				if (signState == 0 && uniqueKey == UniqueKeyEnum.dailySign) {
 					progress = "鏈鍒�";
 					taskClassVO.setBtnName("绛惧埌");
-				} 
+				}
 				taskClassVO.setProgress(progress);
 			}
-			
+
 			data.put("count", count);
 			data.put("list", gson.toJson(list));
 			out.print(JsonUtil.loadTrueResult(data));
@@ -262,7 +265,7 @@
 		if ("android".equalsIgnoreCase(acceptData.getPlatform())) {
 			count = Integer.MAX_VALUE;
 		}
-		
+
 		List<IntegralTaskRecord> list = integralTaskRecordService.listNotReceived(count, uid);
 		if (list == null) {
 			list = new ArrayList<IntegralTaskRecord>();
@@ -281,17 +284,20 @@
 	 * 
 	 * @param acceptData
 	 * @param uid
-	 * @param ids  // 棰嗗彇id
-	 * @param gids // 鏈鍙杋d
+	 * @param ids
+	 *            // 棰嗗彇id
+	 * @param gids
+	 *            // 鏈鍙杋d
 	 * @param out
 	 */
 	@RequestMapping(value = "receiveGoldCoin", method = RequestMethod.POST)
-	public void receiveGoldCoin(AcceptData acceptData, Long uid, Integer type, String ids, String gids, PrintWriter out) {
+	public void receiveGoldCoin(AcceptData acceptData, Long uid, Integer type, String ids, String gids,
+			PrintWriter out) {
 		if (uid == null || uid <= 0) {
 			out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�"));
 			return;
 		}
-		
+
 		try {
 			// 鍏ㄩ儴棰嗗彇
 			if (type != null && type == 1) {
@@ -300,8 +306,8 @@
 				data.put("goldCoin", goldCoin);
 				out.print(JsonUtil.loadTrueResult(data));
 				return;
-			} 
-			
+			}
+
 			// 閮ㄥ垎棰嗗彇
 			Gson gson = new Gson();
 			Set<Long> idList = gson.fromJson(ids, new TypeToken<HashSet<Long>>() {
@@ -311,20 +317,21 @@
 				return;
 			}
 			Integer goldCoin = integralTaskRecordService.receiveGoldCoin(uid, idList);
-			Set<Long> gidList = gson.fromJson(gids, new TypeToken<HashSet<Long>>() {}.getType());
+			Set<Long> gidList = gson.fromJson(gids, new TypeToken<HashSet<Long>>() {
+			}.getType());
 			List<IntegralTaskRecord> list = null;
 			if (gidList != null && gidList.size() > 0) {
 				list = integralTaskRecordService.listNotReceivedExcludeId(5 - gidList.size(), uid, gidList);
 			} else {
 				list = integralTaskRecordService.listNotReceivedExcludeId(5, uid, null);
 			}
-			
+
 			if (list == null) {
 				list = new ArrayList<IntegralTaskRecord>();
 			}
 			GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
 			Gson gson2 = gsonBuilder.create();
-	
+
 			JSONObject data = new JSONObject();
 			data.put("goldCoin", goldCoin);
 			data.put("list", gson2.toJson(list));
@@ -365,7 +372,7 @@
 		if (list == null)
 			list = new ArrayList<IntegralExchange>();
 
-		//Long count = integralExchangeService.countValid();
+		// Long count = integralExchangeService.countValid();
 
 		GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
 		Gson gson = gsonBuilder.create();
@@ -510,9 +517,19 @@
 			out.print(JsonUtil.loadFalseResult("鐢ㄦ埛灏氭湭鐧诲綍"));
 			return;
 		}
-		
+
 		if (StringUtil.isNullOrEmpty(event)) {
 			out.print(JsonUtil.loadFalseResult("浜嬩欢涓虹┖"));
+			return;
+		}
+		IntegralTaskRecord record = null;
+		try {
+			record = integralGetService.addEventStatistic(uid, event, null);
+		} catch (IntegralGetException e) {
+			e.printStackTrace();
+		}
+		if (record == null) {
+			out.print(JsonUtil.loadFalseResult("娣诲姞澶辫触"));
 			return;
 		}
 
@@ -521,21 +538,17 @@
 				|| "scanTBCart".equalsIgnoreCase(event)) {
 			JSONObject notify = new JSONObject();
 			switch (event) {
-			
 			case "recommendSearch":
 				notify.put("name", "瀹屾垚涓�娆℃櫤鑳芥悳绱�");
-				notify.put("score", "+20閲戝竵");
 				break;
 			case "scanGoods":
 				notify.put("name", "瀹屾垚涓�娆″晢鍝佹祻瑙�");
-				notify.put("score", "+100閲戝竵");
 				break;
 			case "scanTBCart":
 				notify.put("name", "瀹屾垚涓�娆¤喘鐗╄溅娴忚");
-				notify.put("score", "+300閲戝竵");
 				break;
 			}
-
+			notify.put("score", String.format("+%s閲戝竵", record.getGoldCoin()));
 			data.put("notify", notify);
 		}
 		out.print(JsonUtil.loadTrueResult(data));
@@ -607,7 +620,6 @@
 		return gson;
 	}
 
-	
 	/**
 	 * 鏄庣粏璇︽儏
 	 * 
@@ -619,7 +631,8 @@
 	 *            骞翠唤
 	 * @param month
 	 *            鏈堜唤
-	 *  @param type  缁熻绫诲瀷  0鍏ㄩ儴  1
+	 * @param type
+	 *            缁熻绫诲瀷 0鍏ㄩ儴 1
 	 * @param out
 	 */
 	@RequestMapping(value = "getDetails")
@@ -634,7 +647,7 @@
 			out.print(JsonUtil.loadFalseResult(1, "鏃ユ湡涓嶅畬鏁�"));
 			return;
 		}
-		
+
 		Date date = null;
 
 		if (year != null && month != null) {

--
Gitblit v1.8.0