提交 bd36ced5 作者: 沈振路

客服

上级 927f59f1
...@@ -15,6 +15,7 @@ import com.yaoyaozw.customer.entity.CustomerGraphics; ...@@ -15,6 +15,7 @@ import com.yaoyaozw.customer.entity.CustomerGraphics;
import com.yaoyaozw.customer.entity.ReferralEntity; import com.yaoyaozw.customer.entity.ReferralEntity;
import com.yaoyaozw.customer.entity.RegisterUserEntity; import com.yaoyaozw.customer.entity.RegisterUserEntity;
import com.yaoyaozw.customer.feigns.ReferralFeignClient; import com.yaoyaozw.customer.feigns.ReferralFeignClient;
import com.yaoyaozw.customer.mapper.KanbanCommonMapper;
import com.yaoyaozw.customer.mapper.MaterialCommonMapper; import com.yaoyaozw.customer.mapper.MaterialCommonMapper;
import com.yaoyaozw.customer.service.CrowdPackageConditionMatchService; import com.yaoyaozw.customer.service.CrowdPackageConditionMatchService;
import com.yaoyaozw.customer.service.ReferralEntityService; import com.yaoyaozw.customer.service.ReferralEntityService;
...@@ -58,6 +59,8 @@ public class CustomerServiceCommonAsyncComponent { ...@@ -58,6 +59,8 @@ public class CustomerServiceCommonAsyncComponent {
private ReferralFeignClient referralFeignClient; private ReferralFeignClient referralFeignClient;
@Autowired @Autowired
private MaterialCommonMapper materialCommonMapper; private MaterialCommonMapper materialCommonMapper;
@Autowired
private KanbanCommonMapper kanbanCommonMapper;
@Async("myExecutor") @Async("myExecutor")
...@@ -163,7 +166,8 @@ public class CustomerServiceCommonAsyncComponent { ...@@ -163,7 +166,8 @@ public class CustomerServiceCommonAsyncComponent {
private void generateExtendLink(Map<String, List<CrowdPackageUserVO>> storeGroupMap, ReferralEntity customerReferral) { private void generateExtendLink(Map<String, List<CrowdPackageUserVO>> storeGroupMap, ReferralEntity customerReferral) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
String dateStr = dateFormat.format(new Date());
storeGroupMap.forEach((storeType, userVoList) -> { storeGroupMap.forEach((storeType, userVoList) -> {
LOCAL_LOG.info("当前处理书城: {}", storeType); LOCAL_LOG.info("当前处理书城: {}", storeType);
...@@ -178,8 +182,12 @@ public class CustomerServiceCommonAsyncComponent { ...@@ -178,8 +182,12 @@ public class CustomerServiceCommonAsyncComponent {
BeanUtil.copyProperties(customerReferral, referralEntity); BeanUtil.copyProperties(customerReferral, referralEntity);
// 重新生成链接主键id // 重新生成链接主键id
referralEntity.setId(snowflakeComponent.snowflakeId()); referralEntity.setId(snowflakeComponent.snowflakeId());
// TODO: 2022/10/9 获取原文链接 referralEntity.setAccountId(authInfoVo.getAccountId());
getCopyReferral(null, authInfoVo, referralEntity); try {
getCopyReferral(dateStr, authInfoVo, referralEntity);
} catch (Exception e) {
LOCAL_LOG.warn("公众号: {} 获取链接异常: {}", authInfoVo.getAccountName(), e.getMessage());
}
referralEntityList.add(referralEntity); referralEntityList.add(referralEntity);
} }
...@@ -191,21 +199,28 @@ public class CustomerServiceCommonAsyncComponent { ...@@ -191,21 +199,28 @@ public class CustomerServiceCommonAsyncComponent {
private void generateActivityLink(Map<String, List<CrowdPackageUserVO>> storeGroupMap, ReferralEntity customerReferral) { private void generateActivityLink(Map<String, List<CrowdPackageUserVO>> storeGroupMap, ReferralEntity customerReferral) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
String dateStr = dateFormat.format(new Date());
storeGroupMap.forEach((storeType, userVoList) -> { storeGroupMap.forEach((storeType, userVoList) -> {
LOCAL_LOG.info("当前处理书城: {}", storeType); LOCAL_LOG.info("当前处理书城: {}", storeType);
// 去重提取公众号 // 去重提取公众号
Set<String> accountSet = userVoList.stream().map(CrowdPackageUserVO::getAccountId).collect(Collectors.toSet()); Set<String> accountSet = userVoList.stream().map(CrowdPackageUserVO::getAccountId).collect(Collectors.toSet());
List<AuthInfoVO> authInfoList = materialCommonMapper.getAuthInfoList(accountSet);
// 定义 // 定义
List<ReferralEntity> referralEntityList = new ArrayList<>(accountSet.size()); List<ReferralEntity> referralEntityList = new ArrayList<>(accountSet.size());
ReferralEntity referralEntity = new ReferralEntity(); for (AuthInfoVO authInfoVo : authInfoList) {
ReferralEntity referralEntity = new ReferralEntity();
BeanUtil.copyProperties(customerReferral, referralEntity); BeanUtil.copyProperties(customerReferral, referralEntity);
// 重新生成链接主键id // 重新生成链接主键id
referralEntity.setId(snowflakeComponent.snowflakeId()); referralEntity.setId(snowflakeComponent.snowflakeId());
// TODO: 2022/10/9 获取原文链接 referralEntity.setAccountId(authInfoVo.getAccountId());
getCopyReferral(dateStr, authInfoVo, referralEntity);
referralEntityList.add(referralEntity); referralEntityList.add(referralEntity);
}
// 批量新增 // 批量新增
referralEntityService.saveBatch(referralEntityList); referralEntityService.saveBatch(referralEntityList);
...@@ -218,17 +233,21 @@ public class CustomerServiceCommonAsyncComponent { ...@@ -218,17 +233,21 @@ public class CustomerServiceCommonAsyncComponent {
LOCAL_LOG.info("当前处理书城: {}", storeType); LOCAL_LOG.info("当前处理书城: {}", storeType);
// 去重提取公众号 // 去重提取公众号
Set<String> accountSet = userVoList.stream().map(CrowdPackageUserVO::getAccountId).collect(Collectors.toSet()); Set<String> accountSet = userVoList.stream().map(CrowdPackageUserVO::getAccountId).collect(Collectors.toSet());
List<AuthInfoVO> authInfoList = materialCommonMapper.getAuthInfoList(accountSet);
// 定义 // 定义
List<ReferralEntity> referralEntityList = new ArrayList<>(accountSet.size()); List<ReferralEntity> referralEntityList = new ArrayList<>(accountSet.size());
ReferralEntity referralEntity = new ReferralEntity(); for (AuthInfoVO authInfoVo : authInfoList) {
ReferralEntity referralEntity = new ReferralEntity();
BeanUtil.copyProperties(customerReferral, referralEntity); BeanUtil.copyProperties(customerReferral, referralEntity);
// 重新生成链接主键id // 重新生成链接主键id
referralEntity.setId(snowflakeComponent.snowflakeId()); referralEntity.setId(snowflakeComponent.snowflakeId());
// TODO: 2022/10/9 获取原文链接 referralEntity.setAccountId(authInfoVo.getAccountId());
getCopyReferral(null, authInfoVo, referralEntity);
referralEntityList.add(referralEntity); referralEntityList.add(referralEntity);
}
// 批量新增 // 批量新增
referralEntityService.saveBatch(referralEntityList); referralEntityService.saveBatch(referralEntityList);
...@@ -237,16 +256,28 @@ public class CustomerServiceCommonAsyncComponent { ...@@ -237,16 +256,28 @@ public class CustomerServiceCommonAsyncComponent {
private void getCopyReferral(String dateStr, private void getCopyReferral(String dateStr, AuthInfoVO authInfoVo, ReferralEntity referralEntity) {
AuthInfoVO authInfoVo,
ReferralEntity referralEntity) {
referralEntity.setStoreType(authInfoVo.getStoreType()); referralEntity.setStoreType(authInfoVo.getStoreType());
referralEntity.setStoreTypeName(authInfoVo.getStoreTypeName());
// 非常用链接类型的name需要处理 // 非常用链接类型的name需要处理
if (!CustomerCommonConstant.USUAL_LINK_NEWS_TYPE.equals(referralEntity.getNewsType())) { String name = referralEntity.getName();
referralEntity.setName(replaceName(referralEntity.getName(), dateStr)); Integer newsType = referralEntity.getNewsType();
if (!CustomerCommonConstant.USUAL_LINK_NEWS_TYPE.equals(newsType) && !StringUtils.isBlank(name)) {
String newsTypeName = CustomerCommonConstant.getNewsTypeName(newsType);
if (ObjectUtil.isNull(newsTypeName)) {
throw new RuntimeException("无法获取链接类型");
}
// 替换共用字段
name = name.replace("{newsType}", newsTypeName).replace("{accountNickName}", authInfoVo.getAccountName())
.replace("{storeType}", referralEntity.getStoreType()).replace("{currentDate}", dateStr);
if (newsType.equals(CustomerCommonConstant.BOOK_NEWS_TYPE)) {
// 系统-客服-{newsType}-{accountNickName}-{storeType}-{currentDate}-{bookName}
name = name.replace("{bookName}", referralEntity.getBookName());
} else if (newsType.equals(CustomerCommonConstant.ACTIVITY_NEWS_TYPE)) {
// 系统-客服-{newsType}-{accountNickName}-{storeType}-{currentDate}-充{recharge}送{gift}
name = name.replace("{recharge}", referralEntity.getRechargeAmount().toPlainString()).replace("{gift}", referralEntity.getGiftAmount().toString());
}
referralEntity.setName(name);
} }
referralEntity.setAccountId(null);
referralEntity.setInfoId(authInfoVo.getId()); referralEntity.setInfoId(authInfoVo.getId());
R r = referralFeignClient.productReferral(referralEntity); R r = referralFeignClient.productReferral(referralEntity);
if (!r.getCode().equals(ApiResultConstant.SUCCESS_CODE)) { if (!r.getCode().equals(ApiResultConstant.SUCCESS_CODE)) {
...@@ -257,24 +288,12 @@ public class CustomerServiceCommonAsyncComponent { ...@@ -257,24 +288,12 @@ public class CustomerServiceCommonAsyncComponent {
String referral = jsonObject1.getString("referral"); String referral = jsonObject1.getString("referral");
referralEntity.setPromoteId(jsonObject1.getString("promoteId")); referralEntity.setPromoteId(jsonObject1.getString("promoteId"));
referralEntity.setReferral(referral); referralEntity.setReferral(referral);
// 系统-客服-{newsType}-{accountNickName}-{storeType}-{currentDate}-{bookName}
// 系统-客服-{newsType}-{accountNickName}-{storeType}-{currentDate}-充{recharge}送{gift}
} }
private String getConfigIdFromInterface(String storeType) {
private String replaceName(String materialName, String appNickName) {
if (StringUtils.isBlank(materialName)) {
return null;
}
if (materialName.contains("-")) {
String[] split = materialName.split("-");
String format = new SimpleDateFormat("yyyy/MM/dd").format(new Date());
split[5] = format;
split[3] = appNickName;
return String.join("-", split);
}
return materialName;
return null;
} }
} }
...@@ -10,11 +10,17 @@ public class CustomerCommonConstant { ...@@ -10,11 +10,17 @@ public class CustomerCommonConstant {
public final static String CROWD_HUMAN_NUN_REDIS_KEY = "crowdHumanNum"; public final static String CROWD_HUMAN_NUN_REDIS_KEY = "crowdHumanNum";
public final static Integer ACTIVITY_NEWS_TYPE = 8;
public final static Integer BOOK_NEWS_TYPE = 7; public final static Integer BOOK_NEWS_TYPE = 1;
public final static String BOOK_NEWS_TYPE_NAME = "推广";
public final static String BOOK_NEWS_TYPE_NAME_MODEL = "系统-客服-{newsType}-{accountNickName}-{storeType}-{currentDate}-{bookName}";
public final static Integer USUAL_LINK_NEWS_TYPE = 9; public final static Integer ACTIVITY_NEWS_TYPE = 2;
public final static String ACTIVITY_NEWS_TYPE_NAME = "活动";
public final static String ACTIVITY_NEWS_TYPE_NAME_MODEL = "系统-客服-{newsType}-{accountNickName}-{storeType}-{currentDate}-充{recharge}送{gift}";
public final static Integer USUAL_LINK_NEWS_TYPE = 3;
public final static String USUAL_LINK_NEWS_TYPE_NAME = "常用";
public final static String CUSTOMER_TYPE_VALUE_GRAPHICS = "news"; public final static String CUSTOMER_TYPE_VALUE_GRAPHICS = "news";
...@@ -37,4 +43,34 @@ public class CustomerCommonConstant { ...@@ -37,4 +43,34 @@ public class CustomerCommonConstant {
return type; return type;
} }
public static String getNewsTypeName(Integer code) {
if (ObjectUtil.isNull(code)) {
return null;
}
if (code.equals(BOOK_NEWS_TYPE)) {
return BOOK_NEWS_TYPE_NAME;
}
if (code.equals(ACTIVITY_NEWS_TYPE)) {
return ACTIVITY_NEWS_TYPE_NAME;
}
if (code.equals(USUAL_LINK_NEWS_TYPE)) {
return USUAL_LINK_NEWS_TYPE_NAME;
}
return null;
}
public static String getLinkNameModel(Integer code) {
if (ObjectUtil.isNull(code)) {
return null;
}
if (code.equals(BOOK_NEWS_TYPE)) {
return BOOK_NEWS_TYPE_NAME_MODEL;
}
if (code.equals(ACTIVITY_NEWS_TYPE)) {
return ACTIVITY_NEWS_TYPE_NAME_MODEL;
}
return null;
}
} }
...@@ -32,9 +32,15 @@ public class CustomerReferralDTO implements Serializable { ...@@ -32,9 +32,15 @@ public class CustomerReferralDTO implements Serializable {
@ApiModelProperty("书城") @ApiModelProperty("书城")
private String storeType; private String storeType;
@ApiModelProperty("书城名")
private String storeTypeName;
@ApiModelProperty("书") @ApiModelProperty("书")
private String bookId; private String bookId;
@ApiModelProperty("书名")
private String bookName;
@ApiModelProperty("章节") @ApiModelProperty("章节")
private Integer chapterIdx; private Integer chapterIdx;
......
package com.yaoyaozw.customer.entity; package com.yaoyaozw.customer.entity;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.annotation.*; import com.baomidou.mybatisplus.annotation.*;
import java.io.Serializable; import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import lombok.Data; import lombok.Data;
import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Id;
...@@ -63,6 +65,12 @@ public class CustomerGraphics implements Serializable { ...@@ -63,6 +65,12 @@ public class CustomerGraphics implements Serializable {
private Date postTime; private Date postTime;
/** /**
* 发送状态
*/
@TableField(value = "send_status")
private Integer sendStatus;
/**
* 创建人 * 创建人
*/ */
@TableField(value = "create_user") @TableField(value = "create_user")
...@@ -120,4 +128,12 @@ public class CustomerGraphics implements Serializable { ...@@ -120,4 +128,12 @@ public class CustomerGraphics implements Serializable {
this.gmtModified = now; this.gmtModified = now;
this.modifiedUser = userId; this.modifiedUser = userId;
} }
public String getPostTimeStr() {
if (ObjectUtil.isNull(this.postTime)) {
return null;
}
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return dateFormat.format(this.postTime);
}
} }
\ No newline at end of file
...@@ -19,6 +19,7 @@ public interface ReferralEntityMapper extends BaseMapper<ReferralEntity> { ...@@ -19,6 +19,7 @@ public interface ReferralEntityMapper extends BaseMapper<ReferralEntity> {
* 物理删除素材元素 * 物理删除素材元素
* *
* @param sourceId 素材主体ID * @param sourceId 素材主体ID
* @param extraCondition 特殊条件表达式
*/ */
void ultimateDeleteReferrals(@Param("sourceId") Long sourceId); void ultimateDeleteReferrals(@Param("sourceId") Long sourceId, @Param("extraCondition") String extraCondition);
} }
\ No newline at end of file
...@@ -14,8 +14,9 @@ public interface ReferralEntityService extends IService<ReferralEntity> { ...@@ -14,8 +14,9 @@ public interface ReferralEntityService extends IService<ReferralEntity> {
* 物理删除素材元素 * 物理删除素材元素
* *
* @param sourceId 素材主体ID * @param sourceId 素材主体ID
* @param extraCondition 特殊条件表达式
*/ */
void ultimateDeleteReferrals(Long sourceId); void ultimateDeleteReferrals(Long sourceId, String extraCondition);
} }
...@@ -30,6 +30,7 @@ import org.slf4j.LoggerFactory; ...@@ -30,6 +30,7 @@ import org.slf4j.LoggerFactory;
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 java.text.SimpleDateFormat;
import java.util.List; import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yaoyaozw.customer.entity.CustomerGraphics; import com.yaoyaozw.customer.entity.CustomerGraphics;
...@@ -82,7 +83,10 @@ public class CustomerGraphicsServiceImpl extends ServiceImpl<CustomerGraphicsMap ...@@ -82,7 +83,10 @@ public class CustomerGraphicsServiceImpl extends ServiceImpl<CustomerGraphicsMap
ReferralEntity referralEntity = new ReferralEntity(); ReferralEntity referralEntity = new ReferralEntity();
BeanUtil.copyProperties(saveDto.getCustomerReferralDto(), referralEntity); BeanUtil.copyProperties(saveDto.getCustomerReferralDto(), referralEntity);
referralEntity.setMaterialGraphicsId(customerGraphics.getId()); referralEntity.setMaterialGraphicsId(customerGraphics.getId());
// 获取name模板
String nameModel = CustomerCommonConstant.getLinkNameModel(referralEntity.getNewsType());
LOCAL_LOG.info("获取name模板: {}", nameModel);
referralEntity.setName(nameModel);
// 保存链接数据 // 保存链接数据
referralEntityService.saveOrUpdate(referralEntity); referralEntityService.saveOrUpdate(referralEntity);
...@@ -99,6 +103,7 @@ public class CustomerGraphicsServiceImpl extends ServiceImpl<CustomerGraphicsMap ...@@ -99,6 +103,7 @@ public class CustomerGraphicsServiceImpl extends ServiceImpl<CustomerGraphicsMap
} }
CustomerMessageDetailVO customerMessageDetailVO = new CustomerMessageDetailVO(); CustomerMessageDetailVO customerMessageDetailVO = new CustomerMessageDetailVO();
BeanUtil.copyProperties(customerGraphics, customerMessageDetailVO); BeanUtil.copyProperties(customerGraphics, customerMessageDetailVO);
customerMessageDetailVO.setPostTime(customerGraphics.getPostTimeStr());
// 获取链接数据 // 获取链接数据
ReferralEntity referralEntity = referralEntityService.getOne(new QueryWrapper<ReferralEntity>().eq("material_graphics_id", id).isNull("account_id")); ReferralEntity referralEntity = referralEntityService.getOne(new QueryWrapper<ReferralEntity>().eq("material_graphics_id", id).isNull("account_id"));
...@@ -161,12 +166,14 @@ public class CustomerGraphicsServiceImpl extends ServiceImpl<CustomerGraphicsMap ...@@ -161,12 +166,14 @@ public class CustomerGraphicsServiceImpl extends ServiceImpl<CustomerGraphicsMap
return checkResult; return checkResult;
} }
} }
// TODO: 2022/10/8 根据人群包条件获取用户公众号,生成链接
byId.setPackId(packId); byId.setPackId(packId);
boolean result = super.updateById(byId); boolean result = super.updateById(byId);
if (result) { if (result) {
// 删除之前设置人群包的时候获取链接生成的数据
referralEntityService.ultimateDeleteReferrals(id, "and account_id is not null");
// 调用异步方法,获取链接
commonAsyncComponent.getAuthListLink(byId, referralEntity);
return new BaseResult().success(); return new BaseResult().success();
} }
return new BaseResult().error("更新失败"); return new BaseResult().error("更新失败");
......
...@@ -14,8 +14,8 @@ import org.springframework.stereotype.Service; ...@@ -14,8 +14,8 @@ import org.springframework.stereotype.Service;
public class ReferralEntityServiceImpl extends ServiceImpl<ReferralEntityMapper, ReferralEntity> implements ReferralEntityService { public class ReferralEntityServiceImpl extends ServiceImpl<ReferralEntityMapper, ReferralEntity> implements ReferralEntityService {
@Override @Override
public void ultimateDeleteReferrals(Long materialId) { public void ultimateDeleteReferrals(Long materialId, String extraCondition) {
super.baseMapper.ultimateDeleteReferrals(materialId); super.baseMapper.ultimateDeleteReferrals(materialId, extraCondition);
} }
} }
...@@ -12,15 +12,12 @@ ...@@ -12,15 +12,12 @@
<select id="getAuthInfoList" resultType="com.yaoyaozw.customer.vo.AuthInfoVO"> <select id="getAuthInfoList" resultType="com.yaoyaozw.customer.vo.AuthInfoVO">
select select
ai.id, ai.account_id as accountId, id, account_id as accountId,
ai.nick_name as accountName, nick_name as accountName,
ai.store_type as storeType, store_type as storeType
se.store_name as storeTypeName from authorizer_info
from authorizer_info ai
left join store_entity se
on ai.store_type = se.store_type
where ai.account_id in where account_id in
<foreach collection="accountSet" item="accountId" separator="," open="(" close=")"> <foreach collection="accountSet" item="accountId" separator="," open="(" close=")">
#{accountId} #{accountId}
</foreach> </foreach>
......
...@@ -27,6 +27,9 @@ ...@@ -27,6 +27,9 @@
<delete id="ultimateDeleteReferrals"> <delete id="ultimateDeleteReferrals">
delete from referral_entity where material_graphics_id = #{sourceId} delete from referral_entity where material_graphics_id = #{sourceId}
<if test="extraCondition != null and extraCondition != ''">
${extraCondition}
</if>
</delete> </delete>
</mapper> </mapper>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论