提交 ea246c31 作者: 沈振路

关回接口(对接调整)

上级 473af6da
......@@ -73,8 +73,7 @@ public class FollowReplyComponent {
SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd");
String dateStr = format.format(new Date());
AuthorizerInfo authorizerInfo = authorizerInfoService.getById(referralBody.getInfoId());
handleReferralName(dateStr, authorizerInfo.getNickName(), referralEntity);
handleReferralName(dateStr, referralBody.getAccountName(), referralEntity);
}
// 获取链接
......@@ -264,7 +263,7 @@ public class FollowReplyComponent {
private void handleReferralName(String dateStr, String accountName, ReferralEntity referral) {
Integer newsType = referral.getNewsType();
// 书籍、活动 类型, 重新构造name
String name = CustomerCommonConstant.getLinkNameModel(newsType);
String name = CustomerCommonConstant.getLinkNameModel(newsType, referral.getConfigName());
String newsTypeName = CustomerCommonConstant.getNewsTypeName(newsType);
name = name.replace("{newsType}", newsTypeName).replace("{accountNickName}", accountName)
.replace("{storeType}", referral.getStoreTypeName()).replace("{currentDate}", dateStr);
......@@ -274,8 +273,11 @@ public class FollowReplyComponent {
} else if (newsType.equals(CustomerCommonConstant.ACTIVITY_NEWS_TYPE)) {
// 系统-客服-{newsType}-{accountNickName}-{storeType}-{currentDate}-充{recharge}送{gift}
name = name.replace("{recharge}", referral.getRechargeAmount().stripTrailingZeros().toPlainString()).replace("{gift}", referral.getGiftAmount().toString());
if (StringUtils.isNotEmpty(referral.getConfigName())) {
name = name.replace("{configName}", referral.getConfigName());
}
}
name = name.replace("客服", "关回");
referral.setName(name + "-" +System.currentTimeMillis() % 100000);
}
......
package com.yaoyaozw.customer.constants;
import cn.hutool.core.util.ObjectUtil;
import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal;
import java.util.Arrays;
......@@ -43,6 +44,7 @@ public class CustomerCommonConstant {
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 String ACTIVITY_NEWS_TYPE_NAME_CONFIG_NAME_MODEL = "系统-客服-{newsType}-{accountNickName}-{storeType}-{currentDate}-{configName}";
public final static String CUSTOMER_TEXT_LINK_TEMPLATE = "<a href=\"{url}-\" style='color: blue'>{content}</a>";
......@@ -117,4 +119,22 @@ public class CustomerCommonConstant {
return "";
}
public static String getLinkNameModel(Integer code, String configName) {
if (ObjectUtil.isNull(code)) {
return "";
}
if (code.equals(BOOK_NEWS_TYPE)) {
return BOOK_NEWS_TYPE_NAME_MODEL;
}
if (code.equals(ACTIVITY_NEWS_TYPE)) {
if (StringUtils.isEmpty(configName)) {
return ACTIVITY_NEWS_TYPE_NAME_MODEL;
} else {
return ACTIVITY_NEWS_TYPE_NAME_CONFIG_NAME_MODEL;
}
}
return "";
}
}
package com.yaoyaozw.customer.constants;
import org.apache.commons.lang3.StringUtils;
import java.util.Arrays;
import java.util.List;
......@@ -23,5 +25,20 @@ public class FollowReplyCommonConstant {
return TENCENT_MEDIA_TYPE_NEWS.equals(type) || TENCENT_MEDIA_TYPE_TEXT.equals(type);
}
public static String getTypeDesc(String type) {
if (TENCENT_MEDIA_TYPE_PIC.equals(type)) {
return "图片";
} else if (TENCENT_MEDIA_TYPE_VOICE.equals(type)) {
return "语音";
} else if (TENCENT_MEDIA_TYPE_NEWS.equals(type)) {
return "图文";
} else if (TENCENT_MEDIA_TYPE_TEXT.equals(type)) {
return "文本";
}
return "";
}
}
......@@ -10,6 +10,7 @@ import com.yaoyaozw.customer.service.CustomerFollowReplyService;
import com.yaoyaozw.customer.vo.follow.FollowReplyInfoVO;
import com.yaoyaozw.customer.vo.follow.FollowReplyListVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
......@@ -32,7 +33,7 @@ public class FollowReplyController {
}
@PostMapping("/create")
public GenericsResult<String> create(@RequestBody FollowReplySaveDTO saveDto) {
public GenericsResult<String> create(@RequestBody @Validated FollowReplySaveDTO saveDto) {
return followReplyService.create(saveDto);
}
......
......@@ -5,6 +5,8 @@ import com.yaoyaozw.customer.entity.CommonReferralBody;
import com.yaoyaozw.customer.vo.AuthInfoVO;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
......@@ -16,11 +18,13 @@ public class FollowReplySaveDTO implements Serializable {
private Long id;
@NotEmpty(message = "appid不能为空")
private String appid;
@NotEmpty(message = "素材名称不能为空")
private String name;
@NotEmpty(message = "素材类型不能为空")
private String type;
private String originMediaUrl;
......@@ -29,6 +33,7 @@ public class FollowReplySaveDTO implements Serializable {
private String extendDesc;
@NotNull(message = "素材排序不能为空")
private Integer sort;
private CommonReferralBody referralBody;
......
......@@ -47,6 +47,11 @@ public class CommonReferralBody implements Serializable {
@ApiModelProperty(value="序号")
private Integer sort;
private String accountName;
@ApiModelProperty(value = "渠道号")
private String accountId;
@ApiModelProperty("书城")
private String storeType;
......@@ -89,6 +94,9 @@ public class CommonReferralBody implements Serializable {
@ApiModelProperty(value = "赠送数量")
private Integer giftAmount;
@ApiModelProperty(value = "模板Id")
private String templateId;
public Date getStartTime() {
if (ObjectUtil.isNull(this.startTime) && CollectionUtil.isNotEmpty(this.dateList)) {
return dateList.get(0);
......
......@@ -106,7 +106,7 @@ public class CustomerFollowReply implements Serializable {
/**
* 创建人
*/
@TableField(value = "gmt_create", fill = FieldFill.INSERT)
@TableField(value = "create_user", fill = FieldFill.INSERT)
private Long createUser;
/**
......@@ -118,7 +118,7 @@ public class CustomerFollowReply implements Serializable {
/**
* 更新人
*/
@TableField(value = "gmt_modified", fill = FieldFill.INSERT_UPDATE)
@TableField(value = "modified_user", fill = FieldFill.INSERT_UPDATE)
private Long modifiedUser;
/**
......
......@@ -208,6 +208,9 @@ public class ReferralEntity implements Serializable {
@ApiModelProperty(value = "infoId")
private Long infoId;
@TableField(exist = false)
private String accountName;
public static final String COL_ID = "id";
public static final String COL_ACCOUNT_ID = "account_id";
......
package com.yaoyaozw.customer.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yaoyaozw.customer.dto.follow.FollowReplyQueryDTO;
import com.yaoyaozw.customer.entity.CustomerFollowReply;
import com.yaoyaozw.customer.vo.follow.FollowReplyListVO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @author darker
* @date 2023/3/14 11:14
*/
@Repository
public interface CustomerFollowReplyMapper extends BaseMapper<CustomerFollowReply> {
/**
* 得到列表
*
* @param queryDto 查询dto
* @return {@link List}<{@link FollowReplyListVO}>
*/
List<FollowReplyListVO> getList(@Param("queryDto") FollowReplyQueryDTO queryDto);
}
......@@ -59,16 +59,28 @@ public class CustomerFollowReplyServiceImpl extends ServiceImpl<CustomerFollowRe
@Override
public GenericsResult<List<FollowReplyListVO>> list(FollowReplyQueryDTO queryDto) {
return null;
List<FollowReplyListVO> list = this.baseMapper.getList(queryDto);
return new GenericsResult<>(list);
}
@Override
public GenericsResult<String> create(FollowReplySaveDTO saveDto) {
String result = checkNecessary(saveDto);
if (StringUtils.isNotEmpty(result)) {
return new GenericsResult<>(false, result);
}
CustomerFollowReply entity = new CustomerFollowReply();
BeanUtil.copyProperties(saveDto, entity);
CustomerFollowReply sourceEntity = this.getById(entity.getId());
CustomerFollowReply sourceEntity = null;
boolean isCreate = ObjectUtil.isNull(entity.getId());
if (!isCreate) {
sourceEntity = this.getById(entity.getId());
if (ObjectUtil.isNull(sourceEntity)) {
return new GenericsResult<>(false, "");
}
}
if (isCreate) {
// 新增的id
entity.setId(snowflakeComponent.snowflakeId());
......@@ -77,6 +89,7 @@ public class CustomerFollowReplyServiceImpl extends ServiceImpl<CustomerFollowRe
referralEntityService.remove(new QueryWrapper<ReferralEntity>().eq(ReferralEntity.COL_MATERIAL_GRAPHICS_ID, sourceEntity.getId()));
}
entity.setStatus(1);
// 判断是否需要上传文件(图片、语音)
if (FollowReplyCommonConstant.needUpload(entity.getType())) {
// 编辑的时候,删除原来的media
......@@ -105,6 +118,7 @@ public class CustomerFollowReplyServiceImpl extends ServiceImpl<CustomerFollowRe
throw new RuntimeException("获取链接异常: " + e.getMessage());
}
referralEntity.setMaterialGraphicsId(entity.getId());
entity.setSourceUrl(referralEntity.getReferral());
// 保存链接数据
if (ObjectUtil.isNull(referralEntity.getId())) {
referralEntityService.save(referralEntity);
......@@ -312,4 +326,16 @@ public class CustomerFollowReplyServiceImpl extends ServiceImpl<CustomerFollowRe
}
private String checkNecessary(FollowReplySaveDTO saveDto) {
if (!FollowReplyCommonConstant.TENCENT_MEDIA_TYPE_TEXT.equals(saveDto.getType())) {
// 非文本类型的都需要文件
if (StringUtils.isEmpty(saveDto.getOriginMediaUrl())) {
return "请选择素材文件";
}
}
return null;
}
}
......@@ -35,6 +35,7 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -55,6 +56,8 @@ public class CustomerGraphicsDelayServiceImpl extends ServiceImpl<CustomerGraphi
private final static String EMPTY_STR = " ";
private final static String STORE_NAME_REDIS_KEY = "STORE_NAME_MAP";
@Autowired
private TokenManager tokenManager;
@Autowired
......@@ -69,6 +72,8 @@ public class CustomerGraphicsDelayServiceImpl extends ServiceImpl<CustomerGraphi
private CustomerServiceCommonAsyncComponent commonAsyncComponent;
@Autowired
private MaterialCommonMapper materialCommonMapper;
@Autowired
private RedisTemplate<String, Object> redisTemplate;
@Override
......@@ -310,6 +315,17 @@ public class CustomerGraphicsDelayServiceImpl extends ServiceImpl<CustomerGraphi
}
List<AuthInfoVO> authList = super.baseMapper.getAuthList(keyword, keywordList, storeType, appId);
Map<Object, Object> entries = redisTemplate.opsForHash().entries(STORE_NAME_REDIS_KEY);
if (CollectionUtil.isNotEmpty(entries)) {
Map<String, String> map = new HashMap<>(entries.size());
entries.forEach((key, value) -> {
map.put(key.toString(), value.toString());
});
authList.forEach(item -> item.setStoreTypeName(map.get(item.getStoreType())));
}
return new GenericsResult<>(authList);
}
......
......@@ -2,7 +2,9 @@ package com.yaoyaozw.customer.vo.follow;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.yaoyaozw.customer.constants.FollowReplyCommonConstant;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import java.io.Serializable;
......@@ -16,10 +18,19 @@ public class FollowReplyListVO implements Serializable {
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
private String name;
private String authName;
private String typeDesc;
private String statusDesc;
private String type;
private Integer sort;
public String getTypeDesc() {
return FollowReplyCommonConstant.getTypeDesc(this.type);
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.yaoyaozw.customer.mapper.CustomerFollowReplyMapper">
<select id="getList" resultType="com.yaoyaozw.customer.vo.follow.FollowReplyListVO">
select
rep.id,
rep.name,
rep.type,
rep.sort,
ai.nick_name as authName,
if(rep.status = 1, '正常', '异常') as statusDesc
from customer_follow_reply rep
left join authorizer_info ai
on rep.appid = ai.appid
where rep.is_deleted = 0
and rep.appid = #{queryDto.appId}
</select>
</mapper>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论