From 98b1a0affd69bbe63223c21fdd2c404e8bedfccb Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期三, 20 五月 2020 17:25:08 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/div' into 2.1.2

---
 fanli/src/main/java/com/yeshi/fanli/controller/admin/UserSystemCouponAdminController.java |  218 +++++++++++++----------------------------------------
 1 files changed, 55 insertions(+), 163 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/admin/UserSystemCouponAdminController.java b/fanli/src/main/java/com/yeshi/fanli/controller/admin/UserSystemCouponAdminController.java
index a2f6c35..b31365a 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/admin/UserSystemCouponAdminController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/admin/UserSystemCouponAdminController.java
@@ -2,7 +2,6 @@
 
 import java.io.PrintWriter;
 import java.util.List;
-import java.util.Map;
 
 import javax.annotation.Resource;
 
@@ -12,15 +11,14 @@
 
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
-import com.yeshi.fanli.controller.admin.utils.AdminUtils;
+import com.yeshi.fanli.entity.bus.user.UserSystemCouponGiveRecord;
 import com.yeshi.fanli.service.inter.count.UserSystemCouponCountService;
+import com.yeshi.fanli.service.inter.user.UserSystemCouponGiveRecordService;
 import com.yeshi.fanli.tag.PageEntity;
 import com.yeshi.fanli.util.Constant;
-import com.yeshi.fanli.util.StringUtil;
 import com.yeshi.fanli.vo.user.SystemCouponVO;
 import com.yeshi.fanli.vo.user.UserSystemCouponCountVO;
 
-import net.sf.json.JSONArray;
 import net.sf.json.JSONObject;
 
 @Controller
@@ -29,6 +27,9 @@
 
 	@Resource
 	private UserSystemCouponCountService userSystemCouponCountService;
+	
+	@Resource
+	private UserSystemCouponGiveRecordService userSystemCouponGiveRecordService;
 
 	/**
 	 * 鐢ㄦ埛濂栧姳鍒稿垪琛�
@@ -147,7 +148,7 @@
 				return;
 			}
 
-			long count = userSystemCouponCountService.countSystemCouponFree(key);
+			long count = list.size();
 
 			int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
 			PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
@@ -275,176 +276,67 @@
 			e.printStackTrace();
 		}
 	}
-
-	/**
-	 * 濂栧姳鍒告暟閲忔洸绾垮浘
-	 * @param callback
-	 * @param dateType
-	 * @param year
-	 * @param startTime
-	 * @param endTime
-	 * @param out
-	 */
-	@RequestMapping(value = "getRebateCouponUsedNumCharts")
-	public void getRebateCouponUsedNumCharts(String callback, Integer dateType, String year, String startTime,
-			String endTime, PrintWriter out){
-		try {
-			String validateMsg = AdminUtils.validateParams(dateType, startTime, endTime);
-			if (validateMsg != null) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg));
-				return;
-			}
-			JSONObject data = getChartsData(dateType, year, startTime, endTime, 1, null);
-			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 pageIndex
+	 * @param pageSize
+	 * @param key
+	 * @param type 1璧犻�佸厤鍗曞埜 銆�2-濂栧姳鍒�
+	 * @param state
 	 * @param out
 	 */
-	@RequestMapping(value = "getRebateCouponMoneyCharts")
-	public void getRebateCouponMoneyCharts(String callback, Integer dateType, String year, String startTime,
-			String endTime, PrintWriter out){
-		try {
-			String validateMsg = AdminUtils.validateParams(dateType, startTime, endTime);
-			if (validateMsg != null) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg));
-				return;
-			}
-			JSONObject data = getChartsData(dateType, year, startTime, endTime, 2, null);
-			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 = "getFreeCouponMoneyCharts")
-	public void getFreeCouponMoneyCharts(String callback, Integer dateType, String year, String startTime,
-			String endTime, Integer coupon, PrintWriter out){
-		try {
-			
-			if (coupon == null || (coupon != 1 && coupon != 2)) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鍒哥被鍨嬩笉姝g‘"));
-				return;
-			}
-			
-			String validateMsg = AdminUtils.validateParams(dateType, startTime, endTime);
-			if (validateMsg != null) {
-				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg));
-				return;
-			}
-			
-			String couponType = null;
-			if (coupon == 1) {
-				couponType = "freeCoupon";
-			} else if  (coupon == 2){
-				couponType = "welfareFreeCoupon";
-			}
-			
-			
-			JSONObject data = getChartsData(dateType, year, startTime, endTime, 3, couponType);
-			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
-		} catch (Exception e) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("绯荤粺寮傚父"));
-			e.printStackTrace();
-		}
-	}
-	
-	public JSONObject getChartsData(Integer dateType, String year, String startTime,
-			String endTime, int source, String couponType) throws Exception {
+	@RequestMapping(value = "listGiveCoupon")
+	public void listGiveCoupon(String callback, Integer pageIndex, Integer pageSize, String key, Integer type,
+			Integer state, PrintWriter out) {
 
-		if (dateType != 1 && (!StringUtil.isNullOrEmpty(startTime) || !StringUtil.isNullOrEmpty(endTime))) {
-			startTime = null;
-			endTime = null;
+		if (pageIndex == null || pageIndex < 1) {
+			pageIndex = 1;
 		}
 
-		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();
-		List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year);
-
-		JSONObject innerList = new JSONObject();
-		List<Map<String, Object>> list = null;
-		if (source == 1) {
-			// 濂栧姳鍒告暟閲�
-			innerList.put("name", "鏁伴噺");
-			list = userSystemCouponCountService.getRebateCouponUsedNumToCharts(dateType, year,
-					startTime, endTime);
-		} else if (source == 2) {
-			// 濂栧姳鍒搁噾棰�
-			innerList.put("name", "閲戦");
-			list = userSystemCouponCountService.getRebateCouponMoneyToCharts(dateType, year,
-					startTime, endTime);
-		} else if (source == 3) {
-			// 濂栧姳鍒搁噾棰�
-			innerList.put("name", "閲戦");
-			list = userSystemCouponCountService.getFreeCouponMoneyToCharts(dateType, year,
-					startTime, endTime, couponType);
+		if (pageSize == null || pageSize < 1) {
+			pageSize = Constant.PAGE_SIZE;
 		}
 		
-		
-		Object objectDate = null;
-	
-		if (dateType != 3) {
-			innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateType, dateList, list)));
-		} else {
-			// 骞磋鍥�
-			Map<String, Object> map = AdminUtils.yearsDataFactory(list);
+		String couponType = null;
+		if (type != null) {
+			if (type == 1) {
+				couponType = "freeCouponGive";
+			} else if  (type == 2){
+				couponType = "rebatePercentCoupon";
+			} 
+		}
 
-			if (objectDate == null) {
-				objectDate = map.get("date");
+		try {
+			List<UserSystemCouponGiveRecord> list = userSystemCouponGiveRecordService.listGiveRecord((pageIndex - 1) * pageSize,
+					pageSize, couponType, state);
+
+			if (list == null || list.size() == 0) {
+				JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁"));
+				return;
 			}
-			innerList.put("data", gson.toJson(map.get("value")));
+
+			long count = userSystemCouponGiveRecordService.countGiveRecord(couponType, state);
+
+			int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
+			PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
+
+			GsonBuilder gsonBuilder = new GsonBuilder();
+			gsonBuilder.serializeNulls();
+			Gson gson = gsonBuilder.setDateFormat("yyyy/MM/dd HH:mm:ss").create();
+
+			JSONObject data = new JSONObject();
+			data.put("pe", pe);
+			data.put("result_list", gson.toJson(list));
+			JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
+		} catch (Exception e) {
+			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父"));
+			e.printStackTrace();
 		}
-
-		JSONArray line_list = new JSONArray();
-		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);
-		return data;
 	}
+
+
 }

--
Gitblit v1.8.0