bug修复

1 parent c4ef74d0
Showing 40 changed files with 916 additions and 277 deletions
......@@ -111,14 +111,17 @@ public class WeCustomerController extends BaseController
/**
* 修改企业微信客户
* 修改企业微信客户(目前只更新生日)
*/
// @PreAuthorize("@ss.hasPermi('wecom:customer:edit')")
@Log(title = "企业微信客户", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody WeCustomer weCustomer)
{
weCustomerService.saveOrUpdate(weCustomer);
weCustomerService.update(weCustomer,new LambdaQueryWrapper<WeCustomer>()
.eq(WeCustomer::getExternalUserid,weCustomer.getExternalUserid())
.eq(WeCustomer::getFirstUserId,weCustomer.getFirstUserId()));
return AjaxResult.success();
}
......
......@@ -5,8 +5,6 @@ import com.linkwechat.common.core.controller.BaseController;
import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.core.page.TableDataInfo;
import com.linkwechat.common.enums.BusinessType;
import com.linkwechat.wecom.domain.WeGroupMessageSendResult;
import com.linkwechat.wecom.domain.WeGroupMessageTask;
import com.linkwechat.wecom.domain.WeGroupMessageTemplate;
import com.linkwechat.wecom.domain.query.WeAddGroupMessageQuery;
import com.linkwechat.wecom.domain.vo.WeGroupMessageDetailVo;
......@@ -91,30 +89,4 @@ public class WeGroupMessageTemplateController extends BaseController {
iWeGroupMessageTemplateService.cancelByIds(Arrays.asList(ids));
return AjaxResult.success();
}
/**
* 群发成员发送任务列表
*/
//@PreAuthorize("@ss.hasPermi('linkwechat:template:remove')")
@ApiOperation(value = "群发成员发送任务列表", httpMethod = "GET")
@Log(title = "群发消息模板", businessType = BusinessType.SELECT)
@GetMapping("/task/list")
public TableDataInfo<WeGroupMessageTask> groupMsgTaskList(WeGroupMessageTask task) {
startPage();
List<WeGroupMessageTask> messageTaskList = iWeGroupMessageTemplateService.groupMsgTaskList(task);
return getDataTable(messageTaskList);
}
/**
* 群发成员发送任务列表
*/
//@PreAuthorize("@ss.hasPermi('linkwechat:template:remove')")
@ApiOperation(value = "群发成员发送任务列表", httpMethod = "GET")
@Log(title = "群发消息模板", businessType = BusinessType.SELECT)
@GetMapping("/send/result/list")
public TableDataInfo<WeGroupMessageSendResult> groupMsgSendResultList(WeGroupMessageSendResult sendResult) {
startPage();
List<WeGroupMessageSendResult> sendResultList = iWeGroupMessageTemplateService.groupMsgSendResultList(sendResult);
return getDataTable(sendResultList);
}
}
package com.linkwechat.web.controller.wecom;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.linkwechat.common.annotation.Log;
import com.linkwechat.common.core.controller.BaseController;
import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.core.page.TableDataInfo;
import com.linkwechat.common.enums.BusinessType;
import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.wecom.domain.WeMsgTlp;
import com.linkwechat.wecom.domain.WeMsgTlpScope;
import com.linkwechat.wecom.service.IWeMsgTlpScopeService;
import com.linkwechat.wecom.service.IWeMsgTlpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
/**
* 欢迎语模板Controller
*
......@@ -27,6 +30,8 @@ public class WeMsgTlpController extends BaseController
private IWeMsgTlpService weMsgTlpService;
@Autowired
private IWeMsgTlpScopeService iWeMsgTlpScopeService;
/**
* 查询欢迎语模板列表
......@@ -36,48 +41,54 @@ public class WeMsgTlpController extends BaseController
public TableDataInfo list(WeMsgTlp weMsgTlp)
{
startPage();
return getDataTable(weMsgTlpService.list(
new LambdaQueryWrapper<WeMsgTlp>()
.like(StringUtils.isNotEmpty(weMsgTlp.getWelcomeMsg()),WeMsgTlp::getWelcomeMsg,weMsgTlp.getWelcomeMsg())
.eq(weMsgTlp.getWelcomeMsgTplType() !=null,WeMsgTlp::getWelcomeMsgTplType,weMsgTlp.getWelcomeMsgTplType())
.like(StringUtils.isNotEmpty(weMsgTlp.getUserIds()),WeMsgTlp::getUserIds,weMsgTlp.getUserIds())
));
List<WeMsgTlp> list = weMsgTlpService.selectWeMsgTlpList(weMsgTlp);
return getDataTable(list);
}
/**
* 获取欢迎语模板详细信息
*/
// @PreAuthorize("@ss.hasPermi('wecom:tlp:query')")
@GetMapping(value = "/scop/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(
iWeMsgTlpScopeService.selectWeMsgTlpScopeList(WeMsgTlpScope.builder().msgTlpId(id).build())
);
}
/**
* 新增欢迎语模板
*/
// @PreAuthorize("@ss.hasPermi('wecom:tlp:add')")
@Log(title = "新增欢迎语模板", businessType = BusinessType.INSERT)
@PostMapping(value = "/addorUpdate")
public AjaxResult addorUpdate(@RequestBody WeMsgTlp weMsgTlp)
@PostMapping
public AjaxResult add(@RequestBody WeMsgTlp weMsgTlp)
{
weMsgTlpService.addorUpdate(weMsgTlp);
return AjaxResult.success();
return toAjax(weMsgTlpService.insertWeMsgTlp(weMsgTlp));
}
/**
* 修改欢迎语模板
*/
// @PreAuthorize("@ss.hasPermi('wecom:tlp:edit')")
@Log(title = "修改欢迎语模板", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult add(@RequestBody WeMsgTlp weMsgTlp){
weMsgTlpService.save(weMsgTlp);
return AjaxResult.success();
public AjaxResult edit(@RequestBody WeMsgTlp weMsgTlp)
{
return toAjax(weMsgTlpService.updateWeMsgTlp(weMsgTlp));
}
/**
* 删除欢迎语模板
*/
// @PreAuthorize("@ss.hasPermi('wecom:tlp:remove')")
@Log(title = "删除欢迎语模板", businessType = BusinessType.DELETE)
@DeleteMapping("/remove/{ids}")
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
weMsgTlpService.removeByIds(CollectionUtil.toList(ids));
return AjaxResult.success();
return toAjax(weMsgTlpService.batchRemoveByids(Arrays.asList(ids)));
}
}
......@@ -100,7 +100,8 @@ public class WeTagGroupController extends BaseController
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable String[] ids)
{
return toAjax(weTagGroupService.deleteWeTagGroupByIds(ids));
weTagGroupService.deleteWeTagGroupByIds(ids);
return AjaxResult.success();
}
......
linkwechat.nacos.host=
linkwechat.nacos.port=
linkwechat.nacos.namespace=
linkwechat.nacos.username=
linkwechat.nacos.password=
\ No newline at end of file
linkwechat.nacos.host=119.45.28.29
linkwechat.nacos.port=10848
linkwechat.nacos.namespace=01cf833f-249e-4483-a286-46d37f018fe7
linkwechat.nacos.username=prod
linkwechat.nacos.password=prod@admin123
\ No newline at end of file
......@@ -120,7 +120,7 @@ public class Finance {
System.loadLibrary("libcurl");
System.loadLibrary("WeWorkFinanceSdk");
} else {
System.load("/Users/robin/work/sr_project/sdk/libWeWorkFinanceSdk_Java.so");
System.load("/app/projects/libWeWorkFinanceSdk_Java.so");
}
}
......
......@@ -2,7 +2,6 @@ package com.linkwechat.framework.handler;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.linkwechat.wecom.domain.WeMsgTlp;
import com.linkwechat.wecom.domain.dto.message.CustomerMessagePushDto;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
......
package com.linkwechat.quartz.task;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* @description: 客户画像
* @author: HaoN
* @create: 2021-05-02 21:08
**/
@Slf4j
@Component("customerPortraitTask")
public class CustomerPortraitTask {
}
......@@ -4,6 +4,7 @@ import com.dtflys.forest.annotation.*;
import com.linkwechat.wecom.domain.dto.WeDepartMentDto;
import com.linkwechat.wecom.domain.dto.WeResultDto;
import com.linkwechat.wecom.interceptor.WeAccessTokenInterceptor;
import com.linkwechat.wecom.interceptor.WeCommonAccessTokenInterceptor;
import com.linkwechat.wecom.retry.WeCommonRetryWhen;
/**
......@@ -11,7 +12,7 @@ import com.linkwechat.wecom.retry.WeCommonRetryWhen;
* @author: HaoN
* @create: 2020-08-27 16:40
**/
@BaseRequest(baseURL = "${weComServerUrl}${weComePrefix}", interceptor = WeAccessTokenInterceptor.class)
@BaseRequest(baseURL = "${weComServerUrl}${weComePrefix}", interceptor = WeCommonAccessTokenInterceptor.class)
@Retry(maxRetryCount = "3", maxRetryInterval = "1000", condition = WeCommonRetryWhen.class)
public interface WeDepartMentClient {
......
......@@ -4,6 +4,7 @@ import com.dtflys.forest.annotation.*;
import com.linkwechat.wecom.domain.dto.*;
import com.linkwechat.wecom.interceptor.WeAccessTokenInterceptor;
import com.linkwechat.wecom.interceptor.WeAppAccessTokenInterceptor;
import com.linkwechat.wecom.interceptor.WeCommonAccessTokenInterceptor;
import com.linkwechat.wecom.retry.WeCommonRetryWhen;
/**
......@@ -11,7 +12,7 @@ import com.linkwechat.wecom.retry.WeCommonRetryWhen;
* @author: HaoN
* @create: 2020-08-27 16:42
**/
@BaseRequest(baseURL = "${weComServerUrl}${weComePrefix}", interceptor = WeAccessTokenInterceptor.class)
@BaseRequest(baseURL = "${weComServerUrl}${weComePrefix}", interceptor = WeCommonAccessTokenInterceptor.class)
@Retry(maxRetryCount = "3", maxRetryInterval = "1000", condition = WeCommonRetryWhen.class)
public interface WeUserClient {
......
......@@ -179,6 +179,19 @@ public class WeCustomer extends BaseEntity {
private Date firstAddTime;
//qq
private String qq;
//邮箱
private String email;
//地址
private String address;
//手机号
private String phone;
/**
* 0:正常;1:删除
*/
......
......@@ -55,4 +55,8 @@ public class WeCustomerPortrait {
//客户社交关系
private WeCustomerSocialConn socialConn;
private String tagNames;
private String tagIds;
}
package com.linkwechat.wecom.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.linkwechat.common.core.domain.BaseEntity;
import com.linkwechat.common.utils.SnowFlakeUtil;
import com.linkwechat.wecom.handler.GenericTypeHandler;
import io.swagger.models.auth.In;
import lombok.Data;
......@@ -19,75 +15,29 @@ import java.util.List;
* @date 2020-10-04
*/
@Data
@TableName(value = "we_msg_tlp",autoResultMap = true)
public class WeMsgTlp extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
@TableId
private Long id;
private Long id= SnowFlakeUtil.nextId();
/** 欢迎语 */
private String welcomeMsg;
/**图片url*/
private String picUrl;
/**图文*/
@TableField(typeHandler = GenericTypeHandler.class)
private List<ImageText> imageText;
/**小程序*/
@TableField(typeHandler = GenericTypeHandler.class)
private List<Applet> applet;
/** 素材的id */
private Long mediaId;
/** 0:正常;1:删除; */
private Integer delFlag;
/** 欢迎语模板类型:1:活码欢迎语;2:员工欢迎语;3:入群欢迎语 */
private Integer welcomeMsgTplType;
/**用户名 */
private String userNames;
/**用户id,用逗号隔开*/
private String userIds;
@Data
public static class Applet{
//小程序标题
private String appTile;
//小程序id
private String appId;
//小程序路径
private String appPath;
//小程序图片
private String appPic;
}
@Data
public static class ImageText{
private Integer delFlag=new Integer(0);
//图文标题
private String imageTextTile;
/** 欢迎语模板类型:1:员工欢迎语;2:部门员工欢迎语;3:客户群欢迎语 */
private Long welcomeMsgTplType;
//图文url
private String imageTextUrl;
/** 欢迎语模板使用范围 */
private List<WeMsgTlpScope> weMsgTlpScopes;
}
private String materialUrl;
......
package com.linkwechat.wecom.domain;
import com.linkwechat.common.annotation.Excel;
import com.linkwechat.common.core.domain.BaseEntity;
import com.linkwechat.common.utils.SnowFlakeUtil;
import lombok.Builder;
import lombok.Data;
import lombok.experimental.SuperBuilder;
/**
* 模板使用人员范围对象 we_msg_tlp_scope
*
* @author ruoyi
* @date 2020-10-04
*/
@Data
@SuperBuilder
public class WeMsgTlpScope extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Long id= SnowFlakeUtil.nextId();
/** 模板id */
@Excel(name = "模板id")
private Long msgTlpId;
/** 使用人id */
@Excel(name = "使用人id")
private Long useUserId;
/** 0:正常;1:删除; */
private Integer delFlag=new Integer(0);
}
......@@ -40,6 +40,10 @@ public class WeTagGroup extends BaseEntity
@TableField(exist = false)
private List<WeTag> weTags;
/**新增标签 */
@TableField(exist = false)
private List<WeTag> addWeTags;
/** 分组id */
@TableId
......
......@@ -41,7 +41,7 @@ public class WeCropGroupTagDto {
.group_id(weTagGroup.getGroupId())
.group_name(weTagGroup.getGourpName())
.build();
List<WeTag> newAddWeTag = weTagGroup.getWeTags();
List<WeTag> newAddWeTag = weTagGroup.getAddWeTags();
if(CollectionUtil.isNotEmpty(newAddWeTag)){
//新增的标签
// List<WeTag> newAddWeTag
......
......@@ -41,6 +41,7 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy {
@Autowired
private IWeFlowerCustomerTagRelService weFlowerCustomerTagRelService;
@Autowired
private IWeMaterialService weMaterialService;
@Autowired
......@@ -154,7 +155,8 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy {
);
});
if(weFlowerCustomerTagRelService.saveOrUpdateBatch(weFlowerCustomerTagRels)){
weFlowerCustomerTagRelService.batchAddOrUpdate(weFlowerCustomerTagRels);
//标签同步到企业微信端
weCustomerClient.makeCustomerLabel(CutomerTagEdit.builder()
.external_userid(externalUserId)
......@@ -162,7 +164,7 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy {
.add_tag(weFlowerCustomerTagRels.stream()
.map(WeFlowerCustomerTagRel::getTagId).toArray(String[]::new))
.build());
}
}
......
......@@ -41,6 +41,7 @@ public class WeCallBackAddHalfExternalContactImpl extends WeEventStrategy {
@Autowired
private IWeFlowerCustomerTagRelService weFlowerCustomerTagRelService;
@Autowired
private IWeMaterialService weMaterialService;
......@@ -73,7 +74,7 @@ public class WeCallBackAddHalfExternalContactImpl extends WeEventStrategy {
);
});
weFlowerCustomerTagRelService.saveOrUpdateBatch(weFlowerCustomerTagRels);
weFlowerCustomerTagRelService.batchAddOrUpdate(weFlowerCustomerTagRels);
}
......
......@@ -52,7 +52,10 @@ public class WeCallBackDelExternalContactImpl extends WeEventStrategy {
WeUser user = weUserService.getById(message.getUserId());
weSensitiveActHit.setOperator(user.getName());
WeCustomer weCustomer = weCustomerService.selectWeCustomerById(message.getExternalUserId());
WeCustomer weCustomer = weCustomerService.getOne(new LambdaQueryWrapper<WeCustomer>()
.eq(WeCustomer::getExternalUserid,message.getExternalUserId())
.eq(WeCustomer::getFirstUserId,message.getUserId()));
weSensitiveActHit.setOperateTargetId(weCustomer.getUserId());
weSensitiveActHit.setOperateTarget(weCustomer.getName());
weSensitiveActHitService.insertWeSensitiveActHit(weSensitiveActHit);
......
......@@ -51,7 +51,9 @@ public class WeCallBackDelFollowUserImpl extends WeEventStrategy {
Optional.ofNullable(validWeCorpAccount).ifPresent(weCorpAccount -> {
String customerChurnNoticeSwitch = weCorpAccount.getCustomerChurnNoticeSwitch();
if (WeConstans.DEL_FOLLOW_USER_SWITCH_OPEN.equals(customerChurnNoticeSwitch)) {
WeCustomer weCustomer = weCustomerService.selectWeCustomerById(message.getExternalUserId());
WeCustomer weCustomer = weCustomerService.getOne(new LambdaQueryWrapper<WeCustomer>().eq(WeCustomer::getFirstUserId,message.getUserId())
.eq(WeCustomer::getExternalUserid,message.getExternalUserId()));
String content = "您已经被客户@" + weCustomer.getName() + "删除!";
TextMessageDto textMessageDto = new TextMessageDto();
textMessageDto.setContent(content);
......
......@@ -3,7 +3,6 @@ package com.linkwechat.wecom.handler;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.linkwechat.wecom.domain.WeMoments;
import com.linkwechat.wecom.domain.WeMsgTlp;
import com.linkwechat.wecom.domain.dto.message.CustomerMessagePushDto;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
......@@ -20,7 +19,7 @@ import java.sql.SQLException;
* @param <T>
*/
@SuppressWarnings("all")
@MappedTypes(value = {JSONObject.class, CustomerMessagePushDto.class, WeMsgTlp.Applet.class,WeMsgTlp.ImageText.class,
@MappedTypes(value = {JSONObject.class, CustomerMessagePushDto.class,
WeMoments.OtherContent.class})
@MappedJdbcTypes(value = {JdbcType.VARCHAR}, includeNullJdbcType = true)
public class GenericTypeHandler<T extends Object> extends BaseTypeHandler<T> {
......
......@@ -17,7 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @description: 微信token拦截器
* @description: 微信token拦截器(外部联系人)
* @author: HaoN
* @create: 2020-08-27 22:36
**/
......
package com.linkwechat.wecom.interceptor;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject;
import com.dtflys.forest.exceptions.ForestRuntimeException;
import com.dtflys.forest.http.ForestRequest;
import com.dtflys.forest.http.ForestResponse;
import com.dtflys.forest.interceptor.Interceptor;
import com.linkwechat.common.config.WeComeConfig;
import com.linkwechat.common.enums.WeErrorCodeEnum;
import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.wecom.domain.dto.WeResultDto;
import com.linkwechat.wecom.service.IWeAccessTokenService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @description: 微信token拦截器(外部联系人)
* @author: HaoN
* @create: 2020-08-27 22:36
**/
@Slf4j
@Component
public class WeCommonAccessTokenInterceptor implements Interceptor<WeResultDto> {
@Autowired
private IWeAccessTokenService iWeAccessTokenService;
@Autowired
private WeComeConfig weComeConfig;
/**
* 该方法在请求发送之前被调用, 若返回false则不会继续发送请求
*/
@Override
public boolean beforeExecute(ForestRequest request) {
String token = iWeAccessTokenService.findCommonAccessToken();
request.replaceOrAddQuery("access_token", token);
return true;
}
/**
* 请求发送失败时被调用
*
* @param e
* @param forestRequest
* @param forestResponse
*/
@Override
public void onError(ForestRuntimeException e, ForestRequest forestRequest, ForestResponse forestResponse) {
log.info("url:{},------params:{},----------result:" + forestRequest.getUrl(), JSONObject.toJSONString(forestRequest.getArguments()), forestResponse.getContent());
if (StringUtils.isNotEmpty(forestResponse.getContent())) {
throw new ForestRuntimeException(forestResponse.getContent());
} else {
throw new ForestRuntimeException("网络请求超时");
}
}
/**
* 请求成功调用(微信端错误异常统一处理)
*
* @param resultDto
* @param forestRequest
* @param forestResponse
*/
@Override
public void onSuccess(WeResultDto resultDto, ForestRequest forestRequest, ForestResponse forestResponse) {
log.info("url:{},result:{}", forestRequest.getUrl(), forestResponse.getContent());
if (null != resultDto.getErrcode() && !ObjectUtil.equal(WeErrorCodeEnum.ERROR_CODE_0.getErrorCode(), resultDto.getErrcode())
&& !weComeConfig.getWeNeedRetryErrorCodes().contains(resultDto.getErrcode())) {
throw new ForestRuntimeException(WeErrorCodeEnum.parseEnum(resultDto.getErrcode()).getErrorMsg());
}
}
/**
* 请求重试
* @param request 请求
* @param response 返回值
*/
@Override
public void onRetry(ForestRequest request, ForestResponse response) {
log.info("url:{}, query:{},params:{}, 重试原因:{}, 当前重试次数:{}",request.getUrl(),request.getQueryString(), JSONObject.toJSONString(request.getArguments()),response.getContent(), request.getCurrentRetryCount());
WeResultDto weResultDto = JSONUtil.toBean(response.getContent(), WeResultDto.class);
//当错误码符合重置token时,刷新token
if(!ObjectUtil.equal(WeErrorCodeEnum.ERROR_CODE_OWE_1.getErrorCode(),weResultDto.getErrcode())
&& weComeConfig.getWeNeedRetryErrorCodes().contains(weResultDto.getErrcode())){
//删除缓存
iWeAccessTokenService.removeCommonAccessToken();
//重新查询token
String token = iWeAccessTokenService.findCommonAccessToken();
request.replaceOrAddQuery("access_token", token);
}
}
}
package com.linkwechat.wecom.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linkwechat.wecom.domain.WeMsgTlp;
import org.apache.ibatis.annotations.Param;
......@@ -12,7 +10,7 @@ import org.apache.ibatis.annotations.Param;
* @author ruoyi
* @date 2020-10-04
*/
public interface WeMsgTlpMapper extends BaseMapper<WeMsgTlp>
public interface WeMsgTlpMapper
{
/**
* 查询欢迎语模板
......@@ -22,13 +20,13 @@ public interface WeMsgTlpMapper extends BaseMapper<WeMsgTlp>
*/
public WeMsgTlp selectWeMsgTlpById(Long id);
// /**
// * 查询欢迎语模板列表
// *
// * @param weMsgTlp 欢迎语模板
// * @return 欢迎语模板集合
// */
// public List<WeMsgTlp> selectWeMsgTlpList(WeMsgTlp weMsgTlp);
/**
* 查询欢迎语模板列表
*
* @param weMsgTlp 欢迎语模板
* @return 欢迎语模板集合
*/
public List<WeMsgTlp> selectWeMsgTlpList(WeMsgTlp weMsgTlp);
/**
* 新增欢迎语模板
......
package com.linkwechat.wecom.mapper;
import java.util.List;
import com.linkwechat.wecom.domain.WeMsgTlpScope;
import org.apache.ibatis.annotations.Param;
/**
* 模板使用人员范围Mapper接口
*
* @author ruoyi
* @date 2020-10-04
*/
public interface WeMsgTlpScopeMapper
{
/**
* 查询模板使用人员范围
*
* @param id 模板使用人员范围ID
* @return 模板使用人员范围
*/
public WeMsgTlpScope selectWeMsgTlpScopeById(Long id);
/**
* 查询模板使用人员范围列表
*
* @param weMsgTlpScope 模板使用人员范围
* @return 模板使用人员范围集合
*/
public List<WeMsgTlpScope> selectWeMsgTlpScopeList(WeMsgTlpScope weMsgTlpScope);
/**
* 新增模板使用人员范围
*
* @param weMsgTlpScope 模板使用人员范围
* @return 结果
*/
public int insertWeMsgTlpScope(WeMsgTlpScope weMsgTlpScope);
/**
* 修改模板使用人员范围
*
* @param weMsgTlpScope 模板使用人员范围
* @return 结果
*/
public int updateWeMsgTlpScope(WeMsgTlpScope weMsgTlpScope);
/**
* 删除模板使用人员范围
*
* @param id 模板使用人员范围ID
* @return 结果
*/
public int deleteWeMsgTlpScopeById(Long id);
/**
* 批量删除模板使用人员范围
*
* @param ids 需要删除的数据ID
* @return 结果
*/
public int deleteWeMsgTlpScopeByIds(Long[] ids);
/**
* 批量保存模板使用人员范围
* @param weMsgTlpScopes
* @return
*/
public int batchInsetWeMsgTlpScope(@Param("weMsgTlpScopes") List<WeMsgTlpScope> weMsgTlpScopes);
/**
* 模板id,批量删除
* @param msgTlpIds
* @return
*/
public int batchRemoveWeMsgTlpScopesByMsgTlpIds(List<Long> msgTlpIds);
}
......@@ -66,10 +66,11 @@ public interface WeTagGroupMapper extends BaseMapper<WeTagGroup>
/**
* 根据企业员工与添加客户关系id给客户打标签
* @param flowerCustomerRelId
* @param externalUserid
* @param userid
* @return
*/
public List<WeTagGroup> findCustomerTagByFlowerCustomerRelId(@Param("flowerCustomerRelId") String flowerCustomerRelId);
public List<WeTagGroup> findCustomerTagByFlowerCustomerRelId(@Param("externalUserid") String externalUserid, @Param("userid") String userid);
......
......@@ -30,7 +30,7 @@ public interface IWeAccessTokenService {
public void removeToken(WeCorpAccount wxCorpAccount);
public void removeCommonAccessToken();
public void removeContactAccessToken();
public void removeChatAccessToken();
......
package com.linkwechat.wecom.service;
import java.util.List;
import com.linkwechat.wecom.domain.WeMsgTlpScope;
/**
* 模板使用人员范围Service接口
*
* @author ruoyi
* @date 2020-10-04
*/
public interface IWeMsgTlpScopeService
{
/**
* 查询模板使用人员范围
*
* @param id 模板使用人员范围ID
* @return 模板使用人员范围
*/
public WeMsgTlpScope selectWeMsgTlpScopeById(Long id);
/**
* 查询模板使用人员范围列表
*
* @param weMsgTlpScope 模板使用人员范围
* @return 模板使用人员范围集合
*/
public List<WeMsgTlpScope> selectWeMsgTlpScopeList(WeMsgTlpScope weMsgTlpScope);
/**
* 新增模板使用人员范围
*
* @param weMsgTlpScope 模板使用人员范围
* @return 结果
*/
public int insertWeMsgTlpScope(WeMsgTlpScope weMsgTlpScope);
/**
* 修改模板使用人员范围
*
* @param weMsgTlpScope 模板使用人员范围
* @return 结果
*/
public int updateWeMsgTlpScope(WeMsgTlpScope weMsgTlpScope);
/**
* 批量删除模板使用人员范围
*
* @param ids 需要删除的模板使用人员范围ID
* @return 结果
*/
public int deleteWeMsgTlpScopeByIds(Long[] ids);
/**
* 删除模板使用人员范围信息
*
* @param id 模板使用人员范围ID
* @return 结果
*/
public int deleteWeMsgTlpScopeById(Long id);
/**
* 批量保存模板使用人员范围
* @param weMsgTlpScopes
* @return
*/
public int batchInsetWeMsgTlpScope(List<WeMsgTlpScope> weMsgTlpScopes);
/**
* 通过使用者id批量删除
* @param useUserIds
* @return
*/
public int batchRemoveWeMsgTlpScopesByMsgTlpIds(List<Long> useUserIds);
}
package com.linkwechat.wecom.service;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
import com.linkwechat.wecom.domain.WeMsgTlp;
/**
......@@ -9,9 +9,23 @@ import com.linkwechat.wecom.domain.WeMsgTlp;
* @author ruoyi
* @date 2020-10-04
*/
public interface IWeMsgTlpService extends IService<WeMsgTlp>
public interface IWeMsgTlpService
{
/**
* 查询欢迎语模板
*
* @param id 欢迎语模板ID
* @return 欢迎语模板
*/
public WeMsgTlp selectWeMsgTlpById(Long id);
/**
* 查询欢迎语模板列表
*
* @param weMsgTlp 欢迎语模板
* @return 欢迎语模板集合
*/
public List<WeMsgTlp> selectWeMsgTlpList(WeMsgTlp weMsgTlp);
/**
* 新增欢迎语模板
......@@ -19,7 +33,37 @@ public interface IWeMsgTlpService extends IService<WeMsgTlp>
* @param weMsgTlp 欢迎语模板
* @return 结果
*/
void addorUpdate(WeMsgTlp weMsgTlp);
public int insertWeMsgTlp(WeMsgTlp weMsgTlp);
/**
* 修改欢迎语模板
*
* @param weMsgTlp 欢迎语模板
* @return 结果
*/
public int updateWeMsgTlp(WeMsgTlp weMsgTlp);
/**
* 批量删除欢迎语模板
*
* @param ids 需要删除的欢迎语模板ID
* @return 结果
*/
public int deleteWeMsgTlpByIds(Long[] ids);
/**
* 删除欢迎语模板信息
*
* @param id 欢迎语模板ID
* @return 结果
*/
public int deleteWeMsgTlpById(Long id);
/**
* 批量逻辑删除
* @param msgTlpIds
* @return
*/
public int batchRemoveByids(List<Long> msgTlpIds);
}
......@@ -46,7 +46,7 @@ public interface IWeTagGroupService extends IService<WeTagGroup>
* @param ids 需要删除的标签组ID
* @return 结果
*/
public int deleteWeTagGroupByIds(String[] ids);
public void deleteWeTagGroupByIds(String[] ids);
......@@ -77,5 +77,5 @@ public interface IWeTagGroupService extends IService<WeTagGroup>
* @param flowerCustomerRelId
* @return
*/
public List<WeTagGroup> findCustomerTagByFlowerCustomerRelId(String flowerCustomerRelId);
public List<WeTagGroup> findCustomerTagByFlowerCustomerRelId(String externalUserid, String userid);
}
......@@ -272,6 +272,12 @@ public class WeAccessTokenServiceImpl implements IWeAccessTokenService {
}
@Override
public void removeCommonAccessToken() {
redisCache.deleteObject(WeConstans.WE_COMMON_ACCESS_TOKEN);
}
@Override
public void removeContactAccessToken() {
redisCache.deleteObject(WeConstans.WE_CONTACT_ACCESS_TOKEN);
}
......
......@@ -25,10 +25,7 @@ import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
/**
......@@ -102,7 +99,8 @@ public class WeCustomerMessageServiceImpl extends ServiceImpl<WeCustomerMessageM
//发给客户
if(CollectionUtils.isNotEmpty(customers)){
customers.stream().collect(Collectors.groupingBy(WeCustomer::getUserId)).forEach((k,v)->{
customers.stream().collect(Collectors.groupingBy(WeCustomer::getFirstUserId)).forEach((k,v)->{
customerMessagePushDto.setStaffId(k);
//发送群发消息
......
......@@ -56,11 +56,6 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
@Autowired
private WeCropTagClient weCropTagClient;
@Autowired
private IWeTagService iWeTagService;
@Autowired
......@@ -242,10 +237,17 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
List<WeCustomer> allocateWeCustomers = this.list(new LambdaQueryWrapper<WeCustomer>()
.eq(WeCustomer::getFirstUserId, weLeaveUserInfoAllocateVo.getHandoverUserid()));
if(CollectionUtil.isNotEmpty(allocateWeCustomers)){
if(this.update(WeCustomer.builder()
.firstUserId(weLeaveUserInfoAllocateVo.getTakeoverUserid())
.build(),new LambdaQueryWrapper<WeCustomer>()
.eq(WeCustomer::getFirstUserId,weLeaveUserInfoAllocateVo.getHandoverUserid()))){//接手客户
//删除原有的
this.baseMapper.deleteWeCustomerByUserIds(
new String[]{weLeaveUserInfoAllocateVo.getHandoverUserid()}
);
allocateWeCustomers.stream().forEach(k->{
k.setFirstUserId(weLeaveUserInfoAllocateVo.getTakeoverUserid());
});
//新增
this.baseMapper.batchAddOrUpdate(
allocateWeCustomers
);
//记录接受离职表
List<WeAllocateCustomer> weAllocateCustomers = new ArrayList<>();
allocateWeCustomers.stream().forEach(k->{
......@@ -271,14 +273,9 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
.build());
}
}
}
}
......@@ -331,13 +328,12 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
);
});
if(iWeFlowerCustomerTagRelService.saveBatch(newTagRels)){
iWeFlowerCustomerTagRelService.batchAddOrUpdate(newTagRels);
weCustomerClient.makeCustomerLabel(
cutomerTagEdit
);
}
}else{//为空,取消当前客户所有标签
List<WeFlowerCustomerTagRel> weFlowerCustomerTagRels = iWeFlowerCustomerTagRelService.list(new LambdaQueryWrapper<WeFlowerCustomerTagRel>()
.eq(WeFlowerCustomerTagRel::getExternalUserid, weMakeCustomerTag.getExternalUserid())
......@@ -603,7 +599,7 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
//获取当前客户拥有得标签
weCustomerPortrait.setWeTagGroupList(
iWeTagGroupService.findCustomerTagByFlowerCustomerRelId(
weCustomerPortrait.getFlowerCustomerRelId()
externalUserid,userid
)
);
......@@ -625,12 +621,22 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
WeCustomer weCustomer
= WeCustomer.builder().build();
BeanUtils.copyBeanProp(weCustomer,weCustomerPortrait);
//手机号
weCustomer.setPhone(weCustomerPortrait.getRemarkMobiles());
weCustomer.setCorpName(weCustomerPortrait.getRemarkCorpName());
weCustomer.setFirstUserId(weCustomerPortrait.getUserId());
this.update(weCustomer,new LambdaQueryWrapper<WeCustomer>()
.eq(WeCustomer::getFirstUserId,weCustomerPortrait.getUserId())
.eq(WeCustomer::getExternalUserid,weCustomerPortrait.getExternalUserid()));
//更新用户基本信息表
this.updateById(
weCustomer
);
WeFlowerCustomerRel weFlowerCustomerRel = WeFlowerCustomerRel.builder().build();
BeanUtils.copyBeanProp(weFlowerCustomerRel,weCustomerPortrait);
// this.baseMapper.batchAddOrUpdate(ListUtil.toList(weCustomer));
// this.updateById(
// weCustomer
// );
// WeFlowerCustomerRel weFlowerCustomerRel = WeFlowerCustomerRel.builder().build();
// BeanUtils.copyBeanProp(weFlowerCustomerRel,weCustomerPortrait);
//添加轨迹内容(信息动态)
iWeCustomerTrajectoryService.inforMationNews(weCustomerPortrait.getUserId(),weCustomerPortrait.getExternalUserid(), TrajectorySceneType.TRAJECTORY_TYPE_XXDT_BCZL.getKey());
}
......
package com.linkwechat.wecom.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.linkwechat.wecom.mapper.WeMsgTlpScopeMapper;
import com.linkwechat.wecom.domain.WeMsgTlpScope;
import com.linkwechat.wecom.service.IWeMsgTlpScopeService;
/**
* 模板使用人员范围Service业务层处理
*
* @author ruoyi
* @date 2020-10-04
*/
@Service
public class WeMsgTlpScopeServiceImpl implements IWeMsgTlpScopeService
{
@Autowired
private WeMsgTlpScopeMapper weMsgTlpScopeMapper;
/**
* 查询模板使用人员范围
*
* @param id 模板使用人员范围ID
* @return 模板使用人员范围
*/
@Override
public WeMsgTlpScope selectWeMsgTlpScopeById(Long id)
{
return weMsgTlpScopeMapper.selectWeMsgTlpScopeById(id);
}
/**
* 查询模板使用人员范围列表
*
* @param weMsgTlpScope 模板使用人员范围
* @return 模板使用人员范围
*/
@Override
public List<WeMsgTlpScope> selectWeMsgTlpScopeList(WeMsgTlpScope weMsgTlpScope)
{
return weMsgTlpScopeMapper.selectWeMsgTlpScopeList(weMsgTlpScope);
}
/**
* 新增模板使用人员范围
*
* @param weMsgTlpScope 模板使用人员范围
* @return 结果
*/
@Override
public int insertWeMsgTlpScope(WeMsgTlpScope weMsgTlpScope)
{
return weMsgTlpScopeMapper.insertWeMsgTlpScope(weMsgTlpScope);
}
/**
* 修改模板使用人员范围
*
* @param weMsgTlpScope 模板使用人员范围
* @return 结果
*/
@Override
public int updateWeMsgTlpScope(WeMsgTlpScope weMsgTlpScope)
{
return weMsgTlpScopeMapper.updateWeMsgTlpScope(weMsgTlpScope);
}
/**
* 批量删除模板使用人员范围
*
* @param ids 需要删除的模板使用人员范围ID
* @return 结果
*/
@Override
public int deleteWeMsgTlpScopeByIds(Long[] ids)
{
return weMsgTlpScopeMapper.deleteWeMsgTlpScopeByIds(ids);
}
/**
* 删除模板使用人员范围信息
*
* @param id 模板使用人员范围ID
* @return 结果
*/
@Override
public int deleteWeMsgTlpScopeById(Long id)
{
return weMsgTlpScopeMapper.deleteWeMsgTlpScopeById(id);
}
/**
* 批量保存模板使用人员范围
* @param weMsgTlpScopes
* @return
*/
@Override
public int batchInsetWeMsgTlpScope(List<WeMsgTlpScope> weMsgTlpScopes) {
return weMsgTlpScopeMapper.batchInsetWeMsgTlpScope(weMsgTlpScopes);
}
/**
* 通过使用者id,批量删除
* @param useUserIds
* @return
*/
@Override
public int batchRemoveWeMsgTlpScopesByMsgTlpIds(List<Long> useUserIds) {
return weMsgTlpScopeMapper.batchRemoveWeMsgTlpScopesByMsgTlpIds(useUserIds);
}
}
package com.linkwechat.wecom.service.impl;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.collection.ListUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.wecom.domain.WeUser;
import com.linkwechat.wecom.service.IWeUserService;
import com.linkwechat.common.utils.SecurityUtils;
import com.linkwechat.common.utils.SnowFlakeUtil;
import com.linkwechat.wecom.domain.WeMsgTlpScope;
import com.linkwechat.wecom.service.IWeMsgTlpScopeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.linkwechat.wecom.mapper.WeMsgTlpMapper;
......@@ -23,12 +24,37 @@ import org.springframework.transaction.annotation.Transactional;
* @date 2020-10-04
*/
@Service
public class WeMsgTlpServiceImpl extends ServiceImpl<WeMsgTlpMapper,WeMsgTlp> implements IWeMsgTlpService
public class WeMsgTlpServiceImpl implements IWeMsgTlpService
{
@Autowired
private WeMsgTlpMapper weMsgTlpMapper;
@Autowired
private IWeUserService iWeUserService;
private IWeMsgTlpScopeService iWeMsgTlpScopeService;
/**
* 查询欢迎语模板
*
* @param id 欢迎语模板ID
* @return 欢迎语模板
*/
@Override
public WeMsgTlp selectWeMsgTlpById(Long id)
{
return weMsgTlpMapper.selectWeMsgTlpById(id);
}
/**
* 查询欢迎语模板列表
*
* @param weMsgTlp 欢迎语模板
* @return 欢迎语模板
*/
@Override
public List<WeMsgTlp> selectWeMsgTlpList(WeMsgTlp weMsgTlp)
{
return weMsgTlpMapper.selectWeMsgTlpList(weMsgTlp);
}
/**
* 新增欢迎语模板
......@@ -37,34 +63,91 @@ public class WeMsgTlpServiceImpl extends ServiceImpl<WeMsgTlpMapper,WeMsgTlp> im
* @return 结果
*/
@Override
@Transactional
public void addorUpdate(WeMsgTlp weMsgTlp)
public int insertWeMsgTlp(WeMsgTlp weMsgTlp)
{
weMsgTlp.setCreateBy(SecurityUtils.getUsername());
weMsgTlp.setCreateTime(new Date());
return weMsgTlpMapper.insertWeMsgTlp(weMsgTlp);
// if(returnCode>0){
// List<WeMsgTlpScope> weMsgTlpScopess = weMsgTlp.getWeMsgTlpScopes();
// if(CollectionUtil.isNotEmpty(weMsgTlpScopess)){
//
// List<WeMsgTlpScope> weMsgTlpScopes=weMsgTlp.getWeMsgTlpScopes().stream().filter(c -> c.getUseUserId() != null).collect(Collectors.toList());
// if(CollectionUtil.isNotEmpty(weMsgTlpScopes)){
//
// weMsgTlpScopes.forEach(v->{
// v.setMsgTlpId(weMsgTlp.getId());
// v.setId(SnowFlakeUtil.nextId());
// });
//
// iWeMsgTlpScopeService.batchInsetWeMsgTlpScope(weMsgTlpScopes);
// }
//
// }
// }
// return returnCode;
}
/**
* 修改欢迎语模板
*
* @param weMsgTlp 欢迎语模板
* @return 结果
*/
@Override
public int updateWeMsgTlp(WeMsgTlp weMsgTlp)
{
if(weMsgTlp.getWelcomeMsgTplType()
.equals(new Integer(2))) {
String userIds = weMsgTlp.getUserIds();
if (StringUtils.isNotEmpty(userIds)) {
List<WeUser> weUsers = iWeUserService.listByIds(
ListUtil.toList(userIds.split(","))
);
if (CollectionUtil.isNotEmpty(weUsers)) {
weMsgTlp.setUserNames(String.join(",",
weUsers.stream().map(WeUser::getName).collect(Collectors.toList())));
}
}
}
this.saveOrUpdate(weMsgTlp);
// int returnCode = weMsgTlpMapper.updateWeMsgTlp(weMsgTlp);
//
// if(returnCode>0){
// iWeMsgTlpScopeService.batchRemoveWeMsgTlpScopesByMsgTlpIds(ListUtil.toList(weMsgTlp.getId()));
// List<WeMsgTlpScope> weMsgTlpScopes = weMsgTlp.getWeMsgTlpScopes().stream().filter(c -> c.getUseUserId() != null).collect(Collectors.toList());
//
// if(CollectionUtil.isNotEmpty(weMsgTlpScopes)){
// weMsgTlpScopes.stream().forEach(v->v.setMsgTlpId(weMsgTlp.getId()));
// iWeMsgTlpScopeService.batchInsetWeMsgTlpScope(weMsgTlpScopes);
// }
//
// }
return weMsgTlpMapper.updateWeMsgTlp(weMsgTlp);
}
/**
* 批量删除欢迎语模板
*
* @param ids 需要删除的欢迎语模板ID
* @return 结果
*/
@Override
public int deleteWeMsgTlpByIds(Long[] ids)
{
return weMsgTlpMapper.deleteWeMsgTlpByIds(ids);
}
/**
* 删除欢迎语模板信息
*
* @param id 欢迎语模板ID
* @return 结果
*/
@Override
public int deleteWeMsgTlpById(Long id)
{
return weMsgTlpMapper.deleteWeMsgTlpById(id);
}
/**
* 批量逻辑删除
* @param msgTlpIds
* @return
*/
@Override
public int batchRemoveByids(List<Long> msgTlpIds) {
return weMsgTlpMapper.batchRemoveByids(msgTlpIds);
}
}
......@@ -101,47 +101,103 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper, WeTagGr
public void updateWeTagGroup(WeTagGroup weTagGroup) {
List<WeTag> weTags = weTagGroup.getWeTags();
//获取新增的集合
if (CollectionUtil.isNotEmpty(weTags)) {
List<WeTag> filterWeTags = weTags.stream().filter(v -> StringUtils.isEmpty(v.getTagId())).collect(Collectors.toList());
//同步新增标签到微信端
if (CollectionUtil.isNotEmpty(WeCropGroupTagDto.transformAddTag(weTagGroup).getTag())) {
WeCropGropTagDtlDto
List<WeTag> removeWeTags =new ArrayList<>();
if(CollectionUtil.isNotEmpty(weTags)){
//新增的标签
List<WeTag> addWeTags = weTags.stream().filter(v -> StringUtils.isEmpty(v.getTagId())).collect(Collectors.toList());
if(CollectionUtil.isNotEmpty(addWeTags)){
weTagGroup.setAddWeTags(addWeTags);
WeCropGropTagDtlDto
weCropGropTagDtlDto = weCropTagClient.addCorpTag(WeCropGroupTagDto.transformAddTag(weTagGroup));
if (weCropGropTagDtlDto.getErrcode().equals(WeConstans.WE_SUCCESS_CODE)) {
//微信端返回的标签主键,设置到weTags中
Map<String, String> weCropTagMap = weCropGropTagDtlDto.getTag_group().getTag().stream()
.collect(Collectors.toMap(weCropTagDto -> weCropTagDto.getName(), weCropTagDto -> weCropTagDto.getId()));
filterWeTags.stream().forEach(tag -> {
addWeTags.stream().forEach(tag -> {
tag.setTagId(weCropTagMap.get(tag.getName()));
});
}
}
addWeTags.stream().forEach(v -> v.setGroupId(weTagGroup.getGroupId()));
iWeTagService.saveBatch(addWeTags);
}
//获取需要删除的数据
List<WeTag> removeWeTags = iWeTagService.list(new LambdaQueryWrapper<WeTag>().notIn(WeTag::getTagId,
weTags.stream().map(WeTag::getTagId).collect(Collectors.toList())).eq(WeTag::getGroupId, weTagGroup.getGroupId()));
}
removeWeTags.addAll(
iWeTagService.list(new LambdaQueryWrapper<WeTag>().notIn(WeTag::getTagId,
weTags.stream().map(WeTag::getTagId).collect(Collectors.toList()))
.eq(WeTag::getGroupId, weTagGroup.getGroupId()))
);
}else{//删除所有标签
removeWeTags.addAll(
iWeTagService.list(new LambdaQueryWrapper<WeTag>()
.eq(WeTag::getGroupId, weTagGroup.getGroupId()))
);
}
if (CollectionUtil.isNotEmpty(removeWeTags)) {
//同步删除微信端的标签
if(CollectionUtil.isNotEmpty(removeWeTags)){
//同步删除微信端的标签
try {
weCropTagClient.delCorpTag(
WeCropDelDto.builder()
.group_id(ArrayUtil.toArray(ListUtil.toList(weTagGroup.getGroupId()), String.class))
.tag_id(ArrayUtil.toArray(removeWeTags.stream().map(WeTag::getTagId).collect(Collectors.toList()), String.class))
.build());
}catch (Exception e){
log.error(e.getMessage());
} finally {
//移除本地
iWeTagService.removeByIds(removeWeTags.stream().map(WeTag::getTagId).collect(Collectors.toList()));
}
}
//保存或更新wetag
filterWeTags.stream().forEach(v -> v.setGroupId(weTagGroup.getGroupId()));
iWeTagService.saveOrUpdateBatch(filterWeTags);
}
//获取新增的集合
// if (CollectionUtil.isNotEmpty(weTags)) {
// List<WeTag> filterWeTags = weTags.stream().filter(v -> StringUtils.isEmpty(v.getTagId())).collect(Collectors.toList());
//
// //同步新增标签到微信端
// if (CollectionUtil.isNotEmpty(WeCropGroupTagDto.transformAddTag(weTagGroup).getTag())) {
// WeCropGropTagDtlDto
// weCropGropTagDtlDto = weCropTagClient.addCorpTag(WeCropGroupTagDto.transformAddTag(weTagGroup));
// if (weCropGropTagDtlDto.getErrcode().equals(WeConstans.WE_SUCCESS_CODE)) {
// //微信端返回的标签主键,设置到weTags中
// Map<String, String> weCropTagMap = weCropGropTagDtlDto.getTag_group().getTag().stream()
// .collect(Collectors.toMap(weCropTagDto -> weCropTagDto.getName(), weCropTagDto -> weCropTagDto.getId()));
// filterWeTags.stream().forEach(tag -> {
// tag.setTagId(weCropTagMap.get(tag.getName()));
// });
// }
// }
//
//
// //获取需要删除的数据
// List<WeTag> removeWeTags = iWeTagService.list(new LambdaQueryWrapper<WeTag>().notIn(WeTag::getTagId,
// weTags.stream().map(WeTag::getTagId).collect(Collectors.toList())).eq(WeTag::getGroupId, weTagGroup.getGroupId()));
//
// if (CollectionUtil.isNotEmpty(removeWeTags)) {
// //同步删除微信端的标签
// weCropTagClient.delCorpTag(
// WeCropDelDto.builder()
// .group_id(ArrayUtil.toArray(ListUtil.toList(weTagGroup.getGroupId()), String.class))
// .tag_id(ArrayUtil.toArray(removeWeTags.stream().map(WeTag::getTagId).collect(Collectors.toList()), String.class))
// .build());
//
// //移除本地
// iWeTagService.removeByIds(removeWeTags.stream().map(WeTag::getTagId).collect(Collectors.toList()));
// }
//
//
// //保存或更新wetag
// filterWeTags.stream().forEach(v -> v.setGroupId(weTagGroup.getGroupId()));
// iWeTagService.saveOrUpdateBatch(filterWeTags);
//
// }
}
......@@ -154,27 +210,26 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper, WeTagGr
*/
@Override
@Transactional
public int deleteWeTagGroupByIds(String[] ids) {
int returnCode = weTagGroupMapper.deleteWeTagGroupByIds(ids);
if (returnCode > Constants.SERVICE_RETURN_SUCCESS_CODE) {
public void deleteWeTagGroupByIds(String[] ids) {
if (this.removeByIds(CollectionUtil.toList(ids))) {
List<WeTag> weTags
= iWeTagService.list(new LambdaQueryWrapper<WeTag>().in(WeTag::getGroupId, ids));
if (CollectionUtil.isNotEmpty(weTags)) {
weCropTagClient.delCorpTag(
WeCropDelDto.builder()
.group_id(ids)
.tag_id(weTags.stream().map(WeTag::getTagId).toArray(String[]::new))
.build()
);
try {
weCropTagClient.delCorpTag(
WeCropDelDto.builder()
.group_id(ids)
.tag_id(weTags.stream().map(WeTag::getTagId).toArray(String[]::new))
.build()
);
}catch (Exception e){//防止数据不同步产生的错误
log.error(e.getMessage());
}
}
}
return returnCode;
}
......@@ -336,8 +391,8 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper, WeTagGr
}
@Override
public List<WeTagGroup> findCustomerTagByFlowerCustomerRelId(String flowerCustomerRelId) {
return this.baseMapper.findCustomerTagByFlowerCustomerRelId(flowerCustomerRelId);
public List<WeTagGroup> findCustomerTagByFlowerCustomerRelId(String externalUserid, String userid) {
return this.baseMapper.findCustomerTagByFlowerCustomerRelId(externalUserid, userid);
}
......
......@@ -19,25 +19,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select id, welcome_msg, media_id, del_flag, welcome_msg_tpl_type,create_by,create_time from we_msg_tlp
</sql>
<!-- <select id="selectWeMsgTlpList" parameterType="WeMsgTlp" resultMap="WeMsgTlpResult">-->
<!-- SELECT-->
<!-- wmt.id,-->
<!-- wmt.welcome_msg,-->
<!-- wmt.media_id,-->
<!-- wmt.del_flag,-->
<!-- wmt.welcome_msg_tpl_type,-->
<!-- wmt.create_by,-->
<!-- wmt.create_time,-->
<!-- wm.material_url-->
<!-- FROM-->
<!-- we_msg_tlp wmt-->
<!-- LEFT JOIN we_material wm ON wmt.media_id=wm.id-->
<!-- <where> -->
<!-- <if test="welcomeMsg != null and welcomeMsg != ''"> and wmt.welcome_msg like CONCAT('%',#{welcomeMsg,jdbcType=VARCHAR},'%') </if>-->
<!-- <if test="welcomeMsgTplType !=null "> and wmt.welcome_msg_tpl_type = #{welcomeMsgTplType}</if>-->
<!-- and wmt.del_flag = 0-->
<!-- </where>-->
<!-- </select>-->
<select id="selectWeMsgTlpList" parameterType="WeMsgTlp" resultMap="WeMsgTlpResult">
SELECT
wmt.id,
wmt.welcome_msg,
wmt.media_id,
wmt.del_flag,
wmt.welcome_msg_tpl_type,
wmt.create_by,
wmt.create_time,
wm.material_url
FROM
we_msg_tlp wmt
LEFT JOIN we_material wm ON wmt.media_id=wm.id
<where>
<if test="welcomeMsg != null and welcomeMsg != ''"> and wmt.welcome_msg like CONCAT('%',#{welcomeMsg,jdbcType=VARCHAR},'%') </if>
<if test="welcomeMsgTplType !=null "> and wmt.welcome_msg_tpl_type = #{welcomeMsgTplType}</if>
and wmt.del_flag = 0
</where>
</select>
<select id="selectWeMsgTlpById" parameterType="Long" resultMap="WeMsgTlpResult">
......
<?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.linkwechat.wecom.mapper.WeMsgTlpScopeMapper">
<resultMap type="WeMsgTlpScope" id="WeMsgTlpScopeResult">
<result property="id" column="id" />
<result property="msgTlpId" column="msg_tlp_id" />
<result property="useUserId" column="use_user_id" />
<result property="delFlag" column="del_flag" />
</resultMap>
<sql id="selectWeMsgTlpScopeVo">
select id, msg_tlp_id, use_user_id, del_flag from we_msg_tlp_scope
</sql>
<select id="selectWeMsgTlpScopeList" parameterType="WeMsgTlpScope" resultMap="WeMsgTlpScopeResult">
<include refid="selectWeMsgTlpScopeVo"/>
<where>
<if test="msgTlpId != null "> and msg_tlp_id = #{msgTlpId}</if>
<if test="useUserId != null "> and use_user_id = #{useUserId}</if>
</where>
</select>
<select id="selectWeMsgTlpScopeById" parameterType="Long" resultMap="WeMsgTlpScopeResult">
<include refid="selectWeMsgTlpScopeVo"/>
where id = #{id}
</select>
<insert id="insertWeMsgTlpScope" parameterType="WeMsgTlpScope">
insert into we_msg_tlp_scope
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="msgTlpId != null">msg_tlp_id,</if>
<if test="useUserId != null">use_user_id,</if>
<if test="delFlag != null">del_flag,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="msgTlpId != null">#{msgTlpId},</if>
<if test="useUserId != null">#{useUserId},</if>
<if test="delFlag != null">#{delFlag},</if>
</trim>
</insert>
<update id="updateWeMsgTlpScope" parameterType="WeMsgTlpScope">
update we_msg_tlp_scope
<trim prefix="SET" suffixOverrides=",">
<if test="msgTlpId != null">msg_tlp_id = #{msgTlpId},</if>
<if test="useUserId != null">use_user_id = #{useUserId},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteWeMsgTlpScopeById" parameterType="Long">
delete from we_msg_tlp_scope where id = #{id}
</delete>
<delete id="deleteWeMsgTlpScopeByIds" parameterType="String">
delete from we_msg_tlp_scope where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<insert id="batchInsetWeMsgTlpScope">
insert into we_msg_tlp_scope (id,msg_tlp_id,use_user_id,del_flag)
values
<foreach collection="weMsgTlpScopes" item="scop" index="index" separator=",">
(#{scop.id},#{scop.msgTlpId},#{scop.useUserId},#{scop.delFlag})
</foreach>
</insert>
<update id="batchRemoveWeMsgTlpScopesByMsgTlpIds">
update we_msg_tlp_scope set
del_flag = 2
where msgTlpId in
<foreach collection="msgTlpIds" item="msgTlpId" index="index"
separator="," open="(" close=")">
#{msgTlpId.msgTlpId}
</foreach>
</update>
</mapper>
\ No newline at end of file
......@@ -35,6 +35,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
wtg.del_flag=0 and wt.del_flag=0
<if test="gourpName != null and gourpName != ''"> and gourp_name like concat('%', #{gourpName}, '%')</if>
<if test="groupTagType != null">and wtg.group_tag_type=#{groupTagType}</if>
ORDER BY wtg.create_time DESC
</select>
<select id="getWeTagGroupByIds" resultMap="WeTagGroupResult">
......@@ -113,7 +114,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
we_flower_customer_tag_rel wfctr
INNER JOIN we_tag wt ON wfctr.tag_id = wt.tag_id
INNER JOIN we_tag_group wtg ON wt.group_id = wtg.group_id
WHERE wt.`status`=0 and wtg.`status`=0 and wfctr.flower_customer_rel_id=#{flowerCustomerRelId}
WHERE wt.`status`=0 and wtg.`status`=0 and wfctr.user_id=#{userid} and wfctr.external_userid=#{externalUserid}
</select>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!