From 20f1758957a19bb5fec47fcc1c83818ee268676b Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期五, 11 一月 2019 14:16:07 +0800
Subject: [PATCH] 修改资金统计信息,优化H5的商品详情

---
 fanli/src/main/java/com/yeshi/fanli/controller/admin/OrderAdminController.java |  311 ++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 289 insertions(+), 22 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/admin/OrderAdminController.java b/fanli/src/main/java/com/yeshi/fanli/controller/admin/OrderAdminController.java
index 2da03a5..ff81b8f 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/admin/OrderAdminController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/admin/OrderAdminController.java
@@ -17,9 +17,11 @@
 
 import com.google.gson.Gson;
 import com.google.gson.reflect.TypeToken;
+import com.yeshi.fanli.controller.admin.utils.AdminUtils;
 import com.yeshi.fanli.entity.admin.OrderAdmin;
 import com.yeshi.fanli.service.inter.count.HongBaoV2CountService;
 import com.yeshi.fanli.service.inter.hongbao.HongBaoService;
+import com.yeshi.fanli.service.inter.order.CommonOrderCountService;
 import com.yeshi.fanli.service.inter.order.OrderService;
 import com.yeshi.fanli.tag.PageEntity;
 import com.yeshi.fanli.util.Constant;
@@ -37,6 +39,9 @@
 
 	@Resource
 	private HongBaoV2CountService hongBaoV2CountService;
+	
+	@Resource
+	private CommonOrderCountService commonOrderCountService;
 
 	@RequestMapping(value = "getOrderList", method = RequestMethod.POST)
 	public void getOrderList(int pageIndex, String key, PrintWriter out) {
@@ -129,7 +134,7 @@
 					resultList = new ArrayList<Object>();
 				}
 				channelData.put("name", channel);
-				channelData.put("infos", resultList);
+				channelData.put("data_list", resultList);
 				array.add(channelData);
 			}
 
@@ -195,7 +200,7 @@
 		}
 
 		try {
-			JSONObject data = countHongBao(channelArray, dateType, state, year, startTime,  endTime, 1);
+			JSONObject data = countHistoryHongBao(channelArray, dateType, state, year, startTime,  endTime, 1);
 			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
 		} catch (Exception e) {
 			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("绯荤粺寮傚父"));
@@ -218,14 +223,15 @@
 	public void getHongBaoMoney(String callback,String channelArray, Integer dateType, Integer state,
 			String year, String startTime, String endTime, PrintWriter out) {
 
-		String validateMsg = validateParams(dateType, startTime, endTime);
+		String validateMsg = AdminUtils.validateParams(dateType, startTime, endTime);
 		if (validateMsg != null) {
 			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg));
 			return;
 		}
-
+		
 		try {
-			JSONObject data = countHongBao( channelArray, dateType, state, year, startTime, endTime, 2);
+			
+			JSONObject data = countHistoryHongBao(channelArray, dateType, state, year, startTime,  endTime, 1);
 			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
 		} catch (Exception e) {
 			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("绯荤粺寮傚父"));
@@ -233,6 +239,10 @@
 		}
 	}
 
+	
+	
+	
+	
 	
 
 	
@@ -247,7 +257,7 @@
 	 * @return
 	 * @throws Exception
 	 */
-	public JSONObject countHongBao(String channelArray, Integer dateType, Integer state, String year, String startTime,
+	public JSONObject countHistoryHongBao(String channelArray, Integer dateType, Integer state, String year, String startTime,
 			String endTime, int countType) throws Exception {
 
 		if (dateType != 1 && (!StringUtil.isNullOrEmpty(startTime) || !StringUtil.isNullOrEmpty(endTime))) {
@@ -255,6 +265,7 @@
 			endTime = null;
 		}
 
+		
 		List<String> channelList = null;
 		if (channelArray != null && channelArray.trim().length() > 0) {
 			Gson gson = new Gson();
@@ -266,36 +277,292 @@
 			channelList.add("all");
 		}
 
-		JSONArray array = new JSONArray();
-		for (String channel : channelList) {
-			JSONObject channelData = new JSONObject();
-
+		
+		if (dateType == 1 && year != null) {
+			year = null; // 璁剧疆涓虹┖
+		} else if (dateType == 2) {
+			if (startTime != null) 
+				startTime = null; 
 			
-			List<Map<String, Object>> resultList = null;
+			if (endTime != null) 
+				endTime = null; 
+			
+		} else if (dateType == 3) {
+			if (year != null)
+				year = null; 
+			
+			if (startTime != null) 
+				startTime = null; 
+			
+			if (endTime != null) 
+				endTime = null; 
+		}
+		
+		Gson gson = new Gson();
+		Object objectDate = null;
+		List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year);
+		
+		JSONArray line_list = new JSONArray();
+		for (String channel : channelList) {
+			List<Map<String, Object>> list = null;
 			if (countType == 1 ) {
-				resultList = hongBaoV2CountService.countHongBaoNum(channel, dateType, state, year, 
+				list = hongBaoV2CountService.countHongBaoNum(channel, dateType, state, year, 
 						startTime, endTime);
 			} else if (countType == 2) {
-				resultList = hongBaoV2CountService.countHongBaoMoney(channel, dateType, state, year, 
+				list = hongBaoV2CountService.countHongBaoMoney(channel, dateType, state, year, 
 						startTime, endTime);
 			}
-
-			if (resultList == null) {
-				resultList = new ArrayList<Map<String, Object>>();
-			}
-
+			
 			if ("all".equalsIgnoreCase(channel)) {
 				channel = "鎬昏";
 			}
-			channelData.put("name", channel);
-			channelData.put("infos", resultList);
-			array.add(channelData);
+			
+			JSONObject innerList = new JSONObject();
+			innerList.put("name", channel);
+
+			if (dateType != 3) {
+				innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateList, list)));
+			} else {
+				// 骞磋鍥�
+				Map<String, Object> map = AdminUtils.yearsDataFactory(list);
+
+				if (objectDate == null) {
+					objectDate = map.get("date");
+				}
+				innerList.put("data", gson.toJson(map.get("value")));
+			}
+			
+			line_list.add(innerList);
 		}
 
+
 		JSONObject data = new JSONObject();
-		data.put("result_list", array);
+		if (objectDate != null) {
+			data.put("xAxis_list", gson.toJson(objectDate));
+		} else {
+			data.put("xAxis_list", gson.toJson(dateList));
+		}
+		
+		data.put("line_list", line_list);
 		
 		return data;
 	}
 
+	
+	/**
+	 * 鍒嗙被鍨嬭鍗曟暟涓庢瘮渚� 
+	 * @param callback
+	 * @param dateType 鏃� -1 鏈�-2 骞�-3
+	 * @param type     杩斿埄璁㈠崟-1  鍒嗕韩璁㈠崟-2  閭�璇疯鍗�-3 
+	 * @param year
+	 * @param startTime
+	 * @param endTime
+	 * @param out
+	 */
+	@RequestMapping(value = "getTypeRate")
+	public void getTypeRate(String callback, Integer dateType, Integer type, String year,
+			String startTime, String endTime, PrintWriter out) {
+		
+		if (StringUtil.isNullOrEmpty(startTime) || StringUtil.isNullOrEmpty(endTime)) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇烽�夋嫨姝g‘鏃堕棿鍖洪棿"));
+			return;
+		}
+		
+		if (type == null || dateType ==null) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("瑙嗗浘绫诲瀷銆佽鍗曠被鍨嬩笉鑳戒负绌�"));
+			return;
+		}
+		
+		try {
+
+			List<Map<String, Object>> resultList = hongBaoV2CountService.getProportionByType(dateType,
+					type, year, startTime, endTime);
+			
+			if (resultList == null) {
+				resultList = new ArrayList<Map<String, Object>>();
+			}
+
+			JSONObject innerList = new JSONObject();
+			if (type == 1) {
+				innerList.put("name", "杩斿埄璁㈠崟");
+			} else if (type == 2) {
+				innerList.put("name", "鍒嗕韩璁㈠崟");
+			} else if (type == 3) {
+				innerList.put("name", "閭�璇疯鍗�");
+			}
+			innerList.put("data_list", resultList);
+			
+			JSONArray outList = new JSONArray();
+			outList.add(innerList);
+			
+			JSONObject data = new JSONObject();
+			data.put("result_list", outList);
+			
+			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
+
+		} catch (Exception e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
+			e.printStackTrace();
+		}
+	}
+	
+	/**
+	 * 璁㈠崟璺熻釜鍑嗙‘鐜�(杩斿埄鍒哥敤鎴疯鍗�/娣樺疂鑱旂洘璁㈠崟)
+	 * @param callback
+	 * @param dateType
+	 * @param year
+	 * @param startTime
+	 * @param endTime
+	 * @param out
+	 */
+	@RequestMapping(value = "getTrackAccuracyRate")
+	public void getTrackAccuracyRate(String callback, Integer dateType, String year,
+			String startTime, String endTime, PrintWriter out) {
+		
+		if (StringUtil.isNullOrEmpty(startTime) || StringUtil.isNullOrEmpty(endTime)) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇烽�夋嫨姝g‘鏃堕棿鍖洪棿"));
+			return;
+		}
+		
+		try {
+
+			List<Map<String, Object>> resultList = commonOrderCountService.getTrackAccuracyRate(dateType,
+					 year, startTime, endTime);
+			
+			if (resultList == null) {
+				resultList = new ArrayList<Map<String, Object>>();
+			}
+			
+			JSONObject innerList = new JSONObject();
+			innerList.put("name", "鍑嗙‘鐜�");
+			innerList.put("data_list", resultList);
+			
+			JSONArray outList = new JSONArray();
+			outList.add(innerList);
+			
+			JSONObject data = new JSONObject();
+			data.put("result_list", outList);
+			
+			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
+
+		} catch (Exception e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
+			e.printStackTrace();
+		}
+	}
+	
+	
+	/**
+	 * 褰撳墠鏈敹璐ц鍗曟暟
+	 * @param callback
+	 * @param type 璁㈠崟鐘舵��-鏆傛湭浣跨敤
+	 * @param out
+	 */
+	@RequestMapping(value = "getHistoryUnreceived")
+	public void getHistoryUnreceived(String callback, Integer type, PrintWriter out) {
+		try {
+			
+			Long total = commonOrderCountService.countByState(1);
+			if (total == null) {
+				total = 0L;
+			}
+			JSONObject data = new JSONObject();
+			data.put("total", total);
+			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
+		} catch (Exception e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
+			e.printStackTrace();
+		}
+	}
+	
+	
+	
+	/**
+	 * 缁存潈璁㈠崟鏁�
+	 * @param callback
+	 * @param dateType
+	 * @param year
+	 * @param startTime
+	 * @param endTime
+	 * @param out
+	 */
+	@RequestMapping(value = "getWeiQaunOrderNumber")
+	public void getWeiQaunOrderNumber(String callback, Integer dateType, String year,
+			String startTime, String endTime, PrintWriter out) {
+		
+		if (StringUtil.isNullOrEmpty(startTime) || StringUtil.isNullOrEmpty(endTime)) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇烽�夋嫨姝g‘鏃堕棿鍖洪棿"));
+			return;
+		}
+		try {
+
+			List<Map<String, Object>> resultList = commonOrderCountService.countWeiQaunOrderNumber(dateType,
+					 year, startTime, endTime);
+			
+			if (resultList == null) {
+				resultList = new ArrayList<Map<String, Object>>();
+			}
+
+			JSONObject innerList = new JSONObject();
+			innerList.put("name", "鏁伴噺");
+			innerList.put("data_list", resultList);
+			
+			JSONArray outList = new JSONArray();
+			outList.add(innerList);
+			
+			JSONObject data = new JSONObject();
+			data.put("result_list", outList);
+			
+			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
+
+		} catch (Exception e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
+			e.printStackTrace();
+		}
+	}
+	
+	
+	/**
+	 * 缁存潈璁㈠崟閲戦
+	 * @param callback
+	 * @param dateType
+	 * @param year
+	 * @param startTime
+	 * @param endTime
+	 * @param out
+	 */
+	@RequestMapping(value = "getWeiQaunOrderMoney")
+	public void getWeiQaunOrderMoney(String callback, Integer dateType, String year,
+			String startTime, String endTime, PrintWriter out) {
+		
+		if (StringUtil.isNullOrEmpty(startTime) || StringUtil.isNullOrEmpty(endTime)) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇烽�夋嫨姝g‘鏃堕棿鍖洪棿"));
+			return;
+		}
+		try {
+
+			List<Map<String, Object>> resultList = commonOrderCountService.countWeiQaunOrderMoney(dateType,
+					 year, startTime, endTime);
+			
+			if (resultList == null) {
+				resultList = new ArrayList<Map<String, Object>>();
+			}
+
+			JSONObject innerList = new JSONObject();
+			innerList.put("name", "閲戦");
+			innerList.put("data_list", resultList);
+			
+			JSONArray outList = new JSONArray();
+			outList.add(innerList);
+			
+			JSONObject data = new JSONObject();
+			data.put("result_list", outList);
+			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
+
+		} catch (Exception e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
+			e.printStackTrace();
+		}
+	}
+	
 }

--
Gitblit v1.8.0