From ddf5db7d31af51fcf697eac0cee7dd46ff73bcc1 Mon Sep 17 00:00:00 2001 From: admin <2780501319@qq.com> Date: 星期二, 18 二月 2020 12:50:49 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/div' into div --- fanli/src/main/java/com/yeshi/fanli/controller/admin/ExtractAdminController.java | 435 +++++++++++++++++++++++++++++++++--------------------- 1 files changed, 265 insertions(+), 170 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/admin/ExtractAdminController.java b/fanli/src/main/java/com/yeshi/fanli/controller/admin/ExtractAdminController.java index bcf883a..6fac641 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/admin/ExtractAdminController.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/admin/ExtractAdminController.java @@ -33,12 +33,14 @@ import com.google.gson.reflect.TypeToken; import com.yeshi.fanli.controller.admin.utils.AdminUtils; import com.yeshi.fanli.dto.ChartTDO; +import com.yeshi.fanli.entity.admin.count.CountUserInfo; import com.yeshi.fanli.entity.bus.user.Extract; import com.yeshi.fanli.entity.bus.user.ExtractAuditRecord; import com.yeshi.fanli.entity.bus.user.HongBaoV2; import com.yeshi.fanli.entity.bus.user.UserInfo; import com.yeshi.fanli.entity.bus.user.UserInfoExtra; import com.yeshi.fanli.entity.common.AdminUser; +import com.yeshi.fanli.entity.system.ConfigKeyEnum; import com.yeshi.fanli.exception.ExtractException; import com.yeshi.fanli.exception.NotExistObjectException; import com.yeshi.fanli.exception.ObjectStateException; @@ -57,6 +59,7 @@ import com.yeshi.fanli.service.inter.user.UserInfoExtraService; import com.yeshi.fanli.tag.PageEntity; import com.yeshi.fanli.util.Constant; +import com.yeshi.fanli.util.MoneyBigDecimalUtil; import com.yeshi.fanli.util.RedisManager; import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.util.TimeUtil; @@ -231,8 +234,8 @@ // 褰撳墠鐢ㄦ埛浣欓鎬昏锛氭墍鏈夌敤鎴锋�讳綑棰� BigDecimal amountMoney = userInfoCountService.countAllMoney(null); - // 鍙彁鐜伴噾棰濋檺鍒� - String minMoney = configService.get(Constant.EXTRACT_MIN_MONEY); + // 鍙彁鐜伴噾棰濋檺鍒� + String minMoney = configService.get(ConfigKeyEnum.extractMoneyMin.getKey()); if (minMoney == null) { minMoney = "0"; } @@ -429,7 +432,7 @@ desc.append("缁存潈璁㈠崟鏁�:" + record.getExtraInfo().getWeiQuanOrderCount() + "\n#"); desc.append("缁存潈璁㈠崟浣i噾:" + record.getExtraInfo().getWeiQuanOrderFanAmount() + "\n#"); if (record.getExtraInfo().getOrderCount50More() > 0 - || record.getExtraInfo().getWeiQuanOrderCount() > 1 + || record.getExtraInfo().getWeiQuanOrderCount() > 0 || record.getExtraInfo().getWeiQuanOrderFanAmount().compareTo(new BigDecimal(10)) >= 0) warnLevel = 2; } else { @@ -452,11 +455,11 @@ // long sameGoodsOrderCount = // commonOrderCountService.countSameGoodsOrderByUidAndHongBaoType(typeList, // record.getExtract().getUserInfo().getId(), - // Integer.parseInt(configService.get("admin_min_same_goods_order_count"))); + // Integer.parseInt(configService.get(ConfigKeyEnum.adminMinSameGoodsOrderCount.getKey()))); // long sameShopOrderCount = // commonOrderCountService.countSameShopOrderByUidAndHongBaoType(typeList, // record.getExtract().getUserInfo().getId(), - // Integer.parseInt(configService.get("admin_min_same_shop_order_count"))); + // Integer.parseInt(configService.get(ConfigKeyEnum.adminMinSameShopOrderCount.getKey()))); // if (sameGoodsOrderCount > 0 || sameShopOrderCount > 0) { // warnLevel = 3; // record.setExtraInfoStr( @@ -501,9 +504,9 @@ List<Integer> typeList = new ArrayList<>(); typeList.add(HongBaoV2.TYPE_ZIGOU); long sameGoodsOrderCount = commonOrderCountService.countSameGoodsOrderByUidAndHongBaoType(typeList, uid, - Integer.parseInt(configService.get("admin_min_same_goods_order_count"))); + Integer.parseInt(configService.get(ConfigKeyEnum.adminMinSameGoodsOrderCount.getKey()))); long sameShopOrderCount = commonOrderCountService.countSameShopOrderByUidAndHongBaoType(typeList, uid, - Integer.parseInt(configService.get("admin_min_same_shop_order_count"))); + Integer.parseInt(configService.get(ConfigKeyEnum.adminMinSameShopOrderCount.getKey()))); if (sameGoodsOrderCount > 0 || sameShopOrderCount > 0) { String text = (String.format("鍚屽簵閾�:%s 鍚屽晢鍝�:%s", sameShopOrderCount, sameGoodsOrderCount)); JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(text)); @@ -855,81 +858,122 @@ @RequestMapping(value = "getAuditTotal") public void getAuditTotal(String callback, String stateArray, Integer dateType, String year, String startTime, String endTime, PrintWriter out) { - - String validateMsg = AdminUtils.validateParams(dateType, startTime, endTime); - if (validateMsg != null) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg)); - return; - } - - 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; - } - try { - Object objectDate = null; - List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year); + 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; + } + Date beginDate = null; + Date endDate = null; + + if (dateType == 1) { + beginDate = TimeUtil.parse(startTime); + endDate = TimeUtil.parse(endTime); + } else if (dateType == 2) { + Calendar calendar=Calendar.getInstance(); + int currentYear = calendar.get(Calendar.YEAR); + if (!StringUtil.isNullOrEmpty(year)) { + currentYear = Integer.parseInt(year); + } + calendar.clear(); + calendar.set(Calendar.YEAR, currentYear); + beginDate =calendar.getTime(); + + calendar.clear(); + calendar.set(Calendar.YEAR, currentYear); + calendar.roll(Calendar.DAY_OF_YEAR, -1); + endDate=calendar.getTime(); + } else if (dateType == 3) { + beginDate = TimeUtil.parse("2018-01-01"); + endDate = new Date(); + } Gson gson = new Gson(); - List<Integer> stateList = gson.fromJson(stateArray, new TypeToken<ArrayList<Integer>>() { - }.getType()); - + List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year); + + String substring = stateArray.substring(1, stateArray.length()-1); + List<Integer> channelList = null; + if (stateArray != null && stateArray.trim().length() > 4) { + channelList = gson.fromJson(stateArray, new TypeToken<ArrayList<Integer>>() {}.getType()); + } + JSONArray line_list = new JSONArray(); - for (Integer state : stateList) { - JSONObject innerList = new JSONObject(); - if (state == null || state == 3) { - innerList.put("name", "鎬昏"); - } else if (state == 1) { - innerList.put("name", "閫氳繃鏁�"); - } else if (state == 2) { - innerList.put("name", "椹冲洖鏁�"); - } - - List<ChartTDO> list = extractAuditRecordService.countAuditTotal(state, dateType, year, startTime, - endTime); - 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"); + + if (channelList != null && channelList.size() > 0) { + for (Integer state : channelList) { + List<Object> list = getAuditData(dateList, dateType, beginDate, endDate, state); + String name = ""; + if (state == 1) { + name = "閫氳繃"; + } else if (state == 2) { + name = "椹冲洖"; } - innerList.put("data", gson.toJson(map.get("value"))); + JSONObject innerList = new JSONObject(); + innerList.put("name", name); + innerList.put("data", gson.toJson(list)); + line_list.add(innerList); } + } else { + List<Object> list = getAuditData(dateList, dateType, beginDate, endDate, null); + JSONObject innerList = new JSONObject(); + innerList.put("name", "鍏ㄩ儴"); + innerList.put("data", gson.toJson(list)); 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); + data.put("xAxis_list", gson.toJson(dateList)); JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); } catch (Exception e) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父")); + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("绯荤粺寮傚父")); e.printStackTrace(); } + } + + private List<Object> getAuditData(List<String> dateList, Integer dateType, Date beginDate, Date endDate, + Integer state) throws Exception{ + List<Object> list = new ArrayList<>(); + List<CountUserInfo> listHistory = extractAuditRecordService.getAuditCount(beginDate, endDate, state); + 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; } /** @@ -951,66 +995,90 @@ @RequestMapping(value = "getExtractApplyMoney") public void getExtractApplyMoney(String callback, Integer dateType, String year, String startTime, String endTime, PrintWriter out) { - String validateMsg = AdminUtils.validateParams(dateType, startTime, endTime); - if (validateMsg != null) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg)); - return; - } - - 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; - } - try { - - Object objectDate = null; - List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year); - - Gson gson = new Gson(); - JSONObject innerList = new JSONObject(); - innerList.put("name", "鎬昏"); - - List<ChartTDO> list = extractAuditRecordService.countExtractApplyMoney(null, dateType, year, startTime, - endTime); - - 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"))); + 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; + } + + Date beginDate = null; + Date endDate = null; + if (dateType == 1) { + beginDate = TimeUtil.parse(startTime); + endDate = TimeUtil.parse(endTime); + } else if (dateType == 2) { + Calendar calendar=Calendar.getInstance(); + int currentYear = calendar.get(Calendar.YEAR); + if (!StringUtil.isNullOrEmpty(year)) { + currentYear = Integer.parseInt(year); + } + + calendar.clear(); + calendar.set(Calendar.YEAR, currentYear); + beginDate =calendar.getTime(); + + calendar.clear(); + calendar.set(Calendar.YEAR, currentYear); + calendar.roll(Calendar.DAY_OF_YEAR, -1); + endDate=calendar.getTime(); + } else if (dateType == 3) { + beginDate = TimeUtil.parse("2018-01-01"); + endDate = new Date(); + } + Gson gson = new Gson(); + List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year); + + List<String> list = new ArrayList<>(); + List<CountUserInfo> listHistory = extractAuditRecordService.getApplyMoney(beginDate, endDate); + for (String date: dateList) { + BigDecimal money = new BigDecimal("0"); + if (listHistory == null) { + list.add(money.toString()); + continue; + } + + for (CountUserInfo history: listHistory) { + if (dateType == 1) { + String gernalTime = TimeUtil.getGernalTime(history.getDay().getTime()); + if (gernalTime.equalsIgnoreCase(date)) { + 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)) { + money = MoneyBigDecimalUtil.add(money, history.getMoney()); + continue; + } + } else if (dateType == 3) { + String gernalTime = TimeUtil.getYearOnlyYYYY(history.getDay()); + if (gernalTime.equalsIgnoreCase(date)) { + money = MoneyBigDecimalUtil.add(money, history.getMoney()); + continue; + } + } + } + list.add(money.toString()); + } + + JSONObject innerList = new JSONObject(); + innerList.put("name", "閲戦"); + innerList.put("data", gson.toJson(list)); 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("xAxis_list", gson.toJson(dateList)); data.put("line_list", line_list); JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); } catch (Exception e) { @@ -1040,69 +1108,96 @@ @RequestMapping(value = "getExtractApplyNumber") public void getExtractApplyNumber(String callback, Integer state, Integer dateType, String year, String startTime, String endTime, PrintWriter out) { - String validateMsg = AdminUtils.validateParams(dateType, startTime, endTime); - if (validateMsg != null) { - JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg)); - return; - } - - 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; - } - try { - Object objectDate = null; + 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; + } + + + Date beginDate = null; + Date endDate = null; + + if (dateType == 1) { + beginDate = TimeUtil.parse(startTime); + endDate = TimeUtil.parse(endTime); + } else if (dateType == 2) { + Calendar calendar=Calendar.getInstance(); + int currentYear = calendar.get(Calendar.YEAR); + if (!StringUtil.isNullOrEmpty(year)) { + currentYear = Integer.parseInt(year); + } + + calendar.clear(); + calendar.set(Calendar.YEAR, currentYear); + beginDate =calendar.getTime(); + + calendar.clear(); + calendar.set(Calendar.YEAR, currentYear); + calendar.roll(Calendar.DAY_OF_YEAR, -1); + endDate=calendar.getTime(); + } else if (dateType == 3) { + beginDate = TimeUtil.parse("2018-01-01"); + endDate = new Date(); + } Gson gson = new Gson(); List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year); - - JSONObject innerList = new JSONObject(); - innerList.put("name", "鎬昏"); - - List<ChartTDO> list = extractAuditRecordService.countExtractApplyNumber(null, dateType, year, startTime, - endTime); - - 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"); + + List<Object> list = new ArrayList<>(); + List<CountUserInfo> listHistory = extractAuditRecordService.geApplyNumber(beginDate, endDate); + for (String date: dateList) { + int value = 0; + if (listHistory == null) { + list.add(value + ""); + continue; } - innerList.put("data", gson.toJson(map.get("value"))); + + 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 + ""); } + + JSONObject innerList = new JSONObject(); + innerList.put("name", "鏁伴噺"); + innerList.put("data", gson.toJson(list)); 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("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