提交 8e5478b2 作者: gh

延时客服排期提出实体类

上级 a5f9d5e1
package com.yaoyaozw.customer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.ThreadPoolExecutor;
/**
* @author darker
* @date 2022/8/2 15:01
*/
@Configuration
@EnableAsync
public class ThreadConfig {
/** 核心线程数(默认线程数) */
private static final int CORE_POOL_SIZE = 15;
/** 最大线程数 */
private static final int MAX_POOL_SIZE = 50;
/** 允许线程空闲时间(单位:默认为秒) */
private static final int KEEP_ALIVE_TIME = 60;
/** 缓冲队列大小 */
private static final int QUEUE_CAPACITY = 100;
/** 线程池名前缀 */
private static final String THREAD_NAME_PREFIX = "Async-Service-";
@Bean("myExecutor")
public ThreadPoolTaskExecutor myExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(CORE_POOL_SIZE);
executor.setMaxPoolSize(MAX_POOL_SIZE);
executor.setQueueCapacity(QUEUE_CAPACITY);
executor.setKeepAliveSeconds(KEEP_ALIVE_TIME);
executor.setThreadNamePrefix(THREAD_NAME_PREFIX);
// 线程池对拒绝任务的处理策略
// CallerRunsPolicy:由调用线程(提交任务的线程)处理该任务
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
// 初始化
executor.initialize();
return executor;
}
}
...@@ -4,7 +4,7 @@ import com.yaoyaozw.customer.common.BaseResult; ...@@ -4,7 +4,7 @@ import com.yaoyaozw.customer.common.BaseResult;
import com.yaoyaozw.customer.common.GenericsResult; import com.yaoyaozw.customer.common.GenericsResult;
import com.yaoyaozw.customer.dto.customer.CustomerDelayQueryDTO; import com.yaoyaozw.customer.dto.customer.CustomerDelayQueryDTO;
import com.yaoyaozw.customer.dto.customer.CustomerDelaySaveDTO; import com.yaoyaozw.customer.dto.customer.CustomerDelaySaveDTO;
import com.yaoyaozw.customer.vo.customer.DelayCustomerItemVO; import com.yaoyaozw.customer.vo.customer.CustomerDelayItemVO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -37,7 +37,7 @@ public class CustomerDelayController { ...@@ -37,7 +37,7 @@ public class CustomerDelayController {
@ApiOperation("查询") @ApiOperation("查询")
@PostMapping("/pageList") @PostMapping("/pageList")
public GenericsResult<List<DelayCustomerItemVO>> pageList(@RequestBody CustomerDelayQueryDTO queryDto) { public GenericsResult<List<CustomerDelayItemVO>> pageList(@RequestBody CustomerDelayQueryDTO queryDto) {
return new GenericsResult<>(new ArrayList<>()); return new GenericsResult<>(new ArrayList<>());
} }
......
package com.yaoyaozw.customer.entity;
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 java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* @author wgh
* @date 2022/9/28 18:51
*/
@Data
@TableName(value = "register_user_entity")
public class CustomerDelayPublish implements Serializable {
/**
* 主键
*/
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* app_id
*/
@TableField(exist = false ,value = "app_id")
private String appId;
/**
* openid
*/
@TableField(exist = false ,value = "open_id")
private String openId;
/**
* 未付费0/付费1/VIP 2
*/
@TableField(exist = false ,value= "pay_type")
private Byte payType;
/**
* 延时客服序列
*/
@TableField(value = "customer_sort")
private Integer customerSort;
/**
* 延时客服发送时间
*/
@TableField(value = "customer_publish")
private Date customerPublish;
/**
* 创建时间
*/
@TableField(exist = false ,value = "gmt_create")
private Date gmtCreate;
private static final long serialVersionUID = 1L;
public static final String COL_ID = "id";
public static final String COL_APP_ID = "app_id";
public static final String COL_OPEN_ID = "open_id";
public static final String COL_PAY_TYPE = "pay_type";
public static final String COL_CUSTOMER_SORT = "customer_sort";
public static final String COL_CUSTOMER_PUBLISH = "customer_publish";
public static final String COL_GMT_CREATE = "gmt_create";
}
\ No newline at end of file
...@@ -75,17 +75,6 @@ public class RegisterUserEntity implements Serializable { ...@@ -75,17 +75,6 @@ public class RegisterUserEntity implements Serializable {
@TableField(value = "gmt_create") @TableField(value = "gmt_create")
private Date gmtCreate; private Date gmtCreate;
/**
* 延时客服序列
*/
@TableField(value = "customer_sort")
private Integer customerSort;
/**
* 延时客服发送时间
*/
@TableField(value = "customer_publish")
private Date customerPublish;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -109,7 +98,5 @@ public class RegisterUserEntity implements Serializable { ...@@ -109,7 +98,5 @@ public class RegisterUserEntity implements Serializable {
public static final String COL_GMT_CREATE = "gmt_create"; public static final String COL_GMT_CREATE = "gmt_create";
public static final String COL_CUSTOMER_SORT = "customer_sort";
public static final String COL_CUSTOMER_PUBLISH = "customer_publish";
} }
\ No newline at end of file
...@@ -3,7 +3,10 @@ package com.yaoyaozw.customer.mapper; ...@@ -3,7 +3,10 @@ package com.yaoyaozw.customer.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yaoyaozw.customer.entity.AuthorizerToken; import com.yaoyaozw.customer.entity.AuthorizerToken;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper @Mapper
public interface AuthorizerTokenMapper extends BaseMapper<AuthorizerToken> { public interface AuthorizerTokenMapper extends BaseMapper<AuthorizerToken> {
AuthorizerToken findByAppid(@Param("appid")String appid);
} }
\ No newline at end of file
package com.yaoyaozw.customer.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yaoyaozw.customer.entity.CustomerDelayPublish;
import org.apache.ibatis.annotations.Mapper;
/**
* @author wgh
* @date 2022/9/28 18:51
*/
@Mapper
public interface CustomerDelayPublishMapper extends BaseMapper<CustomerDelayPublish> {
}
\ No newline at end of file
...@@ -3,7 +3,7 @@ package com.yaoyaozw.customer.mapper; ...@@ -3,7 +3,7 @@ package com.yaoyaozw.customer.mapper;
import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yaoyaozw.customer.entity.CustomerGraphicsDelay; import com.yaoyaozw.customer.entity.CustomerGraphicsDelay;
import com.yaoyaozw.customer.vo.customer.DelayCustomerItemVO; import com.yaoyaozw.customer.vo.customer.CustomerDelayItemVO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -20,5 +20,5 @@ public interface CustomerGraphicsDelayMapper extends BaseMapper<CustomerGraphics ...@@ -20,5 +20,5 @@ public interface CustomerGraphicsDelayMapper extends BaseMapper<CustomerGraphics
* @param appidList * @param appidList
* @return * @return
*/ */
List<DelayCustomerItemVO> findAllDelayCustomerMessage(@Param("appidList") Set<String> appidList); List<CustomerDelayItemVO> findAllDelayCustomerMessage(@Param("appidList") Set<String> appidList);
} }
\ No newline at end of file
...@@ -4,5 +4,6 @@ import com.yaoyaozw.customer.entity.AuthorizerToken; ...@@ -4,5 +4,6 @@ import com.yaoyaozw.customer.entity.AuthorizerToken;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
public interface AuthorizerTokenService extends IService<AuthorizerToken>{ public interface AuthorizerTokenService extends IService<AuthorizerToken>{
AuthorizerToken findTokenByAppid(String appid);
} }
package com.yaoyaozw.customer.service;
import com.yaoyaozw.customer.dto.integration.IntegrationRequestDTO;
import com.yaoyaozw.customer.entity.CustomerDelayPublish;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author wgh
* @date 2022/9/28 18:51
*/
public interface CustomerDelayPublishService extends IService<CustomerDelayPublish>{
public void sendCustomerDelayMessage(IntegrationRequestDTO integrationRequestDTO);
}
...@@ -2,7 +2,7 @@ package com.yaoyaozw.customer.service; ...@@ -2,7 +2,7 @@ package com.yaoyaozw.customer.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.yaoyaozw.customer.entity.CustomerGraphicsDelay; import com.yaoyaozw.customer.entity.CustomerGraphicsDelay;
import com.yaoyaozw.customer.vo.customer.DelayCustomerItemVO; import com.yaoyaozw.customer.vo.customer.CustomerDelayItemVO;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
...@@ -13,6 +13,6 @@ import java.util.Set; ...@@ -13,6 +13,6 @@ import java.util.Set;
*/ */
public interface CustomerGraphicsDelayService extends IService<CustomerGraphicsDelay> { public interface CustomerGraphicsDelayService extends IService<CustomerGraphicsDelay> {
List<DelayCustomerItemVO> findAllDelayCustomerMessage(Set<String> appidList); List<CustomerDelayItemVO> findAllDelayCustomerMessage(Set<String> appidList);
} }
...@@ -11,7 +11,4 @@ public interface RegisterUserEntityService extends IService<RegisterUserEntity>{ ...@@ -11,7 +11,4 @@ public interface RegisterUserEntityService extends IService<RegisterUserEntity>{
void sendCustomerMessage(IntegrationRequestDTO integrationRequestDTO); void sendCustomerMessage(IntegrationRequestDTO integrationRequestDTO);
void sendCustomerDelayMessage(IntegrationRequestDTO integrationRequestDTO);
} }
...@@ -10,4 +10,10 @@ import com.yaoyaozw.customer.service.AuthorizerTokenService; ...@@ -10,4 +10,10 @@ import com.yaoyaozw.customer.service.AuthorizerTokenService;
@Service @Service
public class AuthorizerTokenServiceImpl extends ServiceImpl<AuthorizerTokenMapper, AuthorizerToken> implements AuthorizerTokenService{ public class AuthorizerTokenServiceImpl extends ServiceImpl<AuthorizerTokenMapper, AuthorizerToken> implements AuthorizerTokenService{
@Override
public AuthorizerToken findTokenByAppid(String appid) {
return baseMapper.findByAppid(appid);
}
} }
package com.yaoyaozw.customer.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yaoyaozw.customer.dto.integration.IntegrationRequestDTO;
import com.yaoyaozw.customer.entity.AuthorizerToken;
import com.yaoyaozw.customer.service.AuthorizerTokenService;
import com.yaoyaozw.customer.service.CustomerGraphicsDelayService;
import com.yaoyaozw.customer.service.wechat.service.WeChatService;
import com.yaoyaozw.customer.vo.customer.CustomerDelayItemVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.stream.Collectors;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yaoyaozw.customer.entity.CustomerDelayPublish;
import com.yaoyaozw.customer.mapper.CustomerDelayPublishMapper;
import com.yaoyaozw.customer.service.CustomerDelayPublishService;
/**
* @author wgh
* @date 2022/9/28 18:51
*/
@Service
public class CustomerDelayPublishServiceImpl extends ServiceImpl<CustomerDelayPublishMapper, CustomerDelayPublish> implements CustomerDelayPublishService{
@Autowired
private CustomerGraphicsDelayService customerGraphicsDelayService;
@Autowired
private AuthorizerTokenService authorizerTokenService;
@Autowired
private WeChatService weChatService;
@Override
public void sendCustomerDelayMessage(IntegrationRequestDTO integrationRequestDTO) {
//读取延时客服排期人
List<CustomerDelayPublish> allPostUser = list(new QueryWrapper<CustomerDelayPublish>().eq(CustomerDelayPublish.COL_CUSTOMER_PUBLISH,integrationRequestDTO.getRequestDate()));
//涉及的appid
Set<String> appidSet = allPostUser.stream().map(CustomerDelayPublish::getAppId).collect(Collectors.toSet());
if (!allPostUser.isEmpty()){
//号-用户
Map<String, List<CustomerDelayPublish>> userMap = allPostUser.stream().collect(Collectors.groupingBy(CustomerDelayPublish::getAppId));
List<CustomerDelayItemVO> allDelayCustomerMessage = customerGraphicsDelayService.findAllDelayCustomerMessage(appidSet);
/*
List<AuthorizerToken> tokenList = authorizerTokenService.list();
Map<String, String> tokenMap = tokenList.stream().collect(Collectors.toMap(AuthorizerToken::getAuthorizerAppid, AuthorizerToken::getAuthorizerAccessToken));
*/
if (allDelayCustomerMessage!=null&&!allDelayCustomerMessage.isEmpty()){
List<Future<CustomerDelayPublish>>futureList =new ArrayList<>();
//号-发送序列-客服id
Map<String, Map<Integer, CustomerDelayItemVO>> customerMap = allDelayCustomerMessage.stream().collect(Collectors.groupingBy(CustomerDelayItemVO::getAppId, Collectors.toMap(CustomerDelayItemVO::getPostSort, a -> a, (v1, v2) -> v2)));
for (Map.Entry<String, List<CustomerDelayPublish>> userEntry : userMap.entrySet()) {
String appid = userEntry.getKey();
AuthorizerToken authorizerToken = authorizerTokenService.findTokenByAppid(appid);
String token = authorizerToken.getAuthorizerAppid();
//没token过滤
if (token==null||"".equals(token)){ continue; }
//该号下延时客服
Map<Integer,CustomerDelayItemVO> delaySortMap = customerMap.get(appid);
//所有的用户
List<CustomerDelayPublish> userList = userEntry.getValue();
if (delaySortMap!=null&&!delaySortMap.isEmpty()){
for (CustomerDelayPublish userPublish : userList) {
//发送客服
futureList.add(weChatService.sendCustomerDelayMessage(token, userPublish, delaySortMap)) ;
}
}
}
List<CustomerDelayPublish> registerUserEntities = new ArrayList<>();
for (Future<CustomerDelayPublish> delayPublishFuture : futureList) {
try {
registerUserEntities.add(delayPublishFuture.get()) ;
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
}
updateBatchById(registerUserEntities);
}
}
}
}
...@@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; ...@@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yaoyaozw.customer.entity.CustomerGraphicsDelay; import com.yaoyaozw.customer.entity.CustomerGraphicsDelay;
import com.yaoyaozw.customer.mapper.CustomerGraphicsDelayMapper; import com.yaoyaozw.customer.mapper.CustomerGraphicsDelayMapper;
import com.yaoyaozw.customer.service.CustomerGraphicsDelayService; import com.yaoyaozw.customer.service.CustomerGraphicsDelayService;
import com.yaoyaozw.customer.vo.customer.DelayCustomerItemVO; import com.yaoyaozw.customer.vo.customer.CustomerDelayItemVO;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
...@@ -20,7 +20,7 @@ public class CustomerGraphicsDelayServiceImpl extends ServiceImpl<CustomerGraphi ...@@ -20,7 +20,7 @@ public class CustomerGraphicsDelayServiceImpl extends ServiceImpl<CustomerGraphi
@Override @Override
public List<DelayCustomerItemVO> findAllDelayCustomerMessage(Set<String> appidList) { public List<CustomerDelayItemVO> findAllDelayCustomerMessage(Set<String> appidList) {
return baseMapper.findAllDelayCustomerMessage(appidList); return baseMapper.findAllDelayCustomerMessage(appidList);
......
...@@ -3,10 +3,12 @@ package com.yaoyaozw.customer.service.impl; ...@@ -3,10 +3,12 @@ package com.yaoyaozw.customer.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yaoyaozw.customer.dto.integration.IntegrationRequestDTO; import com.yaoyaozw.customer.dto.integration.IntegrationRequestDTO;
import com.yaoyaozw.customer.entity.AuthorizerToken; import com.yaoyaozw.customer.entity.AuthorizerToken;
import com.yaoyaozw.customer.entity.CustomerDelayPublish;
import com.yaoyaozw.customer.service.AuthorizerTokenService; import com.yaoyaozw.customer.service.AuthorizerTokenService;
import com.yaoyaozw.customer.service.CustomerGraphicsDelayService; import com.yaoyaozw.customer.service.CustomerGraphicsDelayService;
import com.yaoyaozw.customer.service.CustomerGraphicsService; import com.yaoyaozw.customer.service.CustomerGraphicsService;
import com.yaoyaozw.customer.vo.customer.DelayCustomerItemVO; import com.yaoyaozw.customer.service.wechat.service.WeChatService;
import com.yaoyaozw.customer.vo.customer.CustomerDelayItemVO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
...@@ -14,9 +16,12 @@ import com.yaoyaozw.customer.mapper.RegisterUserEntityMapper; ...@@ -14,9 +16,12 @@ import com.yaoyaozw.customer.mapper.RegisterUserEntityMapper;
import com.yaoyaozw.customer.entity.RegisterUserEntity; import com.yaoyaozw.customer.entity.RegisterUserEntity;
import com.yaoyaozw.customer.service.RegisterUserEntityService; import com.yaoyaozw.customer.service.RegisterUserEntityService;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -27,72 +32,22 @@ public class RegisterUserEntityServiceImpl extends ServiceImpl<RegisterUserEntit ...@@ -27,72 +32,22 @@ public class RegisterUserEntityServiceImpl extends ServiceImpl<RegisterUserEntit
private CustomerGraphicsService customerGraphicsService; private CustomerGraphicsService customerGraphicsService;
@Autowired @Autowired
private CustomerGraphicsDelayService customerGraphicsDelayService; private AuthorizerTokenService authorizerTokenService;
@Autowired @Autowired
private AuthorizerTokenService authorizerTokenService; private WeChatService weChatService;
@Override @Override
public void sendCustomerMessage(IntegrationRequestDTO integrationRequestDTO) { public void sendCustomerMessage(IntegrationRequestDTO integrationRequestDTO) {
//1.读取人群包 //1.读取人群包
List<RegisterUserEntity> list = list(); List<RegisterUserEntity> list = list();
//2.发送客服消息 //2.发送客服消息
}
@Override
public void sendCustomerDelayMessage(IntegrationRequestDTO integrationRequestDTO) {
//1.读取延时客服排期人
List<RegisterUserEntity> allPostUser = list(new QueryWrapper<RegisterUserEntity>().eq(RegisterUserEntity.COL_CUSTOMER_PUBLISH,integrationRequestDTO.getRequestDate()));
//涉及的appid
Set<String> appidSet = allPostUser.stream().map(RegisterUserEntity::getAppId).collect(Collectors.toSet());
if (!allPostUser.isEmpty()){
//号-用户
Map<String, List<RegisterUserEntity>> userMap = allPostUser.stream().collect(Collectors.groupingBy(RegisterUserEntity::getAppId));
List<DelayCustomerItemVO> allDelayCustomerMessage = customerGraphicsDelayService.findAllDelayCustomerMessage(appidSet);
if (allDelayCustomerMessage!=null&&!allDelayCustomerMessage.isEmpty()){
//号-发送序列-客服id
Map<String, Map<Integer, List<DelayCustomerItemVO>>> customerMap = allDelayCustomerMessage.stream().collect(Collectors.groupingBy(DelayCustomerItemVO::getAppId, Collectors.groupingBy(DelayCustomerItemVO::getPostSort)));
List<AuthorizerToken> tokenList = authorizerTokenService.list();
//找token
Map<String, String> tokenMap = tokenList.stream().collect(Collectors.toMap(AuthorizerToken::getAuthorizerAppid, AuthorizerToken::getAuthorizerAccessToken));
for (Map.Entry<String, List<RegisterUserEntity>> userEntry : userMap.entrySet()) {
String appid = userEntry.getKey();
//该号下延时客服
Map<Integer, List<DelayCustomerItemVO>> delaySortMap = customerMap.get(appid);
//所有的用户
List<RegisterUserEntity> userList = userEntry.getValue();
if (delaySortMap!=null&&!delaySortMap.isEmpty()){
for (RegisterUserEntity user : userList) {
Integer customerSort = user.getCustomerSort();
}
}
}
}
}
}
//2.发送延时客服
}
} }
package com.yaoyaozw.customer.service.wechat.service; package com.yaoyaozw.customer.service.wechat.service;
import com.yaoyaozw.customer.entity.CustomerDelayPublish;
import com.yaoyaozw.customer.entity.RegisterUserEntity;
import com.yaoyaozw.customer.vo.customer.CustomerDelayItemVO;
import java.util.Map;
import java.util.concurrent.Future;
public interface WeChatService { public interface WeChatService {
/** /**
* 发送客服消息 * 发送延时客服消息
*/ */
void sendCustomerServiceMessage(); Future<CustomerDelayPublish> sendCustomerDelayMessage(String token, CustomerDelayPublish user, Map<Integer,CustomerDelayItemVO>delaySortMap);
} }
package com.yaoyaozw.customer.service.wechat.service; package com.yaoyaozw.customer.service.wechat.service;
import com.yaoyaozw.customer.entity.CustomerDelayPublish;
import com.yaoyaozw.customer.entity.RegisterUserEntity;
import com.yaoyaozw.customer.vo.customer.CustomerDelayItemVO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.Map;
import java.util.concurrent.Future;
@Service @Service
public class WeChatServiceImpl implements WeChatService{ public class WeChatServiceImpl implements WeChatService{
@Autowired @Autowired
private WeChatRestService weChatRestService; private WeChatRestService weChatRestService;
@Async("myExecutor")
@Override @Override
public void sendCustomerServiceMessage() { public Future<CustomerDelayPublish> sendCustomerDelayMessage(String token, CustomerDelayPublish user, Map<Integer,CustomerDelayItemVO> delaySortMap) {
//根据公众号发送客服
//当前时间批次发文素材的用户关注时间一致
Long subscribeTimestamp = user.getGmtCreate().getTime();
Integer newSort = user.getCustomerSort()+1;
CustomerDelayItemVO customerDelayItemVO = delaySortMap.get(newSort);
if (customerDelayItemVO!=null&&customerDelayItemVO.getTimeInterval()!=null){
//根据人群包发送客服 user.setCustomerSort(newSort);
user.setCustomerPublish(new Date(subscribeTimestamp+customerDelayItemVO.getTimeInterval()));
}
return new AsyncResult<>(user);
} }
} }
...@@ -10,8 +10,9 @@ import java.io.Serializable; ...@@ -10,8 +10,9 @@ import java.io.Serializable;
* @date 2022/9/16 10:45 * @date 2022/9/16 10:45
*/ */
@Data @Data
public class DelayCustomerItemVO implements Serializable { public class CustomerDelayItemVO implements Serializable {
private static final long serialVersionUID = -4630777409975737444L;
/** /**
* appid * appid
*/ */
......
...@@ -12,4 +12,10 @@ ...@@ -12,4 +12,10 @@
<!--@mbg.generated--> <!--@mbg.generated-->
id, authorizer_access_token, authorizer_appid id, authorizer_access_token, authorizer_appid
</sql> </sql>
<select id="findByAppid" resultMap="BaseResultMap">
select id,authorizer_access_token,authorizer_appid from authorizer_token where authorizer_appid=#{appid}
</select>
</mapper> </mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yaoyaozw.customer.mapper.CustomerDelayPublishMapper">
<resultMap id="BaseResultMap" type="com.yaoyaozw.customer.entity.CustomerDelayPublish">
<!--@mbg.generated-->
<!--@Table register_user_entity-->
<id column="id" jdbcType="BIGINT" property="id" />
<result column="app_id" jdbcType="VARCHAR" property="appId" />
<result column="open_id" jdbcType="VARCHAR" property="openId" />
<result column="pay_type" jdbcType="TINYINT" property="payType" />
<result column="customer_sort" jdbcType="INTEGER" property="customerSort" />
<result column="customer_publish" jdbcType="TIMESTAMP" property="customerPublish" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, app_id, open_id, pay_type, customer_sort, customer_publish
</sql>
</mapper>
\ No newline at end of file
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
</sql> </sql>
<select id="findAllDelayCustomerMessage" resultType="com.yaoyaozw.customer.vo.customer.DelayCustomerItemVO"> <select id="findAllDelayCustomerMessage" resultType="com.yaoyaozw.customer.vo.customer.CustomerDelayItemVO">
select * from customer_graphics_delay select * from customer_graphics_delay
......
...@@ -14,8 +14,6 @@ ...@@ -14,8 +14,6 @@
<result column="avg_month" jdbcType="DOUBLE" property="avgMonth" /> <result column="avg_month" jdbcType="DOUBLE" property="avgMonth" />
<result column="last_active" jdbcType="TIMESTAMP" property="lastActive" /> <result column="last_active" jdbcType="TIMESTAMP" property="lastActive" />
<result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate" /> <result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate" />
<result column="customer_sort" jdbcType="INTEGER" property="customerSort" />
<result column="customer_publish" jdbcType="TIMESTAMP" property="customerPublish" />
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
<!--@mbg.generated--> <!--@mbg.generated-->
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论