From 17b490541bd688abcbc489937e6b3b800103cb9a Mon Sep 17 00:00:00 2001
From: yujian <yujian>
Date: 星期四, 10 一月 2019 15:11:20 +0800
Subject: [PATCH] 后台统计 + 提现历史到账

---
 fanli/src/main/java/com/yeshi/fanli/controller/admin/ExtractAdminController.java |  269 +++++++++++++++++++++++++++++++++++------------------
 1 files changed, 178 insertions(+), 91 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/admin/ExtractAdminController.java b/fanli/src/main/java/com/yeshi/fanli/controller/admin/ExtractAdminController.java
index 1e1dcd2..cfb1355 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/admin/ExtractAdminController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/admin/ExtractAdminController.java
@@ -27,9 +27,12 @@
 
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
+import com.google.gson.reflect.TypeToken;
+import com.yeshi.fanli.controller.admin.utils.AdminUtils;
 import com.yeshi.fanli.entity.bus.user.Extract;
 import com.yeshi.fanli.entity.bus.user.ExtractAuditRecord;
 import com.yeshi.fanli.entity.bus.user.HongBao;
+import com.yeshi.fanli.entity.bus.user.HongBaoV2;
 import com.yeshi.fanli.entity.bus.user.Order;
 import com.yeshi.fanli.entity.bus.user.OrderItem;
 import com.yeshi.fanli.entity.bus.user.UserInfo;
@@ -45,6 +48,7 @@
 import com.yeshi.fanli.service.AdminUserService;
 import com.yeshi.fanli.service.inter.config.ConfigService;
 import com.yeshi.fanli.service.inter.count.ExtractCountService;
+import com.yeshi.fanli.service.inter.count.HongBaoV2CountService;
 import com.yeshi.fanli.service.inter.count.UserInfoCountService;
 import com.yeshi.fanli.service.inter.hongbao.HongBaoService;
 import com.yeshi.fanli.service.inter.order.OrderItemServcie;
@@ -92,6 +96,9 @@
 
 	@Resource
 	private HongBaoService hongBaoService;
+	
+	@Resource
+	private HongBaoV2CountService hongBaoV2CountService;
 
 	@Resource
 	private AdminUserService adminUserService;
@@ -802,8 +809,11 @@
 		try {
 
 			// 缁熻宸查鍙栭噾棰� 璐︽埛鍘嗗彶鎬绘敹鐩�
-			double receiveMoneys = hongBaoService.countReceiveMoneysByUid(uid);
-
+			BigDecimal receiveMoneys = hongBaoV2CountService.countMoneyByUidAndState(uid, HongBaoV2.STATE_YILINGQU);
+			if (receiveMoneys == null) {
+				receiveMoneys = new BigDecimal(0);
+			}
+			
 			// 鍘嗗彶鎻愮幇鎴愬姛閲戦
 			double successMoneys = extractCountService.countSuccessMoneysByUid(uid);
 
@@ -822,7 +832,6 @@
 			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
 
 		} catch (Exception e) {
-			// TODO: handle exception
 			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
 			e.printStackTrace();
 		}
@@ -1428,8 +1437,8 @@
 	/**
 	 * 缁熻瀹℃牳娆℃暟 
 	 * @param callback
-	 * @param state 瀹℃牳鐘舵�侊細鎵�鏈�-绌哄�兼垨鑰呬笉浼�  閫氳繃-1  鎷掔粷- 2
-	 * @param type 缁熻绫诲瀷  1-24灏忔椂  2-鎵�鏈�
+	 * @param state 瀹℃牳鐘舵�侊細鎵�鏈�-3  閫氳繃-1  鎷掔粷- 2
+	 * @param type 缁熻绫诲瀷  1-24灏忔椂  2-鎵�鏈�3
 	 * @param dateType 绫诲瀷  1鏃�  2鏈�  3骞�
 	 * @param year 2018
 	 * @param startTime 2018-12-01 
@@ -1437,41 +1446,80 @@
 	 * @param out
 	 */
 	@RequestMapping(value = "getAuditTotal")
-	public void getAuditTotal(String callback,Integer state, Integer dateType, String year, 
+	public void getAuditTotal(String callback, String stateArray, Integer dateType, 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;
 		}
 		
-		if (dateType != 1 && (!StringUtil.isNullOrEmpty(startTime) || !StringUtil.isNullOrEmpty(endTime))) {
-			startTime = null;
-			endTime = null;
+		if (dateType == 1 && year != null) {
+			year = null; // 璁剧疆涓虹┖
+		} else if (dateType == 2) {
+			if (startTime != null) 
+				startTime = 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; 
 		}
 		
 		try {
+			Object objectDate = null;
+			List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year);
+			
+			Gson gson = new Gson();
+			List<Integer> stateList = gson.fromJson(stateArray, new TypeToken<ArrayList<Integer>>() {}.getType());
 
-			List<Map<String, Object>> resultList = extractAuditRecordService.countAuditTotal(state, dateType, 
-					year, startTime, endTime);
-			
-			JSONObject innerList = new JSONObject();
-			if (state == null) {
-				innerList.put("name", "鎬昏");
-			} else if (state == 1) {
-				innerList.put("name", "閫氳繃鏁�");
-			} else if (state == 2) {
-				innerList.put("name", "椹冲洖鏁�");
+			JSONArray line_list = new JSONArray();
+			for (Integer state: stateList) {
+				JSONObject innerList = new JSONObject();
+				if (state == null || state == 3) {
+					innerList.put("name", "鎬昏");
+				} else if (state == 1) {
+					innerList.put("name", "閫氳繃鏁�");
+				} else if (state == 2) {
+					innerList.put("name", "椹冲洖鏁�");
+				}
+				
+				
+				List<Map<String, Object>> list = extractAuditRecordService.countAuditTotal(state, dateType,
+						year, startTime, endTime);
+				
+				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);
 			}
-			innerList.put("data_list", resultList);
-			
-			JSONArray outList = new JSONArray();
-			outList.add(innerList);
 			
 			JSONObject data = new JSONObject();
-			data.put("result_list", outList);
+			if (objectDate != null) {
+				data.put("xAxis_list", gson.toJson(objectDate));
+			} else {
+				data.put("xAxis_list", gson.toJson(dateList));
+			}
+			
+			data.put("line_list", line_list);
 			
 			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
 			
@@ -1485,52 +1533,80 @@
 	/**
 	 * 缁熻鎻愮幇鐢宠鎬婚
 	 * @param callback
-	 * @param state 鎵�鏈�-绌哄�兼垨鑰呬笉浼�   寰呭鏍�-0 閫氳繃-1  鎷掔粷- 2
 	 * @param type 缁熻绫诲瀷  1-24灏忔椂  2-鎵�鏈�
-	 * @param dateType 绫诲瀷  1鏃�  2鏈�  3骞�
+	 * @param dateType 绫诲瀷  1鏃�  2鏈�  3
 	 * @param year 2018
 	 * @param startTime 2018-12-01 
 	 * @param endTime   2018-12-01 
 	 * @param out
 	 */
-	@RequestMapping(value = "getExtractMoney")
-	public void getExtractMoney(String callback,Integer state, Integer dateType, String year, 
+	@RequestMapping(value = "getExtractApplyMoney")
+	public void getExtractApplyMoney(String callback, Integer dateType, 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;
 		}
 		
-		
-		if (dateType != 1 && (!StringUtil.isNullOrEmpty(startTime) || !StringUtil.isNullOrEmpty(endTime))) {
-			startTime = null;
-			endTime = null;
+		if (dateType == 1 && year != null) {
+			year = null; // 璁剧疆涓虹┖
+		} else if (dateType == 2) {
+			if (startTime != null) 
+				startTime = 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; 
 		}
 		
 		try {
-
-			List<Map<String, Object>> resultList = extractAuditRecordService.countExtractMoney(state, dateType, 
-					year, startTime, endTime);
+			
+			Object objectDate = null;
+			List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year);
+			
+			Gson gson = new Gson();
+			JSONArray line_list = new JSONArray();
 			
 			JSONObject innerList = new JSONObject();
-			if (state == null) {
-				innerList.put("name", "鎬昏");
-			} else if (state == 0) {
-				innerList.put("name", "寰呭鏍�");
-			} else if (state == 1) {
-				innerList.put("name", "閫氳繃");
-			} else if (state == 2) {
-				innerList.put("name", "椹冲洖");
-			}
-			innerList.put("data_list", resultList);
+			innerList.put("name", "鎬昏");
 			
-			JSONArray outList = new JSONArray();
-			outList.add(innerList);
+			List<Map<String, Object>> list = extractAuditRecordService.countExtractApplyMoney(null, dateType,
+					year, startTime, endTime);
+			
+			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", outList);
+			if (objectDate != null) {
+				data.put("xAxis_list", gson.toJson(objectDate));
+			} else {
+				data.put("xAxis_list", gson.toJson(dateList));
+			}
+			
+			data.put("line_list", line_list);
 			
 			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
 			
@@ -1555,40 +1631,69 @@
 	public void getExtractApplyNumber(String callback,Integer state, Integer dateType, 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;
 		}
 		
-		
-		if (dateType != 1 && (!StringUtil.isNullOrEmpty(startTime) || !StringUtil.isNullOrEmpty(endTime))) {
-			startTime = null;
-			endTime = null;
+		if (dateType == 1 && year != null) {
+			year = null; // 璁剧疆涓虹┖
+		} else if (dateType == 2) {
+			if (startTime != null) 
+				startTime = 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; 
 		}
 		
 		try {
 
-			List<Map<String, Object>> resultList = extractAuditRecordService.countExtractApplyNumber(state, dateType, 
-					year, startTime, endTime);
+			Object objectDate = null;
+			List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year);
+			
+			Gson gson = new Gson();
+			JSONArray line_list = new JSONArray();
 			
 			JSONObject innerList = new JSONObject();
-			if (state == null) {
-				innerList.put("name", "鎬昏");
-			} else if (state == 0) {
-				innerList.put("name", "寰呭鏍�");
-			} else if (state == 1) {
-				innerList.put("name", "閫氳繃");
-			} else if (state == 2) {
-				innerList.put("name", "椹冲洖");
-			}
-			innerList.put("data_list", resultList);
+			innerList.put("name", "鎬昏");
 			
-			JSONArray outList = new JSONArray();
-			outList.add(innerList);
+			List<Map<String, Object>> list = extractAuditRecordService.countExtractApplyNumber(null, dateType,
+					year, startTime, endTime);
+			
+			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", outList);
+			if (objectDate != null) {
+				data.put("xAxis_list", gson.toJson(objectDate));
+			} else {
+				data.put("xAxis_list", gson.toJson(dateList));
+			}
+			
+			data.put("line_list", line_list);
 			
 			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
 			
@@ -1626,26 +1731,8 @@
 		data.put("extractMoney", resultData.get("totalmoney"));
 		out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
 	}
+	
+	
 
 	
-	public String validateParams(Integer shwoType,  String startTime, String endTime) {
-
-		if (shwoType == null) {
-			return "璇烽�夋嫨瑙嗗浘绫诲瀷";
-		}
-		
-		if (shwoType == 1 && (StringUtil.isNullOrEmpty(startTime) && StringUtil.isNullOrEmpty(endTime))) {
-			return "璇烽�夋嫨鏃堕棿鍖洪棿";
-		}
-		
-		if (!StringUtil.isNullOrEmpty(startTime) && StringUtil.isNullOrEmpty(endTime)) {
-			return "璇烽�夌粨鏉熸棩鏈�";
-		}
-		
-		if (StringUtil.isNullOrEmpty(startTime) && !StringUtil.isNullOrEmpty(endTime)) {
-			return "璇烽�夎捣濮嬫棩鏈�";
-		}
-		
-		return null;
-	}
 }

--
Gitblit v1.8.0