From e2cf92c43e6d7e274c565cebcef6c97efaf77870 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期四, 03 一月 2019 15:04:26 +0800 Subject: [PATCH] 冲突解决 --- fanli/src/main/java/com/yeshi/fanli/controller/admin/OrderAdminController.java | 157 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 153 insertions(+), 4 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/admin/OrderAdminController.java b/fanli/src/main/java/com/yeshi/fanli/controller/admin/OrderAdminController.java index 13167df..604741e 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/admin/OrderAdminController.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/admin/OrderAdminController.java @@ -1,23 +1,27 @@ package com.yeshi.fanli.controller.admin; import java.io.PrintWriter; +import java.util.ArrayList; import java.util.List; 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.springframework.web.bind.annotation.RequestMethod; +import org.yeshi.utils.JsonUtil; +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; import com.yeshi.fanli.entity.admin.OrderAdmin; import com.yeshi.fanli.service.inter.hongbao.HongBaoService; import com.yeshi.fanli.service.inter.order.OrderService; import com.yeshi.fanli.tag.PageEntity; import com.yeshi.fanli.util.Constant; -import com.yeshi.fanli.util.GsonUtil; -import org.yeshi.utils.JsonUtil; - -import net.sf.json.JSONObject; +import com.yeshi.fanli.util.StringUtil; @Controller @RequestMapping("admin/new/api/v1/order") @@ -42,4 +46,149 @@ data.put("orderList", JsonUtil.getSimpleGsonWithDateAndSerialization().toJson(orderAdminList)); out.print(JsonUtil.loadTrueResult(data)); } + + + /** + * 缁熻褰撳ぉ鏂板鐢ㄦ埛24灏忔椂鍐呬骇鐢熺殑璁㈠崟 + * @param callback + * @param pageIndex + * @param pageSize + * @param channel 娓犻亾鍚嶇О 濡傦細VIVO + * @param out + */ + @RequestMapping(value = "get24HOderByChannel") + public void get24HOderByChannel(String callback, Integer pageIndex, Integer pageSize, + String channelArray, PrintWriter out) { + + if (pageIndex == null || pageIndex < 1) { + pageIndex = 1; + } + + if (pageSize == null || pageSize < 1) { + pageSize = Constant.PAGE_SIZE; + } + + try { + + if (StringUtil.isNullOrEmpty(channelArray)) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇烽�夋嫨鎿嶄綔鐨勬暟鎹�")); + return; + } + + Gson gson = new Gson(); + List<String> list = gson.fromJson(channelArray, new TypeToken<ArrayList<Long>>() {}.getType()); + + if (list == null || list.size() == 0) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏈娴嬪埌鍒犻櫎鐨勬暟鎹�")); + return; + } + + +// List<Map<String, Object>> list = hongBaoService.count24HOderByChannel((pageIndex - 1) * pageSize, pageSize, channel); +// +// if (list == null || list.size() == 0) { +// JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁")); +// return; +// } +// +// JSONObject data = new JSONObject(); +// data.put("pe", pe); +// data.put("result_list", list); + +// JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); + + } catch (Exception e) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父")); + e.printStackTrace(); + } + + } + + /** + * 缁熻鍘嗗彶娓犻亾浜х敓璁㈠崟鐨勯噾棰� + * @param callback + * @param channelArray 鍚嶅瓧鏁扮粍 + * @param type 缁熻绫诲瀷 1-24灏忔椂 2-鎵�鏈� + * @param dateType 绫诲瀷 1鏃� 2鏈� 3骞� + * @param year 2018 + * @param startTime 2018-12-01 + * @param endTime 2018-12-01 + * @param out + */ + @RequestMapping(value = "getHistoryOderByChannel") + public void getHistoryOderByChannel(String callback, String channelArray, Integer dateType, + Integer type, String year, String startTime, String endTime, PrintWriter out) { + + if (StringUtil.isNullOrEmpty(channelArray)) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇烽�夋嫨缁熻瀵瑰簲鍚嶇О")); + return; + } + + if (dateType == null) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇烽�夋嫨鎺掑垪鏂瑰紡")); + return; + } + + if (dateType == 1 && (StringUtil.isNullOrEmpty(startTime) && StringUtil.isNullOrEmpty(endTime))) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇烽�夋嫨鏃堕棿鍖洪棿")); + return; + } + + if (!StringUtil.isNullOrEmpty(startTime) && StringUtil.isNullOrEmpty(endTime)) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇烽�夌粨鏉熸棩鏈�")); + return; + } + + if (StringUtil.isNullOrEmpty(startTime) && !StringUtil.isNullOrEmpty(endTime)) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("璇烽�夎捣濮嬫棩鏈�")); + return; + } + + if (dateType != 1 && (!StringUtil.isNullOrEmpty(startTime) || !StringUtil.isNullOrEmpty(endTime))) { + startTime = null; + endTime = null; + } + + try { + + Gson gson = new Gson(); + List<String> list = gson.fromJson(channelArray, new TypeToken<ArrayList<String>>() {}.getType()); + + if (list == null || list.size() == 0) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鍙傛暟鏍煎紡涓嶆纭�")); + return; + } + + JSONArray array = new JSONArray(); + + for (String channel: list) { + JSONObject channelData = new JSONObject(); + List<Object> resultList = null; + if (type == 1) { + resultList = hongBaoService.count24HOderByChannel(channel, dateType, year, startTime, endTime); + + } else if (type == 2) { + resultList = hongBaoService.countHistoryOderByChannel(channel, dateType, year, startTime, endTime); + } + + + if (resultList == null) { + resultList = new ArrayList<Object>(); + } + channelData.put("name", channel); + channelData.put("infos", resultList); + array.add(channelData); + } + + JSONObject data = new JSONObject(); + data.put("result_list", array); + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); + + } catch (Exception e) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父")); + e.printStackTrace(); + } + + } + } -- Gitblit v1.8.0