From 9c09cead959dbeef292628f345e5f80c30fc3d17 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期一, 19 八月 2019 17:42:44 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/mater-1.6.0' into div

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/v2/TaoLiJinControllerV2.java |  129 ++++++++++++++++++++++++++++++-------------
 1 files changed, 90 insertions(+), 39 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/TaoLiJinControllerV2.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/TaoLiJinControllerV2.java
index 2762ca9..a4d2178 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/TaoLiJinControllerV2.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v2/TaoLiJinControllerV2.java
@@ -39,6 +39,7 @@
 import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
 import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBriefExtra;
 import com.yeshi.fanli.exception.tlj.UserTaoLiJinOriginException;
+import com.yeshi.fanli.exception.tlj.UserTaoLiJinRecordException;
 import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
 import com.yeshi.fanli.service.inter.config.ConfigService;
 import com.yeshi.fanli.service.inter.goods.ShareGoodsService;
@@ -212,8 +213,8 @@
 			return;
 		}
 
-		// 杩囨湡
-		userTaoLiJinOriginService.overdueHongBao(uid);
+		// 杩囨湡 -鍙栨秷鏀跺洖
+		// userTaoLiJinOriginService.overdueHongBao(uid);
 
 		// 鎴戠殑娣樼ぜ閲�
 		BigDecimal tlj = null;
@@ -233,18 +234,36 @@
 		BigDecimal thisMonthWin = userTaoLiJinOriginService.countMoneyByDate(uid, 3);
 		BigDecimal lastMonthWin = userTaoLiJinOriginService.countMoneyByDate(uid, 4);
 
+		BigDecimal zero = new BigDecimal(0);
 		// 娑堣��
 		BigDecimal todayUse = userTaoLiJinDetailService.countUseMoneyByDate(uid, 1);
+		if (todayUse == null || todayUse.compareTo(zero) > 0) {
+			todayUse = zero;
+		}
+		
 		BigDecimal yesterdayUse = userTaoLiJinDetailService.countUseMoneyByDate(uid, 2);
+		if (yesterdayUse == null || yesterdayUse.compareTo(zero) > 0) {
+			yesterdayUse = zero;
+		}
 		BigDecimal thisMonthUse = userTaoLiJinDetailService.countUseMoneyByDate(uid, 3);
+		if (thisMonthUse == null || thisMonthUse.compareTo(zero) > 0) {
+			thisMonthUse = zero;
+		}
 		BigDecimal lastMonthUse = userTaoLiJinDetailService.countUseMoneyByDate(uid, 4);
+		if (lastMonthUse == null || lastMonthUse.compareTo(zero) > 0) {
+			lastMonthUse = zero;
+		}
+		
+		String giveMin = configTaoLiJinService.getValueByKey("give_min_amount");
 
 		// 闂彿閾炬帴
-		String helpLink = configTaoLiJinService.getValueByKey("hongbao_help_link");
-
+		String helpLink = configTaoLiJinService.getValueByKey("hongbao_help_link",null);
+
 		JSONObject data = new JSONObject();
 		data.put("tlj", tlj.setScale(2).toString());
-		data.put("helpLink", helpLink);
+		data.put("giveMin", giveMin);
+		data.put("giveTip", "娉�:璧犻�佹帹骞跨孩鍖呴噾棰濊嚦灏�"+ giveMin +"鍏�");
+		data.put("helpLink", configTaoLiJinService.getValueByKey("hongbao_help_link"));
 		data.put("countShare", countShare);
 		data.put("todayWin", todayWin.setScale(2).toString());
 		data.put("yesterdayWin", yesterdayWin.setScale(2).toString());
@@ -383,7 +402,7 @@
 				// 宸查鍙�
 				money = deviceRecord.getMoney();
 			} else {
-				String value = configTaoLiJinService.getValueByKey("hongbao_newbies");
+				String value = configTaoLiJinService.getValueByKey("hongbao_newbies",null);
 				if (StringUtil.isNullOrEmpty(value)) {
 					out.print(JsonUtil.loadFalseResult(1, "绯荤粺绾㈠寘涓嶅瓨鍦�"));
 					return;
@@ -393,7 +412,7 @@
 			}
 
 			JSONObject data = new JSONObject();
-			data.put("icon", configTaoLiJinService.getValueByKey("taolijin_system_icon"));
+			data.put("icon", configTaoLiJinService.getValueByKey("taolijin_system_icon",null));
 			data.put("title", "鏂颁汉绾㈠寘");
 			data.put("content", "鑷喘鐩存帴鎶电幇锛屼紭鎯犵湡瀹炲彲瑙侊紒");
 			data.put("type", 1);
@@ -401,16 +420,17 @@
 			data.put("usage", "棰嗗彇鎴愬姛锛屽凡瀛樺叆鈥滄垜鐨�-鎺ㄥ箍绾㈠寘鈥�");
 			data.put("jumpName", "鍘讳娇鐢�");
 			data.put("jumpDetail", jumpDetailV2Service.getByTypeCache("share_goods_hot"));
-			data.put("tip", configTaoLiJinService.getValueByKey("hongbao_newbies_tip"));
-			data.put("rules", configTaoLiJinService.getValueByKey("newbies_rules_link"));
+			data.put("tip", configTaoLiJinService.getValueByKey("hongbao_newbies_tip",null));
+			data.put("rules", configTaoLiJinService.getValueByKey("newbies_rules_link",null));
 
 			out.print(JsonUtil.loadTrueResult(data));
 			return;
 		}
 
 		// 鐧诲綍鐢ㄦ埛
+		boolean isReceive = false;
 		JSONObject data = new JSONObject();
-		data.put("icon", configTaoLiJinService.getValueByKey("taolijin_system_icon"));
+		data.put("icon", configTaoLiJinService.getValueByKey("taolijin_system_icon",null));
 
 		if (type.equals(TaoLiJinOriginEnum.newbiesWin.name())) {
 			BigDecimal hasMoney = null;
@@ -434,8 +454,8 @@
 			data.put("usage", "棰嗗彇鎴愬姛锛屽凡瀛樺叆鈥滄垜鐨�-鎺ㄥ箍绾㈠寘鈥�");
 			data.put("jumpName", "鍘讳娇鐢�");
 			data.put("jumpDetail", jumpDetailV2Service.getByTypeCache("share_goods_hot"));
-			data.put("tip", configTaoLiJinService.getValueByKey("hongbao_newbies_tip"));
-			data.put("rules", configTaoLiJinService.getValueByKey("newbies_rules_link"));
+			data.put("tip", configTaoLiJinService.getValueByKey("hongbao_newbies_tip",null));
+			data.put("rules", configTaoLiJinService.getValueByKey("newbies_rules_link",null));
 
 		} else if (type.equals(TaoLiJinOriginEnum.rankWin.name())) {
 			boolean isRank = false;
@@ -443,6 +463,7 @@
 			UserTaoLiJinOrigin userTaoLiJin = userTaoLiJinOriginService.getRankByThisMonth(uid, type);
 			if (userTaoLiJin != null) { // 宸查鍙�
 				isRank = true;
+				isReceive = true;
 				hasMoney = userTaoLiJin.getMoney();
 			} else {
 				isRank = false;
@@ -470,8 +491,8 @@
 				data.put("money", "鏈湀璐︽埛绛夌骇鏈揪鍒癨r\n缁х画鍔犳补");
 				data.put("jumpName", "鍘绘煡鐪�");
 				data.put("jumpDetail", jumpDetailV2Service.getByTypeCache("user_rank"));
-				data.put("tip", configTaoLiJinService.getValueByKey("hongbao_rank_not_enough_tip"));
-				data.put("rules", configTaoLiJinService.getValueByKey("rank_rules_link"));
+				data.put("tip", configTaoLiJinService.getValueByKey("hongbao_rank_not_enough_tip",null));
+				data.put("rules", configTaoLiJinService.getValueByKey("rank_rules_link",null));
 				out.print(JsonUtil.loadTrueResult(data));
 				return;
 			} else {
@@ -479,11 +500,15 @@
 				data.put("content", "鎺ㄥ箍绾㈠寘锛屽ソ鍙嬬鍒╋紒");
 				data.put("type", 1);
 				data.put("money", hasMoney.setScale(2).toString());
-				data.put("usage", "棰嗗彇鎴愬姛锛屽凡瀛樺叆鈥滄垜鐨�-鎺ㄥ箍绾㈠寘鈥�");
+				if (isReceive) {
+					data.put("usage", "鏈湀棰嗗彇锛屽凡瀛樺叆鈥滄垜鐨�-鎺ㄥ箍绾㈠寘鈥�");
+				} else {
+					data.put("usage", "棰嗗彇鎴愬姛锛屽凡瀛樺叆鈥滄垜鐨�-鎺ㄥ箍绾㈠寘鈥�");
+				}
 				data.put("jumpName", "鍘讳娇鐢�");
 				data.put("jumpDetail", jumpDetailV2Service.getByTypeCache("share_goods_hot"));
-				data.put("tip", configTaoLiJinService.getValueByKey("hongbao_rank_tip"));
-				data.put("rules", configTaoLiJinService.getValueByKey("rank_rules_link"));
+				data.put("tip", configTaoLiJinService.getValueByKey("hongbao_rank_tip",null));
+				data.put("rules", configTaoLiJinService.getValueByKey("rank_rules_link",null));
 			}
 
 		} else {
@@ -535,7 +560,7 @@
 			}
 
 			// 璁$畻鎺ㄥ箍绾㈠寘
-			String warningRate = configTaoLiJinService.getValueByKey("warning_value");
+			String warningRate = configTaoLiJinService.getValueByKey("warning_value",new Date());
 			BigDecimal spreadMoney = TaoLiJinUtil.getSpreadMoney(warningRate, taoBaoGoodsBrief);
 
 			// 鎺ㄥ箍绾㈠寘 涓嶈兘灏忎簬1
@@ -559,13 +584,12 @@
 			array.add(gson.toJson(extra));
 		}
 
-		executor.execute(new Runnable() {
-			@Override
-			public void run() {
-				// 杩囨湡
-				userTaoLiJinOriginService.overdueHongBao(uid);
-			}
-		});
+		/*// 杩囨湡 -鍙栨秷鏀跺洖
+		 * executor.execute(new Runnable() {
+		 * 
+		 * @Override public void run() {
+		 * userTaoLiJinOriginService.overdueHongBao(uid); } });
+		 */
 
 		JSONObject data = new JSONObject();
 		data.put("count", array.size());
@@ -598,7 +622,8 @@
 		Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
 				.excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
 		
-		boolean isNewUser = userInfoExtraService.isNewUser(uid);
+		//鍙栨秷鏂颁汉鑷喘
+		boolean isNewUser = false;//userInfoExtraService.isNewUser(uid);
 		if (isNewUser) {
 			// 鍒ゅ畾涓鸿�佺敤鎴凤細 鏂颁汉鍙浣跨敤浜嗘柊浜虹孩鍖咃紝涔熷氨鏄偅1鍧楅挶锛岄偅涔堬紝浠栫湅鍒扮殑鍒嗕韩鐖嗘涓殑鍟嗗搧-灏卞彧鑳藉垎浜��
 			long countRecord = userTaoLiJinRecordService.countRecordByUid(uid);
@@ -608,8 +633,8 @@
 		}
 		
 		
-		BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
-		BigDecimal shareRate = hongBaoManageService.getShareRate();
+		BigDecimal fanLiRate = hongBaoManageService.getTLJShareRate(System.currentTimeMillis());
+		BigDecimal shareRate = hongBaoManageService.getTLJShareRate(System.currentTimeMillis());
 		for (ShareHotGoods hotGoods : listHot) {
 			TaoBaoGoodsBrief taoBaoGoodsBrief = hotGoods.getGoods();
 			if (taoBaoGoodsBrief == null) {
@@ -617,7 +642,7 @@
 			}
 			
 			// 璁$畻鎺ㄥ箍绾㈠寘
-			String warningRate = configTaoLiJinService.getValueByKey("warning_value");
+			String warningRate = configTaoLiJinService.getValueByKey("warning_value",new Date());
 			BigDecimal spreadMoney = TaoLiJinUtil.getSpreadMoney(warningRate, taoBaoGoodsBrief);
 			
 			// 鎺ㄥ箍绾㈠寘 涓嶈兘灏忎簬1
@@ -650,13 +675,12 @@
 			array.add(gson.toJson(detailVO));
 		}
 		
-		executor.execute(new Runnable() {
-			@Override
-			public void run() {
-				// 杩囨湡
-				userTaoLiJinOriginService.overdueHongBao(uid);
-			}
-		});
+		/*
+		 * executor.execute(new Runnable() {
+		 * 
+		 * @Override public void run() { // 杩囨湡
+		 * userTaoLiJinOriginService.overdueHongBao(uid); } });
+		 */
 		
 		JSONObject data = new JSONObject();
 		data.put("count", array.size());
@@ -740,6 +764,7 @@
 		out.print(JsonUtil.loadTrueResult(data));
 	}
 	
+	
 	/**
 	 * 鍒嗕韩鐖嗘鍟嗗搧-闄愪簬娣樼ぜ閲�
 	 * 
@@ -775,11 +800,12 @@
 				continue;
 			}
 
+
 			GoodsDetailVO detailVO = GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, null, proportion, proportion);
 			// 鍘绘帀鏍囩
 			detailVO.setLabels(null);
-
 			
+
 			MoneyInfoVO moneyInfo = detailVO.getMoneyInfo();
 			moneyInfo.setMoneyType(2);
 			detailVO.setMoneyInfo(moneyInfo);
@@ -787,14 +813,16 @@
 			String hongBao = spreadMoney.toString();
 			ReduceHongBao vo = new ReduceHongBao();
 			vo.setLeft(hotGoods.getLeftHongBaoCount());
-			vo.setMoney(hongBao);
-			vo.setName("浠樻绔嬪噺  楼" + hongBao);
+			vo.setMoney(" 楼" + hongBao);
+			vo.setName("浠樻绔嬪噺 ");
 			vo.setTip("");
 			vo.setTotal(hotGoods.getTotalHongBaoCount());
 			
 			OtherInfo otherInfo = new OtherInfo();
 			otherInfo.setReduceHongBao(vo);
 			detailVO.setOtherInfo(otherInfo);
+			
+			array.add(gson.toJson(detailVO));
 		}
 
 		if (page > 1)
@@ -815,5 +843,28 @@
 		}
 		out.print(JsonUtil.loadTrueResult(data));
 	}
+	
+	
+	/**
+	 * 璧犻�佹窐绀奸噾
+	 * @param acceptData
+	 * @param uid
+	 * @param amount
+	 * @param out
+	 */
+	@RequestMapping(value = "giveTLJ", method = RequestMethod.POST)
+	public void giveTLJ(AcceptData acceptData, Long uid, BigDecimal amount, PrintWriter out) {
+		if (uid == null || uid <= 0) {
+			out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�"));
+			return;
+		}
+		
+		try {
+			String tips = userTaoLiJinRecordService.giveTaolijin(uid, amount);
+			out.print(JsonUtil.loadTrueResult(tips));
+		} catch (UserTaoLiJinRecordException e) {
+			out.print(JsonUtil.loadFalseResult(1, e.getMsg()));
+		}
+	}
 
 }

--
Gitblit v1.8.0