| @@ -9,8 +9,11 @@ import io.swagger.annotations.ApiOperation; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.web.bind.annotation.GetMapping; | import org.springframework.web.bind.annotation.GetMapping; | ||||
| import org.springframework.web.bind.annotation.RequestMapping; | import org.springframework.web.bind.annotation.RequestMapping; | ||||
| import org.springframework.web.bind.annotation.RequestParam; | |||||
| import org.springframework.web.bind.annotation.RestController; | import org.springframework.web.bind.annotation.RestController; | ||||
| import java.util.List; | |||||
| @Api(description = "驾驶舱大屏") | @Api(description = "驾驶舱大屏") | ||||
| @RestController | @RestController | ||||
| @RequestMapping("cockpitscreen") | @RequestMapping("cockpitscreen") | ||||
| @@ -32,4 +35,18 @@ public class CockpitScreenController extends BaseController { | |||||
| public ResultData countShop() { | public ResultData countShop() { | ||||
| return new ResultData(cockpitScreenService.countShop(getTenantInfo())); | return new ResultData(cockpitScreenService.countShop(getTenantInfo())); | ||||
| } | } | ||||
| @TenantIgnore | |||||
| @ApiOperation("驾驶舱大屏-统计会员") | |||||
| @GetMapping("/countUser") | |||||
| public ResultData countUser(@RequestParam("years") List<Integer> years) { | |||||
| return new ResultData(cockpitScreenService.countUser(getTenantInfo(), years)); | |||||
| } | |||||
| @TenantIgnore | |||||
| @ApiOperation("驾驶舱大屏-统计触达用户") | |||||
| @GetMapping("/countReachUser") | |||||
| public ResultData countReachUser(@RequestParam("years") List<Integer> years) { | |||||
| return new ResultData(cockpitScreenService.countReachUser(getTenantInfo(), years)); | |||||
| } | |||||
| } | } | ||||
| @@ -0,0 +1,16 @@ | |||||
| package com.iformall.domain.vo.cockpit; | |||||
| import io.swagger.annotations.ApiModel; | |||||
| import io.swagger.annotations.ApiModelProperty; | |||||
| import lombok.Data; | |||||
| import java.util.List; | |||||
| @ApiModel(value = "年度某一数据统计返回数据") | |||||
| @Data | |||||
| public class CountMonthVO { | |||||
| @ApiModelProperty(value = "年份") | |||||
| private Integer year; | |||||
| @ApiModelProperty(value = "月份") | |||||
| private List<MonthDataVO> months; | |||||
| } | |||||
| @@ -0,0 +1,14 @@ | |||||
| package com.iformall.domain.vo.cockpit; | |||||
| import io.swagger.annotations.ApiModel; | |||||
| import io.swagger.annotations.ApiModelProperty; | |||||
| import lombok.Data; | |||||
| @ApiModel(value = "每月统计数量") | |||||
| @Data | |||||
| public class MonthDataVO { | |||||
| @ApiModelProperty(value = "月份") | |||||
| private Integer month; | |||||
| @ApiModelProperty(value = "数量") | |||||
| private Integer count; | |||||
| } | |||||
| @@ -73,5 +73,15 @@ public interface WxCUserBasicInfoMapper extends CommonMapper<WxCUserBasicInfo, S | |||||
| * @param finalTenantId | * @param finalTenantId | ||||
| */ | */ | ||||
| List<CountUserByGenderDTO> countUserByGender(@Param("finalTenantId") String finalTenantId); | List<CountUserByGenderDTO> countUserByGender(@Param("finalTenantId") String finalTenantId); | ||||
| /** | |||||
| * 统计指定年,指定月的会员数量 | |||||
| * | |||||
| * @param finalTenantId | |||||
| * @param year | |||||
| * @param month | |||||
| * @return {@link Integer} | |||||
| */ | |||||
| Integer countUserByMonth(@Param("finalTenantId") String finalTenantId, @Param("year") Integer year, @Param("month") Integer month); | |||||
| } | } | ||||
| @@ -1,9 +1,12 @@ | |||||
| package com.iformall.service; | package com.iformall.service; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.domain.vo.cockpit.CountMonthVO; | |||||
| import com.iformall.domain.vo.cockpit.CountShopVO; | import com.iformall.domain.vo.cockpit.CountShopVO; | ||||
| import com.iformall.domain.vo.cockpit.CountUserGenderVO; | import com.iformall.domain.vo.cockpit.CountUserGenderVO; | ||||
| import java.util.List; | |||||
| /** | /** | ||||
| * 驾驶舱大屏服务 | * 驾驶舱大屏服务 | ||||
| * | * | ||||
| @@ -14,4 +17,8 @@ public interface CockpitScreenService { | |||||
| CountUserGenderVO countUserGender(TenantEntity tenantInfo); | CountUserGenderVO countUserGender(TenantEntity tenantInfo); | ||||
| CountShopVO countShop(TenantEntity tenantInfo); | CountShopVO countShop(TenantEntity tenantInfo); | ||||
| List<CountMonthVO> countUser(TenantEntity tenantInfo, List<Integer> years); | |||||
| List<CountMonthVO> countReachUser(TenantEntity tenantInfo, List<Integer> years); | |||||
| } | } | ||||
| @@ -4,8 +4,10 @@ import com.iformall.common.CommonConstant; | |||||
| import com.iformall.domain.dto.cockpit.CountShopByStatusDTO; | import com.iformall.domain.dto.cockpit.CountShopByStatusDTO; | ||||
| import com.iformall.domain.dto.cockpit.CountUserByGenderDTO; | import com.iformall.domain.dto.cockpit.CountUserByGenderDTO; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.domain.vo.cockpit.CountMonthVO; | |||||
| import com.iformall.domain.vo.cockpit.CountShopVO; | import com.iformall.domain.vo.cockpit.CountShopVO; | ||||
| import com.iformall.domain.vo.cockpit.CountUserGenderVO; | import com.iformall.domain.vo.cockpit.CountUserGenderVO; | ||||
| import com.iformall.domain.vo.cockpit.MonthDataVO; | |||||
| import com.iformall.enums.EnumShopStatus; | import com.iformall.enums.EnumShopStatus; | ||||
| import com.iformall.enums.EnumUserGender; | import com.iformall.enums.EnumUserGender; | ||||
| import com.iformall.mapper.WxCUserBasicInfoMapper; | import com.iformall.mapper.WxCUserBasicInfoMapper; | ||||
| @@ -13,14 +15,14 @@ import com.iformall.mapper.WxShopMapper; | |||||
| import com.iformall.service.CockpitScreenService; | import com.iformall.service.CockpitScreenService; | ||||
| import com.iformall.service.WxCUserBasicInfoService; | import com.iformall.service.WxCUserBasicInfoService; | ||||
| import com.iformall.service.WxMallService; | import com.iformall.service.WxMallService; | ||||
| import com.iformall.utils.DateUtils; | |||||
| import org.apache.commons.collections.CollectionUtils; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import java.math.BigDecimal; | import java.math.BigDecimal; | ||||
| import java.math.RoundingMode; | import java.math.RoundingMode; | ||||
| import java.util.ArrayList; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| import java.util.*; | |||||
| import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||
| /** | /** | ||||
| @@ -96,4 +98,36 @@ public class CockpitScreenServiceImpl implements CockpitScreenService { | |||||
| result.setUnRentedShopCountRatio(BigDecimal.ONE.subtract(rentedShopCountRatio)); | result.setUnRentedShopCountRatio(BigDecimal.ONE.subtract(rentedShopCountRatio)); | ||||
| return result; | return result; | ||||
| } | } | ||||
| @Override | |||||
| public List<CountMonthVO> countUser(TenantEntity tenantInfo, List<Integer> years) { | |||||
| if (CollectionUtils.isEmpty(years)) { | |||||
| years.add(DateUtils.getYear(new Date())); | |||||
| } | |||||
| List<CountMonthVO> result = new ArrayList<>(); | |||||
| years.forEach(year -> { | |||||
| CountMonthVO countMonthVO = new CountMonthVO(); | |||||
| List<MonthDataVO> vos = new ArrayList<>(); | |||||
| for (int i = 0; i < 12; i++) { | |||||
| MonthDataVO vo = new MonthDataVO(); | |||||
| vo.setMonth(i + 1); | |||||
| Integer count = cUserBasicInfoMapper.countUserByMonth(tenantInfo.getFinalTenantId(), year, i + 1); | |||||
| vo.setCount(count); | |||||
| vos.add(vo); | |||||
| } | |||||
| countMonthVO.setYear(year); | |||||
| countMonthVO.setMonths(vos); | |||||
| result.add(countMonthVO); | |||||
| }); | |||||
| return result; | |||||
| } | |||||
| @Override | |||||
| public List<CountMonthVO> countReachUser(TenantEntity tenantInfo, List<Integer> years) { | |||||
| if (CollectionUtils.isEmpty(years)) { | |||||
| years.add(DateUtils.getYear(new Date())); | |||||
| } | |||||
| return null; | |||||
| } | |||||
| } | } | ||||
| @@ -576,6 +576,11 @@ | |||||
| WHERE final_tenant_id = #{finalTenantId} | WHERE final_tenant_id = #{finalTenantId} | ||||
| GROUP BY sex; | GROUP BY sex; | ||||
| </select> | </select> | ||||
| <select id="countUserByMonth" resultType="java.lang.Integer"> | |||||
| SELECT COUNT(id) AS `count` | |||||
| FROM wx_c_user_basic_info | |||||
| WHERE final_tenant_id = #{finalTenantId} AND DATE_FORMAT(create_date, '%Y') = #{year} AND DATE_FORMAT(create_date, '%m') = #{month} | |||||
| </select> | |||||
| <update id="incActRecordById" parameterType="java.util.HashMap"> | <update id="incActRecordById" parameterType="java.util.HashMap"> | ||||