优化客户同步

1 parent e0e1cad3
Showing 65 changed files with 1386 additions and 288 deletions
package com.linkwechat.web.controller.wecom; package com.linkwechat.web.controller.wecom;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.linkwechat.common.annotation.Log; import com.linkwechat.common.annotation.Log;
import com.linkwechat.common.constant.Constants; import com.linkwechat.common.constant.Constants;
...@@ -46,50 +45,6 @@ public class WeCorpAccountController extends BaseController ...@@ -46,50 +45,6 @@ public class WeCorpAccountController extends BaseController
} }
/******************************************************
*************************Lw2.0相关start****************
*****************************************************/
/**
* 获取当前可用企业相关配置
* @return
*/
@GetMapping("/findCurrentCorpAccount")
public AjaxResult findCurrentCorpAccount(){
WeCorpAccount weCorpAccount=new WeCorpAccount();
List<WeCorpAccount> weCorpAccounts = weCorpAccountService.list(new LambdaQueryWrapper<WeCorpAccount>()
.eq(WeCorpAccount::getDelFlag,Constants.NORMAL_CODE));
if(CollectionUtil.isNotEmpty(weCorpAccounts)){
weCorpAccount=weCorpAccounts.stream().findFirst().get();
}
return AjaxResult.success(weCorpAccount);
}
/**
* 新增或编辑企业配置相关
* @param weCorpAccount
* @return
*/
@PostMapping("/addOrUpdate")
public AjaxResult addOrUpdate(@RequestBody WeCorpAccount weCorpAccount){
weCorpAccountService.saveOrUpdate(weCorpAccount);
return AjaxResult.success();
}
/******************************************************
*************************Lw2.0相关end****************
*****************************************************/
// @PreAuthorize("@ss.hasPermi('wechat:corp:add')") // @PreAuthorize("@ss.hasPermi('wechat:corp:add')")
......
package com.linkwechat.web.controller.wecom; package com.linkwechat.web.controller.wecom;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.collection.ListUtil; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.linkwechat.common.annotation.Log; import com.linkwechat.common.annotation.Log;
import com.linkwechat.common.constant.Constants; import com.linkwechat.common.constant.Constants;
...@@ -10,12 +10,10 @@ import com.linkwechat.common.core.controller.BaseController; ...@@ -10,12 +10,10 @@ import com.linkwechat.common.core.controller.BaseController;
import com.linkwechat.common.core.domain.AjaxResult; import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.core.page.TableDataInfo; import com.linkwechat.common.core.page.TableDataInfo;
import com.linkwechat.common.enums.BusinessType; import com.linkwechat.common.enums.BusinessType;
import com.linkwechat.common.utils.poi.ExcelUtil;
import com.linkwechat.wecom.domain.*; import com.linkwechat.wecom.domain.*;
import com.linkwechat.wecom.domain.vo.WeMakeCustomerTag; import com.linkwechat.wecom.domain.vo.WeMakeCustomerTag;
import com.linkwechat.wecom.service.IWeCustomerService; import com.linkwechat.wecom.service.IWeCustomerService;
import com.linkwechat.wecom.service.IWeCustomerTrajectoryService; import com.linkwechat.wecom.service.IWeCustomerTrajectoryService;
import com.linkwechat.wecom.service.IWeFlowerCustomerRelService;
import com.linkwechat.wecom.service.IWeFlowerCustomerTagRelService; import com.linkwechat.wecom.service.IWeFlowerCustomerTagRelService;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -23,7 +21,6 @@ import org.springframework.context.annotation.Lazy; ...@@ -23,7 +21,6 @@ import org.springframework.context.annotation.Lazy;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
...@@ -43,12 +40,6 @@ public class WeCustomerController extends BaseController ...@@ -43,12 +40,6 @@ public class WeCustomerController extends BaseController
@Autowired @Autowired
private IWeFlowerCustomerTagRelService weFlowerCustomerTagRelService;
@Autowired
private IWeFlowerCustomerRelService weFlowerCustomerRelService;
@Autowired
private IWeCustomerTrajectoryService iWeCustomerTrajectoryService; private IWeCustomerTrajectoryService iWeCustomerTrajectoryService;
...@@ -89,41 +80,23 @@ public class WeCustomerController extends BaseController ...@@ -89,41 +80,23 @@ public class WeCustomerController extends BaseController
{ {
startPage(); startPage();
List<WeCustomerList> list = weCustomerService.findWeCustomerList(weCustomerList); List<WeCustomerList> list = weCustomerService.findWeCustomerList(weCustomerList);
if(CollectionUtil.isNotEmpty(list)){
list.stream().forEach(k->{
WeFlowerCustomerRel customerRel = weFlowerCustomerRelService.getOne(new LambdaQueryWrapper<WeFlowerCustomerRel>()
.eq(WeFlowerCustomerRel::getUserId, k.getFirstUserId())
.eq(WeFlowerCustomerRel::getExternalUserid, k.getExternalUserid()));
if(customerRel !=null){
customerRel.setWeFlowerCustomerTagRels(
weFlowerCustomerTagRelService.list(new LambdaQueryWrapper<WeFlowerCustomerTagRel>()
.eq(WeFlowerCustomerTagRel::getUserId,k.getFirstUserId())
.eq(WeFlowerCustomerTagRel::getExternalUserid,k.getExternalUserid()))
);
}
k.setWeFlowerCustomerRels(ListUtil.toList(
customerRel
));
});
}
return getDataTable(list); return getDataTable(list);
} }
/** // /**
* 导出企业微信客户列表 // * 导出企业微信客户列表
*/ // */
// @PreAuthorize("@ss.hasPermi('wecom:customer:export')") // // @PreAuthorize("@ss.hasPermi('wecom:customer:export')")
@Log(title = "企业微信客户", businessType = BusinessType.EXPORT) // @Log(title = "企业微信客户", businessType = BusinessType.EXPORT)
@GetMapping("/export") // @GetMapping("/export")
public AjaxResult export(WeCustomer weCustomer) // public AjaxResult export(WeCustomer weCustomer)
{ // {
List<WeCustomer> list = weCustomerService.selectWeCustomerList(weCustomer); // List<WeCustomer> list = weCustomerService.selectWeCustomerList(weCustomer);
ExcelUtil<WeCustomer> util = new ExcelUtil<WeCustomer>(WeCustomer.class); // ExcelUtil<WeCustomer> util = new ExcelUtil<WeCustomer>(WeCustomer.class);
return util.exportExcel(list, "customer"); // return util.exportExcel(list, "customer");
} // }
/** /**
* 获取企业微信客户详细信息 * 获取企业微信客户详细信息
...@@ -193,7 +166,7 @@ public class WeCustomerController extends BaseController ...@@ -193,7 +166,7 @@ public class WeCustomerController extends BaseController
@DeleteMapping("/removeLabel") @DeleteMapping("/removeLabel")
public AjaxResult removeLabel(@RequestBody WeMakeCustomerTag weMakeCustomerTag){ public AjaxResult removeLabel(@RequestBody WeMakeCustomerTag weMakeCustomerTag){
weCustomerService.removeLabel(weMakeCustomerTag); weCustomerService.makeLabel(weMakeCustomerTag);
return AjaxResult.success(); return AjaxResult.success();
...@@ -239,5 +212,16 @@ public class WeCustomerController extends BaseController ...@@ -239,5 +212,16 @@ public class WeCustomerController extends BaseController
); );
} }
/**
* 客户条件检索
* @param params 检索条件
* @return
*/
@ApiOperation(value = "客户条件检索",httpMethod = "POST")
@PostMapping(value = "/getCustomerByCondition")
public AjaxResult getCustomerByCondition(@RequestBody JSONObject params){
weCustomerService.getCustomerByCondition(params);
return AjaxResult.success("");
}
} }
...@@ -14,19 +14,14 @@ import com.linkwechat.wecom.domain.WeFlowerCustomerRel; ...@@ -14,19 +14,14 @@ import com.linkwechat.wecom.domain.WeFlowerCustomerRel;
import com.linkwechat.wecom.service.IWeEmpleCodeService; import com.linkwechat.wecom.service.IWeEmpleCodeService;
import com.linkwechat.wecom.service.IWeFlowerCustomerRelService; import com.linkwechat.wecom.service.IWeFlowerCustomerRelService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
/** /**
* 员工活码Controller * 员工活码Controller
...@@ -39,6 +34,8 @@ import java.util.zip.ZipOutputStream; ...@@ -39,6 +34,8 @@ import java.util.zip.ZipOutputStream;
public class WeEmpleCodeController extends BaseController { public class WeEmpleCodeController extends BaseController {
@Autowired @Autowired
private IWeEmpleCodeService weEmpleCodeService; private IWeEmpleCodeService weEmpleCodeService;
@Autowired @Autowired
private IWeFlowerCustomerRelService weFlowerCustomerRelService; private IWeFlowerCustomerRelService weFlowerCustomerRelService;
......
package com.linkwechat.web.controller.wecom;
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.wecom.domain.WeGroupMessageTemplate;
import com.linkwechat.wecom.domain.query.WeAddGroupMessageQuery;
import com.linkwechat.wecom.domain.vo.WeGroupMessageDetailVo;
import com.linkwechat.wecom.service.IWeGroupMessageTemplateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
/**
* 群发消息模板Controller
*
* @author ruoyi
* @date 2021-10-27
*/
@Api(tags = "群发消息管理")
@RestController
@RequestMapping("/wecom/groupmsg/template")
public class WeGroupMessageTemplateController extends BaseController {
@Autowired
private IWeGroupMessageTemplateService iWeGroupMessageTemplateService;
/**
* 查询群发消息模板列表
*/
//@PreAuthorize("@ss.hasPermi('linkwechat:template:list')")
@ApiOperation(value = "查询群发消息模板列表", httpMethod = "GET")
@GetMapping("/list")
public TableDataInfo<WeGroupMessageTemplate> list(WeGroupMessageTemplate weGroupMessageTemplate) {
startPage();
List<WeGroupMessageTemplate> list = iWeGroupMessageTemplateService.queryList(weGroupMessageTemplate);
return getDataTable(list);
}
/**
* 获取群发消息模板详细信息
*/
//@PreAuthorize("@ss.hasPermi('linkwechat:template:query')")
@ApiOperation(value = "获取群发消息模板详细信息", httpMethod = "GET")
@GetMapping(value = "/{id}")
public AjaxResult<WeGroupMessageDetailVo> getGroupMsgTemplateDetail(@PathVariable("id") Long id) {
return AjaxResult.success(iWeGroupMessageTemplateService.getGroupMsgTemplateDetail(id));
}
/**
* 新增群发消息模板
*/
//@PreAuthorize("@ss.hasPermi('linkwechat:template:add')")
@ApiOperation(value = "新增群发消息模板", httpMethod = "POST")
@Log(title = "群发消息模板", businessType = BusinessType.INSERT)
@PostMapping("/add")
public AjaxResult addGroupMsgTemplate(@RequestBody WeAddGroupMessageQuery query) {
iWeGroupMessageTemplateService.addGroupMsgTemplate(query);
return AjaxResult.success();
}
/**
* 同步消息发送结果
*/
//@PreAuthorize("@ss.hasPermi('linkwechat:template:remove')")
@ApiOperation(value = "同步消息发送结果", httpMethod = "GET")
@Log(title = "群发消息模板", businessType = BusinessType.OTHER)
@GetMapping("/sync/{ids}")
public AjaxResult sync(@PathVariable Long[] ids) {
iWeGroupMessageTemplateService.syncGroupMsgSendResultByIds(Arrays.asList(ids));
return AjaxResult.success();
}
/**
* 取消定时发送
*/
//@PreAuthorize("@ss.hasPermi('linkwechat:template:remove')")
@ApiOperation(value = "取消定时发送", httpMethod = "GET")
@Log(title = "群发消息模板", businessType = BusinessType.UPDATE)
@GetMapping("/cancel/{ids}")
public AjaxResult cancel(@PathVariable Long[] ids) {
iWeGroupMessageTemplateService.cancelByIds(Arrays.asList(ids));
return AjaxResult.success();
}
}
...@@ -61,6 +61,13 @@ public class WeMsgTlpController extends BaseController ...@@ -61,6 +61,13 @@ public class WeMsgTlpController extends BaseController
} }
@PutMapping
public AjaxResult add(@RequestBody WeMsgTlp weMsgTlp){
weMsgTlpService.save(weMsgTlp);
return AjaxResult.success();
}
/** /**
* 删除欢迎语模板 * 删除欢迎语模板
*/ */
......
package com.linkwechat.web.controller.wecom; import com.linkwechat.common.core.domain.AjaxResult;import com.linkwechat.common.core.redis.RedisCache;import com.linkwechat.wecom.domain.dto.WePageStaticDataDto;import com.linkwechat.wecom.service.IWePageService;import io.swagger.annotations.Api;import io.swagger.annotations.ApiOperation;import lombok.extern.slf4j.Slf4j;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; /** * @author danmo * @description 首页统计 * @date 2021/2/23 15:30 **/@Api(description = "首页统计contraller")@Slf4j@RestController@RequestMapping("wecom/page/")public class WePageDateContraller { @Autowired private RedisCache redisCache; @Autowired private IWePageService iWePageService; /** * */ @ApiOperation(value = "数据总览controller",httpMethod = "GET") // @PreAuthorize("@ss.hasPermi('wecom:page:getCorpBasicData')") @GetMapping("/getCorpBasicData") public AjaxResult getCorpBasicData(){ // return AjaxResult.success(redisCache.getCacheMap("getCorpBasicData")); return AjaxResult.success( iWePageService.getCcorpBasicData() ); } @ApiOperation(value = "实时数据controller",httpMethod = "GET") // @PreAuthorize("@ss.hasPermi('wecom:page:getCorpRealTimeData')") @GetMapping("/getCorpRealTimeData") public AjaxResult getCorpRealTimeData(){ WePageStaticDataDto wePageStaticDataDto = redisCache.getCacheObject("getCorpRealTimeData"); return AjaxResult.success(wePageStaticDataDto); } }
\ No newline at end of file \ No newline at end of file
package com.linkwechat.web.controller.wecom;
import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.core.redis.RedisCache;
import com.linkwechat.wecom.domain.dto.WePageStaticDataDto;
import com.linkwechat.wecom.service.IWeCorpAccountService;
import com.linkwechat.wecom.service.IWeUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
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 danmo
* @description 首页统计
* @date 2021/2/23 15:30
**/
@Api(description = "首页统计contraller")
@Slf4j
@RestController
@RequestMapping("wecom/page/")
public class WePageDateContraller {
@Autowired
private RedisCache redisCache;
/**
*
*/
@ApiOperation(value = "数据总览controller",httpMethod = "GET")
// @PreAuthorize("@ss.hasPermi('wecom:page:getCorpBasicData')")
@GetMapping("/getCorpBasicData")
public AjaxResult getCorpBasicData(){
return AjaxResult.success(redisCache.getCacheMap("getCorpBasicData"));
}
@ApiOperation(value = "实时数据controller",httpMethod = "GET")
// @PreAuthorize("@ss.hasPermi('wecom:page:getCorpRealTimeData')")
@GetMapping("/getCorpRealTimeData")
public AjaxResult getCorpRealTimeData(){
WePageStaticDataDto wePageStaticDataDto = redisCache.getCacheObject("getCorpRealTimeData");
return AjaxResult.success(wePageStaticDataDto);
}
}
...@@ -45,13 +45,22 @@ public interface WeCustomerClient { ...@@ -45,13 +45,22 @@ public interface WeCustomerClient {
@Request(url = "/externalcontact/get") @Request(url = "/externalcontact/get")
ExternalUserDetail get(@Query("external_userid") String externalUserid); ExternalUserDetail get(@Query("external_userid") String externalUserid);
// /**
// * 根据企业成员id批量获取客户详情
// * @param query
// * @return
// */
// @Request(url = "/externalcontact/batch/get_by_user", type = "POST")
// ExternalUserList getByUser(@JSONBody Map<String,Object> query);
/** /**
* 根据企业成员id批量获取客户详情 * 根据企业成员id批量获取客户详情
* @param query * @param param
* @return * @return
*/ */
@Request(url = "/externalcontact/batch/get_by_user", type = "POST") @Request(url = "/externalcontact/batch/get_by_user", type = "POST")
ExternalUserList getByUser(@JSONBody Map<String,Object> query); ExternalUserList getByUser(@JSONBody WeCustomerDto.BatchCustomerParam param);
/** /**
......
...@@ -24,7 +24,7 @@ public interface WeCustomerMessagePushClient { ...@@ -24,7 +24,7 @@ public interface WeCustomerMessagePushClient {
*/ */
@Deprecated @Deprecated
@Request(url = "/externalcontact/add_msg_template", type = "POST") @Request(url = "/externalcontact/add_msg_template", type = "POST")
SendMessageResultDto sendCustomerMessageToUser(@Body WeCustomerMessagePushDto customerMessagePushDto); SendMessageResultDto sendCustomerMessageToUser(@JSONBody WeCustomerMessagePushDto customerMessagePushDto);
......
package com.linkwechat.wecom.client; package com.linkwechat.wecom.client;
import com.dtflys.forest.annotation.*; import com.dtflys.forest.annotation.*;
import com.dtflys.forest.http.ForestResponse;
import com.linkwechat.wecom.domain.dto.WeMediaDto; import com.linkwechat.wecom.domain.dto.WeMediaDto;
import com.linkwechat.wecom.interceptor.WeAccessTokenInterceptor; import com.linkwechat.wecom.interceptor.WeAccessTokenInterceptor;
import com.linkwechat.wecom.retry.WeCommonRetryWhen; import com.linkwechat.wecom.retry.WeCommonRetryWhen;
...@@ -35,4 +36,12 @@ public interface WeMediaClient { ...@@ -35,4 +36,12 @@ public interface WeMediaClient {
@Post(url = "/media/upload") @Post(url = "/media/upload")
WeMediaDto upload(@DataFile(value = "media", fileName = "${1}") InputStream file, String filename, @Query("type") String type); WeMediaDto upload(@DataFile(value = "media", fileName = "${1}") InputStream file, String filename, @Query("type") String type);
/**
* 获取临时素材
*
* @param mediaId 素材id
* @return
*/
@GetRequest(url = "/media/get")
ForestResponse getMediaToResponse(@Query("media_id") String mediaId);
} }
...@@ -57,6 +57,15 @@ public interface WeUserClient { ...@@ -57,6 +57,15 @@ public interface WeUserClient {
* @param fetchChild * @param fetchChild
* @return * @return
*/ */
@Request(url="/user/simplelist")
WeUserListDto simpleList(@Query("department_id") Long departmentId,@Query("fetch_child") Integer fetchChild);
/**
* 获取部门成员
* @param departmentId
* @param fetchChild
* @return
*/
@Request(url="/user/list") @Request(url="/user/list")
WeUserListDto list(@Query("department_id") Long departmentId,@Query("fetch_child") Integer fetchChild); WeUserListDto list(@Query("department_id") Long departmentId,@Query("fetch_child") Integer fetchChild);
...@@ -65,7 +74,7 @@ public interface WeUserClient { ...@@ -65,7 +74,7 @@ public interface WeUserClient {
* 分配客户 * 分配客户
* @return * @return
*/ */
@Request(url="/externalcontact/transfer", type = "POST") @Request(url="/externalcontact/resigned/transfer_customer", type = "POST")
WeResultDto allocateCustomer(@JSONBody AllocateWeCustomerDto allocateWeCustomerDto); WeResultDto allocateCustomer(@JSONBody AllocateWeCustomerDto allocateWeCustomerDto);
......
...@@ -2,13 +2,11 @@ package com.linkwechat.wecom.domain; ...@@ -2,13 +2,11 @@ package com.linkwechat.wecom.domain;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic; import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.linkwechat.common.annotation.Excel; import com.linkwechat.common.annotation.Excel;
import com.linkwechat.common.core.domain.BaseEntity; import com.linkwechat.common.core.domain.BaseEntity;
import com.linkwechat.common.utils.SnowFlakeUtil;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
...@@ -40,11 +38,17 @@ public class WeCustomer extends BaseEntity { ...@@ -40,11 +38,17 @@ public class WeCustomer extends BaseEntity {
/** /**
* 外部联系人的userid * 外部联系人的userid
*/ */
@TableId
@NotBlank(message = "外部联系人的id不可为空") @NotBlank(message = "外部联系人的id不可为空")
@ApiModelProperty("外部联系人的userid") @ApiModelProperty("外部联系人的userid")
private String externalUserid; private String externalUserid;
/**
* 首位添加人
*/
private String firstUserId;
/** /**
* 外部联系人名称 * 外部联系人名称
*/ */
...@@ -167,10 +171,6 @@ public class WeCustomer extends BaseEntity { ...@@ -167,10 +171,6 @@ public class WeCustomer extends BaseEntity {
private String updateBy; private String updateBy;
/**
* 首位添加人
*/
private String firstUserId;
/** /**
......
...@@ -25,7 +25,7 @@ public class WeCustomerList { ...@@ -25,7 +25,7 @@ public class WeCustomerList {
private String tagNames; private String tagNames;
private List<WeFlowerCustomerRel> weFlowerCustomerRels; // private List<WeFlowerCustomerRel> weFlowerCustomerRels;
//查询条件客户姓名 //查询条件客户姓名
private String name; private String name;
......
...@@ -2,6 +2,7 @@ package com.linkwechat.wecom.domain; ...@@ -2,6 +2,7 @@ package com.linkwechat.wecom.domain;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.linkwechat.common.core.domain.BaseEntity; import com.linkwechat.common.core.domain.BaseEntity;
...@@ -29,12 +30,7 @@ public class WeFlowerCustomerTagRel ...@@ -29,12 +30,7 @@ public class WeFlowerCustomerTagRel
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** $column.columnComment */
@TableId
private Long id;
/** 添加客户的企业微信用户 */
private Long flowerCustomerRelId;
/**外部联系人id(客户id) */ /**外部联系人id(客户id) */
...@@ -54,4 +50,7 @@ public class WeFlowerCustomerTagRel ...@@ -54,4 +50,7 @@ public class WeFlowerCustomerTagRel
private Date createTime; private Date createTime;
private String userId; private String userId;
@TableLogic
private Integer delFlag;
} }
package com.linkwechat.wecom.domain; package com.linkwechat.wecom.domain;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.linkwechat.common.annotation.Excel; import com.linkwechat.common.annotation.Excel;
...@@ -12,11 +11,6 @@ import lombok.Data; ...@@ -12,11 +11,6 @@ import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/** /**
* 群发消息附件对象 we_group_message_attachments * 群发消息附件对象 we_group_message_attachments
* *
...@@ -34,6 +28,13 @@ public class WeGroupMessageAttachments extends BaseEntity{ ...@@ -34,6 +28,13 @@ public class WeGroupMessageAttachments extends BaseEntity{
@TableId(value = "id",type = IdType.AUTO) @TableId(value = "id",type = IdType.AUTO)
private Long id; private Long id;
/**
* 群发消息模板id
*/
@ApiModelProperty("群发消息模板id")
@Excel(name = "群发消息模板id")
private Long msgTemplateId;
/** 企业群发消息的id */ /** 企业群发消息的id */
@ApiModelProperty("企业群发消息的id") @ApiModelProperty("企业群发消息的id")
@Excel(name = "企业群发消息的id") @Excel(name = "企业群发消息的id")
...@@ -64,6 +65,11 @@ public class WeGroupMessageAttachments extends BaseEntity{ ...@@ -64,6 +65,11 @@ public class WeGroupMessageAttachments extends BaseEntity{
@Excel(name = "消息描述") @Excel(name = "消息描述")
private String description; private String description;
/** 文件路径 */
@ApiModelProperty("文件路径")
@Excel(name = "文件路径")
private String fileUrl;
/** 消息链接 */ /** 消息链接 */
@ApiModelProperty("消息链接") @ApiModelProperty("消息链接")
@Excel(name = "消息链接") @Excel(name = "消息链接")
......
package com.linkwechat.wecom.domain; package com.linkwechat.wecom.domain;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
...@@ -25,7 +26,7 @@ import java.util.Date; ...@@ -25,7 +26,7 @@ import java.util.Date;
@NoArgsConstructor @NoArgsConstructor
@Accessors(chain = true) @Accessors(chain = true)
@TableName("we_group_message_list") @TableName("we_group_message_list")
public class WeGroupMessageList extends BaseEntity { public class WeGroupMessageList extends BaseEntity{
/** /**
* 主键id * 主键id
...@@ -34,6 +35,14 @@ public class WeGroupMessageList extends BaseEntity { ...@@ -34,6 +35,14 @@ public class WeGroupMessageList extends BaseEntity {
@TableId(value = "id", type = IdType.AUTO) @TableId(value = "id", type = IdType.AUTO)
private Long id; private Long id;
/**
* 群发消息模板id
*/
@ApiModelProperty("群发消息模板id")
@Excel(name = "群发消息模板id")
private Long msgTemplateId;
/** /**
* 企业群发消息的id * 企业群发消息的id
*/ */
...@@ -51,7 +60,7 @@ public class WeGroupMessageList extends BaseEntity { ...@@ -51,7 +60,7 @@ public class WeGroupMessageList extends BaseEntity {
/** /**
* 群发消息创建者userid * 群发消息创建者userid
*/ */
@ApiModelProperty("群发消息创建者userid") @ApiModelProperty(value = "群发消息创建者userid", hidden = true)
@Excel(name = "群发消息创建者userid") @Excel(name = "群发消息创建者userid")
private String userId; private String userId;
...@@ -66,14 +75,14 @@ public class WeGroupMessageList extends BaseEntity { ...@@ -66,14 +75,14 @@ public class WeGroupMessageList extends BaseEntity {
/** /**
* 群发消息创建来源。0:企业 1:个人 * 群发消息创建来源。0:企业 1:个人
*/ */
@ApiModelProperty("群发消息创建来源。0:企业 1:个人") @ApiModelProperty(value = "群发消息创建来源。0:企业 1:个人",hidden = true)
@Excel(name = "群发消息创建来源。0:企业 1:个人") @Excel(name = "群发消息创建来源。0:企业 1:个人")
private Integer createType; private Integer createType = 0;
/** /**
* 是否定时任务 0 常规 1 定时发送 * 群发消息创建者
*/ */
@ApiModelProperty("是否定时任务 0 常规 1 定时发送") @ApiModelProperty(value = "群发消息创建者",hidden = true)
@Excel(name = "是否定时任务 0 常规 1 定时发送") @TableField(exist = false)
private Integer isTask; private String userName;
} }
package com.linkwechat.wecom.domain; package com.linkwechat.wecom.domain;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
...@@ -25,7 +26,7 @@ import java.util.Date; ...@@ -25,7 +26,7 @@ import java.util.Date;
@NoArgsConstructor @NoArgsConstructor
@Accessors(chain = true) @Accessors(chain = true)
@TableName("we_group_message_send_result") @TableName("we_group_message_send_result")
public class WeGroupMessageSendResult extends BaseEntity { public class WeGroupMessageSendResult extends BaseEntity{
/** /**
* 主键id * 主键id
...@@ -34,6 +35,14 @@ public class WeGroupMessageSendResult extends BaseEntity { ...@@ -34,6 +35,14 @@ public class WeGroupMessageSendResult extends BaseEntity {
@TableId(value = "id", type = IdType.AUTO) @TableId(value = "id", type = IdType.AUTO)
private Long id; private Long id;
/**
* 群发消息模板id
*/
@ApiModelProperty("群发消息模板id")
@Excel(name = "群发消息模板id")
private Long msgTemplateId;
/** /**
* 企业群发消息的id * 企业群发消息的id
*/ */
...@@ -76,4 +85,25 @@ public class WeGroupMessageSendResult extends BaseEntity { ...@@ -76,4 +85,25 @@ public class WeGroupMessageSendResult extends BaseEntity {
@Excel(name = "发送时间,发送状态为1时返回", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "发送时间,发送状态为1时返回", width = 30, dateFormat = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date sendTime; private Date sendTime;
/**
* 企业服务人员名称
*/
@ApiModelProperty("企业服务人员名称")
@TableField(exist = false)
private String userName;
/**
* 外部联系人姓名
*/
@ApiModelProperty("外部联系人姓名")
@TableField(exist = false)
private String customerName;
/**
* 外部客户群名称
*/
@ApiModelProperty("外部客户群名称")
@TableField(exist = false)
private String chatName;
} }
package com.linkwechat.wecom.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.linkwechat.common.annotation.Excel;
import com.linkwechat.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* 群发消息成员发送任务表 we_group_message_task
*
* @author ruoyi
* @date 2021-10-19
*/
@ApiModel
@Data
@NoArgsConstructor
@Accessors(chain = true)
@TableName("we_group_message_task")
public class WeGroupMessageTask extends BaseEntity{
/**
* 主键id
*/
@ApiModelProperty("id")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 群发消息模板id
*/
@ApiModelProperty("群发消息模板id")
@Excel(name = "群发消息模板id")
private Long msgTemplateId;
/**
* 企业群发消息的id
*/
@ApiModelProperty("企业群发消息的id")
@Excel(name = "企业群发消息的id")
private String msgId;
/**
* 企业服务人员的userid
*/
@ApiModelProperty("企业服务人员的userid")
@Excel(name = "企业服务人员的userid")
private String userId;
/**
* 发送状态:0-未发送 2-已发送
*/
@ApiModelProperty("发送状态:0-未发送 2-已发送")
@Excel(name = "发送状态:0-未发送 2-已发送")
private Integer status;
/**
* 发送时间,发送状态为1时返回
*/
@ApiModelProperty("发送时间")
@Excel(name = "发送时间,发送状态为1时返回", width = 30, dateFormat = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date sendTime;
/**
* 企业服务人员名称
*/
@ApiModelProperty("企业服务人员名称")
@TableField(exist = false)
private String userName;
}
package com.linkwechat.wecom.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.linkwechat.common.annotation.Excel;
import com.linkwechat.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* 群发消息模板对象 we_group_message_template
*
* @author ruoyi
* @date 2021-10-27
*/
@ApiModel
@Data
@TableName("we_group_message_template")
public class WeGroupMessageTemplate extends BaseEntity {
/**
* 主键id
*/
@ApiModelProperty("id")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 群发任务的类,1:表示发送给客户,2:表示发送给客户群
*/
@ApiModelProperty("群发任务的类,1:表示发送给客户,2:表示发送给客户群")
@Excel(name = "群发任务的类,1:表示发送给客户,2:表示发送给客户群")
private Integer chatType;
/**
* 群发内容
*/
@ApiModelProperty("群发内容")
@Excel(name = "群发内容")
private String content;
/**
* 发送时间
*/
@ApiModelProperty("发送时间")
@Excel(name = "发送时间", width = 30, dateFormat = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date sendTime;
/**
* 条件筛选
*/
@ApiModelProperty("条件筛选")
@Excel(name = "条件筛选")
private String filterCondition;
/**
* 是否定时任务 0 立即发送 1 定时发送
*/
@ApiModelProperty("是否定时任务 0 立即发送 1 定时发送")
@Excel(name = "是否定时任务 0 立即发送 1 定时发送")
private Integer isTask;
/**
* 状态 -1:失败 0:未执行 1:完成 2:取消
*/
@ApiModelProperty("状态 -1:失败 0:未执行 1:完成 2:取消")
@Excel(name = "是否执行 -1:失败 0:未执行 1:完成 2:取消")
private Integer status;
}
...@@ -72,6 +72,10 @@ public class WePoster extends BaseEntity { ...@@ -72,6 +72,10 @@ public class WePoster extends BaseEntity {
@ApiModelProperty("分类id") @ApiModelProperty("分类id")
private Long categoryId; private Long categoryId;
@ApiModelProperty("其他字段")
private String otherField;
/** /**
* 海报组件数组 * 海报组件数组
*/ */
......
...@@ -20,12 +20,12 @@ public class AllocateWeCustomerDto{ ...@@ -20,12 +20,12 @@ public class AllocateWeCustomerDto{
private String handover_userid; private String handover_userid;
/**原跟进成员的userid*/ /**原跟进成员的userid*/
private String external_userid; private String[] external_userid;
/**接替成员的userid*/ /**接替成员的userid*/
private String takeover_userid; private String takeover_userid;
/**转移成功后发给客户的消息,最多200个字符,不填则使用默认文案,目前只对在职成员分配客户的情况生效*/ // /**转移成功后发给客户的消息,最多200个字符,不填则使用默认文案,目前只对在职成员分配客户的情况生效*/
private String transfer_success_msg; // private String transfer_success_msg;
} }
...@@ -5,6 +5,7 @@ import com.linkwechat.common.utils.StringUtils; ...@@ -5,6 +5,7 @@ import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.common.utils.bean.BeanUtils; import com.linkwechat.common.utils.bean.BeanUtils;
import com.linkwechat.wecom.domain.WeCustomer; import com.linkwechat.wecom.domain.WeCustomer;
import com.linkwechat.wecom.domain.WeFlowerCustomerRel; import com.linkwechat.wecom.domain.WeFlowerCustomerRel;
import lombok.Builder;
import lombok.Data; import lombok.Data;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -64,6 +65,18 @@ public class WeCustomerDto extends WeResultDto{ ...@@ -64,6 +65,18 @@ public class WeCustomerDto extends WeResultDto{
} }
/**
* 批量获取客户参数
*/
@Data
@Builder
public static class BatchCustomerParam{
private String[] userid_list;
private String cursor;
private Integer limit;
}
// public WeCustomer transformWeCustomer(){ // public WeCustomer transformWeCustomer(){
// WeCustomer weCustomer=new WeCustomer(); // WeCustomer weCustomer=new WeCustomer();
// //
......
...@@ -75,6 +75,8 @@ public class ExternalUserDetail extends WeResultDto { ...@@ -75,6 +75,8 @@ public class ExternalUserDetail extends WeResultDto {
@Data @Data
public class FollowInfo{ public class FollowInfo{
/**添加人id*/
private String userid;
/**该成员对此外部联系人的备注*/ /**该成员对此外部联系人的备注*/
private String remark; private String remark;
/**该成员对此外部联系人的描述*/ /**该成员对此外部联系人的描述*/
......
package com.linkwechat.wecom.domain.query;
import com.alibaba.fastjson.JSONObject;
import com.linkwechat.wecom.domain.WeGroupMessageTemplate;
import com.linkwechat.wecom.domain.WeMessageTemplate;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author danmo
* @description 添加群发消息入参
* @date 2021/10/24 12:14
**/
@ApiModel
@Data
public class WeAddGroupMessageQuery extends WeGroupMessageTemplate {
/**
* 指定接收消息的成员及对应客户列表
*/
@ApiModelProperty("指定接收消息的成员及对应客户列表")
private List<SenderInfo> senderList;
@ApiModelProperty("附件列表")
private List<WeMessageTemplate> attachmentsList;
@ApiModel
@Data
public static class SenderInfo {
@ApiModelProperty("成员id")
private String userId;
@ApiModelProperty("客户列表")
private List<String> customerList;
@ApiModelProperty("群组列表")
private List<String> chatList;
}
}
package com.linkwechat.wecom.domain.query; package com.linkwechat.wecom.domain.query;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.linkwechat.common.enums.MessageType;
import com.linkwechat.common.exception.wecom.WeComException; import com.linkwechat.common.exception.wecom.WeComException;
import com.linkwechat.wecom.domain.WeMessageTemplate; import com.linkwechat.wecom.domain.WeMessageTemplate;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
...@@ -35,28 +37,39 @@ public class WeAddMsgTemplateQuery { ...@@ -35,28 +37,39 @@ public class WeAddMsgTemplateQuery {
@ApiModelProperty("附件,最多支持添加9个附件 ru") @ApiModelProperty("附件,最多支持添加9个附件 ru")
private List<Attachments> attachments; private List<Attachments> attachments;
public void setChat_type(String chat_type) {
this.chat_type = chat_type;
}
public void setChat_type(Integer chatType) {
if(ObjectUtil.equal(2,chatType)){
this.chat_type = "group";
}else {
this.chat_type = "single";
}
}
public void setAttachments(List<WeMessageTemplate> messageTemplates) { public void setAttachments(List<WeMessageTemplate> messageTemplates) {
final int size = 9; final int size = 10;
this.attachments = new ArrayList<>(16); this.attachments = new ArrayList<>(16);
if (messageTemplates != null && messageTemplates.size() <= size) { if (CollectionUtil.isNotEmpty(messageTemplates) && messageTemplates.size() < size) {
messageTemplates.forEach(messageTemplate -> { messageTemplates.forEach(messageTemplate -> {
if (ObjectUtil.equal("image", messageTemplate.getMsgType())) { if (ObjectUtil.equal(MessageType.IMAGE.getMessageType(), messageTemplate.getMsgType())) {
Attachments images = new Images(messageTemplate.getMsgType(), messageTemplate.getMediaId(), Attachments images = new Images(messageTemplate.getMsgType(), messageTemplate.getMediaId(),
messageTemplate.getPicUrl()); messageTemplate.getPicUrl());
attachments.add(images); attachments.add(images);
} else if (ObjectUtil.equal("link", messageTemplate.getMsgType())) { } else if (ObjectUtil.equal(MessageType.LINK.getMessageType(), messageTemplate.getMsgType())) {
Attachments links = new Links(messageTemplate.getMsgType(), messageTemplate.getTitle(), Attachments links = new Links(messageTemplate.getMsgType(), messageTemplate.getTitle(),
messageTemplate.getPicUrl(), messageTemplate.getDescription(), messageTemplate.getLinkUrl()); messageTemplate.getPicUrl(), messageTemplate.getDescription(), messageTemplate.getLinkUrl());
attachments.add(links); attachments.add(links);
} else if (ObjectUtil.equal("miniprogram", messageTemplate.getMsgType())) { } else if (ObjectUtil.equal(MessageType.MINIPROGRAM.getMessageType(), messageTemplate.getMsgType())) {
Attachments miniprograms = new Miniprograms(messageTemplate.getMsgType(), messageTemplate.getTitle(), Attachments miniprograms = new Miniprograms(messageTemplate.getMsgType(), messageTemplate.getTitle(),
messageTemplate.getMediaId(), messageTemplate.getAppId(), messageTemplate.getLinkUrl()); messageTemplate.getMediaId(), messageTemplate.getAppId(), messageTemplate.getLinkUrl());
attachments.add(miniprograms); attachments.add(miniprograms);
} else if (ObjectUtil.equal("video", messageTemplate.getMsgType())) { } else if (ObjectUtil.equal(MessageType.VIDEO.getMessageType(), messageTemplate.getMsgType())) {
Attachments videos = new Videos(messageTemplate.getMsgType(), messageTemplate.getMediaId()); Attachments videos = new Videos(messageTemplate.getMsgType(), messageTemplate.getMediaId());
attachments.add(videos); attachments.add(videos);
} else if (ObjectUtil.equal("file", messageTemplate.getMsgType())) { } else if (ObjectUtil.equal(MessageType.FILE.getMessageType(), messageTemplate.getMsgType())) {
Attachments files = new Files(messageTemplate.getMsgType(), messageTemplate.getMediaId()); Attachments files = new Files(messageTemplate.getMsgType(), messageTemplate.getMediaId());
attachments.add(files); attachments.add(files);
} }
......
...@@ -14,10 +14,10 @@ import lombok.Data; ...@@ -14,10 +14,10 @@ import lombok.Data;
public class WeGetGroupMsgListQuery { public class WeGetGroupMsgListQuery {
@ApiModelProperty("群发消息的id") @ApiModelProperty("群发消息的id")
private String msgId; private String msgid;
@ApiModelProperty("发送成员userid") @ApiModelProperty("发送成员userid")
private String userId; private String userid;
@ApiModelProperty("返回的最大记录数,整型,最大值1000,默认值500") @ApiModelProperty("返回的最大记录数,整型,最大值1000,默认值500")
private Integer limit; private Integer limit;
......
package com.linkwechat.wecom.domain.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.linkwechat.wecom.domain.WeGroupMessageAttachments;
import com.linkwechat.wecom.domain.WeGroupMessageSendResult;
import com.linkwechat.wecom.domain.WeGroupMessageTask;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* @author danmo
* @description 群发详情出参
* @date 2021/10/23 15:09
**/
@ApiModel
@Data
public class WeGroupMessageDetailVo {
@ApiModelProperty("发送内容")
private String content;
@ApiModelProperty("发送类型")
private Integer chatType;
@ApiModelProperty("发送时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date sendTime;
/**
* 附件
*/
@ApiModelProperty("附件")
private List<WeGroupMessageAttachments> attachments;
/**
* 待发送者列表
*/
@ApiModelProperty("待发送者列表")
private List<WeGroupMessageTaskVo> toBeSentList;
/**
* 已发送者列表
*/
@ApiModelProperty("已发送者列表")
private List<WeGroupMessageTaskVo> alreadySentList;
}
package com.linkwechat.wecom.domain.vo;
import com.linkwechat.wecom.domain.WeGroupMessageAttachments;
import com.linkwechat.wecom.domain.WeGroupMessageSendResult;
import com.linkwechat.wecom.domain.WeGroupMessageTask;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author danmo
* @description 群发详情出参
* @date 2021/10/23 15:09
**/
@ApiModel
@Data
public class WeGroupMessageListVo {
private String msgTemplateId;
/**
* 附件
*/
@ApiModelProperty("附件")
private List<WeGroupMessageAttachments> attachments;
/**
* 发送者
*/
@ApiModelProperty("发送者信息")
private List<WeGroupMessageTask> senders;
/**
* 发送客户
*/
@ApiModelProperty("接收者信息")
private List<WeGroupMessageSendResult> extralInfos;
}
package com.linkwechat.wecom.domain.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.linkwechat.common.annotation.Excel;
import com.linkwechat.wecom.domain.WeGroupMessageAttachments;
import com.linkwechat.wecom.domain.WeGroupMessageSendResult;
import com.linkwechat.wecom.domain.WeGroupMessageTask;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* @author danmo
* @description 群发成员任务出参
* @date 2021/10/23 15:09
**/
@ApiModel
@Data
public class WeGroupMessageTaskVo {
/**
* 企业服务人员的userid
*/
@ApiModelProperty("企业服务人员的userid")
private String userId;
/**
* 企业服务人员的名称
*/
@ApiModelProperty("企业服务人员的名称")
private String userName;
/**
* 发送时间
*/
@ApiModelProperty("发送时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date sendTime;
/**
* 发送客户列表
*/
@ApiModelProperty("发送客户列表")
private List<String> customerList;
/**
* 发送群列表
*/
@ApiModelProperty("发送群列表")
private List<String> groupList;
}
...@@ -9,7 +9,8 @@ import lombok.Data; ...@@ -9,7 +9,8 @@ import lombok.Data;
*/ */
@Data @Data
public class WeLeaveUserInfoAllocateVo { public class WeLeaveUserInfoAllocateVo {
//移交人
private String handoverUserid; private String handoverUserid;
//接管人
private String takeoverUserid; private String takeoverUserid;
} }
...@@ -19,7 +19,6 @@ import java.util.List; ...@@ -19,7 +19,6 @@ import java.util.List;
@NoArgsConstructor @NoArgsConstructor
public class WeMakeCustomerTag { public class WeMakeCustomerTag {
private String externalUserid; private String externalUserid;
private Long flowerCustomerRelId;
private String userId; private String userId;
private List<WeTag> addTag; private List<WeTag> addTag;
......
package com.linkwechat.wecom.factory.impl.customer; package com.linkwechat.wecom.factory.impl.customer;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.FileUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.linkwechat.common.config.CosConfig;
import com.linkwechat.common.constant.WeConstans; import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.enums.MediaType; import com.linkwechat.common.enums.MediaType;
import com.linkwechat.common.utils.StringUtils; import com.linkwechat.common.utils.StringUtils;
...@@ -19,12 +19,10 @@ import com.linkwechat.wecom.service.*; ...@@ -19,12 +19,10 @@ import com.linkwechat.wecom.service.*;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors;
/** /**
* @author danmo * @author danmo
...@@ -40,8 +38,7 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy { ...@@ -40,8 +38,7 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy {
private IWeEmpleCodeTagService weEmpleCodeTagService; private IWeEmpleCodeTagService weEmpleCodeTagService;
@Autowired @Autowired
private IWeEmpleCodeService weEmpleCodeService; private IWeEmpleCodeService weEmpleCodeService;
@Autowired
private IWeFlowerCustomerRelService weFlowerCustomerRelService;
@Autowired @Autowired
private IWeFlowerCustomerTagRelService weFlowerCustomerTagRelService; private IWeFlowerCustomerTagRelService weFlowerCustomerTagRelService;
@Autowired @Autowired
...@@ -66,10 +63,6 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy { ...@@ -66,10 +63,6 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy {
@Override @Override
public void eventHandle(WxCpXmlMessageVO message) { public void eventHandle(WxCpXmlMessageVO message) {
if (message.getExternalUserId() != null) { if (message.getExternalUserId() != null) {
WeFlowerCustomerRel weFlowerCustomerRel = weFlowerCustomerRelService.getOne(new LambdaQueryWrapper<WeFlowerCustomerRel>()
.eq(WeFlowerCustomerRel::getExternalUserid, message.getExternalUserId())
.eq(WeFlowerCustomerRel::getUserId,message.getUserId()));
weFlowerCustomerRelThreadLocal.set(weFlowerCustomerRel);
weCustomerService.getCustomersInfoAndSynchWeCustomer(message.getExternalUserId(),message.getUserId()); weCustomerService.getCustomersInfoAndSynchWeCustomer(message.getExternalUserId(),message.getUserId());
} }
...@@ -146,30 +139,19 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy { ...@@ -146,30 +139,19 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy {
//查询活码对应标签 //查询活码对应标签
List<WeEmpleCodeTag> tagList = weEmpleCodeTagService.list(new LambdaQueryWrapper<WeEmpleCodeTag>() List<WeEmpleCodeTag> tagList = weEmpleCodeTagService.list(new LambdaQueryWrapper<WeEmpleCodeTag>()
.eq(WeEmpleCodeTag::getEmpleCodeId, messageMap.getEmpleCodeId())); .eq(WeEmpleCodeTag::getEmpleCodeId, messageMap.getEmpleCodeId()));
if(CollectionUtil.isNotEmpty(tagList)){
//查询外部联系人与通讯录关系数据
WeFlowerCustomerRel weFlowerCustomerRel = weFlowerCustomerRelService
.getOne(new LambdaQueryWrapper<WeFlowerCustomerRel>()
.eq(WeFlowerCustomerRel::getUserId, userId)
.eq(WeFlowerCustomerRel::getExternalUserid, externalUserId));
//为外部联系人添加员工活码标签
List<WeFlowerCustomerTagRel> weFlowerCustomerTagRels = new ArrayList<>(); List<WeFlowerCustomerTagRel> weFlowerCustomerTagRels = new ArrayList<>();
Optional.ofNullable(weFlowerCustomerRel).ifPresent(weFlowerCustomerRel1 -> {
Optional.ofNullable(tagList).orElseGet(ArrayList::new).forEach(tag -> {
tagList.stream().forEach(k->{
weFlowerCustomerTagRels.add( weFlowerCustomerTagRels.add(
WeFlowerCustomerTagRel.builder() WeFlowerCustomerTagRel.builder()
.flowerCustomerRelId(weFlowerCustomerRel.getId()) .tagId(k.getTagId())
.userId(userId)
.externalUserid(externalUserId) .externalUserid(externalUserId)
.tagId(tag.getTagId()) .userId(userId)
.createTime(new Date()) .createTime(new Date())
.relTagType(new Integer(1))
.build() .build()
); );
}); });
if(weFlowerCustomerTagRelService.saveOrUpdateBatch(weFlowerCustomerTagRels)){ if(weFlowerCustomerTagRelService.saveOrUpdateBatch(weFlowerCustomerTagRels)){
...@@ -181,8 +163,9 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy { ...@@ -181,8 +163,9 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy {
.map(WeFlowerCustomerTagRel::getTagId).toArray(String[]::new)) .map(WeFlowerCustomerTagRel::getTagId).toArray(String[]::new))
.build()); .build());
} }
}
});
// 发送欢迎语 // 发送欢迎语
log.debug(">>>>>>>>>欢迎语查询结果:{}", JSONObject.toJSONString(messageMap)); log.debug(">>>>>>>>>欢迎语查询结果:{}", JSONObject.toJSONString(messageMap));
......
package com.linkwechat.wecom.factory.impl.customer; package com.linkwechat.wecom.factory.impl.customer;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.linkwechat.common.enums.MediaType; import com.linkwechat.common.enums.MediaType;
...@@ -37,8 +38,7 @@ public class WeCallBackAddHalfExternalContactImpl extends WeEventStrategy { ...@@ -37,8 +38,7 @@ public class WeCallBackAddHalfExternalContactImpl extends WeEventStrategy {
private IWeEmpleCodeTagService weEmpleCodeTagService; private IWeEmpleCodeTagService weEmpleCodeTagService;
@Autowired @Autowired
private IWeEmpleCodeService weEmpleCodeService; private IWeEmpleCodeService weEmpleCodeService;
@Autowired
private IWeFlowerCustomerRelService weFlowerCustomerRelService;
@Autowired @Autowired
private IWeFlowerCustomerTagRelService weFlowerCustomerTagRelService; private IWeFlowerCustomerTagRelService weFlowerCustomerTagRelService;
@Autowired @Autowired
...@@ -59,24 +59,25 @@ public class WeCallBackAddHalfExternalContactImpl extends WeEventStrategy { ...@@ -59,24 +59,25 @@ public class WeCallBackAddHalfExternalContactImpl extends WeEventStrategy {
//查询活码对应标签 //查询活码对应标签
List<WeEmpleCodeTag> tagList = weEmpleCodeTagService.list(new LambdaQueryWrapper<WeEmpleCodeTag>() List<WeEmpleCodeTag> tagList = weEmpleCodeTagService.list(new LambdaQueryWrapper<WeEmpleCodeTag>()
.eq(WeEmpleCodeTag::getEmpleCodeId, empleCodeId)); .eq(WeEmpleCodeTag::getEmpleCodeId, empleCodeId));
//查询外部联系人与通讯录关系数据 //客户添加活码标签
WeFlowerCustomerRel weFlowerCustomerRel = weFlowerCustomerRelService.getOne(new LambdaQueryWrapper<WeFlowerCustomerRel>() if(CollectionUtil.isNotEmpty(tagList)){
.eq(WeFlowerCustomerRel::getUserId, message.getUserId())
.eq(WeFlowerCustomerRel::getExternalUserid, message.getExternalUserId()));
//为外部联系人添加员工活码标签
List<WeFlowerCustomerTagRel> weFlowerCustomerTagRels = new ArrayList<>(); List<WeFlowerCustomerTagRel> weFlowerCustomerTagRels = new ArrayList<>();
Optional.ofNullable(weFlowerCustomerRel).ifPresent(weFlowerCustomerRel1 -> { tagList.stream().forEach(k->{
Optional.ofNullable(tagList).orElseGet(ArrayList::new).forEach(tag ->{
weFlowerCustomerTagRels.add( weFlowerCustomerTagRels.add(
WeFlowerCustomerTagRel.builder() WeFlowerCustomerTagRel.builder()
.flowerCustomerRelId(weFlowerCustomerRel.getId()) .tagId(k.getTagId())
.tagId(tag.getTagId()) .externalUserid( message.getUserId())
.userId(message.getExternalUserId())
.createTime(new Date()) .createTime(new Date())
.build() .build()
); );
}); });
weFlowerCustomerTagRelService.saveOrUpdateBatch(weFlowerCustomerTagRels); weFlowerCustomerTagRelService.saveOrUpdateBatch(weFlowerCustomerTagRels);
}); }
log.debug(">>>>>>>>>欢迎语查询结果:{}", JSONObject.toJSONString(messageMap)); log.debug(">>>>>>>>>欢迎语查询结果:{}", JSONObject.toJSONString(messageMap));
if (messageMap != null) { if (messageMap != null) {
if (StringUtils.isNotEmpty(messageMap.getWelcomeMsg())){ if (StringUtils.isNotEmpty(messageMap.getWelcomeMsg())){
......
package com.linkwechat.wecom.factory.impl.customer; package com.linkwechat.wecom.factory.impl.customer;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.linkwechat.wecom.domain.WeCustomer; import com.linkwechat.wecom.domain.WeCustomer;
import com.linkwechat.wecom.domain.WeSensitiveAct; import com.linkwechat.wecom.domain.WeSensitiveAct;
import com.linkwechat.wecom.domain.WeSensitiveActHit; import com.linkwechat.wecom.domain.WeSensitiveActHit;
...@@ -7,7 +8,6 @@ import com.linkwechat.wecom.domain.WeUser; ...@@ -7,7 +8,6 @@ import com.linkwechat.wecom.domain.WeUser;
import com.linkwechat.wecom.domain.vo.WxCpXmlMessageVO; import com.linkwechat.wecom.domain.vo.WxCpXmlMessageVO;
import com.linkwechat.wecom.factory.WeEventStrategy; import com.linkwechat.wecom.factory.WeEventStrategy;
import com.linkwechat.wecom.service.IWeCustomerService; import com.linkwechat.wecom.service.IWeCustomerService;
import com.linkwechat.wecom.service.IWeFlowerCustomerRelService;
import com.linkwechat.wecom.service.IWeSensitiveActHitService; import com.linkwechat.wecom.service.IWeSensitiveActHitService;
import com.linkwechat.wecom.service.IWeUserService; import com.linkwechat.wecom.service.IWeUserService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -26,8 +26,7 @@ import java.util.Date; ...@@ -26,8 +26,7 @@ import java.util.Date;
public class WeCallBackDelExternalContactImpl extends WeEventStrategy { public class WeCallBackDelExternalContactImpl extends WeEventStrategy {
@Autowired @Autowired
private IWeCustomerService weCustomerService; private IWeCustomerService weCustomerService;
@Autowired
private IWeFlowerCustomerRelService weFlowerCustomerRelService;
@Autowired @Autowired
private IWeSensitiveActHitService weSensitiveActHitService; private IWeSensitiveActHitService weSensitiveActHitService;
@Autowired @Autowired
...@@ -36,9 +35,11 @@ public class WeCallBackDelExternalContactImpl extends WeEventStrategy { ...@@ -36,9 +35,11 @@ public class WeCallBackDelExternalContactImpl extends WeEventStrategy {
@Override @Override
public void eventHandle(WxCpXmlMessageVO message) { public void eventHandle(WxCpXmlMessageVO message) {
if (message.getExternalUserId() != null) { if (message.getExternalUserId() != null) {
//weCustomerService.deleteCustomersByEid(message.getExternalUserId());
weFlowerCustomerRelService.deleteFollowUser(message.getUserId(), message.getExternalUserId());
//删除客户
if(weCustomerService.remove(new LambdaQueryWrapper<WeCustomer>()
.eq(WeCustomer::getExternalUserid,message.getExternalUserId())
.eq(WeCustomer::getFirstUserId,message.getUserId()))){
//增加敏感行为记录,员工删除客户 //增加敏感行为记录,员工删除客户
WeSensitiveAct weSensitiveAct = weSensitiveActHitService.getSensitiveActType("拉黑/删除好友"); WeSensitiveAct weSensitiveAct = weSensitiveActHitService.getSensitiveActType("拉黑/删除好友");
if (weSensitiveAct != null && weSensitiveAct.getEnableFlag() == 1) { if (weSensitiveAct != null && weSensitiveAct.getEnableFlag() == 1) {
...@@ -56,6 +57,9 @@ public class WeCallBackDelExternalContactImpl extends WeEventStrategy { ...@@ -56,6 +57,9 @@ public class WeCallBackDelExternalContactImpl extends WeEventStrategy {
weSensitiveActHit.setOperateTarget(weCustomer.getName()); weSensitiveActHit.setOperateTarget(weCustomer.getName());
weSensitiveActHitService.insertWeSensitiveActHit(weSensitiveActHit); weSensitiveActHitService.insertWeSensitiveActHit(weSensitiveActHit);
} }
}
} }
} }
} }
package com.linkwechat.wecom.factory.impl.customer; package com.linkwechat.wecom.factory.impl.customer;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.linkwechat.common.constant.WeConstans; import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.core.domain.entity.WeCorpAccount; import com.linkwechat.common.core.domain.entity.WeCorpAccount;
import com.linkwechat.common.enums.MessageType; import com.linkwechat.common.enums.MessageType;
...@@ -29,8 +30,6 @@ public class WeCallBackDelFollowUserImpl extends WeEventStrategy { ...@@ -29,8 +30,6 @@ public class WeCallBackDelFollowUserImpl extends WeEventStrategy {
@Autowired @Autowired
private IWeCustomerService weCustomerService; private IWeCustomerService weCustomerService;
@Autowired @Autowired
private IWeFlowerCustomerRelService weFlowerCustomerRelService;
@Autowired
private IWeCorpAccountService weCorpAccountService; private IWeCorpAccountService weCorpAccountService;
@Autowired @Autowired
private WeMessagePushClient weMessagePushClient; private WeMessagePushClient weMessagePushClient;
...@@ -43,7 +42,11 @@ public class WeCallBackDelFollowUserImpl extends WeEventStrategy { ...@@ -43,7 +42,11 @@ public class WeCallBackDelFollowUserImpl extends WeEventStrategy {
public void eventHandle(WxCpXmlMessageVO message) { public void eventHandle(WxCpXmlMessageVO message) {
try { try {
if (message.getUserId() != null && message.getExternalUserId() != null) { if (message.getUserId() != null && message.getExternalUserId() != null) {
weFlowerCustomerRelService.deleteFollowUser(message.getUserId(), message.getExternalUserId());
if(weCustomerService.remove(new LambdaQueryWrapper<WeCustomer>()
.eq(WeCustomer::getExternalUserid,message.getExternalUserId())
.eq(WeCustomer::getFirstUserId,message.getUserId()))){
WeCorpAccount validWeCorpAccount = weCorpAccountService.findValidWeCorpAccount(); WeCorpAccount validWeCorpAccount = weCorpAccountService.findValidWeCorpAccount();
Optional.ofNullable(validWeCorpAccount).ifPresent(weCorpAccount -> { Optional.ofNullable(validWeCorpAccount).ifPresent(weCorpAccount -> {
String customerChurnNoticeSwitch = weCorpAccount.getCustomerChurnNoticeSwitch(); String customerChurnNoticeSwitch = weCorpAccount.getCustomerChurnNoticeSwitch();
...@@ -80,10 +83,11 @@ public class WeCallBackDelFollowUserImpl extends WeEventStrategy { ...@@ -80,10 +83,11 @@ public class WeCallBackDelFollowUserImpl extends WeEventStrategy {
} }
} }
}); });
}
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); log.error("删除跟进成员事件>>>>>>>>>>>>>param:{},ex:{}", JSONObject.toJSONString(message), e);
log.error("del_follow_user>>>>>>>>>>>>>param:{},ex:{}", JSONObject.toJSONString(message), e);
} }
} }
} }
package com.linkwechat.wecom.factory.impl.tag; package com.linkwechat.wecom.factory.impl.tag;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.linkwechat.wecom.domain.WeFlowerCustomerRel; import com.linkwechat.wecom.domain.WeCustomer;
import com.linkwechat.wecom.domain.WeFlowerCustomerTagRel; import com.linkwechat.wecom.domain.WeFlowerCustomerTagRel;
import com.linkwechat.wecom.domain.vo.WxCpXmlMessageVO; import com.linkwechat.wecom.domain.vo.WxCpXmlMessageVO;
import com.linkwechat.wecom.factory.WeEventStrategy; import com.linkwechat.wecom.factory.WeEventStrategy;
import com.linkwechat.wecom.service.IWeFlowerCustomerRelService; import com.linkwechat.wecom.service.IWeCustomerService;
import com.linkwechat.wecom.service.IWeFlowerCustomerTagRelService; import com.linkwechat.wecom.service.IWeFlowerCustomerTagRelService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -27,8 +25,10 @@ import java.util.stream.Collectors; ...@@ -27,8 +25,10 @@ import java.util.stream.Collectors;
public class WeCallBackUpdateUserTagImpl extends WeEventStrategy { public class WeCallBackUpdateUserTagImpl extends WeEventStrategy {
@Autowired @Autowired
private IWeFlowerCustomerTagRelService weFlowerCustomerTagRelService; private IWeFlowerCustomerTagRelService weFlowerCustomerTagRelService;
@Autowired @Autowired
private IWeFlowerCustomerRelService weFlowerCustomerRelService; private IWeCustomerService iWeCustomerService;
@Override @Override
public void eventHandle(WxCpXmlMessageVO message) { public void eventHandle(WxCpXmlMessageVO message) {
...@@ -37,46 +37,40 @@ public class WeCallBackUpdateUserTagImpl extends WeEventStrategy { ...@@ -37,46 +37,40 @@ public class WeCallBackUpdateUserTagImpl extends WeEventStrategy {
//标签中新增的成员userid列表,用逗号分隔 //标签中新增的成员userid列表,用逗号分隔
List<String> addUserItemsList = Arrays.stream(Optional.ofNullable(message.getAddUserItems()) List<String> addUserItemsList = Arrays.stream(Optional.ofNullable(message.getAddUserItems())
.orElse("").split(",")).collect(Collectors.toList()); .orElse("").split(",")).collect(Collectors.toList());
//标签中删除的成员userid列表,用逗号分隔 if(CollectionUtil.isNotEmpty(addUserItemsList)){
List<String> delUserItemsList = Arrays.stream(Optional.ofNullable(message.getDelUserItems())
.orElse("").split(",")).collect(Collectors.toList()); //获取员工对应的所有客户
List<WeCustomer> weCustomers = iWeCustomerService.list(new LambdaQueryWrapper<WeCustomer>()
.in(WeCustomer::getFirstUserId, addUserItemsList));
//标签中新增的成员userid列表,建立关联 if(CollectionUtil.isNotEmpty(weCustomers)){
List<WeFlowerCustomerTagRel> weFlowerCustomerTagRels = new ArrayList<>(); List<WeFlowerCustomerTagRel> weFlowerCustomerTagRels = new ArrayList<>();
LambdaQueryWrapper<WeFlowerCustomerRel> relLambdaQueryWrapper = new LambdaQueryWrapper<>(); weCustomers.stream().forEach(k->{
relLambdaQueryWrapper.in(WeFlowerCustomerRel::getUserId, addUserItemsList); weFlowerCustomerTagRels.add(
List<WeFlowerCustomerRel> flowerCustomerRelList = weFlowerCustomerRelService.list(relLambdaQueryWrapper); WeFlowerCustomerTagRel.builder()
List<Long> idList = Optional.ofNullable(flowerCustomerRelList).orElseGet(ArrayList::new) .userId(k.getFirstUserId())
.stream().map(WeFlowerCustomerRel::getId).collect(Collectors.toList()); .externalUserid(k.getExternalUserid())
idList.forEach(id -> {
weFlowerCustomerTagRels.add(WeFlowerCustomerTagRel.builder().flowerCustomerRelId(id)
.tagId(tagId) .tagId(tagId)
.build()); .createTime(new Date())
.build()
);
}); });
weFlowerCustomerTagRelService.batchInsetWeFlowerCustomerTagRel(weFlowerCustomerTagRels); weFlowerCustomerTagRelService.batchAddOrUpdate(weFlowerCustomerTagRels);
}
}
//当前标签对应成员列表
LambdaQueryWrapper<WeFlowerCustomerTagRel> tagRelLambdaQueryWrapper = new LambdaQueryWrapper<>();
tagRelLambdaQueryWrapper.eq(WeFlowerCustomerTagRel::getTagId, tagId);
List<WeFlowerCustomerTagRel> tagRelList = weFlowerCustomerTagRelService.list(tagRelLambdaQueryWrapper);
List<Long> flowerCustomerRelIdList = Optional.ofNullable(tagRelList).orElseGet(ArrayList::new) //标签中删除的成员userid列表,用逗号分隔
.stream().map(WeFlowerCustomerTagRel::getFlowerCustomerRelId).collect(Collectors.toList()); List<String> delUserItemsList = Arrays.stream(Optional.ofNullable(message.getDelUserItems())
.orElse("").split(",")).collect(Collectors.toList());
if (!flowerCustomerRelIdList.isEmpty()) { if(CollectionUtil.isNotEmpty(delUserItemsList)){
LambdaQueryWrapper<WeFlowerCustomerRel> queryWrapper = new LambdaQueryWrapper<>(); weFlowerCustomerTagRelService.remove(new LambdaQueryWrapper<WeFlowerCustomerTagRel>()
queryWrapper.in(WeFlowerCustomerRel::getId, flowerCustomerRelIdList) .in(WeFlowerCustomerTagRel::getTagId,delUserItemsList));
.in(WeFlowerCustomerRel::getUserId, delUserItemsList);
List<WeFlowerCustomerRel> relList = weFlowerCustomerRelService.list(queryWrapper);
List<Long> relIdList = Optional.ofNullable(relList).orElseGet(ArrayList::new)
.stream().map(WeFlowerCustomerRel::getId).collect(Collectors.toList());
//标签中删除的成员userid列表
LambdaQueryWrapper<WeFlowerCustomerTagRel> tagRelQueryWrapper = new LambdaQueryWrapper<>();
tagRelQueryWrapper.in(WeFlowerCustomerTagRel::getFlowerCustomerRelId, relIdList);
weFlowerCustomerTagRelService.remove(tagRelQueryWrapper);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage()); log.error(e.getMessage());
} }
} }
......
package com.linkwechat.wecom.handler;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.core.redis.RedisCache;
import com.linkwechat.common.enums.MessageType;
import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.wecom.client.WeCustomerMessagePushClient;
import com.linkwechat.wecom.domain.WeGroupMessageList;
import com.linkwechat.wecom.domain.WeGroupMessageTemplate;
import com.linkwechat.wecom.domain.WeMessageTemplate;
import com.linkwechat.wecom.domain.dto.WeMediaDto;
import com.linkwechat.wecom.domain.dto.message.SendMessageResultDto;
import com.linkwechat.wecom.domain.query.WeAddGroupMessageQuery;
import com.linkwechat.wecom.domain.query.WeAddMsgTemplateQuery;
import com.linkwechat.wecom.service.IWeGroupMessageListService;
import com.linkwechat.wecom.service.IWeGroupMessageTemplateService;
import com.linkwechat.wecom.service.IWeMaterialService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.data.redis.core.ZSetOperations;
import org.springframework.stereotype.Component;
import java.util.*;
import java.util.concurrent.atomic.AtomicLong;
/**
* @author danmo
* @description 群发任务发送执行器
* @date 2021/10/29 11:43
**/
@Slf4j
@Component
public class WeGroupMessageTaskHandler implements ApplicationRunner {
@Autowired
private IWeGroupMessageListService groupMessageListService;
@Autowired
private IWeGroupMessageTemplateService groupMessageTemplateService;
@Autowired
private WeCustomerMessagePushClient customerMessagePushClient;
@Autowired
private IWeMaterialService weMaterialService;
@Autowired
private RedisCache redisCache;
private AtomicLong templateId;
@Override
public void run(ApplicationArguments args) {
ThreadUtil.execute(this::groupMessageTaskHandler);
}
public void groupMessageTaskHandler() {
while (WeConstans.WEGROUPMSGTIMEDTASK_SWITCH) {
try {
Set<ZSetOperations.TypedTuple<String>> typedTuples = redisCache.rangeWithScore(WeConstans.WEGROUPMSGTIMEDTASK_KEY, 0, 0);
Optional.ofNullable(typedTuples).orElseGet(HashSet::new).forEach(item -> {
long score = Objects.requireNonNull(item.getScore()).longValue();
if (score < System.currentTimeMillis()) {
try {
//当时间小于当前时间时删除第一个记录,并发送群发消息
log.info("获取到消息,执行群发任务: {}", item.getValue());
WeAddGroupMessageQuery query = JSONObject.parseObject(item.getValue(), WeAddGroupMessageQuery.class);
if (query != null) {
templateId = new AtomicLong(query.getId());
Optional.of(query).map(WeAddGroupMessageQuery::getSenderList).orElseGet(ArrayList::new).forEach(sender -> {
WeAddMsgTemplateQuery templateQuery = new WeAddMsgTemplateQuery();
templateQuery.setChat_type(query.getChatType());
templateQuery.setSender(sender.getUserId());
if (ObjectUtil.equal(1, query.getChatType())) {
templateQuery.setExternal_userid(sender.getCustomerList());
}
getMediaId(query.getAttachmentsList());
templateQuery.setAttachments(query.getAttachmentsList());
if (StringUtils.isNotEmpty(query.getContent())) {
WeAddMsgTemplateQuery.Text text = new WeAddMsgTemplateQuery.Text();
text.setContent(query.getContent());
templateQuery.setText(text);
}
SendMessageResultDto resultDto = customerMessagePushClient.addMsgTemplate(templateQuery);
if (resultDto != null && ObjectUtil.equal(WeConstans.WE_SUCCESS_CODE, resultDto.getErrcode())) {
String msgid = resultDto.getMsgid();
Long msgTemplateId = query.getId();
WeGroupMessageList messageList = new WeGroupMessageList();
messageList.setMsgId(msgid);
groupMessageListService.update(messageList, new LambdaQueryWrapper<WeGroupMessageList>()
.eq(WeGroupMessageList::getMsgTemplateId, msgTemplateId)
.eq(WeGroupMessageList::getUserId, sender.getUserId()));
}
});
}
} finally {
redisCache.removeRangeCacheZSet(WeConstans.WEGROUPMSGTIMEDTASK_KEY, 0, 0);
}
}
});
} catch (Exception e) {
e.printStackTrace();
//任务异常修改模板状态为失败
if (templateId != null) {
WeGroupMessageTemplate template = new WeGroupMessageTemplate();
template.setId(templateId.get());
template.setStatus(-1);
groupMessageTemplateService.updateById(template);
}
}
}
}
void getMediaId(List<WeMessageTemplate> messageTemplates){
Optional.ofNullable(messageTemplates).orElseGet(ArrayList::new).forEach(messageTemplate -> {
if (ObjectUtil.equal(MessageType.IMAGE.getMessageType(), messageTemplate.getMsgType())) {
WeMediaDto weMedia = weMaterialService.uploadTemporaryMaterial(messageTemplate.getMediaId()
,MessageType.IMAGE.getMessageType()
,FileUtil.getName(messageTemplate.getMediaId()));
messageTemplate.setMediaId(weMedia.getMedia_id());
}else if (ObjectUtil.equal(MessageType.MINIPROGRAM.getMessageType(), messageTemplate.getMsgType())) {
WeMediaDto weMedia = weMaterialService.uploadTemporaryMaterial(messageTemplate.getMediaId()
,MessageType.IMAGE.getMessageType()
,FileUtil.getName(messageTemplate.getMediaId()));
messageTemplate.setMediaId(weMedia.getMedia_id());
} else if (ObjectUtil.equal(MessageType.VIDEO.getMessageType(), messageTemplate.getMsgType())) {
WeMediaDto weMedia = weMaterialService.uploadTemporaryMaterial(messageTemplate.getMediaId()
,MessageType.IMAGE.getMessageType()
,FileUtil.getName(messageTemplate.getMediaId()));
messageTemplate.setMediaId(weMedia.getMedia_id());
} else if (ObjectUtil.equal(MessageType.FILE.getMessageType(), messageTemplate.getMsgType())) {
WeMediaDto weMedia = weMaterialService.uploadTemporaryMaterial(messageTemplate.getMediaId()
,MessageType.IMAGE.getMessageType()
,FileUtil.getName(messageTemplate.getMediaId()));
messageTemplate.setMediaId(weMedia.getMedia_id());
}
});
}
}
...@@ -137,4 +137,8 @@ public interface WeCustomerMapper extends BaseMapper<WeCustomer> ...@@ -137,4 +137,8 @@ public interface WeCustomerMapper extends BaseMapper<WeCustomer>
List<CusertomerBelongUserInfo> findCusertomerBelongUserInfo(@Param("externalUserId") String externalUserId); List<CusertomerBelongUserInfo> findCusertomerBelongUserInfo(@Param("externalUserId") String externalUserId);
void batchAddOrUpdate(@Param("weCustomers") List<WeCustomer> weCustomer);
} }
...@@ -3,7 +3,9 @@ package com.linkwechat.wecom.mapper; ...@@ -3,7 +3,9 @@ package com.linkwechat.wecom.mapper;
import java.util.List; import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linkwechat.wecom.domain.WeCustomer;
import com.linkwechat.wecom.domain.WeFlowerCustomerTagRel; import com.linkwechat.wecom.domain.WeFlowerCustomerTagRel;
import org.apache.ibatis.annotations.Param;
/** /**
* 客户标签关系Mapper接口 * 客户标签关系Mapper接口
...@@ -68,4 +70,7 @@ public interface WeFlowerCustomerTagRelMapper extends BaseMapper<WeFlowerCustom ...@@ -68,4 +70,7 @@ public interface WeFlowerCustomerTagRelMapper extends BaseMapper<WeFlowerCustom
* @return * @return
*/ */
public int batchInsetWeFlowerCustomerTagRel(List<WeFlowerCustomerTagRel> weFlowerCustomerTagRels); public int batchInsetWeFlowerCustomerTagRel(List<WeFlowerCustomerTagRel> weFlowerCustomerTagRels);
void batchAddOrUpdate(@Param("tagRels") List<WeFlowerCustomerTagRel> tagRels);
} }
package com.linkwechat.wecom.mapper; package com.linkwechat.wecom.mapper;
import com.linkwechat.wecom.domain.WeGroupMessageList;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linkwechat.wecom.domain.WeGroupMessageList;
import com.linkwechat.wecom.domain.vo.WeGroupMessageListVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* 群发消息列Mapper接口 * 群发消息列Mapper接口
...@@ -11,4 +15,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; ...@@ -11,4 +15,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/ */
public interface WeGroupMessageListMapper extends BaseMapper<WeGroupMessageList> { public interface WeGroupMessageListMapper extends BaseMapper<WeGroupMessageList> {
/**
* 查询群发消息详情
* @param msgTemplateIds 消息模板id列表
* @return
*/
List<WeGroupMessageListVo> getGroupMsgDetails(@Param("msgTemplateIds") List<Long> msgTemplateIds);
} }
package com.linkwechat.wecom.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linkwechat.wecom.domain.WeGroupMessageTask;
/**
* 群发消息成员发送任务表Mapper接口
*
* @author ruoyi
* @date 2021-10-19
*/
public interface WeGroupMessageTaskMapper extends BaseMapper<WeGroupMessageTask> {
}
package com.linkwechat.wecom.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linkwechat.wecom.domain.WeGroupMessageTemplate;
/**
* 群发消息模板Mapper接口
*
* @author ruoyi
* @date 2021-10-27
*/
public interface WeGroupMessageTemplateMapper extends BaseMapper<WeGroupMessageTemplate> {
}
package com.linkwechat.wecom.service; package com.linkwechat.wecom.service;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.linkwechat.wecom.domain.WeCustomer; import com.linkwechat.wecom.domain.WeCustomer;
import com.linkwechat.wecom.domain.WeCustomerList; import com.linkwechat.wecom.domain.WeCustomerList;
...@@ -67,11 +68,11 @@ public interface IWeCustomerService extends IService<WeCustomer> ...@@ -67,11 +68,11 @@ public interface IWeCustomerService extends IService<WeCustomer>
public void makeLabel(WeMakeCustomerTag weMakeCustomerTag); public void makeLabel(WeMakeCustomerTag weMakeCustomerTag);
/** // /**
* 移除客户标签 // * 移除客户标签
* @param weMakeCustomerTag // * @param weMakeCustomerTag
*/ // */
public void removeLabel(WeMakeCustomerTag weMakeCustomerTag); // public void removeLabel(WeMakeCustomerTag weMakeCustomerTag);
/** /**
...@@ -88,11 +89,7 @@ public interface IWeCustomerService extends IService<WeCustomer> ...@@ -88,11 +89,7 @@ public interface IWeCustomerService extends IService<WeCustomer>
*/ */
public void getCustomersInfoAndSynchWeCustomer(String externalUserid,String userId); public void getCustomersInfoAndSynchWeCustomer(String externalUserid,String userId);
/**
* 删除客户
* @param externalUserid
*/
public void deleteCustomersByEid(String externalUserid);
/** /**
* 向客户发送欢迎语 * 向客户发送欢迎语
...@@ -106,12 +103,7 @@ public interface IWeCustomerService extends IService<WeCustomer> ...@@ -106,12 +103,7 @@ public interface IWeCustomerService extends IService<WeCustomer>
*/ */
public boolean updateCustomerChatStatus(String externalUserId); public boolean updateCustomerChatStatus(String externalUserId);
/**
* 通过标签查询客户列表
* @param ids 标签id
* @return
*/
public List<WeUser> getCustomerByTag(List<String> ids);
...@@ -158,8 +150,9 @@ public interface IWeCustomerService extends IService<WeCustomer> ...@@ -158,8 +150,9 @@ public interface IWeCustomerService extends IService<WeCustomer>
WeCustomerDetailVo findWeCustomerDetail(String externalUserid); WeCustomerDetailVo findWeCustomerDetail(String externalUserid);
/**
* 客户条件检索
* @param params
*/
void getCustomerByCondition(JSONObject params);
} }
...@@ -4,6 +4,7 @@ import java.util.List; ...@@ -4,6 +4,7 @@ import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.linkwechat.wecom.domain.WeFlowerCustomerTagRel; import com.linkwechat.wecom.domain.WeFlowerCustomerTagRel;
import org.apache.ibatis.annotations.Param;
/** /**
* 客户标签关系Service接口 * 客户标签关系Service接口
...@@ -70,4 +71,7 @@ public interface IWeFlowerCustomerTagRelService extends IService<WeFlowerCustome ...@@ -70,4 +71,7 @@ public interface IWeFlowerCustomerTagRelService extends IService<WeFlowerCustome
* @return * @return
*/ */
public int batchInsetWeFlowerCustomerTagRel(List<WeFlowerCustomerTagRel> weFlowerCustomerTagRels); public int batchInsetWeFlowerCustomerTagRel(List<WeFlowerCustomerTagRel> weFlowerCustomerTagRels);
void batchAddOrUpdate(List<WeFlowerCustomerTagRel> tagRels);
} }
package com.linkwechat.wecom.service; package com.linkwechat.wecom.service;
import com.linkwechat.wecom.domain.WeGroupMessageList;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.linkwechat.wecom.domain.WeGroupMessageList;
import com.linkwechat.wecom.domain.dto.message.WeGroupMsgListDto; import com.linkwechat.wecom.domain.dto.message.WeGroupMsgListDto;
import com.linkwechat.wecom.domain.vo.WeGroupMessageListVo;
import java.util.List; import java.util.List;
...@@ -13,12 +14,6 @@ import java.util.List; ...@@ -13,12 +14,6 @@ import java.util.List;
* @date 2021-10-19 * @date 2021-10-19
*/ */
public interface IWeGroupMessageListService extends IService<WeGroupMessageList> { public interface IWeGroupMessageListService extends IService<WeGroupMessageList> {
/**
* 查询列表
*/
List<WeGroupMessageList> queryList(WeGroupMessageList weGroupMessageList);
/** /**
* 获取群发记录列表 * 获取群发记录列表
* *
...@@ -31,11 +26,9 @@ public interface IWeGroupMessageListService extends IService<WeGroupMessageList> ...@@ -31,11 +26,9 @@ public interface IWeGroupMessageListService extends IService<WeGroupMessageList>
WeGroupMsgListDto getGroupMsgList(String chatType, Long startTime, Long endTime, String cursor); WeGroupMsgListDto getGroupMsgList(String chatType, Long startTime, Long endTime, String cursor);
/** /**
* 获取群发成员发送任务列表 * 查询群发消息详情
* * @param msgTemplateId 模板id
* @param msgId 群发消息的id * @return
* @param cursor 用于分页查询的游标
* @return WeGroupMsgListDto 群发成员发送任务列表
*/ */
WeGroupMsgListDto getGroupMsgTask(String msgId, String cursor); List<WeGroupMessageListVo> getGroupMsgDetail(Long msgTemplateId);
} }
...@@ -2,6 +2,7 @@ package com.linkwechat.wecom.service; ...@@ -2,6 +2,7 @@ package com.linkwechat.wecom.service;
import com.linkwechat.wecom.domain.WeGroupMessageSendResult; import com.linkwechat.wecom.domain.WeGroupMessageSendResult;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.linkwechat.wecom.domain.WeGroupMessageTask;
import com.linkwechat.wecom.domain.dto.message.WeGroupMsgListDto; import com.linkwechat.wecom.domain.dto.message.WeGroupMsgListDto;
import java.util.List; import java.util.List;
...@@ -28,4 +29,7 @@ public interface IWeGroupMessageSendResultService extends IService<WeGroupMessag ...@@ -28,4 +29,7 @@ public interface IWeGroupMessageSendResultService extends IService<WeGroupMessag
* @return WeGroupMsgListDto 群成员发送结果列表 * @return WeGroupMsgListDto 群成员发送结果列表
*/ */
WeGroupMsgListDto getGroupMsgSendResult(String msgId, String userId, String cursor); WeGroupMsgListDto getGroupMsgSendResult(String msgId, String userId, String cursor);
void addOrUpdateBatchByCondition(List<WeGroupMessageSendResult> taskList);
} }
package com.linkwechat.wecom.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.linkwechat.wecom.domain.WeGroupMessageSendResult;
import com.linkwechat.wecom.domain.WeGroupMessageTask;
import com.linkwechat.wecom.domain.dto.message.WeGroupMsgListDto;
import java.util.List;
/**
* 群发消息成员发送任务表Service接口
*
* @author ruoyi
* @date 2021-10-19
*/
public interface IWeGroupMessageTaskService extends IService<WeGroupMessageTask> {
/**
* 获取群发成员发送任务列表
*
* @param msgId 群发消息的id
* @param cursor 用于分页查询的游标
* @return WeGroupMsgListDto 群发成员发送任务列表
*/
WeGroupMsgListDto getGroupMsgTask(String msgId, String cursor);
/**
* 根据消息id和成员id批量保存更新
* @param taskList
*/
void addOrUpdateBatchByCondition(List<WeGroupMessageTask> taskList);
}
package com.linkwechat.wecom.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.linkwechat.wecom.domain.WeGroupMessageTemplate;
import com.linkwechat.wecom.domain.query.WeAddGroupMessageQuery;
import com.linkwechat.wecom.domain.vo.WeGroupMessageDetailVo;
import java.util.List;
/**
* 群发消息模板Service接口
*
* @author ruoyi
* @date 2021-10-27
*/
public interface IWeGroupMessageTemplateService extends IService<WeGroupMessageTemplate> {
/**
* 查询列表
*/
List<WeGroupMessageTemplate> queryList(WeGroupMessageTemplate weGroupMessageTemplate);
/**
* 获取群发消息详情
* @param id 模板id
* @return
*/
WeGroupMessageDetailVo getGroupMsgTemplateDetail(Long id);
/**
* 创建群发消息
* @param query
*/
void addGroupMsgTemplate(WeAddGroupMessageQuery query);
/**
* 取消定时发送
* @param asList
*/
void cancelByIds(List<Long> asList);
/**
* 同步消息发送结果
* @param asList
*/
void syncGroupMsgSendResultByIds(List<Long> asList);
}
...@@ -100,4 +100,11 @@ public interface IWeMaterialService { ...@@ -100,4 +100,11 @@ public interface IWeMaterialService {
* @return * @return
*/ */
WeMediaDto uploadImg(MultipartFile file); WeMediaDto uploadImg(MultipartFile file);
/**
* 获取素材
* @param mediaId 素材id
* @return
*/
WeMediaDto getMediaToResponse(String mediaId);
} }
...@@ -105,4 +105,9 @@ public class WeFlowerCustomerTagRelServiceImpl extends ServiceImpl<WeFlowerCusto ...@@ -105,4 +105,9 @@ public class WeFlowerCustomerTagRelServiceImpl extends ServiceImpl<WeFlowerCusto
public int batchInsetWeFlowerCustomerTagRel(List<WeFlowerCustomerTagRel> weFlowerCustomerTagRels) { public int batchInsetWeFlowerCustomerTagRel(List<WeFlowerCustomerTagRel> weFlowerCustomerTagRels) {
return weFlowerCustomerTagRelMapper.batchInsetWeFlowerCustomerTagRel(weFlowerCustomerTagRels); return weFlowerCustomerTagRelMapper.batchInsetWeFlowerCustomerTagRel(weFlowerCustomerTagRels);
} }
@Override
public void batchAddOrUpdate(List<WeFlowerCustomerTagRel> tagRels) {
this.baseMapper.batchAddOrUpdate(tagRels);
}
} }
package com.linkwechat.wecom.service.impl; package com.linkwechat.wecom.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
...@@ -7,14 +8,15 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; ...@@ -7,14 +8,15 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.common.utils.StringUtils; import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.wecom.client.WeCustomerMessagePushClient; import com.linkwechat.wecom.client.WeCustomerMessagePushClient;
import com.linkwechat.wecom.domain.WeGroupMessageSendResult; import com.linkwechat.wecom.domain.WeGroupMessageSendResult;
import com.linkwechat.wecom.domain.WeGroupMessageTask;
import com.linkwechat.wecom.domain.dto.message.WeGroupMsgListDto; import com.linkwechat.wecom.domain.dto.message.WeGroupMsgListDto;
import com.linkwechat.wecom.domain.dto.message.WeGroupMsgSendDto; import com.linkwechat.wecom.domain.dto.message.WeGroupMsgSendDto;
import com.linkwechat.wecom.domain.dto.message.WeGroupMsgTaskDto;
import com.linkwechat.wecom.domain.query.WeGetGroupMsgListQuery; import com.linkwechat.wecom.domain.query.WeGetGroupMsgListQuery;
import com.linkwechat.wecom.mapper.WeGroupMessageSendResultMapper; import com.linkwechat.wecom.mapper.WeGroupMessageSendResultMapper;
import com.linkwechat.wecom.service.IWeGroupMessageSendResultService; import com.linkwechat.wecom.service.IWeGroupMessageSendResultService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List; import java.util.List;
...@@ -56,12 +58,12 @@ public class WeGroupMessageSendResultServiceImpl extends ServiceImpl<WeGroupMess ...@@ -56,12 +58,12 @@ public class WeGroupMessageSendResultServiceImpl extends ServiceImpl<WeGroupMess
@Override @Override
public WeGroupMsgListDto getGroupMsgSendResult(String msgId, String userId, String cursor) { public WeGroupMsgListDto getGroupMsgSendResult(String msgId, String userId, String cursor) {
WeGetGroupMsgListQuery query = new WeGetGroupMsgListQuery(); WeGetGroupMsgListQuery query = new WeGetGroupMsgListQuery();
query.setMsgId(msgId); query.setMsgid(msgId);
query.setUserId(userId); query.setUserid(userId);
query.setCursor(cursor); query.setCursor(cursor);
WeGroupMsgListDto groupMsgSendResult = messagePushClient.getGroupMsgSendResult(query); WeGroupMsgListDto groupMsgSendResult = messagePushClient.getGroupMsgSendResult(query);
if(groupMsgSendResult != null && ObjectUtil.equal(0,groupMsgSendResult.getErrcode())){ if (groupMsgSendResult != null && ObjectUtil.equal(0, groupMsgSendResult.getErrcode())) {
if(StringUtils.isNotEmpty(groupMsgSendResult.getNextCursor())){ if (StringUtils.isNotEmpty(groupMsgSendResult.getNextCursor())) {
WeGroupMsgListDto clildMsgList = getGroupMsgSendResult(msgId, userId, groupMsgSendResult.getNextCursor()); WeGroupMsgListDto clildMsgList = getGroupMsgSendResult(msgId, userId, groupMsgSendResult.getNextCursor());
List<WeGroupMsgSendDto> sendList = clildMsgList.getSendList(); List<WeGroupMsgSendDto> sendList = clildMsgList.getSendList();
sendList.addAll(clildMsgList.getSendList()); sendList.addAll(clildMsgList.getSendList());
...@@ -71,4 +73,24 @@ public class WeGroupMessageSendResultServiceImpl extends ServiceImpl<WeGroupMess ...@@ -71,4 +73,24 @@ public class WeGroupMessageSendResultServiceImpl extends ServiceImpl<WeGroupMess
} }
return groupMsgSendResult; return groupMsgSendResult;
} }
@Transactional(rollbackFor = Exception.class)
@Override
public void addOrUpdateBatchByCondition(List<WeGroupMessageSendResult> sendResultList) {
if (CollectionUtil.isNotEmpty(sendResultList)) {
sendResultList.forEach(item -> {
LambdaQueryWrapper<WeGroupMessageSendResult> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(WeGroupMessageSendResult::getMsgId, item.getMsgId())
.eq(WeGroupMessageSendResult::getExternalUserid, item.getExternalUserid())
.eq(WeGroupMessageSendResult::getUserId, item.getUserId())
.eq(WeGroupMessageSendResult::getChatId, item.getChatId());
if(item.getMsgTemplateId() != null){
wrapper.eq(WeGroupMessageSendResult::getMsgTemplateId,item.getMsgTemplateId());
}
if (!this.update(item, wrapper)) {
this.save(item);
}
});
}
}
} }
package com.linkwechat.wecom.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.wecom.client.WeCustomerMessagePushClient;
import com.linkwechat.wecom.domain.WeGroupMessageTask;
import com.linkwechat.wecom.domain.dto.message.WeGroupMsgListDto;
import com.linkwechat.wecom.domain.dto.message.WeGroupMsgTaskDto;
import com.linkwechat.wecom.domain.query.WeGetGroupMsgListQuery;
import com.linkwechat.wecom.mapper.WeGroupMessageTaskMapper;
import com.linkwechat.wecom.service.IWeGroupMessageTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* 群发消息成员执行结果Service业务层处理
*
* @author ruoyi
* @date 2021-10-19
*/
@Service
public class WeGroupMessageTaskServiceImpl extends ServiceImpl<WeGroupMessageTaskMapper, WeGroupMessageTask> implements IWeGroupMessageTaskService {
@Autowired
private WeCustomerMessagePushClient messagePushClient;
@Override
public WeGroupMsgListDto getGroupMsgTask(String msgId, String cursor) {
WeGetGroupMsgListQuery query = new WeGetGroupMsgListQuery();
query.setMsgid(msgId);
query.setCursor(cursor);
WeGroupMsgListDto groupMsgTask = messagePushClient.getGroupMsgTask(query);
if (groupMsgTask != null && ObjectUtil.equal(0, groupMsgTask.getErrcode())) {
if (StringUtils.isNotEmpty(groupMsgTask.getNextCursor())) {
WeGroupMsgListDto clildMsgList = getGroupMsgTask(msgId, groupMsgTask.getNextCursor());
List<WeGroupMsgTaskDto> taskList = clildMsgList.getTaskList();
taskList.addAll(clildMsgList.getTaskList());
groupMsgTask.setTaskList(taskList);
groupMsgTask.setNextCursor(clildMsgList.getNextCursor());
}
}
return groupMsgTask;
}
@Transactional(rollbackFor = Exception.class)
@Override
public void addOrUpdateBatchByCondition(List<WeGroupMessageTask> taskList) {
if (CollectionUtil.isNotEmpty(taskList)) {
taskList.forEach(item -> {
LambdaQueryWrapper<WeGroupMessageTask> wrapper = new LambdaQueryWrapper<>();
if(item.getMsgTemplateId() != null){
wrapper.eq(WeGroupMessageTask::getMsgTemplateId,item.getMsgTemplateId());
}
wrapper.eq(WeGroupMessageTask::getMsgId, item.getMsgId()).eq(WeGroupMessageTask::getUserId, item.getUserId());
if (!this.update(item,wrapper)){
this.save(item);
}
});
}
}
}
...@@ -2,17 +2,23 @@ package com.linkwechat.wecom.service.impl; ...@@ -2,17 +2,23 @@ package com.linkwechat.wecom.service.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import com.alibaba.fastjson.JSONObject;
import com.dtflys.forest.http.ForestResponse;
import com.linkwechat.common.config.CosConfig; import com.linkwechat.common.config.CosConfig;
import com.linkwechat.common.config.RuoYiConfig; import com.linkwechat.common.config.RuoYiConfig;
import com.linkwechat.common.config.ServerConfig; import com.linkwechat.common.config.ServerConfig;
import com.linkwechat.common.constant.WeConstans; import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.enums.WeErrorCodeEnum;
import com.linkwechat.common.exception.wecom.WeComException; import com.linkwechat.common.exception.wecom.WeComException;
import com.linkwechat.common.utils.SnowFlakeUtil; import com.linkwechat.common.utils.SnowFlakeUtil;
import com.linkwechat.common.utils.StringUtils; import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.common.utils.file.FileUploadUtils; import com.linkwechat.common.utils.file.FileUploadUtils;
import com.linkwechat.common.utils.file.FileUtils;
import com.linkwechat.wecom.client.WeMediaClient; import com.linkwechat.wecom.client.WeMediaClient;
import com.linkwechat.wecom.domain.WeMaterial; import com.linkwechat.wecom.domain.WeMaterial;
import com.linkwechat.wecom.domain.dto.WeMediaDto; import com.linkwechat.wecom.domain.dto.WeMediaDto;
import com.linkwechat.wecom.domain.dto.WeResultDto;
import com.linkwechat.wecom.domain.vo.WeMaterialFileVO; import com.linkwechat.wecom.domain.vo.WeMaterialFileVO;
import com.linkwechat.wecom.mapper.WeMaterialMapper; import com.linkwechat.wecom.mapper.WeMaterialMapper;
import com.linkwechat.wecom.service.IWeMaterialService; import com.linkwechat.wecom.service.IWeMaterialService;
...@@ -23,6 +29,7 @@ import org.springframework.web.multipart.MultipartFile; ...@@ -23,6 +29,7 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.File; import java.io.File;
import java.io.InputStream; import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.util.Arrays; import java.util.Arrays;
...@@ -157,4 +164,33 @@ public class WeMaterialServiceImpl implements IWeMaterialService { ...@@ -157,4 +164,33 @@ public class WeMaterialServiceImpl implements IWeMaterialService {
return weMediaClient.uploadimg(file); return weMediaClient.uploadimg(file);
} }
@Override
public WeMediaDto getMediaToResponse(String mediaId) {
WeMediaDto weMediaDto = new WeMediaDto();
weMediaDto.setErrcode(0);
ForestResponse forestResponse = weMediaClient.getMediaToResponse(mediaId);
if (forestResponse != null) {
try {
String fixedName =new String(forestResponse.getFilename().getBytes("ISO8859-1"),"UTF-8");
fixedName = fixedName.replace("\"", "");
weMediaDto.setFileName(fixedName);
if(ruoYiConfig.getFile().isStartCosUpload()) {
String fileFullName = FileUploadUtils.upload2Cos(forestResponse.getInputStream(), FileUtil.getSuffix(fixedName), ruoYiConfig.getFile().getCos());
String imgUrlPrefix = ruoYiConfig.getFile().getCos().getCosImgUrlPrefix();
weMediaDto.setUrl(imgUrlPrefix + fileFullName);
}else {
String filePath = FileUploadUtils.upload(forestResponse.getInputStream(), fixedName);
weMediaDto.setUrl(filePath);
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
weMediaDto.setErrcode(-1);
} catch (Exception e) {
e.printStackTrace();
throw new WeComException("文件下载异常");
}
}
return weMediaDto;
}
} }
...@@ -29,6 +29,7 @@ import java.awt.image.BufferedImage; ...@@ -29,6 +29,7 @@ import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.net.URL;
import java.util.List; import java.util.List;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -114,7 +115,7 @@ public class WePosterServiceImpl extends ServiceImpl<WePosterMapper, WePoster> i ...@@ -114,7 +115,7 @@ public class WePosterServiceImpl extends ServiceImpl<WePosterMapper, WePoster> i
} }
/** /**
* 生成海报图片地址 * 生成海报图片地址(合成图片+文字)
* *
* @param poster * @param poster
* @return * @return
...@@ -125,6 +126,7 @@ public class WePosterServiceImpl extends ServiceImpl<WePosterMapper, WePoster> i ...@@ -125,6 +126,7 @@ public class WePosterServiceImpl extends ServiceImpl<WePosterMapper, WePoster> i
poster.setSampleImgPath(poster.getBackgroundImgPath()); poster.setSampleImgPath(poster.getBackgroundImgPath());
return poster.getBackgroundImgPath(); return poster.getBackgroundImgPath();
} }
Set<String> existFontId = new HashSet<>(); Set<String> existFontId = new HashSet<>();
...@@ -158,7 +160,15 @@ public class WePosterServiceImpl extends ServiceImpl<WePosterMapper, WePoster> i ...@@ -158,7 +160,15 @@ public class WePosterServiceImpl extends ServiceImpl<WePosterMapper, WePoster> i
Map<String, BufferedImage> bufferedImageMap = fileCallableMap.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, stringFileCallableEntry -> { Map<String, BufferedImage> bufferedImageMap = fileCallableMap.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, stringFileCallableEntry -> {
try { try {
return ImageUtils.copyBufferedImage(ImageIO.read(new ByteArrayInputStream(Objects.requireNonNull(NetFileUtils.getByteArrayOutputStream(stringFileCallableEntry.getValue(), false)).toByteArray())),
ByteArrayOutputStream byteArrayOutputStream = NetFileUtils.getByteArrayOutputStream(stringFileCallableEntry.getValue(), false);
return ImageUtils.copyBufferedImage(ImageIO.read(new ByteArrayInputStream(Objects.requireNonNull(byteArrayOutputStream).toByteArray())),
BufferedImage.TYPE_INT_ARGB); BufferedImage.TYPE_INT_ARGB);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
......
package com.linkwechat.wecom.service.impl; package com.linkwechat.wecom.service.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.linkwechat.common.config.CosConfig;
import com.linkwechat.common.constant.WeConstans; import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.enums.TaskFissionType; import com.linkwechat.common.enums.TaskFissionType;
import com.linkwechat.common.exception.wecom.WeComException; import com.linkwechat.common.exception.wecom.WeComException;
...@@ -15,7 +13,6 @@ import com.linkwechat.common.utils.DateUtils; ...@@ -15,7 +13,6 @@ import com.linkwechat.common.utils.DateUtils;
import com.linkwechat.common.utils.QREncode; import com.linkwechat.common.utils.QREncode;
import com.linkwechat.common.utils.SecurityUtils; import com.linkwechat.common.utils.SecurityUtils;
import com.linkwechat.common.utils.StringUtils; import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.common.utils.file.FileUploadUtils;
import com.linkwechat.common.utils.file.FileUtil; import com.linkwechat.common.utils.file.FileUtil;
import com.linkwechat.common.utils.img.NetFileUtils; import com.linkwechat.common.utils.img.NetFileUtils;
import com.linkwechat.wecom.client.WeExternalContactClient; import com.linkwechat.wecom.client.WeExternalContactClient;
...@@ -73,8 +70,7 @@ public class WeTaskFissionServiceImpl extends ServiceImpl<WeTaskFissionMapper, W ...@@ -73,8 +70,7 @@ public class WeTaskFissionServiceImpl extends ServiceImpl<WeTaskFissionMapper, W
private IWeGroupCodeService weGroupCodeService; private IWeGroupCodeService weGroupCodeService;
@Autowired @Autowired
private IWeCustomerService weCustomerService; private IWeCustomerService weCustomerService;
@Autowired
private IWeFlowerCustomerRelService weFlowerCustomerRelService;
@Autowired @Autowired
private IWeTaskFissionCompleteRecordService weTaskFissionCompleteRecordService; private IWeTaskFissionCompleteRecordService weTaskFissionCompleteRecordService;
...@@ -310,16 +306,16 @@ public class WeTaskFissionServiceImpl extends ServiceImpl<WeTaskFissionMapper, W ...@@ -310,16 +306,16 @@ public class WeTaskFissionServiceImpl extends ServiceImpl<WeTaskFissionMapper, W
}); });
} }
} else { } else {
WeTaskFissionRecord weTaskFissionRecord = weTaskFissionRecordService // WeTaskFissionRecord weTaskFissionRecord = weTaskFissionRecordService
.selectWeTaskFissionRecordByIdAndCustomerId(Long.valueOf(fissionId), unionId); // .selectWeTaskFissionRecordByIdAndCustomerId(Long.valueOf(fissionId), unionId);
Optional.ofNullable(weTaskFissionRecord).orElseThrow(() -> new WeComException("任务记录信息不存在")); // Optional.ofNullable(weTaskFissionRecord).orElseThrow(() -> new WeComException("任务记录信息不存在"));
List<WeFlowerCustomerRel> list = weFlowerCustomerRelService.list(new LambdaQueryWrapper<WeFlowerCustomerRel>() // List<WeFlowerCustomerRel> list = weFlowerCustomerRelService.list(new LambdaQueryWrapper<WeFlowerCustomerRel>()
.eq(WeFlowerCustomerRel::getState, WeConstans.FISSION_PREFIX + weTaskFissionRecord.getId())); // .eq(WeFlowerCustomerRel::getState, WeConstans.FISSION_PREFIX + weTaskFissionRecord.getId()));
List<String> eidList = Optional.ofNullable(list).orElseGet(ArrayList::new).stream() // List<String> eidList = Optional.ofNullable(list).orElseGet(ArrayList::new).stream()
.map(WeFlowerCustomerRel::getExternalUserid).collect(Collectors.toList()); // .map(WeFlowerCustomerRel::getExternalUserid).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(eidList)) { // if (CollectionUtil.isNotEmpty(eidList)) {
customerList.addAll(weCustomerService.listByIds(eidList)); // customerList.addAll(weCustomerService.listByIds(eidList));
} // }
} }
return customerList; return customerList;
} }
......
...@@ -548,6 +548,46 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -548,6 +548,46 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select> </select>
<insert id="batchAddOrUpdate">
INSERT INTO we_customer(
external_userid,
NAME,
avatar,
type,
gender,
unionid,
birthday,
corp_name,
corp_full_name,
position,
is_open_chat,
create_time,
create_by,
first_user_id,
first_add_time
) values
<foreach collection="weCustomers" item="item" index="index" separator=",">
(#{item.externalUserid},#{item.name},#{item.avatar},#{item.type},#{item.gender}, #{item.unionid},#{item.birthday},
#{item.corpName},#{item.corpFullName},#{item.position},#{item.isOpenChat}, #{item.createTime},
#{item.createBy},#{item.firstUserId},#{item.firstAddTime}
)
</foreach>
ON DUPLICATE KEY UPDATE
NAME=IF(we_customer.NAME != null, VALUES(NAME), we_customer.NAME),
avatar=IF(we_customer.avatar != null, VALUES(avatar), we_customer.avatar),
type=IF(we_customer.type != null, VALUES(type), we_customer.type),
gender=IF(we_customer.gender != null, VALUES(gender), we_customer.gender),
unionid=IF(we_customer.unionid != null, VALUES(unionid), we_customer.unionid),
birthday=IF(we_customer.birthday != null,VALUES(birthday), we_customer.birthday),
corp_name=IF(we_customer.corp_name != null, VALUES(corp_name), we_customer.corp_name),
corp_full_name=IF(we_customer.corp_full_name != null, VALUES(corp_full_name), we_customer.corp_full_name),
position=IF(we_customer.position != null, VALUES(position), we_customer.position),
is_open_chat=IF(we_customer.is_open_chat != null, VALUES(is_open_chat), we_customer.is_open_chat),
first_user_id=IF(we_customer.first_user_id != null, VALUES(first_user_id), we_customer.first_user_id),
first_add_time=IF(we_customer.first_add_time != null, VALUES(first_add_time), we_customer.first_add_time);
</insert>
......
...@@ -5,14 +5,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -5,14 +5,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<mapper namespace="com.linkwechat.wecom.mapper.WeFlowerCustomerTagRelMapper"> <mapper namespace="com.linkwechat.wecom.mapper.WeFlowerCustomerTagRelMapper">
<resultMap type="WeFlowerCustomerTagRel" id="WeFlowerCustomerTagRelResult"> <resultMap type="WeFlowerCustomerTagRel" id="WeFlowerCustomerTagRelResult">
<result property="id" column="id" />
<result property="flowerCustomerRelId" column="flower_customer_rel_id" />
<result property="tagId" column="tag_id" /> <result property="tagId" column="tag_id" />
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
</resultMap> </resultMap>
<sql id="selectWeFlowerCustomerTagRelVo"> <sql id="selectWeFlowerCustomerTagRelVo">
select id, flower_customer_rel_id, tag_id, create_time from we_flower_customer_tag_rel select id,tag_id, create_time from we_flower_customer_tag_rel
</sql> </sql>
<select id="selectWeFlowerCustomerTagRelList" parameterType="WeFlowerCustomerTagRel" resultMap="WeFlowerCustomerTagRelResult"> <select id="selectWeFlowerCustomerTagRelList" parameterType="WeFlowerCustomerTagRel" resultMap="WeFlowerCustomerTagRelResult">
...@@ -31,14 +29,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -31,14 +29,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertWeFlowerCustomerTagRel" parameterType="WeFlowerCustomerTagRel"> <insert id="insertWeFlowerCustomerTagRel" parameterType="WeFlowerCustomerTagRel">
insert into we_flower_customer_tag_rel insert into we_flower_customer_tag_rel
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="flowerCustomerRelId != null">flower_customer_rel_id,</if>
<if test="tagId != null">tag_id,</if> <if test="tagId != null">tag_id,</if>
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="flowerCustomerRelId != null">#{flowerCustomerRelId},</if>
<if test="tagId != null">#{tagId},</if> <if test="tagId != null">#{tagId},</if>
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
</trim> </trim>
...@@ -74,4 +70,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -74,4 +70,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach> </foreach>
</insert> </insert>
<insert id="batchAddOrUpdate">
INSERT INTO we_flower_customer_tag_rel(
user_id,
external_userid,
tag_id,
create_time
) values
<foreach collection="tagRels" item="item" index="index" separator=",">
(#{item.userId},#{item.externalUserid},#{item.tagId},NOW())
</foreach>
ON DUPLICATE KEY UPDATE
user_id=IF(we_flower_customer_tag_rel.user_id != null, VALUES(user_id), we_flower_customer_tag_rel.user_id),
external_userid=IF(we_flower_customer_tag_rel.external_userid != null, VALUES(external_userid), we_flower_customer_tag_rel.external_userid),
tag_id=IF(we_flower_customer_tag_rel.tag_id != null, VALUES(tag_id), we_flower_customer_tag_rel.tag_id);
</insert>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -6,12 +6,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -6,12 +6,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="WeGroupMessageAttachments" id="WeGroupMessageAttachmentsResult"> <resultMap type="WeGroupMessageAttachments" id="WeGroupMessageAttachmentsResult">
<result property="id" column="id" /> <result property="id" column="id" />
<result property="msgTemplateId" column="msg_template_id" />
<result property="msgId" column="msg_id" /> <result property="msgId" column="msg_id" />
<result property="msgType" column="msg_type" /> <result property="msgType" column="msg_type" />
<result property="content" column="content" /> <result property="content" column="content" />
<result property="mediaId" column="media_id" /> <result property="mediaId" column="media_id" />
<result property="title" column="title" /> <result property="title" column="title" />
<result property="description" column="description" /> <result property="description" column="description" />
<result property="fileUrl" column="file_url" />
<result property="linkUrl" column="link_url" /> <result property="linkUrl" column="link_url" />
<result property="picUrl" column="pic_url" /> <result property="picUrl" column="pic_url" />
<result property="appId" column="app_id" /> <result property="appId" column="app_id" />
......
...@@ -6,17 +6,90 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -6,17 +6,90 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="WeGroupMessageList" id="WeGroupMessageListResult"> <resultMap type="WeGroupMessageList" id="WeGroupMessageListResult">
<result property="id" column="id" /> <result property="id" column="id" />
<result property="msgTemplateId" column="msg_template_id" />
<result property="msgId" column="msg_id" /> <result property="msgId" column="msg_id" />
<result property="chatType" column="chat_type" /> <result property="chatType" column="chat_type" />
<result property="userId" column="user_id" /> <result property="userId" column="user_id" />
<result property="sendTime" column="send_time" /> <result property="sendTime" column="send_time" />
<result property="createType" column="create_type" /> <result property="createType" column="create_type" />
<result property="isTask" column="is_task" />
<result property="createBy" column="create_by" /> <result property="createBy" column="create_by" />
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" /> <result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time" />
</resultMap> </resultMap>
<resultMap id="groupMsgDetailResult" type="WeGroupMessageListVo">
<result property="msgTemplateId" column="msg_template_id" />
<collection property="attachments" ofType="com.linkwechat.wecom.domain.WeGroupMessageAttachments">
<result property="msgType" column="msg_type"/>
<result property="content" column="content"/>
<result property="appId" column="app_id"/>
<result property="mediaId" column="media_id"/>
<result property="description" column="description"/>
<result property="linkUrl" column="link_url"/>
<result property="picUrl" column="pic_url"/>
</collection>
<collection property="senders" ofType="com.linkwechat.wecom.domain.WeGroupMessageTask">
<result property="userId" column="sender"/>
<result property="userName" column="sender_name"/>
<result property="status" column="task_status"/>
<result property="sendTime" column="task_send_time"/>
</collection>
<collection property="extralInfos" ofType="com.linkwechat.wecom.domain.WeGroupMessageSendResult">
<result property="userId" column="res_sender"/>
<result property="userName" column="res_sender_name"/>
<result property="chatId" column="chat_id"/>
<result property="chatName" column="chat_name"/>
<result property="externalUserid" column="external_userid"/>
<result property="customerName" column="customer_name"/>
<result property="status" column="res_status"/>
<result property="sendTime" column="res_send_time"/>
</collection>
</resultMap>
<sql id="getDetailVo">
select
wgml.msg_template_id,
wgma.msg_type,
wgma.content,
wgma.app_id ,
wgma.media_id ,
wgma.description ,
wgma.link_url ,
wgma.file_url ,
wgma.pic_url ,
wgmt.user_id as sender,
(select user_name from we_user wu where wu.user_id = wgmt.user_id limit 1) as sender_name,
wgmt.status as task_status,
wgmt.send_time as task_send_time,
wgmsr.user_id as res_sender,
(select user_name from we_user wu where wu.user_id = wgmsr.user_id limit 1) as res_sender_name,
wgmsr.chat_id ,
if(wgmsr.chat_id is null,null,(select wg.group_name from we_group wg where wg.chat_id = wgmsr.chat_id limit 1)) as chat_name,
wgmsr.external_userid,
if(wgmsr.external_userid is null,null,(select wc.name from we_customer wc where wc.external_userid = wgmsr.external_userid limit 1)) as customer_name,
wgmsr.status as res_status,
wgmsr.send_time as res_send_time
from
we_group_message_list wgml
left join we_group_message_attachments wgma on
wgma.msg_template_id = wgml.msg_template_id
left join we_group_message_task wgmt on
wgmt.msg_template_id = wgml.msg_template_id
left join we_group_message_send_result wgmsr on
wgmsr.msg_template_id = wgml.msg_template_id
where
1 = 1
</sql>
<select id="getGroupMsgDetails" resultMap="groupMsgDetailResult">
<include refid="getDetailVo"/>
<if test="msgTemplateIds != null and msgTemplateIds.size > 0">
and wgml.msg_template_id in
<foreach collection="msgTemplateIds" index="index" item="msgTemplateId" open="(" separator="," close=")">
#{msgTemplateId}
</foreach>
</if>
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -6,6 +6,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -6,6 +6,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="WeGroupMessageSendResult" id="WeGroupMessageSendResultResult"> <resultMap type="WeGroupMessageSendResult" id="WeGroupMessageSendResultResult">
<result property="id" column="id" /> <result property="id" column="id" />
<result property="msgTemplateId" column="msg_template_id" />
<result property="msgId" column="msg_id" /> <result property="msgId" column="msg_id" />
<result property="userId" column="user_id" /> <result property="userId" column="user_id" />
<result property="externalUserid" column="external_userid" /> <result property="externalUserid" column="external_userid" />
......
<?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.WeGroupMessageTaskMapper">
<resultMap type="WeGroupMessageTask" id="WeGroupMessageTaskResult">
<result property="id" column="id" />
<result property="msgTemplateId" column="msg_template_id" />
<result property="msgId" column="msg_id" />
<result property="userId" column="user_id" />
<result property="status" column="status" />
<result property="sendTime" column="send_time" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
</mapper>
\ No newline at end of file \ 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.linkwechat.wecom.mapper.WeGroupMessageTemplateMapper">
<resultMap type="WeGroupMessageTemplate" id="WeGroupMessageTemplateResult">
<result property="id" column="id" />
<result property="chatType" column="chat_type" />
<result property="content" column="context" />
<result property="sendTime" column="send_time" />
<result property="filterCondition" column="filter_condition" />
<result property="isTask" column="is_task" />
<result property="status" column="status" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
</mapper>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!