添加对比任务数据

main
bynt 1 month ago
parent d305f8a059
commit 399892c140

@ -129,6 +129,11 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-loadbalancer</artifactId>
</dependency>
<dependency>
<groupId>com.vdurmont</groupId>
<artifactId>emoji-java</artifactId>
<version>4.0.0</version>
</dependency>
</dependencies>
<build>
<plugins>

@ -175,6 +175,12 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-loadbalancer</artifactId>
</dependency>
<dependency>
<groupId>com.vdurmont</groupId>
<artifactId>emoji-java</artifactId>
<version>4.0.0</version>
</dependency>
</dependencies>
<build>

@ -89,18 +89,20 @@ public class AddFileFriendDataListener extends AnalysisEventListener<FileAddFrie
for (FileAddFriendVO friendVO : cachedDataList) {
String pollingWechat = balance.chooseOne(saveAddFriendDTO.getTrumpetWechatList());
friend = new AddFriend();
if (StringUtils.isNotBlank(friendVO.getFlagArrays())){
List<String> toList = Splitter.on
(StrPool.COMMA).trimResults().splitToList(friendVO.getFlagArrays());
friend.setLabelIds(toList);
if (StringUtils.isNotBlank(friendVO.getTargetSource())) {
if (StringUtils.isNotBlank(friendVO.getFlagArrays())) {
List<String> toList = Splitter.on
(StrPool.COMMA).trimResults().splitToList(friendVO.getFlagArrays());
friend.setLabelIds(toList);
}
friend.setGreet(friendVO.getGreet());
friend.setTrumpetWechat(pollingWechat);
friend.setUserId(saveAddFriendDTO.getUserId());
friend.setTaskId(saveAddFriendDTO.getTaskId());
friend.setTargetWechat(friendVO.getTargetSource());
friend.setAddStatus(DefaultNumberConstants.ZERO_NUMBER);
list.add(friend);
}
friend.setGreet(friendVO.getGreet());
friend.setTrumpetWechat(pollingWechat);
friend.setUserId(saveAddFriendDTO.getUserId());
friend.setTaskId(saveAddFriendDTO.getTaskId());
friend.setTargetWechat(friendVO.getTargetSource());
friend.setAddStatus(DefaultNumberConstants.ZERO_NUMBER);
list.add(friend);
}
addFriendService.saveBatch(list);
log.info("存储数据库成功!");

@ -0,0 +1,104 @@
package com.baiye.listener;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.excel.util.ListUtils;
import com.baiye.constant.DefaultNumberConstants;
import com.baiye.modules.scrm.dto.SaveComparisonDTO;
import com.baiye.modules.scrm.entity.ComparisonRecord;
import com.baiye.modules.scrm.service.ComparisonRecordService;
import com.baiye.modules.scrm.vo.ComparisonVO;
import com.baiye.util.AESUtils;
import com.google.common.collect.Sets;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
* @author Enzo
* @date : 2024/6/2
*/
@Slf4j
public class ComparisonAdditionalDataListener extends AnalysisEventListener<ComparisonVO> {
/**
* 5使100list 便
*/
private static final int BATCH_COUNT = 500;
/**
*
*/
private List<ComparisonVO> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
private final ComparisonRecordService comparisonRecordService;
private final SaveComparisonDTO saveComparisonDTO;
public ComparisonAdditionalDataListener(ComparisonRecordService comparisonRecordService, SaveComparisonDTO saveComparisonDTO) {
this.comparisonRecordService = comparisonRecordService;
this.saveComparisonDTO = saveComparisonDTO;
}
/**
*
*
* @param data one row value. Is is same as {@link AnalysisContext#readRowHolder()}
* @param context
*/
@Override
public void invoke(ComparisonVO data, AnalysisContext context) {
cachedDataList.add(data);
// 达到BATCH_COUNT了需要去存储一次数据库防止数据几万条数据在内存容易OOM
if (cachedDataList.size() >= BATCH_COUNT) {
updateDate();
// 存储完成清理 list
cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
}
}
/**
*
*
* @param context
*/
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
// 这里也要保存数据,确保最后遗留的数据也存储到数据库
if (CollUtil.isNotEmpty(cachedDataList)) {
updateDate();
}
cachedDataList.clear();
log.info("所有数据解析完成!");
}
/**
*
*/
private void updateDate() {
Set<ComparisonRecord> set = Sets.newHashSet();
Map<String, String> resultMap =
cachedDataList.stream().filter(c -> StringUtils.isNotBlank(c.getRedBookId()) && StringUtils.isNotBlank
(c.getPhone()) && c.getPhone().length() == DefaultNumberConstants.ELEVEN_NUMBER)
.collect(Collectors.toMap(ComparisonVO::getRedBookId, ComparisonVO::getPhone));
List<ComparisonRecord> recordList = comparisonRecordService.queryByTaskAndRedBookId(saveComparisonDTO.getTaskId(), resultMap.keySet());
if (CollUtil.isNotEmpty(recordList)) {
for (ComparisonRecord record : recordList) {
String comparisonResult = resultMap.get(record.getRedBookId());
if (StringUtils.isNotBlank(comparisonResult)) {
record.setConversionTime(DateUtil.date());
record.setComparisonResult(AESUtils.encrypt(comparisonResult, "==marketing-scrm="));
set.add(record);
}
}
comparisonRecordService.updateBatchById(set);
}
log.info("数据解析成功!");
}
}

@ -0,0 +1,107 @@
package com.baiye.listener;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.text.StrPool;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.excel.util.ListUtils;
import com.baiye.constant.DefaultNumberConstants;
import com.baiye.modules.scrm.dto.SaveAddFriendDTO;
import com.baiye.modules.scrm.dto.SaveComparisonDTO;
import com.baiye.modules.scrm.entity.AddFriend;
import com.baiye.modules.scrm.entity.ComparisonRecord;
import com.baiye.modules.scrm.service.AddFriendService;
import com.baiye.modules.scrm.service.ComparisonRecordService;
import com.baiye.modules.scrm.vo.ComparisonVO;
import com.baiye.modules.scrm.vo.FileAddFriendVO;
import com.baiye.polling.QueueBalance;
import com.google.common.base.Splitter;
import com.google.common.collect.Sets;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import java.util.List;
import java.util.Set;
/**
* @author Enzo
* @date : 2024/6/2
*/
@Slf4j
public class ComparisonRecordDataListener extends AnalysisEventListener<ComparisonVO> {
/**
* 5使100list 便
*/
private static final int BATCH_COUNT = 500;
/**
*
*/
private List<ComparisonVO> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
private final ComparisonRecordService comparisonRecordService;
private final SaveComparisonDTO saveComparisonDTO;
public ComparisonRecordDataListener(ComparisonRecordService comparisonRecordService, SaveComparisonDTO saveComparisonDTO) {
this.comparisonRecordService = comparisonRecordService;
this.saveComparisonDTO = saveComparisonDTO;
}
/**
*
*
* @param data one row value. Is is same as {@link AnalysisContext#readRowHolder()}
* @param context
*/
@Override
public void invoke(ComparisonVO data, AnalysisContext context) {
cachedDataList.add(data);
// 达到BATCH_COUNT了需要去存储一次数据库防止数据几万条数据在内存容易OOM
if (cachedDataList.size() >= BATCH_COUNT) {
saveData();
// 存储完成清理 list
cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
}
}
/**
*
*
* @param context
*/
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
// 这里也要保存数据,确保最后遗留的数据也存储到数据库
if (CollUtil.isNotEmpty(cachedDataList)) {
saveData();
}
cachedDataList.clear();
log.info("所有数据解析完成!");
}
/**
*
*/
private void saveData() {
log.info("{}条数据,开始存储数据库!", cachedDataList.size());
Set<ComparisonRecord> set = Sets.newHashSet();
// 随机添加微信
for (ComparisonVO vo : cachedDataList) {
ComparisonRecord record = new ComparisonRecord();
if (StringUtils.isNotBlank(vo.getRedBookId()) && StringUtils.isNotBlank(vo.getRedBookNo())){
record.setDateStr(vo.getDateStr());
record.setRedBookNo(vo.getRedBookNo());
record.setRedBookId(vo.getRedBookId());
record.setPhotograph(vo.getPhotograph());
record.setInstitution(vo.getInstitution());
record.setTaskId(saveComparisonDTO.getTaskId());
record.setUserId(saveComparisonDTO.getUserId());
set.add(record);
}
}
comparisonRecordService.saveBatch(set);
log.info("存储数据库成功!");
}
}

@ -70,7 +70,6 @@ public class CustomerInfoController {
@Operation(summary = "获取主账号")
@GetMapping("listRobotByCustomerId")
public List<WeChatAccountVO> listRobotBYCustomerId(Long customerId) {
return customerUserService.listRobotByCustomerId(customerId);
}
@ -82,6 +81,13 @@ public class CustomerInfoController {
}
@Operation(summary = "获取次级账号")
@GetMapping(value = "acquisition/secondary")
public R<List<WeChatAccountVO>> acquisitionSecondary(Long customerId) {
return R.ok(customerUserService.acquisitionSecondary(customerId));
}
@DeleteMapping("/{id}")
@Operation(summary = "删除客服")
public R<String> deleteByUserId(@PathVariable("id") Long customerId) {

@ -55,10 +55,10 @@ public class CustomerWxLabelController {
}
@DeleteMapping("/del")
@DeleteMapping("/del/{id}")
@Operation(summary = "删除标签")
public R<String> deleteByUserId(@RequestBody Set<Long> ids) {
return Boolean.TRUE.equals(customerRobotWxLabelService.del(ids)) ? R.ok() : R.failed(BaseResultCode.UPDATE_DATABASE_ERROR, "删除失败");
public R<String> deleteByUserId(@PathVariable("id") Long id) {
return Boolean.TRUE.equals(customerRobotWxLabelService.del(id)) ? R.ok() : R.failed(BaseResultCode.UPDATE_DATABASE_ERROR, "删除失败");
}

@ -81,7 +81,7 @@ public interface CustomerJoinRobotMapper extends ExtendMapper<CustomerJoinRobot>
default Integer updateByCustomerIdAndRobotId(Long customerId, List<Long> list, Integer number) {
LambdaUpdateWrapper<CustomerJoinRobot> wrapper = WrappersX.lambdaUpdate(CustomerJoinRobot.class);
wrapper.set(CustomerJoinRobot::getDelFlag, number);
wrapper.eq(CustomerJoinRobot::getCustomerId, customerId).in(CustomerJoinRobot::getRobotId, list);
wrapper.eq(CustomerJoinRobot::getCustomerId, customerId).in(CustomerJoinRobot::getId, list);
return update(null, wrapper);
}
}

@ -53,4 +53,10 @@ public interface CustomerRobotWxLabelMapper extends ExtendMapper<CustomerRobotWx
wrapper.eq(CustomerRobotWxLabel::getWechatId, wxId);
return this.selectCount(wrapper);
}
default Long selectCountByLabelNameAndUserId(String labelName, Long userId) {
LambdaUpdateWrapper<CustomerRobotWxLabel> wrapper = WrappersX.lambdaUpdate(CustomerRobotWxLabel.class);
wrapper.eq(CustomerRobotWxLabel::getLabelName, labelName).eq(CustomerRobotWxLabel::getUserId, userId);
return this.selectCount(wrapper);
}
}

@ -51,6 +51,7 @@ public interface CustomerUserInfoMapper extends ExtendMapper<CustomerUserInfo> {
if (StringUtils.isNotBlank(qo.getStartTime()) && StringUtils.isNotBlank(qo.getEndTime())) {
wrapperX.between(CustomerUserInfo::getCreateTime, qo.getStartTime(), qo.getEndTime());
}
wrapperX.eqIfPresent(CustomerUserInfo::getUserId, qo.getUserId());
wrapperX.likeIfPresent(CustomerUserInfo::getAccount, qo.getAccount()).orderByDesc(CustomerUserInfo::getId);
this.selectPage(page, wrapperX);
IPage<CustomerUserInfoVO> voPage = page.convert(CustomerUserConverter.INSTANCE::entityToVo);

@ -45,5 +45,5 @@ public interface CustomerRobotWxLabelService extends ExtendService<CustomerRobot
Boolean del(Set<Long> ids);
Boolean del(Long id);
}

@ -78,4 +78,11 @@ public interface CustomerUserService extends ExtendService<CustomerUserInfo> {
* @return
*/
List<WeChatAccountVO> listRobotByCustomerId(Long customerId);
/**
*
* @param customerId
* @return
*/
List<WeChatAccountVO> acquisitionSecondary(Long customerId);
}

@ -39,7 +39,7 @@ public class CustomerJoinRobotServiceImpl extends
List<CustomerJoinRobot> listByCustomerId = baseMapper.selectListByCustomerId(customerId, DefaultNumberConstants.ONE_NUMBER);
// 同步群成员
Map<Long, CustomerJoinRobot> robotMap =
listByCustomerId.stream().collect(Collectors.toMap(CustomerJoinRobot::getRobotId, robot -> robot));
listByCustomerId.stream().distinct().collect(Collectors.toMap(CustomerJoinRobot::getRobotId, robot -> robot));
for (WeChatAccount chatAccount : values) {
CustomerJoinRobot joinRobot = new CustomerJoinRobot();
CustomerJoinRobot customerJoinRobot = robotMap.get(chatAccount.getId());

@ -1,10 +1,11 @@
package com.baiye.modules.customer.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baiye.constant.DefaultNumberConstants;
import com.baiye.domain.PageParam;
import com.baiye.domain.PageResult;
import com.baiye.exception.BadRequestException;
import com.baiye.extend.mybatis.plus.service.impl.ExtendServiceImpl;
import com.baiye.modules.customer.entity.CustomerRobotWxLabel;
import com.baiye.modules.customer.mapper.CustomerRobotWxLabelMapper;
@ -16,16 +17,12 @@ import com.baiye.modules.scrm.service.WeChatService;
import com.baiye.modules.scrm.vo.CustomerWxLabelVO;
import com.baiye.modules.scrm.vo.WeChatAccountVO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
* @author Enzo
* @date : 2024/7/8
@ -51,6 +48,10 @@ public class CustomerRobotWxLabelServiceImpl extends
@Override
public Boolean add(CustomerWxLabelDTO labelDTO, Long userId) {
Long count = baseMapper.selectCountByLabelNameAndUserId(labelDTO.getLabelName(), userId);
if (count > DefaultNumberConstants.ZERO_NUMBER) {
throw new BadRequestException("该标签已存在 请勿重复填写");
}
Integer weChatLabel = wechatService.addWeChatLabel(labelDTO.getWechatId(), labelDTO.getLabelName());
if (weChatLabel > DefaultNumberConstants.ZERO_NUMBER) {
CustomerRobotWxLabel wxLabel = new CustomerRobotWxLabel();
@ -63,16 +64,11 @@ public class CustomerRobotWxLabelServiceImpl extends
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean del(Set<Long> ids) {
List<CustomerRobotWxLabel> customerRobotWxLabels = baseMapper.selectBatchIds(ids);
if (CollUtil.isNotEmpty(customerRobotWxLabels)){
Map<String, List<CustomerRobotWxLabel>> listMap =
customerRobotWxLabels.stream().collect(Collectors.groupingBy(CustomerRobotWxLabel::getWechatId));
for (Map.Entry<String, List<CustomerRobotWxLabel>> entry : listMap.entrySet()) {
List<Integer> list = entry.getValue().stream().map(CustomerRobotWxLabel::getLabelId).collect(Collectors.toList());
wechatService.deleteWeChatLabel(entry.getKey(), list);
}
return removeBatchByIds(ids);
public Boolean del(Long id) {
CustomerRobotWxLabel customerRobotWxLabel = baseMapper.selectById(id);
if (ObjectUtil.isNotNull(customerRobotWxLabel)) {
wechatService.deleteWeChatLabel(customerRobotWxLabel.getWechatId(), Lists.newArrayList(customerRobotWxLabel.getLabelId()));
return removeById(id);
}
return Boolean.FALSE;
}

@ -12,12 +12,12 @@ import com.baiye.extend.mybatis.plus.service.impl.ExtendServiceImpl;
import com.baiye.modules.customer.entity.CustomerJoinRobot;
import com.baiye.modules.customer.entity.CustomerUserInfo;
import com.baiye.modules.customer.feign.CustomerVisibleFeign;
import com.baiye.modules.customer.mapper.CustomerUserInfoMapper;
import com.baiye.modules.customer.service.CustomerJoinRobotService;
import com.baiye.modules.customer.service.CustomerUserService;
import com.baiye.modules.scrm.dto.CustomerAddRobotDTO;
import com.baiye.modules.scrm.dto.CustomerUserInfoDTO;
import com.baiye.modules.scrm.entity.WeChatAccount;
import com.baiye.modules.customer.mapper.CustomerUserInfoMapper;
import com.baiye.modules.scrm.qo.CustomerUserQo;
import com.baiye.modules.scrm.service.WechatAccountService;
import com.baiye.modules.scrm.vo.CustomerUserInfoVO;
@ -35,7 +35,6 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
@ -43,7 +42,6 @@ import java.util.stream.Collectors;
* @author Enzo
* @date : 2024/7/5
*/
@Slf4j
@Service
@RequiredArgsConstructor
@ -66,7 +64,7 @@ public class CustomerUserServiceImpl extends ExtendServiceImpl<CustomerUserInfoM
userInfoDTO.setUserId(currentUserId);
String dtoAccount = userInfoDTO.getAccount();
List<Long> robotIds = userInfoDTO.getRobotIds();
CustomerUserInfo userInfo = customerUserInfoMapper.queryByAccount(userInfoDTO.getAccount());
CustomerUserInfo userInfo = customerUserInfoMapper.queryByAccount(userInfoDTO.getAccount().trim());
if (ObjectUtil.isNotNull(userInfo) && ObjectUtil.isNotNull(userInfo.getId()) && !userInfo.getId().equals(userInfoDTO.getId())) {
throw new BadRequestException("该账号已被使用!");
}
@ -79,7 +77,7 @@ public class CustomerUserServiceImpl extends ExtendServiceImpl<CustomerUserInfoM
CustomerUserInfo customerUserInfo = baseMapper.selectById(userInfoDTO.getId());
if (ObjectUtil.isNotNull(customerUserInfo) && ObjectUtil.isNotNull(customerUserInfo.getId())) {
// 是主客服的设备
Set<Long> customerSet = weChatAccounts.stream().map(WeChatAccount::getCustomerId).filter(Objects::nonNull).collect(Collectors.toSet());
Set<Long> customerSet = weChatAccounts.stream().filter(k -> userInfo.getId().equals(k.getCustomerId())).map(WeChatAccount::getId).collect(Collectors.toSet());
// 去除主客服设备
saveAccountId = Sets.newHashSet(Sets.difference(Sets.newHashSet(robotIds), customerSet));
Set<Long> customerJoinRobots =
@ -131,6 +129,8 @@ public class CustomerUserServiceImpl extends ExtendServiceImpl<CustomerUserInfoM
List<CustomerJoinRobot> joinRobots = customerJoinRobotService.queryCustomerByCustomerId(result.getId());
List<Long> robotCustomerList = joinRobots.stream().map(CustomerJoinRobot::getRobotId).collect(Collectors.toList());
robotCustomerList.addAll(byCustomerId.stream().map(WeChatAccountVO::getId).collect(Collectors.toList()));
result.setRobotNum(Integer.valueOf(wechatAccountService.getCountByCustomerId(result.getId()).toString()));
result.setRobotSubNum(Integer.valueOf(customerJoinRobotService.getCountByCustomerId(result.getId()).toString()));
result.setRobotIds(robotCustomerList);
});
return pageResult;
@ -151,16 +151,17 @@ public class CustomerUserServiceImpl extends ExtendServiceImpl<CustomerUserInfoM
if (Boolean.FALSE.equals(booleanListEntry.getKey())) {
// 修改主动
wechatAccountService.cancelCustomerIdByRobotIds(addRobot.getCustomerId(), list);
customerJoinRobotService.updateByCustomerIdAndRobotId(addRobot.getCustomerId(), list, DefaultNumberConstants.ONE_NUMBER);
List<WeChatAccount> weChatAccounts = wechatAccountService.listByIds(list);
customerJoinRobotService.saveCustomerJoinRobot(addRobot.getCustomerId(), userInfo.getAccount(), weChatAccounts);
}
if (Boolean.TRUE.equals(booleanListEntry.getKey())) {
// 取消所有次级
customerJoinRobotService.cancelCustomerIdByIdsIn(userInfo.getId(), list);
wechatAccountService.updateByCustomerIdAndIds(userInfo.getId(), list);
customerJoinRobotService.cancelCustomerIdByIdsIn(userInfo.getId(), list);
}
}
}
userInfo.setRobotNum(Integer.valueOf(wechatAccountService.getCountByCustomerId(addRobot.getCustomerId()).toString()));
userInfo.setRobotNum(Integer.valueOf(wechatAccountService.getCountByCustomerId(userInfo.getId()).toString()));
userInfo.setRobotSubNum(Integer.valueOf(customerJoinRobotService.getCountByCustomerId(userInfo.getId()).toString()));
return this.updateById(userInfo);
}
@ -212,6 +213,11 @@ public class CustomerUserServiceImpl extends ExtendServiceImpl<CustomerUserInfoM
return wechatAccountService.findByCustomerId(customerId);
}
@Override
public List<WeChatAccountVO> acquisitionSecondary(Long customerId) {
return customerJoinRobotService.queryWeAccountByCustomer(customerId);
}
@Override
public Map<String, Object> listMasterDetailByCustomerId(Long customerId) {

@ -0,0 +1,65 @@
package com.baiye.modules.scrm.controller;
import com.baiye.constant.DefaultNumberConstants;
import com.baiye.domain.PageParam;
import com.baiye.domain.PageResult;
import com.baiye.modules.scrm.entity.CircleFriendTask;
import com.baiye.modules.scrm.qo.CircleFriendQO;
import com.baiye.modules.scrm.qo.ComparisonQO;
import com.baiye.modules.scrm.service.CircleFriendTaskService;
import com.baiye.modules.scrm.vo.CircleFriendTaskVO;
import com.baiye.modules.scrm.vo.ComparisonTaskVO;
import com.baiye.result.BaseResultCode;
import com.baiye.result.R;
import com.baiye.security.util.SecurityUtils;
import com.baiye.validation.group.CreateGroup;
import com.baiye.validation.group.UpdateGroup;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
* @author Enzo
* @date : 2024/8/15
*/
@Tag(name = "朋友圈")
@Slf4j
@RestController
@RequestMapping(value = "/circle/friend")
@AllArgsConstructor
public class CircleFriendTaskController {
private final CircleFriendTaskService circleFriendTaskService;
@GetMapping("/page")
@Operation(summary = "分页查询记录")
public R<PageResult<CircleFriendTaskVO>> robotGroupPage(@Validated PageParam pageParam, CircleFriendQO qo) {
qo.setUserId(SecurityUtils.getCurrentUserId());
return R.ok(circleFriendTaskService.queryPage(pageParam, qo));
}
@PostMapping("/add")
public R<Object> add(@Validated({CreateGroup.class}) @RequestBody CircleFriendTask entity) {
circleFriendTaskService.create(entity);
return R.ok();
}
@PostMapping("/update")
public R<Object> update(@Validated({UpdateGroup.class}) @RequestBody CircleFriendTask entity) {
circleFriendTaskService.update(entity);
return R.ok();
}
@DeleteMapping("/{id}")
@Operation(summary = "ID删除任务")
public R<Void> deleteByUserId(@PathVariable("id") Long taskId) {
return Boolean.TRUE.equals(circleFriendTaskService.del(taskId)) ? R.ok() : R.failed(BaseResultCode.UPDATE_DATABASE_ERROR, "删除失败");
}
}

@ -0,0 +1,72 @@
package com.baiye.modules.scrm.controller;
import cn.hutool.json.JSONUtil;
import com.baiye.constant.DefaultNumberConstants;
import com.baiye.domain.PageParam;
import com.baiye.domain.PageResult;
import com.baiye.modules.scrm.dto.CreateAddFriendTaskDTO;
import com.baiye.modules.scrm.qo.ComparisonQO;
import com.baiye.modules.scrm.qo.RobotGroupQo;
import com.baiye.modules.scrm.service.ComparisonTaskService;
import com.baiye.modules.scrm.vo.ComparisonTaskVO;
import com.baiye.modules.scrm.vo.RobotGroupVO;
import com.baiye.result.R;
import com.baiye.security.util.SecurityUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
/**
* @author Enzo
* @date : 2024/8/16
*/
@Tag(name = "对比任务")
@Slf4j
@RestController
@RequestMapping(value = "/comparison/task")
@AllArgsConstructor
public class ComparisonTaskController {
private final ComparisonTaskService comparisonTaskService;
@GetMapping("/page")
@Operation(summary = "分页查询记录")
public R<PageResult<ComparisonTaskVO>> robotGroupPage(@Validated PageParam pageParam, ComparisonQO qo) {
qo.setUserId(SecurityUtils.getWhichUserId() ==
DefaultNumberConstants.ONE_NUMBER ? SecurityUtils.getCurrentUserId() : SecurityUtils.getWhichUserId());
return R.ok(comparisonTaskService.queryPage(pageParam, qo));
}
@PostMapping("/create/task")
@Operation(summary = "创建任务")
public R<String> createTestTask(MultipartFile file, String taskName,String remark) {
return Boolean.TRUE.equals(comparisonTaskService.createTask(file, taskName, remark)) ? R.ok() : R.failed("创建任务失败");
}
@PostMapping("/additional")
@Operation(summary = "追加任务")
public R<String> createTestTask(MultipartFile file, Long taskId,Boolean isComplete) {
return Boolean.TRUE.equals(comparisonTaskService.additionalTask(file, taskId, isComplete)) ? R.ok() : R.failed("追加任务失败");
}
@GetMapping("/export")
@Operation(summary = "导出数据")
public void export(HttpServletResponse response, Long taskId) {
comparisonTaskService.exportByTaskId(response, taskId);
}
}

@ -2,6 +2,7 @@ package com.baiye.modules.scrm.controller;
import com.baiye.domain.PageParam;
import com.baiye.domain.PageResult;
import com.baiye.modules.scrm.dto.PacketDTO;
import com.baiye.modules.scrm.qo.AccountQo;
import com.baiye.modules.scrm.service.LoginEquipmentService;
import com.baiye.modules.scrm.vo.WeChatAccountVO;
@ -11,9 +12,9 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @author Enzo

@ -0,0 +1,73 @@
package com.baiye.modules.scrm.controller;
import com.baiye.domain.PageParam;
import com.baiye.domain.PageResult;
import com.baiye.modules.scrm.entity.RobotGroup;
import com.baiye.modules.scrm.qo.RobotGroupQo;
import com.baiye.modules.scrm.service.RobotGroupService;
import com.baiye.modules.scrm.vo.RobotGroupVO;
import com.baiye.result.BaseResultCode;
import com.baiye.result.R;
import com.baiye.security.util.SecurityUtils;
import com.baiye.validation.group.CreateGroup;
import com.baiye.validation.group.UpdateGroup;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @author Enzo
* @date : 2024/8/14
*/
@RestController
@Tag(name = "分组管理")
@RequestMapping("/robot/group")
@RequiredArgsConstructor
public class RobotGroupController {
private final RobotGroupService robotGroupService;
@GetMapping("/page")
@Operation(summary = "分页查询记录")
public R<PageResult<RobotGroupVO>> robotGroupPage(@Validated PageParam pageParam, RobotGroupQo qo) {
qo.setUserId(SecurityUtils.getCurrentUserId());
return R.ok(robotGroupService.queryPage(pageParam, qo));
}
@PostMapping("/add")
public R<Object> add(@Validated({CreateGroup.class}) @RequestBody RobotGroup entity) {
robotGroupService.create(entity);
return R.ok();
}
@PostMapping("/update")
public R<Object> update(@Validated({ UpdateGroup.class }) @RequestBody RobotGroup entity) {
robotGroupService.update(entity);
return R.ok();
}
@DeleteMapping("/{id}")
@Operation(summary = "ID删除任务")
public R<Void> deleteByUserId(@PathVariable("id") Long groupId) {
return Boolean.TRUE.equals(robotGroupService.del(groupId)) ? R.ok() : R.failed(BaseResultCode.UPDATE_DATABASE_ERROR, "删除失败");
}
@GetMapping("/list")
@Operation(summary = "查询所有数据")
public R<List<RobotGroupVO>> robotGroupList() {
return R.ok(robotGroupService.queryByUserId(SecurityUtils.getCurrentUserId()));
}
}

@ -55,6 +55,6 @@ public class StaticResourceController {
@DeleteMapping("/{id}")
@Operation(summary = "ID删除任务")
public R<Void> deleteByUserId(@PathVariable("id") Long resourceId) {
return staticResourceService.del(resourceId) ? R.ok() : R.failed(BaseResultCode.UPDATE_DATABASE_ERROR, "删除失败");
return Boolean.TRUE.equals(staticResourceService.del(resourceId)) ? R.ok() : R.failed(BaseResultCode.UPDATE_DATABASE_ERROR, "删除失败");
}
}

@ -0,0 +1,31 @@
package com.baiye.modules.scrm.controller;
import com.baiye.modules.scrm.dto.PacketDTO;
import com.baiye.modules.scrm.service.WechatAccountService;
import com.baiye.result.R;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author Enzo
* @date : 2024/8/16
*/
@Slf4j
@RestController
@RequestMapping("/wechat/account")
@RequiredArgsConstructor
public class WeChatAccountController {
private final WechatAccountService wechatAccountService;
@PostMapping("/update/packet")
@Operation(summary = "修改分组")
public R<Boolean> updatePacketById(@RequestBody PacketDTO dto) {
return R.ok(wechatAccountService.updatePacketById(dto));
}
}

@ -3,6 +3,7 @@ package com.baiye.modules.scrm.controller;
import com.baiye.domain.PageParam;
import com.baiye.domain.PageResult;
import com.baiye.modules.scrm.dto.CreateCodeDTO;
import com.baiye.modules.scrm.dto.PacketDTO;
import com.baiye.modules.scrm.dto.PushCodeDTO;
import com.baiye.modules.scrm.dto.WeChatStatisticsDTO;
import com.baiye.modules.scrm.qo.AccountQo;
@ -68,8 +69,8 @@ public class WeChatController {
@GetMapping("/create/equipment")
@Operation(summary = "创建设备")
public R<String> createEquipment(Integer num) {
return Boolean.TRUE.equals(weChatService.createEquipment(num, SecurityUtils.getCurrentUserId())) ? R.ok() : R.failed("创建设备失败");
public R<String> createEquipment(Integer num, Long packetId) {
return Boolean.TRUE.equals(weChatService.createEquipment(num, packetId, SecurityUtils.getCurrentUserId())) ? R.ok() : R.failed("创建设备失败");
}
@ -128,4 +129,6 @@ public class WeChatController {
}
}

@ -0,0 +1,26 @@
package com.baiye.modules.scrm.converter;
import com.baiye.modules.scrm.entity.CircleFriendTask;
import com.baiye.modules.scrm.entity.ComparisonTask;
import com.baiye.modules.scrm.vo.CircleFriendTaskVO;
import com.baiye.modules.scrm.vo.ComparisonTaskVO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
* @author Enzo
* @date : 2024/3/28
*/
@Mapper
public interface CircleFriendTaskConverter {
CircleFriendTaskConverter INSTANCE = Mappers.getMapper(CircleFriendTaskConverter.class);
/**
* vo
*
* @param circleFriendTask
* @return
*/
CircleFriendTaskVO entityToVo(CircleFriendTask circleFriendTask);
}

@ -0,0 +1,27 @@
package com.baiye.modules.scrm.converter;
import com.baiye.modules.scrm.entity.ComparisonTask;
import com.baiye.modules.scrm.entity.PayOrder;
import com.baiye.modules.scrm.vo.ComparisonTaskVO;
import com.baiye.modules.scrm.vo.ComparisonVO;
import com.baiye.modules.scrm.vo.PayOrderVO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
* @author Enzo
* @date : 2024/3/28
*/
@Mapper
public interface ComparisonConverter {
ComparisonConverter INSTANCE = Mappers.getMapper(ComparisonConverter.class);
/**
* vo
*
* @param comparisonTask
* @return
*/
ComparisonTaskVO entityToVo(ComparisonTask comparisonTask);
}

@ -0,0 +1,24 @@
package com.baiye.modules.scrm.converter;
import com.baiye.modules.scrm.entity.RobotGroup;
import com.baiye.modules.scrm.vo.RobotGroupVO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
* @author Enzo
* @date : 2024/3/28
*/
@Mapper
public interface RobotGroupConverter {
RobotGroupConverter INSTANCE = Mappers.getMapper(RobotGroupConverter.class);
/**
* vo
*
* @param robotGroup
* @return
*/
RobotGroupVO entityToVo(RobotGroup robotGroup);
}

@ -19,11 +19,11 @@ public class AddFriendDTO {
private String greet;
@Schema(title = "微信小号")
private String trumpetWechat;
private List<String> trumpetWechat;
@Schema(title = "标签ID")
private List<String> labelIds;
@Schema(title = "小号微信")
@Schema(title = "对方微信")
private String targetWechat;
}

@ -0,0 +1,15 @@
package com.baiye.modules.scrm.dto;
import lombok.Data;
/**
* @author Enzo
* @date : 2024/8/5
*/
@Data
public class AfterPassingDTO {
private String passGreetMessage;
private Integer type;
}

@ -1,19 +1,11 @@
package com.baiye.modules.scrm.dto;
import cn.hutool.core.date.DatePattern;
import com.baiye.extend.mybatis.plus.converter.JsonStringArrayTypeHandler;
import com.baiye.validation.group.UpdateGroup;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.multipart.MultipartFile;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;
@ -78,8 +70,7 @@ public class CreateAddFriendTaskDTO {
@Schema(title = "添加对象")
private List<AddFriendDTO> addFriendDTOList;
@Schema(title = "通过之后好友语句")
private List<String> passGreetMessage;
private List<AfterPassingDTO> afterPassing;
}

@ -53,6 +53,8 @@ public class CustomerAddRobotDTO implements Serializable {
private Long id;
private Long robotId;
private Boolean isPrimary;
}

@ -0,0 +1,16 @@
package com.baiye.modules.scrm.dto;
import lombok.Data;
import java.util.List;
/**
* @author Enzo
* @date : 2024/8/15
*/
@Data
public class PacketDTO {
private List<Long> idList;
private Long packetId;
}

@ -0,0 +1,26 @@
package com.baiye.modules.scrm.dto;
import lombok.Builder;
import lombok.Data;
import java.util.List;
/**
* @author Enzo
* @date : 2024/6/13
*/
@Data
@Builder
public class SaveComparisonDTO {
/**
* ID
*/
private Long userId;
/**
* id
*/
private Long taskId;
}

@ -2,14 +2,14 @@ package com.baiye.modules.scrm.entity;
import com.baiye.extend.mybatis.plus.alias.TableAlias;
import com.baiye.validation.group.UpdateGroup;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.*;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
/**
* @author Enzo
@ -26,7 +26,7 @@ public class ActiveAddFriedRecord implements Serializable {
@NotNull(message = "ID不能为空", groups = { UpdateGroup.class })
private Long id;
@Schema(title = "上传ID")
@Schema(title = "微信id")
private Long addFriendId;
@Schema(title = "任务id")
@ -66,8 +66,88 @@ public class ActiveAddFriedRecord implements Serializable {
@Schema(title = "用户名")
private String userName;
@Schema(title = "添加状态")
private Integer addStatus;
/**
* ID
*/
@TableField("friend_id")
private String friendId;
/**
*
*/
@TableField("friend_no")
private String friendNo;
/**
* id
*/
@TableField("source_user_name")
private String sourceUserName;
/**
*
*/
@TableField("source_nick_name")
private String sourceNickName;
/**
*
*/
@TableField("memo")
private String memo;
/**
* 1-2-
*/
@TableField("add_friend_type")
private Integer addFriendType;
/**
*
*/
@TableField("ticket")
private String ticket;
/**
*
*/
@TableField("scene")
private Integer scene;
/**
*
*/
@TableField("encrypt_username")
private String encryptUsername;
@TableField(fill = FieldFill.INSERT)
@Schema(title = "创建时间")
private LocalDateTime createTime;
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(title = "修改时间")
private LocalDateTime updateTime;
/**
*
*/
@TableField("tg_time")
private Date tgTime;
@TableField("create_by")
private String createBy;
}

@ -50,7 +50,7 @@ public class AddFriend {
@Schema(title = "对方微信")
private String targetWechat;
@Schema(title = "添加状态")
@Schema(title = "添加状态 0未添加 1 已添加 3添加失败 4 好友通过")
private Integer addStatus;

@ -0,0 +1,39 @@
package com.baiye.modules.scrm.entity;
import com.baiye.entity.BaseEntity;
import com.baiye.extend.mybatis.plus.alias.TableAlias;
import com.baiye.validation.group.UpdateGroup;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import javax.validation.constraints.NotNull;
/**
* @author Enzo
* @date : 2024/8/5
*/
@Getter
@Setter
@ToString
@TableName(value = "tb_add_friend_pass_greet_message")
@Schema(title = "添加之后语句")
@TableAlias("am")
public class AddFriendPassGreetMessage extends BaseEntity {
@TableId(type = IdType.AUTO)
@Schema(title = "ID")
@NotNull(message = "ID不能为空", groups = { UpdateGroup.class })
private Long id;
private Long taskId;
private Integer type;
@Schema(title = "通过之后消息")
private String passGreetMessage;
}

@ -0,0 +1,85 @@
package com.baiye.modules.scrm.entity;
import com.baiye.entity.LogicDeletedBaseEntity;
import com.baiye.extend.mybatis.plus.alias.TableAlias;
import com.baiye.extend.mybatis.plus.converter.JsonStringArrayTypeHandler;
import com.baiye.validation.group.UpdateGroup;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;
/**
* @author Enzo
* @date : 2024/8/13
*/
@Getter
@Setter
@ToString
@TableName(value = "tb_circle_friend_task")
@Schema(title = "朋友圈任务")
@TableAlias("ct")
public class CircleFriendTask extends LogicDeletedBaseEntity {
@TableId(type = IdType.AUTO)
@Schema(title = "ID")
@NotNull(message = "ID不能为空", groups = { UpdateGroup.class })
private Long id;
@Schema(title = "任务名称")
private String taskName;
@Schema(title = "标题")
private String title;
@Schema(title = "发送状态")
private Integer sendStatus;
@Schema(title = "用户ID")
private Long userId;
@Schema(title = "内容")
private String content;
@Schema(title = "类型")
private Integer type;
@Schema(title = "延后时间")
private Integer deferredTime;
@Schema(title = "是否现在执行")
private Boolean isNow;
@Schema(title = "执行时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date executionTime;
@Schema(title = "资源地址")
private String sourcePath;
@Schema(title = "延后评论")
@TableField(value = "deferred_comment", typeHandler = JsonStringArrayTypeHandler.class)
private List<String> deferredComment;
@Schema(title = "图片地址")
@TableField(value = "picture_list", typeHandler = JsonStringArrayTypeHandler.class)
private List<String> pictureList;
@TableField(value = "execute_wechat_list", typeHandler = JsonStringArrayTypeHandler.class)
@Schema(title = "执行微信号")
private List<String> executeWechatList;
}

@ -0,0 +1,84 @@
package com.baiye.modules.scrm.entity;
import com.baiye.entity.BaseEntity;
import com.baiye.extend.mybatis.plus.alias.TableAlias;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.Objects;
/**
* @author Enzo
* @date : 2024/8/19
*
*/
@Getter
@Setter
@ToString
@TableName(value = "tb_comparison_record", autoResultMap = true)
@Schema(title = "对比记录")
@TableAlias("cr")
public class ComparisonRecord extends BaseEntity {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.INPUT)
@Schema(title = "线索ID")
@NotNull(message = "id")
private Long id;
@Schema(title = "任务ID")
private Long taskId;
@Schema(title = "用户ID")
private Long userId;
@Schema(description = "日期")
private String dateStr;
@Schema(description = "小红书ID")
private String redBookId;
@Schema(description = "小红书号")
private String redBookNo;
@Schema(description = "项目")
private String photograph;
@Schema( description = "机构")
private String institution;
@Schema( description = "建模时间")
private Date conversionTime;
@Schema( description = "对比结果")
private String comparisonResult;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ComparisonRecord that = (ComparisonRecord) o;
return Objects.equals(redBookId, that.redBookId) && Objects.equals(redBookNo, that.redBookNo);
}
@Override
public int hashCode() {
return Objects.hash(redBookId, redBookNo);
}
}

@ -0,0 +1,51 @@
package com.baiye.modules.scrm.entity;
import com.baiye.entity.BaseEntity;
import com.baiye.extend.mybatis.plus.alias.TableAlias;
import com.baiye.validation.group.UpdateGroup;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import javax.validation.constraints.NotNull;
/**
* @author Enzo
* @date : 2024/8/16
*/
@Getter
@Setter
@ToString
@TableName(value = "tb_comparison_task", autoResultMap = true)
@Schema(title = "对比")
@TableAlias("ct")
public class ComparisonTask extends BaseEntity {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.INPUT)
@Schema(title = "线索ID")
@NotNull(message = "分发ID不能为空", groups = {UpdateGroup.class})
private Long id;
@Schema(title = "任务名称")
private String taskName;
@Schema(title = "用户ID")
private Long userId;
@Schema(title = "父类ID")
private Long parentId;
@Schema(title = "线索备注")
private String remark;
@Schema(title = "是否完成")
private Boolean isComplete;
}

@ -0,0 +1,43 @@
package com.baiye.modules.scrm.entity;
import com.baiye.entity.BaseEntity;
import com.baiye.extend.mybatis.plus.alias.TableAlias;
import com.baiye.validation.group.UpdateGroup;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import javax.validation.constraints.NotNull;
/**
* @author Enzo
* @date : 2024/8/16
*/
@Getter
@Setter
@ToString
@TableName(value = "tb_down_comparison_log", autoResultMap = true)
@Schema(title = "下载日志")
@TableAlias("cl")
public class ComparisonTaskLog extends BaseEntity {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.INPUT)
@Schema(title = "线索ID")
@NotNull(message = "分发ID不能为空", groups = {UpdateGroup.class})
private Long id;
@Schema(title = "任务名称")
private Long taskId;
@Schema(title = "任务名称")
private Long userId;
}

@ -47,4 +47,8 @@ public class LoginEquipment extends BaseEntity {
@Schema(name = "expiration_time")
private Date expirationTime;
@Schema(name = "packet_id")
private Long packetId;
}

@ -0,0 +1,45 @@
package com.baiye.modules.scrm.entity;
import com.baiye.entity.LogicDeletedBaseEntity;
import com.baiye.extend.mybatis.plus.alias.TableAlias;
import com.baiye.validation.group.UpdateGroup;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* @author Enzo
* @date : 2024/8/14
*/
@Getter
@Setter
@TableAlias("rg")
@TableName(value = "tb_robot_group")
public class RobotGroup extends LogicDeletedBaseEntity {
@TableId(type = IdType.AUTO)
@Schema(title = "分组ID")
@NotNull(message = "分组ID", groups = { UpdateGroup.class })
private Long id;
@Schema(title = "user_id")
private Long userId;
@TableField("group_type")
private Integer groupType;
@Schema(title = "name")
@NotBlank
private String name;
@TableField
private String remark;
}

@ -75,4 +75,7 @@ public class WeChatAccount extends LogicDeletedBaseEntity {
@Schema(title = "客服ID")
private Long customerId;
@Schema(title = "分组ID")
private Long packetId;
}

@ -1,8 +1,10 @@
package com.baiye.modules.scrm.mapper;
import cn.hutool.core.date.DateTime;
import com.baiye.extend.mybatis.plus.mapper.ExtendMapper;
import com.baiye.extend.mybatis.plus.toolkit.WrappersX;
import com.baiye.modules.scrm.entity.ActiveAddFriedRecord;
import com.baiye.modules.scrm.entity.AddFriend;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@ -21,11 +23,23 @@ public interface ActiveAddFriendRecordMapper extends ExtendMapper<ActiveAddFried
* @param nickName
* @param wxId
* @param number
* @param type
* @return
*/
default List<ActiveAddFriedRecord> selectByFromUsernameAndToUsername(String nickName, String wxId, Integer number) {
default List<ActiveAddFriedRecord> selectByFromUsernameAndToUsername(String nickName, String wxId, Integer number, Integer type) {
return selectList(WrappersX.lambdaQueryX(ActiveAddFriedRecord.class).eq
(ActiveAddFriedRecord::getRobotWxId, wxId).eq(ActiveAddFriedRecord::getNickName, nickName).eq
(ActiveAddFriedRecord::getAddStatus, number).orderByDesc(ActiveAddFriedRecord::getId));
(ActiveAddFriedRecord::getRobotWxId, wxId).like(ActiveAddFriedRecord::getNickName, nickName).eq
(ActiveAddFriedRecord::getAddStatus, number).eq(ActiveAddFriedRecord::getType, type).orderByDesc(ActiveAddFriedRecord::getId));
}
/**
* @param taskId
* @param startTime
* @param endTime
* @return
*/
default Long selectCountByTaskIdAndDate(String taskId, DateTime startTime, DateTime endTime) {
return selectCount(WrappersX.lambdaQueryX(ActiveAddFriedRecord.class).eq
(ActiveAddFriedRecord::getTaskId, taskId).gt(ActiveAddFriedRecord::getCreateTime, startTime).lt(ActiveAddFriedRecord::getCreateTime, endTime));
}
}

@ -65,12 +65,14 @@ public interface AddFriendMapper extends ExtendMapper<AddFriend> {
*
*
* @param taskId
* @param number
* @param startTime
* @param endTime
* @return
*/
default Long selectCountByTime(String taskId, DateTime startTime, DateTime endTime) {
return selectCount(WrappersX.lambdaQueryX(AddFriend.class).eq(AddFriend::getTaskId, taskId).gt(AddFriend::getCreateTime, startTime).lt(AddFriend::getCreateTime, endTime));
default Long selectCountByTime(String taskId, Integer number, DateTime startTime, DateTime endTime) {
return selectCount(WrappersX.lambdaQueryX(AddFriend.class).eq(AddFriend::getTaskId, taskId).gt(AddFriend::getAddStatus,number).
gt(AddFriend::getCreateTime, startTime).lt(AddFriend::getCreateTime, endTime));
}

@ -0,0 +1,28 @@
package com.baiye.modules.scrm.mapper;
import com.baiye.extend.mybatis.plus.mapper.ExtendMapper;
import com.baiye.extend.mybatis.plus.toolkit.WrappersX;
import com.baiye.modules.scrm.entity.AddFriendPassGreetMessage;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @author Enzo
* @date : 2024/8/5
*/
@Mapper
public interface AddFriendPassGreetMessageMapper extends ExtendMapper<AddFriendPassGreetMessage> {
default List<AddFriendPassGreetMessage> selectListByTaskId(Long taskId){
return this.selectList(WrappersX.lambdaQueryX(AddFriendPassGreetMessage.class).eq
(AddFriendPassGreetMessage::getTaskId, taskId).orderByAsc(AddFriendPassGreetMessage::getId));
}
default Boolean deleteByTaskId(Long id){
LambdaUpdateWrapper<AddFriendPassGreetMessage> wrapper = WrappersX.lambdaUpdate(AddFriendPassGreetMessage.class);
wrapper.eq(AddFriendPassGreetMessage::getTaskId, id);
return SqlHelper.retBool(this.delete(wrapper));
}
}

@ -0,0 +1,45 @@
package com.baiye.modules.scrm.mapper;
import com.baiye.domain.PageParam;
import com.baiye.domain.PageResult;
import com.baiye.extend.mybatis.plus.conditions.query.LambdaQueryWrapperX;
import com.baiye.extend.mybatis.plus.mapper.ExtendMapper;
import com.baiye.extend.mybatis.plus.toolkit.WrappersX;
import com.baiye.modules.scrm.converter.CircleFriendTaskConverter;
import com.baiye.modules.scrm.converter.ComparisonConverter;
import com.baiye.modules.scrm.entity.CircleFriendTask;
import com.baiye.modules.scrm.entity.ComparisonTask;
import com.baiye.modules.scrm.qo.CircleFriendQO;
import com.baiye.modules.scrm.qo.ComparisonQO;
import com.baiye.modules.scrm.vo.CircleFriendTaskVO;
import com.baiye.modules.scrm.vo.ComparisonTaskVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import org.apache.ibatis.annotations.Mapper;
/**
* @author Enzo
* @date : 2024/8/13
*/
@Mapper
public interface CircleFriendTaskMapper extends ExtendMapper<CircleFriendTask> {
/**
*
*
* @param pageParam
* @param qo
* @return
*/
default PageResult<CircleFriendTaskVO> queryPage(PageParam pageParam, CircleFriendQO qo){
IPage<CircleFriendTask> page = this.prodPage(pageParam);
LambdaQueryWrapperX<CircleFriendTask> wrapperX = WrappersX.lambdaQueryX(CircleFriendTask.class);
if (StringUtils.isNotBlank(qo.getStartTime()) && StringUtils.isNotBlank(qo.getEndTime())) {
wrapperX.between(CircleFriendTask::getCreateTime, qo.getStartTime(), qo.getEndTime());
}
wrapperX.eqIfPresent(CircleFriendTask::getUserId, qo.getUserId()).orderByDesc(CircleFriendTask::getId);
this.selectPage(page, wrapperX);
IPage<CircleFriendTaskVO> voPage = page.convert(CircleFriendTaskConverter.INSTANCE::entityToVo);
return new PageResult<>(voPage.getRecords(), voPage.getTotal());
}
}

@ -0,0 +1,35 @@
package com.baiye.modules.scrm.mapper;
import com.baiye.extend.mybatis.plus.conditions.query.LambdaQueryWrapperX;
import com.baiye.extend.mybatis.plus.mapper.ExtendMapper;
import com.baiye.extend.mybatis.plus.toolkit.WrappersX;
import com.baiye.modules.scrm.entity.ComparisonRecord;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
import java.util.Set;
/**
* @author Enzo
* @date : 2024/8/19
*/
@Mapper
public interface ComparisonRecordMapper extends ExtendMapper<ComparisonRecord> {
default List<ComparisonRecord> selectListByTaskId(Long taskId, Boolean flag){
LambdaQueryWrapperX<ComparisonRecord> wrapperX = WrappersX.lambdaQueryX(ComparisonRecord.class);
if (Boolean.FALSE.equals(flag)){
wrapperX.select(ComparisonRecord::getRedBookId);
}
wrapperX.eq(ComparisonRecord::getTaskId, taskId);
return selectList(wrapperX);
}
default List<ComparisonRecord> selectListByTaskIdAndRedBookId(Long taskId, Set<String> strings){
LambdaQueryWrapperX<ComparisonRecord> wrapperX = WrappersX.lambdaQueryX(ComparisonRecord.class);
wrapperX.eq(ComparisonRecord::getTaskId, taskId).in(ComparisonRecord::getRedBookId, strings);
return selectList(wrapperX);
}
}

@ -0,0 +1,19 @@
package com.baiye.modules.scrm.mapper;
import com.baiye.extend.mybatis.plus.conditions.query.LambdaQueryWrapperX;
import com.baiye.extend.mybatis.plus.mapper.ExtendMapper;
import com.baiye.extend.mybatis.plus.toolkit.WrappersX;
import com.baiye.modules.scrm.entity.ComparisonTaskLog;
import org.apache.ibatis.annotations.Mapper;
/**
* @author Enzo
* @date : 2024/8/19
*/
@Mapper
public interface ComparisonTaskLogMapper extends ExtendMapper<ComparisonTaskLog> {
default Long countByUserAndTaskId(Long taskId, Long currentUserId){
LambdaQueryWrapperX<ComparisonTaskLog> wrapperX = WrappersX.lambdaQueryX();
return this.selectCount(wrapperX.eq(ComparisonTaskLog::getTaskId, taskId).eq(ComparisonTaskLog::getUserId, currentUserId));
}
}

@ -0,0 +1,45 @@
package com.baiye.modules.scrm.mapper;
import com.baiye.domain.PageParam;
import com.baiye.domain.PageResult;
import com.baiye.extend.mybatis.plus.conditions.query.LambdaQueryWrapperX;
import com.baiye.extend.mybatis.plus.mapper.ExtendMapper;
import com.baiye.extend.mybatis.plus.toolkit.WrappersX;
import com.baiye.modules.scrm.converter.ComparisonConverter;
import com.baiye.modules.scrm.entity.ComparisonTask;
import com.baiye.modules.scrm.qo.ComparisonQO;
import com.baiye.modules.scrm.vo.ComparisonTaskVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import org.apache.ibatis.annotations.Mapper;
/**
* @author Enzo
* @date : 2024/8/16
*/
@Mapper
public interface ComparisonTaskMapper extends ExtendMapper<ComparisonTask> {
/**
*
*
* @param pageParam
* @param qo
* @return
*/
default PageResult<ComparisonTaskVO> queryPage(PageParam pageParam, ComparisonQO qo) {
IPage<ComparisonTask> page = this.prodPage(pageParam);
LambdaQueryWrapperX<ComparisonTask> wrapperX = WrappersX.lambdaQueryX(ComparisonTask.class);
if (StringUtils.isNotBlank(qo.getStartTime()) && StringUtils.isNotBlank(qo.getEndTime())) {
wrapperX.between(ComparisonTask::getCreateTime, qo.getStartTime(), qo.getEndTime());
}
wrapperX.eqIfPresent(ComparisonTask::getParentId, qo.getUserId()).orderByDesc(ComparisonTask::getId);
this.selectPage(page, wrapperX);
IPage<ComparisonTaskVO> voPage = page.convert(ComparisonConverter.INSTANCE::entityToVo);
return new PageResult<>(voPage.getRecords(), voPage.getTotal());
}
default int setCompleteById(Long taskId) {
return this.update(null, WrappersX.lambdaUpdate(ComparisonTask.class).eq
(ComparisonTask::getId, taskId).set(ComparisonTask::getIsComplete, Boolean.TRUE));
}
}

@ -11,8 +11,10 @@ import com.baiye.modules.scrm.entity.WeChatAccount;
import com.baiye.modules.scrm.qo.AccountQo;
import com.baiye.modules.scrm.vo.WeChatAccountVO;
import com.baiye.modules.scrm.vo.WeChatAddFriendVo;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -35,7 +37,7 @@ public interface LoginEquipmentMapper extends ExtendMapper<LoginEquipment> {
}
wrapperX.likeIfPresent(WeChatAccount::getNickname, qo.getNickname()).likeIfPresent
(WeChatAccount::getWxId, qo.getWxId()).eqIfPresent(WeChatAccount::getUserId, qo.getUserId()).likeIfPresent(WeChatAccount::getWxId, qo.getWxId());
this.selectByPage(page, qo.getStartTime(), qo.getEndTime(), qo.getNickname(), qo.getWxId(), qo.getUserId());
this.selectByPage(page, qo.getStartTime(), qo.getEndTime(), qo.getNickname(), qo.getWxId(), qo.getUserId(), qo.getPacketId());
return new PageResult<>(page.getRecords(), page.getTotal());
}
@ -48,10 +50,12 @@ public interface LoginEquipmentMapper extends ExtendMapper<LoginEquipment> {
* @param username
* @param wxId
* @param userId
* @param packetId
* @return
*/
IPage<WeChatAccountVO> selectByPage(IPage<WeChatAccountVO> page,
@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("username") String username, @Param("wxId") String wxId, @Param("userId") Long userId);
@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("username") String username,
@Param("wxId") String wxId, @Param("userId") Long userId, @Param("packetId") Long packetId);
/**
@ -104,4 +108,20 @@ public interface LoginEquipmentMapper extends ExtendMapper<LoginEquipment> {
default List<LoginEquipment> selectListByTime(DateTime date) {
return this.selectList(WrappersX.lambdaQueryX(LoginEquipment.class).gt(LoginEquipment::getExpirationTime, date));
}
default int deleteByGroupId(Long groupId) {
return delete(WrappersX.lambdaUpdate(LoginEquipment.class).eq(LoginEquipment::getPacketId, groupId));
}
default int updatePacketById(List<Long> idList, Long packetId) {
LambdaUpdateWrapper<LoginEquipment> wrapper = Wrappers.<LoginEquipment>lambdaUpdate()
.set(LoginEquipment::getPacketId, packetId).in(LoginEquipment::getId, idList);
return this.update(null, wrapper);
}
default Long countByRobotId(Long id){
return selectCount(WrappersX.lambdaQueryX(LoginEquipment.class).eq(LoginEquipment::getPacketId, id));
}
List<WeChatAccountVO> queryByPacketId(@Param("packetId") Long id);
}

@ -0,0 +1,61 @@
package com.baiye.modules.scrm.mapper;
import cn.hutool.core.convert.Convert;
import com.baiye.domain.PageParam;
import com.baiye.domain.PageResult;
import com.baiye.extend.mybatis.plus.conditions.query.LambdaQueryWrapperX;
import com.baiye.extend.mybatis.plus.mapper.ExtendMapper;
import com.baiye.extend.mybatis.plus.toolkit.WrappersX;
import com.baiye.modules.scrm.converter.RobotGroupConverter;
import com.baiye.modules.scrm.entity.RobotGroup;
import com.baiye.modules.scrm.qo.RobotGroupQo;
import com.baiye.modules.scrm.vo.RobotGroupVO;
import com.baiye.modules.scrm.vo.WeChatAccountVO;
import com.baiye.security.userdetails.User;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @author Enzo
* @date : 2024/8/14
*/
@Mapper
public interface RobotGroupMapper extends ExtendMapper<RobotGroup> {
/**
*
*
* @param pageParam
* @param qo
* @return
*/
default PageResult<RobotGroupVO> queryPage(PageParam pageParam, RobotGroupQo qo) {
IPage<RobotGroup> page = this.prodPage(pageParam);
LambdaQueryWrapperX<RobotGroup> wrapperX = WrappersX.lambdaQueryX(RobotGroup.class);
wrapperX.eqIfPresent(RobotGroup::getUserId, qo.getUserId()).likeIfPresent(RobotGroup::getName, qo.getName()).orderByDesc(RobotGroup::getId);
this.selectPage(page, wrapperX);
IPage<RobotGroupVO> voPage = page.convert(RobotGroupConverter.INSTANCE::entityToVo);
return new PageResult<>(voPage.getRecords(), voPage.getTotal());
}
/**
*
*
* @param name
* @param currentUserId
* @return
*/
default List<RobotGroup> findByName(String name, Long currentUserId) {
return this.selectList(WrappersX.lambdaUpdate(RobotGroup.class).eq
(RobotGroup::getName, name).eq(RobotGroup::getUserId, currentUserId));
}
default List<RobotGroupVO> selectListByUserId(Long currentUserId){
List<RobotGroup> groupList = this.selectList(WrappersX.lambdaUpdate(RobotGroup.class).eq
(RobotGroup::getUserId, currentUserId).eq(RobotGroup::getUserId, currentUserId));
return Convert.toList(RobotGroupVO.class, groupList);
}
}

@ -36,6 +36,7 @@ public interface StaticResourceMapper extends ExtendMapper<StaticResource> {
if (StringUtils.isNotBlank(qo.getStartTime()) && StringUtils.isNotBlank(qo.getEndTime())) {
wrapperX.between(StaticResource::getCreateTime, qo.getStartTime(), qo.getEndTime());
}
wrapperX.eqIfPresent(StaticResource::getUserId, qo.getUserId());
wrapperX.likeIfPresent(StaticResource::getTitle, qo.getTitle()).orderByDesc(StaticResource::getId);
this.selectPage(page, wrapperX);
IPage<StaticResourceVO> voPage = page.convert(StaticResourceConverter.INSTANCE::entityToVo);

@ -9,6 +9,7 @@ import com.baiye.extend.mybatis.plus.conditions.query.LambdaQueryWrapperX;
import com.baiye.extend.mybatis.plus.mapper.ExtendMapper;
import com.baiye.extend.mybatis.plus.toolkit.WrappersX;
import com.baiye.modules.scrm.converter.WeChatAccountConverter;
import com.baiye.modules.scrm.entity.LoginEquipment;
import com.baiye.modules.scrm.entity.WeChatAccount;
import com.baiye.modules.scrm.qo.AccountQo;
import com.baiye.modules.scrm.vo.WeChatAccountVO;
@ -58,7 +59,7 @@ public interface WeChatAccountMapper extends ExtendMapper<WeChatAccount> {
wrapperX.between(WeChatAccount::getCreateTime, qo.getStartTime(), qo.getEndTime());
}
wrapperX.likeIfPresent(WeChatAccount::getNickname, qo.getNickname()).likeIfPresent(WeChatAccount::getWxId, qo.getWxId()).
eqIfPresent(WeChatAccount::getUserId, qo.getUserId()).orderByDesc(WeChatAccount::getId);
eqIfPresent(WeChatAccount::getUserId, qo.getUserId()).eqIfPresent(WeChatAccount::getPacketId,qo.getPacketId()).orderByDesc(WeChatAccount::getId);
this.selectPage(page, wrapperX);
IPage<WeChatAccountVO> voPage = page.convert(WeChatAccountConverter.INSTANCE::entityToVo);
return new PageResult<>(voPage.getRecords(), voPage.getTotal());
@ -209,4 +210,15 @@ public interface WeChatAccountMapper extends ExtendMapper<WeChatAccount> {
wrapperX.eq(WeChatAccount::getWxId, wxId);
return SqlHelper.retBool(update(null, wrapperX));
}
default List<WeChatAccountVO> selectListByWechatId(List<String> executeWechatList){
LambdaUpdateWrapper<WeChatAccount> wrapperX = WrappersX.lambdaUpdate(WeChatAccount.class);
return Convert.toList(WeChatAccountVO.class, this.selectList(wrapperX.in(WeChatAccount::getWxId, executeWechatList)));
}
default int updatePacketIdByList(List<Long> idList, Long packetId){
LambdaUpdateWrapper<WeChatAccount> wrapper = Wrappers.<WeChatAccount>lambdaUpdate()
.set(WeChatAccount::getPacketId, packetId).in(WeChatAccount::getId, idList);
return this.update(null, wrapper);
}
}

@ -27,6 +27,9 @@ public class AccountQo {
@Schema(title = "微信id")
private String wxId;
@Schema(title = "分组ID")
private Long packetId;
@Schema(title = "查询类型 1:查询标签")
private Integer queryType;

@ -0,0 +1,20 @@
package com.baiye.modules.scrm.qo;
import io.swagger.v3.oas.annotations.Parameter;
import lombok.Data;
/**
* @author Enzo
* @date : 2024/8/19
*/
@Data
public class CircleFriendQO {
@Parameter(description = "用户ID")
private Long userId;
@Parameter(description = "开始时间")
private String startTime;
@Parameter(description = "结束时间")
private String endTime;
}

@ -0,0 +1,20 @@
package com.baiye.modules.scrm.qo;
import io.swagger.v3.oas.annotations.Parameter;
import lombok.Data;
/**
* @author Enzo
* @date : 2024/8/19
*/
@Data
public class ComparisonQO {
@Parameter(description = "用户ID")
private Long userId;
@Parameter(description = "开始时间")
private String startTime;
@Parameter(description = "结束时间")
private String endTime;
}

@ -0,0 +1,18 @@
package com.baiye.modules.scrm.qo;
import lombok.Data;
/**
* @author Enzo
* @date 2024-7-11
*
*/
@Data
public class RobotGroupQo {
private Long userId;
private String name;
}

@ -1,5 +1,6 @@
package com.baiye.modules.scrm.service;
import cn.hutool.core.date.DateTime;
import com.baiye.extend.mybatis.plus.service.ExtendService;
import com.baiye.modules.scrm.entity.ActiveAddFriedRecord;
@ -18,7 +19,18 @@ public interface ActiveAddFriendService extends ExtendService<ActiveAddFriedReco
* @param nickName
* @param wxId
* @param number
* @param type
* @return
*/
List<ActiveAddFriedRecord> selectByFromUsernameAndToUsername(String nickName, String wxId, Integer number);
List<ActiveAddFriedRecord> selectByFromUsernameAndToUsername(String nickName, String wxId, Integer number,Integer type);
/**
*
* @param taskId
* @param dateTime
* @param dateTime1
* @return
*/
Long countByTaskAndDate(String taskId, DateTime dateTime, DateTime dateTime1);
}

@ -0,0 +1,37 @@
package com.baiye.modules.scrm.service;
import com.baiye.extend.mybatis.plus.service.ExtendService;
import com.baiye.modules.scrm.dto.AfterPassingDTO;
import com.baiye.modules.scrm.entity.AddFriendPassGreetMessage;
import java.util.List;
/**
* @author Enzo
* @date : 2024/8/5
*/
public interface AddFriendPassGreetMessageService extends ExtendService<AddFriendPassGreetMessage> {
/**
*
* @param taskId
* @param afterPassing
* @return
*/
Boolean addAfterMessage(Long taskId, List<AfterPassingDTO> afterPassing);
/**
* ID
* @param taskId
* @return
*/
List<AddFriendPassGreetMessage> findByTaskId(Long taskId);
/**
*
* @param id
* @param afterPassing
* @return
*/
Boolean updatePassGreetByTaskId(Long id, List<AfterPassingDTO> afterPassing);
}

@ -38,12 +38,14 @@ public interface AddFriendService extends ExtendService<AddFriend> {
/**
*
*
* @param taskId
* @param number
* @param dateTime
* @param dateTime1
* @return
*/
Long countByTaskAndDate(String taskId, DateTime dateTime, DateTime dateTime1);
Long countByTaskAndDate(String taskId, Integer number, DateTime dateTime, DateTime dateTime1);
/**
*

@ -0,0 +1,49 @@
package com.baiye.modules.scrm.service;
import com.baiye.domain.PageParam;
import com.baiye.domain.PageResult;
import com.baiye.extend.mybatis.plus.service.ExtendService;
import com.baiye.modules.scrm.entity.CircleFriendTask;
import com.baiye.modules.scrm.qo.CircleFriendQO;
import com.baiye.modules.scrm.qo.ComparisonQO;
import com.baiye.modules.scrm.vo.CircleFriendTaskVO;
import com.baiye.modules.scrm.vo.ComparisonTaskVO;
/**
* @author Enzo
* @date : 2024/8/14
*/
public interface CircleFriendTaskService extends ExtendService<CircleFriendTask> {
/**
*
*
* @param entity
* @return
*/
Boolean create(CircleFriendTask entity);
/**
*
*
* @param entity
* @return
*/
Boolean update(CircleFriendTask entity);
/**
*
*
* @param taskId
* @return
*/
Boolean del(Long taskId);
/**
*
* @param pageParam
* @param qo
* @return
*/
PageResult<CircleFriendTaskVO> queryPage(PageParam pageParam, CircleFriendQO qo);
}

@ -0,0 +1,30 @@
package com.baiye.modules.scrm.service;
import com.baiye.extend.mybatis.plus.service.ExtendService;
import com.baiye.modules.scrm.entity.ComparisonRecord;
import java.util.List;
import java.util.Set;
/**
* @author Enzo
* @date : 2024/8/19
*/
public interface ComparisonRecordService extends ExtendService<ComparisonRecord> {
/**
* ID
* @param taskId
* @param flag
* @return
*/
List<ComparisonRecord> selectListByTaskId(Long taskId, Boolean flag);
/**
* idID
* @param taskId
* @param strings
* @return
*/
List<ComparisonRecord> queryByTaskAndRedBookId(Long taskId, Set<String> strings);
}

@ -0,0 +1,27 @@
package com.baiye.modules.scrm.service;
import com.baiye.extend.mybatis.plus.service.ExtendService;
import com.baiye.modules.scrm.entity.ComparisonTaskLog;
/**
* @author Enzo
* @date : 2024/8/19
*/
public interface ComparisonTaskLogService extends ExtendService<ComparisonTaskLog> {
/**
* ID
* @param taskId
* @param currentUserId
* @return
*/
Long countByUserAndTaskId(Long taskId, Long currentUserId);
/**
*
* @param taskId
* @param currentUserId
* @return
*/
Boolean createTaskLogByTaskIdAndUserId(Long taskId, Long currentUserId);
}

@ -0,0 +1,53 @@
package com.baiye.modules.scrm.service;
import com.baiye.domain.PageParam;
import com.baiye.domain.PageResult;
import com.baiye.extend.mybatis.plus.service.ExtendService;
import com.baiye.modules.scrm.entity.ComparisonTask;
import com.baiye.modules.scrm.qo.ComparisonQO;
import com.baiye.modules.scrm.vo.ComparisonTaskVO;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
/**
* @author Enzo
* @date : 2024/8/16
*/
public interface ComparisonTaskService extends ExtendService<ComparisonTask> {
/**
*
*
* @param file
* @param taskName
* @param remark
* @return
*/
Boolean createTask(MultipartFile file, String taskName, String remark);
/**
*
* @param pageParam
* @param qo
* @return
*/
PageResult<ComparisonTaskVO> queryPage(PageParam pageParam, ComparisonQO qo);
/**
*
*
* @param file
* @param taskId
* @param isComplete
* @return
*/
Boolean additionalTask(MultipartFile file, Long taskId, Boolean isComplete);
/**
*
*
* @param response
* @param taskId
*/
void exportByTaskId(HttpServletResponse response, Long taskId);
}

@ -3,6 +3,7 @@ package com.baiye.modules.scrm.service;
import com.baiye.domain.PageParam;
import com.baiye.domain.PageResult;
import com.baiye.extend.mybatis.plus.service.ExtendService;
import com.baiye.modules.scrm.dto.PacketDTO;
import com.baiye.modules.scrm.entity.LoginEquipment;
import com.baiye.modules.scrm.qo.AccountQo;
import com.baiye.modules.scrm.vo.WeChatAccountVO;
@ -22,7 +23,6 @@ public interface LoginEquipmentService extends ExtendService<LoginEquipment> {
* @param qo
* @return
*/
PageResult<WeChatAccountVO> queryPage(PageParam pageParam, AccountQo qo);
/**
@ -71,4 +71,33 @@ public interface LoginEquipmentService extends ExtendService<LoginEquipment> {
* @return
*/
List<LoginEquipment> findExpiredAccount();
/**
* ID
* @param groupId
* @return
*/
Boolean deleteByGroupId(Long groupId);
/**
*
*
* @param dto
* @return
*/
Boolean updatePacketById(PacketDTO dto);
/**
* ID
* @param id
* @return
*/
Long countByRobotId(Long id);
/**
* ID
* @param id
* @return
*/
List<WeChatAccountVO> queryByPacketId(Long id);
}

@ -0,0 +1,53 @@
package com.baiye.modules.scrm.service;
import com.baiye.domain.PageParam;
import com.baiye.domain.PageResult;
import com.baiye.extend.mybatis.plus.service.ExtendService;
import com.baiye.modules.scrm.entity.RobotGroup;
import com.baiye.modules.scrm.entity.StaticResource;
import com.baiye.modules.scrm.qo.RobotGroupQo;
import com.baiye.modules.scrm.vo.RobotGroupVO;
import java.util.List;
/**
* @author Enzo
* @date : 2024/8/14
*/
public interface RobotGroupService extends ExtendService<RobotGroup> {
/**
*
* @param pageParam
* @param qo
* @return
*/
PageResult<RobotGroupVO> queryPage(PageParam pageParam, RobotGroupQo qo);
/**
*
* @param currentUserId
* @return
*/
List<RobotGroupVO> queryByUserId(Long currentUserId);
/**
*
* @param entity
*/
Boolean create(RobotGroup entity);
/**
*
* @param entity
* @return
*/
Boolean update(RobotGroup entity);
/**
*
* @param groupId
* @return
*/
Boolean del(Long groupId);
}

@ -2,7 +2,6 @@ package com.baiye.modules.scrm.service;
import com.baiye.domain.PageParam;
import com.baiye.domain.PageResult;
import com.baiye.extend.mybatis.plus.service.ExtendService;
import com.baiye.modules.scrm.dto.*;
import com.baiye.modules.scrm.entity.WeChatAccount;
import com.baiye.modules.scrm.qo.AccountQo;
@ -49,10 +48,11 @@ public interface WeChatService {
*
*
* @param num
* @param userId
* @param packetId
* @param currentUserId
* @return
*/
Boolean createEquipment(Integer num , Long userId);
Boolean createEquipment(Integer num , Long packetId, Long currentUserId);
/**
*
@ -147,12 +147,12 @@ public interface WeChatService {
/**
*
*
* @param passGreetMessage
* @param sendTextMessage
* @param wxId
* @param fromUserName
* @return
*/
Boolean sendTextMessage(List<String> passGreetMessage, String wxId, String fromUserName);
Boolean sendTextMessage(String sendTextMessage, String wxId, String fromUserName);
/**
*
@ -191,4 +191,61 @@ public interface WeChatService {
* @return
*/
Boolean deleteWeChatLabel(String wechatId, List<Integer> list);
/**
*
* @param passGreetMessage
* @param wxId
* @param fromUserName
* @return
*/
Boolean sendPictureMessage(String passGreetMessage, String wxId, String fromUserName);
/**
*
* @param wxId
* @param fromUserName
* @return
*/
WechatMemberDTO queryByWechatId(String wxId, String fromUserName);
/**
*
* @param wechat
* @param pictures
* @param title
* @param comments
* @param blackList
* @param labelIds
*/
Boolean sendTextCircleFriends(String wechat, List<String> pictures, String title, List<String> comments, List<String> blackList, List<String> labelIds);
/**
*
* @param wechat
* @param reqUrl
* @param content
* @param coverUrl
* @param comments
* @param blackList
* @param labelIds
* @return
*/
Boolean sendVideoCircleFriends(String wechat, String reqUrl, String content, String coverUrl, List<String> comments, List<String> blackList, List<String> labelIds);
/**
*
* @param wechat
* @param reqUrl
* @param title
* @param content
* @param coverUrl
* @param comments
* @param blackList
* @param labelIds
* @return
*/
Boolean sendLinkCircleFriends(String wechat, String reqUrl, String title, String content, String coverUrl, List<String> comments, List<String> blackList, List<String> labelIds);
}

@ -1,6 +1,7 @@
package com.baiye.modules.scrm.service;
import com.baiye.extend.mybatis.plus.service.ExtendService;
import com.baiye.modules.scrm.dto.PacketDTO;
import com.baiye.modules.scrm.entity.StaticResource;
import com.baiye.modules.scrm.entity.WeChatAccount;
import com.baiye.modules.scrm.vo.WeChatAccountVO;
@ -58,4 +59,18 @@ public interface WechatAccountService extends ExtendService<WeChatAccount> {
* @return
*/
Long getCountByCustomerId(Long customerId);
/**
* ID
* @param executeWechatList
* @return
*/
List<WeChatAccountVO> queryByWeChatId(List<String> executeWechatList);
/**
*
* @param dto
* @return
*/
Boolean updatePacketById(PacketDTO dto);
}

@ -1,5 +1,6 @@
package com.baiye.modules.scrm.service.impl;
import cn.hutool.core.date.DateTime;
import com.baiye.extend.mybatis.plus.service.impl.ExtendServiceImpl;
import com.baiye.modules.scrm.entity.ActiveAddFriedRecord;
import com.baiye.modules.scrm.mapper.ActiveAddFriendRecordMapper;
@ -21,7 +22,16 @@ public class ActiveAddFriendRecordServiceImpl extends ExtendServiceImpl<ActiveAd
@Override
public List<ActiveAddFriedRecord> selectByFromUsernameAndToUsername(String nickName, String wxId, Integer number) {
return baseMapper.selectByFromUsernameAndToUsername(nickName, wxId, number);
public List<ActiveAddFriedRecord> selectByFromUsernameAndToUsername(String nickName, String wxId, Integer number,Integer type) {
return baseMapper.selectByFromUsernameAndToUsername(nickName, wxId, number, type);
}
@Override
public Long countByTaskAndDate(String taskId, DateTime startTime, DateTime endTime) {
return baseMapper.selectCountByTaskIdAndDate(taskId, startTime, endTime);
}
}

@ -0,0 +1,52 @@
package com.baiye.modules.scrm.service.impl;
import com.baiye.extend.mybatis.plus.service.impl.ExtendServiceImpl;
import com.baiye.modules.scrm.dto.AfterPassingDTO;
import com.baiye.modules.scrm.entity.AddFriendPassGreetMessage;
import com.baiye.modules.scrm.mapper.AddFriendPassGreetMessageMapper;
import com.baiye.modules.scrm.service.AddFriendPassGreetMessageService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.List;
/**
* @author Enzo
* @date : 2024/6/2
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class AddFriendPassGreetMessageServiceImpl extends
ExtendServiceImpl<AddFriendPassGreetMessageMapper, AddFriendPassGreetMessage> implements AddFriendPassGreetMessageService {
@Override
public Boolean addAfterMessage(Long taskId, List<AfterPassingDTO> afterPassing) {
for (AfterPassingDTO afterPassingDTO : afterPassing) {
AddFriendPassGreetMessage message = new AddFriendPassGreetMessage();
message.setTaskId(taskId);
message.setType(afterPassingDTO.getType());
message.setPassGreetMessage(afterPassingDTO.getPassGreetMessage());
baseMapper.insert(message);
}
return Boolean.TRUE;
}
@Override
public List<AddFriendPassGreetMessage> findByTaskId(Long taskId) {
return baseMapper.selectListByTaskId(taskId);
}
@Override
public Boolean updatePassGreetByTaskId(Long id, List<AfterPassingDTO> afterPassing) {
Boolean aBoolean = baseMapper.deleteByTaskId(id);
if (Boolean.TRUE.equals(aBoolean)){
return addAfterMessage(id, afterPassing);
}
return Boolean.FALSE;
}
}

@ -4,7 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpUtil;
import cn.hutool.extra.emoji.EmojiUtil;
import com.baiye.constant.DefaultNumberConstants;
import com.baiye.domain.PageParam;
import com.baiye.domain.PageResult;
@ -14,7 +14,7 @@ import com.baiye.modules.scrm.dto.WeChatFriendDTO;
import com.baiye.modules.scrm.dto.WechatMemberDTO;
import com.baiye.modules.scrm.entity.ActiveAddFriedRecord;
import com.baiye.modules.scrm.entity.AddFriend;
import com.baiye.modules.scrm.entity.AddFriendTask;
import com.baiye.modules.scrm.entity.AddFriendPassGreetMessage;
import com.baiye.modules.scrm.mapper.AddFriendMapper;
import com.baiye.modules.scrm.mapper.AddFriendTaskMapper;
import com.baiye.modules.scrm.qo.AddFriendQo;
@ -24,6 +24,7 @@ import com.baiye.system.properties.FileProperties;
import com.baiye.util.FileUtil;
import com.baiye.util.PictureUtil;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.opencv.core.Mat;
import org.opencv.imgcodecs.Imgcodecs;
@ -31,6 +32,7 @@ import org.opencv.imgproc.Imgproc;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
* @author Enzo
@ -41,6 +43,8 @@ import java.util.List;
@RequiredArgsConstructor
public class AddFriendServiceImpl extends ExtendServiceImpl<AddFriendMapper, AddFriend> implements AddFriendService {
private final AddFriendPassGreetMessageService addFriendPassGreetMessageService;
private final ActiveAddFriendService activeAddFriendService;
private final WechatFriendService wechatFriendService;
@ -54,36 +58,47 @@ public class AddFriendServiceImpl extends ExtendServiceImpl<AddFriendMapper, Add
private final WeChatService weChatService;
@Override
public List<AddFriend> queryAddSourceByTaskIdAndStatus(String taskId, Integer addFriendNum, Integer taskStatus) {
return baseMapper.queryByTaskIdAndStatus(taskId, addFriendNum, taskStatus);
}
@Override
@SneakyThrows
public Boolean addFriendSuccessfully(OtherInformationDTO dto, String wxId) {
String fromUserName = dto.getFromUserName();
WechatMemberDTO targetWxInfo = dto.getTargetWxInfo();
WeChatFriendDTO weChatFriendDTO = new WeChatFriendDTO();
BeanUtil.copyProperties(targetWxInfo, weChatFriendDTO);
weChatFriendDTO.setRobotWxId(wxId);
weChatFriendDTO.setFriendId(targetWxInfo.getUserName());
weChatFriendDTO.setAddAcceptTime(System.currentTimeMillis());
weChatFriendDTO.setAddFriendType(DefaultNumberConstants.TWO_NUMBER);
// 昵称查询数据
if (ObjectUtil.isNull(targetWxInfo) || ObjectUtil.isNull(targetWxInfo.getNickName())) {
int reNum = DefaultNumberConstants.THREE_NUMBER;
while (ObjectUtil.isNull(targetWxInfo) && reNum > DefaultNumberConstants.ZERO_NUMBER) {
targetWxInfo = weChatService.queryByWechatId(wxId, fromUserName);
TimeUnit.SECONDS.sleep(DefaultNumberConstants.THIRTY);
reNum--;
}
}
log.info("============= json as {} ==================", targetWxInfo);
if (ObjectUtil.isNotNull(targetWxInfo) && ObjectUtil.isNotNull(targetWxInfo.getNickName())) {
WeChatFriendDTO weChatFriendDTO = new WeChatFriendDTO();
BeanUtil.copyProperties(targetWxInfo, weChatFriendDTO);
weChatFriendDTO.setRobotWxId(wxId);
weChatFriendDTO.setFriendId(targetWxInfo.getUserName());
weChatFriendDTO.setAddAcceptTime(System.currentTimeMillis());
weChatFriendDTO.setAddFriendType(DefaultNumberConstants.TWO_NUMBER);
// 昵称查询数据
List<ActiveAddFriedRecord> addFriedRecords =
activeAddFriendService.selectByFromUsernameAndToUsername(targetWxInfo.getNickName(), wxId, DefaultNumberConstants.ZERO_NUMBER);
activeAddFriendService.selectByFromUsernameAndToUsername(EmojiUtil.toAlias(targetWxInfo.getNickName()), wxId,
DefaultNumberConstants.ZERO_NUMBER, DefaultNumberConstants.ZERO_NUMBER);
if (addFriedRecords.size() == DefaultNumberConstants.ONE_NUMBER) {
ActiveAddFriedRecord friedRecord = addFriedRecords.get(DefaultNumberConstants.ZERO_NUMBER);
AddFriend addFriend = baseMapper.selectById(friedRecord.getAddFriendId());
processingInitiativeAddFriend(wxId, friedRecord, addFriend, fromUserName, weChatFriendDTO);
}
if (addFriedRecords.size() > DefaultNumberConstants.ONE_NUMBER) {
String contrastPicture = FileUtil.downLoadFromUrl(dto.getTargetWxInfo().getBigHeadImgUrl(), fileProperties.getPath().getAvatar(),dto.getTargetWxInfo().getNickName());
String contrastPicture = FileUtil.downLoadFromUrl(dto.getTargetWxInfo().getBigHeadImgUrl(), fileProperties.getPath().getAvatar(), dto.getTargetWxInfo().getNickName());
for (ActiveAddFriedRecord addFriedRecord : addFriedRecords) {
// 下载图片
String recordPath = FileUtil.downLoadFromUrl(addFriedRecord.getBigHeadImgUrl(), fileProperties.getPath().getAvatar(),addFriedRecord.getNickName());
String recordPath = FileUtil.downLoadFromUrl(addFriedRecord.getBigHeadImgUrl(), fileProperties.getPath().getAvatar(), addFriedRecord.getNickName());
nu.pattern.OpenCV.loadLocally();
// 读取两张图像。准备比对的图片
Mat image1 = Imgcodecs.imread(contrastPicture);
@ -100,13 +115,15 @@ public class AddFriendServiceImpl extends ExtendServiceImpl<AddFriendMapper, Add
}
}
}
wechatFriendService.addFriendByResponse(weChatFriendDTO);
}
wechatFriendService.addFriendByResponse(weChatFriendDTO);
return Boolean.TRUE;
}
/**
*
*
* @param wxId
* @param addFriedRecord
* @param addFriend
@ -115,16 +132,25 @@ public class AddFriendServiceImpl extends ExtendServiceImpl<AddFriendMapper, Add
*/
private void processingInitiativeAddFriend(String wxId, ActiveAddFriedRecord addFriedRecord, AddFriend addFriend, String fromUserName, WeChatFriendDTO weChatFriendDTO) {
if (ObjectUtil.isNotNull(addFriend) && ObjectUtil.isNotNull(addFriend.getId())) {
AddFriendTask friendTask = addFriendTaskMapper.selectById(addFriend.getTaskId());
if (CollUtil.isNotEmpty(addFriend.getLabelIds())) {
// 修改好友标签
weChatLabelService.modifyLabel(addFriend.getLabelIds(), wxId, fromUserName);
}
List<AddFriendPassGreetMessage> messageList = addFriendPassGreetMessageService.findByTaskId(addFriedRecord.getTaskId());
// 发送消息
if (CollUtil.isNotEmpty(friendTask.getPassGreetMessage())) {
weChatService.sendTextMessage(friendTask.getPassGreetMessage(), wxId, fromUserName);
if (CollUtil.isNotEmpty(messageList)) {
for (AddFriendPassGreetMessage message : messageList) {
if (message.getType() == DefaultNumberConstants.ONE_NUMBER) {
weChatService.sendTextMessage(message.getPassGreetMessage(), wxId, fromUserName);
}
if (message.getType() == DefaultNumberConstants.TWO_NUMBER) {
weChatService.sendPictureMessage(message.getPassGreetMessage(), wxId, fromUserName);
}
}
}
}
addFriend.setAddStatus(DefaultNumberConstants.FOUR_NUMBER);
baseMapper.updateById(addFriend);
// 设置通过
addFriedRecord.setAddStatus(DefaultNumberConstants.ONE_NUMBER);
weChatFriendDTO.setAddFriendType(DefaultNumberConstants.ONE_NUMBER);
@ -132,8 +158,8 @@ public class AddFriendServiceImpl extends ExtendServiceImpl<AddFriendMapper, Add
}
@Override
public Long countByTaskAndDate(String taskId, DateTime startTime, DateTime endTime) {
return baseMapper.selectCountByTime(taskId, startTime, endTime);
public Long countByTaskAndDate(String taskId, Integer number, DateTime startTime, DateTime endTime) {
return baseMapper.selectCountByTime(taskId, number, startTime, endTime);
}
@Override

@ -1,6 +1,7 @@
package com.baiye.modules.scrm.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.text.CharSequenceUtil;
@ -23,27 +24,34 @@ import com.baiye.modules.scrm.entity.AddFriend;
import com.baiye.modules.scrm.entity.AddFriendTask;
import com.baiye.modules.scrm.mapper.AddFriendTaskMapper;
import com.baiye.modules.scrm.qo.TaskQo;
import com.baiye.modules.scrm.service.AddFriendPassGreetMessageService;
import com.baiye.modules.scrm.service.AddFriendService;
import com.baiye.modules.scrm.service.AddFriendTaskService;
import com.baiye.modules.scrm.service.WechatAccountService;
import com.baiye.modules.scrm.vo.AddFriendTaskVO;
import com.baiye.modules.scrm.vo.FileAddFriendVO;
import com.baiye.modules.scrm.vo.WeChatAccountVO;
import com.baiye.polling.QueueBalance;
import com.baiye.schedule.handler.AddFriendJob;
import com.baiye.security.util.SecurityUtils;
import com.baiye.util.CronUtil;
import com.baiye.util.FileUtil;
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import com.google.common.base.Splitter;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Set;
@ -65,19 +73,22 @@ public class AddFriendTaskServiceImpl extends ExtendServiceImpl<AddFriendTaskMap
@Value("${snowflake.datacenterId}")
private int datacenterId;
private final SimpleJob addFriendTask;
private final AddFriendJob addFriendJob;
private final AddFriendService addFriendService;
private final ElasticJobHandler elasticJobHandler;
private final WechatAccountService wechatAccountService;
private final AddFriendPassGreetMessageService addFriendPassGreetMessageService;
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean createTask(MultipartFile file, CreateAddFriendTaskDTO createAddFriendTaskDTO, Long currentUserId) {
DateTime date = DateUtil.date();
List<String> list = Lists.newArrayList();
List<AddFriendDTO> addFriendDTOList = createAddFriendTaskDTO.getAddFriendDTOList();
// 雪花算法id
long taskId = IdUtil.getSnowflake(workerId, datacenterId).nextId();
@ -90,14 +101,17 @@ public class AddFriendTaskServiceImpl extends ExtendServiceImpl<AddFriendTaskMap
String generatedCronByTime = CronUtil.generateCronByTime
(beginDate, endDate, createAddFriendTaskDTO.getAddIntervalStart(), createAddFriendTaskDTO.getAddIntervalEnd(), null);
List<String> listList = addFriendDTOList.stream().map
(AddFriendDTO::getTrumpetWechat).collect(Collectors.toList());
addFriendDTOList.forEach(dto -> list.addAll(dto.getTrumpetWechat()));
if (CollUtil.isNotEmpty(createAddFriendTaskDTO.getAfterPassing())) {
addFriendPassGreetMessageService.addAfterMessage(taskId, createAddFriendTaskDTO.getAfterPassing());
}
// 创建任务
AddFriendTask friendTask = new AddFriendTask();
BeanUtil.copyProperties(createAddFriendTaskDTO, friendTask);
friendTask.setId(taskId);
friendTask.setExecuteWechatList(listList);
friendTask.setExecuteWechatList(list);
friendTask.setCronExpression(generatedCronByTime);
friendTask.setTaskStatus(DefaultNumberConstants.ONE_NUMBER);
friendTask.setEndTime(DateUtil.endOfDay(createAddFriendTaskDTO.getEndTime()));
@ -106,7 +120,7 @@ public class AddFriendTaskServiceImpl extends ExtendServiceImpl<AddFriendTaskMap
if (ObjectUtil.isNotNull(file)
&& createAddFriendTaskDTO.getAddFriendType() == DefaultNumberConstants.THREE_NUMBER) {
SaveAddFriendDTO saveAddFriendDTO =
SaveAddFriendDTO.builder().trumpetWechatList(listList).taskId(taskId).userId(currentUserId).build();
SaveAddFriendDTO.builder().trumpetWechatList(list).taskId(taskId).userId(currentUserId).build();
// 解析 文件
File upload = FileUtil.multiToFile(file);
EasyExcelFactory.read(upload, FileAddFriendVO.class, new AddFileFriendDataListener(addFriendService, saveAddFriendDTO)).build().readAll();
@ -116,18 +130,21 @@ public class AddFriendTaskServiceImpl extends ExtendServiceImpl<AddFriendTaskMap
for (AddFriendDTO addFriendDTO : addFriendDTOList) {
AddFriend friend;
List<String> targetWechat = createAddFriendTaskDTO.getAddFriendType() == DefaultNumberConstants.ONE_NUMBER ?
List<String> targetWechat = createAddFriendTaskDTO.getAddFriendType() == DefaultNumberConstants.ONE_NUMBER ?
JSONUtil.toList(addFriendDTO.getTargetWechat(), String.class) :
Splitter.on(StrPool.COMMA).omitEmptyStrings().trimResults().splitToList(addFriendDTO.getTargetWechat());
Splitter.on(StrPool.COMMA).omitEmptyStrings().trimResults().splitToList(addFriendDTO.getTargetWechat());
// 随机添加微信
QueueBalance<String> balance = new QueueBalance<>();
for (String string : targetWechat) {
if (StringUtils.isNotBlank(string)) {
String pollingWechat = balance.chooseOne(list);
friend = new AddFriend();
friend.setTaskId(taskId);
friend.setUserId(currentUserId);
friend.setTargetWechat(string.trim());
friend.setTrumpetWechat(pollingWechat);
friend.setGreet(addFriendDTO.getGreet());
friend.setLabelIds(addFriendDTO.getLabelIds());
friend.setTrumpetWechat(addFriendDTO.getTrumpetWechat());
friend.setAddStatus(DefaultNumberConstants.ZERO_NUMBER);
saveSet.add(friend);
}
@ -136,7 +153,7 @@ public class AddFriendTaskServiceImpl extends ExtendServiceImpl<AddFriendTaskMap
// 异步方式同步群成员信息
CompletableFuture.runAsync(() -> addFriendService.saveBatch(saveSet));
}
elasticJobHandler.addJob(createAddFriendTaskDTO.getTaskName().concat(StrPool.DASHED).concat(String.valueOf(taskId)), generatedCronByTime, DefaultNumberConstants.ONE_NUMBER, addFriendTask, String.valueOf(taskId), CharSequenceUtil.EMPTY);
elasticJobHandler.addJob(createAddFriendTaskDTO.getTaskName().concat(StrPool.DASHED).concat(String.valueOf(taskId)), generatedCronByTime, DefaultNumberConstants.ONE_NUMBER, addFriendJob, String.valueOf(taskId), CharSequenceUtil.EMPTY);
return Boolean.TRUE;
}
return Boolean.FALSE;
@ -148,9 +165,13 @@ public class AddFriendTaskServiceImpl extends ExtendServiceImpl<AddFriendTaskMap
}
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean updateTask(CreateAddFriendTaskDTO createAddFriendTaskDTO) {
AddFriendTask friendTask = baseMapper.selectById(createAddFriendTaskDTO.getId());
if (ObjectUtil.isNotNull(friendTask) && ObjectUtil.isNotNull(friendTask.getId())) {
if (CollUtil.isNotEmpty(createAddFriendTaskDTO.getAfterPassing())) {
addFriendPassGreetMessageService.updatePassGreetByTaskId(createAddFriendTaskDTO.getId(), createAddFriendTaskDTO.getAfterPassing());
}
BeanUtil.copyProperties(createAddFriendTaskDTO, friendTask);
return SqlHelper.retBool(baseMapper.updateById(friendTask));
}
@ -202,7 +223,13 @@ public class AddFriendTaskServiceImpl extends ExtendServiceImpl<AddFriendTaskMap
@Override
public PageResult<AddFriendTaskVO> queryPage(PageParam pageParam, TaskQo qo) {
qo.setUserId(SecurityUtils.getCurrentUserId());
return baseMapper.queryPage(pageParam, qo);
PageResult<AddFriendTaskVO> queryPage = baseMapper.queryPage(pageParam, qo);
queryPage.getRecords().forEach(c -> {
List<String> executeWechatList = c.getExecuteWechatList();
List<WeChatAccountVO> list = wechatAccountService.queryByWeChatId(executeWechatList);
c.setExecuteWechatNicknameList(list.stream().map(WeChatAccountVO::getNickname).collect(Collectors.toList()));
});
return queryPage;
}
}

@ -88,7 +88,7 @@ public class AliPayServiceImpl extends ExtendServiceImpl<PayOrderMapper, PayOrde
order.setStatus(DefaultNumberConstants.ONE_NUMBER);
if (Boolean.FALSE.equals(order.getIsRenew())) {
// 创建设备
weChatService.createEquipment(order.getNum(), order.getUserId());
weChatService.createEquipment(order.getNum(), order.getUserId(), SecurityUtils.getCurrentUserId());
}
if (Boolean.TRUE.equals(order.getIsRenew())) {
// 续费操作设备
@ -157,7 +157,7 @@ public class AliPayServiceImpl extends ExtendServiceImpl<PayOrderMapper, PayOrde
throw new BadRequestException("至多创建三台免费设备!");
}
// 创建设备
weChatService.createEquipment(num, userId);
weChatService.createEquipment(num, userId, SecurityUtils.getCurrentUserId());
map.put("orderNo", orderNo);
return map;
}

@ -0,0 +1,93 @@
package com.baiye.modules.scrm.service.impl;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.text.StrPool;
import cn.hutool.core.util.IdUtil;
import com.baiye.common.job.handler.ElasticJobHandler;
import com.baiye.constant.DefaultNumberConstants;
import com.baiye.domain.PageParam;
import com.baiye.domain.PageResult;
import com.baiye.extend.mybatis.plus.service.impl.ExtendServiceImpl;
import com.baiye.modules.scrm.entity.CircleFriendTask;
import com.baiye.modules.scrm.mapper.CircleFriendTaskMapper;
import com.baiye.modules.scrm.qo.CircleFriendQO;
import com.baiye.modules.scrm.service.CircleFriendTaskService;
import com.baiye.modules.scrm.service.WeChatService;
import com.baiye.modules.scrm.vo.CircleFriendTaskVO;
import com.baiye.schedule.handler.SendCircleFriendTaskJob;
import com.baiye.util.CronUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.Collections;
/**
* @author Enzo
* @date : 2024/8/14
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class CircleFriendTaskServiceImpl extends ExtendServiceImpl<CircleFriendTaskMapper, CircleFriendTask> implements CircleFriendTaskService {
@Value("${snowflake.workerId}")
private int workerId;
@Value("${snowflake.datacenterId}")
private int datacenterId;
private final WeChatService weChatService;
private final ElasticJobHandler elasticJobHandler;
private final SendCircleFriendTaskJob sendCircleFriendTaskJob;
@Override
public Boolean create(CircleFriendTask entity) {
long taskId = IdUtil.getSnowflake(workerId, datacenterId).nextId();
if (Boolean.TRUE.equals(entity.getIsNow())) {
for (String targetWechat : entity.getExecuteWechatList()) {
// 发送文本
if (entity.getType() == DefaultNumberConstants.ONE_NUMBER) {
weChatService.sendTextCircleFriends
(targetWechat, entity.getPictureList(), entity.getTitle(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList());
}
// 发送图文链接
if (entity.getType() == DefaultNumberConstants.TWO_NUMBER) {
weChatService.sendLinkCircleFriends
(targetWechat, entity.getSourcePath(), entity.getTitle(), entity.getContent(), entity.getPictureList().get(DefaultNumberConstants.ZERO_NUMBER), Collections.emptyList(), Collections.emptyList(), Collections.emptyList());
}
// 发送视频
if (entity.getType() == DefaultNumberConstants.THREE_NUMBER) {
weChatService.sendVideoCircleFriends
(targetWechat, entity.getSourcePath(), entity.getTitle(), entity.getPictureList().get(DefaultNumberConstants.ZERO_NUMBER), Collections.emptyList(), Collections.emptyList(), Collections.emptyList());
}
log.info("============= send text circle friends {} type as {} ============", targetWechat, entity.getType());
}
return save(entity);
}
String generatedCronByTime = CronUtil.getCron(entity.getExecutionTime());
elasticJobHandler.addJob(entity.getTaskName().concat(StrPool.DASHED).concat(String.valueOf(taskId)), generatedCronByTime, DefaultNumberConstants.ONE_NUMBER, sendCircleFriendTaskJob, String.valueOf(taskId), CharSequenceUtil.EMPTY);
return save(entity);
}
@Override
public Boolean update(CircleFriendTask entity) {
return null;
}
@Override
public Boolean del(Long taskId) {
return null;
}
@Override
public PageResult<CircleFriendTaskVO> queryPage(PageParam pageParam, CircleFriendQO qo) {
return baseMapper.queryPage(pageParam, qo);
}
}

@ -0,0 +1,34 @@
package com.baiye.modules.scrm.service.impl;
import com.baiye.extend.mybatis.plus.service.impl.ExtendServiceImpl;
import com.baiye.modules.scrm.entity.ComparisonRecord;
import com.baiye.modules.scrm.mapper.ComparisonRecordMapper;
import com.baiye.modules.scrm.service.ComparisonRecordService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.List;
import java.util.Set;
/**
* @author Enzo
* @date : 2024/8/19
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class ComparisonRecordServiceImpl extends ExtendServiceImpl<ComparisonRecordMapper, ComparisonRecord> implements ComparisonRecordService {
@Override
public List<ComparisonRecord> selectListByTaskId(Long taskId, Boolean flag) {
return baseMapper.selectListByTaskId(taskId, flag);
}
@Override
public List<ComparisonRecord> queryByTaskAndRedBookId(Long taskId, Set<String> strings) {
return baseMapper.selectListByTaskIdAndRedBookId(taskId, strings);
}
}

@ -0,0 +1,31 @@
package com.baiye.modules.scrm.service.impl;
import com.baiye.extend.mybatis.plus.service.impl.ExtendServiceImpl;
import com.baiye.modules.scrm.entity.ComparisonTaskLog;
import com.baiye.modules.scrm.mapper.ComparisonTaskLogMapper;
import com.baiye.modules.scrm.service.ComparisonTaskLogService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/**
* @author Enzo
* @date : 2024/8/19
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class ComparisonTaskLogServiceImpl extends ExtendServiceImpl<ComparisonTaskLogMapper, ComparisonTaskLog> implements ComparisonTaskLogService {
@Override
public Long countByUserAndTaskId(Long taskId, Long currentUserId) {
return baseMapper.countByUserAndTaskId(taskId, currentUserId);
}
@Override
public Boolean createTaskLogByTaskIdAndUserId(Long taskId, Long currentUserId) {
ComparisonTaskLog taskLog = new ComparisonTaskLog();
taskLog.setTaskId(taskId);
taskLog.setUserId(currentUserId);
return this.save(taskLog);
}
}

@ -0,0 +1,153 @@
package com.baiye.modules.scrm.service.impl;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.IdUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.EasyExcelFactory;
import com.baiye.constant.DefaultNumberConstants;
import com.baiye.domain.PageParam;
import com.baiye.domain.PageResult;
import com.baiye.exception.BadRequestException;
import com.baiye.extend.mybatis.plus.service.impl.ExtendServiceImpl;
import com.baiye.listener.ComparisonAdditionalDataListener;
import com.baiye.listener.ComparisonRecordDataListener;
import com.baiye.modules.scrm.dto.SaveComparisonDTO;
import com.baiye.modules.scrm.entity.ComparisonRecord;
import com.baiye.modules.scrm.entity.ComparisonTask;
import com.baiye.modules.scrm.mapper.ComparisonTaskMapper;
import com.baiye.modules.scrm.qo.ComparisonQO;
import com.baiye.modules.scrm.service.ComparisonRecordService;
import com.baiye.modules.scrm.service.ComparisonTaskLogService;
import com.baiye.modules.scrm.service.ComparisonTaskService;
import com.baiye.modules.scrm.vo.ComparisonRecordVO;
import com.baiye.modules.scrm.vo.ComparisonSummaryVO;
import com.baiye.modules.scrm.vo.ComparisonTaskVO;
import com.baiye.modules.scrm.vo.ComparisonVO;
import com.baiye.security.userdetails.User;
import com.baiye.security.util.SecurityUtils;
import com.baiye.util.AESUtils;
import com.baiye.util.FileUtil;
import com.baiye.util.RedisUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.util.List;
/**
* @author Enzo
* @date : 2024/8/16
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class ComparisonTaskServiceImpl extends ExtendServiceImpl<ComparisonTaskMapper, ComparisonTask> implements ComparisonTaskService {
@Value("${snowflake.workerId}")
private int workerId;
@Value("${snowflake.datacenterId}")
private int datacenterId;
private final RedisUtils redisUtils;
private final ComparisonRecordService comparisonRecordService;
private final ComparisonTaskLogService comparisonTaskLogService;
@Override
public Boolean createTask(MultipartFile file, String taskName, String remark) {
User user = SecurityUtils.getUser();
Long userId = user.getUserId();
Long whichUserId = user.getWhichUserId();
ComparisonTask task = new ComparisonTask();
// 雪花算法id
long taskId = IdUtil.getSnowflake(workerId, datacenterId).nextId();
SaveComparisonDTO comparisonDTO =
SaveComparisonDTO.builder().taskId(taskId).userId(user.getUserId()).build();
// 解析 文件
File upload = FileUtil.multiToFile(file);
EasyExcelFactory.read(upload, ComparisonVO.class,
new ComparisonRecordDataListener(comparisonRecordService, comparisonDTO)).build().readAll();
task.setParentId(whichUserId);
task.setTaskName(taskName);
task.setRemark(remark);
task.setUserId(userId);
task.setId(taskId);
return this.save(task);
}
@Override
public PageResult<ComparisonTaskVO> queryPage(PageParam pageParam, ComparisonQO qo) {
Long currentUserId = SecurityUtils.getCurrentUserId();
PageResult<ComparisonTaskVO> pageResult = baseMapper.queryPage(pageParam, qo);
pageResult.getRecords().forEach(r -> {
Long count = comparisonTaskLogService.countByUserAndTaskId(r.getId(), currentUserId);
r.setIsDown(count > DefaultNumberConstants.ZERO_NUMBER);
});
return pageResult;
}
@Override
public Boolean additionalTask(MultipartFile file, Long taskId, Boolean isComplete) {
User user = SecurityUtils.getUser();
SaveComparisonDTO comparisonDTO =
SaveComparisonDTO.builder().taskId(taskId).userId(user.getUserId()).build();
// 解析 文件
File upload = FileUtil.multiToFile(file);
EasyExcelFactory.read(upload, ComparisonVO.class,
new ComparisonAdditionalDataListener(comparisonRecordService, comparisonDTO)).build().readAll();
if (Boolean.TRUE.equals(isComplete)) {
baseMapper.setCompleteById(taskId);
}
return Boolean.TRUE;
}
@Override
public void exportByTaskId(HttpServletResponse response, Long taskId) {
Long currentUserId = SecurityUtils.getCurrentUserId();
// 创建一个唯一的锁标识例如用户ID和表单ID的组合
String lockKey = taskId + ":" + currentUserId;
// 尝试获取锁,如果锁不存在,则设置锁并执行业务逻辑
if (Boolean.TRUE.equals(redisUtils.acquireKey(lockKey))) {
try {
Long count = comparisonTaskLogService.countByUserAndTaskId(taskId, currentUserId);
if (count > DefaultNumberConstants.ZERO_NUMBER) {
throw new BadRequestException("当前记录已下载,请勿重复下载!");
}
Boolean flag = SecurityUtils.getWhichUserId() == DefaultNumberConstants.ONE_NUMBER;
List<ComparisonRecord> recordList = this.comparisonRecordService.selectListByTaskId(taskId, flag);
// 设置字符编码
response.setCharacterEncoding("utf-8");
// 设置文本内省
response.setContentType("application/vnd.ms-excel");
// 设置响应头
response.setHeader("Content-disposition", "attachment;filename=" + System.currentTimeMillis() + ".xlsx");
if (Boolean.TRUE.equals(flag)) {
recordList.forEach(comparisonRecord -> comparisonRecord.setComparisonResult(AESUtils.decrypt(comparisonRecord.getComparisonResult(), "==marketing-scrm=")));
List<ComparisonSummaryVO> voList = Convert.toList(ComparisonSummaryVO.class, recordList);
EasyExcel.write(response.getOutputStream(), ComparisonSummaryVO.class).sheet("总表记录").doWrite(voList);
}
if (Boolean.FALSE.equals(flag)) {
List<ComparisonRecordVO> voList = Convert.toList(ComparisonRecordVO.class, recordList);
EasyExcel.write(response.getOutputStream(), ComparisonRecordVO.class).sheet("上传记录").doWrite(voList);
}
comparisonTaskLogService.createTaskLogByTaskIdAndUserId(taskId, currentUserId);
} catch (IOException e) {
log.error(" ================== exception as {} ==================", e.getMessage());
} finally {
redisUtils.del(lockKey);
}
}
}
}

@ -2,33 +2,24 @@ package com.baiye.modules.scrm.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpStatus;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import com.baiye.constant.DefaultNumberConstants;
import com.baiye.constant.url.WeChatPersonRequest;
import com.baiye.domain.PageParam;
import com.baiye.domain.PageResult;
import com.baiye.extend.mybatis.plus.service.impl.ExtendServiceImpl;
import com.baiye.extend.mybatis.plus.toolkit.WrappersX;
import com.baiye.modules.scrm.dto.WeChatOnlineStatusDTO;
import com.baiye.modules.scrm.dto.PacketDTO;
import com.baiye.modules.scrm.entity.LoginEquipment;
import com.baiye.modules.scrm.mapper.LoginEquipmentMapper;
import com.baiye.modules.scrm.qo.AccountQo;
import com.baiye.modules.scrm.service.LoginEquipmentService;
import com.baiye.modules.scrm.vo.WeChatAccountVO;
import com.baiye.modules.scrm.vo.WeChatAddFriendVo;
import com.baiye.result.WeChatResponse;
import com.baiye.security.util.SecurityUtils;
import com.baiye.system.properties.WeChatProperties;
import com.google.common.collect.ImmutableMap;
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
* @author Enzo
@ -40,30 +31,12 @@ import java.util.Map;
public class LoginEquipmentServiceImpl extends ExtendServiceImpl<LoginEquipmentMapper, LoginEquipment> implements
LoginEquipmentService {
private final WeChatProperties weChatProperties;
@Override
public PageResult<WeChatAccountVO> queryPage(PageParam pageParam, AccountQo qo) {
qo.setUserId(SecurityUtils.getCurrentUserId());
PageResult<WeChatAccountVO> queryPage = baseMapper.queryPage(pageParam, qo);
/*queryPage.getRecords().forEach(accountVO -> {
// 默认离线状态
accountVO.setStatus(DefaultNumberConstants.TWO_NUMBER);
if (StringUtils.isNotBlank(accountVO.getWxId())) {
Map<String, Object> map = ImmutableMap.of
("wechat", accountVO.getWxId(), "loginType", DefaultNumberConstants.ONE_NUMBER, "needDetailInfo", Boolean.FALSE);
String result = HttpUtil.post
(weChatProperties.getRequestUrl().concat(WeChatPersonRequest.ONLINE_STATUS), map);
log.info("================= the response as {} =================", result);
if (JSONUtil.isTypeJSON(result)) {
WeChatResponse weChatResponse = JSONUtil.toBean(result, WeChatResponse.class);
WeChatOnlineStatusDTO statusDTO = JSONUtil.toBean(JSONUtil.toJsonStr(weChatResponse.getData()), WeChatOnlineStatusDTO.class);
accountVO.setStatus(statusDTO.getStatus());
}
}
});*/
return queryPage;
return baseMapper.queryPage(pageParam, qo);
}
@Override
@ -106,5 +79,25 @@ public class LoginEquipmentServiceImpl extends ExtendServiceImpl<LoginEquipmentM
return baseMapper.selectListByTime(DateUtil.date());
}
@Override
public Boolean deleteByGroupId(Long groupId) {
return SqlHelper.retBool(baseMapper.deleteByGroupId(groupId));
}
@Override
public Boolean updatePacketById(PacketDTO dto) {
return SqlHelper.retBool(baseMapper.updatePacketById(dto.getIdList(),dto.getPacketId()));
}
@Override
public Long countByRobotId(Long id) {
return baseMapper.countByRobotId(id);
}
@Override
public List<WeChatAccountVO> queryByPacketId(Long id) {
return baseMapper.queryByPacketId(id);
}
}

@ -0,0 +1,96 @@
package com.baiye.modules.scrm.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.baiye.domain.PageParam;
import com.baiye.domain.PageResult;
import com.baiye.exception.BadRequestException;
import com.baiye.extend.mybatis.plus.service.impl.ExtendServiceImpl;
import com.baiye.modules.scrm.entity.RobotGroup;
import com.baiye.modules.scrm.mapper.RobotGroupMapper;
import com.baiye.modules.scrm.qo.RobotGroupQo;
import com.baiye.modules.scrm.service.LoginEquipmentService;
import com.baiye.modules.scrm.service.RobotGroupService;
import com.baiye.modules.scrm.vo.RobotGroupVO;
import com.baiye.modules.scrm.vo.WeChatAccountVO;
import com.baiye.security.util.SecurityUtils;
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
import com.google.common.collect.Maps;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* @author Enzo
* @date : 2024/8/14
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class RobotGroupServiceImpl extends ExtendServiceImpl<RobotGroupMapper, RobotGroup> implements RobotGroupService {
private final RobotGroupMapper robotGroupMapper;
private final LoginEquipmentService loginEquipmentService;
@Override
public PageResult<RobotGroupVO> queryPage(PageParam pageParam, RobotGroupQo qo) {
PageResult<RobotGroupVO> pageResult = robotGroupMapper.queryPage(pageParam, qo);
pageResult.getRecords().forEach(record -> record.setAccountNum(loginEquipmentService.countByRobotId(record.getId())));
return pageResult;
}
@Override
public List<RobotGroupVO> queryByUserId(Long currentUserId) {
List<RobotGroupVO> groupVOList = robotGroupMapper.selectListByUserId(currentUserId);
for (RobotGroupVO groupVO : groupVOList) {
List<WeChatAccountVO> voList = loginEquipmentService.queryByPacketId(groupVO.getId());
Map<String, Object> map = Maps.newConcurrentMap();
Iterator<WeChatAccountVO> iterator = voList.iterator();
while (iterator.hasNext()) {
WeChatAccountVO vo = iterator.next();
if (StringUtils.isBlank(vo.getWxId())) {
iterator.remove();
continue;
}
if (map.containsKey(vo.getWxId())) {
iterator.remove();
}
map.put(vo.getWxId(), vo.getWxId());
}
groupVO.setChildren(voList);
}
return groupVOList;
}
@Override
public Boolean create(RobotGroup entity) {
List<RobotGroup> byName = robotGroupMapper.findByName(entity.getName(), SecurityUtils.getCurrentUserId());
if (CollUtil.isNotEmpty(byName)) {
throw new BadRequestException("该名称已存在!");
}
entity.setUserId(SecurityUtils.getCurrentUserId());
return this.save(entity);
}
@Override
public Boolean update(RobotGroup entity) {
List<RobotGroup> byName = robotGroupMapper.findByName(entity.getName(), SecurityUtils.getCurrentUserId());
if (CollUtil.isNotEmpty(byName)) {
throw new BadRequestException("该名称已存在!");
}
return this.updateById(entity);
}
@Override
public Boolean del(Long groupId) {
loginEquipmentService.deleteByGroupId(groupId);
return SqlHelper.retBool(baseMapper.deleteById(groupId));
}
}

@ -2,25 +2,23 @@ package com.baiye.modules.scrm.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.net.URLEncodeUtil;
import cn.hutool.core.text.CharPool;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.text.StrPool;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.extra.emoji.EmojiUtil;
import cn.hutool.http.HttpStatus;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import com.baiye.constant.AddFriendConstant;
import com.baiye.constant.DefaultNumberConstants;
import com.baiye.constant.enums.ResponseCode;
import com.baiye.constant.url.WeChatAccountRequest;
import com.baiye.constant.url.WeChatFriendRequest;
import com.baiye.constant.url.WeChatPersonRequest;
import com.baiye.constant.url.WeChatSendMessageRequest;
import com.baiye.constant.url.*;
import com.baiye.domain.PageParam;
import com.baiye.domain.PageResult;
import com.baiye.enums.PackageEnum;
@ -52,6 +50,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.LinkedMultiValueMap;
import java.util.List;
import java.util.Map;
@ -128,6 +127,8 @@ public class WeChatServiceImpl implements WeChatService {
friedRecord.setAddFriendId(addFriendId);
friedRecord.setRobotWxId(weChatFriendDTO.getWechat());
friedRecord.setAddStatus(DefaultNumberConstants.ZERO_NUMBER);
friedRecord.setAddFriendType(DefaultNumberConstants.ONE_NUMBER);
friedRecord.setNickName(EmojiUtil.toAlias(friedRecord.getNickName()));
activeAddFriendService.save(friedRecord);
// 添加成功
return DefaultNumberConstants.ONE_NUMBER;
@ -149,13 +150,16 @@ public class WeChatServiceImpl implements WeChatService {
}
@Override
public Boolean createEquipment(Integer num, Long userId) {
long pit = IdUtil.getSnowflake().nextId();
// 创建账号
LoginEquipment equipment = new LoginEquipment();
equipment.setUserId(userId);
equipment.setPit(String.valueOf(pit));
loginEquipmentService.save(equipment);
public Boolean createEquipment(Integer num, Long packetId, Long currentUserId) {
for (int i = 0; i < num; i++) {
long pit = IdUtil.getSnowflake().nextId();
// 创建账号
LoginEquipment equipment = new LoginEquipment();
equipment.setPacketId(packetId);
equipment.setUserId(currentUserId);
equipment.setPit(String.valueOf(pit));
loginEquipmentService.save(equipment);
}
return Boolean.TRUE;
}
@ -391,18 +395,17 @@ public class WeChatServiceImpl implements WeChatService {
}
@Override
public Boolean sendTextMessage(List<String> passGreetMessage, String toUserName, String fromUserName) {
for (String sendMessage : passGreetMessage) {
if (StringUtils.isNotBlank(sendMessage)) {
Map<String, Object> map = ImmutableMap.of("wechat", toUserName,
"content", sendMessage, "tagetWxId", fromUserName);
String result = HttpUtil.post
(weChatProperties.getRequestUrl().concat(WeChatSendMessageRequest.SEND_TEXT_MESSAGE), map);
if (JSONUtil.isTypeJSON(result)) {
WeChatResponse weChatResponse = JSONUtil.toBean(result, WeChatResponse.class);
if (weChatResponse.getStatus() == HttpStatus.HTTP_OK) {
return Boolean.TRUE;
}
public Boolean sendTextMessage(String message, String toUserName, String fromUserName) {
if (StringUtils.isNotBlank(message)) {
Map<String, Object> map = ImmutableMap.of("wechat", toUserName,
"content", message, "tagetWxId", fromUserName);
String result = HttpUtil.post
(weChatProperties.getRequestUrl().concat(WeChatSendMessageRequest.SEND_TEXT_MESSAGE), map);
log.info("========== the send text message as {} ==========", result);
if (JSONUtil.isTypeJSON(result)) {
WeChatResponse weChatResponse = JSONUtil.toBean(result, WeChatResponse.class);
if (weChatResponse.getStatus() == HttpStatus.HTTP_OK) {
return Boolean.TRUE;
}
}
}
@ -492,4 +495,106 @@ public class WeChatServiceImpl implements WeChatService {
return Boolean.FALSE;
}
@Override
public Boolean sendPictureMessage(String passGreetMessage, String wxId, String fromUserName) {
if (StringUtils.isNotBlank(passGreetMessage)) {
Map<String, Object> map = ImmutableMap.of("wechat", wxId,
"parhUrl", passGreetMessage, "tagetWxId", fromUserName);
String result = HttpUtil.post
(weChatProperties.getRequestUrl().concat(WeChatSendMessageRequest.SEND_PICTURE_MESSAGE), map);
log.info("========== the picture text message as {} ==========", result);
if (JSONUtil.isTypeJSON(result)) {
WeChatResponse weChatResponse = JSONUtil.toBean(result, WeChatResponse.class);
if (weChatResponse.getStatus() == HttpStatus.HTTP_OK) {
return Boolean.TRUE;
}
}
}
return Boolean.FALSE;
}
@Override
public WechatMemberDTO queryByWechatId(String wxId, String targetWechat) {
Map<String, Object> map = ImmutableMap.of("wechat", wxId,
"targetWx", targetWechat, "type", DefaultNumberConstants.ONE_NUMBER);
String result = HttpUtil.post((weChatProperties.getRequestUrl()
.concat(WeChatAccountRequest.WE_CHAT_FRIEND_INFO)), map);
log.info("============== the request friend info as {} ==============", result);
if (JSONUtil.isTypeJSON(result)) {
WeChatResponse weChatResponse = JSONUtil.toBean(result, WeChatResponse.class);
if (weChatResponse.getStatus() == HttpStatus.HTTP_OK) {
if (ObjectUtil.isNotNull(weChatResponse.getData())) {
String jsonStr = JSONUtil.toJsonStr(weChatResponse.getData());
return JSONUtil.toBean(jsonStr, WechatMemberDTO.class);
}
}
}
return null;
}
@Override
public Boolean sendTextCircleFriends(String wechat, List<String> pictures, String title, List<String> comments, List<String> blackList, List<String> labelIds) {
Map<String, Object> hashMap = Maps.newHashMap();
hashMap.put("wechat", wechat);
hashMap.put("pictures[]", StringUtils.join(pictures, CharPool.COMMA));
hashMap.put("title", title);
hashMap.put("comments[]", comments);
hashMap.put("blackList", StringUtils.join(blackList, CharPool.COMMA));
hashMap.put("labelIds", StringUtils.join(labelIds, CharPool.COMMA));
String result = HttpUtil.post((weChatProperties.getRequestUrl()
.concat(WechatCircleFriendRequest.TEXT_CIRCLE_FRIEND)), hashMap);
log.info("============== the send circle friend as {} ==============", result);
if (JSONUtil.isTypeJSON(result)) {
WeChatResponse weChatResponse = JSONUtil.toBean(result, WeChatResponse.class);
if (weChatResponse.getStatus() == HttpStatus.HTTP_OK) {
return Boolean.TRUE;
}
}
return Boolean.FALSE;
}
@Override
public Boolean sendVideoCircleFriends(String wechat, String reqUrl, String content, String coverUrl, List<String> comments, List<String> blackList, List<String> labelIds) {
Map<String, Object> hashMap = Maps.newHashMap();
hashMap.put("wechat", wechat);
hashMap.put("reqUrl", reqUrl);
hashMap.put("content", content);
hashMap.put("coverUrl", coverUrl);
hashMap.put("comments[]", comments);
hashMap.put("blackList", StringUtils.join(blackList, CharPool.COMMA));
hashMap.put("labelIds", StringUtils.join(labelIds, CharPool.COMMA));
String result = HttpUtil.post((weChatProperties.getRequestUrl()
.concat(WechatCircleFriendRequest.VIDEO_CIRCLE_FRIEND)), hashMap);
log.info("============== the send video circle friend as {} ==============", result);
if (JSONUtil.isTypeJSON(result)) {
WeChatResponse weChatResponse = JSONUtil.toBean(result, WeChatResponse.class);
if (weChatResponse.getStatus() == HttpStatus.HTTP_OK) {
return Boolean.TRUE;
}
}
return Boolean.FALSE;
}
@Override
public Boolean sendLinkCircleFriends(String wechat, String reqUrl, String title, String content, String coverUrl, List<String> comments, List<String> blackList, List<String> labelIds) {
Map<String, Object> hashMap = Maps.newHashMap();
hashMap.put("wechat", wechat);
hashMap.put("reqUrl", reqUrl);
hashMap.put("title", title);
hashMap.put("content", content);
hashMap.put("coverUrl", coverUrl);
hashMap.put("comments[]", comments);
hashMap.put("blackList", StringUtils.join(blackList, CharPool.COMMA));
hashMap.put("labelIds", StringUtils.join(labelIds, CharPool.COMMA));
String result = HttpUtil.post((weChatProperties.getRequestUrl()
.concat(WechatCircleFriendRequest.VIDEO_CIRCLE_FRIEND)), hashMap);
log.info("============== the send link circle friend as {} ==============", result);
if (JSONUtil.isTypeJSON(result)) {
WeChatResponse weChatResponse = JSONUtil.toBean(result, WeChatResponse.class);
if (weChatResponse.getStatus() == HttpStatus.HTTP_OK) {
return Boolean.TRUE;
}
}
return Boolean.FALSE;
}
}

@ -1,6 +1,8 @@
package com.baiye.modules.scrm.service.impl;
import cn.hutool.core.convert.Convert;
import com.baiye.extend.mybatis.plus.service.impl.ExtendServiceImpl;
import com.baiye.modules.scrm.dto.PacketDTO;
import com.baiye.modules.scrm.entity.WeChatAccount;
import com.baiye.modules.scrm.mapper.WeChatAccountMapper;
import com.baiye.modules.scrm.service.WechatAccountService;
@ -10,6 +12,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.List;
/**
@ -50,4 +53,14 @@ public class WechatAccountServiceImpl extends ExtendServiceImpl
public Long getCountByCustomerId(Long customerId) {
return baseMapper.selectCountByCustomerId(customerId);
}
@Override
public List<WeChatAccountVO> queryByWeChatId(List<String> executeWechatList) {
return baseMapper.selectListByWechatId(executeWechatList);
}
@Override
public Boolean updatePacketById(PacketDTO dto) {
return SqlHelper.retBool(baseMapper.updatePacketIdByList(dto.getIdList(), dto.getPacketId()));
}
}

@ -141,6 +141,7 @@ public class WechatCallbackServiceImpl implements WechatCallbackService {
WeChatAccount byWxId = weChatService.findByWxId(wxId);
if (ObjectUtil.isNotNull(byWxId) && ObjectUtil.isNotNull(byWxId.getId())) {
for (GroupCallbackDTO dto : groupCallbackDTOList) {
log.info("========= the group id as {} ===========",dto.getUserName());
Long syncedGroup = weChatGroupService.syncGroup(byWxId, dto);
// 插入群
if (syncedGroup > DefaultNumberConstants.ZERO_NUMBER
@ -215,6 +216,7 @@ public class WechatCallbackServiceImpl implements WechatCallbackService {
String groupJson
= weChatGroupService.queryGroupUserList(weChatResponse.getWxId(), wechatMemberDTO.getUserName());
List<GroupCallbackDTO> groupCallbackDTOList = JSONUtil.toList(groupJson, GroupCallbackDTO.class);
// 异步方式同步群成员信息
CompletableFuture.runAsync(() -> syncGroupMember(weChatResponse.getWxId(), groupCallbackDTOList));
continue;

@ -4,7 +4,6 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baiye.constant.DefaultNumberConstants;
import com.baiye.domain.PageResult;
import com.baiye.enums.StatisticsEnum;
@ -54,7 +53,7 @@ public class WechatFriendServiceImpl extends ExtendServiceImpl
for (WeChatAccountVO vo : voList) {
Long count = this.baseMapper.selectCount(WrappersX.lambdaQueryX(WeChatFriedRecord.class).eq
(WeChatFriedRecord::getRobotWxId, weChatFriendDTO.getRobotWxId()).eq
(WeChatFriedRecord::getFriendId, weChatFriendDTO.getFriendId()).eq(WeChatFriedRecord::getUserId, vo.getUserId()));
(WeChatFriedRecord::getFriendId, weChatFriendDTO.getFriendId()).eq(WeChatFriedRecord::getUserId, vo.getUserId()));
if (count == DefaultNumberConstants.ZERO_NUMBER &&
vo.getWxId().equals(weChatFriendDTO.getRobotWxId())) {
WeChatFriedRecord weChatFriedRecord = new WeChatFriedRecord();

@ -71,31 +71,28 @@ public class WechatGroupServiceImpl extends ExtendServiceImpl
@Override
public Long syncGroup(WeChatAccount byWxId, GroupCallbackDTO dto) {
if (StringUtils.isNotBlank(dto.getNickName())) {
WeChatGroup weChatGroup = this.baseMapper.queryByUsername(dto.getUserName());
if (ObjectUtil.isNull(weChatGroup) || ObjectUtil.isNull(weChatGroup.getId())) {
// 雪花算法id
long groupId = IdUtil.getSnowflake(workerId, datacenterId).nextId();
weChatGroup = new WeChatGroup();
weChatGroup.setId(groupId);
weChatGroup.setUserId(byWxId.getUserId());
weChatGroup.setWechatId(byWxId.getWxId());
weChatGroup.setChatRoomId(dto.getUserName());
weChatGroup.setChatRoomNick(dto.getNickName());
weChatGroup.setChatRoomIcon
(StringUtils.isEmpty(dto.getBigHeadImgUrl()) ? dto.getSmallHeadImgUrl() : dto.getBigHeadImgUrl());
weChatGroup.setChatRoomOwner(dto.getChatRoomOwner());
this.save(weChatGroup);
return groupId;
}
WeChatGroup weChatGroup = this.baseMapper.queryByUsername(dto.getUserName());
if (ObjectUtil.isNull(weChatGroup) || ObjectUtil.isNull(weChatGroup.getId())) {
// 雪花算法id
long groupId = IdUtil.getSnowflake(workerId, datacenterId).nextId();
weChatGroup = new WeChatGroup();
weChatGroup.setId(groupId);
weChatGroup.setUserId(byWxId.getUserId());
weChatGroup.setWechatId(byWxId.getWxId());
weChatGroup.setChatRoomId(dto.getUserName());
weChatGroup.setChatRoomNick(dto.getNickName());
weChatGroup.setChatRoomIcon
(StringUtils.isEmpty(dto.getBigHeadImgUrl()) ? dto.getSmallHeadImgUrl() : dto.getBigHeadImgUrl());
weChatGroup.setChatRoomOwner(dto.getChatRoomOwner());
this.updateById(weChatGroup);
return weChatGroup.getId();
this.save(weChatGroup);
return groupId;
}
return (long) DefaultNumberConstants.ZERO_NUMBER;
weChatGroup.setChatRoomNick(StringUtils.isNotBlank(dto.getNickName()) ? dto.getNickName() : "群聊");
weChatGroup.setChatRoomIcon
(StringUtils.isEmpty(dto.getBigHeadImgUrl()) ? dto.getSmallHeadImgUrl() : dto.getBigHeadImgUrl());
weChatGroup.setChatRoomOwner(dto.getChatRoomOwner());
this.updateById(weChatGroup);
return weChatGroup.getId();
}
@Override

@ -90,4 +90,7 @@ public class AddFriendTaskVO {
private List<String> executeWechatList;
@Schema(title = "执行微信号昵称")
private List<String> executeWechatNicknameList;
}

@ -0,0 +1,66 @@
package com.baiye.modules.scrm.vo;
import com.baiye.extend.mybatis.plus.converter.JsonStringArrayTypeHandler;
import com.baiye.validation.group.UpdateGroup;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;
/**
* @author Enzo
* @date : 2024/8/20
*/
@Data
public class CircleFriendTaskVO {
@TableId(type = IdType.AUTO)
@Schema(title = "ID")
@NotNull(message = "ID不能为空", groups = { UpdateGroup.class })
private Long id;
@Schema(title = "任务名称")
private String taskName;
@Schema(title = "标题")
private String title;
@Schema(title = "发送状态")
private Integer sendStatus;
@Schema(title = "用户ID")
private Long userId;
@Schema(title = "内容")
private String content;
@Schema(title = "类型")
private Integer type;
@Schema(title = "延后时间")
private Integer deferredTime;
@Schema(title = "延后评论")
private String deferredComment;
@Schema(title = "是否现在执行")
private Boolean isNow;
@Schema(title = "执行时间")
private Date executionTime;
@Schema(title = "资源地址")
private String sourcePath;
@Schema(title = "图片地址")
private List<String> pictureList;
@Schema(title = "执行微信号")
private List<String> executeWechatList;
}

@ -0,0 +1,28 @@
package com.baiye.modules.scrm.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentFontStyle;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
import lombok.Data;
/**
* @author Enzo
* @date : 2024/8/19
*/
@Data
@HeadRowHeight(30)
@ContentRowHeight(15)
@ColumnWidth(18)
@ContentFontStyle(fontHeightInPoints = (short) 12)
public class ComparisonRecordVO {
@ExcelProperty("小红书ID")
@ColumnWidth(20)
private String redBookId;
}

@ -0,0 +1,64 @@
package com.baiye.modules.scrm.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentFontStyle;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
import lombok.Getter;
import lombok.Setter;
import java.util.Date;
/**
* @author Enzo
* @date : 2024/8/19
*/
@Getter
@Setter
@HeadRowHeight(30)
@ContentRowHeight(15)
@ColumnWidth(18)
@ContentFontStyle(fontHeightInPoints = (short) 12)
public class ComparisonSummaryVO {
@ExcelProperty("id")
@ColumnWidth(20)
private Long id;
@ExcelProperty("收集日期")
@ColumnWidth(20)
private String dateStr;
@ExcelProperty(value = "上传日期")
@ColumnWidth(20)
@DateTimeFormat("yyyy-MM-dd")
private Date createTime;
@ExcelProperty(value = "建模日期")
@ColumnWidth(20)
@DateTimeFormat("yyyy-MM-dd")
private Date conversionTime;
@ExcelProperty(value = "小红书ID")
@ColumnWidth(20)
private String redBookId;
@ExcelProperty(value = "小红书号")
@ColumnWidth(20)
private String redBookNo;
@ExcelProperty(value = "项目")
@ColumnWidth(20)
private String photograph;
@ExcelProperty(value = "对标医生/机构")
@ColumnWidth(20)
private String institution;
@ExcelProperty(value = "手机号")
@ColumnWidth(20)
private String comparisonResult;
}

@ -0,0 +1,52 @@
package com.baiye.modules.scrm.vo;
import com.baiye.validation.group.UpdateGroup;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
/**
* @author Enzo
* @date : 2024/8/19
*/
@Data
public class ComparisonTaskVO {
@TableId(type = IdType.INPUT)
@Schema(title = "线索ID")
@NotNull(message = "分发ID不能为空", groups = {UpdateGroup.class})
private Long id;
@Schema(title = "任务名称")
private String taskName;
@Schema(title = "用户ID")
private Long userId;
@Schema(title = "父类ID")
private Long parentId;
@Schema(title = "线索备注")
private String remark;
@Schema(title = "是否下载完成")
private Boolean isDown;
@Schema(title = "是否完成")
private Boolean isComplete;
@Schema(title = "创建时间")
private LocalDateTime createTime;
@Schema(title = "修改时间")
private LocalDateTime updateTime;
}

@ -0,0 +1,57 @@
package com.baiye.modules.scrm.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author Enzo
* @date : 2024/6/2
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ComparisonVO {
/**
*
*/
@ExcelProperty(value = "日期")
private String dateStr;
/**
* ID
*/
@ExcelProperty(value = "小红书ID")
private String redBookId;
/**
*
*/
@ExcelProperty(value = "小红书号")
private String redBookNo;
/**
*
*/
@ExcelProperty(value = "项目")
private String photograph;
/**
*
*/
@ExcelProperty(value = "对标医生/机构")
private String institution;
/**
*
*/
@ExcelProperty(value = "手机号")
private String phone;
}

@ -0,0 +1,42 @@
package com.baiye.modules.scrm.vo;
import com.baiye.validation.group.UpdateGroup;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* @author Enzo
*
*/
@Data
public class RobotGroupVO {
@TableId(type = IdType.AUTO)
@Schema(title = "分组ID")
@NotNull(message = "分组ID", groups = {UpdateGroup.class})
private Long id;
@Schema(title = "user_id")
private Long userId;
@Schema()
private Integer groupType;
@Schema(title = "name")
private String name;
@Schema
private String remark;
private Long accountNum;
private List<WeChatAccountVO> children;
}

@ -14,13 +14,15 @@ import java.util.Date;
public class WeChatAccountVO {
@Schema(title = "id")
private Long id;
@Schema(title = "用户id")
private Long userId;
@Schema(title = "分组ID")
private Long packetId;
@Schema(title = "设备信息")
private String deviceInformation;
@ -55,7 +57,7 @@ public class WeChatAccountVO {
@Schema(name = "拥有者")
private Long ownerId;
@Schema(name = "微信号")
@Schema(name = "别名")
private String alias;
@ -94,4 +96,7 @@ public class WeChatAccountVO {
@Schema(title = "标签数")
private Integer labelNum;
@Schema(title = "客服ID")
private Long customerId;
}

@ -1,25 +1,23 @@
package com.baiye.schedule.handler;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.text.StrPool;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.http.HttpUtil;
import com.baiye.common.job.handler.ElasticJobHandler;
import com.baiye.constant.DefaultNumberConstants;
import com.baiye.constant.url.WeChatFriendRequest;
import com.baiye.modules.scrm.dto.WeChatAddFriendDTO;
import com.baiye.modules.scrm.entity.AddFriend;
import com.baiye.modules.scrm.entity.AddFriendFrequentlyRecord;
import com.baiye.modules.scrm.entity.AddFriendTask;
import com.baiye.modules.scrm.mapper.AddFriendTaskMapper;
import com.baiye.modules.scrm.service.ActiveAddFriendService;
import com.baiye.modules.scrm.service.AddFriendFrequentlyRecordService;
import com.baiye.modules.scrm.service.AddFriendService;
import com.baiye.modules.scrm.service.WeChatService;
import com.baiye.util.CronUtil;
import com.baiye.validation.ValidationUtil;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import lombok.RequiredArgsConstructor;
@ -30,6 +28,7 @@ import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
/**
* @author Enzo
* @date : 2024/6/2
@ -41,6 +40,8 @@ public class AddFriendJob implements SimpleJob {
private final AddFriendFrequentlyRecordService addFriendFrequentlyRecordService;
private final ActiveAddFriendService activeAddFriendService;
private final AddFriendTaskMapper addFriendTaskMapper;
private final ElasticJobHandler elasticJobHandler;
@ -74,7 +75,8 @@ public class AddFriendJob implements SimpleJob {
DateUtil.offsetMinute(byTaskId.getLastExecutionTime(), byTaskId.getAddIntervalStart()).after(now)) {
return;
}
Long countByDate = addFriendService.countByTaskAndDate(taskId, DateUtil.beginOfDay(now), DateUtil.endOfDay(now));
Long countByDate = activeAddFriendService.countByTaskAndDate
(taskId, DateUtil.beginOfDay(now), DateUtil.endOfDay(now));
long dayLimit = byTaskId.getAddFriendMax() - countByDate;
if (dayLimit > DefaultNumberConstants.ZERO_NUMBER) {
// 查询资源
@ -100,15 +102,15 @@ public class AddFriendJob implements SimpleJob {
// 添加好友
WeChatAddFriendDTO addFriendDTO = WeChatAddFriendDTO.builder().wechat
(addFriend.getTrumpetWechat()).tagetWxId(addFriend.getTargetWechat()).helloContent
(StringUtils.isNotBlank(addFriend.getGreet()) ? addFriend.getGreet() : "你好,很高兴认识你!" ).type(addFriend.getTargetWechat().length() == DefaultNumberConstants.ELEVEN_NUMBER ?
DefaultNumberConstants.FIFTEEN_NUMBER : DefaultNumberConstants.THREE_NUMBER).build();
(StringUtils.isNotBlank(addFriend.getGreet()) ? addFriend.getGreet() : "你好,很高兴认识你!").type
(ValidationUtil.isNumber(addFriend.getTargetWechat()) ? DefaultNumberConstants.FIFTEEN_NUMBER : DefaultNumberConstants.THREE_NUMBER).build();
Integer addedFriend = weChatService.addFriend(Long.parseLong(taskId), addFriend.getId(), addFriendDTO);
addFriend.setAddStatus(addedFriend);
addFriend.setExecutionTime(DateUtil.date());
addFriendService.updateById(addFriend);
}
String generatedCronByTime = CronUtil.generateCronByTime
(byTaskId.getStartTime(), byTaskId.getEndTime(), byTaskId.getAddIntervalStart(), byTaskId.getAddIntervalEnd(),byTaskId.getLastExecutionTime());
(byTaskId.getStartTime(), byTaskId.getEndTime(), byTaskId.getAddIntervalStart(), byTaskId.getAddIntervalEnd(), byTaskId.getLastExecutionTime());
// 修改定时任务随机时间
elasticJobHandler.updateJob(jobName, generatedCronByTime);
// 修改最后执行时间
@ -119,5 +121,4 @@ public class AddFriendJob implements SimpleJob {
}
log.info("{}定时添加好友end...", DateUtil.format(new Date(), DatePattern.NORM_DATETIME_MS_PATTERN));
}
}

@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUtil;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.Date;

@ -0,0 +1,59 @@
package com.baiye.schedule.handler;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baiye.constant.DefaultNumberConstants;
import com.baiye.modules.scrm.entity.CircleFriendTask;
import com.baiye.modules.scrm.mapper.CircleFriendTaskMapper;
import com.baiye.modules.scrm.service.WeChatService;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import java.util.Collections;
import java.util.Date;
/**
* @author Enzo
* @date : 2024/8/16
*/
@Slf4j
@Component
@RequiredArgsConstructor
public class SendCircleFriendTaskJob implements SimpleJob {
private final WeChatService weChatService;
private final CircleFriendTaskMapper circleFriendTaskMapper;
@Override
public void execute(ShardingContext shardingContext) {
Date now = DateUtil.date();
String jobName = shardingContext.getJobName();
String taskId = shardingContext.getJobParameter();
log.info("{}定时发送朋友圈start task name {} task id {} ...", DateUtil.format(now, DatePattern.NORM_DATETIME_MS_PATTERN), jobName, taskId);
if (ObjectUtil.isNotNull(taskId)) {
CircleFriendTask circleFriendTask = circleFriendTaskMapper.selectById(Long.parseLong(taskId));
if (ObjectUtil.isNotNull(circleFriendTask) && ObjectUtil.isNotNull(circleFriendTask.getId())) {
// 判断是否过期
if (circleFriendTask.getExecutionTime().before(now)) {
circleFriendTask.setSendStatus(DefaultNumberConstants.ONE_NUMBER);
circleFriendTaskMapper.updateById(circleFriendTask);
return;
}
for (String targetWechat : circleFriendTask.getExecuteWechatList()) {
Boolean result = weChatService.sendTextCircleFriends
(targetWechat, circleFriendTask.getPictureList(), circleFriendTask.getTitle(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList());
log.info("============= send text circle friends {} success {} ============", targetWechat, result);
}
circleFriendTask.setSendStatus(DefaultNumberConstants.ONE_NUMBER);
circleFriendTaskMapper.updateById(circleFriendTask);
}
}
log.info("{}定时发送朋友圈end...", DateUtil.format(new Date(), DatePattern.NORM_DATETIME_MS_PATTERN));
}
}

@ -5,7 +5,7 @@ spring:
password: 'k12BDmcsvk.'
redis:
host: localhost
password:
password: 5FyJUj35jnzy
port: 6379
@ -49,4 +49,4 @@ minio:
feign:
request:
url: http://127.0.0.1:8082
url: http://172.17.34.99:8082

@ -15,6 +15,7 @@
le.create_time,
le.update_time,
wa.user_id,
wa.packet_id,
le.id,
le.pit,
le.robot_id,
@ -46,6 +47,10 @@
<if test="endTime != null">
and wa.create_time &lt;= #{endTime,jdbcType=TIMESTAMP}
</if>
<if test="packetId != null">
and wa.packet_id = #{packetId,jdbcType=BIGINT}
</if>
order by le.id desc
</select>
@ -79,4 +84,17 @@
LEFT join tb_wechat_account wa on wa.id = we.account_id
where wa.wx_id = #{wxId}
</select>
<select id="queryByPacketId" resultType="com.baiye.modules.scrm.vo.WeChatAccountVO">
SELECT
<include refid="Base_Alias_Column_List"/>
FROM
tb_login_equipment le
LEFT JOIN ( SELECT equipment_id, max( create_time ) AS min_binding_time FROM tb_wechat_equipment GROUP BY equipment_id ) min_binding ON le.id = min_binding.equipment_id
LEFT JOIN tb_wechat_equipment we ON le.id = we.equipment_id
AND we.create_time = min_binding.min_binding_time
LEFT JOIN tb_wechat_account wa ON wa.id = we.account_id
where wa.packet_id = #{packetId,jdbcType=BIGINT}
order by le.id desc
</select>
</mapper>

@ -1,5 +1,11 @@
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import com.baiye.AdminApplication;
import com.baiye.constant.url.WeChatGroupRequest;
import com.baiye.modules.customer.feign.CustomerInfoFeign;
import com.baiye.system.properties.WeChatProperties;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
@ -8,7 +14,10 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author Enzo
@ -24,6 +33,9 @@ public class FeignTest {
@Resource
CustomerInfoFeign customerInfoFeign;
@Resource
WeChatProperties weChatProperties;
@Test
public void getSetting() {
@ -32,4 +44,30 @@ public class FeignTest {
customerInfoFeign.getUsers("aaa");
}
@Test
public void fileTest(){
List<String> newed = Lists.newArrayList();
newed.add("wxid_zbrfto9s8p7822");
String[] array = newed.toArray(new String[0]);
Map<String, Object> map = ImmutableMap.of("wechat", "wxid_mhm4bqgb9gpg21",
"groupid", "52494312484@chatroom", "members[]",array);
System.out.println(JSONUtil.toJsonStr(map));
String userListResult = HttpUtil.post
("http://test.ipad.ecofanli.com/wechat/v1/addgroup", map);
System.out.println(userListResult);
}
@Test
public void down(){
Map<String, Object> map = ImmutableMap.of("wechat", "wxid_mhm4bqgb9gpg21",
"len", "4861", "msgId","1230003955","isSync","false");
String userListResult = HttpUtil.post
("http://test.ipad.ecofanli.com/wechat/v1/downVoiceMsg", map);
System.out.println(userListResult);
}
}

@ -19,4 +19,6 @@ public class FileTest {
@Test
public void fileTest(){
}
}

@ -5,7 +5,7 @@ spring:
password: 'k12BDmcsvk.'
redis:
host: localhost
password:
password: 5FyJUj35jnzy
port: 6379
@ -49,4 +49,4 @@ minio:
feign:
request:
url: http://127.0.0.1:8082
url: http://172.17.34.99:8082

@ -15,6 +15,7 @@
le.create_time,
le.update_time,
wa.user_id,
wa.packet_id,
le.id,
le.pit,
le.robot_id,
@ -46,6 +47,10 @@
<if test="endTime != null">
and wa.create_time &lt;= #{endTime,jdbcType=TIMESTAMP}
</if>
<if test="packetId != null">
and wa.packet_id = #{packetId,jdbcType=BIGINT}
</if>
order by le.id desc
</select>
@ -79,4 +84,17 @@
LEFT join tb_wechat_account wa on wa.id = we.account_id
where wa.wx_id = #{wxId}
</select>
<select id="queryByPacketId" resultType="com.baiye.modules.scrm.vo.WeChatAccountVO">
SELECT
<include refid="Base_Alias_Column_List"/>
FROM
tb_login_equipment le
LEFT JOIN ( SELECT equipment_id, max( create_time ) AS min_binding_time FROM tb_wechat_equipment GROUP BY equipment_id ) min_binding ON le.id = min_binding.equipment_id
LEFT JOIN tb_wechat_equipment we ON le.id = we.equipment_id
AND we.create_time = min_binding.min_binding_time
LEFT JOIN tb_wechat_account wa ON wa.id = we.account_id
where wa.packet_id = #{packetId,jdbcType=BIGINT}
order by le.id desc
</select>
</mapper>

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save