yujian
2019-01-08 85b08b045c79180a81abd43be0ac7fd2ae50cd46
后台数据统计+ 订单接口统计类型调整
28个文件已修改
4个文件已添加
1893 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/admin/ExtractAdminController.java 74 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/LostOrderAdminController.java 134 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/OrderAdminController.java 225 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/UserInfoAdminController.java 81 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/UserOrderController.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/HongBaoV2CountMapper.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/order/CommonOrderCountMapper.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/order/LostOrderMapper.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/taobao/TaoBaoOrderMapper.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/taobao/TaoBaoWeiQuanOrderMapper.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/user/UserActiveLogMapper.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/ExtractAuditRecordMapper.xml 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/UserInfoMapper.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/hongbao/HongBaoV2CountMapper.xml 119 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderCountMapper.xml 58 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderMapper.xml 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/order/LostOrderMapper.xml 81 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/taobao/TaoBaoOrderMapper.xml 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/taobao/TaoBaoWeiQuanOrderMapper.xml 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/user/UserActiveLogMapper.xml 97 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/count/CommonOrderCountServiceImpl.java 258 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/count/HongBaoV2CountServiceImpl.java 81 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoServiceImpl.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/LostOrderServiceImpl.java 157 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/ExtractAuditRecordServiceImpl.java 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserActiveLogServiceImpl.java 134 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/count/HongBaoV2CountService.java 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/order/CommonOrderCountService.java 49 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/order/LostOrderService.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserActiveLogService.java 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/vo/order/CommonOrderVO.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/ExtractAdminController.java
@@ -15,6 +15,7 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Controller;
@@ -1436,28 +1437,41 @@
     * @param out
     */
    @RequestMapping(value = "getAuditTotal")
    public void getAuditTotal(String callback,Integer state, Integer shwoType, String year,
    public void getAuditTotal(String callback,Integer state, Integer dateType, String year,
            String startTime, String endTime, PrintWriter out) {
        String validateMsg = validateParams(shwoType, startTime, endTime);
        String validateMsg = validateParams(dateType, startTime, endTime);
        if (validateMsg != null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg));
            return;
        }
        
        if (shwoType != 1 && (!StringUtil.isNullOrEmpty(startTime) || !StringUtil.isNullOrEmpty(endTime))) {
        if (dateType != 1 && (!StringUtil.isNullOrEmpty(startTime) || !StringUtil.isNullOrEmpty(endTime))) {
            startTime = null;
            endTime = null;
        }
        
        try {
            List<Map<String, Object>> resultList = extractAuditRecordService.countAuditTotal(state, shwoType,
            List<Map<String, Object>> resultList = extractAuditRecordService.countAuditTotal(state, dateType,
                    year, startTime, endTime);
            
            JSONObject innerList = new JSONObject();
            if (state == null) {
                innerList.put("name", "总计");
            } else if (state == 1) {
                innerList.put("name", "通过数");
            } else if (state == 2) {
                innerList.put("name", "驳回数");
            }
            innerList.put("data_list", resultList);
            JSONArray outList = new JSONArray();
            outList.add(innerList);
            JSONObject data = new JSONObject();
            data.put("result_list", resultList);
            data.put("result_list", outList);
            
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
            
@@ -1480,28 +1494,43 @@
     * @param out
     */
    @RequestMapping(value = "getExtractMoney")
    public void getExtractMoney(String callback,Integer state, Integer shwoType, String year,
    public void getExtractMoney(String callback,Integer state, Integer dateType, String year,
            String startTime, String endTime, PrintWriter out) {
        String validateMsg = validateParams(shwoType, startTime, endTime);
        String validateMsg = validateParams(dateType, startTime, endTime);
        if (validateMsg != null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg));
            return;
        }
        
        
        if (shwoType != 1 && (!StringUtil.isNullOrEmpty(startTime) || !StringUtil.isNullOrEmpty(endTime))) {
        if (dateType != 1 && (!StringUtil.isNullOrEmpty(startTime) || !StringUtil.isNullOrEmpty(endTime))) {
            startTime = null;
            endTime = null;
        }
        
        try {
            List<Map<String, Object>> resultList = extractAuditRecordService.countExtractMoney(state, shwoType,
            List<Map<String, Object>> resultList = extractAuditRecordService.countExtractMoney(state, dateType,
                    year, startTime, endTime);
            
            JSONObject innerList = new JSONObject();
            if (state == null) {
                innerList.put("name", "总计");
            } else if (state == 0) {
                innerList.put("name", "待审核");
            } else if (state == 1) {
                innerList.put("name", "通过");
            } else if (state == 2) {
                innerList.put("name", "驳回");
            }
            innerList.put("data_list", resultList);
            JSONArray outList = new JSONArray();
            outList.add(innerList);
            JSONObject data = new JSONObject();
            data.put("result_list", resultList);
            data.put("result_list", outList);
            
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
            
@@ -1523,28 +1552,43 @@
     * @param out
     */
    @RequestMapping(value = "getExtractApplyNumber")
    public void getExtractApplyNumber(String callback,Integer state, Integer shwoType, String year,
    public void getExtractApplyNumber(String callback,Integer state, Integer dateType, String year,
            String startTime, String endTime, PrintWriter out) {
        String validateMsg = validateParams(shwoType, startTime, endTime);
        String validateMsg = validateParams(dateType, startTime, endTime);
        if (validateMsg != null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg));
            return;
        }
        
        
        if (shwoType != 1 && (!StringUtil.isNullOrEmpty(startTime) || !StringUtil.isNullOrEmpty(endTime))) {
        if (dateType != 1 && (!StringUtil.isNullOrEmpty(startTime) || !StringUtil.isNullOrEmpty(endTime))) {
            startTime = null;
            endTime = null;
        }
        
        try {
            List<Map<String, Object>> resultList = extractAuditRecordService.countExtractApplyNumber(state, shwoType,
            List<Map<String, Object>> resultList = extractAuditRecordService.countExtractApplyNumber(state, dateType,
                    year, startTime, endTime);
            
            JSONObject innerList = new JSONObject();
            if (state == null) {
                innerList.put("name", "总计");
            } else if (state == 0) {
                innerList.put("name", "待审核");
            } else if (state == 1) {
                innerList.put("name", "通过");
            } else if (state == 2) {
                innerList.put("name", "驳回");
            }
            innerList.put("data_list", resultList);
            JSONArray outList = new JSONArray();
            outList.add(innerList);
            JSONObject data = new JSONObject();
            data.put("result_list", resultList);
            data.put("result_list", outList);
            
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
            
fanli/src/main/java/com/yeshi/fanli/controller/admin/LostOrderAdminController.java
@@ -1,11 +1,13 @@
package com.yeshi.fanli.controller.admin;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Controller;
@@ -21,6 +23,7 @@
import com.yeshi.fanli.tag.PageEntity;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.GsonUtil;
import com.yeshi.fanli.util.StringUtil;
@Controller
@RequestMapping("admin/new/api/v1/lostOrder")
@@ -214,4 +217,135 @@
        }
        
    }
    /**
     * 验证统计信息参数
     * @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;
    }
    /**
     * 统计提现申请总次数
     * @param callback
     * @param dateType     显示视图:日-1 、月-2、 年-3
     * @param state 状态:  1-未处理 2-成功  3-失败
     * @param year
     * @param startTime
     * @param endTime
     * @param out
     */
    @RequestMapping(value = "getLostNum")
    public void getLostNum(String callback, Integer dateType, Integer state, String year, String startTime,
            String endTime, PrintWriter out) {
        String validateMsg = validateParams(dateType, startTime, endTime);
        if (validateMsg != null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg));
            return;
        }
        try {
            if (dateType != 1 && (!StringUtil.isNullOrEmpty(startTime) || !StringUtil.isNullOrEmpty(endTime))) {
                startTime = null;
                endTime = null;
            }
            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);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("系统异常"));
            e.printStackTrace();
        }
    }
    /**
     * 统计申诉金额总数
     * @param callback
     * @param dateType 显示视图:日-1 、月-2、 年-3
     * @param year
     * @param startTime
     * @param endTime
     * @param out
     */
    @RequestMapping(value = "getAppealMoney")
    public void getAppealMoney(String callback, Integer dateType, String year, String startTime, String endTime,
            PrintWriter out) {
        String validateMsg = validateParams(dateType, startTime, endTime);
        if (validateMsg != null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg));
            return;
        }
        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>>();
            }
            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);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("系统异常"));
            e.printStackTrace();
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/controller/admin/OrderAdminController.java
@@ -20,6 +20,7 @@
import com.yeshi.fanli.entity.admin.OrderAdmin;
import com.yeshi.fanli.service.inter.count.HongBaoV2CountService;
import com.yeshi.fanli.service.inter.hongbao.HongBaoService;
import com.yeshi.fanli.service.inter.order.CommonOrderCountService;
import com.yeshi.fanli.service.inter.order.OrderService;
import com.yeshi.fanli.tag.PageEntity;
import com.yeshi.fanli.util.Constant;
@@ -37,6 +38,9 @@
    @Resource
    private HongBaoV2CountService hongBaoV2CountService;
    @Resource
    private CommonOrderCountService commonOrderCountService;
    @RequestMapping(value = "getOrderList", method = RequestMethod.POST)
    public void getOrderList(int pageIndex, String key, PrintWriter out) {
@@ -129,7 +133,7 @@
                    resultList = new ArrayList<Object>();
                }
                channelData.put("name", channel);
                channelData.put("infos", resultList);
                channelData.put("data_list", resultList);
                array.add(channelData);
            }
@@ -288,7 +292,7 @@
                channel = "总计";
            }
            channelData.put("name", channel);
            channelData.put("infos", resultList);
            channelData.put("data_list", resultList);
            array.add(channelData);
        }
@@ -298,4 +302,221 @@
        return data;
    }
    /**
     * 分类型订单数与比例
     * @param callback
     * @param dateType 日 -1 月-2 年-3
     * @param type     返利订单-1  分享订单-2  邀请订单-3
     * @param year
     * @param startTime
     * @param endTime
     * @param out
     */
    @RequestMapping(value = "getTypeRate")
    public void getTypeRate(String callback, Integer dateType, Integer type, String year,
            String startTime, String endTime, PrintWriter out) {
        if (StringUtil.isNullOrEmpty(startTime) || StringUtil.isNullOrEmpty(endTime)) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择正确时间区间"));
            return;
        }
        if (type == null || dateType ==null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("视图类型、订单类型不能为空"));
            return;
        }
        try {
            List<Map<String, Object>> resultList = hongBaoV2CountService.getProportionByType(dateType,
                    type, year, startTime, endTime);
            if (resultList == null) {
                resultList = new ArrayList<Map<String, Object>>();
            }
            JSONObject innerList = new JSONObject();
            if (type == 1) {
                innerList.put("name", "返利订单");
            } else if (type == 2) {
                innerList.put("name", "分享订单");
            } else if (type == 3) {
                innerList.put("name", "邀请订单");
            }
            innerList.put("data_list", resultList);
            JSONArray outList = new JSONArray();
            outList.add(innerList);
            JSONObject data = new JSONObject();
            data.put("result_list", outList);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
            e.printStackTrace();
        }
    }
    /**
     * 订单跟踪准确率(返利券用户订单/淘宝联盟订单)
     * @param callback
     * @param dateType
     * @param year
     * @param startTime
     * @param endTime
     * @param out
     */
    @RequestMapping(value = "getTrackAccuracyRate")
    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;
        }
        try {
            List<Map<String, Object>> resultList = commonOrderCountService.getTrackAccuracyRate(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);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
            e.printStackTrace();
        }
    }
    /**
     * 当前未收货订单数
     * @param callback
     * @param type 订单状态-暂未使用
     * @param out
     */
    @RequestMapping(value = "getHistoryUnreceived")
    public void getHistoryUnreceived(String callback, Integer type, PrintWriter out) {
        try {
            Long total = commonOrderCountService.countByState(1);
            if (total == null) {
                total = 0L;
            }
            JSONObject data = new JSONObject();
            data.put("total", total);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
            e.printStackTrace();
        }
    }
    /**
     * 维权订单数
     * @param callback
     * @param dateType
     * @param year
     * @param startTime
     * @param endTime
     * @param out
     */
    @RequestMapping(value = "getWeiQaunOrderNumber")
    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("请选择正确时间区间"));
            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);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
            e.printStackTrace();
        }
    }
    /**
     * 维权订单金额
     * @param callback
     * @param dateType
     * @param year
     * @param startTime
     * @param endTime
     * @param out
     */
    @RequestMapping(value = "getWeiQaunOrderMoney")
    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("请选择正确时间区间"));
            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);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
            e.printStackTrace();
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/controller/admin/UserInfoAdminController.java
@@ -1219,7 +1219,7 @@
                    resultList = new ArrayList<Object>();
                }
                channelData.put("name", channel);
                channelData.put("infos", resultList);
                channelData.put("data_list", resultList);
                array.add(channelData);
            }
            
@@ -1273,13 +1273,80 @@
                    resultList = new ArrayList<Object>();
                }
                channelData.put("name", channel);
                channelData.put("infos", resultList);
                channelData.put("data_list", 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();
        }
    }
    /**
     * 当周产生3单的新增用户概率
     * @param callback
     * @param channelArray 渠道名称
     * @param startTime
     * @param endTime
     * @param orderNum 订单数量
     * @param out
     */
    @RequestMapping(value = "getWeekProportion")
    public void getWeekProportion(String callback, String channelArray, String startTime, String endTime,
            Integer orderNum, PrintWriter out) {
        if (StringUtil.isNullOrEmpty(startTime) || StringUtil.isNullOrEmpty(endTime)) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择正确时间区间"));
            return;
        }
        try {
            if (orderNum == null ) {
                orderNum = 0;
            }
            List<String> channelList = null;
            if (channelArray != null && channelArray.trim().length() > 0) {
                Gson gson = new Gson();
                channelList = gson.fromJson(channelArray, new TypeToken<ArrayList<String>>() {}.getType());
            }
            if (channelList == null || channelList.size() == 0) {
                channelList = new ArrayList<String>();
                channelList.add("all");
            }
            JSONArray array = new JSONArray();
            for (String channel : channelList) {
                JSONObject channelData = new JSONObject();
                List<Map<String, Object>> resultList = userActiveLogService.countOneWeekUserInfo(channel,
                        startTime, endTime, orderNum);
                if (resultList == null) {
                    resultList = new ArrayList<Map<String, Object>>();
                }
                if ("all".equalsIgnoreCase(channel)) {
                    channel = "总计";
                }
                channelData.put("name", channel);
                channelData.put("data_list", resultList);
                array.add(channelData);
            }
            JSONObject data = new JSONObject();
            data.put("result_list", array);
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
@@ -1361,8 +1428,16 @@
                resultList = new ArrayList<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", resultList);
            data.put("result_list", outList);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
fanli/src/main/java/com/yeshi/fanli/controller/client/UserOrderController.java
@@ -105,8 +105,9 @@
                // 统计总数
                count = commonOrderService.countGroupOrderNoByUid(uid,  state, type, orderState, orderNo, 
                        startTime, endTime, dateType);
            }
                
                // 需要统计信息
            // 需要统计筛选信息 :未失效的总金额 以及订单
                if (needCount && page == 1) {
                    Map<String, Object> countMap = commonOrderService.countMoneyGroupOrderNoByUid(uid, type,
                            orderNo, startTime, endTime, dateType);
@@ -120,7 +121,7 @@
                        todayTotal  = (long) countMap.get("totalRow");
                    }
                }
            }
            
            int totalValid = 0;
            int totalProces = 0;
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/HongBaoV2CountMapper.java
@@ -35,5 +35,33 @@
            @Param("state") Integer state, @Param("year") String year, 
            @Param("startTime")String startTime, @Param("endTime")String endTime);
    
    /**
     * 统计总个数
     * @param channel 渠道
     * @param type
     * @param state
     * @param years
     * @param startTime
     * @param endTime
     * @return
     */
    List<Map<String, Object>> countHongBaoType(@Param("dateType")Integer dateType,
            @Param("type") Integer type, @Param("year") String year,
            @Param("startTime")String startTime, @Param("endTime")String endTime);
    /**
     * 统计总个数
     * @param channel 渠道
     * @param type
     * @param state
     * @param years
     * @param startTime
     * @param endTime
     * @return
     */
    List<Map<String, Object>> countHongBaoTotalNum(@Param("dateType")Integer dateType, @Param("year") String year,
            @Param("startTime")String startTime, @Param("endTime")String endTime);
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/order/CommonOrderCountMapper.java
New file
@@ -0,0 +1,28 @@
package com.yeshi.fanli.dao.mybatis.order;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Param;
public interface CommonOrderCountMapper {
    /**
     * 当前各个状态订单数
     * @param state 状态
     * @return
     */
    Long countByState(@Param("state")Integer state);
    /**
     *  统计所有订单
     * @param channel
     * @return
     */
    List<Map<String, Object>> countOrderNumber( @Param("dateType") Integer dateType, @Param("year") String year,
            @Param("startTime")String startTime, @Param("endTime")String endTime);
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/order/LostOrderMapper.java
@@ -37,4 +37,30 @@
            @Param("state") Integer state, @Param("handleType") Integer handleType);
    
    long countQuery(@Param("key") String key, @Param("state") Integer state, @Param("handleType") Integer handleType);
    /**
     * 统计申诉订单数量
     * @param type
     * @param state
     * @param years
     * @param startTime
     * @param endTime
     * @return
     */
    List<Map<String, Object>> countLostNum(@Param("dateType")Integer dateType,@Param("resultCode")Integer resultCode,
            @Param("year") String year, @Param("startTime")String startTime, @Param("endTime")String endTime);
    /**
     * 统计申诉成功订单金额
     * @param type
     * @param state
     * @param years
     * @param startTime
     * @param endTime
     * @return
     */
    List<Map<String, Object>> countAppealMoney(@Param("dateType")Integer dateType, @Param("year") String year,
            @Param("startTime")String startTime, @Param("endTime")String endTime);
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/taobao/TaoBaoOrderMapper.java
@@ -71,4 +71,13 @@
    TaoBaoOrder selectLatestByAuctionId(long auctionId);
    
    
    /**
     *  统计所有订单
     * @param channel
     * @return
     */
    List<Map<String, Object>> countOrderNumber( @Param("dateType") Integer dateType, @Param("year") String year,
            @Param("startTime")String startTime, @Param("endTime")String endTime);
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/taobao/TaoBaoWeiQuanOrderMapper.java
@@ -1,6 +1,7 @@
package com.yeshi.fanli.dao.mybatis.taobao;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Param;
@@ -29,5 +30,26 @@
            @Param("state") String state);
    
    
    /**
     * 统计总金额
     * @param dateType
     * @param years
     * @param startTime
     * @param endTime
     * @return
     */
    List<Map<String, Object>> countWeiQaunOrderNumber(@Param("dateType")Integer dateType, @Param("year") String year,
            @Param("startTime")String startTime, @Param("endTime")String endTime);
    /**
     * 统计总个数
     * @param dateType
     * @param years
     * @param startTime
     * @param endTime
     * @return
     */
    List<Map<String, Object>> countWeiQaunOrderMoney(@Param("dateType")Integer dateType, @Param("year") String year,
            @Param("startTime")String startTime, @Param("endTime")String endTime);
    
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/user/UserActiveLogMapper.java
@@ -1,5 +1,6 @@
package com.yeshi.fanli.dao.mybatis.user;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
@@ -42,12 +43,11 @@
            @Param("startTime")String startTime, @Param("endTime")String endTime);
    
    /**
     * 根据渠道   统计当日新增用户有购买行为的订单数量大于3
     * 统计
     * @param channel
     * @return
     */
    List<Map<String, Object>> countSameDayAndBuyGoodsByChannelAndBuyNum(@Param("channel")String channel,
            @Param("type")Integer type, @Param("years") String years,
    Map<String, BigDecimal> countOneWeekUserInfo(@Param("channel")String channel,
            @Param("startTime")String startTime, @Param("endTime")String endTime,
            @Param("orderNum")Integer orderNum);
            @Param("orderNumber")Integer orderNumber);
}
fanli/src/main/java/com/yeshi/fanli/mapping/ExtractAuditRecordMapper.xml
@@ -246,7 +246,7 @@
     
     
    <select id="countAuditTotal" resultType="java.util.HashMap">
        SELECT COALESCE(COUNT(tr.id),0) AS 'total',
        SELECT COALESCE(COUNT(tr.id),0) AS 'showValue',
            <if test="type == 1">
                 FROM_UNIXTIME(tr.`auditTime`/1000,'%Y-%m-%d') AS 'showDate'
            </if>
@@ -286,7 +286,7 @@
    </select>
    
    <select id="countExtractMoney" resultType="java.util.HashMap">
        SELECT CAST(SUM(t.`money`)AS DECIMAL(19,2)) AS total,
        SELECT CAST(SUM(t.`money`)AS DECIMAL(19,2)) AS showValue,
            <if test="type == 1">
                 FROM_UNIXTIME(t.`extractTime`/1000,'%Y-%m-%d') AS 'showDate'
            </if>
@@ -323,7 +323,7 @@
    </select>
    
    <select id="countExtractApplyNumber" resultType="java.util.HashMap">
        SELECT COUNT(t.id) AS total,
        SELECT COUNT(t.id) AS showValue,
            <if test="type == 1">
                 FROM_UNIXTIME(t.`extractTime`/1000,'%Y-%m-%d') AS 'showDate'
            </if>
fanli/src/main/java/com/yeshi/fanli/mapping/UserInfoMapper.xml
@@ -377,10 +377,9 @@
    </select>
    
    <select id="countHasOrderUser" resultType="java.lang.Long">
        SELECT COUNT(DISTINCT h.`uid`) FROM yeshi_ec_hongbao h
        WHERE h.`type`=1 OR h.`type`=20
        SELECT COUNT(DISTINCT h.`uid`) FROM yeshi_ec_hongbao_v2 h
        WHERE h.`hb_type`=1 or  h.`hb_type`=2
    </select>
    
    
    <select id="countNewUserByDate" resultType="java.util.HashMap">
fanli/src/main/java/com/yeshi/fanli/mapping/hongbao/HongBaoV2CountMapper.xml
@@ -49,8 +49,21 @@
            AND th.hb_state =4
        </if>
    </sql>
    <sql id="Count_Select_Type">
        <if test="type != null and type == 1"> <!-- 自购订单 -->
            AND (t.hb_type =1 or t.hb_type =2)
        </if>
        <if test="type != null and type == 2"> <!-- 分享订单 -->
            AND t.`hb_type` = 20
        </if>
        <if test="type != null and type == 3"> <!-- 邀请订单 -->
            AND (t.`hb_type` = 5 OR t.`hb_type` = 6 OR t.`hb_type` = 7 OR t.`hb_type` = 21 OR t.`hb_type` = 22)
        </if>
    </sql>
    <select id="countHongBaoMoney" resultType="java.util.HashMap">
        SELECT CAST(SUM(t.`hb_money`)AS DECIMAL(19,2)) AS total,<include refid="Column_DateType"/>
        SELECT CAST(SUM(t.`hb_money`)AS DECIMAL(19,2)) AS showValue,<include refid="Column_DateType"/>
        FROM yeshi_ec_hongbao_v2 t
        <if test="channel != null and  channel != 'all' ">
            LEFT JOIN (SELECT a.`lua_uid` AS uid FROM `yeshi_ec_log_user_active` a WHERE a.`lua_channel`='${channel}' GROUP BY a.`lua_uid`) a ON t.`hb_uid`=a.uid 
@@ -62,7 +75,7 @@
    </select>
    
    <select id="countHongBaoNum" resultType="java.util.HashMap">
        SELECT COUNT(t.`hb_id`)AS total,<include refid="Column_DateType"/>
        SELECT COUNT(t.`hb_id`)AS showValue,<include refid="Column_DateType"/>
        FROM yeshi_ec_hongbao_v2 t 
        <if test="channel != null and  channel != 'all' ">
            LEFT JOIN (SELECT a.`lua_uid` AS uid FROM `yeshi_ec_log_user_active` a WHERE a.`lua_channel`='${channel}' GROUP BY a.`lua_uid`) a ON t.`hb_uid`=a.uid 
@@ -74,4 +87,106 @@
    </select>
    
    <select id="countHongBaoType" resultType="java.util.HashMap">
        SELECT COUNT(t.`hb_id`)AS showValue,<include refid="Column_DateType"/>
        FROM yeshi_ec_hongbao_v2 t
        WHERE t.`hb_uid` IS NOT NULL
            <include refid="Count_Select_DateType"/>
            <include refid="Count_Select_Type"/>
        <include refid="Count_Group_DateType"/>
        ORDER BY t.`hb_create_time`
    </select>
    <select id="countHongBaoTotalNum" resultType="java.util.HashMap">
        SELECT COUNT(t.`hb_id`)AS showValue,<include refid="Column_DateType"/>
        FROM yeshi_ec_hongbao_v2 t
        WHERE t.`hb_uid` IS NOT NULL AND t.`hb_type` not in(1,3,4) <include refid="Count_Select_DateType"/>
        <include refid="Count_Group_DateType"/>
        ORDER BY t.`hb_create_time`
    </select>
        <select id="count24HOderByChannel" resultType="java.util.HashMap">
        SELECT  COALESCE(SUM(b.money*2),0) AS 'commision',  COALESCE(COUNT(b.id),0) AS'countOrder',
             COALESCE(SUM(b.payMoney),0) AS 'payMoney',
             <if test="type == 1">
                 FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') AS 'createDate'
            </if>
            <if test="type == 2">
                 FROM_UNIXTIME(u.`createtime`/1000,'%m') AS 'createDate'
            </if>
            <if test="type == 3">
                 FROM_UNIXTIME(u.`createtime`/1000,'%Y') AS 'createDate'
            </if>
        FROM
            (
            SELECT h.* FROM  yeshi_ec_hongbao_v2 h
            LEFT JOIN (SELECT a.`lua_uid` AS uid FROM `yeshi_ec_log_user_active`  a
                  WHERE a.`lua_channel`='${channel}' GROUP BY a.`lua_uid`) a
            ON a.uid=h.`uid` WHERE a.uid IS NOT NULL AND (h.`type`=1 OR h.`type`=20)
            ) b
        LEFT JOIN yeshi_ec_user u ON u.`id`=b.uid
        WHERE <![CDATA[b.createtime<u.`createtime`+1000*60*60*24 ]]>
            <if test="startTime != null and startTime != '' ">
                 AND FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
            </if>
            <if test="endTime != null and endTime != '' ">
                 AND FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') <![CDATA[ <= ]]> '${endTime}'
            </if>
            <if test="years != null and years != '' ">
                 AND FROM_UNIXTIME(u.`createtime`/1000,'%Y') = '${years}'
            </if>
        <if test="type == 1">
            GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d')
        </if>
        <if test="type == 2">
             GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m')
        </if>
        <if test="type == 3">
             GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y')
        </if>
        ORDER BY u.`createtime`
    </select>
    <select id="countHistoryOderByChannel" resultType="java.util.HashMap">
        SELECT  COALESCE(SUM(h.`money`)*2,0) AS 'commision', COALESCE(COUNT(h.id),0) AS 'countOrder',
             COALESCE(SUM(h.payMoney),0) AS 'payMoney',
                <if test="type == 1">
                     FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m-%d') AS 'createDate'
                </if>
                <if test="type == 2">
                     FROM_UNIXTIME(h.`createtime`/1000,'%m') AS 'createDate'
                </if>
                <if test="type == 3">
                     FROM_UNIXTIME(h.`createtime`/1000,'%Y') AS 'createDate'
                </if>
        FROM yeshi_ec_hongbao h
        LEFT JOIN (SELECT a.`lua_uid` AS uid FROM `yeshi_ec_log_user_active`  a
            WHERE a.`lua_channel`='${channel}' GROUP BY a.`lua_uid`) a ON h.`uid`=a.uid
        WHERE  (h.`type`=1 OR h.`type`=20)  AND  a.uid IS NOT NULL
                <if test="startTime != null and startTime != '' ">
                 AND FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
                </if>
                <if test="endTime != null and endTime != '' ">
                     AND FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m-%d') <![CDATA[ <= ]]> '${endTime}'
                </if>
                <if test="years != null and years != '' ">
                     AND FROM_UNIXTIME(h.`createtime`/1000,'%Y') = '${years}'
                </if>
        <if test="type == 1">
            GROUP BY FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m-%d')
        </if>
        <if test="type == 2">
             GROUP BY FROM_UNIXTIME(h.`createtime`/1000,'%Y-%m')
        </if>
        <if test="type == 3">
             GROUP BY FROM_UNIXTIME(h.`createtime`/1000,'%Y')
        </if>
        ORDER BY h.`createtime`
    </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderCountMapper.xml
New file
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeshi.fanli.dao.mybatis.order.CommonOrderCountMapper">
    <sql id="Column_DateType">
        <if test="dateType == 1">
            DATE_FORMAT(t.`co_create_time`,'%Y-%m-%d') AS 'showDate'
        </if>
        <if test="dateType == 2">
            DATE_FORMAT(t.`co_create_time`,'%m') AS 'showDate'
        </if>
        <if test="dateType == 3">
            DATE_FORMAT(t.`co_create_time`,'%Y') AS 'showDate'
        </if>
    </sql>
    <sql id="Count_Select_DateType">
        <if test="startTime != null and startTime != '' ">
            AND DATE_FORMAT(t.`co_create_time`,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
        </if>
        <if test="endTime != null and endTime != '' ">
            AND DATE_FORMAT(t.`co_create_time`,'%Y-%m-%d') <![CDATA[ <= ]]>'${endTime}'
        </if>
        <if test="year != null and year != '' ">
            AND DATE_FORMAT(t.`co_create_time`,'%Y') = '${year}'
        </if>
    </sql>
    <sql id="Count_Group_DateType">
        <if test="dateType == 1">
            GROUP BY DATE_FORMAT(t.`co_create_time`,'%Y-%m-%d')
        </if>
        <if test="dateType == 2">
            GROUP BY DATE_FORMAT(t.`co_create_time`,'%Y-%m')
        </if>
        <if test="dateType == 3">
            GROUP BY DATE_FORMAT(t.`co_create_time`,'%Y')
        </if>
    </sql>
    <select id="countByState" resultType="java.lang.Long">
        SELECT IFNULL(COUNT(t.`co_id`),0) FROM  `yeshi_ec_common_order` t
        WHERE 1=1
            <if test="type != null">
                AND t.`co_state` = #{state}
            </if>
    </select>
    <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
        WHERE t.`co_create_time` IS NOT NULL <include refid="Count_Select_DateType"/>
        <include refid="Count_Group_DateType"/>
        ORDER BY t.`co_create_time`
    </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/order/CommonOrderMapper.xml
@@ -89,8 +89,8 @@
            jdbcType="TIMESTAMP" />
        <result column="totalCount" property="totalCount" jdbcType="INTEGER" />
        <result column="totalSettlement" property="totalSettlement"
            jdbcType="DECIMAL" />
        <result column="totalSettlement" property="totalSettlement" jdbcType="DECIMAL" />
        <result column="totalPayment" property="totalPayment" jdbcType="DECIMAL" />
        <association property="userInfo" column="co_uid"
            resultMap="com.yeshi.fanli.dao.mybatis.UserInfoMapper.BaseResultMap">
@@ -299,7 +299,8 @@
            LEFT JOIN
            yeshi_ec_hongbao_v2 th ON (tr.`ho_hongbao_id` = th.`hb_id` OR
            th.`hb_pid` = tr.`ho_hongbao_id` )
            WHERE th.`hb_uid` = #{uid}     AND th.hb_state = 3 AND (tc.co_state = 1 or tc.co_state = 2)
            WHERE th.`hb_uid` = #{uid}
                AND (th.hb_state = 1 OR th.hb_state = 2 OR th.hb_state = 3)
            <if test="type != null and type == 1"> <!-- 自购订单 -->
                AND (th.hb_type =1 or th.hb_type =2)
            </if>
@@ -400,9 +401,8 @@
    <select id="listByOrderNoAndType" resultMap="ResultMap"
        parameterType="java.util.List">
        SELECT COALESCE(SUM(tc.`co_settlement`),0)AS
        totalSettlement,COALESCE(SUM(tc.`co_count`),0)AS
        totalCount,tc.`co_source_type`,tc.`co_order_no`,tg.*
        SELECT COALESCE(SUM(tc.`co_payment`),0)AS totalPayment,COALESCE(SUM(tc.`co_settlement`),0)AS totalSettlement,
            COALESCE(SUM(tc.`co_count`),0)AS totalCount,tc.`co_source_type`,tc.`co_order_no`,tg.*
        FROM
        yeshi_ec_common_order_goods tg
        LEFT JOIN yeshi_ec_common_order tc ON
fanli/src/main/java/com/yeshi/fanli/mapping/order/LostOrderMapper.xml
@@ -109,4 +109,85 @@
    </select>
      
      
      <select id="countLostNum" resultType="java.util.HashMap">
        SELECT COUNT(t.`id`) AS showValue,
            <if test="dateType == 1">
                 FROM_UNIXTIME(t.`createTime`/1000,'%Y-%m-%d') AS 'showDate'
            </if>
            <if test="dateType == 2">
                 FROM_UNIXTIME(t.`createTime`/1000,'%m') AS 'showDate'
            </if>
            <if test="dateType == 3">
                 FROM_UNIXTIME(t.`createTime`/1000,'%Y') AS 'showDate'
            </if>
        FROM `yeshi_ec_lost_order` t
        WHERE t.`createTime`IS NOT NULL
            <if test="startTime != null and startTime != '' ">
                 AND FROM_UNIXTIME(t.`createTime`/1000,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
            </if>
            <if test="endTime != null and endTime != '' ">
                 AND FROM_UNIXTIME(t.`createTime`/1000,'%Y-%m-%d') <![CDATA[ <= ]]> '${endTime}'
            </if>
            <if test="year != null and year != '' ">
                 AND FROM_UNIXTIME(t.`createTime`/1000,'%Y') = '${year}'
            </if>
            <if test="resultCode != null and resultCode != 0 ">
                 AND t.`result_code` = ${resultCode}
            </if>
        <if test="dateType == 1">
            GROUP BY FROM_UNIXTIME(t.`createTime`/1000,'%Y-%m-%d')
        </if>
        <if test="dateType == 2">
             GROUP BY FROM_UNIXTIME(t.`createTime`/1000,'%Y-%m')
        </if>
        <if test="dateType == 3">
             GROUP BY FROM_UNIXTIME(t.`createTime`/1000,'%Y')
        </if>
        ORDER BY t.`createTime`
    </select>
    <select id="countAppealMoney" resultType="java.util.HashMap">
        SELECT CAST(SUM(v.`hb_money`)AS DECIMAL(19,2)) AS showValue,
            <if test="dateType == 1">
                 FROM_UNIXTIME(t.`createTime`/1000,'%Y-%m-%d') AS 'showDate'
            </if>
            <if test="dateType == 2">
                 FROM_UNIXTIME(t.`createTime`/1000,'%m') AS 'showDate'
            </if>
            <if test="dateType == 3">
                 FROM_UNIXTIME(t.`createTime`/1000,'%Y') AS 'showDate'
            </if>
        FROM `yeshi_ec_lost_order` t
        LEFT JOIN  `yeshi_ec_common_order` tc ON tc.`co_order_no` = t.`orderId`
        LEFT JOIN  `yeshi_ec_hongbao_order` h ON h.`ho_order_id` = tc.`co_id`
        LEFT JOIN `yeshi_ec_hongbao_v2`v ON h.`ho_hongbao_id` = v.`hb_id`
        WHERE t.`createTime`IS NOT NULL  AND t.`result_code` = 2 AND (v.`hb_type` =1 OR v.`hb_type` = 2)
            <if test="startTime != null and startTime != '' ">
                 AND FROM_UNIXTIME(t.`createTime`/1000,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
            </if>
            <if test="endTime != null and endTime != '' ">
                 AND FROM_UNIXTIME(t.`createTime`/1000,'%Y-%m-%d') <![CDATA[ <= ]]> '${endTime}'
            </if>
            <if test="year != null and year != '' ">
                 AND FROM_UNIXTIME(t.`createTime`/1000,'%Y') = '${year}'
            </if>
        <if test="dateType == 1">
            GROUP BY FROM_UNIXTIME(t.`createTime`/1000,'%Y-%m-%d')
        </if>
        <if test="dateType == 2">
             GROUP BY FROM_UNIXTIME(t.`createTime`/1000,'%Y-%m')
        </if>
        <if test="dateType == 3">
             GROUP BY FROM_UNIXTIME(t.`createTime`/1000,'%Y')
        </if>
        ORDER BY t.`createTime`
    </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/taobao/TaoBaoOrderMapper.xml
@@ -433,4 +433,52 @@
        where to_order_id = #{orderId} and
        to_payment = #{payment}
    </select>
        <sql id="Column_DateType">
        <if test="dateType == 1">
            DATE_FORMAT(t.`to_create_time`,'%Y-%m-%d') AS 'showDate'
        </if>
        <if test="dateType == 2">
            DATE_FORMAT(t.`to_create_time`,'%m') AS 'showDate'
        </if>
        <if test="dateType == 3">
            DATE_FORMAT(t.`to_create_time`,'%Y') AS 'showDate'
        </if>
    </sql>
    <sql id="Count_Select_DateType">
        <if test="startTime != null and startTime != '' ">
            AND DATE_FORMAT(t.`to_create_time`,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
        </if>
        <if test="endTime != null and endTime != '' ">
            AND DATE_FORMAT(t.`to_create_time`,'%Y-%m-%d') <![CDATA[ <= ]]>'${endTime}'
        </if>
        <if test="year != null and year != '' ">
            AND DATE_FORMAT(t.`to_create_time`,'%Y') = '${year}'
        </if>
    </sql>
    <sql id="Count_Group_DateType">
        <if test="dateType == 1">
            GROUP BY DATE_FORMAT(t.`to_create_time`,'%Y-%m-%d')
        </if>
        <if test="dateType == 2">
            GROUP BY DATE_FORMAT(t.`to_create_time`,'%Y-%m')
        </if>
        <if test="dateType == 3">
            GROUP BY DATE_FORMAT(t.`to_create_time`,'%Y')
        </if>
    </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
        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>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/taobao/TaoBaoWeiQuanOrderMapper.xml
@@ -122,4 +122,56 @@
        </set>
        where tmo_id = #{id,jdbcType=BIGINT}
    </update>
    <sql id="Column_DateType">
        <if test="dateType == 1">
            DATE_FORMAT(t.`tmo_createtime`,'%Y-%m-%d') AS 'showDate'
        </if>
        <if test="dateType == 2">
            DATE_FORMAT(t.`tmo_createtime`,'%m') AS 'showDate'
        </if>
        <if test="dateType == 3">
            DATE_FORMAT(t.`tmo_createtime`,'%Y') AS 'showDate'
        </if>
    </sql>
    <sql id="Count_Select_DateType">
        <if test="startTime != null and startTime != '' ">
            AND DATE_FORMAT(t.`tmo_createtime`,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
        </if>
        <if test="endTime != null and endTime != '' ">
            AND DATE_FORMAT(t.`tmo_createtime`,'%Y-%m-%d') <![CDATA[ <= ]]>'${endTime}'
        </if>
        <if test="year != null and year != '' ">
            AND DATE_FORMAT(t.`tmo_createtime`,'%Y') = '${year}'
        </if>
    </sql>
    <sql id="Count_Group_DateType">
        <if test="dateType == 1">
            GROUP BY DATE_FORMAT(t.`tmo_createtime`,'%Y-%m-%d')
        </if>
        <if test="dateType == 2">
            GROUP BY DATE_FORMAT(t.`tmo_createtime`,'%Y-%m')
        </if>
        <if test="dateType == 3">
            GROUP BY DATE_FORMAT(t.`tmo_createtime`,'%Y')
        </if>
    </sql>
    <select id="countWeiQaunOrderNumber" resultType="java.util.HashMap">
        SELECT  IFNULL(COUNT(t.`tmo_id`),0) AS showValue,<include refid="Column_DateType"/>
        FROM yeshi_ec_taobao_weiqaun_order t
        WHERE t.`tmo_createtime`IS NOT NULL  <include refid="Count_Select_DateType"/>
        <include refid="Count_Group_DateType"/>
        ORDER BY t.`tmo_createtime`
    </select>
    <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"/>
        <include refid="Count_Group_DateType"/>
        ORDER BY t.`tmo_createtime`
    </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/mapping/user/UserActiveLogMapper.xml
@@ -95,15 +95,15 @@
    </update>
    
    <select id="countSameDayByChannel" resultType="java.util.HashMap">
        SELECT COALESCE(COUNT(*),0) AS 'sameDayNum',
        SELECT COALESCE(COUNT(*),0) AS 'showValue',
            <if test="type == 1">
                 FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') AS 'createDate'
                 FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') AS 'showDate'
            </if>
            <if test="type == 2">
                 FROM_UNIXTIME(u.`createtime`/1000,'%m') AS 'createDate'
                 FROM_UNIXTIME(u.`createtime`/1000,'%m') AS 'showDate'
            </if>
            <if test="type == 3">
                 FROM_UNIXTIME(u.`createtime`/1000,'%Y') AS 'createDate'
                 FROM_UNIXTIME(u.`createtime`/1000,'%Y') AS 'showDate'
            </if>
        FROM  (SELECT a.`lua_uid` AS uid FROM `yeshi_ec_log_user_active`  a 
                WHERE a.`lua_channel`='${channel}' GROUP BY a.`lua_uid`) a 
@@ -132,22 +132,28 @@
    </select>
    
    <select id="countSameDayAndBuyGoodsByChannel" resultType="java.util.HashMap">
        SELECT COALESCE(COUNT(DISTINCT u.`id`),0) AS 'sameDayNum',
        SELECT COALESCE(COUNT(DISTINCT u.`id`),0) AS 'showValue',
            <if test="type == 1">
                 FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') AS 'createDate'
                 FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') AS 'showDate'
            </if>
            <if test="type == 2">
                 FROM_UNIXTIME(u.`createtime`/1000,'%m') AS 'createDate'
                 FROM_UNIXTIME(u.`createtime`/1000,'%m') AS 'showDate'
            </if>
            <if test="type == 3">
                 FROM_UNIXTIME(u.`createtime`/1000,'%Y') AS 'createDate'
                 FROM_UNIXTIME(u.`createtime`/1000,'%Y') AS 'showDate'
            </if>
        FROM  (SELECT a.`lua_uid` AS uid FROM `yeshi_ec_log_user_active`  a
        FROM
        <if test="channel != null and channel != 'all' ">
            (SELECT a.`lua_uid` AS uid FROM `yeshi_ec_log_user_active`  a
                WHERE a.`lua_channel`='${channel}' GROUP BY a.`lua_uid`) a 
        LEFT JOIN yeshi_ec_user u ON u.`id`=a.uid
        LEFT JOIN `yeshi_ec_hongbao` h ON h.`uid`= u.`id`
        WHERE (h.`type`=1 OR h.`type`=20)
            AND FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') = FROM_UNIXTIME(h.createtime/1000,'%Y-%m-%d')
        </if>
        LEFT JOIN yeshi_ec_user u     <if test="channel != null and channel != 'all' ">ON u.`id`=a.uid</if>
        LEFT JOIN `yeshi_ec_hongbao_v2` h ON h.`hb_uid`= u.`id`
        WHERE (h.`hb_type`=1 OR h.`hb_type`=20)
            <!-- 当日下单 -->
            AND FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') = FROM_UNIXTIME(h.hb_create_time/1000,'%Y-%m-%d')
            <if test="startTime != null and startTime != '' ">
             AND FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
            </if>
@@ -166,46 +172,39 @@
        <if test="type == 3">
             GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y') 
        </if>        
        ORDER BY u.`createtime`
    </select>
    
    <select id="countSameDayAndBuyGoodsByChannelAndBuyNum" resultType="java.util.HashMap">
        SELECT COALESCE(COUNT(DISTINCT u.`id`),0) AS 'sameDayNum',
            <if test="type == 1">
                 FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') AS 'createDate'
    <select id="countOneWeekUserInfo" resultType="java.util.HashMap">
        SELECT COALESCE(SUM(w.total),0) AS totalUser,COALESCE(SUM(w.orderUser),0)AS orderUser FROM
                (SELECT COUNT(u.`id`)AS total,0 AS orderUser
                FROM
                <if test="channel != null and channel != 'all' ">
                 (SELECT a.`lua_uid` AS uid FROM `yeshi_ec_log_user_active`  a WHERE a.`lua_channel`='${channel}' GROUP BY a.`lua_uid`) a
             LEFT JOIN
            </if>
            <if test="type == 2">
                 FROM_UNIXTIME(u.`createtime`/1000,'%m') AS 'createDate'
             yeshi_ec_user u  <if test="channel != null and channel != 'all' "> ON u.`id`=a.uid </if>
             WHERE FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') = '2018-11-01'
            UNION
            SELECT 0 AS total, COUNT(u.`id`) AS orderUser
            FROM
             <if test="channel != null and channel != 'all' ">
                (SELECT a.`lua_uid` AS uid FROM `yeshi_ec_log_user_active`  a WHERE a.`lua_channel`='${channel}' GROUP BY a.`lua_uid`) a
            LEFT JOIN
            </if>
            <if test="type == 3">
                 FROM_UNIXTIME(u.`createtime`/1000,'%Y') AS 'createDate'
            </if>
        FROM  (SELECT a.`lua_uid` AS uid FROM `yeshi_ec_log_user_active`  a
                WHERE a.`lua_channel`='${channel}' GROUP BY a.`lua_uid`) a
        LEFT JOIN yeshi_ec_user u ON u.`id`=a.uid
        LEFT JOIN (SELECT COUNT(DISTINCT h.`order_id`) AS count_num,h.uid,h.`createtime` FROM yeshi_ec_hongbao h
                    WHERE h.`type`=1 OR h.`type`=20
                    GROUP BY h.`createtime`,h.uid   HAVING count_num>= ${orderNum})hb     ON hb.`uid`= u.`id`
        WHERE FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') = FROM_UNIXTIME(hb.createtime/1000,'%Y-%m-%d')
            <if test="startTime != null and startTime != '' ">
             AND FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d')<![CDATA[ >= ]]>'${startTime}'
            </if>
            <if test="endTime != null and endTime != '' ">
                 AND FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') <![CDATA[ <= ]]> '${endTime}'
            </if>
            <if test="years != null and years != '' ">
                 AND FROM_UNIXTIME(u.`createtime`/1000,'%Y') = '${years}'
            </if>
        <if test="type == 1">
            GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d')
        </if>
        <if test="type == 2">
             GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m')
        </if>
        <if test="type == 3">
             GROUP BY FROM_UNIXTIME(u.`createtime`/1000,'%Y')
        </if>
        ORDER BY u.`createtime`
            yeshi_ec_user u  <if test="channel != null and channel != 'all' "> ON u.`id`=a.uid   </if>
            WHERE FROM_UNIXTIME(u.`createtime`/1000,'%Y-%m-%d') = '2018-01-11'
                    AND u.id = ANY(SELECT hh.hb_uid  FROM (SELECT COUNT(t.`hb_id`) AS num,t.hb_uid
                              FROM yeshi_ec_hongbao_v2 t
                            WHERE  <![CDATA[DATE_FORMAT(t.`hb_create_time`,'%Y-%m-%d') >= '${startTime}']]>
                                AND <![CDATA[DATE_FORMAT(t.`hb_create_time`,'%Y-%m-%d') < '${endTime}']]>
                            GROUP BY t.hb_uid HAVING num >= ${orderNumber}
                        )hh
                    )
            )w
    </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/service/impl/count/CommonOrderCountServiceImpl.java
New file
@@ -0,0 +1,258 @@
package com.yeshi.fanli.service.impl.count;
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 javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.yeshi.utils.DateUtil;
import com.yeshi.fanli.dao.mybatis.order.CommonOrderCountMapper;
import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoOrderMapper;
import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanOrderMapper;
import com.yeshi.fanli.service.inter.order.CommonOrderCountService;
@Service
public class CommonOrderCountServiceImpl implements CommonOrderCountService {
    @Resource
    private TaoBaoWeiQuanOrderMapper taoBaoWeiQuanOrderMapper;
    @Resource
    private TaoBaoOrderMapper taoBaoOrderMapper;
    @Resource
    private CommonOrderCountMapper commonOrderCountMapper;
    @Override
    public Long countByState(Integer state) {
        return     commonOrderCountMapper.countByState(state);
    }
    public List<Map<String, Object>> dayFactory(String startTime, String endTime, List<Map<String, Object>> list) throws Exception {
        List<Map<String, Object>> listObject = new ArrayList<Map<String, Object>>();
        if (startTime.equals(endTime)) {
            Map<String, Object> map = list.get(0);
            Object total = map.get("showValue");
            if (total == null) {
                map.put("showValue", 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("showDate");
                String month = createDate.toString();
                if (plusDay.equalsIgnoreCase(month)) {
                    total = map.get("showValue");
                    break;
                }
            }
            if (total == null) {
                total = 0;
            }
            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));
            listObject.add(mapObject);
            if (plusDay.equals(endTime)) {
                break; // 时间结束
            }
        }
        return listObject;
    }
    public List<Map<String, Object>> monthFactory(List<Map<String, Object>> list) {
        List<Map<String, Object>> listObject = new ArrayList<Map<String, 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("showDate");
                String month = createDate.toString();
                if ((i + "").equalsIgnoreCase(month) || i == Integer.parseInt(month)) {
                    total = map.get("showValue");
                    break;
                }
            }
            if (total == null) {
                total = 0;
            }
            mapObject.put("showValue", total);
            mapObject.put("showDate", i + "月");
            listObject.add(mapObject);
        }
        return listObject;
    }
    public List<Map<String, Object>> yearFactory(List<Map<String, Object>> list) {
        List<Map<String, Object>> listObject = new ArrayList<Map<String, Object>>();
        for (int i = 0; i < list.size(); i++) {
            Map<String, Object> map = list.get(i);
            Object total = map.get("showValue");
            if (total == null) {
                total = 0;
            }
            map.put("showValue", total);
            listObject.add(map);
        }
        return listObject;
    }
    @Override
    public List<Map<String, Object>> getTrackAccuracyRate(Integer dateType, String year, String startTime,
            String endTime) throws Exception{
        List<Map<String, Object>> result_list = null;
        List<Map<String, Object>> listTotal = commonOrderCountMapper.countOrderNumber(dateType, year,
                startTime, endTime);
        if (listTotal == null || listTotal.size() == 0) {
            return result_list;
        }
        List<Map<String, Object>> type_list = taoBaoOrderMapper.countOrderNumber(dateType, year,
                startTime, endTime);
        if (type_list == null || type_list.size() == 0) {
            return null;
        }
        switch (dateType){
            case 1: // 按天处理
                result_list = dayFactory(startTime, endTime, type_list);
                break;
            case 2: // 按月处理
                result_list = monthFactory(type_list);
                break;
            case 3:
                result_list =  yearFactory(type_list);
                break;
            default:
                break;
        }
        for (int i = 0; i < result_list.size(); i++) {
            float 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);
                Object innerDate = innerMap.get("showDate");
                if (innerDate != null && innerDate.toString().equals(showDate.toString())) {
                    Object innerValue = innerMap.get("showValue");
                    long innerData = Long.parseLong(innerValue.toString());
                    Object showValue = resultMap.get("showValue");
                    long showData = Long.parseLong(showValue.toString());
                    if (showData > 0) {
                        proportion =  innerData/showData;
                    }
                    break; // 结束内部循环
                }
            }
            resultMap.put("showValue", proportion);
        }
        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;
        }
    }
    @Override
    public List<Map<String, Object>> countWeiQaunOrderNumber(Integer dateType, String year, String startTime,
            String endTime) throws Exception{
        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;
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/count/HongBaoV2CountServiceImpl.java
@@ -70,9 +70,9 @@
        if (startTime.equals(endTime)) {
            Map<String, Object> map = list.get(0);
            Object total = map.get("total");
            Object total = map.get("showValue");
            if (total == null) {
                map.put("total", 0);
                map.put("showValue", 0);
            }
            listObject.add(map);
            return listObject;
@@ -94,7 +94,7 @@
                Object createDate = map.get("showDate");
                String month = createDate.toString();
                if (plusDay.equalsIgnoreCase(month)) {
                    total = map.get("total");
                    total = map.get("showValue");
                    break;
                }
            }
@@ -102,7 +102,7 @@
            if (total == null) {
                total = 0;
            }
            mapObject.put("total", total);
            mapObject.put("showValue", total);
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/MM/dd");
@@ -133,7 +133,7 @@
                Object createDate = map.get("showDate");
                String month = createDate.toString();
                if ((i + "").equalsIgnoreCase(month) || i == Integer.parseInt(month)) {
                    total = map.get("total");
                    total = map.get("showValue");
                    break;
                }
            }
@@ -141,7 +141,7 @@
            if (total == null) {
                total = 0;
            }
            mapObject.put("total", total);
            mapObject.put("showValue", total);
            mapObject.put("showDate", i + "月");
@@ -156,12 +156,12 @@
        for (int i = 0; i < list.size(); i++) {
            Map<String, Object> map = list.get(i);
            Object total = map.get("total");
            Object total = map.get("showValue");
            if (total == null) {
                total = 0;
            }
            map.put("total", total);
            map.put("showValue", total);
            listObject.add(map);
        }
@@ -215,4 +215,69 @@
    }
    
    @Override
    public List<Map<String, Object>> getProportionByType(Integer dateType, Integer type, String year,
            String startTime, String endTime) throws Exception {
        List<Map<String, Object>> result_list = null;
        List<Map<String, Object>> listTotal = hongBaoV2CountMapper.countHongBaoTotalNum(dateType, year, startTime, endTime);
        if (listTotal == null || listTotal.size() == 0) {
            return result_list;
        }
        List<Map<String, Object>> type_list = hongBaoV2CountMapper.countHongBaoType(dateType, type,
                year, startTime, endTime);
        if (type_list == null || type_list.size() == 0) {
            return null;
        }
        switch (dateType){
            case 1: // 按天处理
                result_list = dayFactory(startTime, endTime, type_list);
                break;
            case 2: // 按月处理
                result_list = monthFactory(type_list);
                break;
            case 3:
                result_list =  yearFactory(type_list);
                break;
            default:
                break;
        }
        for (int i = 0; i < result_list.size(); i++) {
            float 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);
                Object innerDate = innerMap.get("showDate");
                if (innerDate != null && innerDate.toString().equals(showDate.toString())) {
                    Object innerValue = innerMap.get("showValue");
                    long innerData = Long.parseLong(innerValue.toString());
                    Object showValue = resultMap.get("showValue");
                    long showData = Long.parseLong(showValue.toString());
                    if (showData > 0) {
                        proportion =  innerData/showData;
                    }
                    break; // 结束内部循环
                }
            }
            resultMap.put("showValue", proportion);
        }
        return result_list;
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoServiceImpl.java
@@ -1321,7 +1321,7 @@
            
            for (int j = 0; j < list.size(); j++) {
                Map<String, Object> map = list.get(j);
                Object createDate = map.get("createDate");
                Object createDate = map.get("showDate");
                String month = createDate.toString();
                if (plusDay.equalsIgnoreCase(month)) {
                    payMoney = map.get("payMoney");
@@ -1350,7 +1350,7 @@
            SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/MM/dd");
            Date parseDate = sdf.parse(plusDay.toString());
            
            mapObject.put("createDate", sdf2.format(parseDate));
            mapObject.put("showDate", sdf2.format(parseDate));
            
            listObject.add(mapObject);
            
@@ -1375,7 +1375,7 @@
            
            for (int j = 0; j < list.size(); j++) {
                Map<String, Object> map = list.get(j);
                Object createDate = map.get("createDate");
                Object createDate = map.get("showDate");
                String month = createDate.toString();
                if ((i+"").equalsIgnoreCase(month) || i == Integer.parseInt(month)) {
                    payMoney = map.get("payMoney");
@@ -1400,7 +1400,7 @@
            }
            mapObject.put("commision", commision);
            
            mapObject.put("createDate", i + "月");
            mapObject.put("showDate", i + "月");
            
            listObject.add(mapObject);
        }
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java
@@ -17,7 +17,6 @@
import com.yeshi.fanli.dao.mybatis.order.CommonOrderGoodsMapper;
import com.yeshi.fanli.dao.mybatis.order.CommonOrderMapper;
import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanOrderMapper;
import com.yeshi.fanli.entity.bus.user.HongBao;
import com.yeshi.fanli.entity.bus.user.HongBaoV2;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.order.CommonOrder;
@@ -184,9 +183,15 @@
                        commonGoodsVO.setGoodsTitle(titleMap);
                    }
                    // 购买数量
                    commonGoodsVO.setActualCount(commonOrder.getTotalCount() + "件");
                    String settlement = commonOrder.getTotalSettlement().setScale(2, BigDecimal.ROUND_DOWN).toString();
                    commonGoodsVO.setActualPay("实付款:¥" + settlement);
                    BigDecimal totalSettlement = commonOrder.getTotalSettlement();
                    if (totalSettlement == null || totalSettlement.compareTo(new BigDecimal(0)) <= 0) {
                        totalSettlement = commonOrder.getTotalPayment();
                    }
                    // 实付款
                    commonGoodsVO.setActualPay("实付款:¥" + totalSettlement);
                    listOrderGoods.add(commonGoodsVO);
fanli/src/main/java/com/yeshi/fanli/service/impl/order/LostOrderServiceImpl.java
@@ -1,6 +1,10 @@
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;
@@ -10,6 +14,7 @@
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;
@@ -277,4 +282,156 @@
    public long countQuery(String key, Integer state, Integer handleType) {
        return lostOrderMapper.countQuery(key, state, handleType);
    }
    @Override
    public List<Map<String, Object>> countLostNum( Integer dateType, Integer resultCode,
            String year, String startTime, String endTime) throws Exception {
        List<Map<String, Object>> list = lostOrderMapper.countLostNum(dateType, resultCode, year, startTime, endTime);
        if (list == null || list.size() == 0) {
            return null;
        }
        switch (dateType){
            case 1: // 按天处理
                return dayFactory(startTime, endTime, list);
            case 2: // 按月处理
                return monthFactory(list);
            case 3:
                return yearFactory(list);
            default:
                return null;
        }
    }
    @Override
    public List<Map<String, Object>> countAppealMoney( Integer dateType, String year, String startTime,
            String endTime) throws Exception {
        List<Map<String, Object>> list = lostOrderMapper.countAppealMoney(dateType, year, startTime, endTime);
        if (list == null || list.size() == 0) {
            return null;
        }
        switch (dateType){
            case 1: // 按天处理
                return dayFactory(startTime, endTime, list);
            case 2: // 按月处理
                return monthFactory(list);
            case 3:
                return yearFactory(list);
            default:
                return null;
        }
    }
    public List<Map<String, Object>> dayFactory(String startTime, String endTime, List<Map<String, Object>> list) throws Exception {
        List<Map<String, Object>> listObject = new ArrayList<Map<String, Object>>();
        if (startTime.equals(endTime)) {
            Map<String, Object> map = list.get(0);
            Object total = map.get("showValue");
            if (total == null) {
                map.put("showValue", 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("showDate");
                String month = createDate.toString();
                if (plusDay.equalsIgnoreCase(month)) {
                    total = map.get("showValue");
                    break;
                }
            }
            if (total == null) {
                total = 0;
            }
            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));
            listObject.add(mapObject);
            if (plusDay.equals(endTime)) {
                break; // 时间结束
            }
        }
        return listObject;
    }
    public List<Map<String, Object>> monthFactory(List<Map<String, Object>> list) {
        List<Map<String, Object>> listObject = new ArrayList<Map<String, 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("showDate");
                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("showDate", i + "月");
            listObject.add(mapObject);
        }
        return listObject;
    }
    public List<Map<String, Object>> yearFactory(List<Map<String, Object>> list) {
        List<Map<String, Object>> listObject = new ArrayList<Map<String, 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;
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/user/ExtractAuditRecordServiceImpl.java
@@ -162,9 +162,9 @@
        if (startTime.equals(endTime)) {
            Map<String, Object> map = list.get(0);
            Object total = map.get("total");
            Object total = map.get("showValue");
            if (total == null) {
                map.put("total", 0);
                map.put("showValue", 0);
            }
            listObject.add(map);
            return listObject;
@@ -186,7 +186,7 @@
                Object createDate = map.get("showDate");
                String month = createDate.toString();
                if (plusDay.equalsIgnoreCase(month)) {
                    total = map.get("total");
                    total = map.get("showValue");
                    break;
                }
            }
@@ -194,7 +194,7 @@
            if (total == null) {
                total = 0;
            }
            mapObject.put("total", total);
            mapObject.put("showValue", total);
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/MM/dd");
@@ -225,7 +225,7 @@
                Object createDate = map.get("showDate");
                String month = createDate.toString();
                if ((i + "").equalsIgnoreCase(month) || i == Integer.parseInt(month)) {
                    total = map.get("total");
                    total = map.get("showValue");
                    break;
                }
            }
@@ -233,7 +233,7 @@
            if (total == null) {
                total = 0;
            }
            mapObject.put("total", total);
            mapObject.put("showValue", total);
            mapObject.put("showDate", i + "月");
@@ -248,12 +248,12 @@
        for (int i = 0; i < list.size(); i++) {
            Map<String, Object> map = list.get(i);
            Object total = map.get("total");
            Object total = map.get("showValue");
            if (total == null) {
                total = 0;
            }
            map.put("total", total);
            map.put("showValue", total);
            listObject.add(map);
        }
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserActiveLogServiceImpl.java
@@ -1,5 +1,6 @@
package com.yeshi.fanli.service.impl.user;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -16,6 +17,7 @@
import com.yeshi.fanli.dao.mybatis.user.UserActiveLogMapper;
import com.yeshi.fanli.entity.bus.user.UserActiveLog;
import com.yeshi.fanli.service.inter.user.UserActiveLogService;
import com.yeshi.fanli.util.MoneyBigDecimalUtil;
@Service
public class UserActiveLogServiceImpl implements UserActiveLogService {
@@ -90,25 +92,65 @@
    }
    
    @Override
    public List<Object> countSameDayAndBuyGoodsByChannelAndBuyNum(String channel, Integer type, String years,
            String startTime, String endTime, Integer orderNum) throws Exception {
        List<Map<String, Object>> list = userActiveLogMapper.countSameDayAndBuyGoodsByChannelAndBuyNum(channel, type, years,
                startTime, endTime, orderNum);
    public  List<Map<String, Object>> countOneWeekUserInfo(String channel, String startTime, String endTime,
            Integer orderNumber) throws Exception {
        
        if (list == null || list.size() == 0) {
            return null;
        // 时间列表
        List<String> dateList = new ArrayList<String>();
        // 结果列表
        List<Map<String, Object>> resultList = new ArrayList<Map<String,Object>>();
        String middleDay = "";
        for (int i = 0; i < 100 ; i++) {
            if (i == 0) {
                middleDay = startTime;
            } else {
                middleDay = DateUtil.plusDay(i, startTime);
        } 
        
        switch (type){
            case 1: // 按天处理
                return dayFactory(startTime, endTime, list);
            case 2: // 按月处理
                return monthFactory(list);
            case 3:
                return yearFactory(list);
            default:
                return null;
            dateList.add(middleDay);
            if (middleDay.equals(endTime)) {
                break; // 时间结束
        }
        }
        for (String nowDate: dateList) {
            // 加入7天
            String plusDay = DateUtil.plusDay(7, nowDate);
            // 执行查询 并返回结果
            Map<String, BigDecimal> map= userActiveLogMapper.countOneWeekUserInfo(channel, nowDate, plusDay, orderNumber);
            // 比例
            BigDecimal proportion = null;
            if (map != null) {
                // 新增用户
                BigDecimal totalUser = map.get("totalUser");
                // 存在订单的新增用户
                BigDecimal orderUser = map.get("orderUser");
                try {
                    proportion = MoneyBigDecimalUtil.sub(orderUser, totalUser);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            if (proportion == null) {
                proportion = new BigDecimal(0);
            }
            Map<String, Object> result = new HashMap<String, Object>();
            result.put("showValue", MoneyBigDecimalUtil.mul(proportion, new BigDecimal(100)));
            result.put("showDate", nowDate);
            resultList.add(result);
        }
        return resultList;
    }
    
    
@@ -127,8 +169,6 @@
        List<Object> countListBuy=  null;
        if (orderNum <= 1){
            countListBuy = countSameDayAndBuyGoodsByChannel(channel, type, years, startTime, endTime);
        } else {
            countListBuy = countSameDayAndBuyGoodsByChannelAndBuyNum(channel, type, years, startTime, endTime, orderNum);
        }
        
        if (countListBuy == null){
@@ -144,16 +184,16 @@
            Map<String, Object> mapObject = new HashMap<String, Object>();
            
            Map<String, Object> map = (Map<String, Object>) object;
            Object createDate = map.get("createDate");
            Object sameDayNum = map.get("sameDayNum");
            Object createDate = map.get("showDate");
            Object sameDayNum = map.get("showValue");
            
            long totle = Long.parseLong(sameDayNum.toString());
            if (totle > 0 && countListBuy != null && countListBuy.size() > 0) {
                for (int j = 0; j < countListBuy.size(); j++) {
                    Map<String, Object> mapBuy = (Map<String, Object>) countListBuy.get(j);
                    Object createDate2 = mapBuy.get("createDate");
                    Object createDate2 = mapBuy.get("showDate");
                    if (createDate.toString().equals(createDate2.toString())) {
                        Object buyNum = mapBuy.get("sameDayNum");
                        Object buyNum = mapBuy.get("showValue");
                        long totleBuy = Long.parseLong(buyNum.toString());
                        rate = (float)totleBuy/totle;
                        break;
@@ -162,8 +202,8 @@
            }
            
            DecimalFormat df = new DecimalFormat("0.00");//格式化小数
            mapObject.put("sameDayNum", df.format(rate*100));
            mapObject.put("createDate", createDate);
            mapObject.put("showValue", df.format(rate*100));
            mapObject.put("showDate", createDate);
            listObject.add(mapObject);
        }
        
@@ -171,7 +211,14 @@
    }
    
    /**
     * 天数格式
     * @param startTime
     * @param endTime
     * @param list
     * @return
     * @throws Exception
     */
    public List<Object> dayFactory(String startTime, String endTime, List<Map<String, Object>> list) throws Exception {
        
        List<Object> listObject = new ArrayList<Object>();
@@ -179,10 +226,10 @@
        if (startTime.equals(endTime)) {
            
            Map<String, Object> map = list.get(0);
            Object sameDayNum = map.get("sameDayNum");
            Object sameDayNum = map.get("showValue");
            
            if (sameDayNum == null) {
                map.put("sameDayNum", 0);
                map.put("showValue", 0);
            }
            listObject.add(map);
            
@@ -203,10 +250,10 @@
            
            for (int j = 0; j < list.size(); j++) {
                Map<String, Object> map = list.get(j);
                Object createDate = map.get("createDate");
                Object createDate = map.get("showDate");
                String month = createDate.toString();
                if (plusDay.equalsIgnoreCase(month)) {
                    sameDayNum = map.get("sameDayNum");
                    sameDayNum = map.get("showValue");
                    break;
                }
            }
@@ -214,13 +261,13 @@
            if (sameDayNum == null) {
                sameDayNum = 0;
            }
            mapObject.put("sameDayNum", sameDayNum);
            mapObject.put("showValue", sameDayNum);
            
            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));
            mapObject.put("showDate", sdf2.format(parseDate));
            
            listObject.add(mapObject);
            
@@ -232,7 +279,11 @@
        return listObject;
    }
    
    /**
     * 月份格式
     * @param list
     * @return
     */
    public List<Object> monthFactory(List<Map<String, Object>> list) {
        
        List<Object> listObject = new ArrayList<Object>();
@@ -242,10 +293,10 @@
            Object sameDayNum = null;
            for (int j = 0; j < list.size(); j++) {
                Map<String, Object> map = list.get(j);
                Object createDate = map.get("createDate");
                Object createDate = map.get("showDate");
                String month = createDate.toString();
                if ((i+"").equalsIgnoreCase(month) || i == Integer.parseInt(month)) {
                    sameDayNum = map.get("sameDayNum");
                    sameDayNum = map.get("showValue");
                    break;
                }
            }
@@ -253,29 +304,34 @@
            if (sameDayNum == null) {
                sameDayNum = 0;
            }
            mapObject.put("sameDayNum", sameDayNum);
            mapObject.put("showValue", sameDayNum);
            
            mapObject.put("createDate", i + "月");
            mapObject.put("showDate", i + "月");
            
            listObject.add(mapObject);
        }
        return listObject;
    }
    
    /**
     * 年份格式
     * @param list
     * @return
     */
    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 sameDayNum = map.get("sameDayNum");
            Object createDate = map.get("createDate");
            Object sameDayNum = map.get("showValue");
            Object createDate = map.get("showDate");
            
            if (sameDayNum == null) {
                sameDayNum = 0;
            }
            map.put("sameDayNum", sameDayNum);
            map.put("createDate", createDate + "年");
            map.put("showValue", sameDayNum);
            map.put("showDate", createDate + "年");
            
            listObject.add(map);
        }
fanli/src/main/java/com/yeshi/fanli/service/inter/count/HongBaoV2CountService.java
@@ -15,7 +15,7 @@
     * @param endTime      结束时间
     * @return
     */
    List<Map<String, Object>> countHongBaoMoney(String channel, Integer dateType, Integer state, String year,
    public List<Map<String, Object>> countHongBaoMoney(String channel, Integer dateType, Integer state, String year,
            String startTime, String endTime) throws Exception;
    
    /**
@@ -28,7 +28,20 @@
     * @param endTime      结束时间
     * @return
     */
    List<Map<String, Object>> countHongBaoNum(String channel, Integer dateType, Integer state, String year,
    public List<Map<String, Object>> countHongBaoNum(String channel, Integer dateType, Integer state, String year,
            String startTime, String endTime) throws Exception;
    
    /**
     * 分类型订单数与比例
     * @param dateType
     * @param type
     * @param year
     * @param startTime
     * @param endTime
     * @return
     * @throws Exception
     */
    public List<Map<String, Object>> getProportionByType(Integer dateType, Integer type, String year, String startTime,
            String endTime) throws Exception;
}
fanli/src/main/java/com/yeshi/fanli/service/inter/order/CommonOrderCountService.java
New file
@@ -0,0 +1,49 @@
package com.yeshi.fanli.service.inter.order;
import java.util.List;
import java.util.Map;
public interface CommonOrderCountService {
    /**
     * 当前各个状态订单数
     * @param state 状态
     * @return
     */
    public Long countByState(Integer state);
    /**
     *  统计所有订单
     * @param channel
     * @return
     */
    public List<Map<String, Object>> getTrackAccuracyRate(Integer dateType, String year, String startTime,
            String endTime) throws Exception;
    /**
     * 统计总金额
     * @param dateType
     * @param year
     * @param startTime
     * @param endTime
     * @return
     * @throws Exception
     */
    public List<Map<String, Object>> countWeiQaunOrderMoney(Integer dateType, String year, String startTime,
            String endTime)    throws Exception;
    /**
     * 统计总个数
     * @param dateType
     * @param year
     * @param startTime
     * @param endTime
     * @return
     * @throws Exception
     */
    public List<Map<String, Object>> countWeiQaunOrderNumber(Integer dateType, String year, String startTime, String endTime)
            throws Exception;
}
fanli/src/main/java/com/yeshi/fanli/service/inter/order/LostOrderService.java
@@ -93,4 +93,21 @@
    public long countQuery(String key, Integer state, Integer handleType);
    /**
     * 本月申诉订单数 统计
     * @param dateType
     * @param resultCode  (未处理: 成功  失败)
     * @param year
     * @param startTime
     * @param endTime
     * @return
     * @throws Exception
     */
    public List<Map<String, Object>> countLostNum(Integer dateType, Integer resultCode, String year, String startTime,
            String endTime) throws Exception;
    public List<Map<String, Object>> countAppealMoney(Integer dateType, String year, String startTime, String endTime)
            throws Exception;
}
fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserActiveLogService.java
@@ -1,6 +1,7 @@
package com.yeshi.fanli.service.inter.user;
import java.util.List;
import java.util.Map;
import com.yeshi.fanli.entity.bus.user.UserActiveLog;
@@ -54,18 +55,8 @@
    public List<Object> getBuyProportion(String channel, Integer type, String years, String startTime, String endTime,Integer orderNum)
            throws Exception;
    /**
     * 根据渠道   统计当日新增用户有购买行为的订单数量大于3
     * @param channel
     * @param type
     * @param years
     * @param startTime
     * @param endTime
     * @param orderNum
     * @return
     * @throws Exception
     */
    public List<Object> countSameDayAndBuyGoodsByChannelAndBuyNum(String channel, Integer type, String years,
            String startTime, String endTime, Integer orderNum) throws Exception;
    public List<Map<String, Object>> countOneWeekUserInfo(String channel, String startTime, String endTime, Integer orderNumber)
            throws Exception;
}
fanli/src/main/java/com/yeshi/fanli/vo/order/CommonOrderVO.java
@@ -29,6 +29,8 @@
    // 实际总数量
     private Integer totalCount;
     // 实际总付款
     private BigDecimal totalPayment;
    // 实际总结算
     private BigDecimal totalSettlement;
     // 红包类型:
     private Integer hongBaoType;
@@ -219,5 +221,13 @@
        this.orderOrigin = orderOrigin;
    }
    public BigDecimal getTotalPayment() {
        return totalPayment;
    }
    public void setTotalPayment(BigDecimal totalPayment) {
        this.totalPayment = totalPayment;
    }
    
}