| @@ -36,21 +36,8 @@ public class WxChartDataController extends BaseController { | |||
| @ApiImplicitParam(name = "querytime", value = "querytime", dataType = "String", paramType = "query", required = true)}) | |||
| public ResultData queryData(@RequestParam Map<String, String> params) { | |||
| logger.debug("[" + getIpAddr() + "] WxChartDataController::queryData"); | |||
| Integer chart = Integer.valueOf(params.get("chart")); | |||
| String querytime = params.get("querytime"); | |||
| String startdate = DateUtils.getSystemTime("yyyy-MM-dd"); | |||
| String enddate = startdate; | |||
| if (!StringUtils.isEmpty(querytime)) { | |||
| String[] split = querytime.split(","); | |||
| if (split.length == 2) { | |||
| startdate = split[0]; | |||
| enddate = split[1]; | |||
| } else { | |||
| startdate = split[0]; | |||
| enddate = split[0]; | |||
| } | |||
| } | |||
| return wxChartDataService.queryData(getTenantId(), chart, startdate, enddate); | |||
| params.put("tenantId",super.getTenantId()); | |||
| return wxChartDataService.queryData(params); | |||
| } | |||
| } | |||
| @@ -116,12 +116,13 @@ public class WxCouponController extends BaseController { | |||
| return new ResultData(wxCouponService.list(wxCoupon)); | |||
| } | |||
| @ApiOperation("卡类列表统计接口") | |||
| @GetMapping("findCountData") | |||
| @ApiOperation("卡营销列表接口") | |||
| @GetMapping("findCardCountList") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| public ResultData findCountData(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) { | |||
| public ResultData findCardCountList(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) { | |||
| //默认时间本月第一天,截止到当天 | |||
| Map<String,Object> result = new HashedMap(); | |||
| if(wxCoupon.getStartdate() == null){ | |||
| @@ -133,80 +134,46 @@ public class WxCouponController extends BaseController { | |||
| if(wxCoupon.getEnddate() == null){ | |||
| wxCoupon.setEnddate(new Date()); | |||
| } | |||
| List<WxCoupon> saleMoneyList = wxCouponService.findSaleMoneyByDate(wxCoupon); | |||
| List<WxCoupon> paymentList = wxCouponService.findPaymentByDate(wxCoupon); | |||
| Map<String,Integer> saleMap = getDateMap(wxCoupon.getStartdate(),wxCoupon.getEnddate()); | |||
| Map<String,Integer> payMentMap = getDateMap(wxCoupon.getStartdate(),wxCoupon.getEnddate()); | |||
| for (WxCoupon coupon:saleMoneyList){ | |||
| saleMap.put(coupon.getXtime(),coupon.getSaleAmount()); | |||
| } | |||
| for (WxCoupon coupon:paymentList){ | |||
| payMentMap.put(coupon.getXtime(),coupon.getSumPayment()); | |||
| } | |||
| result.put("list",wxCouponService.findCountData(wxCoupon,pageNum,pageSize)); | |||
| result.put("saleHistory",saleMap); | |||
| result.put("paymentHistory",payMentMap); | |||
| result.put("saleCardCount",wxCouponService.findSaleCardCount(wxCoupon)); | |||
| result.put("tranCount",wxCouponService.findTranCardCount(wxCoupon)); | |||
| result.put("subsidyCount",wxCouponService.findSubsidyMoney(wxCoupon)); | |||
| return new ResultData(result); | |||
| } | |||
| @ApiOperation("卷列表统计接口") | |||
| @GetMapping("findCouponData") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| public ResultData findCouponData(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) { | |||
| @GetMapping("findCouponHistory") | |||
| public ResultData findCouponHistory(@ModelAttribute WxCoupon wxCoupon) { | |||
| //默认时间本月第一天,截止到当天 | |||
| Map<String,Object> result = new HashedMap(); | |||
| if(wxCoupon.getStartdate() == null){ | |||
| Calendar c = Calendar.getInstance(); | |||
| c.add(Calendar.MONTH, 0); | |||
| c.set(Calendar.DAY_OF_MONTH,1); | |||
| wxCoupon.setStartdate(c.getTime()); | |||
| } | |||
| if(wxCoupon.getEnddate() == null){ | |||
| wxCoupon.setEnddate(new Date()); | |||
| } | |||
| List<WxCoupon> saleMoneyList = wxCouponService.findSaleMoneyByDate(wxCoupon); | |||
| List<WxCoupon> paymentList = wxCouponService.findPaymentByDate(wxCoupon); | |||
| Map<String,Integer> saleMap = getDateMap(wxCoupon.getStartdate(),wxCoupon.getEnddate()); | |||
| Map<String,Integer> payMentMap = getDateMap(wxCoupon.getStartdate(),wxCoupon.getEnddate()); | |||
| for (WxCoupon coupon:saleMoneyList){ | |||
| saleMap.put(coupon.getXtime(),coupon.getSaleAmount()); | |||
| } | |||
| for (WxCoupon coupon:paymentList){ | |||
| payMentMap.put(coupon.getXtime(),coupon.getSumPayment()); | |||
| } | |||
| result.put("list",wxCouponService.findCouponData(wxCoupon,pageNum,pageSize)); | |||
| result.put("saleHistory",saleMap); | |||
| result.put("paymentHistory",payMentMap); | |||
| result.put("saleCardCount",wxCouponService.findSaleCardCount(wxCoupon)); | |||
| result.put("tranCount",wxCouponService.findTranCardCount(wxCoupon)); | |||
| result.put("subsidyCount",wxCouponService.findSubsidyMoney(wxCoupon)); | |||
| // if(wxCoupon.getStartdate() == null){ | |||
| // Calendar c = Calendar.getInstance(); | |||
| // c.add(Calendar.MONTH, 0); | |||
| // c.set(Calendar.DAY_OF_MONTH,1); | |||
| // wxCoupon.setStartdate(c.getTime()); | |||
| // } | |||
| // if(wxCoupon.getEnddate() == null){ | |||
| // wxCoupon.setEnddate(new Date()); | |||
| // } | |||
| // List<WxCoupon> saleMoneyList = wxCouponService.findSaleMoneyByDate(wxCoupon); | |||
| // List<WxCoupon> paymentList = wxCouponService.findPaymentByDate(wxCoupon); | |||
| // Map<String,Integer> saleMap = getDateMap(wxCoupon.getStartdate(),wxCoupon.getEnddate()); | |||
| // Map<String,Integer> payMentMap = getDateMap(wxCoupon.getStartdate(),wxCoupon.getEnddate()); | |||
| // | |||
| // for (WxCoupon coupon:saleMoneyList){ | |||
| // saleMap.put(coupon.getXtime(),coupon.getSaleAmount()); | |||
| // } | |||
| // for (WxCoupon coupon:paymentList){ | |||
| // payMentMap.put(coupon.getXtime(),coupon.getSumPayment()); | |||
| // } | |||
| // result.put("saleHistory",saleMap); | |||
| // result.put("paymentHistory",payMentMap); | |||
| // result.put("saleCardCount",wxCouponService.findSaleCardCount(wxCoupon)); | |||
| // result.put("tranCount",wxCouponService.findTranCardCount(wxCoupon)); | |||
| // result.put("subsidyCount",wxCouponService.findSubsidyMoney(wxCoupon)); | |||
| return new ResultData(result); | |||
| } | |||
| public static Map<String,Integer> getDateMap(Date begin, Date end) { | |||
| SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); | |||
| Map<String,Integer> map = new LinkedHashMap<>(); | |||
| map.put(format.format(begin),0); | |||
| Calendar calBegin = Calendar.getInstance(); | |||
| calBegin.setTime(begin); | |||
| Calendar calEnd = Calendar.getInstance(); | |||
| calEnd.setTime(end); | |||
| while (calBegin.getTime().before(end)) { | |||
| calBegin.add(Calendar.DAY_OF_MONTH, 1); | |||
| map.put(format.format(calBegin.getTime()),0); | |||
| } | |||
| return map; | |||
| } | |||
| } | |||
| @@ -48,7 +48,10 @@ public enum EnumChart { | |||
| HYNLCC(41, "会员年龄层次"), | |||
| HYCZZ(42, "会员成长值"), | |||
| HYSJPP(43, "会员手机品牌"), | |||
| HYHYD(44, "会员活跃度"),; | |||
| HYHYD(44, "会员活跃度"), | |||
| SALE_CARD(45, "卡营销数据"), | |||
| SALE_COUPON(46, "卷营销数据"); | |||
| public static EnumChart getEnum(Integer code) { | |||
| for (EnumChart value : values()) { | |||
| @@ -2,7 +2,9 @@ package com.iformall.service; | |||
| import com.iformall.common.ResultData; | |||
| import java.util.Map; | |||
| public interface WxChartDataService { | |||
| ResultData queryData(String tenantId, Integer chart, String startdate, String enddate); | |||
| ResultData queryData(Map<String, String> params); | |||
| } | |||
| @@ -10,7 +10,10 @@ import com.iformall.domain.vo.*; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.mapper.*; | |||
| import com.iformall.service.WxChartDataService; | |||
| import com.iformall.service.WxCouponService; | |||
| import com.iformall.utils.DateUtils; | |||
| import org.apache.commons.collections.map.HashedMap; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| @@ -55,10 +58,28 @@ public class WxChartServiceImpl implements WxChartDataService { | |||
| WxLevelConfigMapper wxLevelConfigMapper; | |||
| @Autowired | |||
| WxCUserTagsMapper wxCUserTagsMapper; | |||
| @Autowired | |||
| WxCouponService wxCouponService; | |||
| @Override | |||
| public ResultData queryData(String tenantId, Integer chart, String startdate, String enddate) { | |||
| public ResultData queryData(Map<String, String> paramsMap) { | |||
| String tenantId = paramsMap.get("tenantId"); | |||
| Integer chart = Integer.valueOf(paramsMap.get("chart")); | |||
| String querytime = paramsMap.get("querytime"); | |||
| String startdate = DateUtils.getSystemTime("yyyy-MM-dd"); | |||
| String enddate = startdate; | |||
| if (!StringUtils.isEmpty(querytime)) { | |||
| String[] split = querytime.split(","); | |||
| if (split.length == 2) { | |||
| startdate = split[0]; | |||
| enddate = split[1]; | |||
| } else { | |||
| startdate = split[0]; | |||
| enddate = split[0]; | |||
| } | |||
| } | |||
| //出租率 | |||
| HashMap<String, Object> datamap = new HashMap<>(); | |||
| if (chart.equals(EnumChart.CZL.getCode())) { | |||
| @@ -1447,6 +1468,46 @@ public class WxChartServiceImpl implements WxChartDataService { | |||
| tagList.add(tag); | |||
| return new ResultData(tagList); | |||
| } | |||
| //卡营销数据 | |||
| if (chart.equals(EnumChart.SALE_CARD.getCode())) { | |||
| WxCoupon wxCoupon = new WxCoupon(); | |||
| wxCoupon.setTitle(paramsMap.get("title")); | |||
| //默认时间本月第一天,截止到当天 | |||
| Map<String,Object> result = new HashedMap(); | |||
| if(startdate == null){ | |||
| Calendar c = Calendar.getInstance(); | |||
| c.add(Calendar.MONTH, 0); | |||
| c.set(Calendar.DAY_OF_MONTH,1); | |||
| wxCoupon.setStartdate(c.getTime()); | |||
| }else{ | |||
| Date startTime = DateUtils.stringToDate(startdate + " 00:00:00"); | |||
| wxCoupon.setStartdate(startTime); | |||
| } | |||
| if(enddate == null){ | |||
| wxCoupon.setEnddate(new Date()); | |||
| }else{ | |||
| Date endTime = DateUtils.stringToDate(enddate + " 23:59:59"); | |||
| wxCoupon.setEnddate(endTime); | |||
| } | |||
| List<WxCoupon> saleMoneyList = wxCouponService.findSaleMoneyByDate(wxCoupon); | |||
| List<WxCoupon> paymentList = wxCouponService.findPaymentByDate(wxCoupon); | |||
| Map<String,Integer> saleMap = getDateMap(wxCoupon.getStartdate(),wxCoupon.getEnddate()); | |||
| Map<String,Integer> payMentMap = getDateMap(wxCoupon.getStartdate(),wxCoupon.getEnddate()); | |||
| for (WxCoupon coupon:saleMoneyList){ | |||
| saleMap.put(coupon.getXtime(),coupon.getSaleAmount()); | |||
| } | |||
| for (WxCoupon coupon:paymentList){ | |||
| payMentMap.put(coupon.getXtime(),coupon.getSumPayment()); | |||
| } | |||
| result.put("saleHistory",saleMap); | |||
| result.put("paymentHistory",payMentMap); | |||
| result.put("saleCardCount",wxCouponService.findSaleCardCount(wxCoupon)); | |||
| result.put("tranCount",wxCouponService.findTranCardCount(wxCoupon)); | |||
| result.put("subsidyCount",wxCouponService.findSubsidyMoney(wxCoupon)); | |||
| return new ResultData(result); | |||
| } | |||
| return new ResultData(datamap); | |||
| } | |||
| @@ -1496,7 +1557,6 @@ public class WxChartServiceImpl implements WxChartDataService { | |||
| return timemap; | |||
| } | |||
| private long getCountByAge(EnumAgeInfo a, Calendar c, WxCUserBasicInfoDto dto) { | |||
| if (a.getStart() != 0 || a.getEnd() != 0) { | |||
| c.add(Calendar.YEAR, -a.getEnd()); | |||
| @@ -1531,4 +1591,19 @@ public class WxChartServiceImpl implements WxChartDataService { | |||
| return vo; | |||
| } | |||
| public static Map<String,Integer> getDateMap(Date begin, Date end) { | |||
| SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); | |||
| Map<String,Integer> map = new LinkedHashMap<>(); | |||
| map.put(format.format(begin),0); | |||
| Calendar calBegin = Calendar.getInstance(); | |||
| calBegin.setTime(begin); | |||
| Calendar calEnd = Calendar.getInstance(); | |||
| calEnd.setTime(end); | |||
| while (calBegin.getTime().before(end)) { | |||
| calBegin.add(Calendar.DAY_OF_MONTH, 1); | |||
| map.put(format.format(calBegin.getTime()),0); | |||
| } | |||
| return map; | |||
| } | |||
| } | |||