From aa552facf6d833acab0d3e3e29bda2a0fb826ffe Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期一, 25 十一月 2019 16:14:13 +0800
Subject: [PATCH] 品牌缓存生效

---
 fanli/src/main/java/com/yeshi/fanli/controller/apph5/AppH5UserController.java |  111 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 109 insertions(+), 2 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/apph5/AppH5UserController.java b/fanli/src/main/java/com/yeshi/fanli/controller/apph5/AppH5UserController.java
index ef7b945..ab6df7d 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/apph5/AppH5UserController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/apph5/AppH5UserController.java
@@ -37,7 +37,7 @@
 	 * @param callback
 	 * @param out
 	 */
-	@RequestMapping(value = "getRadioList")
+	// @RequestMapping(value = "getRadioList")
 	public void getRadioList(String callback, PrintWriter out) {
 
 		try {
@@ -57,7 +57,7 @@
 
 				String prize = generateAward();
 				if (prize == null) {
-					prize = "鎶戒腑涓�寮犵鍒╁厤鍗曞埜";
+					prize = "涓�寮犵鍒╁厤鍗曞埜";
 				}
 
 				dataInfo.put("pic", shamUser.getPicUrl());
@@ -136,6 +136,113 @@
 		return prize;
 	}
 
+	
+
+	/**
+	 * 鑾峰彇鎶藉骞垮憡鍒楄〃
+	 * 
+	 * @param callback
+	 * @param out
+	 */
+	// @RequestMapping(value = "getDailyRadioList")
+	public void getDailyRadioList(String callback, PrintWriter out) {
+
+		try {
+			// 闅忔満20鏉℃暟鎹�
+			List<ShamUser> listUser = shamUserService.listRandUser(20);
+
+			JSONArray array = new JSONArray();
+			for (ShamUser shamUser : listUser) {
+				JSONObject dataInfo = new JSONObject();
+
+				String name = shamUser.getName();
+				if (name.length() == 1) {
+					name = "Jx****" + name;
+				} else {
+					name = name.substring(0, 1) + "****" + name.substring(name.length() - 2, name.length() - 1);
+				}
+
+				String prize = dailyGenerateAward();
+				if (prize == null) {
+					prize = "涓ゅ紶杩斿埄濂栧姳鍒�";
+				}
+
+				dataInfo.put("pic", shamUser.getPicUrl());
+				dataInfo.put("content", name + "锛屾娊涓�" + prize);
+				array.add(dataInfo);
+			}
+
+			JSONObject data = new JSONObject();
+			data.put("result_list", array);
+
+			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
+
+		} catch (Exception e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔澶辫触"));
+			e.printStackTrace();
+		}
+	}
+
+
+	/**
+	 * 鐢熸垚濂栭」-澶╁ぉ鎶�
+	 * 
+	 * @return
+	 */
+	public String dailyGenerateAward() {
+
+		RandomGift randomGift1 = new RandomGift();
+		randomGift1.prize = "鎶戒腑鍗庝负鎵嬫満20涓�鍙�";
+		randomGift1.probability = 2;
+
+		RandomGift randomGift2 = new RandomGift();
+		randomGift2.prize = "鐜伴噾绾㈠寘楼188";
+		randomGift2.probability = 5;
+
+		RandomGift randomGift3 = new RandomGift();
+		randomGift3.prize = "鐜伴噾绾㈠寘楼88";
+		randomGift3.probability = 13;
+
+		RandomGift randomGift4 = new RandomGift();
+		randomGift4.prize = "涓ゅ紶杩斿埄濂栧姳鍒�";
+		randomGift4.probability = 40;
+
+		RandomGift randomGift5 = new RandomGift();
+		randomGift5.prize = "涓�寮犺繑鍒╁鍔卞埜";
+		randomGift5.probability = 40;
+
+		List<RandomGift> giftList = new ArrayList<RandomGift>();
+		giftList.add(randomGift1);
+		giftList.add(randomGift2);
+		giftList.add(randomGift3);
+		giftList.add(randomGift4);
+		giftList.add(randomGift5);
+
+		long result = (1 + Math.round(Math.random() * (99)));
+
+		int minRange = 0;
+		int maxRange = 0;
+
+		String prize = null;
+
+		for (int i = 0; i < giftList.size(); i++) {
+			RandomGift obj2 = giftList.get(i);
+			int probability = obj2.probability;
+
+			maxRange = maxRange + probability;
+			minRange = 100 - maxRange;
+
+			if (probability != 0) {
+				if (result > minRange && result <= maxRange) {
+					prize = obj2.prize;
+					break;
+				}
+			}
+		}
+
+		return prize;
+	}
+	
 	class RandomGift {
 		public String prize;// 濂栭」
 		public int probability; // 姒傜巼

--
Gitblit v1.8.0