提交 ad3dc645 作者: 沈振路

客服消息预览接口

上级 3b5d3d83
...@@ -5,10 +5,10 @@ import com.yaoyaozw.customer.annotations.OperateLog; ...@@ -5,10 +5,10 @@ import com.yaoyaozw.customer.annotations.OperateLog;
import com.yaoyaozw.customer.common.BaseResult; import com.yaoyaozw.customer.common.BaseResult;
import com.yaoyaozw.customer.common.GenericsResult; import com.yaoyaozw.customer.common.GenericsResult;
import com.yaoyaozw.customer.dto.customer.CustomerBatchSetPackDTO; import com.yaoyaozw.customer.dto.customer.CustomerBatchSetPackDTO;
import com.yaoyaozw.customer.dto.customer.CustomerGraphicsPreviewDTO;
import com.yaoyaozw.customer.dto.customer.CustomerMessageQueryDTO; import com.yaoyaozw.customer.dto.customer.CustomerMessageQueryDTO;
import com.yaoyaozw.customer.dto.customer.CustomerMessageSaveDTO; import com.yaoyaozw.customer.dto.customer.CustomerMessageSaveDTO;
import com.yaoyaozw.customer.service.CustomerGraphicsService; import com.yaoyaozw.customer.service.CustomerGraphicsService;
import com.yaoyaozw.customer.vo.customer.CustomerDelayListVO;
import com.yaoyaozw.customer.vo.customer.CustomerMessageDetailVO; import com.yaoyaozw.customer.vo.customer.CustomerMessageDetailVO;
import com.yaoyaozw.customer.vo.customer.CustomerMessageListVO; import com.yaoyaozw.customer.vo.customer.CustomerMessageListVO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -16,7 +16,6 @@ import io.swagger.annotations.ApiOperation; ...@@ -16,7 +16,6 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
...@@ -74,4 +73,10 @@ public class CustomerMessageGraphicsController { ...@@ -74,4 +73,10 @@ public class CustomerMessageGraphicsController {
return new BaseResult().success("批量生成中,请稍后查看"); return new BaseResult().success("批量生成中,请稍后查看");
} }
@ApiOperation("预览发文")
@PostMapping("/previewGraphics")
public BaseResult previewGraphics(@RequestBody CustomerGraphicsPreviewDTO previewDTO) {
return customerGraphicsService.previewGraphics(previewDTO);
}
} }
package com.yaoyaozw.customer.dto.customer;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 预览图文DTO
* @author system
* @date 2024/01/01
*/
@Data
@ApiModel("预览图文DTO")
public class CustomerGraphicsPreviewDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("客服消息ID")
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
@ApiModelProperty("授权方ID")
@JsonSerialize(using = ToStringSerializer.class)
private Long authId;
@ApiModelProperty("用户OpenId")
private String userOpenId;
}
...@@ -3,6 +3,7 @@ package com.yaoyaozw.customer.service; ...@@ -3,6 +3,7 @@ package com.yaoyaozw.customer.service;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.yaoyaozw.customer.common.BaseResult; import com.yaoyaozw.customer.common.BaseResult;
import com.yaoyaozw.customer.common.GenericsResult; import com.yaoyaozw.customer.common.GenericsResult;
import com.yaoyaozw.customer.dto.customer.CustomerGraphicsPreviewDTO;
import com.yaoyaozw.customer.dto.customer.CustomerMessageQueryDTO; import com.yaoyaozw.customer.dto.customer.CustomerMessageQueryDTO;
import com.yaoyaozw.customer.dto.customer.CustomerMessageSaveDTO; import com.yaoyaozw.customer.dto.customer.CustomerMessageSaveDTO;
import com.yaoyaozw.customer.dto.integration.IntegrationRequestDTO; import com.yaoyaozw.customer.dto.integration.IntegrationRequestDTO;
...@@ -80,5 +81,12 @@ public interface CustomerGraphicsService extends IService<CustomerGraphics> { ...@@ -80,5 +81,12 @@ public interface CustomerGraphicsService extends IService<CustomerGraphics> {
*/ */
void sendCustomerMessage(IntegrationRequestDTO integrationRequestDTO); void sendCustomerMessage(IntegrationRequestDTO integrationRequestDTO);
/**
* 预览图文
* @param previewDTO 预览参数DTO
* @return {@link BaseResult}
*/
BaseResult previewGraphics(CustomerGraphicsPreviewDTO previewDTO);
} }
...@@ -16,6 +16,7 @@ import com.yaoyaozw.customer.components.TokenManager; ...@@ -16,6 +16,7 @@ import com.yaoyaozw.customer.components.TokenManager;
import com.yaoyaozw.customer.constants.CrowdPackageCommonConstant; import com.yaoyaozw.customer.constants.CrowdPackageCommonConstant;
import com.yaoyaozw.customer.constants.CustomerCommonConstant; import com.yaoyaozw.customer.constants.CustomerCommonConstant;
import com.yaoyaozw.customer.dto.customer.CustomerBatchSetPackDTO; import com.yaoyaozw.customer.dto.customer.CustomerBatchSetPackDTO;
import com.yaoyaozw.customer.dto.customer.CustomerGraphicsPreviewDTO;
import com.yaoyaozw.customer.dto.customer.CustomerMessageQueryDTO; import com.yaoyaozw.customer.dto.customer.CustomerMessageQueryDTO;
import com.yaoyaozw.customer.dto.customer.CustomerMessageSaveDTO; import com.yaoyaozw.customer.dto.customer.CustomerMessageSaveDTO;
import com.yaoyaozw.customer.dto.integration.IntegrationRequestDTO; import com.yaoyaozw.customer.dto.integration.IntegrationRequestDTO;
...@@ -85,6 +86,9 @@ public class CustomerGraphicsServiceImpl extends ServiceImpl<CustomerGraphicsMap ...@@ -85,6 +86,9 @@ public class CustomerGraphicsServiceImpl extends ServiceImpl<CustomerGraphicsMap
@Autowired @Autowired
private CrowdPackageService crowdPackageService; private CrowdPackageService crowdPackageService;
@Autowired
private AuthorizerInfoService authorizerInfoService;
@Override @Override
public BaseResult insertCustomerMessage(CustomerMessageSaveDTO saveDto) { public BaseResult insertCustomerMessage(CustomerMessageSaveDTO saveDto) {
...@@ -372,6 +376,45 @@ public class CustomerGraphicsServiceImpl extends ServiceImpl<CustomerGraphicsMap ...@@ -372,6 +376,45 @@ public class CustomerGraphicsServiceImpl extends ServiceImpl<CustomerGraphicsMap
} }
} }
@Override
public BaseResult previewGraphics(CustomerGraphicsPreviewDTO previewDTO) {
// 用id查询 customer_graphics 表,获取主体类
CustomerGraphics customerGraphics = super.getById(previewDTO.getId());
if (ObjectUtil.isNull(customerGraphics)) {
return new BaseResult().error("找不到客服消息主体数据");
}
// 用 authId 查询 authorizer_info 表
AuthorizerInfo authorizerInfo = authorizerInfoService.getById(previewDTO.getAuthId());
if (ObjectUtil.isNull(authorizerInfo)) {
return new BaseResult().error("找不到授权方信息");
}
// 调用 referralEntityService.findReferralByCustomerGraphicsId 传入 id,查询referral 列表
List<ReferralEntityVo> referralList = referralEntityService.findReferralByCustomerGraphicsId(previewDTO.getId());
// 筛选 account_id = authorizer_info.account_id 的记录
List<ReferralEntityVo> filteredReferralList = referralList.stream()
.filter(referral -> Objects.equals(referral.getAccountId(), authorizerInfo.getAccountId()))
.collect(Collectors.toList());
if (CollectionUtil.isEmpty(filteredReferralList)) {
return new BaseResult().error("找不到公众号:" + authorizerInfo.getNickName() + " 对应的推广内容,请确保公众号在生成范围内,或联系技术进行查看");
}
// 构造 CrowdPackageUserVO 列表(只有一个用户,openId = userOpenId)
CrowdPackageUserVO userVO = new CrowdPackageUserVO();
userVO.setOpenId(previewDTO.getUserOpenId());
userVO.setAppId(authorizerInfo.getAppid());
userVO.setAccountId(authorizerInfo.getAccountId());
List<CrowdPackageUserVO> openidList = CollectionUtil.newArrayList(userVO);
// 调用 weChatService.sendCustomerMessage 进行处理
weChatService.sendCustomerMessage(authorizerInfo.getAppid(), customerGraphics, openidList, filteredReferralList);
return new BaseResult().success("预览消息已发起,请稍后查看");
}
private BaseResult checkExtendBook(String storeType, CrowdPackageConditionMatch storeConditionMatch) { private BaseResult checkExtendBook(String storeType, CrowdPackageConditionMatch storeConditionMatch) {
// 判断有没有选书城条件 // 判断有没有选书城条件
if (ObjectUtil.isNull(storeConditionMatch)) { if (ObjectUtil.isNull(storeConditionMatch)) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论