From f28cb1b4e59305480ef1effee38b1dc411f775a4 Mon Sep 17 00:00:00 2001
From: 喻健 <Administrator@Admin>
Date: 星期二, 25 十二月 2018 17:50:25 +0800
Subject: [PATCH] 奖金统计

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/UserOrderController.java |  114 +++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 99 insertions(+), 15 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/UserOrderController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/UserOrderController.java
index 6a83a09..002715f 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/client/UserOrderController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/UserOrderController.java
@@ -54,7 +54,7 @@
 	 * @param out
 	 */
 	@RequestMapping(value = "getorder", method = RequestMethod.POST)
-	public void getOrder(AcceptData acceptData, Long page, Long uid, Integer state, Integer type, String orderNo, 
+	public void getOrder(AcceptData acceptData, Integer page, Long uid, Integer state, Integer type, String orderNo, 
 			String startTime, String endTime, Integer slotTime, boolean needCount, PrintWriter out) {
 		
 		if (uid == null) {
@@ -63,7 +63,7 @@
 		}
 		
 		if (page == null || page < 1) {
-			page = 1L;
+			page = 1;
 		}
 		
 		if (state !=null && state == 0) {
@@ -114,8 +114,8 @@
 					totalInvite = countOrder.get("totalInvite").intValue();
 				}	
 				
-				todayTotal = commonOrderService.countOrder(uid, 1);
-				todayMoney = commonOrderService.countOrderMoney(uid, 1);
+				todayTotal = commonOrderService.countOrder(uid, type, 1);
+				todayMoney = commonOrderService.countOrderMoney(uid, type , 1); 
 			}
 		
 			if (todayMoney == null) {
@@ -259,13 +259,13 @@
 	}
 	
 	/**
-	 * 缁熻浠婃棩璁㈠崟鏀跺叆 浠ュ強璁㈠崟鏁伴噺
+	 * 缁熻濂栭噾
 	 * @param acceptData
 	 * @param uid
 	 * @param out
 	 */
-	@RequestMapping(value = "countToday", method = RequestMethod.POST)
-	public void countToday(AcceptData acceptData, Long uid, PrintWriter out) {
+	@RequestMapping(value = "countBonus", method = RequestMethod.POST)
+	public void countBonus(AcceptData acceptData, Long uid, Integer dateType, PrintWriter out) {
 		
 		if (uid == null) {
 			out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�"));
@@ -273,16 +273,15 @@
 		}
 		
 		try {
-			long count = commonOrderService.countOrder(uid, 1);
-			BigDecimal money = commonOrderService.countOrderMoney(uid, 1);
-			
-			if (money == null) {
-				money = new BigDecimal(0);
-			}
 			
 			JSONObject data = new JSONObject();
-			data.put("count", count);
-			data.put("money", money);
+			// 鍒嗕韩缁熻
+			data.put("shareCount", commonOrderService.countOrder(uid, 2, dateType));
+			data.put("sharemoney", commonOrderService.countOrderMoney(uid,2, dateType));
+			// 閭�璇风粺璁�
+			data.put("inviteCount", commonOrderService.countOrder(uid, 3, dateType));
+			data.put("inviteMoney", commonOrderService.countOrderMoney(uid,3, dateType));
+			
 			out.print(JsonUtil.loadTrueResult(data));
 			
 		} catch (Exception e) {
@@ -292,6 +291,91 @@
 		
 	}
 	
+	/**
+	 * 濂栭噾璁㈠崟
+	 * @param acceptData
+	 * @param page
+	 * @param uid
+	 * @param dateType   1-浠婃棩 2-鏄ㄥぉ 3-鏈湀 4-涓婁釜鏈�  |
+	 * @param type     璁㈠崟绫诲瀷锛�1-杩斿埄璁㈠崟 2-鍒嗕韩璁㈠崟 3-閭�璇疯鍗� 
+	 * @param out
+	 */
+	@RequestMapping(value = "getbonusorder", method = RequestMethod.POST)
+	public void getBonusOrder(AcceptData acceptData, Integer page, Long uid, Integer dateType, 
+			Integer type, PrintWriter out) {
+		
+		if (uid == null) {
+			out.print(JsonUtil.loadFalseResult(1, "鐢ㄦ埛鏈櫥褰�"));
+			return;
+		}
+		
+		if (type == null || dateType == null ) {
+			out.print(JsonUtil.loadFalseResult(1, "浼犻�掑弬鏁扮己澶�"));
+			return;
+		}
+		
+		if (page == null || page < 1) {
+			page = 1;
+		}
+		
+		try {
+			long count = 0;
+			List<CommonOrderVO> list = commonOrderService.listBonusOrder(page, uid,  type, dateType);
+			
+			if (list != null && list.size() > 0) {
+				count = commonOrderService.countOrder(uid, type, dateType);
+			}
+			
+			int totalValid = 0;
+			int totalProces = 0;
+			int totalInvite = 0;
+			long todayTotal = 0;
+			BigDecimal todayMoney = null;
+			// 闇�瑕佺粺璁′俊鎭�
+			if (page == 1) {
+				Map<String, BigDecimal> countOrder = commonOrderService.countBonusOrderByState(uid, type, dateType);
+				
+				if (countOrder.get("totalValid") != null) {
+					totalValid = countOrder.get("totalValid").intValue();
+				}	
+				
+				if (countOrder.get("totalProces") != null) {
+					totalProces = countOrder.get("totalProces").intValue();
+				}	
+				
+				if (countOrder.get("totalInvite") != null) {
+					totalInvite = countOrder.get("totalInvite").intValue();
+				}	
+				
+				todayTotal = commonOrderService.countOrder(uid, type, 1);
+				todayMoney = commonOrderService.countOrderMoney(uid, type , 1); 
+			}
+		
+			if (todayMoney == null) {
+				todayMoney = new BigDecimal(0);
+			}
+			
+			
+			JSONObject data = new JSONObject();
+			data.put("count", count);
+			data.put("result_list", JsonUtil.getApiCommonGson().toJson(list));
+			
+			data.put("todayTotal", todayTotal);
+			data.put("todayMoney", todayMoney);
+			data.put("totalValid", totalValid); // 鏈夋晥鏁伴噺
+			data.put("totalProces", totalProces); // 缁存潈鏁伴噺
+			data.put("totalInvite", totalInvite); // 澶辨晥鏁伴噺
+			
+			out.print(JsonUtil.loadTrueResult(data));
+			
+		} catch(CommonOrderException e){
+			out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
+		} catch (Exception e) {
+			out.print(JsonUtil.loadFalseResult(1, "鏌ヨ澶辫触"));
+			e.printStackTrace();
+		}
+		
+	}
 	
 	/**
 	 * 鏃堕棿杞崲

--
Gitblit v1.8.0