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/CountChartsAdminController.java | 1090 +++++++++++++++++++++++--------------------------------- 1 files changed, 454 insertions(+), 636 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/admin/CountChartsAdminController.java b/fanli/src/main/java/com/yeshi/fanli/controller/admin/CountChartsAdminController.java index 46b033c..6af82744 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/admin/CountChartsAdminController.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/admin/CountChartsAdminController.java @@ -2,7 +2,6 @@ import java.io.PrintWriter; import java.math.BigDecimal; -import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; @@ -17,11 +16,14 @@ import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.yeshi.fanli.controller.admin.utils.AdminUtils; -import com.yeshi.fanli.entity.admin.count.CountOrderInfo; -import com.yeshi.fanli.entity.admin.count.CountOrderTrackRate; -import com.yeshi.fanli.entity.admin.count.CountUserInfo; -import com.yeshi.fanli.service.inter.count.UserInfoCountService; -import com.yeshi.fanli.service.inter.order.CommonOrderCountService; +import com.yeshi.fanli.entity.admin.count.DailyCountCoupon; +import com.yeshi.fanli.entity.admin.count.DailyCountMoments; +import com.yeshi.fanli.entity.admin.count.DailyCountOrder; +import com.yeshi.fanli.entity.admin.count.DailyCountUser; +import com.yeshi.fanli.service.inter.count.DailyCountCouponService; +import com.yeshi.fanli.service.inter.count.DailyCountMomentsService; +import com.yeshi.fanli.service.inter.count.DailyCountOrderService; +import com.yeshi.fanli.service.inter.count.DailyCountUserService; import com.yeshi.fanli.util.MoneyBigDecimalUtil; import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.util.TimeUtil; @@ -34,10 +36,454 @@ public class CountChartsAdminController { @Resource - private UserInfoCountService userInfoCountService; + private DailyCountCouponService dailyCountCouponService; @Resource - private CommonOrderCountService commonOrderCountService; + private DailyCountUserService dailyCountUserService; + + @Resource + private DailyCountOrderService dailyCountOrderService; + + @Resource + private DailyCountMomentsService dailyCountMomentsService; + + + + + /** + * 璁㈠崟鐩稿叧鍥捐〃鏁版嵁 + * @param callback + * @param dateType + * @param year + * @param startTime + * @param endTime + * @param type 鏌ヨ绫诲瀷 + * @param out + */ + @RequestMapping(value = "getOrderCharts") + public void getOrderCharts(String callback, Integer dateType, String year, String startTime, String endTime, + String typeArray, String channelArray, PrintWriter out) { + try { + // 鏁版嵁楠岃瘉澶勭悊 + verifyQueryData(callback, dateType, year, startTime, endTime, out); + + Date beginDate = getBeginDate(dateType, year, startTime); + Date endDate = getEndDate(dateType, year, endTime); + + Gson gson = new Gson(); + List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year); + + // 娓犻亾 + List<String> typelList = null; + if (typeArray != null && typeArray.trim().length() > 4) { + typelList = gson.fromJson(typeArray, new TypeToken<ArrayList<String>>() {}.getType()); + } + + if (typelList == null || typelList.size() == 0) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("浼犻�掔被鍨嬮敊璇�")); + return; + } + + // 娓犻亾 + List<String> channelList = null; + if (channelArray != null && channelArray.trim().length() > 4) { + channelList = gson.fromJson(channelArray, new TypeToken<ArrayList<String>>() {}.getType()); + } + + + JSONArray line_list = new JSONArray(); + if (channelList != null && channelList.size() > 0) { + String type = typelList.get(0); + for (String channel: channelList) { + List<DailyCountOrder> listData = dailyCountOrderService.getDailyCountList(type, beginDate, endDate, channel); + // 澶勭悊鏁版嵁 + List<Object> list = machineDailyCountOrder(dateList, dateType, listData); + + JSONObject innerList = new JSONObject(); + innerList.put("name", channel); + innerList.put("data", gson.toJson(list)); + line_list.add(innerList); + } + } else { + for (String type: typelList) { + List<DailyCountOrder> listData = dailyCountOrderService.getDailyCountList(type, beginDate, endDate, null); + // 澶勭悊鏁版嵁 + List<Object> list = machineDailyCountOrder(dateList, dateType, listData); + + JSONObject innerList = new JSONObject(); + innerList.put("name", dailyCountOrderService.getTypeEnumDesc(type)); + innerList.put("data", gson.toJson(list)); + line_list.add(innerList); + } + } + + JSONObject data = new JSONObject(); + data.put("line_list", line_list); + data.put("xAxis_list", gson.toJson(dateList)); + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); + } catch (Exception e) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("绯荤粺寮傚父")); + e.printStackTrace(); + } + } + + + private List<Object> machineDailyCountOrder(List<String> dateList, Integer dateType, List<DailyCountOrder> listData) { + List<Object> list = new ArrayList<>(); + for (String date: dateList) { + BigDecimal result = new BigDecimal(0); + + if (listData != null) { + BigDecimal totalDay = new BigDecimal(0); + BigDecimal totalValid = new BigDecimal(0); + + for (DailyCountOrder history: listData) { + if (dateType == 1) { + String gernalTime = TimeUtil.getGernalTime(history.getDay().getTime()); + if (gernalTime.equalsIgnoreCase(date)) { + result = MoneyBigDecimalUtil.add(result, history.getTotal()); + continue; + } + } else if (dateType == 2){ + String gernalTime = TimeUtil.getMonthOnlyMM(history.getDay()); + if(gernalTime.startsWith("0")) { + gernalTime = gernalTime.substring(1, 2); + } + if (gernalTime.equalsIgnoreCase(date)) { + if (!history.isRate()) { + result = MoneyBigDecimalUtil.add(result, history.getTotal()); + } else { + totalDay = MoneyBigDecimalUtil.add(totalDay, history.getTotalDay()); + totalValid = MoneyBigDecimalUtil.add(totalValid, history.getTotalValid()); + } + } + } else if (dateType == 3) { + String gernalTime = TimeUtil.getYearOnlyYYYY(history.getDay()); + if (gernalTime.equalsIgnoreCase(date)) { + if (!history.isRate()) { + result = MoneyBigDecimalUtil.add(result, history.getTotal()); + } else { + totalDay = MoneyBigDecimalUtil.add(totalDay, history.getTotalDay()); + totalValid = MoneyBigDecimalUtil.add(totalValid, history.getTotalValid()); + } + } + } + } + + // 鍒ゆ柇鏄惁璁$畻姣斾緥 + if ((dateType == 2 || dateType == 3) && totalDay.compareTo(BigDecimal.valueOf(0)) > 0){ + result = MoneyBigDecimalUtil.div(totalValid, totalDay); + result = MoneyBigDecimalUtil.mul(result, BigDecimal.valueOf(100)); + } + } + list.add(result); + } + return list; + } + + + + + /** + * 鐢ㄦ埛鐩稿叧鍥捐〃鏁版嵁 + * @param callback + * @param dateType + * @param year + * @param startTime + * @param endTime + * @param type 鏌ヨ绫诲瀷 + * @param out + */ + @RequestMapping(value = "getUserCharts") + public void getUserCharts(String callback, Integer dateType, String year, String startTime, String endTime, + String typeArray, String channelArray, PrintWriter out) { + try { + // 鏁版嵁楠岃瘉澶勭悊 + verifyQueryData(callback, dateType, year, startTime, endTime, out); + + Date beginDate = getBeginDate(dateType, year, startTime); + Date endDate = getEndDate(dateType, year, endTime); + + Gson gson = new Gson(); + List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year); + + List<String> typelList = null; + if (typeArray != null && typeArray.trim().length() > 4) { + typelList = gson.fromJson(typeArray, new TypeToken<ArrayList<String>>() {}.getType()); + } + if (typelList == null || typelList.size() == 0) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("浼犻�掔被鍨嬮敊璇�")); + return; + } + + // 娓犻亾 + List<String> channelList = null; + if (channelArray != null && channelArray.trim().length() > 4) { + channelList = gson.fromJson(channelArray, new TypeToken<ArrayList<String>>() {}.getType()); + } + + JSONArray line_list = new JSONArray(); + + if (channelList != null && channelList.size() > 0) { + String type = typelList.get(0); + for (String channel: channelList) { + List<DailyCountUser> listData = dailyCountUserService.getDailyCountList(type, beginDate, endDate, channel); + // 澶勭悊鏁版嵁 + List<Object> list = machineDailyCountUser(dateList, dateType, listData); + + JSONObject innerList = new JSONObject(); + innerList.put("name", channel); + innerList.put("data", gson.toJson(list)); + line_list.add(innerList); + } + } else { + for (String type: typelList) { + List<DailyCountUser> listData = dailyCountUserService.getDailyCountList(type, beginDate, endDate, null); + // 澶勭悊鏁版嵁 + List<Object> list = machineDailyCountUser(dateList, dateType, listData); + + JSONObject innerList = new JSONObject(); + innerList.put("name", dailyCountUserService.getTypeEnumDesc(type)); + innerList.put("data", gson.toJson(list)); + line_list.add(innerList); + } + } + + JSONObject data = new JSONObject(); + data.put("line_list", line_list); + data.put("xAxis_list", gson.toJson(dateList)); + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); + } catch (Exception e) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("绯荤粺寮傚父")); + e.printStackTrace(); + } + } + + + private List<Object> machineDailyCountUser(List<String> dateList, Integer dateType, List<DailyCountUser> listData) { + List<Object> list = new ArrayList<>(); + for (String date: dateList) { + BigDecimal result = new BigDecimal(0); + + if (listData != null) { + BigDecimal totalDay = new BigDecimal(0); + BigDecimal totalValid = new BigDecimal(0); + + for (DailyCountUser history: listData) { + if (dateType == 1) { + String gernalTime = TimeUtil.getGernalTime(history.getDay().getTime()); + if (gernalTime.equalsIgnoreCase(date)) { + result = MoneyBigDecimalUtil.add(result, history.getTotal()); + continue; + } + } else if (dateType == 2){ + String gernalTime = TimeUtil.getMonthOnlyMM(history.getDay()); + if(gernalTime.startsWith("0")) { + gernalTime = gernalTime.substring(1, 2); + } + if (gernalTime.equalsIgnoreCase(date)) { + if (!history.isRate()) { + result = MoneyBigDecimalUtil.add(result, history.getTotal()); + } else { + totalDay = MoneyBigDecimalUtil.add(totalDay, history.getTotalDay()); + totalValid = MoneyBigDecimalUtil.add(totalValid, history.getTotalValid()); + } + } + } else if (dateType == 3) { + String gernalTime = TimeUtil.getYearOnlyYYYY(history.getDay()); + if (gernalTime.equalsIgnoreCase(date)) { + if (!history.isRate()) { + result = MoneyBigDecimalUtil.add(result, history.getTotal()); + } else { + totalDay = MoneyBigDecimalUtil.add(totalDay, history.getTotalDay()); + totalValid = MoneyBigDecimalUtil.add(totalValid, history.getTotalValid()); + } + } + } + } + + // 鍒ゆ柇鏄惁璁$畻姣斾緥 + if ((dateType == 2 || dateType == 3) && totalDay.compareTo(BigDecimal.valueOf(0)) > 0){ + result = MoneyBigDecimalUtil.div(totalValid, totalDay); + result = MoneyBigDecimalUtil.mul(result, BigDecimal.valueOf(100)); + } + } + list.add(result); + } + return list; + } + + + /** + * 鍒哥浉鍏冲浘琛ㄦ暟鎹� + * @param callback + * @param dateType + * @param year + * @param startTime + * @param endTime + * @param type 鏌ヨ绫诲瀷 + * @param out + */ + @RequestMapping(value = "getCouponCharts") + public void getCouponCharts(String callback, Integer dateType, String year, String startTime, String endTime, + String typeArray, PrintWriter out) { + try { + // 鏁版嵁楠岃瘉澶勭悊 + verifyQueryData(callback, dateType, year, startTime, endTime, out); + + Date beginDate = getBeginDate(dateType, year, startTime); + Date endDate = getEndDate(dateType, year, endTime); + + Gson gson = new Gson(); + List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year); + + // 娓犻亾 + List<String> typelList = null; + if (typeArray != null && typeArray.trim().length() > 4) { + typelList = gson.fromJson(typeArray, new TypeToken<ArrayList<String>>() {}.getType()); + } + + JSONArray line_list = new JSONArray(); + + if (typelList != null && typelList.size() > 0) { + for (String type: typelList) { + List<DailyCountCoupon> listData = dailyCountCouponService.getDailyCountList(type, beginDate, endDate); + // 澶勭悊鏁版嵁 + List<Object> list = machineDailyCountCoupon(dateList, dateType, listData); + + JSONObject innerList = new JSONObject(); + innerList.put("name", dailyCountCouponService.getTypeEnumDesc(type)); + innerList.put("data", gson.toJson(list)); + line_list.add(innerList); + } + } + + JSONObject data = new JSONObject(); + data.put("line_list", line_list); + data.put("xAxis_list", gson.toJson(dateList)); + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); + } catch (Exception e) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("绯荤粺寮傚父")); + e.printStackTrace(); + } + } + + + private List<Object> machineDailyCountCoupon(List<String> dateList, Integer dateType, List<DailyCountCoupon> listData) { + List<Object> list = new ArrayList<>(); + for (String date: dateList) { + BigDecimal result = new BigDecimal(0); + + if (listData != null) { + for (DailyCountCoupon history: listData) { + if (dateType == 1) { + String gernalTime = TimeUtil.getGernalTime(history.getDay().getTime()); + if (gernalTime.equalsIgnoreCase(date)) { + result = MoneyBigDecimalUtil.add(result, history.getTotal()); + continue; + } + } else if (dateType == 2){ + String gernalTime = TimeUtil.getMonthOnlyMM(history.getDay()); + if(gernalTime.startsWith("0")) { + gernalTime = gernalTime.substring(1, 2); + } + if (gernalTime.equalsIgnoreCase(date)) { + result = MoneyBigDecimalUtil.add(result, history.getTotal()); + } + } else if (dateType == 3) { + String gernalTime = TimeUtil.getYearOnlyYYYY(history.getDay()); + if (gernalTime.equalsIgnoreCase(date)) { + result = MoneyBigDecimalUtil.add(result, history.getTotal()); + } + } + } + } + list.add(result); + } + return list; + } + + + @RequestMapping(value = "getMomentsCharts") + public void getMomentsCharts(String callback, Integer dateType, String year, String startTime, String endTime, + String typeArray, PrintWriter out) { + try { + // 鏁版嵁楠岃瘉澶勭悊 + verifyQueryData(callback, dateType, year, startTime, endTime, out); + + Date beginDate = getBeginDate(dateType, year, startTime); + Date endDate = getEndDate(dateType, year, endTime); + + Gson gson = new Gson(); + List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year); + + // 娓犻亾 + List<String> typelList = null; + if (typeArray != null && typeArray.trim().length() > 4) { + typelList = gson.fromJson(typeArray, new TypeToken<ArrayList<String>>() {}.getType()); + } + + if (typelList == null || typelList.size() == 0) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("浼犻�掔被鍨嬮敊璇�")); + return; + } + + + JSONArray line_list = new JSONArray(); + for (String type: typelList) { + List<DailyCountMoments> listData = dailyCountMomentsService.getDailyCountList(type, beginDate, endDate); + // 澶勭悊鏁版嵁 + List<Object> list = machineDailyCountMoments(dateList, dateType, listData); + + JSONObject innerList = new JSONObject(); + innerList.put("name", dailyCountMomentsService.getTypeEnumDesc(type)); + innerList.put("data", gson.toJson(list)); + line_list.add(innerList); + } + + JSONObject data = new JSONObject(); + data.put("line_list", line_list); + data.put("xAxis_list", gson.toJson(dateList)); + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); + } catch (Exception e) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("绯荤粺寮傚父")); + e.printStackTrace(); + } + } + + + private List<Object> machineDailyCountMoments(List<String> dateList, Integer dateType, List<DailyCountMoments> listData) { + List<Object> list = new ArrayList<>(); + for (String date: dateList) { + BigDecimal result = new BigDecimal(0); + + if (listData != null) { + for (DailyCountMoments history: listData) { + if (dateType == 1) { + String gernalTime = TimeUtil.getGernalTime(history.getDay().getTime()); + if (gernalTime.equalsIgnoreCase(date)) { + result = MoneyBigDecimalUtil.add(result, history.getTotal()); + } + } else if (dateType == 2){ + String gernalTime = TimeUtil.getMonthOnlyMM(history.getDay()); + if(gernalTime.startsWith("0")) { + gernalTime = gernalTime.substring(1, 2); + } + if (gernalTime.equalsIgnoreCase(date)) { + result = MoneyBigDecimalUtil.add(result, history.getTotal()); + } + } else if (dateType == 3) { + String gernalTime = TimeUtil.getYearOnlyYYYY(history.getDay()); + if (gernalTime.equalsIgnoreCase(date)) { + result = MoneyBigDecimalUtil.add(result, history.getTotal()); + } + } + } + } + list.add(result); + } + return list; + } @@ -97,632 +543,4 @@ return endDate; } - private List<Object> machineOrderResultNum(List<String> dateList, Integer dateType, List<CountOrderInfo> listHistory) { - List<Object> list = new ArrayList<>(); - for (String date: dateList) { - int value = 0; - if (listHistory != null) { - for (CountOrderInfo history: listHistory) { - if (dateType == 1) { - String gernalTime = TimeUtil.getGernalTime(history.getDay().getTime()); - if (gernalTime.equalsIgnoreCase(date)) { - value += history.getNum(); - continue; - } - } else if (dateType == 2){ - String gernalTime = TimeUtil.getMonthOnlyMM(history.getDay()); - if(gernalTime.startsWith("0")) { - gernalTime = gernalTime.substring(1, 2); - } - - if (gernalTime.equalsIgnoreCase(date)) { - value += history.getNum(); - continue; - } - } else if (dateType == 3) { - String gernalTime = TimeUtil.getYearOnlyYYYY(history.getDay()); - if (gernalTime.equalsIgnoreCase(date)) { - value += history.getNum(); - continue; - } - } - } - } - list.add(value + ""); - } - return list; - } - - - private List<Object> machineOrderResultMoney(List<String> dateList, Integer dateType, List<CountOrderInfo> listHistory) { - List<Object> list = new ArrayList<>(); - for (String date: dateList) { - BigDecimal money = new BigDecimal(0); - if (listHistory != null) { - for (CountOrderInfo history: listHistory) { - if (dateType == 1) { - String gernalTime = TimeUtil.getGernalTime(history.getDay().getTime()); - if (gernalTime.equalsIgnoreCase(date)) { - if (history.getMoney() != null) { - money = MoneyBigDecimalUtil.add(money, history.getMoney()); - } - continue; - } - } else if (dateType == 2){ - String gernalTime = TimeUtil.getMonthOnlyMM(history.getDay()); - if(gernalTime.startsWith("0")) { - gernalTime = gernalTime.substring(1, 2); - } - if (gernalTime.equalsIgnoreCase(date) && history.getMoney() != null) { - money = MoneyBigDecimalUtil.add(money, history.getMoney()); - } - } else if (dateType == 3) { - String gernalTime = TimeUtil.getYearOnlyYYYY(history.getDay()); - if (gernalTime.equalsIgnoreCase(date)) { - if (history.getMoney() != null) { - money = MoneyBigDecimalUtil.add(money, history.getMoney()); - } - } - } - } - } - list.add(money + ""); - } - return list; - } - - private List<Object> machineResultNum(List<String> dateList, Integer dateType, List<CountUserInfo> listHistory) { - List<Object> list = new ArrayList<>(); - for (String date: dateList) { - int value = 0; - if (listHistory != null) { - for (CountUserInfo history: listHistory) { - if (dateType == 1) { - String gernalTime = TimeUtil.getGernalTime(history.getDay().getTime()); - if (gernalTime.equalsIgnoreCase(date)) { - value += history.getNum(); - continue; - } - } else if (dateType == 2){ - String gernalTime = TimeUtil.getMonthOnlyMM(history.getDay()); - if(gernalTime.startsWith("0")) { - gernalTime = gernalTime.substring(1, 2); - } - - if (gernalTime.equalsIgnoreCase(date)) { - value += history.getNum(); - continue; - } - } else if (dateType == 3) { - String gernalTime = TimeUtil.getYearOnlyYYYY(history.getDay()); - if (gernalTime.equalsIgnoreCase(date)) { - value += history.getNum(); - continue; - } - } - } - } - list.add(value + ""); - } - return list; - } - - /** - * 缁熻鏂颁汉涓嬪崟鎯呭喌 - * @param callback - * @param channelArray - * @param dateType 鏃ユ湡绫诲瀷 - * @param year - * @param startTime - * @param endTime - * @param countType 缁熻绫诲瀷锛� 1-褰撴棩涓嬪崟 銆� 2-褰撳懆涓嬪崟銆�3-褰撳懆涓�3鍗� - * @param out - */ - @RequestMapping(value = "getNewUserDownOder") - public void getNewUserDownOder(String callback, String channelArray, Integer dateType, String year, - String startTime, String endTime, Integer countType, PrintWriter out) { - try { - // 鏁版嵁楠岃瘉澶勭悊 - verifyQueryData(callback, dateType, year, startTime, endTime, out); - - Date beginDate = getBeginDate(dateType, year, startTime); - Date endDate = getEndDate(dateType, year, endTime); - - Gson gson = new Gson(); - List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year); - // 娓犻亾 - List<String> channelList = null; - if (channelArray != null && channelArray.trim().length() > 4) { - channelList = gson.fromJson(channelArray, new TypeToken<ArrayList<String>>() {}.getType()); - } - - JSONArray line_list = new JSONArray(); - if (channelList != null && channelList.size() > 0) { - for (String channel : channelList) { - List<CountUserInfo> listData = null; - if (countType == 1) { - listData = userInfoCountService.countUserDownOrderByChannelAndToday(channel, beginDate, endDate); - } else if (countType == 2) { - listData = userInfoCountService.countUseByChannelAndWeekOrder(channel, beginDate, endDate); - } else if (countType == 3) { - listData = userInfoCountService.countUseByChannelAndWeekThreeOrder(channel, beginDate, endDate); - } - List<Object> list = machineResultNum(dateList, dateType, listData); - - JSONObject innerList = new JSONObject(); - innerList.put("name", channel); - innerList.put("data", gson.toJson(list)); - line_list.add(innerList); - } - } else { - List<CountUserInfo> listData = null; - if (countType == 1) { - listData = userInfoCountService.countUserDownOrderByChannelAndToday(null, beginDate, endDate); - } else if (countType == 2) { - listData = userInfoCountService.countUseByChannelAndWeekOrder(null, beginDate, endDate); - } else if (countType == 3) { - listData = userInfoCountService.countUseByChannelAndWeekThreeOrder(null, beginDate, endDate); - } - List<Object> list = machineResultNum(dateList, dateType, listData); - - JSONObject innerList = new JSONObject(); - innerList.put("name", "鍏ㄩ儴"); - innerList.put("data", gson.toJson(list)); - line_list.add(innerList); - } - - JSONObject data = new JSONObject(); - data.put("line_list", line_list); - data.put("xAxis_list", gson.toJson(dateList)); - JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); - } catch (Exception e) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("绯荤粺寮傚父")); - e.printStackTrace(); - } - } - - /** - * 缁熻璁㈠崟鎯呭喌 - * @param callback - * @param channelArray - * @param dateType - * @param year - * @param startTime - * @param endTime - * @param countType 1-鏂扮敤鎴�24灏忔椂璁㈠崟 銆� 2- 鎬昏鍗曟暟閲� - * @param out - */ - @RequestMapping(value = "getDownOderNum") - public void getDownOderNum(String callback, String channelArray, Integer dateType, String year, - String startTime, String endTime, Integer countType, PrintWriter out) { - try { - // 鏁版嵁楠岃瘉澶勭悊 - verifyQueryData(callback, dateType, year, startTime, endTime, out); - - Date beginDate = getBeginDate(dateType, year, startTime); - Date endDate = getEndDate(dateType, year, endTime); - - Gson gson = new Gson(); - List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year); - // 娓犻亾 - List<String> channelList = null; - if (channelArray != null && channelArray.trim().length() > 4) { - channelList = gson.fromJson(channelArray, new TypeToken<ArrayList<String>>() {}.getType()); - } - - JSONArray line_list = new JSONArray(); - if (channelList != null && channelList.size() > 0) { - for (String channel : channelList) { - List<CountOrderInfo> listData = null; - if (countType == 1) { - listData = userInfoCountService.count24HOderByChannel(channel, beginDate, endDate); - } else if (countType == 2) { - listData = userInfoCountService.countOderByChannel(channel, beginDate, endDate); - } - List<Object> list = machineOrderResultNum(dateList, dateType, listData); - - JSONObject innerList = new JSONObject(); - innerList.put("name", channel); - innerList.put("data", gson.toJson(list)); - line_list.add(innerList); - } - } else { - List<CountOrderInfo> listData = null; - if (countType == 1) { - listData = userInfoCountService.count24HOderByChannel(null, beginDate, endDate); - } else if (countType == 2) { - listData = userInfoCountService.countOderByChannel(null, beginDate, endDate); - } - List<Object> list = machineOrderResultNum(dateList, dateType, listData); - - JSONObject innerList = new JSONObject(); - innerList.put("name", "鍏ㄩ儴"); - innerList.put("data", gson.toJson(list)); - line_list.add(innerList); - } - - JSONObject data = new JSONObject(); - data.put("line_list", line_list); - data.put("xAxis_list", gson.toJson(dateList)); - JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); - } catch (Exception e) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("绯荤粺寮傚父")); - e.printStackTrace(); - } - } - - - /** - * 缁熻璁㈠崟浣i噾 - * @param callback - * @param channelArray - * @param dateType - * @param year - * @param startTime - * @param endTime - * @param out - */ - @RequestMapping(value = "getCommissionMoney") - public void getCommissionMoney(String callback, String channelArray, Integer dateType, String year, - String startTime, String endTime, PrintWriter out) { - try { - // 鏁版嵁楠岃瘉澶勭悊 - verifyQueryData(callback, dateType, year, startTime, endTime, out); - - Date beginDate = getBeginDate(dateType, year, startTime); - Date endDate = getEndDate(dateType, year, endTime); - - Gson gson = new Gson(); - List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year); - // 娓犻亾 - List<String> channelList = null; - if (channelArray != null && channelArray.trim().length() > 4) { - channelList = gson.fromJson(channelArray, new TypeToken<ArrayList<String>>() {}.getType()); - } - - JSONArray line_list = new JSONArray(); - if (channelList != null && channelList.size() > 0) { - for (String channel : channelList) { - List<CountOrderInfo> listData = userInfoCountService.countHongBaoByChannel(channel, beginDate, endDate); - List<Object> list = machineOrderResultMoney(dateList, dateType, listData); - JSONObject innerList = new JSONObject(); - innerList.put("name", channel); - innerList.put("data", gson.toJson(list)); - line_list.add(innerList); - } - } else { - List<CountOrderInfo> listData = userInfoCountService.countHongBaoByChannel(null, beginDate, endDate); - List<Object> list = machineOrderResultMoney(dateList, dateType, listData); - JSONObject innerList = new JSONObject(); - innerList.put("name", "鍏ㄩ儴"); - innerList.put("data", gson.toJson(list)); - line_list.add(innerList); - } - - JSONObject data = new JSONObject(); - data.put("line_list", line_list); - data.put("xAxis_list", gson.toJson(dateList)); - JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); - } catch (Exception e) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("绯荤粺寮傚父")); - e.printStackTrace(); - } - } - - - /** - * 缁熻璁㈠崟浣i噾 - * @param callback - * @param channelArray - * @param dateType - * @param year - * @param startTime - * @param endTime - * @param out - */ - @RequestMapping(value = "getOrderTypeNum") - public void getOrderTypeNum(String callback, String typeArray, Integer dateType, String year, - String startTime, String endTime, Integer countType, PrintWriter out) { - try { - // 鏁版嵁楠岃瘉澶勭悊 - verifyQueryData(callback, dateType, year, startTime, endTime, out); - - Date beginDate = getBeginDate(dateType, year, startTime); - Date endDate = getEndDate(dateType, year, endTime); - - Gson gson = new Gson(); - List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year); - // 娓犻亾 - List<Integer> typeList = null; - if (typeArray != null && typeArray.trim().length() > 4) { - typeList = gson.fromJson(typeArray, new TypeToken<ArrayList<Integer>>() {}.getType()); - } - - JSONArray line_list = new JSONArray(); - if (typeList != null && typeList.size() > 0) { - for (Integer type : typeList) { - List<CountOrderInfo> listData = userInfoCountService.countOrderType(type, beginDate, endDate); - List<Object> list = machineOrderResultMoney(dateList, dateType, listData); - JSONObject innerList = new JSONObject(); - - String name = ""; - if (type == 1) { - name = "鑷喘璁㈠崟"; - } else if (type == 2) { - name = "鍒嗕韩璁㈠崟"; - } else if (type == 3) { - name = "閭�璇疯鍗�"; - } - innerList.put("name", name); - innerList.put("data", gson.toJson(list)); - line_list.add(innerList); - } - } else { - List<CountOrderInfo> listData = userInfoCountService.countOrderType(null, beginDate, endDate); - List<Object> list = machineOrderResultMoney(dateList, dateType, listData); - JSONObject innerList = new JSONObject(); - innerList.put("name", "鍏ㄩ儴"); - innerList.put("data", gson.toJson(list)); - line_list.add(innerList); - } - - JSONObject data = new JSONObject(); - data.put("line_list", line_list); - data.put("xAxis_list", gson.toJson(dateList)); - JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); - } catch (Exception e) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("绯荤粺寮傚父")); - e.printStackTrace(); - } - } - - - /** - * 缁存潈璁㈠崟 閲戦銆佽鍗曞彿鏁伴噺 - * @param callback - * @param channelArray - * @param dateType - * @param year - * @param startTime - * @param endTime - * @param out - */ - @RequestMapping(value = "getWeiQuanOrderInfo") - public void getWeiQuanOrderInfo(String callback, Integer dateType, String year, - String startTime, String endTime, Integer countType, PrintWriter out) { - try { - // 鏁版嵁楠岃瘉澶勭悊 - verifyQueryData(callback, dateType, year, startTime, endTime, out); - - Date beginDate = getBeginDate(dateType, year, startTime); - Date endDate = getEndDate(dateType, year, endTime); - - Gson gson = new Gson(); - List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year); - - JSONArray line_list = new JSONArray(); - - List<Object> list = null; - String name = ""; - if (countType == 1) { - name = "缁存潈鏁伴噺"; - List<CountOrderInfo> listData = userInfoCountService.countWeiQuanOrder(beginDate, endDate); - list = machineOrderResultNum(dateList, dateType, listData); - } else if (countType == 2) { - name = "缁存潈閲戦"; - List<CountOrderInfo> listData = userInfoCountService.countWeiQuanOrderMoney(beginDate, endDate); - list = machineOrderResultMoney(dateList, dateType, listData); - } - - JSONObject innerList = new JSONObject(); - innerList.put("name", name); - innerList.put("data", gson.toJson(list)); - line_list.add(innerList); - - JSONObject data = new JSONObject(); - data.put("line_list", line_list); - data.put("xAxis_list", gson.toJson(dateList)); - JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); - } catch (Exception e) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("绯荤粺寮傚父")); - e.printStackTrace(); - } - } - - - /** - * 璁㈠崟鎵惧洖 閲戦銆佽鍗曞彿鏁伴噺 - * @param callback - * @param channelArray - * @param dateType - * @param year - * @param startTime - * @param endTime - * @param out - */ - @RequestMapping(value = "getLostOrderInfo") - public void getLostOrderInfo(String callback, Integer dateType, String year, - String startTime, String endTime, Integer countType, PrintWriter out) { - try { - // 鏁版嵁楠岃瘉澶勭悊 - verifyQueryData(callback, dateType, year, startTime, endTime, out); - - Date beginDate = getBeginDate(dateType, year, startTime); - Date endDate = getEndDate(dateType, year, endTime); - - Gson gson = new Gson(); - List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year); - - JSONArray line_list = new JSONArray(); - - List<Object> list = null; - String name = ""; - if (countType == 1) { - name = "鐢宠瘔鏁伴噺"; - List<CountOrderInfo> listData = userInfoCountService.counOrderLastNum(beginDate, endDate); - list = machineOrderResultNum(dateList, dateType, listData); - } else if (countType == 2) { - name = "鐢宠瘔浣i噾"; - List<CountOrderInfo> listData = userInfoCountService.counOrderLastMoney(beginDate, endDate); - list = machineOrderResultMoney(dateList, dateType, listData); - } - - JSONObject innerList = new JSONObject(); - innerList.put("name", name); - innerList.put("data", gson.toJson(list)); - line_list.add(innerList); - - JSONObject data = new JSONObject(); - data.put("line_list", line_list); - data.put("xAxis_list", gson.toJson(dateList)); - JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); - } catch (Exception e) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("绯荤粺寮傚父")); - e.printStackTrace(); - } - } - - /** - * 璁㈠崟鎵惧洖 閲戦銆佽鍗曞彿鏁伴噺 - * @param callback - * @param channelArray - * @param dateType - * @param year - * @param startTime - * @param endTime - * @param out - */ - @RequestMapping(value = "getOrderCount") - public void getOrderCount(String callback, Integer dateType, String year, String startTime, String endTime, - Integer countType, PrintWriter out) { - try { - // 鏁版嵁楠岃瘉澶勭悊 - verifyQueryData(callback, dateType, year, startTime, endTime, out); - - Date beginDate = getBeginDate(dateType, year, startTime); - Date endDate = getEndDate(dateType, year, endTime); - - Gson gson = new Gson(); - List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year); - - JSONArray line_list = new JSONArray(); - - List<Object> list = null; - String name = ""; - if (countType == 1) { - name = "鍗曟暟"; - List<CountOrderInfo> listData = userInfoCountService.counOrderTotalNum(beginDate, endDate); - list = machineOrderResultNum(dateList, dateType, listData); - } else if (countType == 2) { - name = "浣i噾"; - List<CountOrderInfo> listData = userInfoCountService.counOrderTotalCommission(beginDate, endDate); - list = machineOrderResultMoney(dateList, dateType, listData); - } - - JSONObject innerList = new JSONObject(); - innerList.put("name", name); - innerList.put("data", gson.toJson(list)); - line_list.add(innerList); - - JSONObject data = new JSONObject(); - data.put("line_list", line_list); - data.put("xAxis_list", gson.toJson(dateList)); - JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); - } catch (Exception e) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("绯荤粺寮傚父")); - e.printStackTrace(); - } - } - - - - /** - * 璁㈠崟璺熻釜鐜� - * @param callback - * @param channelArray - * @param dateType - * @param year - * @param startTime - * @param endTime - * @param out - */ - @RequestMapping(value = "getOrderTrackRate") - public void getOrderTrackRate(String callback, Integer dateType, String year, String startTime, String endTime, - Integer countType, PrintWriter out) { - try { - // 鏁版嵁楠岃瘉澶勭悊 - verifyQueryData(callback, dateType, year, startTime, endTime, out); - - Date beginDate = getBeginDate(dateType, year, startTime); - Date endDate = getEndDate(dateType, year, endTime); - - Gson gson = new Gson(); - List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year); - - JSONArray line_list = new JSONArray(); - - List<CountOrderTrackRate> listHistory = commonOrderCountService.getOrderTrackRate(countType, beginDate, endDate); - - List<Object> list = new ArrayList<>(); - DecimalFormat df = new DecimalFormat("#.00"); - for (String date: dateList) { - double proportion = 0; - if (listHistory != null) { - Long upValue = 0L; - Long downValue = 0L; - for (CountOrderTrackRate history: listHistory) { - if (dateType == 1) { - String gernalTime = TimeUtil.getGernalTime(history.getDay().getTime()); - if (gernalTime.equalsIgnoreCase(date)) { - if(history.getNum() != null) - upValue = history.getNum(); - if(history.getTotalNum() != null) - downValue = history.getTotalNum(); - continue; - } - } else if (dateType == 2){ - String gernalTime = TimeUtil.getMonthOnlyMM(history.getDay()); - if(gernalTime.startsWith("0")) { - gernalTime = gernalTime.substring(1, 2); - } - - if (gernalTime.equalsIgnoreCase(date)) { - if(history.getNum() != null) - upValue = history.getNum(); - if(history.getTotalNum() != null) - downValue = history.getTotalNum(); - continue; - } - } else if (dateType == 3) { - String gernalTime = TimeUtil.getYearOnlyYYYY(history.getDay()); - if (gernalTime.equalsIgnoreCase(date)) { - if(history.getNum() != null) - upValue = history.getNum(); - if(history.getTotalNum() != null) - downValue = history.getTotalNum(); - continue; - } - } - } - if(downValue != 0) { - proportion = upValue / (double) downValue; - } - } - list.add(Double.parseDouble(df.format(proportion * 100)) + ""); - } - - JSONObject innerList = new JSONObject(); - innerList.put("name", "璺熻釜鐜�"); - innerList.put("data", gson.toJson(list)); - line_list.add(innerList); - - JSONObject data = new JSONObject(); - data.put("line_list", line_list); - data.put("xAxis_list", gson.toJson(dateList)); - JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); - } catch (Exception e) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("绯荤粺寮傚父")); - e.printStackTrace(); - } - } } -- Gitblit v1.8.0