提交 1bed98b9 作者: 沈振路

客服

上级 39d1c46f
...@@ -3,6 +3,7 @@ package com.yaoyaozw.customer; ...@@ -3,6 +3,7 @@ package com.yaoyaozw.customer;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
...@@ -13,6 +14,7 @@ import org.springframework.scheduling.annotation.EnableScheduling; ...@@ -13,6 +14,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication @SpringBootApplication
@EnableScheduling @EnableScheduling
@MapperScan("com.yaoyaozw.customer.mapper") @MapperScan("com.yaoyaozw.customer.mapper")
@EnableFeignClients
@EnableAsync @EnableAsync
public class CustomerServiceApplication { public class CustomerServiceApplication {
public static void main(String[] args) { public static void main(String[] args) {
......
package com.yaoyaozw.customer.components; package com.yaoyaozw.customer.components;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.yaoyaozw.customer.common.R;
import com.yaoyaozw.customer.constants.ApiResultConstant;
import com.yaoyaozw.customer.constants.CrowdPackageCommonConstant;
import com.yaoyaozw.customer.constants.CustomerCommonConstant;
import com.yaoyaozw.customer.dto.customer.CustomerMessageSaveDTO; import com.yaoyaozw.customer.dto.customer.CustomerMessageSaveDTO;
import com.yaoyaozw.customer.entity.CustomerGraphics;
import com.yaoyaozw.customer.entity.ReferralEntity; import com.yaoyaozw.customer.entity.ReferralEntity;
import com.yaoyaozw.customer.entity.RegisterUserEntity;
import com.yaoyaozw.customer.feigns.ReferralFeignClient;
import com.yaoyaozw.customer.mapper.MaterialCommonMapper;
import com.yaoyaozw.customer.service.CrowdPackageConditionMatchService;
import com.yaoyaozw.customer.service.ReferralEntityService; import com.yaoyaozw.customer.service.ReferralEntityService;
import com.yaoyaozw.customer.service.RegisterUserEntityService; import com.yaoyaozw.customer.service.RegisterUserEntityService;
import com.yaoyaozw.customer.vo.AuthInfoVO;
import com.yaoyaozw.customer.vo.customer.CrowdPackageUserVO; import com.yaoyaozw.customer.vo.customer.CrowdPackageUserVO;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.ArrayList; import java.text.SimpleDateFormat;
import java.util.List; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -29,18 +46,33 @@ public class CustomerServiceCommonAsyncComponent { ...@@ -29,18 +46,33 @@ public class CustomerServiceCommonAsyncComponent {
private RegisterUserEntityService userEntityService; private RegisterUserEntityService userEntityService;
@Autowired @Autowired
private ReferralEntityService referralEntityService; private ReferralEntityService referralEntityService;
@Autowired
private CrowdPackageConditionMatchService conditionMatchService;
@Autowired
private SnowflakeComponent snowflakeComponent;
@Autowired
private CrowdPackageConditionMatchService matchService;
@Autowired
private RedisTemplate redisTemplate;
@Autowired
private ReferralFeignClient referralFeignClient;
@Autowired
private MaterialCommonMapper materialCommonMapper;
@Async("myExecutor") @Async("myExecutor")
public void addMatchUserIntoPackage(Long packageId, List<CrowdPackageUserVO> userList) { public void addMatchUserIntoPackage(Long packageId, Boolean needRemove) {
// 获取符合人群包条件的用户列表
List<CrowdPackageUserVO> userList = matchService.getUserListFromPackage(packageId, null);
redisTemplate.opsForHash().put(CustomerCommonConstant.CROWD_HUMAN_NUN_REDIS_KEY, packageId.toString(), userList.size());
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
String packIdStr = packageId.toString(); String packIdStr = packageId.toString();
// 筛选当前不在这个人群包的用户 // 筛选当前不在这个人群包的用户
List<CrowdPackageUserVO> userNotInPackageList = userList.stream() List<CrowdPackageUserVO> userNotInPackageList = userList.stream()
// 保留现在不在该人群包的用户 // 保留现在不在该人群包的用户
.filter(item -> ObjectUtil.isNull(item.getInPackage()) || !item.getInPackage().contains(packIdStr)) .filter(item -> StringUtils.isBlank(item.getInPackage()) || !item.getInPackage().contains(packIdStr))
.peek(item -> { .peek(item -> {
if (ObjectUtil.isNull(item.getInPackage())) { if (StringUtils.isBlank(item.getInPackage())) {
item.setInPackage(packIdStr); item.setInPackage(packIdStr);
} else { } else {
// 将当前人群包拼在后面 // 将当前人群包拼在后面
...@@ -49,7 +81,19 @@ public class CustomerServiceCommonAsyncComponent { ...@@ -49,7 +81,19 @@ public class CustomerServiceCommonAsyncComponent {
}).collect(Collectors.toList()); }).collect(Collectors.toList());
LOCAL_LOG.info("人群包ID: {} 新增用户 {}个", packIdStr, userNotInPackageList.size()); LOCAL_LOG.info("人群包ID: {} 新增用户 {}个", packIdStr, userNotInPackageList.size());
if (needRemove) {
// 当前在人群包内的用户
List<CrowdPackageUserVO> packCurrentUserList = userEntityService.getCurrentInPackUserList(packageId);
if (CollectionUtil.isNotEmpty(packCurrentUserList)) {
List<String> userOpenIdList = userList.stream().map(CrowdPackageUserVO::getOpenId).collect(Collectors.toList());
// 筛选出之前在人群包内,现在不在地用户列表
List<CrowdPackageUserVO> needRemoveUserList = packCurrentUserList.stream().filter(item -> !userOpenIdList.contains(item.getOpenId())).collect(Collectors.toList());
removeUnMatchUserFromPackage(packageId, needRemoveUserList);
}
}
if (CollectionUtil.isNotEmpty(userNotInPackageList)) {
userEntityService.updateBatchById(encapsulateUserEntity(userNotInPackageList));
}
long endTime = System.currentTimeMillis(); long endTime = System.currentTimeMillis();
LOCAL_LOG.info("异步添加符合条件用户人群包完成, 耗时: {}ms", endTime - startTime); LOCAL_LOG.info("异步添加符合条件用户人群包完成, 耗时: {}ms", endTime - startTime);
...@@ -62,36 +106,168 @@ public class CustomerServiceCommonAsyncComponent { ...@@ -62,36 +106,168 @@ public class CustomerServiceCommonAsyncComponent {
// 筛选当前不在这个人群包的用户 // 筛选当前不在这个人群包的用户
List<CrowdPackageUserVO> userRemoveFromPackList = userList.stream() List<CrowdPackageUserVO> userRemoveFromPackList = userList.stream()
// 移除现在在该人群包但不符合当前条件的用户 // 移除现在在该人群包但不符合当前条件的用户
.filter(item -> ObjectUtil.isNotNull(item.getInPackage()) && item.getInPackage().contains(packIdStr)) .filter(item -> StringUtils.isNotBlank(item.getInPackage()) && item.getInPackage().contains(packIdStr))
.peek(item -> { .peek(item -> {
String removePackageStr = item.getInPackage().replace("," + packIdStr, "") String removePackageStr = item.getInPackage().replace("," + packIdStr, "")
.replace(packIdStr + ",", "") .replace(packIdStr + ",", "")
.replace(packIdStr, ""); .replace(packIdStr, "");
item.setInPackage(removePackageStr); item.setInPackage(StringUtils.isBlank(removePackageStr) ? "" : removePackageStr);
}).collect(Collectors.toList()); }).collect(Collectors.toList());
LOCAL_LOG.info("人群包ID: {} 移除用户 {}个", packIdStr, userRemoveFromPackList.size()); LOCAL_LOG.info("人群包ID: {} 移除用户 {}个", packIdStr, userRemoveFromPackList.size());
if (CollectionUtil.isNotEmpty(userRemoveFromPackList)) {
userEntityService.updateBatchById(encapsulateUserEntity(userRemoveFromPackList));
}
long endTime = System.currentTimeMillis(); long endTime = System.currentTimeMillis();
LOCAL_LOG.info("异步删除不符合条件用户所属人群包完成, 耗时: {}ms", endTime - startTime); LOCAL_LOG.info("异步删除不符合条件用户所属人群包完成, 耗时: {}ms", endTime - startTime);
} }
@Async("myExecutor") @Async("myExecutor")
public void getAuthListLink(Long id, CustomerMessageSaveDTO saveDto) { public void getAuthListLink(CustomerGraphics customerMain, ReferralEntity customerReferral) {
LOCAL_LOG.info("进入异步方法"); Long packId = customerMain.getPackId();
List<Long> accountIdList = userEntityService.getAccountIdListFromPackage(saveDto.getPackId()); LOCAL_LOG.info("开始异步处理客服链接, 客服标题: {}, 人群包主键: {}", customerMain.getName(), packId);
// 获取符合人群包条件的用户所属的公众号列表
List<CrowdPackageUserVO> userListFromPackage = conditionMatchService.getUserListFromPackage(packId, null);
Map<String, List<CrowdPackageUserVO>> storeGroupMap = userListFromPackage.stream().collect(Collectors.groupingBy(CrowdPackageUserVO::getStoreType));
LOCAL_LOG.info("当前包含书城: {} 个", storeGroupMap.size());
// 遍历处理书城
Integer newsType = customerReferral.getNewsType();
// 一个书城一个书城地处理
if (newsType.equals(CustomerCommonConstant.BOOK_NEWS_TYPE)) {
// 是推广链接
generateExtendLink(storeGroupMap, customerReferral);
} else if (CustomerCommonConstant.ACTIVITY_NEWS_TYPE.equals(newsType)) {
// 是活动链接
generateActivityLink(storeGroupMap, customerReferral);
} else if (CustomerCommonConstant.USUAL_LINK_NEWS_TYPE.equals(newsType)) {
// 常用链接
generateUsualLink(storeGroupMap, customerReferral);
}
}
private List<RegisterUserEntity> encapsulateUserEntity(List<CrowdPackageUserVO> userList) {
List<RegisterUserEntity> userEntityList = new ArrayList<>();
for (CrowdPackageUserVO crowdPackageUserVO : userList) {
RegisterUserEntity registerUserEntity = new RegisterUserEntity();
registerUserEntity.setId(crowdPackageUserVO.getId());
registerUserEntity.setInPackage(crowdPackageUserVO.getInPackage());
userEntityList.add(registerUserEntity);
}
return userEntityList;
}
private void generateExtendLink(Map<String, List<CrowdPackageUserVO>> storeGroupMap, ReferralEntity customerReferral) {
storeGroupMap.forEach((storeType, userVoList) -> {
LOCAL_LOG.info("当前处理书城: {}", storeType);
// 去重提取公众号
Set<String> accountSet = userVoList.stream().map(CrowdPackageUserVO::getAccountId).collect(Collectors.toSet());
List<AuthInfoVO> authInfoList = materialCommonMapper.getAuthInfoList(accountSet);
// 定义
List<ReferralEntity> referralEntityList = new ArrayList<>(accountSet.size());
for (AuthInfoVO authInfoVo : authInfoList) {
ReferralEntity referralEntity = new ReferralEntity();
List<ReferralEntity> referralEntityList = new ArrayList<>(accountIdList.size()); BeanUtil.copyProperties(customerReferral, referralEntity);
// 重新生成链接主键id
referralEntity.setId(snowflakeComponent.snowflakeId());
// TODO: 2022/10/9 获取原文链接
getCopyReferral(null, authInfoVo, referralEntity);
// 遍历处理 referralEntityList.add(referralEntity);
}
// 批量新增
referralEntityService.saveBatch(referralEntityList);
});
}
private void generateActivityLink(Map<String, List<CrowdPackageUserVO>> storeGroupMap, ReferralEntity customerReferral) {
storeGroupMap.forEach((storeType, userVoList) -> {
LOCAL_LOG.info("当前处理书城: {}", storeType);
// 去重提取公众号
Set<String> accountSet = userVoList.stream().map(CrowdPackageUserVO::getAccountId).collect(Collectors.toSet());
// 定义
List<ReferralEntity> referralEntityList = new ArrayList<>(accountSet.size());
ReferralEntity referralEntity = new ReferralEntity();
BeanUtil.copyProperties(customerReferral, referralEntity);
// 重新生成链接主键id
referralEntity.setId(snowflakeComponent.snowflakeId());
// TODO: 2022/10/9 获取原文链接
referralEntityService.saveBatch(referralEntityList); referralEntityList.add(referralEntity);
// 批量新增
referralEntityService.saveBatch(referralEntityList);
});
} }
private void generateUsualLink(Map<String, List<CrowdPackageUserVO>> storeGroupMap, ReferralEntity customerReferral) {
storeGroupMap.forEach((storeType, userVoList) -> {
LOCAL_LOG.info("当前处理书城: {}", storeType);
// 去重提取公众号
Set<String> accountSet = userVoList.stream().map(CrowdPackageUserVO::getAccountId).collect(Collectors.toSet());
// 定义
List<ReferralEntity> referralEntityList = new ArrayList<>(accountSet.size());
ReferralEntity referralEntity = new ReferralEntity();
BeanUtil.copyProperties(customerReferral, referralEntity);
// 重新生成链接主键id
referralEntity.setId(snowflakeComponent.snowflakeId());
// TODO: 2022/10/9 获取原文链接
referralEntityList.add(referralEntity);
// 批量新增
referralEntityService.saveBatch(referralEntityList);
});
}
private void getCopyReferral(String dateStr,
AuthInfoVO authInfoVo,
ReferralEntity referralEntity) {
referralEntity.setStoreType(authInfoVo.getStoreType());
referralEntity.setStoreTypeName(authInfoVo.getStoreTypeName());
referralEntity.setName(replaceName(referralEntity.getName(), dateStr));
referralEntity.setAccountId(null);
referralEntity.setInfoId(authInfoVo.getId());
R r = referralFeignClient.productReferral(referralEntity);
if (!r.getCode().equals(ApiResultConstant.SUCCESS_CODE)) {
throw new RuntimeException(r.getMessage());
}
String res = r.getData("storeReferral", new TypeReference<String>() {
});
JSONObject jsonObject1 = JSON.parseObject(res);
String referral = jsonObject1.getString("referral");
referralEntity.setPromoteId(jsonObject1.getString("promoteId"));
referralEntity.setReferral(referral);
// 系统-客服-推广-{accountNickName}-{storeType}-2022/04/24-1-{bookName}
// 系统-客服-活动-{accountNickName}-{storeType}-2022/04/24-1-充{recharge}送{gift}
}
private String replaceName(String materialName, String appNickName) {
if (materialName.contains("-")) {
String[] split = materialName.split("-");
String format = new SimpleDateFormat("yyyy/MM/dd").format(new Date());
split[5] = format;
split[3] = appNickName;
return String.join("-", split);
}
return materialName;
}
} }
...@@ -25,6 +25,12 @@ public class CrowdPackageCommonConstant { ...@@ -25,6 +25,12 @@ public class CrowdPackageCommonConstant {
public static final String GROUP_OR = "group_or"; public static final String GROUP_OR = "group_or";
public static final String CONDITION_STORE_ID = "store_id";
public static final String MULTIPLE_SELECT = "multiple_select";
public static final String COMMA_SEPARATOR = ",";
public static final Integer STATIC_CONDITION = 1; public static final Integer STATIC_CONDITION = 1;
public static final Integer NON_STATIC_CONDITION = 0; public static final Integer NON_STATIC_CONDITION = 0;
......
package com.yaoyaozw.customer.constants; package com.yaoyaozw.customer.constants;
import cn.hutool.core.util.ObjectUtil;
/** /**
* @author darker * @author darker
* @date 2022/9/28 20:09 * @date 2022/9/28 20:09
...@@ -8,4 +10,31 @@ public class CustomerCommonConstant { ...@@ -8,4 +10,31 @@ public class CustomerCommonConstant {
public final static String CROWD_HUMAN_NUN_REDIS_KEY = "crowdHumanNum"; public final static String CROWD_HUMAN_NUN_REDIS_KEY = "crowdHumanNum";
public final static Integer ACTIVITY_NEWS_TYPE = 8;
public final static Integer BOOK_NEWS_TYPE = 7;
public final static Integer USUAL_LINK_NEWS_TYPE = 9;
public final static String CUSTOMER_TYPE_VALUE_GRAPHICS = "news";
public final static String CUSTOMER_TYPE_VALUE_TEXT = "text";
public final static String CUSTOMER_TYPE_NAME_GRAPHICS = "图文";
public final static String CUSTOMER_TYPE_NAME_TEXT = "文本";
public static String getCustomerType(String type) {
if (ObjectUtil.isNull(type)) {
return null;
}
if (type.equals(CUSTOMER_TYPE_VALUE_GRAPHICS)) {
return CUSTOMER_TYPE_NAME_GRAPHICS;
}
if (type.equals(CUSTOMER_TYPE_VALUE_TEXT)) {
return CUSTOMER_TYPE_NAME_TEXT;
}
return type;
}
} }
package com.yaoyaozw.customer.controller;
import com.yaoyaozw.customer.common.GenericsResult;
import com.yaoyaozw.customer.service.CustomerServiceCommonService;
import com.yaoyaozw.customer.vo.CommonOptionResponseVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author darker
* @date 2022/10/9 10:15
*/
@RestController
@RequestMapping("/customer-service/common")
@Api(tags = "客服通用接口")
public class CustomerCommonController {
@Autowired
private CustomerServiceCommonService commonService;
@GetMapping("/getStoreList")
@ApiOperation("获取书城列表")
public GenericsResult<List<CommonOptionResponseVO>> getStoreList() {
return commonService.getStoreList();
}
}
package com.yaoyaozw.customer.controller; package com.yaoyaozw.customer.controller;
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.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.CustomerDelayListVO;
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;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -33,15 +35,15 @@ public class CustomerMessageController { ...@@ -33,15 +35,15 @@ public class CustomerMessageController {
return customerGraphicsService.insertCustomerMessage(saveDto); return customerGraphicsService.insertCustomerMessage(saveDto);
} }
@ApiOperation("编辑") @ApiOperation("获取详情")
@PostMapping("/edit") @GetMapping("/detail/{id}")
public BaseResult updateCustomerMessage(@RequestBody CustomerMessageSaveDTO saveDto) { public GenericsResult<CustomerMessageDetailVO> getCustomerMessageDetail(@PathVariable("id") Long id) {
return customerGraphicsService.updateCustomerMessage(saveDto); return customerGraphicsService.getCustomerMessageDetail(id);
} }
@ApiOperation("查询") @ApiOperation("查询")
@PostMapping("/pageList") @PostMapping("/pageList")
public GenericsResult<List<CustomerMessageListVO>> pageList(@RequestBody CustomerMessageQueryDTO queryDto) { public GenericsResult<PageInfo<CustomerMessageListVO>> pageList(@RequestBody CustomerMessageQueryDTO queryDto) {
return customerGraphicsService.pageList(queryDto); return customerGraphicsService.pageList(queryDto);
} }
...@@ -51,5 +53,10 @@ public class CustomerMessageController { ...@@ -51,5 +53,10 @@ public class CustomerMessageController {
return customerGraphicsService.removeCustomerMessage(id); return customerGraphicsService.removeCustomerMessage(id);
} }
@ApiOperation("设置人群包")
@GetMapping("/setPack")
public BaseResult setPack(@RequestParam Long id, @RequestParam Long packId) {
return customerGraphicsService.setPack(id, packId);
}
} }
package com.yaoyaozw.customer.dto.customer; package com.yaoyaozw.customer.dto.customer;
import com.yaoyaozw.customer.common.PageParams;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable; import java.io.Serializable;
...@@ -10,17 +12,12 @@ import java.io.Serializable; ...@@ -10,17 +12,12 @@ import java.io.Serializable;
* @author darker * @author darker
* @date 2022/9/15 11:20 * @date 2022/9/15 11:20
*/ */
@EqualsAndHashCode(callSuper = true)
@Data @Data
@ApiModel("延时客服列表查询实体") @ApiModel("延时客服列表查询实体")
public class CustomerMessageQueryDTO implements Serializable { public class CustomerMessageQueryDTO extends PageParams implements Serializable {
private static final long serialVersionUID = 2406901469313438527L; private static final long serialVersionUID = 2406901469313438527L;
@ApiModelProperty("消息名称关键词")
private String messageKeyword;
@ApiModelProperty("客服消息类型")
private Integer messageType;
} }
...@@ -18,22 +18,16 @@ public class CustomerMessageSaveDTO implements Serializable { ...@@ -18,22 +18,16 @@ public class CustomerMessageSaveDTO implements Serializable {
@ApiModelProperty("客服消息id") @ApiModelProperty("客服消息id")
private Long id; private Long id;
@ApiModelProperty("人群包ID")
private Long packId;
@ApiModelProperty("标题") @ApiModelProperty("标题")
private String title; private String name;
@ApiModelProperty("消息发送时间") @ApiModelProperty("消息发送时间")
private String postTime; private String postTime;
@ApiModelProperty("是否支付 0-否 1-是")
private Integer isPay;
@ApiModelProperty("客服消息类型(图文、文本)") @ApiModelProperty("客服消息类型(图文、文本)")
private Integer type; private String type;
@ApiModelProperty("素材文本内容") @ApiModelProperty("推广标题")
private String extendTitle; private String extendTitle;
@ApiModelProperty("素材图片路径") @ApiModelProperty("素材图片路径")
......
package com.yaoyaozw.customer.dto.customer; package com.yaoyaozw.customer.dto.customer;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* @author darker * @author darker
...@@ -14,11 +22,18 @@ import java.util.Date; ...@@ -14,11 +22,18 @@ import java.util.Date;
@Data @Data
public class CustomerReferralDTO implements Serializable { public class CustomerReferralDTO implements Serializable {
@ApiModelProperty("主键id")
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
@ApiModelProperty("链接类型") @ApiModelProperty("链接类型")
private Integer newsType; private Integer newsType;
@ApiModelProperty("书城")
private String storeType;
@ApiModelProperty("书") @ApiModelProperty("书")
private Long bookId; private String bookId;
@ApiModelProperty("章节") @ApiModelProperty("章节")
private Integer chapterIdx; private Integer chapterIdx;
...@@ -41,6 +56,42 @@ public class CustomerReferralDTO implements Serializable { ...@@ -41,6 +56,42 @@ public class CustomerReferralDTO implements Serializable {
@ApiModelProperty(value = "结束时间") @ApiModelProperty(value = "结束时间")
private Date endTime; private Date endTime;
@ApiModelProperty(value = "开始、结束时间")
private List<Date> dateList;
@ApiModelProperty(value = "充值金额")
private BigDecimal rechargeAmount;
@ApiModelProperty(value = "赠送数量")
private Integer giftAmount;
private Integer isDeleted;
public Date getStartTime() {
if (ObjectUtil.isNull(this.startTime) && CollectionUtil.isNotEmpty(this.dateList)) {
return dateList.get(0);
}
return startTime;
}
public Date getEndTime() {
if (ObjectUtil.isNull(this.endTime) && CollectionUtil.isNotEmpty(this.dateList)) {
return dateList.get(0);
}
return endTime;
}
public List<Date> getDateList() {
if (CollectionUtil.isEmpty(this.dateList) && ObjectUtil.isNotNull(this.startTime) && ObjectUtil.isNotNull(this.endTime)) {
return Arrays.asList(this.startTime, this.endTime);
}
return dateList;
}
public Integer getIsDeleted() {
if (ObjectUtil.isNull(this.isDeleted)) {
return 0;
}
return isDeleted;
}
} }
...@@ -16,7 +16,7 @@ import org.springframework.data.annotation.Id; ...@@ -16,7 +16,7 @@ import org.springframework.data.annotation.Id;
@Data @Data
@TableName(value = "customer_graphics") @TableName(value = "customer_graphics")
public class CustomerGraphics implements Serializable { public class CustomerGraphics implements Serializable {
@TableId(value = "id", type = IdType.AUTO) @TableId(value = "id", type = IdType.ID_WORKER)
@Id @Id
private Long id; private Long id;
...@@ -29,20 +29,14 @@ public class CustomerGraphics implements Serializable { ...@@ -29,20 +29,14 @@ public class CustomerGraphics implements Serializable {
/** /**
* 标题 * 标题
*/ */
@TableField(value = "title") @TableField(value = "name")
private String title; private String name;
/** /**
* 类型 0-文本 1-图文 * 类型 0-文本 1-图文
*/ */
@TableField(value = "type") @TableField(value = "type")
private Integer type; private String type;
/**
* 是否支付 0-否 1-是
*/
@TableField(value = "is_pay")
private Integer isPay;
/** /**
* 推广标题 * 推广标题
......
...@@ -196,6 +196,10 @@ public class ReferralEntity implements Serializable { ...@@ -196,6 +196,10 @@ public class ReferralEntity implements Serializable {
@TableField(value = "config_name") @TableField(value = "config_name")
private String configName; private String configName;
@TableField(exist = false)
@ApiModelProperty(value = "infoId")
private Long infoId;
public static final String COL_ID = "id"; public static final String COL_ID = "id";
public static final String COL_ACCOUNT_ID = "account_id"; public static final String COL_ACCOUNT_ID = "account_id";
......
...@@ -87,6 +87,12 @@ public class RegisterUserEntity implements Serializable { ...@@ -87,6 +87,12 @@ public class RegisterUserEntity implements Serializable {
@TableField(value = "customer_publish") @TableField(value = "customer_publish")
private Date customerPublish; private Date customerPublish;
/**
* 延时客服发送时间
*/
@TableField(value = "in_package")
private String inPackage;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
......
package com.yaoyaozw.customer.feigns;
import com.yaoyaozw.customer.common.R;
import com.yaoyaozw.customer.entity.ReferralEntity;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
/**
* 推荐装客户端
*
* @author Admin
* @date 2022/10/09
*/
@FeignClient("referral-service-wgh")
public interface ReferralFeignClient {
/**
* 产品推荐
*
* @param referralEntity 推荐实体
* @return {@link R}
*/
@PostMapping("/getReferral")
R productReferral(@RequestBody ReferralEntity referralEntity);
}
package com.yaoyaozw.customer.mapper; package com.yaoyaozw.customer.mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yaoyaozw.customer.dto.customer.CustomerMessageQueryDTO;
import com.yaoyaozw.customer.entity.CustomerGraphics; import com.yaoyaozw.customer.entity.CustomerGraphics;
import com.yaoyaozw.customer.vo.customer.CustomerMessageListVO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author Admin
* @date 2022/10/08
*/
@Mapper @Mapper
@DS("material")
public interface CustomerGraphicsMapper extends BaseMapper<CustomerGraphics> { public interface CustomerGraphicsMapper extends BaseMapper<CustomerGraphics> {
/**
* 页面列表
*
* @param queryDto 查询dto
* @return {@link List}<{@link CustomerMessageListVO}>
*/
List<CustomerMessageListVO> pageList(@Param("queryDto") CustomerMessageQueryDTO queryDto);
} }
\ No newline at end of file
...@@ -33,5 +33,13 @@ public interface KanbanCommonMapper { ...@@ -33,5 +33,13 @@ public interface KanbanCommonMapper {
*/ */
List<Long> getSetupIdListFromStaticCondition(@Param("expressList") List<String> expressList); List<Long> getSetupIdListFromStaticCondition(@Param("expressList") List<String> expressList);
/**
* 被表达存储类型
*
* @param expression 表达式
* @return {@link String}
*/
String getStoreTypeByExpression(@Param("expression") String expression);
} }
package com.yaoyaozw.customer.mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.yaoyaozw.customer.common.GenericsResult;
import com.yaoyaozw.customer.vo.AuthInfoVO;
import com.yaoyaozw.customer.vo.CommonOptionResponseVO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Set;
/**
* @author darker
* @date 2022/10/9 10:31
*/
@Repository
@DS("material")
public interface MaterialCommonMapper {
/**
* 获取存储列表
*
* @return {@link List}<{@link CommonOptionResponseVO}>
*/
List<CommonOptionResponseVO> getStoreList();
/**
* 获得身份验证信息列表
*
* @param accountSet 帐户设置
* @return {@link List}<{@link AuthInfoVO}>
*/
List<AuthInfoVO> getAuthInfoList(@Param("accountSet") Set<String> accountSet);
}
package com.yaoyaozw.customer.mapper; package com.yaoyaozw.customer.mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yaoyaozw.customer.entity.ReferralEntity; import com.yaoyaozw.customer.entity.ReferralEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
...@@ -11,6 +12,7 @@ import org.apache.ibatis.annotations.Param; ...@@ -11,6 +12,7 @@ import org.apache.ibatis.annotations.Param;
* @date 2022/10/08 * @date 2022/10/08
*/ */
@Mapper @Mapper
@DS("material")
public interface ReferralEntityMapper extends BaseMapper<ReferralEntity> { public interface ReferralEntityMapper extends BaseMapper<ReferralEntity> {
/** /**
......
...@@ -29,11 +29,19 @@ public interface RegisterUserEntityMapper extends BaseMapper<RegisterUserEntity> ...@@ -29,11 +29,19 @@ public interface RegisterUserEntityMapper extends BaseMapper<RegisterUserEntity>
void updateUserPackageBelong(@Param("openId") String openId, @Param("packageBelong") String packageBelong); void updateUserPackageBelong(@Param("openId") String openId, @Param("packageBelong") String packageBelong);
/** /**
* 从包中获取用户列表(现在已经在人群包内的) * 从包中获取公众号列表
* *
* @param packageId 包id * @param packageId 包id
* @return {@link List}<{@link RegisterUserEntity}> * @return {@link List}<{@link RegisterUserEntity}>
*/ */
List<Long> getAuthListFromPackage(@Param("packageId") Long packageId); List<Long> getAuthListFromPackage(@Param("packageId") Long packageId);
/**
* 得到当前包用户列表中
*
* @param packageId 包id
* @return {@link List}<{@link CrowdPackageUserVO}>
*/
List<CrowdPackageUserVO> getCurrentInPackUserList(@Param("packageId") Long packageId);
} }
\ No newline at end of file
package com.yaoyaozw.customer.service; package com.yaoyaozw.customer.service;
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.CustomerMessageQueryDTO; import com.yaoyaozw.customer.dto.customer.CustomerMessageQueryDTO;
...@@ -7,6 +8,7 @@ import com.yaoyaozw.customer.dto.customer.CustomerMessageSaveDTO; ...@@ -7,6 +8,7 @@ import com.yaoyaozw.customer.dto.customer.CustomerMessageSaveDTO;
import com.yaoyaozw.customer.entity.CustomerGraphics; import com.yaoyaozw.customer.entity.CustomerGraphics;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.yaoyaozw.customer.vo.customer.CustomerDelayListVO; import com.yaoyaozw.customer.vo.customer.CustomerDelayListVO;
import com.yaoyaozw.customer.vo.customer.CustomerMessageDetailVO;
import com.yaoyaozw.customer.vo.customer.CustomerMessageListVO; import com.yaoyaozw.customer.vo.customer.CustomerMessageListVO;
import java.util.List; import java.util.List;
...@@ -32,10 +34,10 @@ public interface CustomerGraphicsService extends IService<CustomerGraphics> { ...@@ -32,10 +34,10 @@ public interface CustomerGraphicsService extends IService<CustomerGraphics> {
/** /**
* 更新客户信息 * 更新客户信息
* *
* @param saveDto 保存dto * @param id 客服消息主键
* @return {@link BaseResult} * @return {@link BaseResult}
*/ */
BaseResult updateCustomerMessage(CustomerMessageSaveDTO saveDto); GenericsResult<CustomerMessageDetailVO> getCustomerMessageDetail( Long id);
/** /**
...@@ -44,7 +46,7 @@ public interface CustomerGraphicsService extends IService<CustomerGraphics> { ...@@ -44,7 +46,7 @@ public interface CustomerGraphicsService extends IService<CustomerGraphics> {
* @param queryDto 查询dto * @param queryDto 查询dto
* @return {@link GenericsResult}<{@link List}<{@link CustomerDelayListVO}>> * @return {@link GenericsResult}<{@link List}<{@link CustomerDelayListVO}>>
*/ */
GenericsResult<List<CustomerMessageListVO>> pageList(CustomerMessageQueryDTO queryDto); GenericsResult<PageInfo<CustomerMessageListVO>> pageList(CustomerMessageQueryDTO queryDto);
/** /**
* 删除客户信息 * 删除客户信息
...@@ -54,5 +56,13 @@ public interface CustomerGraphicsService extends IService<CustomerGraphics> { ...@@ -54,5 +56,13 @@ public interface CustomerGraphicsService extends IService<CustomerGraphics> {
*/ */
BaseResult removeCustomerMessage(Long id); BaseResult removeCustomerMessage(Long id);
/**
* 设置包
*
* @param id id
* @param packId 包id
* @return {@link BaseResult}
*/
BaseResult setPack(Long id, Long packId);
} }
package com.yaoyaozw.customer.service; package com.yaoyaozw.customer.service;
import com.yaoyaozw.customer.common.GenericsResult;
import com.yaoyaozw.customer.vo.CommonOptionResponseVO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
...@@ -18,4 +20,10 @@ public interface CustomerServiceCommonService { ...@@ -18,4 +20,10 @@ public interface CustomerServiceCommonService {
*/ */
List<Long> getSetupIdListFromStaticCondition(List<String> expressList); List<Long> getSetupIdListFromStaticCondition(List<String> expressList);
/**
* 获取存储列表
*
* @return {@link GenericsResult}<{@link CommonOptionResponseVO}>
*/
GenericsResult<List<CommonOptionResponseVO>> getStoreList();
} }
...@@ -24,13 +24,21 @@ public interface RegisterUserEntityService extends IService<RegisterUserEntity>{ ...@@ -24,13 +24,21 @@ public interface RegisterUserEntityService extends IService<RegisterUserEntity>{
List<CrowdPackageUserVO> getUserMatchDynamicExpress(List<String> dynamicExpressList, String openId); List<CrowdPackageUserVO> getUserMatchDynamicExpress(List<String> dynamicExpressList, String openId);
/** /**
* 从包中获取用户列表(现在已经在人群包内的) * 从包中获取公众号列表
* *
* @param packageId 包id * @param packageId 包id
* @return {@link List}<{@link RegisterUserEntity}> * @return {@link List}<{@link RegisterUserEntity}>
*/ */
List<Long> getAccountIdListFromPackage(Long packageId); List<Long> getAccountIdListFromPackage(Long packageId);
/**
* 得到当前包用户列表中
*
* @param packageId 包id
* @return {@link List}<{@link CrowdPackageUserVO}>
*/
List<CrowdPackageUserVO> getCurrentInPackUserList(Long packageId);
} }
...@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; ...@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
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.components.CustomerServiceCommonAsyncComponent;
import com.yaoyaozw.customer.components.SnowflakeComponent; import com.yaoyaozw.customer.components.SnowflakeComponent;
import com.yaoyaozw.customer.components.TokenManager; import com.yaoyaozw.customer.components.TokenManager;
import com.yaoyaozw.customer.constants.CrowdPackageCommonConstant; import com.yaoyaozw.customer.constants.CrowdPackageCommonConstant;
...@@ -63,6 +64,8 @@ public class CrowdPackageServiceImpl extends ServiceImpl<MaterialCrowdPackageMap ...@@ -63,6 +64,8 @@ public class CrowdPackageServiceImpl extends ServiceImpl<MaterialCrowdPackageMap
private RegisterUserEntityMapper userEntityMapper; private RegisterUserEntityMapper userEntityMapper;
@Autowired @Autowired
private RedisTemplate redisTemplate; private RedisTemplate redisTemplate;
@Autowired
private CustomerServiceCommonAsyncComponent asyncComponent;
@Override @Override
...@@ -86,6 +89,9 @@ public class CrowdPackageServiceImpl extends ServiceImpl<MaterialCrowdPackageMap ...@@ -86,6 +89,9 @@ public class CrowdPackageServiceImpl extends ServiceImpl<MaterialCrowdPackageMap
boolean result = super.saveOrUpdate(crowdPackage); boolean result = super.saveOrUpdate(crowdPackage);
// TODO: 2022/9/26 添加人群包人群的更新 // TODO: 2022/9/26 添加人群包人群的更新
if (result && ObjectUtil.isNotNull(name)) {
asyncComponent.addMatchUserIntoPackage(id, true);
}
return result ? new GenericsResult<>(new CrowdPackageCommonIdVO(crowdPackage.getId(), null)) : new GenericsResult<>(false, "新增人群包失败!"); return result ? new GenericsResult<>(new CrowdPackageCommonIdVO(crowdPackage.getId(), null)) : new GenericsResult<>(false, "新增人群包失败!");
} }
...@@ -232,10 +238,10 @@ public class CrowdPackageServiceImpl extends ServiceImpl<MaterialCrowdPackageMap ...@@ -232,10 +238,10 @@ public class CrowdPackageServiceImpl extends ServiceImpl<MaterialCrowdPackageMap
@Override @Override
public BaseResult updateUserPackageBatch(List<String> openIdList) { public BaseResult updateUserPackageBatch(List<String> openIdList) {
List<CrowdPackage> packageList = super.list(); for (String openId : openIdList) {
this.updateUserPackageBelong(openId);
}
return null; return new BaseResult().success();
} }
/** /**
......
package com.yaoyaozw.customer.service.impl; package com.yaoyaozw.customer.service.impl;
import cn.hutool.core.bean.BeanUtil; 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.github.pagehelper.PageHelper;
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.components.CustomerServiceCommonAsyncComponent; import com.yaoyaozw.customer.components.CustomerServiceCommonAsyncComponent;
import com.yaoyaozw.customer.components.SnowflakeComponent;
import com.yaoyaozw.customer.components.TokenManager; import com.yaoyaozw.customer.components.TokenManager;
import com.yaoyaozw.customer.constants.CrowdPackageCommonConstant;
import com.yaoyaozw.customer.constants.CustomerCommonConstant; import com.yaoyaozw.customer.constants.CustomerCommonConstant;
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.customer.CustomerReferralDTO;
import com.yaoyaozw.customer.entity.CrowdPackageCondition;
import com.yaoyaozw.customer.entity.CrowdPackageConditionMatch;
import com.yaoyaozw.customer.entity.ReferralEntity; import com.yaoyaozw.customer.entity.ReferralEntity;
import com.yaoyaozw.customer.mapper.KanbanCommonMapper;
import com.yaoyaozw.customer.service.CrowdPackageConditionMatchService; import com.yaoyaozw.customer.service.CrowdPackageConditionMatchService;
import com.yaoyaozw.customer.service.CrowdPackageConditionService;
import com.yaoyaozw.customer.service.ReferralEntityService; import com.yaoyaozw.customer.service.ReferralEntityService;
import com.yaoyaozw.customer.service.RegisterUserEntityService; import com.yaoyaozw.customer.vo.customer.CustomerMessageDetailVO;
import com.yaoyaozw.customer.vo.customer.CrowdPackageUserVO;
import com.yaoyaozw.customer.vo.customer.CustomerMessageListVO; import com.yaoyaozw.customer.vo.customer.CustomerMessageListVO;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List; import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yaoyaozw.customer.entity.CustomerGraphics; import com.yaoyaozw.customer.entity.CustomerGraphics;
import com.yaoyaozw.customer.mapper.CustomerGraphicsMapper; import com.yaoyaozw.customer.mapper.CustomerGraphicsMapper;
import com.yaoyaozw.customer.service.CustomerGraphicsService; import com.yaoyaozw.customer.service.CustomerGraphicsService;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
/** /**
* 客户图形服务impl * 客户图形服务impl
...@@ -46,6 +57,12 @@ public class CustomerGraphicsServiceImpl extends ServiceImpl<CustomerGraphicsMap ...@@ -46,6 +57,12 @@ public class CustomerGraphicsServiceImpl extends ServiceImpl<CustomerGraphicsMap
private CustomerServiceCommonAsyncComponent commonAsyncComponent; private CustomerServiceCommonAsyncComponent commonAsyncComponent;
@Autowired @Autowired
private ReferralEntityService referralEntityService; private ReferralEntityService referralEntityService;
@Autowired
private CrowdPackageConditionService conditionService;
@Autowired
private SnowflakeComponent snowflakeComponent;
@Autowired
private KanbanCommonMapper kanbanCommonMapper;
@Override @Override
public BaseResult insertCustomerMessage(CustomerMessageSaveDTO saveDto) { public BaseResult insertCustomerMessage(CustomerMessageSaveDTO saveDto) {
...@@ -54,34 +71,133 @@ public class CustomerGraphicsServiceImpl extends ServiceImpl<CustomerGraphicsMap ...@@ -54,34 +71,133 @@ public class CustomerGraphicsServiceImpl extends ServiceImpl<CustomerGraphicsMap
LOCAL_LOG.info("处理主体数据"); LOCAL_LOG.info("处理主体数据");
CustomerGraphics customerGraphics = new CustomerGraphics(); CustomerGraphics customerGraphics = new CustomerGraphics();
BeanUtil.copyProperties(saveDto, customerGraphics); BeanUtil.copyProperties(saveDto, customerGraphics);
customerGraphics.initOperateInfo(tokenManager.getUserIdFromToken(), true); customerGraphics.initOperateInfo(tokenManager.getUserIdFromToken(), ObjectUtil.isNull(saveDto.getId()));
super.save(customerGraphics); if (ObjectUtil.isNull(customerGraphics.getId())) {
long id = snowflakeComponent.snowflakeId();
customerGraphics.setId(id);
}
super.saveOrUpdate(customerGraphics);
// 处理活动数据 // 处理活动数据
ReferralEntity referralEntity = new ReferralEntity(); ReferralEntity referralEntity = new ReferralEntity();
BeanUtil.copyProperties(saveDto.getCustomerReferralDto(), referralEntity); BeanUtil.copyProperties(saveDto.getCustomerReferralDto(), referralEntity);
referralEntity.setMaterialGraphicsId(customerGraphics.getId()); referralEntity.setMaterialGraphicsId(customerGraphics.getId());
referralEntityService.save(referralEntity);
// 保存链接数据
referralEntityService.saveOrUpdate(referralEntity);
return new BaseResult().success(); return new BaseResult().success();
} }
@Override @Override
public BaseResult updateCustomerMessage(CustomerMessageSaveDTO saveDto) { public GenericsResult<CustomerMessageDetailVO> getCustomerMessageDetail(Long id) {
return null;
// 获取主体数据
CustomerGraphics customerGraphics = super.getById(id);
if (ObjectUtil.isNull(customerGraphics)) {
return new GenericsResult<>(false, "找不到主体数据");
}
CustomerMessageDetailVO customerMessageDetailVO = new CustomerMessageDetailVO();
BeanUtil.copyProperties(customerGraphics, customerMessageDetailVO);
// 获取链接数据
ReferralEntity referralEntity = referralEntityService.getOne(new QueryWrapper<ReferralEntity>().eq("material_graphics_id", id).isNull("account_id"));
CustomerReferralDTO customerReferralDto = new CustomerReferralDTO();
if (ObjectUtil.isNull(referralEntity)) {
return new GenericsResult<>(false, "找不到链接数据");
}
BeanUtil.copyProperties(referralEntity, customerReferralDto);
customerMessageDetailVO.setCustomerReferralDto(customerReferralDto);
return new GenericsResult<>(customerMessageDetailVO);
} }
@Override @Override
public GenericsResult<List<CustomerMessageListVO>> pageList(CustomerMessageQueryDTO queryDto) { public GenericsResult<PageInfo<CustomerMessageListVO>> pageList(CustomerMessageQueryDTO queryDto) {
return null; PageHelper.startPage(queryDto.getCurrentPage(), queryDto.getPageSize());
List<CustomerMessageListVO> list = baseMapper.pageList(queryDto);
PageInfo<CustomerMessageListVO> pageList = new PageInfo<>(list);
return new GenericsResult<>(pageList);
} }
@Override @Override
@Transactional(rollbackFor = Exception.class)
public BaseResult removeCustomerMessage(Long id) { public BaseResult removeCustomerMessage(Long id) {
return null; boolean result = super.removeById(id);
boolean referralResult = referralEntityService.remove(new QueryWrapper<ReferralEntity>().eq("material_graphics_id", id));
if (result && referralResult) {
// 删除成功
return new BaseResult().success();
}
LOCAL_LOG.info("主体删除结果: {}, 链接删除结果: {}, 删除失败,回滚事务", result, referralResult);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return new BaseResult().error("删除异常");
} }
@Override
public BaseResult setPack(Long id, Long packId) {
CustomerGraphics byId = super.getById(id);
if (ObjectUtil.isNull(byId)) {
return new BaseResult().error("无法获取主体数据");
}
byId.setPackId(packId);
ReferralEntity referralEntity = referralEntityService.getOne(new QueryWrapper<ReferralEntity>().eq("material_graphics_id", id).isNull("account_id"));
LOCAL_LOG.info("获取书城条件主体");
CrowdPackageCondition storeCondition = conditionService.getOne(
new QueryWrapper<CrowdPackageCondition>().eq("condition_key", CrowdPackageCommonConstant.CONDITION_STORE_ID).eq("front_type", CrowdPackageCommonConstant.MULTIPLE_SELECT)
);
// TODO: 2022/10/8 校验人群包设置条件
LOCAL_LOG.info("获取人群包下的书城条件");
CrowdPackageConditionMatch storeConditionMatch = matchService.getOne(
new QueryWrapper<CrowdPackageConditionMatch>().eq("package_id", packId).eq("condition_id", storeCondition.getId())
);
Integer newsType = referralEntity.getNewsType();
if (CustomerCommonConstant.BOOK_NEWS_TYPE.equals(newsType)) {
// 是推广链接
BaseResult checkResult = this.checkExtendBook(referralEntity.getStoreType(), storeConditionMatch);
if (!checkResult.getSuccess()) {
return checkResult;
}
}
// TODO: 2022/10/8 根据人群包条件获取用户公众号,生成链接
byId.setPackId(packId);
boolean result = super.updateById(byId);
if (result) {
return new BaseResult().success();
}
return new BaseResult().error("更新失败");
}
private BaseResult checkExtendBook(String storeType, CrowdPackageConditionMatch storeConditionMatch) {
// 判断有没有选书城条件
if (ObjectUtil.isNull(storeConditionMatch)) {
// 没有的话不符合条件,返回
return new BaseResult().error("所选人群包未设置书城条件");
}
String operatorExpression = storeConditionMatch.getOperatorExpression();
// 判断选了几个书城,如果超过1个,则不符合条件
if (operatorExpression.contains(CrowdPackageCommonConstant.COMMA_SEPARATOR)) {
// 只要表达式包含了逗号,就说明选了不止一个书城条件
return new BaseResult().error("所选人群包设置的书城条件超过1个");
}
// 确定只选了一个书城,判断设置的书是不是这个书城里的
LOCAL_LOG.info("原始书城条件表达式: {}", operatorExpression);
operatorExpression = "where " + operatorExpression.replace(CrowdPackageCommonConstant.CONDITION_STORE_ID, "id");
LOCAL_LOG.info("新的书城条件表达式: {}", operatorExpression);
String storeTypeByExpression = kanbanCommonMapper.getStoreTypeByExpression(operatorExpression);
LOCAL_LOG.info("表达式获取到的书城: {}", storeTypeByExpression);
if (storeType.equals(storeTypeByExpression)) {
return new BaseResult().success();
}
return new BaseResult().error("所选书籍不属于人群包指定书城");
}
} }
package com.yaoyaozw.customer.service.impl; package com.yaoyaozw.customer.service.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import com.yaoyaozw.customer.common.GenericsResult;
import com.yaoyaozw.customer.mapper.KanbanCommonMapper; import com.yaoyaozw.customer.mapper.KanbanCommonMapper;
import com.yaoyaozw.customer.mapper.MaterialCommonMapper;
import com.yaoyaozw.customer.service.CustomerServiceCommonService; import com.yaoyaozw.customer.service.CustomerServiceCommonService;
import com.yaoyaozw.customer.vo.CommonOptionResponseVO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -18,6 +21,8 @@ public class CustomerServiceCommonServiceImpl implements CustomerServiceCommonSe ...@@ -18,6 +21,8 @@ public class CustomerServiceCommonServiceImpl implements CustomerServiceCommonSe
@Autowired @Autowired
private KanbanCommonMapper kanbanCommonMapper; private KanbanCommonMapper kanbanCommonMapper;
@Autowired
private MaterialCommonMapper materialCommonMapper;
@Override @Override
public List<Long> getSetupIdListFromStaticCondition(List<String> expressList) { public List<Long> getSetupIdListFromStaticCondition(List<String> expressList) {
...@@ -26,4 +31,10 @@ public class CustomerServiceCommonServiceImpl implements CustomerServiceCommonSe ...@@ -26,4 +31,10 @@ public class CustomerServiceCommonServiceImpl implements CustomerServiceCommonSe
} }
return kanbanCommonMapper.getSetupIdListFromStaticCondition(expressList); return kanbanCommonMapper.getSetupIdListFromStaticCondition(expressList);
} }
@Override
public GenericsResult<List<CommonOptionResponseVO>> getStoreList() {
List<CommonOptionResponseVO> storeList = materialCommonMapper.getStoreList();
return new GenericsResult<>(storeList);
}
} }
...@@ -58,4 +58,9 @@ public class RegisterUserEntityServiceImpl extends ServiceImpl<RegisterUserEntit ...@@ -58,4 +58,9 @@ public class RegisterUserEntityServiceImpl extends ServiceImpl<RegisterUserEntit
public List<Long> getAccountIdListFromPackage(Long packageId) { public List<Long> getAccountIdListFromPackage(Long packageId) {
return baseMapper.getAuthListFromPackage(packageId); return baseMapper.getAuthListFromPackage(packageId);
} }
@Override
public List<CrowdPackageUserVO> getCurrentInPackUserList(Long packageId) {
return baseMapper.getCurrentInPackUserList(packageId);
}
} }
package com.yaoyaozw.customer.vo;
import lombok.Data;
import java.io.Serializable;
/**
* @author darker
* @date 2022/10/9 19:42
*/
@Data
public class AuthInfoVO implements Serializable {
private Long id;
private String accountId;
private String accountName;
private String storeType;
private String storeTypeName;
}
...@@ -23,7 +23,7 @@ public class CrowdPackageConditionVO implements Serializable { ...@@ -23,7 +23,7 @@ public class CrowdPackageConditionVO implements Serializable {
private Long id; private Long id;
@ApiModelProperty("条件key") @ApiModelProperty("条件key")
private String ConditionKey; private String conditionKey;
@ApiModelProperty("条件名称") @ApiModelProperty("条件名称")
private String conditionName; private String conditionName;
...@@ -37,4 +37,7 @@ public class CrowdPackageConditionVO implements Serializable { ...@@ -37,4 +37,7 @@ public class CrowdPackageConditionVO implements Serializable {
@ApiModelProperty("是否静态属性 0 - 否;1 - 是") @ApiModelProperty("是否静态属性 0 - 否;1 - 是")
private Integer isStatic; private Integer isStatic;
@ApiModelProperty("条件服务 为空不调接口")
private String sourceBaseService;
} }
...@@ -17,10 +17,14 @@ public class CrowdPackageUserVO implements Serializable { ...@@ -17,10 +17,14 @@ public class CrowdPackageUserVO implements Serializable {
private String accountId; private String accountId;
private String appId;
private String openId; private String openId;
private Long setupId; private Long setupId;
private String inPackage; private String inPackage;
private String storeType;
} }
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 io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @author darker
* @date 2022/10/8 17:13
*/
@Data
public class CustomerMessageDetailVO implements Serializable {
@ApiModelProperty("客服消息id")
@JsonSerialize(using = ToStringSerializer.class)
private Long id;
@ApiModelProperty("标题")
private String name;
@ApiModelProperty("消息发送时间")
private String postTime;
@ApiModelProperty("是否支付 0-否 1-是")
private Integer isPay;
@ApiModelProperty("客服消息类型(图文、文本)")
private String type;
@ApiModelProperty("素材文本内容")
private String extendTitle;
@ApiModelProperty("素材图片路径")
private String coverUrl;
@ApiModelProperty("素材文本内容")
private String content;
@ApiModelProperty("链接相关内容")
private CustomerReferralDTO customerReferralDto;
}
package com.yaoyaozw.customer.vo.customer; 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.constants.CustomerCommonConstant;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
...@@ -14,10 +17,11 @@ public class CustomerMessageListVO implements Serializable { ...@@ -14,10 +17,11 @@ public class CustomerMessageListVO implements Serializable {
private static final long serialVersionUID = -8057791504394044052L; private static final long serialVersionUID = -8057791504394044052L;
@ApiModelProperty("客服消息id") @ApiModelProperty("客服消息id")
@JsonSerialize(using = ToStringSerializer.class)
private Long id; private Long id;
@ApiModelProperty("标题") @ApiModelProperty("标题")
private String title; private String name;
@ApiModelProperty("消息发送时间") @ApiModelProperty("消息发送时间")
private String postTime; private String postTime;
...@@ -28,9 +32,6 @@ public class CustomerMessageListVO implements Serializable { ...@@ -28,9 +32,6 @@ public class CustomerMessageListVO implements Serializable {
@ApiModelProperty("推广标题") @ApiModelProperty("推广标题")
private String extendTitle; private String extendTitle;
@ApiModelProperty("推广类型")
private String extendType;
@ApiModelProperty("人群包id") @ApiModelProperty("人群包id")
private Long packId; private Long packId;
...@@ -46,4 +47,7 @@ public class CustomerMessageListVO implements Serializable { ...@@ -46,4 +47,7 @@ public class CustomerMessageListVO implements Serializable {
@ApiModelProperty("发送状态描述") @ApiModelProperty("发送状态描述")
private String sendStatusStr; private String sendStatusStr;
public String getType() {
return CustomerCommonConstant.getCustomerType(this.type);
}
} }
...@@ -17,4 +17,32 @@ ...@@ -17,4 +17,32 @@
<!--@mbg.generated--> <!--@mbg.generated-->
id, pack_id, post_time, create_user, gmt_create, modified_user, gmt_modified, is_deleted id, pack_id, post_time, create_user, gmt_create, modified_user, gmt_modified, is_deleted
</sql> </sql>
<select id="pageList" resultType="com.yaoyaozw.customer.vo.customer.CustomerMessageListVO">
select
cg.id,
cg.name,
cg.type,
cg.post_time as postTime,
cg.extend_title as extendTitle,
cg.send_status as sendStatus,
dic.dic_value as sendStatusStr,
cpm.id as packId,
cpm.package_name as packName,
cpm.crowd_num as peopleNum
from customer_graphics cg
left join crowd_package_main cpm
on cpm.id = cg.pack_id
left join sys_dictionary dic
on dic.dic_key = cg.send_status
and dic.group_id = 'CUSTOMER_SEND_STATUS'
and dic.level = 3
where cg.is_deleted = 0
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -24,4 +24,13 @@ ...@@ -24,4 +24,13 @@
</foreach> </foreach>
</where> </where>
</select> </select>
<select id="getStoreTypeByExpression" resultType="java.lang.String">
select
store_type
from store_entity
${expression}
limit 1
</select>
</mapper> </mapper>
\ No newline at end of file
<?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.MaterialCommonMapper">
<select id="getStoreList" resultType="com.yaoyaozw.customer.vo.CommonOptionResponseVO">
select
`value` as `key`,
explanation as `name`
from account_dictionary
where type = 'StoreType'
</select>
<select id="getAuthInfoList" resultType="com.yaoyaozw.customer.vo.AuthInfoVO">
select
ai.id, ai.account_id as accountId,
ai.nick_name as accountName,
ai.store_type as storeType,
se.store_name as storeTypeName
from authorizer_info ai
left join store_entity se
on ai.store_type = se.store_type
where ai.account_id in
<foreach collection="accountSet" item="accountId" separator="," open="(" close=")">
#{accountId}
</foreach>
</select>
</mapper>
\ No newline at end of file
...@@ -27,7 +27,8 @@ ...@@ -27,7 +27,8 @@
ai.account_id as accountId, ai.account_id as accountId,
rue.setup_id as setupId, rue.setup_id as setupId,
rue.open_id as openId, rue.open_id as openId,
rue.in_package as inPackage rue.in_package as inPackage,
ai.store_type as storeType
from register_user_entity rue from register_user_entity rue
...@@ -64,4 +65,24 @@ ...@@ -64,4 +65,24 @@
on rue.app_id = ai.appid on rue.app_id = ai.appid
where find_in_set(#{packageId}, in_package) where find_in_set(#{packageId}, in_package)
</select> </select>
<select id="getCurrentInPackUserList" resultType="com.yaoyaozw.customer.vo.customer.CrowdPackageUserVO">
select
rue.id,
ai.account_id as accountId,
rue.setup_id as setupId,
rue.open_id as openId,
rue.in_package as inPackage,
ai.store_type as storeType,
rue.app_id as appId
from register_user_entity rue
left join authorizer_info ai
on rue.app_id = ai.appid
where find_in_set(#{packageId}, rue.in_package)
</select>
</mapper> </mapper>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论