提交 f2fc953c 作者: 沈振路

客服

上级 25510db5
package com.yaoyaozw.customer.components;
import cn.hutool.core.util.ObjectUtil;
import com.yaoyaozw.customer.dto.customer.CustomerMessageSaveDTO;
import com.yaoyaozw.customer.entity.ReferralEntity;
import com.yaoyaozw.customer.service.ReferralEntityService;
import com.yaoyaozw.customer.service.RegisterUserEntityService;
import com.yaoyaozw.customer.vo.customer.CrowdPackageUserVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
......@@ -19,6 +25,11 @@ public class CustomerServiceCommonAsyncComponent {
private final static Logger LOCAL_LOG = LoggerFactory.getLogger(CustomerServiceCommonAsyncComponent.class);
@Autowired
private RegisterUserEntityService userEntityService;
@Autowired
private ReferralEntityService referralEntityService;
@Async("myExecutor")
public void addMatchUserIntoPackage(Long packageId, List<CrowdPackageUserVO> userList) {
......@@ -66,5 +77,21 @@ public class CustomerServiceCommonAsyncComponent {
LOCAL_LOG.info("异步删除不符合条件用户所属人群包完成, 耗时: {}ms", endTime - startTime);
}
@Async("myExecutor")
public void getAuthListLink(Long id, CustomerMessageSaveDTO saveDto) {
LOCAL_LOG.info("进入异步方法");
List<Long> accountIdList = userEntityService.getAccountIdListFromPackage(saveDto.getPackId());
List<ReferralEntity> referralEntityList = new ArrayList<>(accountIdList.size());
// 遍历处理
referralEntityService.saveBatch(referralEntityList);
}
}
......@@ -22,10 +22,4 @@ public class CustomerDelaySaveDTO implements Serializable {
@ApiModelProperty("客服消息类型(图文、文本)")
private Integer messageType;
@ApiModelProperty("图文实体")
private CustomerGraphicsDTO graphicsDto;
@ApiModelProperty("文本实体")
private CustomerTextDTO textDto;
}
package com.yaoyaozw.customer.dto.customer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @author darker
* @date 2022/9/15 11:15
*/
@Data
@ApiModel("图文实体")
public class CustomerGraphicsDTO implements Serializable {
private static final long serialVersionUID = -7314804348041896227L;
@ApiModelProperty("素材图片路径")
private String graphicsPicUrl;
@ApiModelProperty("素材文本内容")
private String graphicsContent;
}
......@@ -15,22 +15,34 @@ import java.io.Serializable;
public class CustomerMessageSaveDTO implements Serializable {
private static final long serialVersionUID = -4269904448093268275L;
@ApiModelProperty("客服消息人群包ID")
private Long packageId;
@ApiModelProperty("客服消息id")
private Long id;
@ApiModelProperty("客服消息名称")
private String messageName;
@ApiModelProperty("人群包ID")
private Long packId;
@ApiModelProperty("标题")
private String title;
@ApiModelProperty("消息发送时间")
private String postTime;
@ApiModelProperty("是否支付 0-否 1-是")
private Integer isPay;
@ApiModelProperty("客服消息类型(图文、文本)")
private Integer messageType;
private Integer type;
@ApiModelProperty("素材文本内容")
private String extendTitle;
@ApiModelProperty("素材图片路径")
private String coverUrl;
@ApiModelProperty("图文实体")
private CustomerGraphicsDTO graphicsDto;
@ApiModelProperty("素材文本内容")
private String content;
@ApiModelProperty("文本实体")
private CustomerTextDTO textDto;
@ApiModelProperty("链接相关内容")
private CustomerReferralDTO customerReferralDto;
}
package com.yaoyaozw.customer.dto.customer;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* @author darker
* @date 2022/10/8 12:00
*/
@Data
public class CustomerReferralDTO implements Serializable {
@ApiModelProperty("链接类型")
private Integer newsType;
@ApiModelProperty("书")
private Long bookId;
@ApiModelProperty("章节")
private Integer chapterIdx;
@ApiModelProperty("推广类型")
private Integer push;
@ApiModelProperty("原文链接")
private String referral;
@ApiModelProperty("活动标题")
private String activityTitle;
@ApiModelProperty("限制次数")
private Integer limited;
@ApiModelProperty(value = "开始时间")
private Date startTime;
@ApiModelProperty(value = "结束时间")
private Date endTime;
}
package com.yaoyaozw.customer.dto.customer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @author darker
* @date 2022/9/15 11:16
*/
@Data
@ApiModel("文本实体")
public class CustomerTextDTO implements Serializable {
private static final long serialVersionUID = -1088228495201151269L;
@ApiModelProperty("文本消息内容")
private String messageText;
}
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 com.baomidou.mybatisplus.annotation.*;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
import org.springframework.data.annotation.Id;
/**
* 客户图片
*
* @author Admin
* @date 2022/10/08
*/
@Data
@TableName(value = "customer_graphics")
public class CustomerGraphics implements Serializable {
@TableId(value = "id", type = IdType.AUTO)
@Id
private Long id;
/**
......@@ -21,6 +27,42 @@ public class CustomerGraphics implements Serializable {
private Long packId;
/**
* 标题
*/
@TableField(value = "title")
private String title;
/**
* 类型 0-文本 1-图文
*/
@TableField(value = "type")
private Integer type;
/**
* 是否支付 0-否 1-是
*/
@TableField(value = "is_pay")
private Integer isPay;
/**
* 推广标题
*/
@TableField(value = "extend_title")
private String extendTitle;
/**
* 封面地址
*/
@TableField(value = "cover_url")
private String coverUrl;
/**
* 文本内容
*/
@TableField(value = "content")
private String content;
/**
* 发送时间
*/
@TableField(value = "post_time")
......@@ -54,6 +96,7 @@ public class CustomerGraphics implements Serializable {
* 逻辑删除
*/
@TableField(value = "is_deleted")
@TableLogic
private Boolean isDeleted;
private static final long serialVersionUID = 1L;
......@@ -73,4 +116,14 @@ public class CustomerGraphics implements Serializable {
public static final String COL_GMT_MODIFIED = "gmt_modified";
public static final String COL_IS_DELETED = "is_deleted";
public void initOperateInfo(Long userId, Boolean isCreate) {
Date now = new Date();
if (isCreate) {
this.createUser = userId;
this.gmtCreate = now;
}
this.gmtModified = now;
this.modifiedUser = userId;
}
}
\ No newline at end of file
package com.yaoyaozw.customer.entity;
import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* 推荐实体
*
* @author Admin
* @date 2022/10/08
*/
@ApiModel(value="referral_entity")
@Data
@TableName(value = "referral_entity")
public class ReferralEntity implements Serializable {
@TableId(value = "id", type = IdType.ID_WORKER)
@ApiModelProperty(value="")
private Long id;
/**
* 渠道id
*/
@TableField(value = "account_id")
@ApiModelProperty(value="渠道id")
private String accountId;
/**
* name
*/
@TableField(value = "name")
@ApiModelProperty(value="name")
private String name;
/**
* 小说名
*/
@TableField(value = "book_id")
@ApiModelProperty(value="小说名")
private String bookId;
/**
* 章节
*/
@TableField(value = "chapter_idx")
@ApiModelProperty(value="章节")
private Integer chapterIdx;
/**
* 素材表id
*/
@TableField(value = "material_graphics_id")
@ApiModelProperty(value="素材表id")
private Long materialGraphicsId;
/**
* 素材表id
*/
@TableField(value = "material_graphics_info_id")
@ApiModelProperty(value="素材表id")
private Long materialGraphicsInfoId;
/**
* 发文类型
*/
@TableField(value = "news_type")
@ApiModelProperty(value="发文类型")
private Integer newsType;
/**
* 推广id
*/
@TableField(value = "promote_id")
@ApiModelProperty(value="推广id")
private String promoteId;
/**
* 推广类型
*/
@TableField(value = "push_type")
@ApiModelProperty(value="推广类型")
private Integer push;
/**
* 原文链接
*/
@TableField(value = "referral")
@ApiModelProperty(value="原文链接")
private String referral;
/**
* 书成平台
*/
@TableField(value = "store_type")
@ApiModelProperty(value="书成平台")
private String storeType;
/**
* 样式
*/
@TableField(value = "style_type")
@ApiModelProperty(value="样式")
private Integer styleType;
@TableField(value = "gmt_create", fill = FieldFill.INSERT)
@ApiModelProperty(value="")
private Date gmtCreate;
@TableField(value = "gmt_create_user", fill = FieldFill.INSERT)
@ApiModelProperty(value="")
private String gmtCreateUser;
@TableField(value = "gmt_modified", fill = FieldFill.INSERT)
@ApiModelProperty(value="")
private Date gmtModified;
@TableField(value = "gmt_modified_user", fill = FieldFill.INSERT)
@ApiModelProperty(value="")
private String gmtModifiedUser;
/**
* 逻辑删除 1(true)已删除, 0(false)未删除
*/
@TableLogic
@TableField(value = "is_deleted", fill = FieldFill.INSERT)
@ApiModelProperty(value="逻辑删除 1(true)已删除, 0(false)未删除")
private Integer isDeleted;
/**
* name
*/
@ApiModelProperty(value="bookName")
@TableField(value = "book_name")
private String bookName;
/**
* name
*/
@ApiModelProperty(value="storeTypeName")
@TableField(value = "store_type_name")
private String storeTypeName;
/**
* name
*/
@ApiModelProperty(value = "activityTitle")
@TableField(value = "activity_title")
private String activityTitle;
/**
* name
*/
@ApiModelProperty(value = "configId")
@TableField(value = "config_id")
private String configId;
/**
* name
*/
@ApiModelProperty(value = "templateId")
@TableField(value = "template_id")
private String templateId;
/**
* name
*/
@ApiModelProperty(value = "startTime")
@TableField(value = "start_time")
private Date startTime;
/**
* name
*/
@ApiModelProperty(value = "endTime")
@TableField(value = "end_time")
private Date endTime;
/**
* name
*/
@ApiModelProperty(value = "rechargeAmount")
@TableField(value = "recharge_amount")
private BigDecimal rechargeAmount;
/**
* namev
*/
@ApiModelProperty(value = "giftAmount")
@TableField(value = "gift_amount")
private Integer giftAmount;
/**
* namev
*/
@ApiModelProperty(value = "limited")
@TableField(value = "limited")
private Integer limited;
/**
* name
*/
@ApiModelProperty(value = "configId")
@TableField(value = "config_name")
private String configName;
public static final String COL_ID = "id";
public static final String COL_ACCOUNT_ID = "account_id";
public static final String COL_BOOK_ID = "book_id";
public static final String COL_CHAPTER_IDX = "chapter_idx";
public static final String COL_MATERIAL_GRAPHICS_ID = "material_graphics_id";
public static final String COL_NEWS_TYPE = "news_type";
public static final String COL_PROMOTE_ID = "promote_id";
public static final String COL_REFERRAL = "referral";
public static final String COL_STORE_TYPE = "store_type";
public static final String COL_STYLE_TYPE = "style_type";
public static final String COL_GMT_CREATE = "gmt_create";
public static final String COL_GMT_CREATE_USER = "gmt_create_user";
public static final String COL_GMT_MODIFIED = "gmt_modified";
public static final String COL_GMT_MODIFIED_USER = "gmt_modified_user";
public void changeDispatchBelong(Long id, Long materialGraphicsId, Long materialGraphicsInfoId) {
this.id = id;
this.materialGraphicsId = materialGraphicsId;
this.materialGraphicsInfoId = materialGraphicsInfoId;
}
}
\ No newline at end of file
package com.yaoyaozw.customer.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yaoyaozw.customer.entity.ReferralEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* @author Admin
* @date 2022/10/08
*/
@Mapper
public interface ReferralEntityMapper extends BaseMapper<ReferralEntity> {
/**
* 物理删除素材元素
*
* @param sourceId 素材主体ID
*/
void ultimateDeleteReferrals(@Param("sourceId") Long sourceId);
}
\ No newline at end of file
......@@ -28,4 +28,12 @@ public interface RegisterUserEntityMapper extends BaseMapper<RegisterUserEntity>
*/
void updateUserPackageBelong(@Param("openId") String openId, @Param("packageBelong") String packageBelong);
/**
* 从包中获取用户列表(现在已经在人群包内的)
*
* @param packageId 包id
* @return {@link List}<{@link RegisterUserEntity}>
*/
List<Long> getAuthListFromPackage(@Param("packageId") Long packageId);
}
\ No newline at end of file
......@@ -53,5 +53,6 @@ public interface CustomerGraphicsService extends IService<CustomerGraphics> {
* @return {@link BaseResult}
*/
BaseResult removeCustomerMessage(Long id);
}
package com.yaoyaozw.customer.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yaoyaozw.customer.entity.ReferralEntity;
/**
* @author Admin
* @date 2022/10/08
*/
public interface ReferralEntityService extends IService<ReferralEntity> {
/**
* 物理删除素材元素
*
* @param sourceId 素材主体ID
*/
void ultimateDeleteReferrals(Long sourceId);
}
......@@ -23,5 +23,14 @@ public interface RegisterUserEntityService extends IService<RegisterUserEntity>{
*/
List<CrowdPackageUserVO> getUserMatchDynamicExpress(List<String> dynamicExpressList, String openId);
/**
* 从包中获取用户列表(现在已经在人群包内的)
*
* @param packageId 包id
* @return {@link List}<{@link RegisterUserEntity}>
*/
List<Long> getAccountIdListFromPackage(Long packageId);
}
package com.yaoyaozw.customer.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.yaoyaozw.customer.common.BaseResult;
import com.yaoyaozw.customer.common.GenericsResult;
import com.yaoyaozw.customer.components.CustomerServiceCommonAsyncComponent;
import com.yaoyaozw.customer.components.TokenManager;
import com.yaoyaozw.customer.constants.CustomerCommonConstant;
import com.yaoyaozw.customer.dto.customer.CustomerMessageQueryDTO;
import com.yaoyaozw.customer.dto.customer.CustomerMessageSaveDTO;
import com.yaoyaozw.customer.entity.ReferralEntity;
import com.yaoyaozw.customer.service.CrowdPackageConditionMatchService;
import com.yaoyaozw.customer.service.ReferralEntityService;
import com.yaoyaozw.customer.service.RegisterUserEntityService;
import com.yaoyaozw.customer.vo.customer.CrowdPackageUserVO;
import com.yaoyaozw.customer.vo.customer.CustomerMessageListVO;
import org.slf4j.Logger;
......@@ -13,6 +19,8 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yaoyaozw.customer.entity.CustomerGraphics;
......@@ -33,19 +41,31 @@ public class CustomerGraphicsServiceImpl extends ServiceImpl<CustomerGraphicsMap
@Autowired
private CrowdPackageConditionMatchService matchService;
@Autowired
private RedisTemplate redisTemplate;
private TokenManager tokenManager;
@Autowired
private CustomerServiceCommonAsyncComponent commonAsyncComponent;
@Autowired
private ReferralEntityService referralEntityService;
@Override
public BaseResult insertCustomerMessage(CustomerMessageSaveDTO saveDto) {
Long packageId = saveDto.getPackageId();
LOCAL_LOG.info("根据人群包 {} 找符合条件的用户数据", packageId);
List<CrowdPackageUserVO> userList = matchService.getUserListFromPackage(packageId, null);
redisTemplate.opsForHash().put(CustomerCommonConstant.CROWD_HUMAN_NUN_REDIS_KEY, packageId.toString(), userList.size());
// 主体数据
LOCAL_LOG.info("处理主体数据");
CustomerGraphics customerGraphics = new CustomerGraphics();
BeanUtil.copyProperties(saveDto, customerGraphics);
customerGraphics.initOperateInfo(tokenManager.getUserIdFromToken(), true);
super.save(customerGraphics);
// 处理活动数据
ReferralEntity referralEntity = new ReferralEntity();
BeanUtil.copyProperties(saveDto.getCustomerReferralDto(), referralEntity);
referralEntity.setMaterialGraphicsId(customerGraphics.getId());
referralEntityService.save(referralEntity);
// TODO: 2022/9/28 根据人群包找到下面的人所在的公众号,进行链接获取
return new BaseResult().success();
}
......
package com.yaoyaozw.customer.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yaoyaozw.customer.entity.ReferralEntity;
import com.yaoyaozw.customer.mapper.ReferralEntityMapper;
import com.yaoyaozw.customer.service.ReferralEntityService;
import org.springframework.stereotype.Service;
/**
* @Author didi
* @Create 2022/3/23 16:14
*/
@Service
public class ReferralEntityServiceImpl extends ServiceImpl<ReferralEntityMapper, ReferralEntity> implements ReferralEntityService {
@Override
public void ultimateDeleteReferrals(Long materialId) {
super.baseMapper.ultimateDeleteReferrals(materialId);
}
}
......@@ -30,9 +30,6 @@ import java.util.stream.Collectors;
public class RegisterUserEntityServiceImpl extends ServiceImpl<RegisterUserEntityMapper, RegisterUserEntity> implements RegisterUserEntityService{
@Autowired
private CustomerGraphicsService customerGraphicsService;
@Autowired
private AuthorizerTokenService authorizerTokenService;
@Autowired
......@@ -57,4 +54,9 @@ public class RegisterUserEntityServiceImpl extends ServiceImpl<RegisterUserEntit
return baseMapper.getUserMatchDynamicExpress(dynamicExpressList, openId);
}
@Override
public List<Long> getAccountIdListFromPackage(Long packageId) {
return baseMapper.getAuthListFromPackage(packageId);
}
}
package com.yaoyaozw.customer.vo.customer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
......@@ -12,5 +13,37 @@ import java.io.Serializable;
public class CustomerMessageListVO implements Serializable {
private static final long serialVersionUID = -8057791504394044052L;
@ApiModelProperty("客服消息id")
private Long id;
@ApiModelProperty("标题")
private String title;
@ApiModelProperty("消息发送时间")
private String postTime;
@ApiModelProperty("客服消息类型(图文、文本)")
private String type;
@ApiModelProperty("推广标题")
private String extendTitle;
@ApiModelProperty("推广类型")
private String extendType;
@ApiModelProperty("人群包id")
private Long packId;
@ApiModelProperty("人群包名称")
private String packName;
@ApiModelProperty("人数")
private Integer peopleNum;
@ApiModelProperty("发送状态值")
private Integer sendStatus;
@ApiModelProperty("发送状态描述")
private String sendStatusStr;
}
<?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.ReferralEntityMapper">
<resultMap id="BaseResultMap" type="com.yaoyaozw.customer.entity.ReferralEntity">
<!--@mbg.generated-->
<!--@Table referral_entity-->
<id column="id" jdbcType="BIGINT" property="id" />
<result column="account_id" jdbcType="VARCHAR" property="accountId" />
<result column="book_id" jdbcType="VARCHAR" property="bookId" />
<result column="chapter_idx" jdbcType="INTEGER" property="chapterIdx" />
<result column="material_graphics_id" jdbcType="VARCHAR" property="materialGraphicsId" />
<result column="news_type" jdbcType="INTEGER" property="newsType" />
<result column="promote_id" jdbcType="VARCHAR" property="promoteId" />
<result column="referral" jdbcType="VARCHAR" property="referral" />
<result column="store_type" jdbcType="VARCHAR" property="storeType" />
<result column="style_type" jdbcType="INTEGER" property="styleType" />
<result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate" />
<result column="gmt_create_user" jdbcType="CHAR" property="gmtCreateUser" />
<result column="gmt_modified" jdbcType="TIMESTAMP" property="gmtModified" />
<result column="gmt_modified_user" jdbcType="CHAR" property="gmtModifiedUser" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, account_id, book_id, chapter_idx, material_graphics_id, news_type, promote_id,
referral, store_type, style_type, gmt_create, gmt_create_user, gmt_modified, gmt_modified_user
</sql>
<delete id="ultimateDeleteReferrals">
delete from referral_entity where material_graphics_id = #{sourceId}
</delete>
</mapper>
\ No newline at end of file
......@@ -55,4 +55,13 @@
set in_package = #{packageBelong}
where open_id = #{openId}
</update>
<select id="getAuthListFromPackage" resultType="java.lang.Long">
select
distinct ai.account_id
from register_user_entity rue
left join authorizer_info ai
on rue.app_id = ai.appid
where find_in_set(#{packageId}, in_package)
</select>
</mapper>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论