| | |
| | |
|
| | | 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;
|
| | |
| | | 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;
|
| | |
| | |
|
| | | @Resource
|
| | | private HongBaoService hongBaoService;
|
| | | |
| | | @Resource
|
| | | private HongBaoV2CountService hongBaoV2CountService;
|
| | |
|
| | | @Resource
|
| | | private AdminUserService adminUserService;
|
| | |
| | | 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);
|
| | |
|
| | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | |
|
| | | } catch (Exception e) {
|
| | | // TODO: handle exception
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
|
| | | e.printStackTrace();
|
| | | }
|
| | |
| | | /**
|
| | | * 统计审核次数
|
| | | * @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
|
| | |
| | | * @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))) {
|
| | | startTime = null;
|
| | | endTime = null;
|
| | | if (dateType == 1 && year != null) {
|
| | | year = null; // 设置为空
|
| | | } else if (dateType == 2) {
|
| | | if (startTime != null) |
| | | startTime = null; |
| | | |
| | | if (endTime != null) |
| | | endTime = null; |
| | | |
| | | } else if (dateType == 3) {
|
| | | if (year != null)
|
| | | year = null; |
| | | |
| | | if (startTime != null) |
| | | startTime = null; |
| | | |
| | | if (endTime != null) |
| | | endTime = null; |
| | | }
|
| | |
|
| | | try {
|
| | | Object objectDate = null;
|
| | | List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year);
|
| | | |
| | | Gson gson = new Gson();
|
| | | List<Integer> stateList = gson.fromJson(stateArray, new TypeToken<ArrayList<Integer>>() {}.getType());
|
| | |
|
| | | 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", "驳回数");
|
| | | JSONArray line_list = new JSONArray();
|
| | | for (Integer state: stateList) {
|
| | | JSONObject innerList = new JSONObject();
|
| | | if (state == null || state == 3) {
|
| | | innerList.put("name", "总计");
|
| | | } else if (state == 1) {
|
| | | innerList.put("name", "通过数");
|
| | | } else if (state == 2) {
|
| | | innerList.put("name", "驳回数");
|
| | | }
|
| | | |
| | | |
| | | List<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);
|
| | | }
|
| | | innerList.put("data_list", resultList);
|
| | | |
| | | JSONArray outList = new JSONArray();
|
| | | outList.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));
|
| | |
|
| | |
| | | /**
|
| | | * 统计提现申请总额
|
| | | * @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))) {
|
| | | startTime = null;
|
| | | endTime = null;
|
| | | if (dateType == 1 && year != null) {
|
| | | year = null; // 设置为空
|
| | | } else if (dateType == 2) {
|
| | | if (startTime != null) |
| | | startTime = null; |
| | | |
| | | if (endTime != null) |
| | | endTime = null; |
| | | |
| | | } else if (dateType == 3) {
|
| | | if (year != null)
|
| | | year = null; |
| | | |
| | | if (startTime != null) |
| | | startTime = null; |
| | | |
| | | if (endTime != null) |
| | | endTime = null; |
| | | }
|
| | |
|
| | | try {
|
| | |
|
| | | List<Map<String, Object>> resultList = 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);
|
| | | innerList.put("name", "总计");
|
| | |
|
| | | 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));
|
| | |
|
| | |
| | | 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))) {
|
| | | startTime = null;
|
| | | endTime = null;
|
| | | if (dateType == 1 && year != null) {
|
| | | year = null; // 设置为空
|
| | | } else if (dateType == 2) {
|
| | | if (startTime != null) |
| | | startTime = null; |
| | | |
| | | if (endTime != null) |
| | | endTime = null; |
| | | |
| | | } else if (dateType == 3) {
|
| | | if (year != null)
|
| | | year = null; |
| | | |
| | | if (startTime != null) |
| | | startTime = null; |
| | | |
| | | if (endTime != null) |
| | | endTime = null; |
| | | }
|
| | |
|
| | | try {
|
| | |
|
| | | List<Map<String, Object>> resultList = 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);
|
| | | innerList.put("name", "总计");
|
| | |
|
| | | 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));
|
| | |
|
| | |
| | | data.put("extractMoney", resultData.get("totalmoney"));
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
|
| | | }
|
| | | |
| | | |
| | |
|
| | |
|
| | | 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;
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | 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;
|
| | |
| | | }
|
| | |
|
| | | 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("系统异常"));
|
| | |
| | | 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("系统异常"));
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | |
| | | |
| | | |
| | |
|
| | |
|
| | |
|
| | |
| | | * @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))) {
|
| | |
| | | endTime = null;
|
| | | }
|
| | |
|
| | | |
| | | List<String> channelList = null;
|
| | | if (channelArray != null && channelArray.trim().length() > 0) {
|
| | | Gson gson = new Gson();
|
| | |
| | | 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 (endTime != null) |
| | | endTime = null; |
| | | |
| | | } else if (dateType == 3) {
|
| | | if (year != null)
|
| | | year = null; |
| | | |
| | | if (startTime != null) |
| | | startTime = null; |
| | | |
| | | if (endTime != null) |
| | | endTime = null; |
| | | }
|
| | | |
| | | Gson gson = new Gson();
|
| | | Object objectDate = null;
|
| | | List<String> dateList = AdminUtils.getDateList(dateType, startTime, endTime, year);
|
| | | |
| | | JSONArray line_list = new JSONArray();
|
| | | for (String channel : channelList) {
|
| | | List<Map<String, Object>> list = null;
|
| | | if (countType == 1 ) {
|
| | | resultList = hongBaoV2CountService.countHongBaoNum(channel, dateType, state, year, |
| | | list = hongBaoV2CountService.countHongBaoNum(channel, dateType, state, year, |
| | | startTime, endTime);
|
| | | } else if (countType == 2) {
|
| | | resultList = hongBaoV2CountService.countHongBaoMoney(channel, dateType, state, year, |
| | | list = hongBaoV2CountService.countHongBaoMoney(channel, dateType, state, year, |
| | | startTime, endTime);
|
| | | }
|
| | |
|
| | | 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 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;
|
| | | }
|
New file |
| | |
| | | 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;
|
| | | }
|
| | | |
| | | }
|
| | |
| | | package com.yeshi.fanli.dao.mybatis; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | |
| | | 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 渠道 |
| | |
| | | <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"> |
| | |
| | | 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> |
| | |
| | | package com.yeshi.fanli.service.impl.count;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | |
| | | @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);
|
| | | }
|
| | |
|
| | |
|
| | |
| | | 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);
|
| | | }
|
| | |
|
| | |
|
| | | }
|
| | |
| | | @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>>();
|
| | | } |
| | | |
| | | switch (type){
|
| | | case 1: // 按天处理
|
| | | return dayFactory(startTime, endTime, list);
|
| | | case 2: // 按月处理
|
| | | return monthFactory(list);
|
| | | case 3: |
| | | return yearFactory(list);
|
| | | default: |
| | | return null;
|
| | | }
|
| | | return extractAuditRecordMapper.countAuditTotal(state, type, years, startTime, endTime);
|
| | | }
|
| | |
|
| | | |
| | | |
| | | @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>>();
|
| | | } |
| | | |
| | | switch (type){
|
| | | case 1: // 按天处理
|
| | | return dayFactory(startTime, endTime, list);
|
| | | case 2: // 按月处理
|
| | | return monthFactory(list);
|
| | | case 3: |
| | | return yearFactory(list);
|
| | | default: |
| | | return null;
|
| | | }
|
| | | return extractAuditRecordMapper.countExtractMoney(state, type, years, startTime, endTime);
|
| | | }
|
| | | |
| | |
|
| | | @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;
|
| | | }
|
| | | return extractAuditRecordMapper.countExtractApplyNumber(state, type, years, startTime, endTime);
|
| | | }
|
| | |
|
| | |
|
| | | |
| | | 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;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | 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 渠道
|
| | |
| | | public List<Map<String, Object>> getProportionByType(Integer dateType, Integer type, String year, String startTime,
|
| | | String endTime) throws Exception;
|
| | |
|
| | | |
| | | |
| | | |
| | | }
|
| | |
| | | * @param endTime
|
| | | * @return
|
| | | */
|
| | | public List<Map<String, Object>> countAuditTotal(Integer state, Integer type, String years, String startTime,
|
| | | public List<Map<String, Object>>countAuditTotal(Integer state, Integer type, String years, String startTime,
|
| | | String endTime) throws Exception;
|
| | | |
| | |
|
| | |
|
| | | /**
|
| | |
| | | * @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;
|
| | |
|
| | | /**
|
| | |
| | | String endTime) throws Exception;
|
| | |
|
| | |
|
| | | |
| | | }
|