yujian
2019-01-10 17b490541bd688abcbc489937e6b3b800103cb9a
后台统计 + 提现历史到账
9个文件已修改
1个文件已添加
760 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/admin/ExtractAdminController.java 229 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/OrderAdminController.java 86 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/utils/AdminUtils.java 176 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/HongBaoV2CountMapper.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/ExtractAuditRecordMapper.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/hongbao/HongBaoV2CountMapper.xml 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/count/HongBaoV2CountServiceImpl.java 47 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/ExtractAuditRecordServiceImpl.java 160 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/count/HongBaoV2CountService.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/user/ExtractAuditRecordService.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/ExtractAdminController.java
@@ -27,9 +27,12 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.yeshi.fanli.controller.admin.utils.AdminUtils;
import com.yeshi.fanli.entity.bus.user.Extract;
import com.yeshi.fanli.entity.bus.user.ExtractAuditRecord;
import com.yeshi.fanli.entity.bus.user.HongBao;
import com.yeshi.fanli.entity.bus.user.HongBaoV2;
import com.yeshi.fanli.entity.bus.user.Order;
import com.yeshi.fanli.entity.bus.user.OrderItem;
import com.yeshi.fanli.entity.bus.user.UserInfo;
@@ -45,6 +48,7 @@
import com.yeshi.fanli.service.AdminUserService;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.count.ExtractCountService;
import com.yeshi.fanli.service.inter.count.HongBaoV2CountService;
import com.yeshi.fanli.service.inter.count.UserInfoCountService;
import com.yeshi.fanli.service.inter.hongbao.HongBaoService;
import com.yeshi.fanli.service.inter.order.OrderItemServcie;
@@ -92,6 +96,9 @@
    @Resource
    private HongBaoService hongBaoService;
    @Resource
    private HongBaoV2CountService hongBaoV2CountService;
    @Resource
    private AdminUserService adminUserService;
@@ -802,7 +809,10 @@
        try {
            // 统计已领取金额 账户历史总收益
            double receiveMoneys = hongBaoService.countReceiveMoneysByUid(uid);
            BigDecimal receiveMoneys = hongBaoV2CountService.countMoneyByUidAndState(uid, HongBaoV2.STATE_YILINGQU);
            if (receiveMoneys == null) {
                receiveMoneys = new BigDecimal(0);
            }
            // 历史提现成功金额
            double successMoneys = extractCountService.countSuccessMoneysByUid(uid);
@@ -822,7 +832,6 @@
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            // TODO: handle exception
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
            e.printStackTrace();
        }
@@ -1428,8 +1437,8 @@
    /**
     * 统计审核次数 
     * @param callback
     * @param state 审核状态:所有-空值或者不传  通过-1  拒绝- 2
     * @param type 统计类型  1-24小时  2-所有
     * @param state 审核状态:所有-3  通过-1  拒绝- 2
     * @param type 统计类型  1-24小时  2-所有3
     * @param dateType 类型  1日  2月  3年
     * @param year 2018
     * @param startTime 2018-12-01 
@@ -1437,41 +1446,80 @@
     * @param out
     */
    @RequestMapping(value = "getAuditTotal")
    public void getAuditTotal(String callback,Integer state, Integer dateType, String year,
    public void getAuditTotal(String callback, String stateArray, Integer dateType, String year,
            String startTime, String endTime, PrintWriter out) {
        String validateMsg = validateParams(dateType, startTime, endTime);
        String validateMsg = AdminUtils.validateParams(dateType, startTime, endTime);
        if (validateMsg != null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg));
            return;
        }
        
        if (dateType != 1 && (!StringUtil.isNullOrEmpty(startTime) || !StringUtil.isNullOrEmpty(endTime))) {
        if (dateType == 1 && year != null) {
            year = null; // 设置为空
        } else if (dateType == 2) {
            if (startTime != null)
            startTime = null;
            if (endTime != null)
                endTime = null;
        } else if (dateType == 3) {
            if (year != null)
                year = null;
            if (startTime != null)
                startTime = null;
            if (endTime != null)
            endTime = null;
        }
        
        try {
            Object objectDate = null;
            List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year);
            List<Map<String, Object>> resultList = extractAuditRecordService.countAuditTotal(state, dateType,
                    year, startTime, endTime);
            Gson gson = new Gson();
            List<Integer> stateList = gson.fromJson(stateArray, new TypeToken<ArrayList<Integer>>() {}.getType());
            
            JSONArray line_list = new JSONArray();
            for (Integer state: stateList) {
            JSONObject innerList = new JSONObject();
            if (state == null) {
                if (state == null || state == 3) {
                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);
                List<Map<String, Object>> list = extractAuditRecordService.countAuditTotal(state, dateType,
                        year, startTime, endTime);
                if (dateType != 3) {
                    innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateList, list)));
                } else {
                    // 年视图
                    Map<String, Object> map = AdminUtils.yearsDataFactory(list);
                    if (objectDate == null) {
                        objectDate = map.get("date");
                    }
                    innerList.put("data", gson.toJson(map.get("value")));
                }
                line_list.add(innerList);
            }
            
            JSONObject data = new JSONObject();
            data.put("result_list", outList);
            if (objectDate != null) {
                data.put("xAxis_list", gson.toJson(objectDate));
            } else {
                data.put("xAxis_list", gson.toJson(dateList));
            }
            data.put("line_list", line_list);
            
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
            
@@ -1485,52 +1533,80 @@
    /**
     * 统计提现申请总额
     * @param callback
     * @param state 所有-空值或者不传   待审核-0 通过-1  拒绝- 2
     * @param type 统计类型  1-24小时  2-所有
     * @param dateType 类型  1日  2月  3年
     * @param dateType 类型  1日  2月  3
     * @param year 2018
     * @param startTime 2018-12-01 
     * @param endTime   2018-12-01 
     * @param out
     */
    @RequestMapping(value = "getExtractMoney")
    public void getExtractMoney(String callback,Integer state, Integer dateType, String year,
    @RequestMapping(value = "getExtractApplyMoney")
    public void getExtractApplyMoney(String callback, Integer dateType, String year,
            String startTime, String endTime, PrintWriter out) {
        String validateMsg = validateParams(dateType, startTime, endTime);
        String validateMsg = AdminUtils.validateParams(dateType, startTime, endTime);
        if (validateMsg != null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg));
            return;
        }
        
        if (dateType != 1 && (!StringUtil.isNullOrEmpty(startTime) || !StringUtil.isNullOrEmpty(endTime))) {
        if (dateType == 1 && year != null) {
            year = null; // 设置为空
        } else if (dateType == 2) {
            if (startTime != null)
            startTime = null;
            if (endTime != null)
                endTime = null;
        } else if (dateType == 3) {
            if (year != null)
                year = null;
            if (startTime != null)
                startTime = null;
            if (endTime != null)
            endTime = null;
        }
        
        try {
            List<Map<String, Object>> resultList = extractAuditRecordService.countExtractMoney(state, dateType,
                    year, startTime, endTime);
            Object objectDate = null;
            List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year);
            Gson gson = new Gson();
            JSONArray line_list = new JSONArray();
            
            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);
            List<Map<String, Object>> list = extractAuditRecordService.countExtractApplyMoney(null, dateType,
                    year, startTime, endTime);
            if (dateType != 3) {
                innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateList, list)));
            } else {
                // 年视图
                Map<String, Object> map = AdminUtils.yearsDataFactory(list);
                if (objectDate == null) {
                    objectDate = map.get("date");
                }
                innerList.put("data", gson.toJson(map.get("value")));
            }
            line_list.add(innerList);
            
            JSONObject data = new JSONObject();
            data.put("result_list", outList);
            if (objectDate != null) {
                data.put("xAxis_list", gson.toJson(objectDate));
            } else {
                data.put("xAxis_list", gson.toJson(dateList));
            }
            data.put("line_list", line_list);
            
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
            
@@ -1555,40 +1631,69 @@
    public void getExtractApplyNumber(String callback,Integer state, Integer dateType, String year, 
            String startTime, String endTime, PrintWriter out) {
        String validateMsg = validateParams(dateType, startTime, endTime);
        String validateMsg = AdminUtils.validateParams(dateType, startTime, endTime);
        if (validateMsg != null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg));
            return;
        }
        
        if (dateType != 1 && (!StringUtil.isNullOrEmpty(startTime) || !StringUtil.isNullOrEmpty(endTime))) {
        if (dateType == 1 && year != null) {
            year = null; // 设置为空
        } else if (dateType == 2) {
            if (startTime != null)
            startTime = null;
            if (endTime != null)
                endTime = null;
        } else if (dateType == 3) {
            if (year != null)
                year = null;
            if (startTime != null)
                startTime = null;
            if (endTime != null)
            endTime = null;
        }
        
        try {
            List<Map<String, Object>> resultList = extractAuditRecordService.countExtractApplyNumber(state, dateType,
                    year, startTime, endTime);
            Object objectDate = null;
            List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year);
            Gson gson = new Gson();
            JSONArray line_list = new JSONArray();
            
            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);
            List<Map<String, Object>> list = extractAuditRecordService.countExtractApplyNumber(null, dateType,
                    year, startTime, endTime);
            if (dateType != 3) {
                innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateList, list)));
            } else {
                // 年视图
                Map<String, Object> map = AdminUtils.yearsDataFactory(list);
                if (objectDate == null) {
                    objectDate = map.get("date");
                }
                innerList.put("data", gson.toJson(map.get("value")));
            }
            line_list.add(innerList);
            
            JSONObject data = new JSONObject();
            data.put("result_list", outList);
            if (objectDate != null) {
                data.put("xAxis_list", gson.toJson(objectDate));
            } else {
                data.put("xAxis_list", gson.toJson(dateList));
            }
            data.put("line_list", line_list);
            
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
            
@@ -1628,24 +1733,6 @@
    }
    
    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;
    }
}
fanli/src/main/java/com/yeshi/fanli/controller/admin/OrderAdminController.java
@@ -17,6 +17,7 @@
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.yeshi.fanli.controller.admin.utils.AdminUtils;
import com.yeshi.fanli.entity.admin.OrderAdmin;
import com.yeshi.fanli.service.inter.count.HongBaoV2CountService;
import com.yeshi.fanli.service.inter.hongbao.HongBaoService;
@@ -199,7 +200,7 @@
        }
        try {
            JSONObject data = countHongBao(channelArray, dateType, state, year, startTime,  endTime, 1);
            JSONObject data = countHistoryHongBao(channelArray, dateType, state, year, startTime,  endTime, 1);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("系统异常"));
@@ -222,20 +223,25 @@
    public void getHongBaoMoney(String callback,String channelArray, Integer dateType, Integer state,
            String year, String startTime, String endTime, PrintWriter out) {
        String validateMsg = validateParams(dateType, startTime, endTime);
        String validateMsg = AdminUtils.validateParams(dateType, startTime, endTime);
        if (validateMsg != null) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(validateMsg));
            return;
        }
        try {
            JSONObject data = countHongBao( channelArray, dateType, state, year, startTime, endTime, 2);
            JSONObject data = countHistoryHongBao(channelArray, dateType, state, year, startTime,  endTime, 1);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("系统异常"));
            e.printStackTrace();
        }
    }
    
@@ -251,13 +257,14 @@
     * @return
     * @throws Exception
     */
    public JSONObject countHongBao(String channelArray, Integer dateType, Integer state, String year, String startTime,
    public JSONObject countHistoryHongBao(String channelArray, Integer dateType, Integer state, String year, String startTime,
            String endTime, int countType) throws Exception {
        if (dateType != 1 && (!StringUtil.isNullOrEmpty(startTime) || !StringUtil.isNullOrEmpty(endTime))) {
            startTime = null;
            endTime = null;
        }
        List<String> channelList = null;
        if (channelArray != null && channelArray.trim().length() > 0) {
@@ -270,34 +277,73 @@
            channelList.add("all");
        }
        JSONArray array = new JSONArray();
        for (String channel : channelList) {
            JSONObject channelData = new JSONObject();
        if (dateType == 1 && year != null) {
            year = null; // 设置为空
        } else if (dateType == 2) {
            if (startTime != null)
                startTime = null;
            
            List<Map<String, Object>> resultList = null;
            if (countType == 1 ) {
                resultList = hongBaoV2CountService.countHongBaoNum(channel, dateType, state, year,
                        startTime, endTime);
            } else if (countType == 2) {
                resultList = hongBaoV2CountService.countHongBaoMoney(channel, dateType, state, year,
                        startTime, endTime);
            if (endTime != null)
                endTime = null;
        } else if (dateType == 3) {
            if (year != null)
                year = null;
            if (startTime != null)
                startTime = null;
            if (endTime != null)
                endTime = null;
            }
            if (resultList == null) {
                resultList = new ArrayList<Map<String, Object>>();
        Gson gson = new Gson();
        Object objectDate = null;
        List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year);
        JSONArray line_list = new JSONArray();
        for (String channel : channelList) {
            List<Map<String, Object>> list = null;
            if (countType == 1 ) {
                list = hongBaoV2CountService.countHongBaoNum(channel, dateType, state, year,
                        startTime, endTime);
            } else if (countType == 2) {
                list = hongBaoV2CountService.countHongBaoMoney(channel, dateType, state, year,
                        startTime, endTime);
            }
            if ("all".equalsIgnoreCase(channel)) {
                channel = "总计";
            }
            channelData.put("name", channel);
            channelData.put("data_list", resultList);
            array.add(channelData);
            JSONObject innerList = new JSONObject();
            innerList.put("name", channel);
            if (dateType != 3) {
                innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateList, list)));
            } else {
                // 年视图
                Map<String, Object> map = AdminUtils.yearsDataFactory(list);
                if (objectDate == null) {
                    objectDate = map.get("date");
                }
                innerList.put("data", gson.toJson(map.get("value")));
        }
            line_list.add(innerList);
        }
        JSONObject data = new JSONObject();
        data.put("result_list", array);
        if (objectDate != null) {
            data.put("xAxis_list", gson.toJson(objectDate));
        } else {
            data.put("xAxis_list", gson.toJson(dateList));
        }
        data.put("line_list", line_list);
        
        return data;
    }
fanli/src/main/java/com/yeshi/fanli/controller/admin/utils/AdminUtils.java
New file
@@ -0,0 +1,176 @@
package com.yeshi.fanli.controller.admin.utils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.yeshi.utils.DateUtil;
import com.google.gson.Gson;
import com.yeshi.fanli.util.StringUtil;
public class AdminUtils {
    /**
     * 验证数据
     * @param dateType
     * @param startTime
     * @param endTime
     * @return
     */
    public static String validateParams(Integer dateType, String startTime, String endTime) {
        String validateMsg = null;
        if (dateType == null) {
            validateMsg = "请选择视图类型";
        }
        if (dateType == 1 && (StringUtil.isNullOrEmpty(startTime) || StringUtil.isNullOrEmpty(endTime))) {
            validateMsg  = "请选择时间区间";
        }
        return validateMsg;
    }
    /**
     * 获取时间列表
     * @param dateType
     * @param startTime
     * @param endTime
     * @param year
     * @return
     */
    public static List<String> getDateList(Integer dateType, String startTime, String endTime, String year) {
        List<String> dateList = new ArrayList<String>();
        if (dateType == 1) {
            try {
                dateList = DateUtil.dayFactory(startTime, endTime);
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else if (dateType == 2) {
            for (int i = 1; i <= 12; i++) {
                dateList.add(i + ""); // 12个月
            }
        }
        return dateList;
    }
    public static Map<String, Object> yearsDataFactory(List<Map<String, Object>> list) {
        List<Object> resultList = new ArrayList<Object>();
        List<Object> listDate = new ArrayList<Object>();
        if (list != null && list.size() > 0) {
            for (int i = 0; i < list.size(); i++) {
                Map<String, Object> map = list.get(i);
                Object showValue = map.get("showValue");
                Object showDate = map.get("showDate");
                if (showValue == null) {
                    showValue = 0;
                }
                resultList.add(showValue);
                listDate.add(showDate);
            }
        }
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("date", listDate);
        map.put("value", resultList);
        return map;
    }
    public static List<Object> dayOrMonthDataFactory(List<String> listDate , List<Map<String, Object>> list) throws Exception {
        List<Object> resultList = new ArrayList<Object>();
        if (list != null && list.size() > 0) {
            for (int i = 0; i < listDate.size(); i++) {
                Object showValue = null;
                if (list != null && list.size() > 0) {
                    // 日期匹配赋值
                    for (int j = 0; j < list.size(); j++) {
                        Map<String, Object> map = list.get(j);
                        String showDate = listDate.get(i);
                        Object reslutDate = map.get("showDate");
                        String month = reslutDate.toString();
                        if (showDate.equalsIgnoreCase(month)) {
                            showValue = map.get("showValue");
                            break;
                        }
                    }
                }
                if (showValue == null) {
                    showValue = 0;
                }
                resultList.add(showValue);
            }
        }
        return resultList;
    }
    /**
     * 图表数据组织
     * @param dateType
     * @param year
     * @param startTime
     * @param endTime
     * @param list
     * @throws Exception
     */
    public static JSONObject chartDataFactory(Integer dateType, String year, String startTime, String endTime,
            List<Map<String, Object>> list) throws Exception{
        Object objectDate = null;
        List<String> dateList = getDateList(dateType, startTime, endTime, year);
        Gson gson = new Gson();
        JSONArray line_list = new JSONArray();
        JSONObject innerList = new JSONObject();
        innerList.put("name", "总计");
        if (dateType != 3) {
            innerList.put("data", gson.toJson(AdminUtils.dayOrMonthDataFactory(dateList, list)));
        } else {
            // 年视图
            Map<String, Object> map = yearsDataFactory(list);
            if (objectDate == null) {
                objectDate = map.get("date");
            }
            innerList.put("data", gson.toJson(map.get("value")));
        }
        line_list.add(innerList);
        JSONObject data = new JSONObject();
        if (objectDate != null) {
            data.put("xAxis_list", gson.toJson(objectDate));
        } else {
            data.put("xAxis_list", gson.toJson(dateList));
        }
        data.put("line_list", line_list);
        return data;
    }
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/HongBaoV2CountMapper.java
@@ -1,5 +1,6 @@
package com.yeshi.fanli.dao.mybatis;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
@@ -7,6 +8,24 @@
public interface HongBaoV2CountMapper {
    /**
     * 统计历史总到账金额
     * @param uid
     * @param state
     * @return
     */
    BigDecimal countMoneyByUidAndState(@Param("uid")Long uid, @Param("state") Integer state);
    /**
     * 统计历史红包数量
     * @param uid
     * @param state
     * @return
     */
    Integer countNumberByUidAndState(@Param("uid")Long uid, @Param("state") Integer state);
    /**
     * 统计总金额
     * @param channel 渠道
fanli/src/main/java/com/yeshi/fanli/mapping/ExtractAuditRecordMapper.xml
@@ -270,7 +270,7 @@
            <if test="years != null and years != '' ">
                 AND FROM_UNIXTIME(tr.`auditTime`/1000,'%Y') = '${years}'
            </if>
            <if test="state != null and state != 0">
            <if test="state != null and state != 3">
                 AND t.`state` = ${state}
            </if>    
        <if test="type == 1">
fanli/src/main/java/com/yeshi/fanli/mapping/hongbao/HongBaoV2CountMapper.xml
@@ -187,6 +187,22 @@
        ORDER BY h.`createtime`
    </select>
    
    <select id="countMoneyByUidAndState" resultType="java.math.BigDecimal">
        SELECT CAST(SUM(hb.`hb_money`)AS DECIMAL(19,2))
        FROM `yeshi_ec_hongbao_v2` hb
        WHERE hb.`hb_uid` = #{uid}
            <if test="state != null">
                 AND hb.`hb_state` = #{state}
            </if>
    </select>
    <select id="countNumberByUidAndState" resultType="java.lang.Integer">
        SELECT COALESCE(count(hb_id),0) FROM yeshi_ec_hongbao_v2
        WHERE hb_uid = #{uid}
            <if test="state != null">
                 AND hb_state = #{state}
            </if>
    </select>
    
    
</mapper>
fanli/src/main/java/com/yeshi/fanli/service/impl/count/HongBaoV2CountServiceImpl.java
@@ -1,5 +1,6 @@
package com.yeshi.fanli.service.impl.count;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
@@ -173,45 +174,13 @@
    @Override
    public List<Map<String, Object>> countHongBaoMoney(String channel, Integer dateType, Integer state, 
            String year, String startTime, String endTime) throws Exception {
        List<Map<String, Object>> list = hongBaoV2CountMapper.countHongBaoMoney(channel, dateType, state, 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;
        }
        return hongBaoV2CountMapper.countHongBaoMoney(channel, dateType, state, year, startTime, endTime);
    }
    
    @Override
    public List<Map<String, Object>> countHongBaoNum(String channel, Integer dateType, Integer state, 
            String year, String startTime, String endTime) throws Exception {
        List<Map<String, Object>> list = hongBaoV2CountMapper.countHongBaoNum(channel, dateType, state, 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;
        }
        return hongBaoV2CountMapper.countHongBaoNum(channel, dateType, state, year, startTime, endTime);
    }
    
@@ -279,5 +248,15 @@
        return result_list;
    }
    @Override
    public BigDecimal countMoneyByUidAndState(Long uid, Integer state) {
        return hongBaoV2CountMapper.countMoneyByUidAndState(uid, state);
    }
    @Override
    public Integer countNumberByUidAndState(Long uid, Integer state) {
        return hongBaoV2CountMapper.countNumberByUidAndState(uid, state);
    }
    
}
fanli/src/main/java/com/yeshi/fanli/service/impl/user/ExtractAuditRecordServiceImpl.java
@@ -93,172 +93,22 @@
    @Override
    public List<Map<String, Object>> countAuditTotal(Integer state, Integer type, String years, String startTime,
            String endTime) throws Exception{
        List<Map<String, Object>> list = extractAuditRecordMapper.countAuditTotal(state, type, years, startTime, endTime);
        if (list == null || list.size() == 0) {
            return list =  new ArrayList<Map<String, Object>>();
         return extractAuditRecordMapper.countAuditTotal(state, type, years, startTime, endTime);
        } 
        
        switch (type){
            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>> countExtractMoney(Integer state, Integer type, String years, String startTime,
    public List<Map<String, Object>> countExtractApplyMoney(Integer state, Integer type, String years, String startTime,
            String endTime) throws Exception{
        List<Map<String, Object>> list = extractAuditRecordMapper.countExtractMoney(state, type, years, startTime, endTime);
        if (list == null || list.size() == 0) {
            return list =  new ArrayList<Map<String, Object>>();
        return extractAuditRecordMapper.countExtractMoney(state, type, years, startTime, endTime);
        } 
        
        switch (type){
            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>> countExtractApplyNumber(Integer state, Integer type, String years, String startTime,
            String endTime) throws Exception{
        List<Map<String, Object>> list = extractAuditRecordMapper.countExtractApplyNumber(state, type, years, startTime, endTime);
        if (list == null || list.size() == 0) {
            return list =  new ArrayList<Map<String, Object>>();
        }
        switch (type){
            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("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;
        return extractAuditRecordMapper.countExtractApplyNumber(state, type, years, startTime, endTime);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/inter/count/HongBaoV2CountService.java
@@ -1,10 +1,28 @@
package com.yeshi.fanli.service.inter.count;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
public interface HongBaoV2CountService {
    /**
     * 统计历史总到账金额
     * @param uid
     * @param state
     * @return
     */
    public BigDecimal countMoneyByUidAndState(Long uid, Integer state);
    /**
     * 统计历史红包数量
     * @param uid
     * @param state
     * @return
     */
    public Integer countNumberByUidAndState(Long uid, Integer state);
    /**
     * 统计总金额
     * @param channel 渠道
@@ -44,4 +62,7 @@
    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/user/ExtractAuditRecordService.java
@@ -125,6 +125,7 @@
            String endTime) throws Exception;
    
    
    /**
     * 统计申请提的现总金额
     * @param state
@@ -134,7 +135,7 @@
     * @param endTime
     * @return
     */
    public List<Map<String, Object>> countExtractMoney(Integer state, Integer type, String years, String startTime,
    public List<Map<String, Object>> countExtractApplyMoney(Integer state, Integer type, String years, String startTime,
            String endTime) throws Exception;
    /**
@@ -150,4 +151,5 @@
            String endTime) throws Exception;
    
    
}