提交 0fe4a73a 作者: 沈振路

Merge remote-tracking branch 'origin/master'

......@@ -498,7 +498,7 @@ public class CustomerServiceCommonAsyncComponent {
CustomerGraphicsDelay targetCustomerGraphics = new CustomerGraphicsDelay();
List<ReferralEntity> targetReferralEntityList = new ArrayList<>();
BeanUtil.copyProperties(sourceGraphics, targetCustomerGraphics, "sourceUrl");
BeanUtil.copyProperties(sourceGraphics, targetCustomerGraphics, "sourceUrl", "mpPath", "mpAppIds");
long mainId = snowflakeComponent.snowflakeId();
targetCustomerGraphics.setId(mainId);
targetCustomerGraphics.setAuthorizerInfo(targetAuthInfo);
......@@ -516,7 +516,7 @@ public class CustomerServiceCommonAsyncComponent {
for (ReferralEntity sourceReferralEntity : sourceReferralList) {
// 生成新的链接数据
ReferralEntity targetReferralEntity = new ReferralEntity();
BeanUtil.copyProperties(sourceReferralEntity, targetReferralEntity, "referral");
BeanUtil.copyProperties(sourceReferralEntity, targetReferralEntity, "referral", "mpAppId", "mpPath");
if (sourceReferralEntity.getNewsType().equals(-1)) {
// 自定义链接延用链接
targetReferralEntity.setReferral(companyAcquisitionLinkService.checkAndSearchTargetReferral(sourceReferralEntity.getReferral(), targetAuthInfo.getId()));
......@@ -550,6 +550,11 @@ public class CustomerServiceCommonAsyncComponent {
normal = false;
}
targetCustomerGraphics.setSourceUrl(referral);
if (CUSTOMER_TYPE_VALUE_MINI_PROGRAM.equals(targetCustomerGraphics.getType())) {
// 小程序类型
targetCustomerGraphics.setMpPath(targetReferralEntity.getMpPath());
targetCustomerGraphics.setMpAppId(targetReferralEntity.getMpAppId());
}
if (type.equals(CustomerCommonConstant.CUSTOMER_TYPE_VALUE_TEXT)) {
// 文本类型替换h5链接
String context = null;
......
......@@ -28,12 +28,27 @@ public class CustomerDelaySaveDTO implements Serializable {
@ApiModelProperty("客服消息类型(图文、文本)")
private String type;
@ApiModelProperty("客服消息类型(图文、文本)")
@ApiModelProperty("推广标题")
private String extendTitle;
@ApiModelProperty("客服消息类型(图文、文本)")
@ApiModelProperty("方面路径")
private String coverUrl;
@ApiModelProperty("图片/音频 腾讯后台地址")
private String txMediaUrl;
@ApiModelProperty("图片/音频 腾讯后台标识")
private String txMediaId;
@ApiModelProperty("小程序标题")
private String mpTitle;
@ApiModelProperty("小程序appId")
private String mpAppId;
@ApiModelProperty("小程序跳转路径")
private String mpPath;
@ApiModelProperty("文本内容")
private String content;
......
......@@ -51,6 +51,36 @@ public class CustomerGraphicsDelay implements Serializable {
private String coverUrl;
/**
* 图片/音频 腾讯后台地址
*/
@TableField(value = "tx_media_url")
private String txMediaUrl;
/**
* 图片/音频 腾讯后台标识
*/
@TableField(value = "tx_media_id")
private String txMediaId;
/**
* 小程序标题
*/
@TableField(value = "mp_title")
private String mpTitle;
/**
* 小程序appId
*/
@TableField(value = "mp_app_id")
private String mpAppId;
/**
* 小程序跳转路径
*/
@TableField(value = "mp_path")
private String mpPath;
/**
* 文本内容
*/
@TableField(value = "content")
......
......@@ -13,12 +13,14 @@ import com.yaoyaozw.customer.components.CustomerServiceCommonAsyncComponent;
import com.yaoyaozw.customer.components.SnowflakeComponent;
import com.yaoyaozw.customer.components.TokenManager;
import com.yaoyaozw.customer.constants.CustomerCommonConstant;
import com.yaoyaozw.customer.constants.CustomerMaterialConstant;
import com.yaoyaozw.customer.dto.customer.CustomerDelayQueryDTO;
import com.yaoyaozw.customer.dto.customer.CustomerDelaySaveDTO;
import com.yaoyaozw.customer.entity.CommonReferralBody;
import com.yaoyaozw.customer.entity.AuthorizerInfo;
import com.yaoyaozw.customer.entity.CustomerGraphicsDelay;
import com.yaoyaozw.customer.entity.ReferralEntity;
import com.yaoyaozw.customer.exception.BaseException;
import com.yaoyaozw.customer.mapper.AuthorizerTokenMapper;
import com.yaoyaozw.customer.mapper.CustomerGraphicsDelayMapper;
import com.yaoyaozw.customer.mapper.KanbanCommonMapper;
......@@ -26,7 +28,9 @@ import com.yaoyaozw.customer.mapper.MaterialCommonMapper;
import com.yaoyaozw.customer.service.AuthorizerInfoService;
import com.yaoyaozw.customer.service.CustomerGraphicsDelayService;
import com.yaoyaozw.customer.service.ReferralEntityService;
import com.yaoyaozw.customer.utils.TencentCustomerUtil;
import com.yaoyaozw.customer.vo.AuthInfoVO;
import com.yaoyaozw.customer.vo.TencentMediaResponseVO;
import com.yaoyaozw.customer.vo.kanban.AccountSetupVO;
import com.yaoyaozw.customer.vo.kanban.CommonOptionResponseVO;
import com.yaoyaozw.customer.vo.customer.CustomerDelayGraphicsDetailVO;
......@@ -48,6 +52,8 @@ import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static com.yaoyaozw.customer.constants.CustomerCommonConstant.CUSTOMER_TYPE_VALUE_MINI_PROGRAM;
/**
* @author darker
* @date 2022/9/15 11:13
......@@ -79,6 +85,8 @@ public class CustomerGraphicsDelayServiceImpl extends ServiceImpl<CustomerGraphi
private RedisTemplate<String, Object> redisTemplate;
@Autowired
private AuthorizerTokenMapper authorizerTokenMapper;
@Autowired
private TencentCustomerUtil tencentCustomerUtil;
@Override
......@@ -122,8 +130,16 @@ public class CustomerGraphicsDelayServiceImpl extends ServiceImpl<CustomerGraphi
localLog.info("生成referral数据");
ReferralEntity referralEntity = new ReferralEntity();
BeanUtil.copyProperties(saveDto.getCustomerReferralDto(), referralEntity);
// 将标题字段,赋值给referral体
CommonReferralBody commonReferralBody = saveDto.getCustomerReferralDto();
if (CUSTOMER_TYPE_VALUE_MINI_PROGRAM.equals(customerGraphicsDelay.getType())) {
customerGraphicsDelay.setMpTitle(customerGraphicsDelay.getExtendTitle());
commonReferralBody.setMpTitle(customerGraphicsDelay.getMpTitle());
}
BeanUtil.copyProperties(commonReferralBody, referralEntity);
referralEntity.setMaterialGraphicsId(customerGraphicsDelay.getId());
referralEntity.setCustomerMsgType(customerGraphicsDelay.getType());
// 非自定义获取链接
if (!referralEntity.getNewsType().equals(-1)) {
......@@ -146,6 +162,11 @@ public class CustomerGraphicsDelayServiceImpl extends ServiceImpl<CustomerGraphi
commonAsyncComponent.dispatchDelay(dateStr, authInfoVO, referralEntity);
customerGraphicsDelay.setSendStatus(CustomerCommonConstant.SEND_STATUS_ACTIVE);
localLog.info("链接获取完成");
try {
handleTxMedia(customerGraphicsDelay, authorizerInfo);
} catch (Exception e) {
return new BaseResult().error("上传素材异常:" + e.getMessage());
}
} catch (Exception e) {
localLog.info("获取链接异常");
return new BaseResult().error("获取链接异常" + e.getMessage());
......@@ -153,6 +174,10 @@ public class CustomerGraphicsDelayServiceImpl extends ServiceImpl<CustomerGraphi
}
try {
customerGraphicsDelay.setSourceUrl(referralEntity.getReferral());
if (CUSTOMER_TYPE_VALUE_MINI_PROGRAM.equals(customerGraphicsDelay.getType())) {
customerGraphicsDelay.setMpPath(referralEntity.getMpPath());
}
customerGraphicsDelay.setMpAppId(referralEntity.getMpAppId());
} catch (Exception e) {
return new BaseResult().error(e.getMessage());
}
......@@ -172,6 +197,29 @@ public class CustomerGraphicsDelayServiceImpl extends ServiceImpl<CustomerGraphi
return new BaseResult().success();
}
private void handleTxMedia(CustomerGraphicsDelay entity, AuthorizerInfo authorizerInfo) {
if (CustomerMaterialConstant.needUpload(entity.getType())) {
// 编辑的时候,删除原来的media
if (entity.getId() != null) {
if (StringUtils.isNotBlank(entity.getTxMediaId())) {
TencentMediaResponseVO removeResponse = tencentCustomerUtil.removePermanentMedia(authorizerInfo.getAppid(), entity.getTxMediaId());
if (ObjectUtil.isNull(removeResponse.getErrcode()) || removeResponse.getErrcode() != 0) {
throw new BaseException("删除原本素材失败: " + removeResponse.getErrmsg());
}
}
}
// 上传文件
TencentMediaResponseVO uploadResponse = tencentCustomerUtil.uploadTencentMedia(authorizerInfo.getAppid(), entity.getCoverUrl(), entity.getType());
if (StringUtils.isNotBlank(uploadResponse.getErrmsg())) {
// 上传失败
throw new BaseException("上传素材失败: " + uploadResponse.getErrmsg());
}
entity.setTxMediaUrl(uploadResponse.getUrl());
entity.setTxMediaId(uploadResponse.getMedia_id());
}
}
@Override
public GenericsResult<CustomerDelayGraphicsDetailVO> getCustomerDelayDetail(Long id) {
CustomerGraphicsDelay customerGraphicsDelay = super.getById(id);
......@@ -296,6 +344,11 @@ public class CustomerGraphicsDelayServiceImpl extends ServiceImpl<CustomerGraphi
// 遍历要复用的素材
for (CustomerGraphicsDelay item : sourceCustomerList) {
// 清空原本的链接等公众号专属字段
item.setSourceUrl(null);
item.setMpPath(null);
item.setMpAppId(null);
// 设置所属链接
item.setBelongReferralList(referralGroupMap.get(item.getId()));
// 为公众号设置书城名
......
......@@ -201,6 +201,9 @@ public class WeChatServiceImpl implements WeChatService{
}
//图文类
return new WeChatCustomerRequestEntity(CUSTOMER_NEWS,customerDelay.getExtendTitle(),customerDelay.getContent(),customerDelay.getSourceUrl(),customerDelay.getCoverUrl());
} else if (CUSTOMER_MP.equals(customerDelay.getType())) {
return WeChatCustomerRequestEntity.miniProgram(customerDelay.getMpTitle(), customerDelay.getMpAppId(), customerDelay.getMpPath(), customerDelay.getTxMediaId());
}
return null;
}
......
......@@ -37,6 +37,21 @@ public class CustomerDelayGraphicsDetailVO implements Serializable {
@ApiModelProperty("素材图片路径")
private String coverUrl;
@ApiModelProperty("图片/音频 腾讯后台地址")
private String txMediaUrl;
@ApiModelProperty("图片/音频 腾讯后台标识")
private String txMediaId;
@ApiModelProperty("小程序标题")
private String mpTitle;
@ApiModelProperty("小程序appId")
private String mpAppId;
@ApiModelProperty("小程序跳转路径")
private String mpPath;
@ApiModelProperty("推广标题")
private String extendTitle;
......
package com.yaoyaozw.customer.vo.customer;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
......@@ -75,6 +76,19 @@ public class CustomerDelayItemVO implements Serializable {
*/
private final Object LOCK;
@ApiModelProperty("图片/音频 腾讯后台标识")
private String txMediaId;
@ApiModelProperty("小程序标题")
private String mpTitle;
@ApiModelProperty("小程序appId")
private String mpAppId;
@ApiModelProperty("小程序跳转路径")
private String mpPath;
public CustomerDelayItemVO() {
this.LOCK=new Object();
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论