提交 ee47fc32 作者: 沈振路

延时客服-图文-finish

上级 42445d1d
......@@ -69,11 +69,9 @@ public class CustomerServiceCommonAsyncComponent {
private CustomerGraphicsMapper customerGraphicsMapper;
@Autowired
private KanbanCommonMapper kanbanCommonMapper;
@Autowired
private CustomerGraphicsDelayMapper customerGraphicsDelayMapper;
private CustomerGraphicsDelayService graphicsDelayService;
public void setGraphicsDelayService(CustomerGraphicsDelayService graphicsDelayService) {
this.graphicsDelayService = graphicsDelayService;
}
@Async("myExecutor")
public void addMatchUserIntoPackage(Long packageId, Boolean needRemove) {
......@@ -173,10 +171,8 @@ public class CustomerServiceCommonAsyncComponent {
// 遍历客服素材进行处理
for (CustomerGraphicsDelay sourceGraphics : sourceCustomerList) {
generateDelayExtendLink(dateStr, sourceGraphics, targetAuthInfo);
dispatchCustomerDelayLink(dateStr, sourceGraphics, targetAuthInfo);
}
}
......@@ -343,81 +339,125 @@ public class CustomerServiceCommonAsyncComponent {
* 以下是延时客服 的方法
*/
private void generateDelayExtendLink(String dateStr, CustomerGraphicsDelay sourceGraphics, AuthorizerInfo targetAuthInfo) {
List<ReferralEntity> targetReferralEntityList = new ArrayList<>();
private void dispatchCustomerDelayLink(String dateStr, CustomerGraphicsDelay sourceGraphics, AuthorizerInfo targetAuthInfo) {
// 新建新主体
CustomerGraphicsDelay targetCustomerGraphics = new CustomerGraphicsDelay();
List<ReferralEntity> targetReferralEntityList = new ArrayList<>();
BeanUtil.copyProperties(sourceGraphics, targetCustomerGraphics);
long mainId = snowflakeComponent.snowflakeId();
targetCustomerGraphics.setId(mainId);
// 遍历链接数据进行处理
targetCustomerGraphics.setAuthorizerInfo(targetAuthInfo);
targetCustomerGraphics.setAppId(targetAuthInfo.getAppid());
List<ReferralEntity> sourceReferralList = sourceGraphics.getBelongReferralList();
for (ReferralEntity sourceReferralEntity : sourceReferralList) {
Integer postSort = sourceGraphics.getPostSort();
// 遍历处理客服链接
for (ReferralEntity sourceReferralEntity : sourceReferralList) {
// 生成新的链接数据
ReferralEntity targetReferralEntity = new ReferralEntity();
BeanUtil.copyProperties(sourceReferralEntity, targetReferralEntity);
// 重新生成链接主键id
targetReferralEntity.setId(snowflakeComponent.snowflakeId());
targetReferralEntity.setMaterialGraphicsId(mainId);
targetReferralEntity.setAccountId(targetAuthInfo.getAccountId());
targetReferralEntity.setStoreTypeName(targetAuthInfo.getStoreTypeName());
try {
// 获取链接
AuthInfoVO authInfoVo = new AuthInfoVO();
authInfoVo.putPropertyValue(targetAuthInfo);
getCopyReferral(dateStr, authInfoVo, targetReferralEntity);
targetCustomerGraphics.setSourceUrl(targetReferralEntity.getReferral());
} catch (Exception e) {
LOCAL_LOG.warn("公众号: {} 获取链接异常: {}", targetAuthInfo.getNickName(), e.getMessage());
String name = CustomerCommonConstant.getLinkNameModel(targetReferralEntity.getNewsType());
if (StringUtils.isNotBlank(name)) {
name = name + "-" + postSort;
if (ObjectUtil.isNotNull(targetReferralEntity.getSort())) {
name = name + "-" + targetReferralEntity.getSort();
}
targetReferralEntity.setName(name);
}
Integer newsType = sourceReferralEntity.getNewsType();
// 调用获取链接方法
if (newsType.equals(CustomerCommonConstant.BOOK_NEWS_TYPE)) {
// 是推广链接
generateDelayExtendLink(dateStr, targetReferralEntity, targetAuthInfo);
} else if (newsType.equals(CustomerCommonConstant.ACTIVITY_NEWS_TYPE)) {
// 是活动链接
generateDelayActivityLink(dateStr, targetReferralEntity, targetAuthInfo);
} else if (newsType.equals(CustomerCommonConstant.USUAL_LINK_NEWS_TYPE)) {
// 常用链接
} else {
LOCAL_LOG.info("newsType: {}, 不需要获取链接", newsType);
}
targetReferralEntityList.add(targetReferralEntity);
// 图文主表只有一个素材链接,文本主表不需要存素材链接
targetCustomerGraphics.setSourceUrl(targetReferralEntity.getReferral());
}
targetCustomerGraphics.setSendStatus(CustomerCommonConstant.SEND_STATUS_LINK_FINISH);
LOCAL_LOG.info("保存主体数据, 主体id: {}", mainId);
graphicsDelayService.save(targetCustomerGraphics);
customerGraphicsDelayMapper.insert(targetCustomerGraphics);
LOCAL_LOG.info("准备保存, 共生成链接数据 : {} 条", targetReferralEntityList.size());
referralEntityService.saveBatch(targetReferralEntityList);
}
private void generateDelayActivityLink(String dateStr, CustomerGraphicsDelay sourceGraphics, AuthorizerInfo targetAuthInfo) {
List<ReferralEntity> targetReferralEntityList = new ArrayList<>();
// 新建新主体
CustomerGraphicsDelay targetCustomerGraphics = new CustomerGraphicsDelay();
long mainId = snowflakeComponent.snowflakeId();
targetCustomerGraphics.setId(mainId);
private void generateDelayExtendLink(String dateStr, ReferralEntity targetReferralEntity, AuthorizerInfo targetAuthInfo) {
// 遍历链接数据进行处理
List<ReferralEntity> sourceReferralList = sourceGraphics.getBelongReferralList();
for (ReferralEntity sourceReferralEntity : sourceReferralList) {
try {
// 获取链接
AuthInfoVO authInfoVo = new AuthInfoVO();
authInfoVo.putPropertyValue(targetAuthInfo);
getCopyReferral(dateStr, authInfoVo, targetReferralEntity);
} catch (Exception e) {
LOCAL_LOG.warn("公众号: {} 获取链接异常: {}", targetAuthInfo.getNickName(), e.getMessage());
}
}
ReferralEntity targetReferralEntity = new ReferralEntity();
BeanUtil.copyProperties(sourceReferralEntity, targetReferralEntity);
private void generateDelayActivityLink(String dateStr, ReferralEntity targetReferralEntity, AuthorizerInfo targetAuthInfo) {
String storeType = targetReferralEntity.getStoreType();
boolean isLegal = true;
String configId = null;
String activityContent = targetReferralEntity.getRechargeAmount().stripTrailingZeros().toPlainString() + "送" + targetReferralEntity.getGiftAmount();
// 阳光、掌中云 需要获取configId
if (storeType.equals(CustomerCommonConstant.STORE_NAME_YANG_GUANG) || storeType.equals(CustomerCommonConstant.STORE_NAME_ZHANG_ZHONG_YUN)) {
R activityConfig = referralFeignClient.getActivityConfig(targetReferralEntity.getRechargeAmount().stripTrailingZeros().toPlainString(), storeType, null);
// 获取资源配置列表
Map<String, Object> data = activityConfig.getData();
JSONArray configList = JSONUtil.parseArray(data.get("configList"));
List<CommonOptionResponseVO> activityConfigList = JSONUtil.toList(configList, CommonOptionResponseVO.class);
if (!CollectionUtil.isEmpty(activityConfigList)) {
// 转换config
Map<String, String> configMap = activityConfigList.stream().collect(Collectors.toMap(key -> key.getLabel().replaceAll("[^(0-9.送)]", ""), CommonOptionResponseVO::getValue, (o1, o2) -> o2));
configId = configMap.get(activityContent);
LOCAL_LOG.info("活动内容: {} 获取到configId: {}", activityContent, configId);
if (ObjectUtil.isNull(configId)) {
isLegal = false;
}
} else {
isLegal = false;
LOCAL_LOG.info("无法获取资源配置");
}
}
targetReferralEntity.setConfigId(configId);
String tempId = CustomerStoreTemplateEnum.getTempId(storeType);
targetReferralEntity.setTemplateId(tempId);
if (isLegal) {
// 重新生成链接主键id
targetReferralEntity.setId(snowflakeComponent.snowflakeId());
targetReferralEntity.setMaterialGraphicsId(mainId);
targetReferralEntity.setAccountId(targetAuthInfo.getAccountId());
targetReferralEntity.setStoreTypeName(targetAuthInfo.getStoreTypeName());
try {
// 获取链接
AuthInfoVO authInfoVo = new AuthInfoVO();
authInfoVo.putPropertyValue(targetAuthInfo);
getCopyReferral(dateStr, authInfoVo, targetReferralEntity);
targetCustomerGraphics.setSourceUrl(targetReferralEntity.getReferral());
} catch (Exception e) {
LOCAL_LOG.warn("公众号: {} 获取链接异常: {}", targetAuthInfo.getNickName(), e.getMessage());
targetReferralEntity.setReferral("error");
}
targetReferralEntityList.add(targetReferralEntity);
}
targetCustomerGraphics.setSendStatus(CustomerCommonConstant.SEND_STATUS_LINK_FINISH);
LOCAL_LOG.info("保存主体数据, 主体id: {}", mainId);
graphicsDelayService.save(targetCustomerGraphics);
LOCAL_LOG.info("准备保存, 共生成链接数据 : {} 条", targetReferralEntityList.size());
referralEntityService.saveBatch(targetReferralEntityList);
}
......@@ -430,7 +470,7 @@ public class CustomerServiceCommonAsyncComponent {
/**
* 以下是公有方法
*/
private void getCopyReferral(String dateStr, AuthInfoVO authInfoVo, ReferralEntity referralEntity) {
public void getCopyReferral(String dateStr, AuthInfoVO authInfoVo, ReferralEntity referralEntity) {
referralEntity.setStoreType(authInfoVo.getStoreType());
// 非常用链接类型的name需要处理
String name = referralEntity.getName();
......
......@@ -41,6 +41,9 @@ public class CustomerDelaySaveDTO implements Serializable {
@ApiModelProperty("发文间隔时间")
private Long timeInterval;
@ApiModelProperty("已支付、未支付")
private Integer isPay;
@ApiModelProperty("消息内容实体")
private CustomerReferralDTO customerReferralDto;
......
......@@ -44,6 +44,11 @@ public class CustomerGraphicsDelay implements Serializable {
@TableField(value = "extend_title")
private String extendTitle;
/**
* 封面图片地址
*/
@TableField(value = "cover_url")
private String coverUrl;
/**
* 文本内容
......@@ -64,6 +69,12 @@ public class CustomerGraphicsDelay implements Serializable {
private String sourceUrl;
/**
* 是否支付
*/
@TableField(value = "is_pay")
private Integer isPay;
/**
* 是否是历史遗留
*/
@TableField(value = "is_history")
......
......@@ -50,9 +50,10 @@ public interface CustomerGraphicsDelayMapper extends BaseMapper<CustomerGraphics
* @param keyword 关键词
* @param keywordList 关键词拆分
* @param storeType 书城
* @param appId 需要排除的公众号appId
* @return {@link List}<{@link AuthInfoVO}>
*/
List<AuthInfoVO> getAuthList(@Param("keyword") String keyword, @Param("keywordList") List<String> keywordList, @Param("storeType") String storeType);
List<AuthInfoVO> getAuthList(@Param("keyword") String keyword, @Param("keywordList") List<String> keywordList, @Param("storeType") String storeType, @Param("appId") String appId);
/**
* 让时间间隔列表
......
......@@ -36,6 +36,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
......@@ -78,7 +79,6 @@ public class CustomerGraphicsDelayServiceImpl extends ServiceImpl<CustomerGraphi
}
@Override
@Transactional(rollbackFor = Exception.class)
public BaseResult insertCustomerDelay(CustomerDelaySaveDTO saveDto) {
CustomerGraphicsDelay customerGraphicsDelay = new CustomerGraphicsDelay();
......@@ -92,23 +92,45 @@ public class CustomerGraphicsDelayServiceImpl extends ServiceImpl<CustomerGraphi
}
customerGraphicsDelay.setSendStatus(CustomerCommonConstant.SEND_STATUS_LINK_GETTING);
localLog.info("生成referral数据");
ReferralEntity referralEntity = new ReferralEntity();
BeanUtil.copyProperties(saveDto.getCustomerReferralDto(), referralEntity);
referralEntity.setMaterialGraphicsId(customerGraphicsDelay.getId());
// 非自定义获取链接
if (!referralEntity.getNewsType().equals(-1)) {
try {
localLog.info("准备获取链接");
String linkNameModel = CustomerCommonConstant.getLinkNameModel(referralEntity.getNewsType());
localLog.info("获取链接name模板: {}", linkNameModel);
referralEntity.setName(linkNameModel);
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
String dateStr = dateFormat.format(new Date());
AuthorizerInfo authorizerInfo = authorizerInfoService.getOne(new QueryWrapper<AuthorizerInfo>().eq("appid", saveDto.getAppId()));
AuthInfoVO authInfoVO = new AuthInfoVO();
authInfoVO.putPropertyValue(authorizerInfo);
commonAsyncComponent.getCopyReferral(dateStr, authInfoVO, referralEntity);
customerGraphicsDelay.setSendStatus(CustomerCommonConstant.SEND_STATUS_LINK_FINISH);
localLog.info("链接获取完成");
} catch (Exception e) {
localLog.info("获取链接异常");
return new BaseResult().error("获取链接异常");
}
}
customerGraphicsDelay.setSourceUrl(referralEntity.getReferral());
boolean mainResult = super.saveOrUpdate(customerGraphicsDelay);
if (!mainResult) {
localLog.info("主体数据生成异常");
return new BaseResult().error("新增/更新 主体数据异常");
}
localLog.info("生成referral数据");
ReferralEntity referralEntity = new ReferralEntity();
referralEntity.setMaterialGraphicsId(customerGraphicsDelay.getId());
BeanUtil.copyProperties(referralEntity, saveDto.getCustomerReferralDto());
boolean referralResult = referralEntityService.saveOrUpdate(referralEntity);
if (!referralResult) {
localLog.info("referral数据生成异常, 回滚事务");
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return new BaseResult().error("新增/更新 链接数据异常");
}
// TODO: 2022/10/14 生成链接
return new BaseResult().success();
}
......@@ -221,7 +243,7 @@ public class CustomerGraphicsDelayServiceImpl extends ServiceImpl<CustomerGraphi
keyword = null;
}
List<AuthInfoVO> authList = super.baseMapper.getAuthList(keyword, keywordList, storeType);
List<AuthInfoVO> authList = super.baseMapper.getAuthList(keyword, keywordList, storeType, appId);
return new GenericsResult<>(authList);
}
......
......@@ -29,14 +29,25 @@ public class CustomerDelayGraphicsDetailVO implements Serializable {
private String type;
@ApiModelProperty("是否支付 0-否 1-是")
@JsonSerialize(using = ToStringSerializer.class)
private Integer isPay;
@ApiModelProperty("素材图片路径")
private String coverUrl;
@ApiModelProperty("推广标题")
private String extendTitle;
@ApiModelProperty("素材文本内容")
private String content;
@ApiModelProperty("素材文本内容")
private Integer postSort;
@ApiModelProperty("时间间隔")
@JsonSerialize(using = ToStringSerializer.class)
private Long timeInterval;
@ApiModelProperty("链接相关内容")
private CustomerReferralDTO customerReferralDto;
......
......@@ -31,7 +31,7 @@ public class CustomerMessageDetailVO implements Serializable {
@ApiModelProperty("客服消息类型(图文、文本)")
private String type;
@ApiModelProperty("素材文本内容")
@ApiModelProperty("推广标题")
private String extendTitle;
@ApiModelProperty("素材图片路径")
......
......@@ -110,6 +110,9 @@
<if test="storeType != null and storeType != ''">
and store_type = #{storeType}
</if>
<if test="appId != null and appId != ''">
and appId != #{appId}
</if>
</where>
</select>
</mapper>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论