页面统计 昨日营销数任务 今日营销数方法

This commit is contained in:
wangshuai 2024-07-10 14:09:25 +08:00
parent 2b8cd1bf3e
commit 73bd8df9da
10 changed files with 128 additions and 37 deletions

View File

@ -65,9 +65,9 @@ public class BusAgentInfoController extends BaseController
{
startPage();
LoginUser user = SecurityUtils.getLoginUser();
if(!"admin".equals(user.getUsername())){
busAgentInfo.setSuperiorAgentCode(user.getUserId());
}
// if(!"admin".equals(user.getUsername())){
// busAgentInfo.setSuperiorAgentCode(user.getUserId());
// }
List<BusAgentInfo> list = busAgentInfoService.selectBusAgentInfoList(busAgentInfo);
List<BusAgentInfo> listData = list.stream().map(bean -> {
BusStoreInfo busStoreInfo = new BusStoreInfo();

View File

@ -60,20 +60,24 @@ public class BusSaleInfoController extends BaseController
.map(info -> {
BusStoreInfo busStoreInfo = new BusStoreInfo();
busStoreInfo.setSaleBindId(info.getId());
int count = 0;
int lastFiveNum = 0;
int lastOrderNum = 0;
int lastReturnVisitNum = 0;
List<BusStoreInfo> ll = iBusStoreInfoService.selectBusStoreInfoList(busStoreInfo);
for (BusStoreInfo b:ll) {
BusStoreDayInfo busStoreDayInfo = new BusStoreDayInfo();
busStoreDayInfo.setStoreId(b.getId());
List<BusStoreDayInfo> dayList = iBusStoreDayInfoService.selectBusStoreDayInfoList(busStoreDayInfo);
for (BusStoreDayInfo day: dayList){
count = day.getLastFiveStarReviewsNum()+count;
if(dayList.size() == 1){
lastFiveNum = dayList.get(0).getLastFiveStarReviewsNum() + lastFiveNum;
lastOrderNum = dayList.get(0).getLastOrderNum() + lastOrderNum;
lastReturnVisitNum = dayList.get(0).getLastReturnVisitNum() + lastReturnVisitNum;
}
}
info.setStoreNum(ll.size());
info.setLastOrderNum(0);
info.setFiveStarReviewsNum(count);
info.setReturnVisitNum(0);
info.setLastOrderNum(lastOrderNum);
info.setFiveStarReviewsNum(lastFiveNum);
info.setReturnVisitNum(lastReturnVisitNum);
return info;
})
.collect(Collectors.toList());

View File

@ -92,9 +92,9 @@ public class BusStoreInfoController extends BaseController {
BusStoreInfo busStoreInfo = new BusStoreInfo();
BeanUtils.copyProperties(reqBusStoreInfo, busStoreInfo);
LoginUser user = SecurityUtils.getLoginUser();
if (!"admin".equals(user.getUsername())) {
busStoreInfo.setBindUser(user.getUsername());
}
// if (!"admin".equals(user.getUsername())) {
// busStoreInfo.setBindUser(user.getUsername());
// }
List<BusStoreInfo> list = busStoreInfoService.selectBusStoreInfoList(busStoreInfo);
List<RespBusStoreInfo> tableList = list.stream()
.map(busStoreInfo1 -> {
@ -102,17 +102,19 @@ public class BusStoreInfoController extends BaseController {
BusStoreDayInfo busStoreDayInfo = new BusStoreDayInfo();
busStoreDayInfo.setStoreId(info.getId());
List<BusStoreDayInfo> ll = busStoreDayInfoService.selectBusStoreDayInfoList(busStoreDayInfo);
int b = ll.get(0).getLastOrderNum();
info.setLastOrderNum(ll.get(0).getLastOrderNum());
int a = ll.get(0).getLastOrderNum();
int b = ll.get(0).getLastReturnVisitNum();
info.setLastOrderNum(a);
info.setLastReturnVisitNum(b);
info.setLastPositiveReviewsNum(ll.get(0).getLastPositiveReviewsNum());
info.setLastFiveStarReviewsNum(ll.get(0).getLastFiveStarReviewsNum());
String date = LocalDateTime.now().minusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
List<BusReturnVisitInfo> llll = iBusReturnVisitInfoService.selectBusReturnVisitInfoListByDate(busStoreInfo1.getStoreCode(),date);
info.setLastReturnVisitNum(llll.size());
// String date = LocalDateTime.now().minusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
// List<BusReturnVisitInfo> llll = iBusReturnVisitInfoService.selectBusReturnVisitInfoListByDate(busStoreInfo1.getStoreCode(),date);
// info.setLastReturnVisitNum(llll.size());
info.setScore(ll.get(0).getScore());
if (b != 0 && llll.size() != 0) {
if (a != 0 && b != 0) {
java.text.DecimalFormat df = new java.text.DecimalFormat("0.00");
String formattedResult = df.format(((double) llll.size() / b)*100);
String formattedResult = df.format(((double) b / a)*100);
info.setLastReturnVisitRate(formattedResult);
} else {
info.setLastReturnVisitRate("0");

View File

@ -1,9 +1,6 @@
package com.ruoyi.quartz.task;
import com.ruoyi.business.domain.BusAgentInfo;
import com.ruoyi.business.domain.BusFifteenInfo;
import com.ruoyi.business.domain.BusOrderInfo;
import com.ruoyi.business.domain.BusStoreInfo;
import com.ruoyi.business.domain.*;
import com.ruoyi.business.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -25,6 +22,8 @@ public class RyTask {
@Autowired
private IBusStoreInfoService storeInfoService;
@Autowired
private IBusStoreDayInfoService iBusStoreDayInfoService;
@Autowired
private IBusAgentInfoService agentInfoService;
@Autowired
private IAiService aiService;
@ -32,6 +31,10 @@ public class RyTask {
private IMeituanService iMeituanService;
@Autowired
private IBusFifteenInfoService fifteenInfoService;
@Autowired
private IBusBanOperateInfoService iBusBanOperateInfoService;
@Autowired
private IBusReturnVisitInfoService iBusReturnVisitInfoService;
// public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i)
// {
@ -63,23 +66,34 @@ public class RyTask {
*
* @throws Exception
*/
public void sendToAi() throws Exception {
public void sendToAiOld() throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
LocalDateTime t30 = LocalDateTime.now().minusMinutes(30);
LocalDateTime t10 = LocalDateTime.now().minusMinutes(10);
String t1 = t30.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"));
String t2 = t10.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"));
List<BusOrderInfo> list = orderInfoService.selectBusOrderInfoListToAi(t1, t2);
// 配置规则
List<BusOrderInfo> list = orderInfoService.selectBusOrderInfoListToAi("",t1, t2);
list.forEach(System.out::println);
for (BusOrderInfo busOrderInfo : list) {
BusBanOperateInfo busBanOperateInfo = new BusBanOperateInfo();
busBanOperateInfo.setBindOrderCode(busOrderInfo.getId()+"");
List<BusBanOperateInfo> list1 = iBusBanOperateInfoService.selectBusBanOperateInfoList(busBanOperateInfo);
if(list1.size() > 0){//加入免运营订单-黑名单的 不营销跳出
continue;
}
BusStoreInfo storeInfo = new BusStoreInfo();
storeInfo.setStoreCode(busOrderInfo.getStoreCode());
List<BusStoreInfo> tempStore = storeInfoService.selectBusStoreInfoList(storeInfo);
if (tempStore.size() > 0) {
BusStoreInfo busStoreInfo = tempStore.get(0);
if("2".equals(busStoreInfo.getReturnVisitStatus())){
// 未开启营销的跳出
continue;
}
BusAgentInfo agentInfo = new BusAgentInfo();
agentInfo.setAgentAccount(tempStore.get(0).getBindUser());
agentInfo.setAgentAccount(busStoreInfo.getBindUser());
List<BusAgentInfo> agentInfoL = agentInfoService.selectBusAgentInfoList(agentInfo);
if (agentInfoL.size() > 0) {
if (agentInfoL.get(0).getIntegral() <= 0) {
@ -95,11 +109,61 @@ public class RyTask {
fifteenInfo.setCustomId(tempInfo.getCustomId());
List<BusFifteenInfo> listInfo = fifteenInfoService.selectBusFifteenInfoList(fifteenInfo);
if (listInfo.size() == 0) {
// aiService.sendAiTask(busOrderInfo);
}
}
}
/**
* 发送AI 1分钟
*
* @throws Exception
*/
public void sendToAi() throws Exception {
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
LocalDateTime now = LocalDateTime.now();
LocalDateTime t30 = LocalDateTime.now().minusMinutes(30);
LocalDateTime t10 = LocalDateTime.now().minusMinutes(10);
String t1 = t30.format(dateTimeFormatter);
String t2 = t10.format(dateTimeFormatter);
BusStoreInfo storeInfo = new BusStoreInfo();
List<BusStoreInfo> storeInfoList = storeInfoService.selectBusStoreInfoList(storeInfo);
for (BusStoreInfo busStoreInfo : storeInfoList) {
if("2".equals(busStoreInfo.getReturnVisitStatus())){
continue;// 未开启营销的跳出
}
BusAgentInfo agentInfo = new BusAgentInfo();
agentInfo.setAgentAccount(busStoreInfo.getBindUser());
List<BusAgentInfo> agentInfoL = agentInfoService.selectBusAgentInfoList(agentInfo);
if (agentInfoL.size() > 0) {
if (agentInfoL.get(0).getIntegral() <= 0) {
continue;//代理账分不足跳出
}
} else continue;
// 配置规则
List<BusOrderInfo> list = orderInfoService.selectBusOrderInfoListToAi(busStoreInfo.getStoreCode(),t1, t2);
list.forEach(System.out::println);
for (BusOrderInfo busOrderInfo : list) {
BusBanOperateInfo busBanOperateInfo = new BusBanOperateInfo();
busBanOperateInfo.setBindOrderCode(busOrderInfo.getId()+"");
busBanOperateInfo.setBanStatus("1");
List<BusBanOperateInfo> list1 = iBusBanOperateInfoService.selectBusBanOperateInfoList(busBanOperateInfo);
if(list1.size() > 0){//加入免运营订单-黑名单的 不营销跳出
continue;
}
BusFifteenInfo fifteenInfo = new BusFifteenInfo();
fifteenInfo.setCustomId(busOrderInfo.getCustomId());
List<BusFifteenInfo> listInfo = fifteenInfoService.selectBusFifteenInfoList(fifteenInfo);
if (listInfo.size() == 0) {
aiService.sendAiTask(busOrderInfo);
}
}
}
}
/**
* 获取AI结果 5分钟
*/
@ -107,4 +171,25 @@ public class RyTask {
aiService.queryAiTask();
}
/**
* 统计昨日营销数 每天8点执行一次
*/
public void getReturnInfo() {
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDateTime date = LocalDateTime.now().minusDays(1);
BusStoreInfo storeInfo = new BusStoreInfo();
List<BusStoreInfo> storeInfoList = storeInfoService.selectBusStoreInfoList(storeInfo);
for (BusStoreInfo busStoreInfo : storeInfoList) {
List<BusReturnVisitInfo> list = iBusReturnVisitInfoService.selectBusReturnVisitInfoListByDate(busStoreInfo.getStoreCode(),date.format(dateTimeFormatter));
BusStoreDayInfo busStoreDayInfo = new BusStoreDayInfo();
busStoreDayInfo.setStoreId(busStoreInfo.getId());
List<BusStoreDayInfo> list1 = iBusStoreDayInfoService.selectBusStoreDayInfoList(busStoreDayInfo);
if(list1.size()==1){
busStoreDayInfo = list1.get(0);
busStoreDayInfo.setLastReturnVisitNum(list.size());
iBusStoreDayInfoService.updateBusStoreDayInfo(busStoreDayInfo);
}
}
}
}

View File

@ -62,5 +62,5 @@ public interface BusOrderInfoMapper
int batchInsertOrder(@Param("list") List<BusOrderInfo> list);
int batchupdateBusOrderInfo(@Param("lcs") List<BusOrderInfo> lcs);
List<BusOrderInfo> selectBusOrderInfoListToAi(@Param("t1") String t1,@Param("t2") String t2);
List<BusOrderInfo> selectBusOrderInfoListToAi(@Param("storeCode") String storeCode, @Param("t1") String t1,@Param("t2") String t2);
}

View File

@ -59,5 +59,5 @@ public interface IBusOrderInfoService
*/
public int deleteBusOrderInfoById(Long id);
List<BusOrderInfo> selectBusOrderInfoListToAi(String t1, String t2);
List<BusOrderInfo> selectBusOrderInfoListToAi(String storeCode, String t1, String t2);
}

View File

@ -92,7 +92,7 @@ public class BusOrderInfoServiceImpl implements IBusOrderInfoService
}
@Override
public List<BusOrderInfo> selectBusOrderInfoListToAi(String t1, String t2) {
return busOrderInfoMapper.selectBusOrderInfoListToAi(t1,t2);
public List<BusOrderInfo> selectBusOrderInfoListToAi(String storeCode, String t1, String t2) {
return busOrderInfoMapper.selectBusOrderInfoListToAi(storeCode, t1, t2);
}
}

View File

@ -541,7 +541,7 @@ public class MeituanServiceImpl implements IMeituanService {
* @return
*/
@Transactional(rollbackFor = Exception.class)
private Boolean getScoreOne(BusStoreInfo store) {
Boolean getScoreOne(BusStoreInfo store) {
CloseableHttpClient httpClient = proxyHttpClient();
String wmPoiId = valueFromCookie("wmPoiId", store.getStoreCookie());
String url = "https://waimaieapp.meituan.com/gw/customer/comment/scores";
@ -594,7 +594,7 @@ public class MeituanServiceImpl implements IMeituanService {
* @return
*/
@Transactional(rollbackFor = Exception.class)
private Boolean getCommentsOne(BusStoreInfo store) {
Boolean getCommentsOne(BusStoreInfo store) {
LocalDateTime now = LocalDateTime.now();
String url = "https://waimaieapp.meituan.com/gw/customer/comment/statistics/score/summary/single/distribution";
@ -633,10 +633,9 @@ public class MeituanServiceImpl implements IMeituanService {
busStoreDayInfo.setStoreId(store.getId());
List<BusStoreDayInfo> list1 = busStoreDayInfoService.selectBusStoreDayInfoList(busStoreDayInfo);
if (list1.size() == 1) {
BusStoreDayInfo busStoreDayInfo1 = new BusStoreDayInfo();
BusStoreDayInfo busStoreDayInfo1 = list1.get(0);
int fiveNum = array.getJSONObject(array.size()-1).getInteger("fiveNum");
int fourNum = array.getJSONObject(array.size()-1).getInteger("fourNum");
busStoreDayInfo1.setId(list1.get(0).getId());
busStoreDayInfo1.setLastFiveStarReviewsNum(fiveNum);
busStoreDayInfo1.setLastPositiveReviewsNum(fiveNum + fourNum);
busStoreDayInfoService.updateBusStoreDayInfo(busStoreDayInfo1);

View File

@ -49,6 +49,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select a.* from bus_order_info a
LEFT JOIN bus_return_visit_info b on b.phone_number=a.privcy_phone
where b.return_visit_time is null
<if test="storeCode != null and storeCode != ''"> and store_code = #{storeCode}</if>
<if test="t1 != null and t1 != ''"> and a.complete_time &gt; #{t1}</if>
<if test="t2 != null and t2 != ''"> and a.complete_time &lt; #{t2}</if>
</select>