| | |
| | | public void getTrackAccuracyRate(String callback, Integer dateType, String year,
|
| | | String startTime, String endTime, PrintWriter out) {
|
| | |
|
| | | 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;
|
| | | }
|
| | |
|
| | | 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 {
|
| | |
|
| | | List<Map<String, Object>> resultList = commonOrderCountService.getTrackAccuracyRate(dateType,
|
| | | |
| | | Gson gson = new Gson();
|
| | | Object objectDate = null;
|
| | | List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year);
|
| | | |
| | | JSONArray line_list = new JSONArray();
|
| | | |
| | | List<Map<String, Object>> list = commonOrderCountService.getTrackAccuracyRate(dateType,
|
| | | year, startTime, endTime);
|
| | |
|
| | | if (resultList == null) {
|
| | | resultList = new ArrayList<Map<String, Object>>();
|
| | | 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) {
|
| | |
| | | public void getWeiQaunOrderNumber(String callback, Integer dateType, String year,
|
| | | String startTime, String endTime, PrintWriter out) {
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(startTime) || StringUtil.isNullOrEmpty(endTime)) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择正确时间区间"));
|
| | | String validateMsg = AdminUtils.validateParams(dateType, startTime, endTime);
|
| | | if (validateMsg != null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg));
|
| | | return;
|
| | | }
|
| | |
|
| | | try {
|
| | |
|
| | | List<Map<String, Object>> resultList = commonOrderCountService.countWeiQaunOrderNumber(dateType,
|
| | | 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);
|
| | | |
| | | JSONObject data = countWeiQaunOrder(dateType, year, startTime, endTime, 1);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | |
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("系统异常"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
| | | public void getWeiQaunOrderMoney(String callback, Integer dateType, String year,
|
| | | String startTime, String endTime, PrintWriter out) {
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(startTime) || StringUtil.isNullOrEmpty(endTime)) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择正确时间区间"));
|
| | | String validateMsg = AdminUtils.validateParams(dateType, startTime, endTime);
|
| | | if (validateMsg != null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg));
|
| | | return;
|
| | | }
|
| | |
|
| | | try {
|
| | |
|
| | | List<Map<String, Object>> resultList = commonOrderCountService.countWeiQaunOrderMoney(dateType,
|
| | | 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);
|
| | | JSONObject data = countWeiQaunOrder(dateType, year, startTime, endTime, 2);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | |
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("系统异常"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | |
|
| | | /**
|
| | | * 统计红包信息
|
| | | * @param channelArray
|
| | | * @param dateType
|
| | | * @param state
|
| | | * @param year
|
| | | * @param startTime
|
| | | * @param endTime
|
| | | * @return
|
| | | * @throws Exception
|
| | | */
|
| | | public JSONObject countWeiQaunOrder(Integer dateType, String year, String startTime,
|
| | | String endTime, int countType) throws Exception {
|
| | |
|
| | | 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);
|
| | | |
| | | JSONArray line_list = new JSONArray();
|
| | | List<Map<String, Object>> list = null;
|
| | | if (countType == 1 ) {
|
| | | list = commonOrderCountService.countWeiQaunOrderNumber(dateType, year, startTime, endTime);
|
| | | } else if (countType == 2) {
|
| | | list = commonOrderCountService.countWeiQaunOrderMoney(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")));
|
| | | }
|
| | | |
| | | 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);
|
| | | |
| | | return data;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | |
| | | <select id="countOrderNumber" resultType="java.util.HashMap"> |
| | | SELECT IFNULL(COUNT(t.`co_id`),0) AS showValue,<include refid="Column_DateType"/> |
| | | `yeshi_ec_common_order` t |
| | | FROM `yeshi_ec_common_order` t |
| | | WHERE t.`co_create_time` IS NOT NULL <include refid="Count_Select_DateType"/> |
| | | <include refid="Count_Group_DateType"/> |
| | | ORDER BY t.`co_create_time` |
| | |
| | | </sql> |
| | | |
| | | <select id="countOrderNumber" resultType="java.util.HashMap"> |
| | | SELECT IFNULL(COUNT(t.`co_id`),0) AS showValue,<include refid="Column_DateType"/> |
| | | `yeshi_ec_taobao_order` t |
| | | SELECT IFNULL(COUNT(t.`to_id`),0) AS showValue,<include refid="Column_DateType"/> |
| | | FROM `yeshi_ec_taobao_order` t |
| | | WHERE t.`to_create_time` IS NOT NULL <include refid="Count_Select_DateType"/> |
| | | <include refid="Count_Group_DateType"/> |
| | | ORDER BY t.`to_create_time` |
| | |
| | | <select id="countWeiQaunOrderMoney" resultType="java.util.HashMap"> |
| | | SELECT CAST(SUM(t.`tmo_fan_money`)AS DECIMAL(19,2)) AS showValue,<include refid="Column_DateType"/> |
| | | FROM yeshi_ec_taobao_weiqaun_order t |
| | | WHEREt.`tmo_createtime` IS NOT NULL <include refid="Count_Select_DateType"/> |
| | | WHERE t.`tmo_createtime` IS NOT NULL <include refid="Count_Select_DateType"/> |
| | | <include refid="Count_Group_DateType"/> |
| | | ORDER BY t.`tmo_createtime` |
| | | </select> |
| | |
| | | package com.yeshi.fanli.service.impl.count;
|
| | |
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.text.DecimalFormat;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
| | | }
|
| | | mapObject.put("showValue", total);
|
| | |
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
| | | SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/MM/dd");
|
| | | Date parseDate = sdf.parse(plusDay.toString());
|
| | |
|
| | | mapObject.put("showDate", sdf2.format(parseDate));
|
| | | mapObject.put("showDate", plusDay);
|
| | |
|
| | | listObject.add(mapObject);
|
| | |
|
| | |
| | | total = 0;
|
| | | }
|
| | | mapObject.put("showValue", total);
|
| | |
|
| | | mapObject.put("showDate", i + "月");
|
| | | |
| | | if (i <10) {
|
| | | mapObject.put("showDate", "0"+ i);
|
| | | } else {
|
| | | mapObject.put("showDate", i);
|
| | | }
|
| | |
|
| | | listObject.add(mapObject);
|
| | | }
|
| | |
| | | break;
|
| | | }
|
| | |
|
| | | DecimalFormat df = new DecimalFormat("#.00");
|
| | |
|
| | | for (int i = 0; i < result_list.size(); i++) {
|
| | |
|
| | | float proportion = 0;
|
| | | double proportion = 0;
|
| | | Map<String, Object> resultMap = result_list.get(i);
|
| | |
|
| | | Object showDate = resultMap.get("showDate");
|
| | | for (int j = 0; j < listTotal.size(); j++) {
|
| | | Map<String, Object> innerMap = result_list.get(j);
|
| | | Map<String, Object> innerMap = listTotal.get(j);
|
| | | Object innerDate = innerMap.get("showDate");
|
| | |
|
| | | if (innerDate != null && innerDate.toString().equals(showDate.toString())) {
|
| | |
| | | long showData = Long.parseLong(showValue.toString());
|
| | |
|
| | | if (showData > 0) {
|
| | | proportion = innerData/showData;
|
| | | proportion = innerData/(double)showData;
|
| | | }
|
| | |
|
| | | break; // 结束内部循环
|
| | | }
|
| | | }
|
| | |
|
| | | resultMap.put("showValue", proportion);
|
| | | resultMap.put("showValue", Double.parseDouble(df.format(proportion *100)));
|
| | | }
|
| | |
|
| | | return result_list;
|
| | |
| | | @Override
|
| | | public List<Map<String, Object>> countWeiQaunOrderMoney(Integer dateType, String year, String startTime,
|
| | | String endTime) throws Exception{
|
| | | |
| | | List<Map<String, Object>> listTotal = taoBaoWeiQuanOrderMapper.countWeiQaunOrderMoney(dateType,
|
| | | year, startTime, endTime);
|
| | | |
| | | if (listTotal == null || listTotal.size() == 0) {
|
| | | return null;
|
| | | } |
| | | |
| | | switch (dateType){
|
| | | case 1: // 按天处理
|
| | | return dayFactory(startTime, endTime, listTotal);
|
| | | case 2: // 按月处理
|
| | | return monthFactory(listTotal);
|
| | | case 3: |
| | | return yearFactory(listTotal);
|
| | | default: |
| | | return null;
|
| | | }
|
| | | return taoBaoWeiQuanOrderMapper.countWeiQaunOrderMoney(dateType, year, startTime, endTime);
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | public List<Map<String, Object>> countWeiQaunOrderNumber(Integer dateType, String year, String startTime,
|
| | | String endTime) throws Exception{
|
| | | return taoBaoWeiQuanOrderMapper.countWeiQaunOrderNumber(dateType, year, startTime, endTime);
|
| | |
|
| | | List<Map<String, Object>> listTotal = taoBaoWeiQuanOrderMapper.countWeiQaunOrderNumber(dateType,
|
| | | year, startTime, endTime);
|
| | | |
| | | if (listTotal == null || listTotal.size() == 0) {
|
| | | return null;
|
| | | } |
| | | |
| | | switch (dateType){
|
| | | case 1: // 按天处理
|
| | | return dayFactory(startTime, endTime, listTotal);
|
| | | case 2: // 按月处理
|
| | | return monthFactory(listTotal);
|
| | | case 3: |
| | | return yearFactory(listTotal);
|
| | | default: |
| | | return null;
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | |
| | | |
| | | }
|
| | |
| | | }
|
| | |
|
| | |
|
| | | |
| | | public List<Object> dayFactory(String startTime, String endTime, List<Map<String, Object>> list) throws Exception {
|
| | | |
| | | List<Object> listObject = new ArrayList<Object>();
|
| | | |
| | | if (startTime.equals(endTime)) {
|
| | | |
| | | Map<String, Object> map = list.get(0);
|
| | | Object total = map.get("total");
|
| | | if (total == null) {
|
| | | map.put("payMoney", 0);
|
| | | }
|
| | | listObject.add(map);
|
| | | return listObject;
|
| | | }
|
| | | |
| | | |
| | | String plusDay = "";
|
| | | for (int i = 0; i < 1000 ; i++) {
|
| | | if (i == 0) {
|
| | | plusDay = startTime;
|
| | | } else {
|
| | | plusDay = DateUtil.plusDay(i, startTime);
|
| | | }
|
| | | |
| | | Map<String, Object> mapObject = new HashMap<String, Object>();
|
| | | Object total = null;
|
| | | |
| | | for (int j = 0; j < list.size(); j++) {
|
| | | Map<String, Object> map = list.get(j);
|
| | | Object createDate = map.get("createDate");
|
| | | String month = createDate.toString();
|
| | | if (plusDay.equalsIgnoreCase(month)) {
|
| | | total = map.get("total");
|
| | | break;
|
| | | }
|
| | | }
|
| | | |
| | | if (total == null) {
|
| | | total = 0;
|
| | | }
|
| | | mapObject.put("total", total);
|
| | | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
| | | SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/MM/dd");
|
| | | Date parseDate = sdf.parse(plusDay.toString());
|
| | | |
| | | mapObject.put("createDate", sdf2.format(parseDate));
|
| | | |
| | | listObject.add(mapObject);
|
| | | |
| | | if (plusDay.equals(endTime)) {
|
| | | break; // 时间结束
|
| | | }
|
| | | }
|
| | | |
| | | return listObject;
|
| | | }
|
| | | |
| | | |
| | | public List<Object> monthFactory(List<Map<String, Object>> list) {
|
| | | |
| | | List<Object> listObject = new ArrayList<Object>();
|
| | | // 12 个月处理
|
| | | for (int i = 1; i <= 12; i++) {
|
| | | Map<String, Object> mapObject = new HashMap<String, Object>();
|
| | | Object total = null;
|
| | | |
| | | for (int j = 0; j < list.size(); j++) {
|
| | | Map<String, Object> map = list.get(j);
|
| | | Object createDate = map.get("createDate");
|
| | | String month = createDate.toString();
|
| | | if ((i+"").equalsIgnoreCase(month) || i == Integer.parseInt(month)) {
|
| | | total = map.get("total");
|
| | | break;
|
| | | }
|
| | | }
|
| | | |
| | | if (total == null) {
|
| | | total = 0;
|
| | | }
|
| | | mapObject.put("total", total);
|
| | | |
| | | mapObject.put("createDate", i + "月");
|
| | | |
| | | listObject.add(mapObject);
|
| | | }
|
| | | return listObject;
|
| | | }
|
| | | |
| | | public List<Object> yearFactory(List<Map<String, Object>> list) {
|
| | | |
| | | List<Object> listObject = new ArrayList<Object>();
|
| | | |
| | | for (int i = 0; i < list.size(); i++) {
|
| | | Map<String, Object> map = list.get(i);
|
| | | Object total = map.get("total");
|
| | | |
| | | if (total == null) {
|
| | | total = 0;
|
| | | }
|
| | | map.put("total", total);
|
| | | |
| | | listObject.add(map);
|
| | | }
|
| | | |
| | | return listObject;
|
| | | }
|
| | |
|
| | |
|
| | | |
| | |
|
| | | }
|
| | |
| | | package com.yeshi.fanli.service.impl.order;
|
| | |
|
| | | import java.io.Serializable;
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
|
| | |
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.yeshi.utils.DateUtil;
|
| | | import org.yeshi.utils.NumberUtil;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.order.LostOrderMapper;
|
| | |
| | | @Override
|
| | | public List<Map<String, Object>> countAppealMoney( Integer dateType, String year, String startTime,
|
| | | String endTime) throws Exception {
|
| | | |
| | | return lostOrderMapper.countAppealMoney(dateType, year, startTime, endTime);
|
| | | }
|
| | |
|