From d28bed1a1275131a5ca37f7da37961e2b518ac07 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期一, 26 八月 2019 13:44:00 +0800 Subject: [PATCH] 淘礼金创建异常处理 --- fanli/src/main/java/com/yeshi/fanli/controller/admin/LostOrderAdminController.java | 300 +++++++++++++++++++++++++++++++++++------------------------ 1 files changed, 179 insertions(+), 121 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 92befeb..9d21266 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 @@ -7,23 +7,24 @@ import javax.annotation.Resource; -import net.sf.json.JSONArray; -import net.sf.json.JSONObject; - import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.yeshi.utils.JsonUtil; 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; import com.yeshi.fanli.service.inter.order.LostOrderService; import com.yeshi.fanli.tag.PageEntity; import com.yeshi.fanli.util.Constant; -import com.yeshi.fanli.util.GsonUtil; import com.yeshi.fanli.util.StringUtil; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; @Controller @RequestMapping("admin/new/api/v1/lostOrder") @@ -32,49 +33,6 @@ @Resource private LostOrderService lostOrderService; - @RequestMapping("findLostOrderList") - public void findLostOrderList(int page, String key, PrintWriter out) { - List<LostOrder> list = lostOrderService.findLostOrderList(key, page); - int count = lostOrderService.getCount(key); - PageEntity pe = new PageEntity(page, Constant.PAGE_SIZE, count); - JSONObject data = new JSONObject(); - data.put("pe", pe); - data.put("lostOrderList", GsonUtil.toJsonByUserAp(list)); - out.print(JsonUtil.loadTrueResult(data)); - } - - @RequestMapping("pass") - public void pass(long id, PrintWriter out) { - LostOrder lostOrder = lostOrderService.getOne(id); - if (lostOrder == null) { - out.print(JsonUtil.loadFalseResult("涓嶅瓨鍦ㄨ鏌ヨ璁㈠崟")); - return; - } - if (lostOrder.getState() != 0) { - out.print(JsonUtil.loadFalseResult("璇ヨ鍗曞凡澶勭悊")); - return; - } - lostOrderService.pass(lostOrder); - out.print(JsonUtil.loadTrueResult("")); - } - - @RequestMapping("reject") - public void reject(long id,String reason, PrintWriter out) { - LostOrder lostOrder = lostOrderService.getOne(id); - if (lostOrder == null) { - out.print(JsonUtil.loadFalseResult("涓嶅瓨鍦ㄨ鏌ヨ璁㈠崟")); - return; - } - if (lostOrder.getState() != 0) { - out.print(JsonUtil.loadFalseResult("璇ヨ鍗曞凡澶勭悊")); - return; - } - lostOrder.setRemake(reason); - lostOrderService.reject(lostOrder); - out.print(JsonUtil.loadTrueResult("")); - } - - /** * 鏂扮増鍚庡彴 鍒楄〃鏌ヨ * @param callback @@ -84,7 +42,7 @@ */ @RequestMapping("query") public void query(String callback, Integer pageIndex, Integer pageSize, String key, Integer state, - Integer handleType, PrintWriter out) { + Integer handleType, Integer type, PrintWriter out) { if (pageIndex == null || pageIndex < 0){ pageIndex = 1; @@ -96,7 +54,7 @@ try { - List<LostOrder> list = lostOrderService.listQuery((pageIndex - 1) * pageSize, pageSize, key, state, handleType); + List<LostOrder> list = lostOrderService.listQuery((pageIndex - 1) * pageSize, pageSize, key, state, handleType, type); if (list == null || list.size() == 0) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏇村鏁版嵁")); return; @@ -105,12 +63,35 @@ for (LostOrder lostOrder: list) { + Integer stateOrder = lostOrder.getState(); + Integer resultCode = lostOrder.getResultCode(); + if (stateOrder != null && stateOrder == 1 && resultCode!= null) { + switch(resultCode) { + case 1: + lostOrder.setRemake("绛夊緟鐖彇涓�"); + break; + case 2: + lostOrder.setRemake("澶勭悊鎴愬姛"); + break; + case 3: + lostOrder.setState(2); + lostOrder.setRemake("澶勭悊澶辫触"); + break; + default: + break; + } + } else if (stateOrder != null && stateOrder == 2) { + lostOrder.setRemake("宸叉嫆缁�"); + } + + Order order = lostOrder.getOrder(); if (order == null) { lostOrder.setOrder(new Order()); } - UserInfo userInfo = lostOrder.getUserInfo(); + + UserInfo userInfo = lostOrder.getUserInfo(); if (userInfo == null) { lostOrder.setUserInfo(new UserInfo()); } else { @@ -122,7 +103,7 @@ } } - long count = lostOrderService.countQuery(key, state, handleType); + long count = lostOrderService.countQuery(key, state, handleType, type); int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1); PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage); @@ -219,34 +200,6 @@ } - /** - * 楠岃瘉缁熻淇℃伅鍙傛暟 - * @param shwoType - * @param startTime - * @param endTime - * @return - */ - 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; - } - /** * 缁熻鎻愮幇鐢宠鎬绘鏁� @@ -259,45 +212,107 @@ * @param out */ @RequestMapping(value = "getLostNum") - public void getLostNum(String callback, Integer dateType, Integer state, String year, String startTime, - String endTime, PrintWriter out) { + public void getLostNum(String callback, Integer dateType, String stateArray, 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; + } + + 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 { + - if (dateType != 1 && (!StringUtil.isNullOrEmpty(startTime) || !StringUtil.isNullOrEmpty(endTime))) { - startTime = null; - endTime = null; + 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); + } + } - List<Map<String, Object>> resultList =lostOrderService.countLostNum(dateType, state, 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); + 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("绯荤粺寮傚父")); + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父")); e.printStackTrace(); } + } /** @@ -313,38 +328,81 @@ public void getAppealMoney(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; + } + + Gson gson = new Gson(); + Object objectDate = null; + List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year); + try { - - if (dateType != 1 && (!StringUtil.isNullOrEmpty(startTime) || !StringUtil.isNullOrEmpty(endTime))) { - startTime = null; - endTime = null; - } - List<Map<String, Object>> resultList =lostOrderService.countAppealMoney(dateType, year, startTime, endTime); - if (resultList == null) { - resultList = new ArrayList<Map<String,Object>>(); + + 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"))); } - JSONObject innerList = new JSONObject(); - innerList.put("name", "閲戦"); - innerList.put("data_list", resultList); - - JSONArray outList = new JSONArray(); - outList.add(innerList); - + 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)); - + } catch (Exception e) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("绯荤粺寮傚父")); + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父")); e.printStackTrace(); } } -- Gitblit v1.8.0