diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/WxUserStructureController.java b/mallinkAdmin/src/main/java/com/iformall/controller/WxUserStructureController.java index f61280b5f..eec416f8a 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/WxUserStructureController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/WxUserStructureController.java @@ -3,16 +3,11 @@ package com.iformall.controller; import com.github.pagehelper.PageInfo; import com.iformall.common.ResultData; import com.iformall.domain.dto.WxCUserBasicInfoDto; -import com.iformall.domain.po.WxCUser; -import com.iformall.domain.po.WxLevelConfig; -import com.iformall.domain.po.WxUserChannel; +import com.iformall.domain.po.*; import com.iformall.domain.vo.UserStructureVo; import com.iformall.enums.EnumAgeInfo; import com.iformall.enums.EnumCUserBaseInfoSex; -import com.iformall.service.WxCUserBasicInfoService; -import com.iformall.service.WxCUserService; -import com.iformall.service.WxLevelConfigService; -import com.iformall.service.WxUserChannelService; +import com.iformall.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -45,6 +40,9 @@ public class WxUserStructureController extends BaseController { @Autowired private WxLevelConfigService wxLevelConfigService; + @Autowired + private WxCUserCarService wxCUserCarService; + @Autowired private WxUserChannelService wxUserChannelService; @@ -132,6 +130,48 @@ public class WxUserStructureController extends BaseController { return new ResultData(levelList); } + @ApiOperation("查询会员绑车牌结构") + @GetMapping("/findUserCarStructure") + public ResultData findCarLevelStructure(Date startTime, Date endTime) { + + WxCUserBasicInfoDto dto = new WxCUserBasicInfoDto(); + dto.setTenantId(getTenantId()); + dto.setStartTime(startTime); + dto.setEndTime(endTime); + List idList = wxCUserBasicInfoService.findIdList(dto); + + WxCUserCar wxCUserCar = new WxCUserCar(); + + wxCUserCar.setTenantId(getTenantId()); + wxCUserCar.setIds(idList); //注:countUser接口通过ids传递user_id list. + long userCountWithCar = wxCUserCarService.countUser(wxCUserCar); + Map userWithCar = new HashMap(); + userWithCar.put("title","已绑定车牌"); + userWithCar.put("count",userCountWithCar); + + + long userCountWithoutCar = idList.size()-userCountWithCar; + + Map userWithoutCar = new HashMap(); + userWithoutCar.put("title","未绑定车牌"); + userWithoutCar.put("count",userCountWithoutCar); + + NumberFormat nf = NumberFormat.getPercentInstance(); + nf.setMinimumFractionDigits(2); + + if(userCountWithoutCar + userCountWithCar>0) { + userWithCar.put("percentage",nf.format(userCountWithCar/new Double(userCountWithoutCar + userCountWithCar).doubleValue())); + userWithoutCar.put("percentage",nf.format(userCountWithoutCar/new Double(userCountWithoutCar + userCountWithCar).doubleValue())); + } else { + userWithCar.put("percentage","--"); + userWithoutCar.put("percentage","--"); + } + + List list = new ArrayList<>(); + list.add(userWithCar); + list.add(userWithoutCar); + return new ResultData(list); + } /********************************会员数据**************************************/ diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxCUserBasicInfoMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxCUserBasicInfoMapper.java index 3473ed8a2..c3113e8ae 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxCUserBasicInfoMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxCUserBasicInfoMapper.java @@ -23,4 +23,6 @@ public interface WxCUserBasicInfoMapper extends CommonMapper findIdList(WxCUserBasicInfoDto dto); + } diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxCUserCarMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxCUserCarMapper.java index 33837dd76..ba46a95a9 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxCUserCarMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxCUserCarMapper.java @@ -8,10 +8,5 @@ public interface WxCUserCarMapper extends CommonMapper { List findList(WxCUserCar wxCUserCar); Integer countList(WxCUserCar wxCUserCar); - - - - - - + Integer countUser(WxCUserCar wxCUserCar); } diff --git a/mallinkService/src/main/java/com/iformall/service/WxCUserBasicInfoService.java b/mallinkService/src/main/java/com/iformall/service/WxCUserBasicInfoService.java index 4891402e4..3872e133e 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxCUserBasicInfoService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxCUserBasicInfoService.java @@ -98,6 +98,13 @@ public interface WxCUserBasicInfoService { */ long findCountByScore(WxCUserBasicInfoDto dto); + /** + * 查找id列表 + * + * @param dto + * @return + */ + List findIdList(WxCUserBasicInfoDto dto); void exportData(HttpServletRequest request, HttpServletResponse response, String tenantId); diff --git a/mallinkService/src/main/java/com/iformall/service/WxCUserCarService.java b/mallinkService/src/main/java/com/iformall/service/WxCUserCarService.java index 94d511c5e..d89691cf5 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxCUserCarService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxCUserCarService.java @@ -33,6 +33,13 @@ public interface WxCUserCarService { */ Integer countUserCar(WxCUserCar record); + /** + * 根据实体查询count + * + * @param record + * @return + */ + Integer countUser(WxCUserCar record); /** * 根据实体查询 * diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java index e2aa3cca0..cb8bfb097 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java @@ -128,13 +128,11 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { wxCUserBasicInfoMapper.deleteByPrimaryKey(id); } - @Override public long findCountBySex(WxCUserBasicInfoDto dto) { return wxCUserBasicInfoMapper.findCountBySex(dto); } - @Override public long findCountByAge(WxCUserBasicInfoDto dto) { return wxCUserBasicInfoMapper.findCountByAge(dto); @@ -145,6 +143,13 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { return wxCUserBasicInfoMapper.findCountByScore(dto); } + @Override + public List findIdList(WxCUserBasicInfoDto dto) + { + return wxCUserBasicInfoMapper.findIdList(dto); + } + + @Override public void exportData(HttpServletRequest request, HttpServletResponse response, String tenantId) { WxCUserBasicInfo basicInfoQ = new WxCUserBasicInfo(); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCUserCarServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCUserCarServiceImpl.java index f4a1a68db..9c7846242 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCUserCarServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCUserCarServiceImpl.java @@ -35,6 +35,11 @@ public class WxCUserCarServiceImpl implements WxCUserCarService { return wxCUserCarMapper.countList(record); } + @Override + public Integer countUser(WxCUserCar record) { + return wxCUserCarMapper.countUser(record); + } + @Override public WxCUserCar getOne(WxCUserCar record) { List userCarList = wxCUserCarMapper.findList(record); diff --git a/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml b/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml index 8e3fa71ab..6290247c4 100644 --- a/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml @@ -193,5 +193,17 @@ and tenant_id =#{tenantId} - + + diff --git a/mallinkService/src/main/resources/mapper/WxCUserCarMapper.xml b/mallinkService/src/main/resources/mapper/WxCUserCarMapper.xml index 10e441e69..a366412b8 100644 --- a/mallinkService/src/main/resources/mapper/WxCUserCarMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCUserCarMapper.xml @@ -76,5 +76,18 @@ select count(*) from wx_c_user_car - + +