commit
fb860aaafe
@ -1,16 +1,16 @@
|
|||||||
package com.stdiet.web.controller.custom;
|
package com.stdiet.web.controller.custom;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.math.BigDecimal;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.stdiet.common.utils.DateUtils;
|
import com.stdiet.common.utils.DateUtils;
|
||||||
import com.stdiet.custom.domain.SysWxDistribution;
|
import com.stdiet.custom.domain.SysWxDistribution;
|
||||||
import com.stdiet.custom.dto.request.FanStatisticsRequest;
|
import com.stdiet.custom.dto.request.FanStatisticsRequest;
|
||||||
import com.stdiet.custom.dto.response.ExportFanStatisticsResponse;
|
import com.stdiet.custom.dto.response.ExportFanStatisticsResponse;
|
||||||
|
import com.stdiet.custom.service.ISysImportFanRecordService;
|
||||||
import com.stdiet.custom.service.ISysWxDistributionService;
|
import com.stdiet.custom.service.ISysWxDistributionService;
|
||||||
import com.stdiet.framework.web.domain.server.Sys;
|
import com.stdiet.framework.web.domain.server.Sys;
|
||||||
|
import io.swagger.models.auth.In;
|
||||||
import org.aspectj.weaver.loadtime.Aj;
|
import org.aspectj.weaver.loadtime.Aj;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -40,6 +40,9 @@ public class SysWxFanStatisticsController extends BaseController
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ISysWxDistributionService sysWxDistributionService;
|
private ISysWxDistributionService sysWxDistributionService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysImportFanRecordService sysImportFanRecordService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询进粉统计列表
|
* 查询进粉统计列表
|
||||||
*/
|
*/
|
||||||
@ -153,4 +156,78 @@ public class SysWxFanStatisticsController extends BaseController
|
|||||||
List<SysWxDistribution> list = sysWxDistributionService.selectDistributionWxByUserId(userId);
|
List<SysWxDistribution> list = sysWxDistributionService.selectDistributionWxByUserId(userId);
|
||||||
return AjaxResult.success(list);
|
return AjaxResult.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取导粉通过率
|
||||||
|
*/
|
||||||
|
@RequestMapping("/getImportFanPassRate")
|
||||||
|
public AjaxResult getImportFanPassRate(SysWxFanStatistics sysWxFanStatistics){
|
||||||
|
List<Map<String,Object>> passList = sysWxFanStatisticsService.getTotalFanNumGroupByChannel(sysWxFanStatistics);
|
||||||
|
List<Map<String,Object>> importList = sysImportFanRecordService.getTotalFanNumGroupByChannel(sysWxFanStatistics);
|
||||||
|
List<Map<String,Object>> resultList = new ArrayList<>();
|
||||||
|
List<Integer> channelIdList = new ArrayList<>();
|
||||||
|
for (Map<String,Object> map : passList) {
|
||||||
|
Integer channelId = (Integer)map.get("channelId");
|
||||||
|
if(channelId != null && !channelIdList.contains(channelId)){
|
||||||
|
channelIdList.add(channelId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Map<String,Object> map : importList) {
|
||||||
|
Integer channelId = (Integer)map.get("channelId");
|
||||||
|
if(channelId != null && !channelIdList.contains(channelId)){
|
||||||
|
channelIdList.add(channelId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Double allTotalImportFanNum = 0.0;
|
||||||
|
Double allTotalPassFanNum = 0.0;
|
||||||
|
for (Integer channelId : channelIdList) {
|
||||||
|
//根据渠道ID查询导粉记录
|
||||||
|
Map<String,Object> importMap = getMap(importList, channelId);
|
||||||
|
Map<String,Object> passMap = getMap(passList, channelId);
|
||||||
|
if(importMap != null || passMap != null){
|
||||||
|
BigDecimal totalImportFanNum = new BigDecimal(0);
|
||||||
|
BigDecimal totalPassFanNum = new BigDecimal(0);
|
||||||
|
String channelName = "";
|
||||||
|
if(importMap != null){
|
||||||
|
totalImportFanNum = importMap.get("totalFanNum") != null ? (BigDecimal) importMap.get("totalFanNum") : new BigDecimal(0);
|
||||||
|
channelName = (String)importMap.get("channelName");
|
||||||
|
}
|
||||||
|
if(passMap != null){
|
||||||
|
totalPassFanNum = passMap.get("totalFanNum") != null ? (BigDecimal) passMap.get("totalFanNum") : new BigDecimal(0);
|
||||||
|
channelName = (String)passMap.get("channelName");
|
||||||
|
}
|
||||||
|
if(totalImportFanNum.doubleValue() == 0 && totalPassFanNum.doubleValue() == 0){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
allTotalImportFanNum += totalImportFanNum.doubleValue();
|
||||||
|
allTotalPassFanNum += totalPassFanNum.doubleValue();
|
||||||
|
Map<String, Object> rateMap = new HashMap<>();
|
||||||
|
rateMap.put("channelName", channelName);
|
||||||
|
rateMap.put("totalImportFanNum", totalImportFanNum);
|
||||||
|
rateMap.put("totalPassFanNum", totalPassFanNum);
|
||||||
|
BigDecimal passRate = totalImportFanNum.doubleValue() > 0 ? new BigDecimal(totalPassFanNum.doubleValue()*100/totalImportFanNum.doubleValue()).setScale(1, BigDecimal.ROUND_HALF_UP) : new BigDecimal(100);
|
||||||
|
rateMap.put("passRate", passRate.doubleValue() > 100 ? 100 : passRate);
|
||||||
|
resultList.add(rateMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(resultList.size() > 0){
|
||||||
|
Map<String,Object> total = new HashMap<>();
|
||||||
|
total.put("channelName", "总计");
|
||||||
|
total.put("totalImportFanNum", allTotalImportFanNum);
|
||||||
|
total.put("totalPassFanNum", allTotalPassFanNum);
|
||||||
|
BigDecimal totalPassRate = allTotalImportFanNum > 0 ? new BigDecimal(allTotalPassFanNum*100/allTotalImportFanNum).setScale(1, BigDecimal.ROUND_HALF_UP) : new BigDecimal(100);
|
||||||
|
total.put("passRate", totalPassRate.doubleValue() > 100 ? 100 : totalPassRate);
|
||||||
|
resultList.add(total);
|
||||||
|
}
|
||||||
|
return AjaxResult.success(resultList);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String,Object> getMap(List<Map<String,Object>> list, Integer channelId){
|
||||||
|
for (Map<String,Object> map : list) {
|
||||||
|
if(map.get("channelId") != null && ((Integer) map.get("channelId")).intValue() == channelId.intValue()){
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
package com.stdiet.custom.mapper;
|
package com.stdiet.custom.mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import com.stdiet.custom.domain.SysImportFanRecord;
|
import com.stdiet.custom.domain.SysImportFanRecord;
|
||||||
|
import com.stdiet.custom.domain.SysWxFanStatistics;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导粉管理Mapper接口
|
* 导粉管理Mapper接口
|
||||||
@ -68,4 +71,11 @@ public interface SysImportFanRecordMapper
|
|||||||
|
|
||||||
//查询总导粉数量
|
//查询总导粉数量
|
||||||
int selectTotalSysImportFanNum(SysImportFanRecord sysImportFanRecord);
|
int selectTotalSysImportFanNum(SysImportFanRecord sysImportFanRecord);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据时间范围统计各个渠道的总导粉数量
|
||||||
|
* @param sysWxFanStatistics
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<Map<String,Object>> getTotalFanNumGroupByChannel(SysWxFanStatistics sysWxFanStatistics);
|
||||||
}
|
}
|
@ -3,6 +3,7 @@ package com.stdiet.custom.mapper;
|
|||||||
import com.stdiet.custom.domain.SysRecipes;
|
import com.stdiet.custom.domain.SysRecipes;
|
||||||
import com.stdiet.custom.domain.SysRecipesDaily;
|
import com.stdiet.custom.domain.SysRecipesDaily;
|
||||||
import com.stdiet.custom.domain.SysRecipesDailyDishes;
|
import com.stdiet.custom.domain.SysRecipesDailyDishes;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -33,4 +34,8 @@ public interface SysRecipesMapper {
|
|||||||
public List<SysRecipesDailyDishes> selectDishesByMenuId(Long id);
|
public List<SysRecipesDailyDishes> selectDishesByMenuId(Long id);
|
||||||
|
|
||||||
public List<SysRecipesDailyDishes> selectDishesByMenuIdShow(Long id);
|
public List<SysRecipesDailyDishes> selectDishesByMenuIdShow(Long id);
|
||||||
|
|
||||||
|
List<SysRecipesDaily> getRecipesListByRecipesId(@Param("recipesId")Long id);
|
||||||
|
|
||||||
|
int updateRecipesById(SysRecipesDaily sysRecipesDaily);
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package com.stdiet.custom.mapper;
|
|||||||
import com.stdiet.custom.domain.SysWxFanStatistics;
|
import com.stdiet.custom.domain.SysWxFanStatistics;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 进粉统计Mapper接口
|
* 进粉统计Mapper接口
|
||||||
@ -73,4 +74,11 @@ public interface SysWxFanStatisticsMapper {
|
|||||||
public int selectFanNumCount(SysWxFanStatistics sysWxFanStatistics);
|
public int selectFanNumCount(SysWxFanStatistics sysWxFanStatistics);
|
||||||
|
|
||||||
public List<SysWxFanStatistics> exportStatisticsList(SysWxFanStatistics sysWxFanStatistics);
|
public List<SysWxFanStatistics> exportStatisticsList(SysWxFanStatistics sysWxFanStatistics);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据时间范围统计每个渠道的进粉数量
|
||||||
|
* @param sysWxFanStatistics
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<Map<String,Object>> getTotalFanNumGroupByChannel(SysWxFanStatistics sysWxFanStatistics);
|
||||||
}
|
}
|
@ -1,7 +1,10 @@
|
|||||||
package com.stdiet.custom.service;
|
package com.stdiet.custom.service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import com.stdiet.custom.domain.SysImportFanRecord;
|
import com.stdiet.custom.domain.SysImportFanRecord;
|
||||||
|
import com.stdiet.custom.domain.SysWxFanStatistics;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导粉管理Service接口
|
* 导粉管理Service接口
|
||||||
@ -61,4 +64,11 @@ public interface ISysImportFanRecordService
|
|||||||
|
|
||||||
//查询总导粉数量
|
//查询总导粉数量
|
||||||
int selectTotalSysImportFanNum(SysImportFanRecord sysImportFanRecord);
|
int selectTotalSysImportFanNum(SysImportFanRecord sysImportFanRecord);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据时间范围统计各个渠道的总导粉数量
|
||||||
|
* @param sysWxFanStatistics
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<Map<String,Object>> getTotalFanNumGroupByChannel(SysWxFanStatistics sysWxFanStatistics);
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package com.stdiet.custom.service;
|
package com.stdiet.custom.service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import com.stdiet.common.core.domain.AjaxResult;
|
import com.stdiet.common.core.domain.AjaxResult;
|
||||||
import com.stdiet.custom.domain.SysWxFanStatistics;
|
import com.stdiet.custom.domain.SysWxFanStatistics;
|
||||||
@ -84,4 +85,11 @@ public interface ISysWxFanStatisticsService
|
|||||||
public int selectFanNumCount(SysWxFanStatistics sysWxFanStatistics);
|
public int selectFanNumCount(SysWxFanStatistics sysWxFanStatistics);
|
||||||
|
|
||||||
List<SysWxFanStatistics> exportStatisticsList(SysWxFanStatistics sysWxFanStatistics);
|
List<SysWxFanStatistics> exportStatisticsList(SysWxFanStatistics sysWxFanStatistics);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据时间范围统计每个渠道的进粉数量
|
||||||
|
* @param sysWxFanStatistics
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<Map<String,Object>> getTotalFanNumGroupByChannel(SysWxFanStatistics sysWxFanStatistics);
|
||||||
}
|
}
|
@ -2,8 +2,11 @@ package com.stdiet.custom.service.impl;
|
|||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import com.stdiet.common.utils.DateUtils;
|
import com.stdiet.common.utils.DateUtils;
|
||||||
import com.stdiet.custom.domain.SysImportFanWxAccount;
|
import com.stdiet.custom.domain.SysImportFanWxAccount;
|
||||||
|
import com.stdiet.custom.domain.SysWxFanStatistics;
|
||||||
import com.stdiet.custom.service.ISysImportFanWxAccountService;
|
import com.stdiet.custom.service.ISysImportFanWxAccountService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -138,4 +141,13 @@ public class SysImportFanRecordServiceImpl implements ISysImportFanRecordService
|
|||||||
public int selectTotalSysImportFanNum(SysImportFanRecord sysImportFanRecord){
|
public int selectTotalSysImportFanNum(SysImportFanRecord sysImportFanRecord){
|
||||||
return sysImportFanRecordMapper.selectTotalSysImportFanNum(sysImportFanRecord);
|
return sysImportFanRecordMapper.selectTotalSysImportFanNum(sysImportFanRecord);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据时间范围统计各个渠道的总导粉数量
|
||||||
|
* @param sysWxFanStatistics
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<Map<String,Object>> getTotalFanNumGroupByChannel(SysWxFanStatistics sysWxFanStatistics){
|
||||||
|
return sysImportFanRecordMapper.getTotalFanNumGroupByChannel(sysWxFanStatistics);
|
||||||
|
}
|
||||||
}
|
}
|
@ -214,23 +214,37 @@ public class SysRecipesPlanServiceImpl implements ISysRecipesPlanService {
|
|||||||
*/
|
*/
|
||||||
private void supplyRecipesBmenu(Long cusId){
|
private void supplyRecipesBmenu(Long cusId){
|
||||||
List<Map<String,Object>> list = getNeedSupplyRecipesByCusId(cusId);
|
List<Map<String,Object>> list = getNeedSupplyRecipesByCusId(cusId);
|
||||||
if(list != null && list.size() > 0){
|
if(list == null || list.size() == 0){
|
||||||
for (Map<String,Object> map : list) {
|
return;
|
||||||
Long recipesId = (Long)map.get("recipesId");
|
}
|
||||||
Integer enNumDay = (Integer)map.get("enNumDay");
|
for (Map<String,Object> map : list) {
|
||||||
Integer maxNumDay = (Integer)map.get("maxNumDay");
|
Long recipesId = (Long)map.get("recipesId");
|
||||||
if(recipesId != null && enNumDay != null && maxNumDay != null){
|
Integer startNumDay = (Integer)map.get("startNumDay");
|
||||||
List<SysRecipesDaily> menus = new ArrayList<>();
|
Integer endNumDay = (Integer)map.get("endNumDay");
|
||||||
for (int i = maxNumDay+1; i <= enNumDay; i++) {
|
if(recipesId == null || startNumDay == null || endNumDay == null){
|
||||||
SysRecipesDaily daily = new SysRecipesDaily();
|
continue;
|
||||||
daily.setCusId(cusId);
|
}
|
||||||
daily.setNumDay(i);
|
List<SysRecipesDaily> recipesDailyList = sysRecipesMapper.getRecipesListByRecipesId(recipesId);
|
||||||
daily.setRecipesId(recipesId);
|
if(recipesDailyList != null && recipesDailyList.size() > 0){
|
||||||
menus.add(daily);
|
for (SysRecipesDaily sysRecipesDaily : recipesDailyList) {
|
||||||
}
|
sysRecipesDaily.setNumDay(startNumDay);
|
||||||
sysRecipesMapper.bashAddMenus(menus);
|
//更新
|
||||||
|
sysRecipesMapper.updateRecipesById(sysRecipesDaily);
|
||||||
|
startNumDay++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
recipesDailyList = new ArrayList<>();
|
||||||
|
for (int i = startNumDay; i <= endNumDay; i++) {
|
||||||
|
SysRecipesDaily sysRecipesDaily = new SysRecipesDaily();
|
||||||
|
sysRecipesDaily.setNumDay(i);
|
||||||
|
sysRecipesDaily.setRecipesId(recipesId);
|
||||||
|
sysRecipesDaily.setCusId(cusId);
|
||||||
|
recipesDailyList.add(sysRecipesDaily);
|
||||||
|
}
|
||||||
|
if(recipesDailyList.size() > 0){
|
||||||
|
//批量添加
|
||||||
|
sysRecipesMapper.bashAddMenus(recipesDailyList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.stdiet.custom.service.impl;
|
package com.stdiet.custom.service.impl;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import com.stdiet.common.core.domain.AjaxResult;
|
import com.stdiet.common.core.domain.AjaxResult;
|
||||||
import com.stdiet.common.utils.DateUtils;
|
import com.stdiet.common.utils.DateUtils;
|
||||||
@ -149,4 +150,14 @@ public class SysWxFanStatisticsServiceImpl implements ISysWxFanStatisticsService
|
|||||||
public List<SysWxFanStatistics> exportStatisticsList(SysWxFanStatistics sysWxFanStatistics) {
|
public List<SysWxFanStatistics> exportStatisticsList(SysWxFanStatistics sysWxFanStatistics) {
|
||||||
return sysWxFanStatisticsMapper.exportStatisticsList(sysWxFanStatistics);
|
return sysWxFanStatisticsMapper.exportStatisticsList(sysWxFanStatistics);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据时间范围统计每个渠道的进粉数量
|
||||||
|
* @param sysWxFanStatistics
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<Map<String,Object>> getTotalFanNumGroupByChannel(SysWxFanStatistics sysWxFanStatistics){
|
||||||
|
return sysWxFanStatisticsMapper.getTotalFanNumGroupByChannel(sysWxFanStatistics);
|
||||||
|
}
|
||||||
}
|
}
|
@ -138,4 +138,21 @@
|
|||||||
where fwc.del_flag = 0 and fwc.import_fan_record_id = #{id}
|
where fwc.del_flag = 0 and fwc.import_fan_record_id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<!-- 根据时间范围统计各个渠道的总导粉数量 -->
|
||||||
|
<select id="getTotalFanNumGroupByChannel" parameterType="SysWxFanStatistics" resultType="Map" >
|
||||||
|
select s.channelId,acc.dict_label as channelName, s.totalFanNum from
|
||||||
|
(
|
||||||
|
select fr.import_fan_channel as channelId,sum(wa.import_fan_num) as totalFanNum from sys_import_fan_wx_account wa
|
||||||
|
left join sys_import_fan_record fr on fr.id = wa.import_fan_record_id and fr.del_flag = 0
|
||||||
|
where wa.del_flag = 0
|
||||||
|
<if test="fanStartTime != null and fanEndTime != null">
|
||||||
|
and fr.import_fan_date >= #{fanStartTime} and #{fanEndTime} >= fr.import_fan_date
|
||||||
|
</if>
|
||||||
|
group by fr.import_fan_channel
|
||||||
|
)
|
||||||
|
s LEFT JOIN (SELECT dict_label, dict_value FROM sys_dict_data WHERE dict_type = 'cus_account') AS acc ON acc.dict_value = s.channelId
|
||||||
|
order by s.channelId asc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
@ -218,5 +218,16 @@
|
|||||||
) ing USING(id)
|
) ing USING(id)
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<!-- 根据 recipesId查询食谱具体每天详情 -->
|
||||||
|
<select id="getRecipesListByRecipesId" parameterType="Long" resultType="SysRecipesDaily">
|
||||||
|
SELECT id, num_day as numDay FROM sys_customer_daily_menu WHERE recipes_id = #{recipesId} order by num_day asc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<update id="updateRecipesById" parameterType="SysRecipesDaily">
|
||||||
|
update sys_customer_daily_menu
|
||||||
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<if test="numDay != null">num_day = #{numDay},</if>
|
||||||
|
</trim>
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
</mapper>
|
</mapper>
|
@ -287,13 +287,13 @@
|
|||||||
|
|
||||||
<!-- 查询食谱计划中对应食谱存在天数缺失的食谱计划,食谱计划发生变化时,可能会导致sys_customer_daily_menu表中天数缺失,需要查询出来进行补充 -->
|
<!-- 查询食谱计划中对应食谱存在天数缺失的食谱计划,食谱计划发生变化时,可能会导致sys_customer_daily_menu表中天数缺失,需要查询出来进行补充 -->
|
||||||
<select id="getNeedSupplyRecipesByCusId" parameterType="Long" resultType="Map">
|
<select id="getNeedSupplyRecipesByCusId" parameterType="Long" resultType="Map">
|
||||||
select plan.recipes_id as recipesId,plan.end_num_day as enNumDay,s.maxNumDay from sys_recipes_plan as plan left join
|
select plan.cus_id as cusId,plan.recipes_id as recipesId,plan.start_num_day as startNumDay, plan.end_num_day as endNumDay from sys_recipes_plan as plan left join
|
||||||
|
|
||||||
(
|
(
|
||||||
select recipes_id,count(1) as dayNum,max(num_day) as maxNumDay from sys_customer_daily_menu where cus_id = #{cusId} and recipes_id is not null group by recipes_id
|
select recipes_id,count(1) as dayNum,min(num_day) as minNumDay,max(num_day) as maxNumDay from sys_customer_daily_menu where cus_id = #{cusId} and recipes_id is not null group by recipes_id
|
||||||
)
|
)
|
||||||
as s on s.recipes_id = plan.recipes_id
|
as s on s.recipes_id = plan.recipes_id
|
||||||
|
|
||||||
where plan.cus_id = #{cusId} and plan.del_flag = 0 and plan.recipes_id is not null and plan.end_num_day > s.maxNumDay
|
where plan.cus_id = #{cusId} and plan.del_flag = 0 and plan.recipes_id is not null and (s.minNumDay <![CDATA[ <> ]]> plan.start_num_day or s.maxNumDay <![CDATA[ <> ]]> plan.end_num_day)
|
||||||
|
order by plan.start_num_day asc
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
@ -153,4 +153,22 @@
|
|||||||
<if test="wxId != null">and swfs.wx_id = #{wxId}</if>
|
<if test="wxId != null">and swfs.wx_id = #{wxId}</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<!-- 根据时间范围统计每个渠道的总进粉量 -->
|
||||||
|
<select id="getTotalFanNumGroupByChannel" parameterType="SysWxFanStatistics" resultType="Map">
|
||||||
|
select s.channelId,acc.dict_label as channelName,s.totalFanNum from
|
||||||
|
(
|
||||||
|
select
|
||||||
|
swd.account_id as channelId, sum(swfs.fan_num) as totalFanNum
|
||||||
|
from sys_wx_fan_statistics swfs
|
||||||
|
left join sys_wx_distribution swd on swd.wechat_account = swfs.wx_id and swd.del_flag = 0
|
||||||
|
where swfs.del_flag = 0
|
||||||
|
<if test="fanStartTime != null and fanEndTime != null">
|
||||||
|
and swfs.fan_time >= #{fanStartTime} and #{fanEndTime} >= swfs.fan_time
|
||||||
|
</if>
|
||||||
|
group by swd.account_id
|
||||||
|
) s
|
||||||
|
LEFT JOIN (SELECT dict_label, dict_value FROM sys_dict_data WHERE dict_type = 'cus_account') AS acc ON acc.dict_value = s.channelId
|
||||||
|
order by s.channelId asc
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
@ -61,5 +61,15 @@ export function getWxByUserId(userId) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取通过率
|
||||||
|
export function getImportFanPassRate(data) {
|
||||||
|
return request({
|
||||||
|
url: '/custom/fanStatistics/getImportFanPassRate',
|
||||||
|
method: 'get',
|
||||||
|
params: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
74
stdiet-ui/src/components/ImportFanRate/index.vue
Normal file
74
stdiet-ui/src/components/ImportFanRate/index.vue
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
<template>
|
||||||
|
<!-- -->
|
||||||
|
<!-- 导粉通过率 -->
|
||||||
|
<el-dialog :title="title" :visible.sync="open" width="600px" :close-on-click-modal="true" append-to-body @closed="cancel">
|
||||||
|
<div style="height: 500px; overflow: auto">
|
||||||
|
<el-table v-loading="loading" :data="passRateList">
|
||||||
|
<el-table-column label="账号渠道" align="center" prop="channelName" width="160"/>
|
||||||
|
<el-table-column label="导粉量" align="center" prop="totalImportFanNum" width="120"/>
|
||||||
|
<el-table-column label="进粉量" align="center" prop="totalPassFanNum" width="120"/>
|
||||||
|
<el-table-column label="通过率" align="center" prop="passRate" width="120">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
{{scope.row.passRate + '%'}}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import {getImportFanPassRate} from "@/api/custom/fanStatistics";
|
||||||
|
export default {
|
||||||
|
name: "ImportFanRate",
|
||||||
|
components: {
|
||||||
|
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
// 遮罩层
|
||||||
|
loading: true,
|
||||||
|
// 弹出层标题
|
||||||
|
title: "",
|
||||||
|
// 是否显示弹出层
|
||||||
|
open: false,
|
||||||
|
data: null,
|
||||||
|
passRateList: null
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created(){
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
showDialog(data) {
|
||||||
|
if(!data || data == undefined || data == null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.data = data;
|
||||||
|
this.title = data.fanStartTime ? ("「"+data.fanStartTime+" 至 "+data.fanEndTime+"」进粉通过率统计") : "进粉通过率统计";
|
||||||
|
this.getImportFanPassRate();
|
||||||
|
this.open = true;
|
||||||
|
},
|
||||||
|
cancel(){
|
||||||
|
this.open = false;
|
||||||
|
},
|
||||||
|
//获取所有可接粉的微信号
|
||||||
|
getImportFanPassRate() {
|
||||||
|
this.loading = true;
|
||||||
|
getImportFanPassRate(this.data).then((response) => {
|
||||||
|
if(response.code == 200){
|
||||||
|
this.passRateList = response.data;
|
||||||
|
}
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
|
||||||
|
</style>
|
@ -108,6 +108,15 @@
|
|||||||
>导出</el-button
|
>导出</el-button
|
||||||
>
|
>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
size="mini"
|
||||||
|
type="success"
|
||||||
|
@click="showPassRate()"
|
||||||
|
|
||||||
|
>导粉通过率统计</el-button
|
||||||
|
>
|
||||||
|
</el-col>
|
||||||
<right-toolbar
|
<right-toolbar
|
||||||
:showSearch.sync="showSearch"
|
:showSearch.sync="showSearch"
|
||||||
@queryTable="getList"
|
@queryTable="getList"
|
||||||
@ -270,6 +279,9 @@
|
|||||||
<el-button @click="editCancel">取 消</el-button>
|
<el-button @click="editCancel">取 消</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
|
<!-- 通过率 -->
|
||||||
|
<ImportFanRate ref="importFanRateRef"></ImportFanRate>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -282,7 +294,9 @@ import {
|
|||||||
updateFanStatistics,
|
updateFanStatistics,
|
||||||
exportFanStatistics,
|
exportFanStatistics,
|
||||||
getWxByUserId,
|
getWxByUserId,
|
||||||
|
getImportFanPassRate
|
||||||
} from "@/api/custom/fanStatistics";
|
} from "@/api/custom/fanStatistics";
|
||||||
|
import ImportFanRate from "@/components/ImportFanRate";
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import { mapState } from "vuex";
|
import { mapState } from "vuex";
|
||||||
@ -366,6 +380,9 @@ export default {
|
|||||||
preSaleIdOptions: (state) => state.global.preSaleIdOptions.slice(1),
|
preSaleIdOptions: (state) => state.global.preSaleIdOptions.slice(1),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
components:{
|
||||||
|
ImportFanRate
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
/** 查询进粉统计列表 */
|
/** 查询进粉统计列表 */
|
||||||
getList() {
|
getList() {
|
||||||
@ -563,6 +580,11 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
showPassRate(){
|
||||||
|
this.queryParams.fanStartTime = this.fanTimeScope && this.fanTimeScope.length > 0 ? this.fanTimeScope[0] : null;
|
||||||
|
this.queryParams.fanEndTime = this.fanTimeScope && this.fanTimeScope.length > 0 ? this.fanTimeScope[1] : null;
|
||||||
|
this.$refs.importFanRateRef.showDialog(this.queryParams);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
// 监听用户ID变化
|
// 监听用户ID变化
|
||||||
|
Loading…
x
Reference in New Issue
Block a user