From e6cb7c27384f22b39ccee584028e23b56c30e9ee Mon Sep 17 00:00:00 2001
From: yujian <yujian>
Date: 星期四, 07 三月 2019 15:01:22 +0800
Subject: [PATCH] 券推送调用

---
 fanli/src/main/java/com/yeshi/fanli/controller/admin/LostOrderAdminController.java |  213 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 213 insertions(+), 0 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/admin/LostOrderAdminController.java b/fanli/src/main/java/com/yeshi/fanli/controller/admin/LostOrderAdminController.java
index d611d32..9fedd37 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/admin/LostOrderAdminController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/admin/LostOrderAdminController.java
@@ -1,11 +1,13 @@
 package com.yeshi.fanli.controller.admin;
 
 import java.io.PrintWriter;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
 import javax.annotation.Resource;
 
+import net.sf.json.JSONArray;
 import net.sf.json.JSONObject;
 
 import org.springframework.stereotype.Controller;
@@ -14,6 +16,8 @@
 
 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.LostOrder;
 import com.yeshi.fanli.entity.bus.user.Order;
 import com.yeshi.fanli.entity.bus.user.UserInfo;
@@ -21,6 +25,7 @@
 import com.yeshi.fanli.tag.PageEntity;
 import com.yeshi.fanli.util.Constant;
 import com.yeshi.fanli.util.GsonUtil;
+import com.yeshi.fanli.util.StringUtil;
 
 @Controller
 @RequestMapping("admin/new/api/v1/lostOrder")
@@ -214,4 +219,212 @@
 		}
 		
 	}
+	
+	
+
+	/**
+	 * 缁熻鎻愮幇鐢宠鎬绘鏁�
+	 * @param callback
+	 * @param dateType     鏄剧ず瑙嗗浘锛氭棩-1 銆佹湀-2銆� 骞�-3
+	 * @param state 鐘舵�侊細  1-鏈鐞� 2-鎴愬姛  3-澶辫触
+	 * @param year 
+	 * @param startTime
+	 * @param endTime
+	 * @param out
+	 */
+	@RequestMapping(value = "getLostNum")
+	public void getLostNum(String callback, Integer dateType, String stateArray, String year, 
+			String startTime, String endTime, PrintWriter out) {
+
+		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;
+		}
+
+		
+		List<Integer> channelList = null;
+		if (stateArray != null && stateArray.trim().length() > 0) {
+			Gson gson = new Gson();
+			channelList = gson.fromJson(stateArray, new TypeToken<ArrayList<Integer>>() {}.getType());
+		}
+
+		
+		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; 
+		}
+		
+		Gson gson = new Gson();
+		Object objectDate = null;
+		List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year);
+		
+		try {
+
+			
+			JSONArray line_list = new JSONArray();
+			if (channelList == null || channelList.size() == 0) {
+				
+			} else {
+				for (Integer state : channelList) {
+					
+					List<Map<String, Object>> list = lostOrderService.countLostNum(dateType, state, year, 
+							startTime, endTime);
+					
+					
+					JSONObject innerList = new JSONObject();
+					if (state == 1) {
+						innerList.put("name", "鏈鐞�");
+					} else if (state == 2) {
+						innerList.put("name", "鎴愬姛");
+					} else if (state == 3) {
+						innerList.put("name", "澶辫触");
+					}
+
+					if (dateType != 3) {
+						innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateType, 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();
+			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));
+
+		} catch (Exception e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
+			e.printStackTrace();
+		}
+	
+	}
+	
+	/**
+	 * 缁熻鐢宠瘔閲戦鎬绘暟
+	 * @param callback
+	 * @param dateType 鏄剧ず瑙嗗浘锛氭棩-1 銆佹湀-2銆� 骞�-3
+	 * @param year 
+	 * @param startTime
+	 * @param endTime
+	 * @param out
+	 */
+	@RequestMapping(value = "getAppealMoney")
+	public void getAppealMoney(String callback, Integer dateType, String year, String startTime, String endTime,
+			PrintWriter out) {
+
+		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; 
+		}
+		
+		Gson gson = new Gson();
+		Object objectDate = null;
+		List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year);
+		
+		try {
+
+			
+			JSONArray line_list = new JSONArray();
+					
+			List<Map<String, Object>> list = lostOrderService.countAppealMoney(dateType, year, startTime, endTime);
+					
+					
+			JSONObject innerList = new JSONObject();
+				innerList.put("name", "鎬昏");
+
+			if (dateType != 3) {
+				innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateType, 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();
+			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));
+
+		} catch (Exception e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
+			e.printStackTrace();
+		}
+	}
 }

--
Gitblit v1.8.0