From 10f1422bc8f401b06b1e55ee63b23016d74abce8 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期三, 28 二月 2024 11:34:09 +0800
Subject: [PATCH] 优化商户发券逻辑
---
ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/task/ShopTaskServiceImpl.java | 140 ++++++++++++++++++++++++++++++++++++----------
1 files changed, 109 insertions(+), 31 deletions(-)
diff --git a/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/task/ShopTaskServiceImpl.java b/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/task/ShopTaskServiceImpl.java
index f535117..3449772 100644
--- a/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/task/ShopTaskServiceImpl.java
+++ b/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/task/ShopTaskServiceImpl.java
@@ -1,26 +1,34 @@
package com.ruoyi.shop.service.impl.task;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.utils.uuid.IdUtils;
import com.ruoyi.shop.domain.dto.*;
-import com.ruoyi.shop.domain.pojo.task.*;
+import com.ruoyi.shop.domain.pojo.task.ShopTask;
+import com.ruoyi.shop.domain.pojo.task.ShopTaskRecord;
+import com.ruoyi.shop.domain.pojo.task.TaskFile;
import com.ruoyi.shop.domain.vo.StaffShopTaskPageVo;
import com.ruoyi.shop.mapper.task.ShopTaskMapper;
+import com.ruoyi.shop.service.shop.ShopService;
import com.ruoyi.shop.service.task.ShopTaskRecordService;
import com.ruoyi.shop.service.task.ShopTaskService;
import com.ruoyi.shop.service.task.TaskFileService;
-import com.ruoyi.system.api.domain.poji.sys.SysUser;
+import com.ruoyi.system.api.domain.poji.shop.Shop;
+import com.ruoyi.system.api.domain.poji.sys.SysStaff;
import com.ruoyi.system.api.domain.vo.MgtBulletinBoardVo;
+import com.ruoyi.system.api.service.RemoteConfigService;
import com.ruoyi.system.api.service.RemoteUserService;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
+import java.util.function.Function;
+import java.util.stream.Collectors;
/**
* <p>
@@ -44,6 +52,15 @@
@Resource
private RemoteUserService remoteUserService;
+
+ @Resource
+ private RemoteConfigService remoteConfigService;
+
+ @Autowired
+ private ShopService shopService;
+
+
+
/**
* 平台跟进商户
@@ -71,7 +88,7 @@
shopTaskRecord.setTaskId(taskId);
shopTaskRecord.setUserId(mgtFollowShopTaskDto.getUserId());
shopTaskRecord.setFollowType(2);
- shopTaskRecord.setCustomFollowType(mgtFollowShopTaskDto.getFollowType());
+ shopTaskRecord.setCustomeFollowType(mgtFollowShopTaskDto.getFollowType());
shopTaskRecord.setFollowContent(mgtFollowShopTaskDto.getFollowContent());
shopTaskRecord.setCreateTime(nowTime);
shopTaskRecordService.saveOrUpdate(shopTaskRecord);
@@ -120,12 +137,18 @@
* @date 2023/6/18 17:08
*/
@Override
- public MgtBulletinBoardVo boardTaskTotal(){
+ public MgtBulletinBoardVo boardTaskTotal(List<Long> userIds){
MgtBulletinBoardVo mgtBulletinBoardVo = new MgtBulletinBoardVo();
LambdaQueryWrapper<ShopTask> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ShopTask::getDelFlag,0);
queryWrapper.eq(ShopTask::getTaskStatus,1);
queryWrapper.eq(ShopTask::getTaskDate,DateUtils.getDate());
+ if(null != userIds && userIds.size() > 0){
+ List<Shop> list = shopService.list(new QueryWrapper<Shop>().eq("del_flag", 0)
+ .in("belong_user_id", userIds));
+ List<Long> collect = list.stream().map(Shop::getShopId).collect(Collectors.toList());
+ queryWrapper.in(ShopTask::getShopId, collect);
+ }
Integer followShopToday = this.count(queryWrapper);
mgtBulletinBoardVo.setFollowShopToday(followShopToday);
return mgtBulletinBoardVo;
@@ -155,13 +178,24 @@
List<StaffShopTaskPageVo> shopTaskPageVoList = shopTaskMapper.pageStaffShopTask(page, staffShopTaskPageDto);
if(shopTaskPageVoList!=null&&shopTaskPageVoList.size()>0){
Long userId;
- SysUser sysUser;
+ SysStaff sysStaff;
+ HashSet<Long> userIdSet = new HashSet<>();
+ for(StaffShopTaskPageVo staffShopTaskPageVo : shopTaskPageVoList){
+ userIdSet.add(staffShopTaskPageVo.getUserId());
+ }
+ List<Long> useIdList = new ArrayList<>(userIdSet);
+ List<SysStaff> sysStaffList = remoteConfigService.listSysStaffByIds(useIdList).getData();
+ Map<Long,SysStaff> sysStaffMap = sysStaffList.stream()
+ .collect(Collectors.toMap(SysStaff::getUserId, Function.identity()));
for(StaffShopTaskPageVo staffShopTaskPageVo : shopTaskPageVoList){
//获取任务用户信息
userId = staffShopTaskPageVo.getUserId();
- sysUser = remoteUserService.getSysUser(userId).getData();
- staffShopTaskPageVo.setUserName(sysUser.getNickName());
- staffShopTaskPageVo.setUserPicture(sysUser.getAvatar());
+ if(userId!=null){
+ sysStaff = sysStaffMap.get(userId);
+ staffShopTaskPageVo.setUserName(sysStaff.getStaffName());
+ staffShopTaskPageVo.setUserPicture(sysStaff.getStaffAvatar());
+ staffShopTaskPageVo.setUserPosition(sysStaff.getStaffPost());
+ }
}
}
return shopTaskPageVoList;
@@ -186,6 +220,7 @@
shopTask.setEmergencyState(staffAddTaskDto.getEmergencyState());
shopTask.setCreateTime(new Date());
shopTask.setTaskDate(staffAddTaskDto.getTaskDate());
+ //任务状态
int i = staffAddTaskDto.getTaskDate().compareTo(nowTimeStr);
if(i>0){
shopTask.setTaskStatus(0);
@@ -229,6 +264,7 @@
shopTaskRecord.setCallPhone(staffFollowShopTaskDto.getCallPhone());
shopTaskRecord.setFollowContent(followPhoneDto.getFollowContent());
shopTaskRecord.setCallTime(followPhoneDto.getCallTime());
+ shopTaskRecord.setCreateTime(new Date());
// 保存或更新会员任务记录
shopTaskRecordService.saveOrUpdate(shopTaskRecord);
}
@@ -241,53 +277,57 @@
shopTaskRecord.setUserId(staffFollowShopTaskDto.getUserId());
shopTaskRecord.setFollowType(staffFollowShopTaskDto.getFollowType());
shopTaskRecord.setFollowContent(staffFollowShopTaskDto.getFollowContent());
+ shopTaskRecord.setCustomeFollowType(staffFollowShopTaskDto.getCustomeFollowType());
shopTaskRecord.setCreateTime(new Date());
// 保存或更新会员任务记录
shopTaskRecordService.saveOrUpdate(shopTaskRecord);
// 获取图片、视频和音频
- String picture = staffFollowShopTaskDto.getPicture();
- String video = staffFollowShopTaskDto.getVideo();
- String audio = staffFollowShopTaskDto.getAudio();
- String[] strArr;
+ List<FileDto> picture = staffFollowShopTaskDto.getPicture();
+ List<FileDto> video = staffFollowShopTaskDto.getVideo();
+ List<FileDto> audio = staffFollowShopTaskDto.getAudio();
TaskFile taskFile;
+ List<TaskFile> taskFileList = new ArrayList<>();
// 判断图片是否为空,并处理
- if (StringUtils.isNotBlank(picture)) {
- strArr = picture.split(",");
- for (String str : strArr) {
+ if (picture!=null&&!picture.isEmpty()) {
+ for (FileDto fileDto : picture) {
taskFile = new TaskFile();
taskFile.setDelFlag(0);
taskFile.setFollowId(shopTaskRecord.getId());
taskFile.setFollowFrom(4);
- taskFile.setFileUrl(str);
+ taskFile.setFileName(fileDto.getFileName());
+ taskFile.setFileUrl(fileDto.getFileUrl());
taskFile.setFileType(1);
- taskFileService.saveOrUpdate(taskFile);
+ taskFileList.add(taskFile);
}
}
// 判断视频是否为空,并处理
- if (StringUtils.isNotBlank(video)) {
- strArr = picture.split(",");
- for (String str : strArr) {
+ if (video!=null&&!video.isEmpty()) {
+ for (FileDto fileDto : video) {
taskFile = new TaskFile();
taskFile.setDelFlag(0);
taskFile.setFollowId(shopTaskRecord.getId());
taskFile.setFollowFrom(4);
- taskFile.setFileUrl(str);
+ taskFile.setFileName(fileDto.getFileName());
+ taskFile.setFileUrl(fileDto.getFileUrl());
taskFile.setFileType(2);
- taskFileService.saveOrUpdate(taskFile);
+ taskFileList.add(taskFile);
}
}
// 判断音频是否为空,并处理
- if (StringUtils.isNotBlank(audio)) {
- strArr = picture.split(",");
- for (String str : strArr) {
+ if (audio!=null&&!audio.isEmpty()) {
+ for (FileDto fileDto : audio) {
taskFile = new TaskFile();
taskFile.setDelFlag(0);
taskFile.setFollowId(shopTaskRecord.getId());
taskFile.setFollowFrom(4);
- taskFile.setFileUrl(str);
+ taskFile.setFileName(fileDto.getFileName());
+ taskFile.setFileUrl(fileDto.getFileUrl());
taskFile.setFileType(3);
- taskFileService.saveOrUpdate(taskFile);
+ taskFileList.add(taskFile);
}
+ }
+ if(taskFileList!=null&&!taskFileList.isEmpty()){
+ taskFileService.saveBatch(taskFileList);
}
}
// 判断下一个任务日期是否为空,并处理
@@ -298,10 +338,48 @@
shopTask.setDelFlag(0);
shopTask.setShopId(oldShopTask.getShopId());
shopTask.setTaskDate(staffFollowShopTaskDto.getNextTaskDate());
- shopTask.setFollowContent(staffFollowShopTaskDto.getNextTaskContent());
- shopTask.setTaskStatus(2);
+ shopTask.setTaskTitle(staffFollowShopTaskDto.getNextTaskContent());
+ String nowTimeStr = DateUtils.getDate();
+ int i = staffFollowShopTaskDto.getNextTaskDate().compareTo(nowTimeStr);
+ if(i>0){
+ shopTask.setTaskStatus(0);
+ }else if(i==0){
+ shopTask.setTaskStatus(1);
+ }else{
+ shopTask.setTaskStatus(3);
+ }
+ shopTask.setEmergencyState(staffFollowShopTaskDto.getEmergencyState());
shopTask.setCreateTime(new Date());
this.saveOrUpdate(shopTask);
}
}
+
+ /**
+ * @description 检查任务时间状态
+ * @author jqs
+ * @date 2023/7/19 18:01
+ * @param
+ * @return void
+ */
+ @Override
+ public void checkTaskDateStatus(){
+ //平台-商户任务状态
+ shopTaskMapper.checkShopTaskStatus();
+ //商户-代理商任务状态
+ shopTaskMapper.checkAgencyTaskStatus();
+ //商户-会员任务状态
+ shopTaskMapper.checkMemberTaskStatus();
+ }
+
+ /**
+ * @description 获取商户最近任务
+ * @author jqs
+ * @date 2023/8/22 17:27
+ * @param shopId
+ * @return ShopTask
+ */
+ @Override
+ public ShopTask getLastTask(Long shopId){
+ return shopTaskMapper.getLastTask(shopId);
+ }
}
--
Gitblit v1.7.1