提交 9672b5fe 作者: 沈振路

Merge branch 'customer_service_SZlu'

# Conflicts:
#	src/main/java/com/yaoyaozw/customer/components/CustomerServiceCommonAsyncComponent.java
#	src/main/java/com/yaoyaozw/customer/entity/CustomerGraphicsDelay.java
#	src/main/resources/mapper/KanbanCommonMapper.xml
......@@ -3,6 +3,7 @@ package com.yaoyaozw.customer.common;
import cn.hutool.core.util.ObjectUtil;
import com.yaoyaozw.customer.constants.ApiResultConstant;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
/**
* @author darker
......@@ -37,6 +38,14 @@ public class BaseResult {
}
return this;
}
public BaseResult success(String message) {
this.success = Boolean.TRUE;
this.code = ApiResultConstant.SUCCESS_CODE;
if (ObjectUtil.isNull(this.message)) {
this.message = StringUtils.isBlank(message) ? ApiResultConstant.SUCCESS_MSG : message;
}
return this;
}
/**
* 错误
......
......@@ -11,10 +11,7 @@ import com.alibaba.fastjson.TypeReference;
import com.yaoyaozw.customer.common.R;
import com.yaoyaozw.customer.constants.ApiResultConstant;
import com.yaoyaozw.customer.constants.CustomerCommonConstant;
import com.yaoyaozw.customer.entity.CustomerGraphics;
import com.yaoyaozw.customer.entity.CustomerGraphicsDelay;
import com.yaoyaozw.customer.entity.ReferralEntity;
import com.yaoyaozw.customer.entity.RegisterUserEntity;
import com.yaoyaozw.customer.entity.*;
import com.yaoyaozw.customer.enums.CustomerStoreTemplateEnum;
import com.yaoyaozw.customer.feigns.ReferralFeignClient;
import com.yaoyaozw.customer.mapper.CustomerGraphicsDelayMapper;
......@@ -148,7 +145,7 @@ public class CustomerServiceCommonAsyncComponent {
for (ReferralEntity referralEntity : referralEntityList) {
// 获取链接
if (CustomerCommonConstant.REPLACE_LINK_NEWS_TYPE_LIST.contains(referralEntity.getNewsType())) {
if (CustomerCommonConstant.REMOTE_LINK_NEWS_TYPE_LIST.contains(referralEntity.getNewsType())) {
LOCAL_LOG.info("异步获取图文客服链接");
getMessageAuthListLink(storeGroupMap, customerGraphics, referralEntity);
} else {
......@@ -156,25 +153,28 @@ public class CustomerServiceCommonAsyncComponent {
}
}
// 处理完之后将状态改为待发送
customerGraphics.setSendStatus(CustomerCommonConstant.SEND_STATUS_LINK_FINISH);
customerGraphics.setSendStatus(CustomerCommonConstant.SEND_STATUS_ACTIVE);
customerGraphicsMapper.updateById(customerGraphics);
}
@Async("myExecutor")
public void obtainDelayLink(Long materialId, CustomerGraphicsDelay customerGraphicsDelay, List<ReferralEntity> referralEntityList) {
public void obtainDelayGraphicsLink(List<CustomerGraphicsDelay> sourceCustomerList, AuthorizerInfo targetAuthInfo) {
String accountName = targetAuthInfo.getNickName();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
String dateStr = dateFormat.format(new Date());
LOCAL_LOG.info("延时客服复用--公众号【{}】, 要复制客服数量: {} 条", accountName, sourceCustomerList.size());
// 遍历客服素材进行处理
for (CustomerGraphicsDelay sourceGraphics : sourceCustomerList) {
dispatchCustomerDelayLink(dateStr, sourceGraphics, targetAuthInfo);
}
}
/**
* 以下是客服消息模块的私有方法
*/
private void getMessageAuthListLink(Map<String, List<CrowdPackageUserVO>> storeGroupMap, CustomerGraphics customerMain, ReferralEntity customerReferral) {
Long packId = customerMain.getPackId();
LOCAL_LOG.info("开始异步处理客服链接, 客服标题: {}, 人群包主键: {}", customerMain.getName(), packId);
......@@ -184,18 +184,18 @@ public class CustomerServiceCommonAsyncComponent {
// 一个书城一个书城地处理
if (newsType.equals(CustomerCommonConstant.BOOK_NEWS_TYPE)) {
// 是推广链接
generateExtendLink(storeGroupMap, customerReferral);
generateMessageExtendLink(storeGroupMap, customerReferral);
} else if (CustomerCommonConstant.ACTIVITY_NEWS_TYPE.equals(newsType)) {
// 是活动链接
generateActivityLink(storeGroupMap, customerReferral);
generateMessageActivityLink(storeGroupMap, customerReferral);
} else if (CustomerCommonConstant.USUAL_LINK_NEWS_TYPE.equals(newsType)) {
// 常用链接
generateUsualLink(storeGroupMap, customerReferral);
generateMessageUsualLink(storeGroupMap, customerReferral);
}
}
private void generateExtendLink(Map<String, List<CrowdPackageUserVO>> storeGroupMap, ReferralEntity customerReferral) {
private void generateMessageExtendLink(Map<String, List<CrowdPackageUserVO>> storeGroupMap, ReferralEntity customerReferral) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
String dateStr = dateFormat.format(new Date());
......@@ -230,7 +230,7 @@ public class CustomerServiceCommonAsyncComponent {
});
}
private void generateActivityLink(Map<String, List<CrowdPackageUserVO>> storeGroupMap, ReferralEntity customerReferral) {
private void generateMessageActivityLink(Map<String, List<CrowdPackageUserVO>> storeGroupMap, ReferralEntity customerReferral) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
String dateStr = dateFormat.format(new Date());
......@@ -301,7 +301,7 @@ public class CustomerServiceCommonAsyncComponent {
});
}
private void generateUsualLink(Map<String, List<CrowdPackageUserVO>> storeGroupMap, ReferralEntity customerReferral) {
private void generateMessageUsualLink(Map<String, List<CrowdPackageUserVO>> storeGroupMap, ReferralEntity customerReferral) {
Map<String, String> storeEntityMap = getStoreEntityMap(storeGroupMap.keySet());
storeGroupMap.forEach((storeType, userVoList) -> {
......@@ -331,7 +331,173 @@ public class CustomerServiceCommonAsyncComponent {
});
}
private void getCopyReferral(String dateStr, AuthInfoVO authInfoVo, ReferralEntity referralEntity) {
/**
* 以下是延时客服 的方法
*/
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();
String type = sourceGraphics.getType();
// 构造h5
StringBuilder h5Context = new StringBuilder();
// 遍历处理客服链接
int idx = 1;
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());
String name = CustomerCommonConstant.getLinkNameModel(targetReferralEntity.getNewsType());
if (StringUtils.isNotBlank(name) && !CustomerCommonConstant.USUAL_LINK_NEWS_TYPE.equals(targetReferralEntity.getNewsType())) {
name = name + "-" +System.currentTimeMillis() % 100000;
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)) {
// 常用链接
generateDelayUsualLink(dateStr, targetReferralEntity, targetAuthInfo);
} else {
LOCAL_LOG.info("newsType: {}, 不需要获取链接", newsType);
}
targetReferralEntityList.add(targetReferralEntity);
// 图文主表只有一个素材链接,文本主表不需要存素材链接
String referral = targetReferralEntity.getReferral();
targetCustomerGraphics.setSourceUrl(referral);
if (type.equals(CustomerCommonConstant.CUSTOMER_TYPE_VALUE_TEXT)) {
// 文本类型替换h5链接
String context = null;
if (CustomerCommonConstant.REPLACE_LINK_NEWS_TYPE_LIST.contains(newsType)) {
context = CustomerCommonConstant.CUSTOMER_TEXT_LINK_TEMPLATE.replace(CustomerCommonConstant.CUSTOMER_TEXT_CONTENT_PLACEHOLDER, targetReferralEntity.getTextContent());
} else if (CustomerCommonConstant.COMMON_NEWS_TYPE_LIST.contains(newsType)){
context = targetReferralEntity.getTextContent();
}
if (ObjectUtil.isNotNull(context)) {
// 拼接的要替换链接
h5Context.append(context.replace(CustomerCommonConstant.CUSTOMER_TEXT_URL_PLACEHOLDER, referral));
if (idx != sourceReferralList.size()) {
h5Context.append("\n").append("\n");
}
}
idx += 1;
}
}
targetCustomerGraphics.setSendStatus(CustomerCommonConstant.SEND_STATUS_ACTIVE);
if (StringUtils.isNotBlank(h5Context)) {
targetCustomerGraphics.setContent(h5Context.toString().replace(CustomerCommonConstant.H5_STYLE_CODE, ""));
}
LOCAL_LOG.info("保存主体数据, 主体id: {}", mainId);
customerGraphicsDelayMapper.insert(targetCustomerGraphics);
LOCAL_LOG.info("准备保存, 共生成链接数据 : {} 条", targetReferralEntityList.size());
referralEntityService.saveBatch(targetReferralEntityList);
}
private void generateDelayExtendLink(String dateStr, ReferralEntity targetReferralEntity, AuthorizerInfo targetAuthInfo) {
// 遍历链接数据进行处理
try {
// 获取链接
AuthInfoVO authInfoVo = new AuthInfoVO();
authInfoVo.putPropertyValue(targetAuthInfo);
getCopyReferral(dateStr, authInfoVo, targetReferralEntity);
} catch (Exception e) {
LOCAL_LOG.warn("公众号: {} 获取链接异常: {}", targetAuthInfo.getNickName(), e.getMessage());
}
}
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.setAccountId(targetAuthInfo.getAccountId());
try {
// 获取链接
AuthInfoVO authInfoVo = new AuthInfoVO();
authInfoVo.putPropertyValue(targetAuthInfo);
getCopyReferral(dateStr, authInfoVo, targetReferralEntity);
} catch (Exception e) {
LOCAL_LOG.warn("公众号: {} 获取链接异常: {}", targetAuthInfo.getNickName(), e.getMessage());
targetReferralEntity.setReferral("error");
}
}
}
private void generateDelayUsualLink(String dateStr, ReferralEntity targetReferralEntity, AuthorizerInfo targetAuthInfo) {
try {
// 获取链接
AuthInfoVO authInfoVo = new AuthInfoVO();
authInfoVo.putPropertyValue(targetAuthInfo);
getCopyReferral(dateStr, authInfoVo, targetReferralEntity);
} catch (Exception e) {
LOCAL_LOG.warn("公众号: {} 获取链接异常: {}", targetAuthInfo.getNickName(), e.getMessage());
}
}
/**
* 以下是公有方法
*/
public void getCopyReferral(String dateStr, AuthInfoVO authInfoVo, ReferralEntity referralEntity) {
referralEntity.setStoreType(authInfoVo.getStoreType());
// 非常用链接类型的name需要处理
String name = referralEntity.getName();
......@@ -350,10 +516,13 @@ public class CustomerServiceCommonAsyncComponent {
} else if (newsType.equals(CustomerCommonConstant.ACTIVITY_NEWS_TYPE)) {
// 系统-客服-{newsType}-{accountNickName}-{storeType}-{currentDate}-充{recharge}送{gift}
name = name.replace("{recharge}", referralEntity.getRechargeAmount().stripTrailingZeros().toPlainString()).replace("{gift}", referralEntity.getGiftAmount().toString());
String tempId = CustomerStoreTemplateEnum.getTempId(referralEntity.getStoreType());
referralEntity.setTemplateId(tempId);
}
referralEntity.setName(name);
}
referralEntity.setInfoId(authInfoVo.getId());
LOCAL_LOG.info("获取链接, 参数: {}", referralEntity);
R r = referralFeignClient.productReferral(referralEntity);
if (!r.getCode().equals(ApiResultConstant.SUCCESS_CODE)) {
throw new RuntimeException(r.getMessage());
......
......@@ -20,12 +20,15 @@ public class CustomerCommonConstant {
public final static String ERROR_LABEL = "error";
public final static List<Integer> LINK_NEWS_TYPE_LIST = Arrays.asList(1, 2, 3, -1);
public final static List<Integer> REPLACE_LINK_NEWS_TYPE_LIST = Arrays.asList(1, 2, 3, -1);
public final static List<Integer> REPLACE_LINK_NEWS_TYPE_LIST = Arrays.asList(1, 2, 3);
public final static List<Integer> REMOTE_LINK_NEWS_TYPE_LIST = Arrays.asList(1, 2, 3);
public final static List<Integer> COMMON_NEWS_TYPE_LIST = Collections.singletonList(4);
public final static String YW_LINK_LIMIT_REDIS_KEY = "YW_REFERRAL";
public final static String YANG_GUANG_ACCESS_LIMIT_REDIS_KEY = "YG_ACCESS_LIMIT_NUM";
public final static Integer BOOK_NEWS_TYPE = 1;
public final static String BOOK_NEWS_TYPE_NAME = "推广";
......@@ -58,6 +61,8 @@ public class CustomerCommonConstant {
public final static Integer SEND_STATUS_LINK_FINISH = 2;
public final static Integer SEND_STATUS_ACTIVE = 9;
public final static Integer SEND_STATUS_SENT_SUCCESS = 3;
public final static Integer SEND_STATUS_SENT_FAIL = 4;
......
......@@ -30,4 +30,10 @@ public class CustomerCommonController {
return commonService.getStoreList();
}
@GetMapping("/getCoverPicList")
@ApiOperation("获取书城列表")
public GenericsResult<List<CommonOptionResponseVO>> getCoverPicList() {
return commonService.getCoverPicList();
}
}
......@@ -74,8 +74,8 @@ public class CustomerDelayGraphicsController {
@ApiOperation("所有公众号")
@GetMapping("/getAuthList")
public GenericsResult<List<AuthInfoVO>> getAuthList(@RequestParam(required = false) String keyword) {
return customerGraphicsDelayService.getAuthList(keyword);
public GenericsResult<List<AuthInfoVO>> getAuthList(@RequestParam(required = false) String keyword, @RequestParam(required = false) String appId) {
return customerGraphicsDelayService.getAuthList(keyword, appId);
}
@ApiOperation("时间间隔")
......
package com.yaoyaozw.customer.controller;
import com.yaoyaozw.customer.common.GenericsResult;
import com.yaoyaozw.customer.dto.customer.CustomerDelayTextSaveDTO;
import com.yaoyaozw.customer.dto.customer.CustomerReferralDTO;
import com.yaoyaozw.customer.service.CustomerDelayTextService;
import com.yaoyaozw.customer.vo.customer.CustomerDelayTextDetailVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* @author darker
* @date 2022/9/15 11:13
*/
@Api(tags = "延时客服接口-文本")
@RestController
@RequestMapping("/customer-service/delay/text")
public class CustomerDelayTextController {
@Autowired
private CustomerDelayTextService textService;
@ApiOperation("新增客服主体")
@PostMapping("/insertCustomerDelay")
public GenericsResult<String> insertCustomerDelay(@RequestBody CustomerDelayTextSaveDTO saveDto) {
return textService.insertCustomerDelay(saveDto);
}
@ApiOperation("新增客服内容")
@PostMapping("/insertCustomerContent")
public GenericsResult<CustomerDelayTextDetailVO> insertCustomerContent(@RequestBody CustomerReferralDTO referralDto) {
return textService.insertCustomerContent(referralDto);
}
@ApiOperation("获取文本客服详情")
@GetMapping("/detail/{id}")
public GenericsResult<CustomerDelayTextDetailVO> getCustomerTextDetail(@PathVariable("id") Long id) {
return textService.getCustomerTextDetail(id);
}
@ApiOperation("删除单条文本内容")
@GetMapping("/removeCustomerContent/{contentId}")
public GenericsResult<CustomerDelayTextDetailVO> removeCustomerContent(@PathVariable("contentId") Long contentId) {
return textService.removeCustomerContent(contentId);
}
}
......@@ -41,6 +41,9 @@ public class CustomerDelaySaveDTO implements Serializable {
@ApiModelProperty("发文间隔时间")
private Long timeInterval;
@ApiModelProperty("已支付、未支付")
private Integer isPay;
@ApiModelProperty("消息内容实体")
private CustomerReferralDTO customerReferralDto;
......
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 CustomerDelayTextSaveDTO implements Serializable {
@ApiModelProperty("客服消息id")
private Long id;
@ApiModelProperty("公众号AppId")
private String appId;
@ApiModelProperty("标题")
private String name;
@ApiModelProperty("发文序号")
private Integer postSort;
@ApiModelProperty("发文间隔时间")
private Long timeInterval;
@ApiModelProperty("已支付、未支付")
private Integer isPay;
@ApiModelProperty("客服消息类型(图文、文本)")
private String type;
}
......@@ -33,9 +33,15 @@ public class CustomerReferralDTO implements Serializable {
@ApiModelProperty("文本类型文本内容")
private String textContent;
@ApiModelProperty("appId")
private String appId;
@ApiModelProperty("链接类型")
private Integer newsType;
@ApiModelProperty("链接名")
private String name;
@ApiModelProperty(value="序号")
private Integer sort;
......
package com.yaoyaozw.customer.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.*;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
......@@ -65,10 +63,16 @@ public class CustomerGraphicsDelay implements Serializable {
private Integer sendStatus;
/**
* 是否是历史遗留
* 原文链接
*/
@TableField(value = "source_url")
private String sourceUrl;
/**
* 是否支付
*/
@TableField(value = "is_history")
private Integer isHistory;
@TableField(value = "is_pay")
private Integer isPay;
/**
* 发送序列
......@@ -110,6 +114,7 @@ public class CustomerGraphicsDelay implements Serializable {
* 逻辑删除
*/
@TableField(value = "is_deleted")
@TableLogic
private Integer isDeleted;
@TableField(exist = false)
......
......@@ -35,7 +35,7 @@ public interface CustomerGraphicsDelayMapper extends BaseMapper<CustomerGraphics
* @param queryDto 查询dto
* @return {@link List}<{@link CustomerDelayListVO}>
*/
List<CustomerDelayListVO> pageList(CustomerDelayQueryDTO queryDto);
List<CustomerDelayListVO> pageList(@Param("queryDto") CustomerDelayQueryDTO queryDto);
/**
* 得到客户账户存在
......@@ -48,10 +48,13 @@ public interface CustomerGraphicsDelayMapper extends BaseMapper<CustomerGraphics
/**
* 让时间间隔列表
*
* @param keyword 关键词
* @param keyword 关键词
* @param keywordList 关键词拆分
* @param storeType 书城
* @param appId 需要排除的公众号appId
* @return {@link List}<{@link AuthInfoVO}>
*/
List<AuthInfoVO> getAuthList(@Param("keyword") String keyword);
List<AuthInfoVO> getAuthList(@Param("keyword") String keyword, @Param("keywordList") List<String> keywordList, @Param("storeType") String storeType, @Param("appId") String appId);
/**
* 让时间间隔列表
......@@ -60,4 +63,11 @@ public interface CustomerGraphicsDelayMapper extends BaseMapper<CustomerGraphics
*/
List<CommonOptionResponseVO> getTimeIntervalList();
/**
* 获取延时客服主体的公众号
* @param customerId 延时客服主键
* @return 公众号
*/
AuthInfoVO getCustomerDelayAuthInfo(@Param("customerId") Long customerId);
}
\ No newline at end of file
......@@ -51,6 +51,12 @@ public interface KanbanCommonMapper {
*/
List<CommonOptionResponseVO> getStoreTypeEntity(@Param("storeKeySet") Set<String> storeKeySet);
/**
* @param appId 应用程序id
* @return {@link String}
*/
String getStoreTypeNameByAppId(@Param("appId") String appId);
List<CommonCostSetupVo> getWechatCostSetup(@Param("appid")String appid);
......
......@@ -33,4 +33,11 @@ public interface MaterialCommonMapper {
*/
List<AuthInfoVO> getAuthInfoList(@Param("accountSet") Set<String> accountSet);
/**
* 把封面图片列表
*
* @return {@link GenericsResult}<{@link List}<{@link CommonOptionResponseVO}>>
*/
List<CommonOptionResponseVO> getCoverPicList();
}
......@@ -21,11 +21,19 @@ public interface ReferralEntityMapper extends BaseMapper<ReferralEntity> {
/**
* 物理删除素材元素
*
* @param sourceId 素材主体ID
* @param sourceId 素材主体ID
* @param extraCondition 特殊条件表达式
*/
void ultimateDeleteReferrals(@Param("sourceId") Long sourceId, @Param("extraCondition") String extraCondition);
List<ReferralEntityVo> findByMaterialGraphicsId(@Param("graphicsId")Long graphicsId);
List<ReferralEntityVo> findByMaterialGraphicsId(@Param("graphicsId") Long graphicsId);
/**
* 物理删除素材元素
*
* @param sourceIdList 素材主体ID
* @param extraCondition 特殊条件表达式
*/
void ultimateDeleteReferralsBatch(@Param("sourceIdList") List<Long> sourceIdList, @Param("extraCondition") String extraCondition);
}
\ No newline at end of file
package com.yaoyaozw.customer.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yaoyaozw.customer.common.GenericsResult;
import com.yaoyaozw.customer.dto.customer.CustomerDelayTextSaveDTO;
import com.yaoyaozw.customer.dto.customer.CustomerReferralDTO;
import com.yaoyaozw.customer.entity.CustomerGraphicsDelay;
import com.yaoyaozw.customer.vo.customer.CustomerDelayTextDetailVO;
/**
* @author darker
* @date 2022/10/17 16:38
*/
public interface CustomerDelayTextService extends IService<CustomerGraphicsDelay> {
/**
* 插入客户延迟
*
* @param saveDto 保存dto
* @return {@link GenericsResult}<{@link String}>
*/
GenericsResult<String> insertCustomerDelay(CustomerDelayTextSaveDTO saveDto);
/**
* 插入客户内容
*
* @param referralDto 推荐dto
* @return {@link GenericsResult}<{@link CustomerDelayTextDetailVO}>
*/
GenericsResult<CustomerDelayTextDetailVO> insertCustomerContent(CustomerReferralDTO referralDto);
/**
* 得到客户文本细节
*
* @param id id
* @return {@link GenericsResult}<{@link CustomerDelayTextDetailVO}>
*/
GenericsResult<CustomerDelayTextDetailVO> getCustomerTextDetail(Long id);
/**
* 删除客户内容
*
* @param contentId 内容识别
* @return {@link GenericsResult}<{@link CustomerDelayTextDetailVO}>
*/
GenericsResult<CustomerDelayTextDetailVO> removeCustomerContent(Long contentId);
}
......@@ -97,9 +97,10 @@ public interface CustomerGraphicsDelayService extends IService<CustomerGraphicsD
* 获得认证列表
*
* @param keyword 关键字
* @param appId 公众号id
* @return {@link GenericsResult}<{@link List}<{@link AuthInfoVO}>>
*/
GenericsResult<List<AuthInfoVO>> getAuthList(String keyword);
GenericsResult<List<AuthInfoVO>> getAuthList(String keyword, String appId);
/**
* 让时间间隔列表
......@@ -107,5 +108,12 @@ public interface CustomerGraphicsDelayService extends IService<CustomerGraphicsD
* @return {@link GenericsResult}<{@link List}<{@link CommonOptionResponseVO}>>
*/
GenericsResult<List<CommonOptionResponseVO>> getTimeIntervalList();
/**
* 客户重新排序
*
* @param appId 应用程序id
*/
void reSortCustomer(String appId);
}
......@@ -25,4 +25,11 @@ public interface CustomerServiceCommonService {
* @return {@link GenericsResult}<{@link CommonOptionResponseVO}>
*/
GenericsResult<List<CommonOptionResponseVO>> getStoreList();
/**
* 把封面图片列表
*
* @return {@link GenericsResult}<{@link List}<{@link CommonOptionResponseVO}>>
*/
GenericsResult<List<CommonOptionResponseVO>> getCoverPicList();
}
......@@ -22,6 +22,14 @@ public interface ReferralEntityService extends IService<ReferralEntity> {
void ultimateDeleteReferrals(Long sourceId, String extraCondition);
/**
* 物理删除素材元素
*
* @param sourceIdList 素材主体ID
* @param extraCondition 特殊条件表达式
*/
void ultimateDeleteReferralsBatch(List<Long> sourceIdList, String extraCondition);
/**
* 根据客服id找链接
* @param graphicsId 客服主体id
* @return
......
package com.yaoyaozw.customer.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
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.GenericsResult;
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.dto.customer.CustomerDelayTextSaveDTO;
import com.yaoyaozw.customer.dto.customer.CustomerReferralDTO;
import com.yaoyaozw.customer.entity.AuthorizerInfo;
import com.yaoyaozw.customer.entity.CustomerGraphicsDelay;
import com.yaoyaozw.customer.entity.ReferralEntity;
import com.yaoyaozw.customer.mapper.CustomerGraphicsDelayMapper;
import com.yaoyaozw.customer.mapper.KanbanCommonMapper;
import com.yaoyaozw.customer.service.AuthorizerInfoService;
import com.yaoyaozw.customer.service.CustomerDelayTextService;
import com.yaoyaozw.customer.service.CustomerGraphicsDelayService;
import com.yaoyaozw.customer.service.ReferralEntityService;
import com.yaoyaozw.customer.vo.AuthInfoVO;
import com.yaoyaozw.customer.vo.customer.CustomerContentVO;
import com.yaoyaozw.customer.vo.customer.CustomerDelayTextDetailVO;
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.interceptor.TransactionAspectSupport;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* @author darker
* @date 2022/10/17 16:39
*/
@Service
public class CustomerDelayTextServiceImpl extends ServiceImpl<CustomerGraphicsDelayMapper, CustomerGraphicsDelay> implements CustomerDelayTextService {
private final static Logger localLog = LoggerFactory.getLogger(CustomerDelayTextServiceImpl.class);
@Autowired
private TokenManager tokenManager;
@Autowired
private SnowflakeComponent snowflakeComponent;
@Autowired
private ReferralEntityService referralEntityService;
@Autowired
private CustomerServiceCommonAsyncComponent commonAsyncComponent;
@Autowired
private KanbanCommonMapper kanbanCommonMapper;
@Autowired
private CustomerGraphicsDelayService graphicsDelayService;
@Override
public GenericsResult<String> insertCustomerDelay(CustomerDelayTextSaveDTO saveDto) {
// 主体数据
localLog.info("处理主体数据");
CustomerGraphicsDelay customerGraphicsDelay = new CustomerGraphicsDelay();
BeanUtil.copyProperties(saveDto, customerGraphicsDelay);
boolean isCreate = ObjectUtil.isNull(customerGraphicsDelay.getId());
customerGraphicsDelay.initOperateInfo(tokenManager.getUserIdFromToken(), ObjectUtil.isNull(saveDto.getId()));
if (isCreate) {
long id = snowflakeComponent.snowflakeId();
customerGraphicsDelay.setId(id);
}
customerGraphicsDelay.setSendStatus(CustomerCommonConstant.SEND_STATUS_ACTIVE);
super.saveOrUpdate(customerGraphicsDelay);
String appId = saveDto.getAppId();
if (StringUtils.isBlank(appId)) {
// 更新的时候
CustomerGraphicsDelay entity = super.getById(saveDto.getId());
if (ObjectUtil.isNotNull(entity)) {
appId = entity.getAppId();
}
}
if (!StringUtils.isBlank(appId)) {
graphicsDelayService.reSortCustomer(appId);
}
return new GenericsResult<>(customerGraphicsDelay.getId().toString());
}
@Override
public GenericsResult<CustomerDelayTextDetailVO> insertCustomerContent(CustomerReferralDTO referralDto) {
// 处理活动数据
ReferralEntity referralEntity = new ReferralEntity();
BeanUtil.copyProperties(referralDto, referralEntity);
// 获取name模板
String nameModel = CustomerCommonConstant.getLinkNameModel(referralEntity.getNewsType());
localLog.info("获取name模板: {}", nameModel);
if (StringUtils.isNotBlank(nameModel)) {
referralEntity.setName(nameModel);
}
String storeTypeName = kanbanCommonMapper.getStoreTypeNameByAppId(referralDto.getAppId());
referralEntity.setStoreTypeName(storeTypeName);
// 获取链接
// 日期
String format = new SimpleDateFormat("yyyy/MM/dd").format(new Date());
// 公众号
AuthInfoVO authInfoVO = super.baseMapper.getCustomerDelayAuthInfo(referralDto.getMaterialGraphicsId());
if (CustomerCommonConstant.REMOTE_LINK_NEWS_TYPE_LIST.contains(referralEntity.getNewsType())) {
commonAsyncComponent.getCopyReferral(format, authInfoVO, referralEntity);
}
// 保存链接数据
referralEntityService.saveOrUpdate(referralEntity);
return getCustomerTextDetail(referralDto.getMaterialGraphicsId());
}
@Override
public GenericsResult<CustomerDelayTextDetailVO> getCustomerTextDetail(Long id) {
// 查询主体数据
CustomerGraphicsDelay customerGraphicsDelay = super.getById(id);
if (ObjectUtil.isNull(customerGraphicsDelay)) {
return new GenericsResult<>(false, "找不到主体数据");
}
// 赋值主体数据
CustomerDelayTextDetailVO detailVO = new CustomerDelayTextDetailVO();
BeanUtil.copyProperties(customerGraphicsDelay, detailVO);
// 查询所有的链接信息
List<ReferralEntity> referralEntityList = referralEntityService.list(new QueryWrapper<ReferralEntity>().eq("material_graphics_id", id).orderByAsc("gmt_create").orderByAsc("sort"));
List<CustomerContentVO> contentList = new ArrayList<>();
StringBuilder mainH5Content = new StringBuilder();
localLog.info("根据链接重新生成H5");
// 位置计数器
int idx = 1;
for (ReferralEntity item : referralEntityList) {
item.setSort(idx);
CustomerContentVO customerContentVO = new CustomerContentVO();
// 设置主键id和h5代码段
customerContentVO.setId(item.getId());
Integer newsType = item.getNewsType();
// 处理h5文本
String context = null;
if (CustomerCommonConstant.REPLACE_LINK_NEWS_TYPE_LIST.contains(newsType)) {
context = CustomerCommonConstant.CUSTOMER_TEXT_LINK_TEMPLATE.replace(CustomerCommonConstant.CUSTOMER_TEXT_CONTENT_PLACEHOLDER, item.getTextContent());
} else if (CustomerCommonConstant.COMMON_NEWS_TYPE_LIST.contains(newsType)){
context = item.getTextContent();
}
if (ObjectUtil.isNotNull(context)) {
// 拼接的要替换链接
mainH5Content.append(context.replace(CustomerCommonConstant.CUSTOMER_TEXT_URL_PLACEHOLDER, item.getReferral()));
if (idx != referralEntityList.size()) {
mainH5Content.append("\n").append("\n");
}
// 将链接中的占位符换成链接
customerContentVO.setContent(context.replace(CustomerCommonConstant.CUSTOMER_TEXT_URL_PLACEHOLDER + idx, "#"));
}
// 赋值链接信息
CustomerReferralDTO customerReferralDto = new CustomerReferralDTO();
BeanUtil.copyProperties(item, customerReferralDto);
customerContentVO.setCustomerReferralDto(customerReferralDto);
contentList.add(customerContentVO);
idx += 1;
}
customerGraphicsDelay.setContent(mainH5Content.toString().replace(CustomerCommonConstant.H5_STYLE_CODE, ""));
detailVO.setContentList(contentList);
// 公众号
AuthInfoVO authInfoVO = super.baseMapper.getCustomerDelayAuthInfo(id);
detailVO.setAuthInfoVo(authInfoVO);
// 更新连接表
localLog.info("更新连接表");
if (CollectionUtil.isNotEmpty(referralEntityList)) {
referralEntityService.updateBatchById(referralEntityList);
}
// 更新主表
localLog.info("更新主表");
customerGraphicsDelay.initOperateInfo(tokenManager.getUserIdFromToken(), false);
super.updateById(customerGraphicsDelay);
return new GenericsResult<>(detailVO);
}
@Override
public GenericsResult<CustomerDelayTextDetailVO> removeCustomerContent(Long contentId) {
ReferralEntity referralEntity = referralEntityService.getById(contentId);
if (ObjectUtil.isNull(referralEntity)) {
return new GenericsResult<>(false, "找不到主体数据");
}
boolean result = referralEntityService.removeById(contentId);
if (result) {
return getCustomerTextDetail(referralEntity.getMaterialGraphicsId());
}
return new GenericsResult<>(false, "删除失败");
}
}
......@@ -9,6 +9,7 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yaoyaozw.customer.common.BaseResult;
import com.yaoyaozw.customer.common.GenericsResult;
import com.yaoyaozw.customer.components.CustomerServiceCommonAsyncComponent;
import com.yaoyaozw.customer.components.SnowflakeComponent;
import com.yaoyaozw.customer.components.TokenManager;
import com.yaoyaozw.customer.constants.CustomerCommonConstant;
......@@ -21,6 +22,7 @@ import com.yaoyaozw.customer.entity.ReferralEntity;
import com.yaoyaozw.customer.mapper.CustomerGraphicsDelayMapper;
import com.yaoyaozw.customer.mapper.KanbanCommonMapper;
import com.yaoyaozw.customer.service.AuthorizerInfoService;
import com.yaoyaozw.customer.service.CustomerDelayTextService;
import com.yaoyaozw.customer.service.CustomerGraphicsDelayService;
import com.yaoyaozw.customer.service.ReferralEntityService;
import com.yaoyaozw.customer.vo.AuthInfoVO;
......@@ -28,6 +30,7 @@ import com.yaoyaozw.customer.vo.kanban.CommonOptionResponseVO;
import com.yaoyaozw.customer.vo.customer.CustomerDelayGraphicsDetailVO;
import com.yaoyaozw.customer.vo.customer.CustomerDelayItemVO;
import com.yaoyaozw.customer.vo.customer.CustomerDelayListVO;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -35,6 +38,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;
......@@ -48,6 +52,8 @@ public class CustomerGraphicsDelayServiceImpl extends ServiceImpl<CustomerGraphi
private final static Logger localLog = LoggerFactory.getLogger(CustomerGraphicsDelayServiceImpl.class);
private final static String EMPTY_STR = " ";
@Autowired
private TokenManager tokenManager;
@Autowired
......@@ -58,6 +64,8 @@ public class CustomerGraphicsDelayServiceImpl extends ServiceImpl<CustomerGraphi
private AuthorizerInfoService authorizerInfoService;
@Autowired
private KanbanCommonMapper kanbanCommonMapper;
@Autowired
private CustomerServiceCommonAsyncComponent commonAsyncComponent;
@Override
......@@ -77,37 +85,61 @@ public class CustomerGraphicsDelayServiceImpl extends ServiceImpl<CustomerGraphi
@Override
@Transactional(rollbackFor = Exception.class)
public BaseResult insertCustomerDelay(CustomerDelaySaveDTO saveDto) {
boolean isCreate = false;
CustomerGraphicsDelay customerGraphicsDelay = new CustomerGraphicsDelay();
BeanUtil.copyProperties(saveDto, customerGraphicsDelay);
// 初始化操作信息
customerGraphicsDelay.initOperateInfo(tokenManager.getUserIdFromToken(), ObjectUtil.isNull(saveDto.getId()));
if (ObjectUtil.isNull(customerGraphicsDelay.getId())) {
isCreate = true;
long id = snowflakeComponent.snowflakeId();
localLog.info("是新增, 新生成ID: {}", id);
customerGraphicsDelay.setId(id);
}
customerGraphicsDelay.setSendStatus(CustomerCommonConstant.SEND_STATUS_LINK_GETTING);
localLog.info("生成referral数据");
ReferralEntity referralEntity = new ReferralEntity();
BeanUtil.copyProperties(saveDto.getCustomerReferralDto(), referralEntity);
referralEntity.setMaterialGraphicsId(customerGraphicsDelay.getId());
// 非自定义获取链接
if (isCreate && !referralEntity.getNewsType().equals(-1)) {
try {
customerGraphicsDelay.setSendStatus(CustomerCommonConstant.SEND_STATUS_LINK_GETTING);
localLog.info("准备获取链接");
String linkNameModel = CustomerCommonConstant.getLinkNameModel(referralEntity.getNewsType());
if (StringUtils.isNotBlank(linkNameModel)) {
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_ACTIVE);
localLog.info("链接获取完成");
} catch (Exception e) {
localLog.info("获取链接异常");
return new BaseResult().error("获取链接异常" + e.getMessage());
}
}
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 生成链接
reSortCustomer(saveDto.getAppId());
return new BaseResult().success();
}
......@@ -131,6 +163,8 @@ public class CustomerGraphicsDelayServiceImpl extends ServiceImpl<CustomerGraphi
BeanUtil.copyProperties(referralEntity, customerReferralDto);
customerDelayGraphicsDetailVO.setCustomerReferralDto(customerReferralDto);
AuthInfoVO authInfoVO = super.baseMapper.getCustomerDelayAuthInfo(id);
customerDelayGraphicsDetailVO.setAuthInfoVo(authInfoVO);
return new GenericsResult<>(customerDelayGraphicsDetailVO);
}
......@@ -152,12 +186,33 @@ public class CustomerGraphicsDelayServiceImpl extends ServiceImpl<CustomerGraphi
@Override
public BaseResult removeCustomerDelay(Long id) {
return null;
CustomerGraphicsDelay entity = super.getById(id);
boolean result = super.removeById(id);
if (result) {
referralEntityService.ultimateDeleteReferrals(id, null);
localLog.info("处理完成, 正在重新排序");
reSortCustomer(entity.getAppId());
return new BaseResult().success();
}
return new BaseResult().error("弃用失败");
}
@Override
public BaseResult removeBatch(List<Long> idList) {
return null;
List<CustomerGraphicsDelay> list = (List<CustomerGraphicsDelay>) super.listByIds(idList);
boolean result = super.removeByIds(idList);
if (result) {
referralEntityService.ultimateDeleteReferralsBatch(idList, null);
localLog.info("处理完成, 正在重新排序");
Set<String> appIdSet = list.stream().map(CustomerGraphicsDelay::getAppId).collect(Collectors.toSet());
for (String appId : appIdSet) {
reSortCustomer(appId);
}
return new BaseResult().success();
}
return new BaseResult().error("删除失败");
}
@Override
......@@ -175,8 +230,8 @@ public class CustomerGraphicsDelayServiceImpl extends ServiceImpl<CustomerGraphi
// 找到号下面的所有的客服素材
List<CustomerGraphicsDelay> sourceCustomerList = super.list(new QueryWrapper<CustomerGraphicsDelay>().eq("app_id", appId));
List<Long> sourceMainIdList = sourceCustomerList.stream().map(CustomerGraphicsDelay::getId).collect(Collectors.toList());
// 获取原始链接素材
List<ReferralEntity> referralEntityList = referralEntityService.list(new QueryWrapper<ReferralEntity>().in("material_graphics_id", sourceMainIdList));
// 获取原始链接素材 图文只有一条、文本有多条
List<ReferralEntity> referralEntityList = referralEntityService.list(new QueryWrapper<ReferralEntity>().in("material_graphics_id", sourceMainIdList).orderByAsc("gmt_create").orderByAsc("sort"));
Map<Long, List<ReferralEntity>> referralGroupMap = referralEntityList.stream().collect(Collectors.groupingBy(ReferralEntity::getMaterialGraphicsId));
// 遍历处理
......@@ -187,36 +242,40 @@ public class CustomerGraphicsDelayServiceImpl extends ServiceImpl<CustomerGraphi
localLog.info("当前复用书城: {}", storeTypeName);
sourceAuthInfo.setStoreTypeName(storeTypeName);
for (String targetAppId : targetAppList) {
// 遍历要复用的素材
for (CustomerGraphicsDelay item : sourceCustomerList) {
// 设置所属链接
item.setBelongReferralList(referralGroupMap.get(item.getId()));
// 为公众号设置书城名
item.setAuthorizerInfo(sourceAuthInfo);
}
for (String targetAppId : targetAppList) {
// 构造目标公众号的信息
AuthorizerInfo targetAuthInfo = authMap.get(targetAppId);
if (ObjectUtil.isNull(targetAuthInfo)) {
localLog.info("appId: {} 找不到对应公众号", targetAppId);
// 执行下一个公众号
continue;
}
targetAuthInfo.setStoreTypeName(storeTypeName);
// 遍历要复用的素材
for (CustomerGraphicsDelay item : sourceCustomerList) {
// 设置所属链接
item.setBelongReferralList(referralGroupMap.get(item.getId()));
// 为公众号设置书城名
item.setAuthorizerInfo(sourceAuthInfo);
// 执行复用
}
// 异步复用
commonAsyncComponent.obtainDelayGraphicsLink(sourceCustomerList, targetAuthInfo);
}
return null;
return new BaseResult().success("复用进行中, 请等待");
}
@Override
public GenericsResult<List<AuthInfoVO>> getAuthList(String keyword) {
List<AuthInfoVO> authList = super.baseMapper.getAuthList(keyword);
public GenericsResult<List<AuthInfoVO>> getAuthList(String keyword, String appId) {
String storeType = null;
if (ObjectUtil.isNotNull(appId)) {
AuthorizerInfo authInfo = authorizerInfoService.getOne(new QueryWrapper<AuthorizerInfo>().eq("appid", appId));
storeType = authInfo.getStoreType();
}
List<String> keywordList = null;
// 拆分多关键词
if (ObjectUtil.isNotNull(keyword) && keyword.contains(EMPTY_STR)) {
String[] keywordSplit = keyword.split(EMPTY_STR);
keywordList = Arrays.asList(keywordSplit);
keyword = null;
}
List<AuthInfoVO> authList = super.baseMapper.getAuthList(keyword, keywordList, storeType, appId);
return new GenericsResult<>(authList);
}
......@@ -225,5 +284,27 @@ public class CustomerGraphicsDelayServiceImpl extends ServiceImpl<CustomerGraphi
List<CommonOptionResponseVO> timeIntervalList = super.baseMapper.getTimeIntervalList();
return new GenericsResult<>(timeIntervalList);
}
@Override
public void reSortCustomer(String appId) {
List<CustomerGraphicsDelay> list = super.list(new QueryWrapper<CustomerGraphicsDelay>().eq("app_id", appId).orderByAsc("time_interval"));
int idx = 0;
Long previousTime = 0L;
for (CustomerGraphicsDelay item : list) {
boolean equal = previousTime.equals(item.getTimeInterval());
if (!equal) {
idx += 1;
}
item.setPostSort(idx);
previousTime = item.getTimeInterval();
}
if (CollectionUtil.isNotEmpty(list)) {
super.updateBatchById(list);
}
}
}
......@@ -93,7 +93,7 @@ public class CustomerGraphicsServiceImpl extends ServiceImpl<CustomerGraphicsMap
customerGraphics.setId(id);
}
// 设置链接数
if (CustomerCommonConstant.REPLACE_LINK_NEWS_TYPE_LIST.contains(saveDto.getCustomerReferralDto().getNewsType())) {
if (CustomerCommonConstant.REMOTE_LINK_NEWS_TYPE_LIST.contains(saveDto.getCustomerReferralDto().getNewsType())) {
customerGraphics.setReferralSize(1);
}
super.saveOrUpdate(customerGraphics);
......
......@@ -65,8 +65,6 @@ public class CustomerGraphicsTextServiceImpl extends ServiceImpl<CustomerGraphic
@Transactional(rollbackFor = Exception.class)
public GenericsResult<CustomerMessageTextDetailVO> insertCustomerContent(CustomerReferralDTO referralDto) {
System.out.println(referralDto);
// 处理活动数据
ReferralEntity referralEntity = new ReferralEntity();
BeanUtil.copyProperties(referralDto, referralEntity);
......@@ -111,7 +109,7 @@ public class CustomerGraphicsTextServiceImpl extends ServiceImpl<CustomerGraphic
// 设置主键id和h5代码段
customerContentVO.setId(item.getId());
String context = null;
if (CustomerCommonConstant.LINK_NEWS_TYPE_LIST.contains(item.getNewsType())) {
if (CustomerCommonConstant.REPLACE_LINK_NEWS_TYPE_LIST.contains(item.getNewsType())) {
context = CustomerCommonConstant.CUSTOMER_TEXT_LINK_TEMPLATE
.replace(CustomerCommonConstant.CUSTOMER_TEXT_CONTENT_PLACEHOLDER, item.getTextContent())
.replace(CustomerCommonConstant.CUSTOMER_TEXT_URL_PLACEHOLDER, CustomerCommonConstant.CUSTOMER_TEXT_URL_PLACEHOLDER + idx);
......@@ -135,7 +133,7 @@ public class CustomerGraphicsTextServiceImpl extends ServiceImpl<CustomerGraphic
contentList.add(customerContentVO);
// 统计referralSize
if (CustomerCommonConstant.REPLACE_LINK_NEWS_TYPE_LIST.contains(item.getNewsType())) {
if (CustomerCommonConstant.REMOTE_LINK_NEWS_TYPE_LIST.contains(item.getNewsType())) {
replaceLinkTypeNum += 1;
}
idx += 1;
......
......@@ -37,4 +37,11 @@ public class CustomerServiceCommonServiceImpl implements CustomerServiceCommonSe
List<CommonOptionResponseVO> storeList = materialCommonMapper.getStoreList();
return new GenericsResult<>(storeList);
}
@Override
public GenericsResult<List<CommonOptionResponseVO>> getCoverPicList() {
List<CommonOptionResponseVO> coverPicList = materialCommonMapper.getCoverPicList();
return new GenericsResult<>(coverPicList);
}
}
package com.yaoyaozw.customer.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yaoyaozw.customer.entity.ReferralEntity;
import com.yaoyaozw.customer.mapper.ReferralEntityMapper;
......@@ -18,10 +20,21 @@ public class ReferralEntityServiceImpl extends ServiceImpl<ReferralEntityMapper,
@Override
public void ultimateDeleteReferrals(Long materialId, String extraCondition) {
if (ObjectUtil.isNull(materialId)) {
return;
}
super.baseMapper.ultimateDeleteReferrals(materialId, extraCondition);
}
@Override
public void ultimateDeleteReferralsBatch(List<Long> sourceIdList, String extraCondition) {
if (CollectionUtil.isEmpty(sourceIdList)) {
return;
}
super.baseMapper.ultimateDeleteReferralsBatch(sourceIdList, extraCondition);
}
@Override
public List<ReferralEntityVo> findReferralByCustomerGraphicsId(Long graphicsId) {
return baseMapper.findByMaterialGraphicsId(graphicsId);
}
......
......@@ -2,6 +2,7 @@ package com.yaoyaozw.customer.vo;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.yaoyaozw.customer.entity.AuthorizerInfo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -33,4 +34,13 @@ public class AuthInfoVO implements Serializable {
@ApiModelProperty("书城名")
private String storeTypeName;
public void putPropertyValue(AuthorizerInfo authorizerInfo) {
this.id = authorizerInfo.getId();
this.accountId = authorizerInfo.getAccountId();
this.appId = authorizerInfo.getAppid();
this.accountName = authorizerInfo.getNickName();
this.storeType = authorizerInfo.getStoreType();
this.storeTypeName = authorizerInfo.getStoreTypeName();
}
}
package com.yaoyaozw.customer.vo.customer;
import cn.hutool.core.util.ObjectUtil;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.yaoyaozw.customer.constants.CustomerCommonConstant;
import com.yaoyaozw.customer.dto.customer.CustomerReferralDTO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import java.io.Serializable;
......@@ -25,4 +28,14 @@ public class CustomerContentVO implements Serializable {
@ApiModelProperty("链接相关内容")
private CustomerReferralDTO customerReferralDto;
@ApiModelProperty("是否可编辑")
private Boolean editable;
public Boolean getEditable() {
if (ObjectUtil.isNull(this.customerReferralDto)) {
return true;
}
// 如果是需要远程获取链接的,并且链接已经生成的,则不能再进行编辑
return !(CustomerCommonConstant.REMOTE_LINK_NEWS_TYPE_LIST.contains(this.customerReferralDto.getNewsType()) && StringUtils.isNotBlank(this.customerReferralDto.getReferral()));
}
}
......@@ -3,6 +3,7 @@ package com.yaoyaozw.customer.vo.customer;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.yaoyaozw.customer.dto.customer.CustomerReferralDTO;
import com.yaoyaozw.customer.vo.AuthInfoVO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -29,15 +30,28 @@ 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;
private AuthInfoVO authInfoVo;
}
package com.yaoyaozw.customer.vo.customer;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.yaoyaozw.customer.vo.AuthInfoVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @author darker
* @date 2022/10/12 11:30
*/
@Data
@ApiModel("文本客服详情实体")
public class CustomerDelayTextDetailVO implements Serializable {
@JsonSerialize(using = ToStringSerializer.class)
@ApiModelProperty("主键id")
private Long id;
@ApiModelProperty("标题")
private String name;
@ApiModelProperty("文本子内容")
private List<CustomerContentVO> contentList;
@ApiModelProperty("类型")
private String type;
@ApiModelProperty("发文序号")
private Integer postSort;
@ApiModelProperty("发文间隔时间")
@JsonSerialize(using = ToStringSerializer.class)
private Long timeInterval;
@ApiModelProperty("已支付、未支付")
@JsonSerialize(using = ToStringSerializer.class)
private Integer isPay;
@ApiModelProperty("appId")
private String appId;
private AuthInfoVO authInfoVo;
}
......@@ -31,7 +31,7 @@ public class CustomerMessageDetailVO implements Serializable {
@ApiModelProperty("客服消息类型(图文、文本)")
private String type;
@ApiModelProperty("素材文本内容")
@ApiModelProperty("推广标题")
private String extendTitle;
@ApiModelProperty("素材图片路径")
......
......@@ -63,6 +63,13 @@
on s_dic.group_id = 'CUSTOMER_SEND_STATUS'
and s_dic.dic_key = cgd.send_status
where cgd.is_deleted = 0
<if test="queryDto.appId != null and queryDto.appId != ''">
and cgd.app_id = #{queryDto.appId}
</if>
order by cgd.app_id, cgd.post_sort
</select>
<select id="getExistCustomerAccount" resultType="com.yaoyaozw.customer.vo.AuthInfoVO">
......@@ -103,8 +110,36 @@
nick_name as accountName,
store_type as storeType
from authorizer_info
<if test="keyword != null and keyword != ''">
where nick_name like concat('%', #{keyword}, '%')
</if>
<where>
<if test="keyword != null and keyword != ''">
and nick_name like concat('%', #{keyword}, '%')
</if>
<if test="keywordList != null and keywordList.size() != 0">
and nick_name in
<foreach collection="keywordList" separator="," open="(" close=")" item="splitKeyword">
#{splitKeyword}
</foreach>
</if>
<if test="storeType != null and storeType != ''">
and store_type = #{storeType}
</if>
<if test="appId != null and appId != ''">
and appId != #{appId}
</if>
</where>
</select>
<select id="getCustomerDelayAuthInfo" resultType="com.yaoyaozw.customer.vo.AuthInfoVO">
select
ai.id,
ai.account_id as accountId,
ai.appid as appId,
ai.nick_name as accountName,
ai.store_type as storeType
from customer_graphics_delay cgd
left join authorizer_info ai
on cgd.app_id = ai.appid
where cgd.id = #{customerId}
</select>
</mapper>
\ No newline at end of file
......@@ -50,4 +50,15 @@
select id,app_id,cost_date from account_cost_setup where app_id =#{appid}
</select>
<select id="getStoreTypeNameByAppId" resultType="java.lang.String">
select
se.store_name
from account_entity ae
left join store_entity se
on ae.store_id = se.id
where ae.app_id = #{appId}
</select>
</mapper>
\ No newline at end of file
......@@ -22,4 +22,15 @@
#{accountId}
</foreach>
</select>
<select id="getCoverPicList" resultType="com.yaoyaozw.customer.vo.CommonOptionResponseVO">
select
dic_value as label,
dic_key as `value`
from sys_dictionary
where is_deleted = 0 and level = 3
and group_id = 'CUSTOMER_PIC'
order by sort
</select>
</mapper>
\ No newline at end of file
......@@ -48,4 +48,15 @@
</select>
<delete id="ultimateDeleteReferralsBatch">
delete from referral_entity
where material_graphics_id in
<foreach collection="sourceIdList" item="sourceId" separator="," open="(" close=")">
#{sourceId}
</foreach>
<if test="extraCondition != null and extraCondition != ''">
${extraCondition}
</if>
</delete>
</mapper>
\ No newline at end of file
import com.yaoyaozw.customer.CustomerServiceApplication;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.concurrent.TimeUnit;
/**
* @author darker
* @date 2022/10/19 14:42
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = CustomerServiceApplication.class)
public class Test {
@Autowired
private RedisTemplate redisTemplate;
@org.junit.Test
public void testRedis() {
redisTemplate.opsForValue().set("count", 0);
redisTemplate.expire("count", 1, TimeUnit.MINUTES);
try {
Thread.sleep(15000);
} catch (InterruptedException e) {
e.printStackTrace();
}
redisTemplate.opsForValue().increment("count");
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论