提交 8acace10 作者: 卢宇

菜单资源配置小程序客服消息推送适配

上级 0d88aedd
...@@ -59,10 +59,14 @@ public class CustomerCommonConstant { ...@@ -59,10 +59,14 @@ public class CustomerCommonConstant {
public final static String CUSTOMER_TYPE_VALUE_TEXT = "text"; public final static String CUSTOMER_TYPE_VALUE_TEXT = "text";
public final static String CUSTOMER_TYPE_VALUE_MINI_PROGRAM = "miniProgram";
public final static String CUSTOMER_TYPE_NAME_GRAPHICS = "图文"; public final static String CUSTOMER_TYPE_NAME_GRAPHICS = "图文";
public final static String CUSTOMER_TYPE_NAME_TEXT = "文本"; public final static String CUSTOMER_TYPE_NAME_TEXT = "文本";
public final static String CUSTOMER_TYPE_NAME_MINI_PROGRAM = "小程序";
public final static Integer SEND_STATUS_WAITING = 0; public final static Integer SEND_STATUS_WAITING = 0;
public final static Integer SEND_STATUS_LINK_GETTING = 1; public final static Integer SEND_STATUS_LINK_GETTING = 1;
...@@ -82,11 +86,13 @@ public class CustomerCommonConstant { ...@@ -82,11 +86,13 @@ public class CustomerCommonConstant {
if (ObjectUtil.isNull(type)) { if (ObjectUtil.isNull(type)) {
return null; return null;
} }
if (type.equals(CUSTOMER_TYPE_VALUE_GRAPHICS)) { switch (type) {
return CUSTOMER_TYPE_NAME_GRAPHICS; case CUSTOMER_TYPE_VALUE_GRAPHICS:
} return CUSTOMER_TYPE_NAME_GRAPHICS;
if (type.equals(CUSTOMER_TYPE_VALUE_TEXT)) { case CUSTOMER_TYPE_VALUE_TEXT:
return CUSTOMER_TYPE_NAME_TEXT; return CUSTOMER_TYPE_NAME_TEXT;
case CUSTOMER_TYPE_VALUE_MINI_PROGRAM:
return CUSTOMER_TYPE_NAME_MINI_PROGRAM;
} }
return type; return type;
} }
......
package com.yaoyaozw.customer.controller;
import com.yaoyaozw.customer.annotations.OperateLog;
import com.yaoyaozw.customer.common.BaseResult;
import com.yaoyaozw.customer.common.GenericsResult;
import com.yaoyaozw.customer.dto.customer.CustomerMessageMiniProgramSaveDTO;
import com.yaoyaozw.customer.dto.customer.CustomerMessageTextSaveDTO;
import com.yaoyaozw.customer.entity.CommonReferralBody;
import com.yaoyaozw.customer.service.CustomerGraphicsMiniProgramService;
import com.yaoyaozw.customer.service.CustomerGraphicsTextService;
import com.yaoyaozw.customer.vo.customer.CustomerMessageTextDetailVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* @author Luy
* @date 2024/8/6 11:13
*/
@Api(tags = "客服消息接口-小程序")
@RestController
@RequestMapping("/customer-service/message/miniProgram")
public class CustomerMessageMiniProgramController {
@Autowired
private CustomerGraphicsMiniProgramService miniProgramService;
@ApiOperation("新增客服主体")
@PostMapping("/insertCustomerMessage")
@OperateLog(module = "客服消息-小程序", desc = "新增小程序客服消息")
public BaseResult insertCustomerMessage(@RequestBody CustomerMessageMiniProgramSaveDTO saveDto) {
return miniProgramService.insertCustomerMessage(saveDto);
}
@ApiOperation("获取文本客服详情")
@GetMapping("/detail/{id}")
public GenericsResult<CustomerMessageMiniProgramSaveDTO> getCustomerTextDetail(@PathVariable("id") Long id) {
return miniProgramService.getCustomerTextDetail(id);
}
}
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/10/12 16:33
*/
@Data
@ApiModel("小程序类型客服保存实体")
public class CustomerMessageMiniProgramSaveDTO implements Serializable {
@ApiModelProperty("客服消息id")
private Long id;
@ApiModelProperty("标题")
private String name;
@ApiModelProperty("消息发送时间")
private String postTime;
@ApiModelProperty("客服消息类型(图文,文本,小程序)")
private String type;
@ApiModelProperty("小程序标题")
private String mpTitle;
@ApiModelProperty("小程序appId")
private String mpAppId;
@ApiModelProperty("小程序跳转路径")
private String mpPath;
}
...@@ -214,6 +214,18 @@ public class ReferralEntity implements Serializable { ...@@ -214,6 +214,18 @@ public class ReferralEntity implements Serializable {
@JsonSerialize(using = ToStringSerializer.class) @JsonSerialize(using = ToStringSerializer.class)
private Long infoId; private Long infoId;
@TableField(value = "mp_title")
@ApiModelProperty("小程序标题")
private String mpTitle;
@TableField(value = "mp_app_id")
@ApiModelProperty("小程序appId")
private String mpAppId;
@TableField(value = "mp_path")
@ApiModelProperty("小程序跳转路径")
private String mpPath;
@TableField(exist = false) @TableField(exist = false)
private String h5Content; private String h5Content;
......
package com.yaoyaozw.customer.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yaoyaozw.customer.common.BaseResult;
import com.yaoyaozw.customer.common.GenericsResult;
import com.yaoyaozw.customer.dto.customer.CustomerMessageMiniProgramSaveDTO;
import com.yaoyaozw.customer.dto.customer.CustomerMessageTextSaveDTO;
import com.yaoyaozw.customer.entity.CustomerGraphics;
public interface CustomerGraphicsMiniProgramService extends IService<CustomerGraphics> {
/**
* 新增小程序客服消息
* @param saveDto
* @return
*/
BaseResult insertCustomerMessage(CustomerMessageMiniProgramSaveDTO saveDto);
/**
* 获取详情
* @param id
* @return
*/
GenericsResult<CustomerMessageMiniProgramSaveDTO> getCustomerTextDetail(Long id);
}
package com.yaoyaozw.customer.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yaoyaozw.customer.common.BaseResult;
import com.yaoyaozw.customer.common.GenericsResult;
import com.yaoyaozw.customer.components.SnowflakeComponent;
import com.yaoyaozw.customer.components.TokenManager;
import com.yaoyaozw.customer.constants.CustomerCommonConstant;
import com.yaoyaozw.customer.dto.customer.CustomerMessageMiniProgramSaveDTO;
import com.yaoyaozw.customer.entity.CommonReferralBody;
import com.yaoyaozw.customer.entity.CustomerGraphics;
import com.yaoyaozw.customer.entity.ReferralEntity;
import com.yaoyaozw.customer.mapper.CustomerGraphicsMapper;
import com.yaoyaozw.customer.service.CustomerGraphicsMiniProgramService;
import com.yaoyaozw.customer.service.ReferralEntityService;
import com.yaoyaozw.customer.vo.customer.CustomerMessageDetailVO;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
public class CustomerGraphicsMiniProgramServiceImpl extends ServiceImpl<CustomerGraphicsMapper, CustomerGraphics> implements CustomerGraphicsMiniProgramService {
private final static Logger LOCAL_LOG = LoggerFactory.getLogger(CustomerGraphicsMiniProgramServiceImpl.class);
@Autowired
private TokenManager tokenManager;
@Autowired
private SnowflakeComponent snowflakeComponent;
@Autowired
private ReferralEntityService referralEntityService;
@Override
@Transactional(rollbackFor = Exception.class)
public BaseResult insertCustomerMessage(CustomerMessageMiniProgramSaveDTO saveDto) {
// 主体数据
LOCAL_LOG.info("处理主体数据");
CustomerGraphics customerGraphics = new CustomerGraphics();
BeanUtil.copyProperties(saveDto, customerGraphics);
customerGraphics.initOperateInfo(tokenManager.getUserIdFromToken(), ObjectUtil.isNull(saveDto.getId()));
if (ObjectUtil.isNull(customerGraphics.getId())) {
long id = snowflakeComponent.snowflakeId();
customerGraphics.setId(id);
}
// // 设置链接数
// if (CustomerCommonConstant.REMOTE_LINK_NEWS_TYPE_LIST.contains(saveDto.getCustomerReferralDto().getNewsType())) {
// customerGraphics.setReferralSize(1);
// }
super.saveOrUpdate(customerGraphics);
// 处理活动数据
ReferralEntity referralEntity = new ReferralEntity();
BeanUtil.copyProperties(saveDto, referralEntity);
referralEntity.setMaterialGraphicsId(customerGraphics.getId());
// 获取name模板
String nameModel = CustomerCommonConstant.getLinkNameModel(referralEntity.getNewsType());
LOCAL_LOG.info("获取name模板: {}", nameModel);
if (StringUtils.isNotBlank(nameModel)) {
referralEntity.setName(nameModel);
}
// 保存链接数据
referralEntityService.saveOrUpdate(referralEntity);
return new BaseResult().success();
}
@Override
public GenericsResult<CustomerMessageMiniProgramSaveDTO> getCustomerTextDetail(Long id) {
// 获取主体数据
CustomerGraphics customerGraphics = super.getById(id);
if (ObjectUtil.isNull(customerGraphics)) {
return new GenericsResult<>(false, "找不到主体数据");
}
CustomerMessageMiniProgramSaveDTO miniProgramDTO = new CustomerMessageMiniProgramSaveDTO();
BeanUtil.copyProperties(customerGraphics, miniProgramDTO);
miniProgramDTO.setPostTime(customerGraphics.getPostTimeStr());
// 获取链接数据
ReferralEntity referralEntity = referralEntityService.getOne(new QueryWrapper<ReferralEntity>().eq("material_graphics_id", id).isNull("account_id"));
if (ObjectUtil.isNull(referralEntity)) {
return new GenericsResult<>(false, "找不到链接数据");
}
miniProgramDTO.setMpAppId(referralEntity.getMpAppId());
miniProgramDTO.setMpTitle(referralEntity.getMpTitle());
miniProgramDTO.setMpPath(referralEntity.getMpPath());
return new GenericsResult<>(miniProgramDTO);
}
}
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
and dic.level = 3 and dic.level = 3
where cg.is_deleted = 0 where cg.is_deleted = 0
order by cg.gmt_modified DESC
</select> </select>
</mapper> </mapper>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论