优化客户同步

1 parent 91f6ec40
Showing 65 changed files with 1448 additions and 350 deletions
package com.linkwechat.web.controller.wecom;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.linkwechat.common.annotation.Log;
import com.linkwechat.common.constant.Constants;
......@@ -20,7 +19,7 @@ import java.util.List;
/**
* 企业id相关配置Controller
*
*
* @author ruoyi
* @date 2020-08-24
*/
......@@ -40,56 +39,12 @@ public class WeCorpAccountController extends BaseController
{
startPage();
List<WeCorpAccount> list = weCorpAccountService.list(new LambdaQueryWrapper<WeCorpAccount>()
.eq(WeCorpAccount::getDelFlag,Constants.NORMAL_CODE)
.like(WeCorpAccount::getCompanyName,weCorpAccount.getCompanyName()));
.eq(WeCorpAccount::getDelFlag,Constants.NORMAL_CODE)
.like(WeCorpAccount::getCompanyName,weCorpAccount.getCompanyName()));
return getDataTable(list);
}
/******************************************************
*************************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')")
......@@ -116,7 +71,7 @@ public class WeCorpAccountController extends BaseController
// @PreAuthorize("@ss.hasPermi('wechat:corp:startVailWeCorpAccount')")
@Log(title = "启用有效企业微信账号", businessType = BusinessType.DELETE)
@PutMapping("/startVailWeCorpAccount/{corpId}")
@PutMapping("/startVailWeCorpAccount/{corpId}")
@ApiOperation("启用有效企业微信账号")
public AjaxResult startWeCorpAccount(@PathVariable String corpId)
{
......
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.linkwechat.common.annotation.Log;
import com.linkwechat.common.constant.Constants;
......@@ -10,12 +10,10 @@ import com.linkwechat.common.core.controller.BaseController;
import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.core.page.TableDataInfo;
import com.linkwechat.common.enums.BusinessType;
import com.linkwechat.common.utils.poi.ExcelUtil;
import com.linkwechat.wecom.domain.*;
import com.linkwechat.wecom.domain.vo.WeMakeCustomerTag;
import com.linkwechat.wecom.service.IWeCustomerService;
import com.linkwechat.wecom.service.IWeCustomerTrajectoryService;
import com.linkwechat.wecom.service.IWeFlowerCustomerRelService;
import com.linkwechat.wecom.service.IWeFlowerCustomerTagRelService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -23,7 +21,6 @@ import org.springframework.context.annotation.Lazy;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
/**
......@@ -43,12 +40,6 @@ public class WeCustomerController extends BaseController
@Autowired
private IWeFlowerCustomerTagRelService weFlowerCustomerTagRelService;
@Autowired
private IWeFlowerCustomerRelService weFlowerCustomerRelService;
@Autowired
private IWeCustomerTrajectoryService iWeCustomerTrajectoryService;
......@@ -89,41 +80,23 @@ public class WeCustomerController extends BaseController
{
startPage();
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);
}
/**
* 导出企业微信客户列表
*/
// @PreAuthorize("@ss.hasPermi('wecom:customer:export')")
@Log(title = "企业微信客户", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(WeCustomer weCustomer)
{
List<WeCustomer> list = weCustomerService.selectWeCustomerList(weCustomer);
ExcelUtil<WeCustomer> util = new ExcelUtil<WeCustomer>(WeCustomer.class);
return util.exportExcel(list, "customer");
}
// /**
// * 导出企业微信客户列表
// */
// // @PreAuthorize("@ss.hasPermi('wecom:customer:export')")
// @Log(title = "企业微信客户", businessType = BusinessType.EXPORT)
// @GetMapping("/export")
// public AjaxResult export(WeCustomer weCustomer)
// {
// List<WeCustomer> list = weCustomerService.selectWeCustomerList(weCustomer);
// ExcelUtil<WeCustomer> util = new ExcelUtil<WeCustomer>(WeCustomer.class);
// return util.exportExcel(list, "customer");
// }
/**
* 获取企业微信客户详细信息
......@@ -193,7 +166,7 @@ public class WeCustomerController extends BaseController
@DeleteMapping("/removeLabel")
public AjaxResult removeLabel(@RequestBody WeMakeCustomerTag weMakeCustomerTag){
weCustomerService.removeLabel(weMakeCustomerTag);
weCustomerService.makeLabel(weMakeCustomerTag);
return AjaxResult.success();
......@@ -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;
import com.linkwechat.wecom.service.IWeEmpleCodeService;
import com.linkwechat.wecom.service.IWeFlowerCustomerRelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.*;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
/**
* 员工活码Controller
......@@ -39,6 +34,8 @@ import java.util.zip.ZipOutputStream;
public class WeEmpleCodeController extends BaseController {
@Autowired
private IWeEmpleCodeService weEmpleCodeService;
@Autowired
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
}
@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
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 {
@Request(url = "/externalcontact/get")
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批量获取客户详情
* @param query
* @param param
* @return
*/
@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 {
*/
@Deprecated
@Request(url = "/externalcontact/add_msg_template", type = "POST")
SendMessageResultDto sendCustomerMessageToUser(@Body WeCustomerMessagePushDto customerMessagePushDto);
SendMessageResultDto sendCustomerMessageToUser(@JSONBody WeCustomerMessagePushDto customerMessagePushDto);
......
package com.linkwechat.wecom.client;
import com.dtflys.forest.annotation.*;
import com.dtflys.forest.http.ForestResponse;
import com.linkwechat.wecom.domain.dto.WeMediaDto;
import com.linkwechat.wecom.interceptor.WeAccessTokenInterceptor;
import com.linkwechat.wecom.retry.WeCommonRetryWhen;
......@@ -35,4 +36,12 @@ public interface WeMediaClient {
@Post(url = "/media/upload")
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 {
* @param fetchChild
* @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")
WeUserListDto list(@Query("department_id") Long departmentId,@Query("fetch_child") Integer fetchChild);
......@@ -65,7 +74,7 @@ public interface WeUserClient {
* 分配客户
* @return
*/
@Request(url="/externalcontact/transfer", type = "POST")
@Request(url="/externalcontact/resigned/transfer_customer", type = "POST")
WeResultDto allocateCustomer(@JSONBody AllocateWeCustomerDto allocateWeCustomerDto);
......
......@@ -2,13 +2,11 @@ package com.linkwechat.wecom.domain;
import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
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 com.linkwechat.common.utils.SnowFlakeUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
......@@ -40,11 +38,17 @@ public class WeCustomer extends BaseEntity {
/**
* 外部联系人的userid
*/
@TableId
@NotBlank(message = "外部联系人的id不可为空")
@ApiModelProperty("外部联系人的userid")
private String externalUserid;
/**
* 首位添加人
*/
private String firstUserId;
/**
* 外部联系人名称
*/
......@@ -167,10 +171,6 @@ public class WeCustomer extends BaseEntity {
private String updateBy;
/**
* 首位添加人
*/
private String firstUserId;
/**
......
......@@ -25,7 +25,7 @@ public class WeCustomerList {
private String tagNames;
private List<WeFlowerCustomerRel> weFlowerCustomerRels;
// private List<WeFlowerCustomerRel> weFlowerCustomerRels;
//查询条件客户姓名
private String name;
......
......@@ -2,6 +2,7 @@ package com.linkwechat.wecom.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.linkwechat.common.core.domain.BaseEntity;
......@@ -29,12 +30,7 @@ public class WeFlowerCustomerTagRel
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
@TableId
private Long id;
/** 添加客户的企业微信用户 */
private Long flowerCustomerRelId;
/**外部联系人id(客户id) */
......@@ -54,4 +50,7 @@ public class WeFlowerCustomerTagRel
private Date createTime;
private String userId;
@TableLogic
private Integer delFlag;
}
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.linkwechat.common.annotation.Excel;
......@@ -12,11 +11,6 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* 群发消息附件对象 we_group_message_attachments
*
......@@ -34,6 +28,13 @@ public class WeGroupMessageAttachments extends BaseEntity{
@TableId(value = "id",type = IdType.AUTO)
private Long id;
/**
* 群发消息模板id
*/
@ApiModelProperty("群发消息模板id")
@Excel(name = "群发消息模板id")
private Long msgTemplateId;
/** 企业群发消息的id */
@ApiModelProperty("企业群发消息的id")
@Excel(name = "企业群发消息的id")
......@@ -64,6 +65,11 @@ public class WeGroupMessageAttachments extends BaseEntity{
@Excel(name = "消息描述")
private String description;
/** 文件路径 */
@ApiModelProperty("文件路径")
@Excel(name = "文件路径")
private String fileUrl;
/** 消息链接 */
@ApiModelProperty("消息链接")
@Excel(name = "消息链接")
......
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;
......@@ -25,7 +26,7 @@ import java.util.Date;
@NoArgsConstructor
@Accessors(chain = true)
@TableName("we_group_message_list")
public class WeGroupMessageList extends BaseEntity {
public class WeGroupMessageList extends BaseEntity{
/**
* 主键id
......@@ -34,6 +35,14 @@ public class WeGroupMessageList extends BaseEntity {
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 群发消息模板id
*/
@ApiModelProperty("群发消息模板id")
@Excel(name = "群发消息模板id")
private Long msgTemplateId;
/**
* 企业群发消息的id
*/
......@@ -51,7 +60,7 @@ public class WeGroupMessageList extends BaseEntity {
/**
* 群发消息创建者userid
*/
@ApiModelProperty("群发消息创建者userid")
@ApiModelProperty(value = "群发消息创建者userid", hidden = true)
@Excel(name = "群发消息创建者userid")
private String userId;
......@@ -66,14 +75,14 @@ public class WeGroupMessageList extends BaseEntity {
/**
* 群发消息创建来源。0:企业 1:个人
*/
@ApiModelProperty("群发消息创建来源。0:企业 1:个人")
@ApiModelProperty(value = "群发消息创建来源。0:企业 1:个人",hidden = true)
@Excel(name = "群发消息创建来源。0:企业 1:个人")
private Integer createType;
private Integer createType = 0;
/**
* 是否定时任务 0 常规 1 定时发送
* 群发消息创建者
*/
@ApiModelProperty("是否定时任务 0 常规 1 定时发送")
@Excel(name = "是否定时任务 0 常规 1 定时发送")
private Integer isTask;
@ApiModelProperty(value = "群发消息创建者",hidden = true)
@TableField(exist = false)
private String userName;
}
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;
......@@ -25,7 +26,7 @@ import java.util.Date;
@NoArgsConstructor
@Accessors(chain = true)
@TableName("we_group_message_send_result")
public class WeGroupMessageSendResult extends BaseEntity {
public class WeGroupMessageSendResult extends BaseEntity{
/**
* 主键id
......@@ -34,6 +35,14 @@ public class WeGroupMessageSendResult extends BaseEntity {
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 群发消息模板id
*/
@ApiModelProperty("群发消息模板id")
@Excel(name = "群发消息模板id")
private Long msgTemplateId;
/**
* 企业群发消息的id
*/
......@@ -76,4 +85,25 @@ public class WeGroupMessageSendResult extends BaseEntity {
@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;
/**
* 外部联系人姓名
*/
@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 {
@ApiModelProperty("分类id")
private Long categoryId;
@ApiModelProperty("其他字段")
private String otherField;
/**
* 海报组件数组
*/
......
......@@ -20,12 +20,12 @@ public class AllocateWeCustomerDto{
private String handover_userid;
/**原跟进成员的userid*/
private String external_userid;
private String[] external_userid;
/**接替成员的userid*/
private String takeover_userid;
/**转移成功后发给客户的消息,最多200个字符,不填则使用默认文案,目前只对在职成员分配客户的情况生效*/
private String transfer_success_msg;
// /**转移成功后发给客户的消息,最多200个字符,不填则使用默认文案,目前只对在职成员分配客户的情况生效*/
// private String transfer_success_msg;
}
......@@ -5,6 +5,7 @@ import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.common.utils.bean.BeanUtils;
import com.linkwechat.wecom.domain.WeCustomer;
import com.linkwechat.wecom.domain.WeFlowerCustomerRel;
import lombok.Builder;
import lombok.Data;
import java.util.ArrayList;
......@@ -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(){
// WeCustomer weCustomer=new WeCustomer();
//
......
......@@ -75,6 +75,8 @@ public class ExternalUserDetail extends WeResultDto {
@Data
public class FollowInfo{
/**添加人id*/
private String userid;
/**该成员对此外部联系人的备注*/
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;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.linkwechat.common.enums.MessageType;
import com.linkwechat.common.exception.wecom.WeComException;
import com.linkwechat.wecom.domain.WeMessageTemplate;
import io.swagger.annotations.ApiModel;
......@@ -35,28 +37,39 @@ public class WeAddMsgTemplateQuery {
@ApiModelProperty("附件,最多支持添加9个附件 ru")
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) {
final int size = 9;
final int size = 10;
this.attachments = new ArrayList<>(16);
if (messageTemplates != null && messageTemplates.size() <= size) {
if (CollectionUtil.isNotEmpty(messageTemplates) && messageTemplates.size() < size) {
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(),
messageTemplate.getPicUrl());
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(),
messageTemplate.getPicUrl(), messageTemplate.getDescription(), messageTemplate.getLinkUrl());
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(),
messageTemplate.getMediaId(), messageTemplate.getAppId(), messageTemplate.getLinkUrl());
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.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.add(files);
}
......
......@@ -14,10 +14,10 @@ import lombok.Data;
public class WeGetGroupMsgListQuery {
@ApiModelProperty("群发消息的id")
private String msgId;
private String msgid;
@ApiModelProperty("发送成员userid")
private String userId;
private String userid;
@ApiModelProperty("返回的最大记录数,整型,最大值1000,默认值500")
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;
*/
@Data
public class WeLeaveUserInfoAllocateVo {
//移交人
private String handoverUserid;
//接管人
private String takeoverUserid;
}
......@@ -19,7 +19,6 @@ import java.util.List;
@NoArgsConstructor
public class WeMakeCustomerTag {
private String externalUserid;
private Long flowerCustomerRelId;
private String userId;
private List<WeTag> addTag;
......
package com.linkwechat.wecom.factory.impl.customer;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.io.FileUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.linkwechat.common.config.CosConfig;
import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.enums.MediaType;
import com.linkwechat.common.utils.StringUtils;
......@@ -19,12 +19,10 @@ import com.linkwechat.wecom.service.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* @author danmo
......@@ -40,8 +38,7 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy {
private IWeEmpleCodeTagService weEmpleCodeTagService;
@Autowired
private IWeEmpleCodeService weEmpleCodeService;
@Autowired
private IWeFlowerCustomerRelService weFlowerCustomerRelService;
@Autowired
private IWeFlowerCustomerTagRelService weFlowerCustomerTagRelService;
@Autowired
......@@ -66,10 +63,6 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy {
@Override
public void eventHandle(WxCpXmlMessageVO message) {
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());
}
......@@ -146,43 +139,33 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy {
//查询活码对应标签
List<WeEmpleCodeTag> tagList = weEmpleCodeTagService.list(new LambdaQueryWrapper<WeEmpleCodeTag>()
.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<>();
Optional.ofNullable(weFlowerCustomerRel).ifPresent(weFlowerCustomerRel1 -> {
Optional.ofNullable(tagList).orElseGet(ArrayList::new).forEach(tag -> {
List<WeFlowerCustomerTagRel> weFlowerCustomerTagRels = new ArrayList<>();
tagList.stream().forEach(k->{
weFlowerCustomerTagRels.add(
WeFlowerCustomerTagRel.builder()
.flowerCustomerRelId(weFlowerCustomerRel.getId())
.userId(userId)
.tagId(k.getTagId())
.externalUserid(externalUserId)
.tagId(tag.getTagId())
.userId(userId)
.createTime(new Date())
.relTagType(new Integer(1))
.build()
);
});
if(weFlowerCustomerTagRelService.saveOrUpdateBatch(weFlowerCustomerTagRels)){
//标签同步到企业微信端
weCustomerClient.makeCustomerLabel(CutomerTagEdit.builder()
.external_userid(externalUserId)
.userid(userId)
.add_tag(weFlowerCustomerTagRels.stream()
.map(WeFlowerCustomerTagRel::getTagId).toArray(String[]::new))
.external_userid(externalUserId)
.userid(userId)
.add_tag(weFlowerCustomerTagRels.stream()
.map(WeFlowerCustomerTagRel::getTagId).toArray(String[]::new))
.build());
}
}
});
// 发送欢迎语
log.debug(">>>>>>>>>欢迎语查询结果:{}", JSONObject.toJSONString(messageMap));
......
package com.linkwechat.wecom.factory.impl.customer;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.linkwechat.common.enums.MediaType;
......@@ -37,8 +38,7 @@ public class WeCallBackAddHalfExternalContactImpl extends WeEventStrategy {
private IWeEmpleCodeTagService weEmpleCodeTagService;
@Autowired
private IWeEmpleCodeService weEmpleCodeService;
@Autowired
private IWeFlowerCustomerRelService weFlowerCustomerRelService;
@Autowired
private IWeFlowerCustomerTagRelService weFlowerCustomerTagRelService;
@Autowired
......@@ -59,24 +59,25 @@ public class WeCallBackAddHalfExternalContactImpl extends WeEventStrategy {
//查询活码对应标签
List<WeEmpleCodeTag> tagList = weEmpleCodeTagService.list(new LambdaQueryWrapper<WeEmpleCodeTag>()
.eq(WeEmpleCodeTag::getEmpleCodeId, empleCodeId));
//查询外部联系人与通讯录关系数据
WeFlowerCustomerRel weFlowerCustomerRel = weFlowerCustomerRelService.getOne(new LambdaQueryWrapper<WeFlowerCustomerRel>()
.eq(WeFlowerCustomerRel::getUserId, message.getUserId())
.eq(WeFlowerCustomerRel::getExternalUserid, message.getExternalUserId()));
//为外部联系人添加员工活码标签
List<WeFlowerCustomerTagRel> weFlowerCustomerTagRels = new ArrayList<>();
Optional.ofNullable(weFlowerCustomerRel).ifPresent(weFlowerCustomerRel1 -> {
Optional.ofNullable(tagList).orElseGet(ArrayList::new).forEach(tag ->{
//客户添加活码标签
if(CollectionUtil.isNotEmpty(tagList)){
List<WeFlowerCustomerTagRel> weFlowerCustomerTagRels = new ArrayList<>();
tagList.stream().forEach(k->{
weFlowerCustomerTagRels.add(
WeFlowerCustomerTagRel.builder()
.flowerCustomerRelId(weFlowerCustomerRel.getId())
.tagId(tag.getTagId())
.tagId(k.getTagId())
.externalUserid( message.getUserId())
.userId(message.getExternalUserId())
.createTime(new Date())
.build()
);
});
weFlowerCustomerTagRelService.saveOrUpdateBatch(weFlowerCustomerTagRels);
});
}
log.debug(">>>>>>>>>欢迎语查询结果:{}", JSONObject.toJSONString(messageMap));
if (messageMap != null) {
if (StringUtils.isNotEmpty(messageMap.getWelcomeMsg())){
......
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.WeSensitiveAct;
import com.linkwechat.wecom.domain.WeSensitiveActHit;
......@@ -7,7 +8,6 @@ import com.linkwechat.wecom.domain.WeUser;
import com.linkwechat.wecom.domain.vo.WxCpXmlMessageVO;
import com.linkwechat.wecom.factory.WeEventStrategy;
import com.linkwechat.wecom.service.IWeCustomerService;
import com.linkwechat.wecom.service.IWeFlowerCustomerRelService;
import com.linkwechat.wecom.service.IWeSensitiveActHitService;
import com.linkwechat.wecom.service.IWeUserService;
import lombok.extern.slf4j.Slf4j;
......@@ -26,8 +26,7 @@ import java.util.Date;
public class WeCallBackDelExternalContactImpl extends WeEventStrategy {
@Autowired
private IWeCustomerService weCustomerService;
@Autowired
private IWeFlowerCustomerRelService weFlowerCustomerRelService;
@Autowired
private IWeSensitiveActHitService weSensitiveActHitService;
@Autowired
......@@ -36,26 +35,31 @@ public class WeCallBackDelExternalContactImpl extends WeEventStrategy {
@Override
public void eventHandle(WxCpXmlMessageVO message) {
if (message.getExternalUserId() != null) {
//weCustomerService.deleteCustomersByEid(message.getExternalUserId());
weFlowerCustomerRelService.deleteFollowUser(message.getUserId(), message.getExternalUserId());
//增加敏感行为记录,员工删除客户
WeSensitiveAct weSensitiveAct = weSensitiveActHitService.getSensitiveActType("拉黑/删除好友");
if (weSensitiveAct != null && weSensitiveAct.getEnableFlag() == 1) {
WeSensitiveActHit weSensitiveActHit = new WeSensitiveActHit();
weSensitiveActHit.setSensitiveActId(weSensitiveAct.getId());
weSensitiveActHit.setSensitiveAct(weSensitiveAct.getActName());
weSensitiveActHit.setCreateTime(new Date(message.getCreateTime()));
weSensitiveActHit.setCreateBy("admin");
weSensitiveActHit.setOperatorId(message.getUserId());
WeUser user = weUserService.getById(message.getUserId());
weSensitiveActHit.setOperator(user.getName());
WeCustomer weCustomer = weCustomerService.selectWeCustomerById(message.getExternalUserId());
weSensitiveActHit.setOperateTargetId(weCustomer.getUserId());
weSensitiveActHit.setOperateTarget(weCustomer.getName());
weSensitiveActHitService.insertWeSensitiveActHit(weSensitiveActHit);
//删除客户
if(weCustomerService.remove(new LambdaQueryWrapper<WeCustomer>()
.eq(WeCustomer::getExternalUserid,message.getExternalUserId())
.eq(WeCustomer::getFirstUserId,message.getUserId()))){
//增加敏感行为记录,员工删除客户
WeSensitiveAct weSensitiveAct = weSensitiveActHitService.getSensitiveActType("拉黑/删除好友");
if (weSensitiveAct != null && weSensitiveAct.getEnableFlag() == 1) {
WeSensitiveActHit weSensitiveActHit = new WeSensitiveActHit();
weSensitiveActHit.setSensitiveActId(weSensitiveAct.getId());
weSensitiveActHit.setSensitiveAct(weSensitiveAct.getActName());
weSensitiveActHit.setCreateTime(new Date(message.getCreateTime()));
weSensitiveActHit.setCreateBy("admin");
weSensitiveActHit.setOperatorId(message.getUserId());
WeUser user = weUserService.getById(message.getUserId());
weSensitiveActHit.setOperator(user.getName());
WeCustomer weCustomer = weCustomerService.selectWeCustomerById(message.getExternalUserId());
weSensitiveActHit.setOperateTargetId(weCustomer.getUserId());
weSensitiveActHit.setOperateTarget(weCustomer.getName());
weSensitiveActHitService.insertWeSensitiveActHit(weSensitiveActHit);
}
}
}
}
}
package com.linkwechat.wecom.factory.impl.customer;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.core.domain.entity.WeCorpAccount;
import com.linkwechat.common.enums.MessageType;
......@@ -29,8 +30,6 @@ public class WeCallBackDelFollowUserImpl extends WeEventStrategy {
@Autowired
private IWeCustomerService weCustomerService;
@Autowired
private IWeFlowerCustomerRelService weFlowerCustomerRelService;
@Autowired
private IWeCorpAccountService weCorpAccountService;
@Autowired
private WeMessagePushClient weMessagePushClient;
......@@ -43,47 +42,52 @@ public class WeCallBackDelFollowUserImpl extends WeEventStrategy {
public void eventHandle(WxCpXmlMessageVO message) {
try {
if (message.getUserId() != null && message.getExternalUserId() != null) {
weFlowerCustomerRelService.deleteFollowUser(message.getUserId(), message.getExternalUserId());
WeCorpAccount validWeCorpAccount = weCorpAccountService.findValidWeCorpAccount();
Optional.ofNullable(validWeCorpAccount).ifPresent(weCorpAccount -> {
String customerChurnNoticeSwitch = weCorpAccount.getCustomerChurnNoticeSwitch();
if (WeConstans.DEL_FOLLOW_USER_SWITCH_OPEN.equals(customerChurnNoticeSwitch)) {
WeCustomer weCustomer = weCustomerService.selectWeCustomerById(message.getExternalUserId());
String content = "您已经被客户@" + weCustomer.getName() + "删除!";
TextMessageDto textMessageDto = new TextMessageDto();
textMessageDto.setContent(content);
WeMessagePushDto weMessagePushDto = new WeMessagePushDto();
weMessagePushDto.setMsgtype(MessageType.TEXT.getMessageType());
weMessagePushDto.setTouser(message.getUserId());
weMessagePushDto.setText(textMessageDto);
Optional.ofNullable(validWeCorpAccount).map(WeCorpAccount::getAgentId).ifPresent(agentId -> {
weMessagePushDto.setAgentid(Integer.valueOf(agentId));
});
if(weCustomerService.remove(new LambdaQueryWrapper<WeCustomer>()
.eq(WeCustomer::getExternalUserid,message.getExternalUserId())
.eq(WeCustomer::getFirstUserId,message.getUserId()))){
WeCorpAccount validWeCorpAccount = weCorpAccountService.findValidWeCorpAccount();
Optional.ofNullable(validWeCorpAccount).ifPresent(weCorpAccount -> {
String customerChurnNoticeSwitch = weCorpAccount.getCustomerChurnNoticeSwitch();
if (WeConstans.DEL_FOLLOW_USER_SWITCH_OPEN.equals(customerChurnNoticeSwitch)) {
WeCustomer weCustomer = weCustomerService.selectWeCustomerById(message.getExternalUserId());
String content = "您已经被客户@" + weCustomer.getName() + "删除!";
TextMessageDto textMessageDto = new TextMessageDto();
textMessageDto.setContent(content);
WeMessagePushDto weMessagePushDto = new WeMessagePushDto();
weMessagePushDto.setMsgtype(MessageType.TEXT.getMessageType());
weMessagePushDto.setTouser(message.getUserId());
weMessagePushDto.setText(textMessageDto);
weMessagePushClient.sendMessageToUser(weMessagePushDto,weMessagePushDto.getAgentid().toString());
Optional.ofNullable(validWeCorpAccount).map(WeCorpAccount::getAgentId).ifPresent(agentId -> {
weMessagePushDto.setAgentid(Integer.valueOf(agentId));
});
//增加敏感行为记录,客户删除员工
WeSensitiveAct weSensitiveAct = weSensitiveActHitService.getSensitiveActType("拉黑/删除好友");
if (weSensitiveAct != null && weSensitiveAct.getEnableFlag() == 1) {
WeSensitiveActHit weSensitiveActHit = new WeSensitiveActHit();
weSensitiveActHit.setSensitiveActId(weSensitiveAct.getId());
weSensitiveActHit.setSensitiveAct(weSensitiveAct.getActName());
weSensitiveActHit.setCreateTime(new Date(message.getCreateTime()));
weSensitiveActHit.setCreateBy("admin");
WeUser user = weUserService.getById(message.getUserId());
weSensitiveActHit.setOperatorId(weCustomer.getUserId());
weSensitiveActHit.setOperator(weCustomer.getName());
weSensitiveActHit.setOperateTargetId(user.getUserId());
weSensitiveActHit.setOperateTarget(user.getName());
weSensitiveActHitService.insertWeSensitiveActHit(weSensitiveActHit);
weMessagePushClient.sendMessageToUser(weMessagePushDto,weMessagePushDto.getAgentid().toString());
//增加敏感行为记录,客户删除员工
WeSensitiveAct weSensitiveAct = weSensitiveActHitService.getSensitiveActType("拉黑/删除好友");
if (weSensitiveAct != null && weSensitiveAct.getEnableFlag() == 1) {
WeSensitiveActHit weSensitiveActHit = new WeSensitiveActHit();
weSensitiveActHit.setSensitiveActId(weSensitiveAct.getId());
weSensitiveActHit.setSensitiveAct(weSensitiveAct.getActName());
weSensitiveActHit.setCreateTime(new Date(message.getCreateTime()));
weSensitiveActHit.setCreateBy("admin");
WeUser user = weUserService.getById(message.getUserId());
weSensitiveActHit.setOperatorId(weCustomer.getUserId());
weSensitiveActHit.setOperator(weCustomer.getName());
weSensitiveActHit.setOperateTargetId(user.getUserId());
weSensitiveActHit.setOperateTarget(user.getName());
weSensitiveActHitService.insertWeSensitiveActHit(weSensitiveActHit);
}
}
}
});
});
}
}
} catch (Exception e) {
e.printStackTrace();
log.error("del_follow_user>>>>>>>>>>>>>param:{},ex:{}", JSONObject.toJSONString(message), e);
log.error("删除跟进成员事件>>>>>>>>>>>>>param:{},ex:{}", JSONObject.toJSONString(message), e);
}
}
}
package com.linkwechat.wecom.factory.impl.tag;
import cn.hutool.core.collection.CollectionUtil;
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.vo.WxCpXmlMessageVO;
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 lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.*;
import java.util.stream.Collectors;
/**
......@@ -27,8 +25,10 @@ import java.util.stream.Collectors;
public class WeCallBackUpdateUserTagImpl extends WeEventStrategy {
@Autowired
private IWeFlowerCustomerTagRelService weFlowerCustomerTagRelService;
@Autowired
private IWeFlowerCustomerRelService weFlowerCustomerRelService;
private IWeCustomerService iWeCustomerService;
@Override
public void eventHandle(WxCpXmlMessageVO message) {
......@@ -37,46 +37,40 @@ public class WeCallBackUpdateUserTagImpl extends WeEventStrategy {
//标签中新增的成员userid列表,用逗号分隔
List<String> addUserItemsList = Arrays.stream(Optional.ofNullable(message.getAddUserItems())
.orElse("").split(",")).collect(Collectors.toList());
if(CollectionUtil.isNotEmpty(addUserItemsList)){
//获取员工对应的所有客户
List<WeCustomer> weCustomers = iWeCustomerService.list(new LambdaQueryWrapper<WeCustomer>()
.in(WeCustomer::getFirstUserId, addUserItemsList));
if(CollectionUtil.isNotEmpty(weCustomers)){
List<WeFlowerCustomerTagRel> weFlowerCustomerTagRels = new ArrayList<>();
weCustomers.stream().forEach(k->{
weFlowerCustomerTagRels.add(
WeFlowerCustomerTagRel.builder()
.userId(k.getFirstUserId())
.externalUserid(k.getExternalUserid())
.tagId(tagId)
.createTime(new Date())
.build()
);
});
weFlowerCustomerTagRelService.batchAddOrUpdate(weFlowerCustomerTagRels);
}
}
//标签中删除的成员userid列表,用逗号分隔
List<String> delUserItemsList = Arrays.stream(Optional.ofNullable(message.getDelUserItems())
.orElse("").split(",")).collect(Collectors.toList());
//标签中新增的成员userid列表,建立关联
List<WeFlowerCustomerTagRel> weFlowerCustomerTagRels = new ArrayList<>();
LambdaQueryWrapper<WeFlowerCustomerRel> relLambdaQueryWrapper = new LambdaQueryWrapper<>();
relLambdaQueryWrapper.in(WeFlowerCustomerRel::getUserId, addUserItemsList);
List<WeFlowerCustomerRel> flowerCustomerRelList = weFlowerCustomerRelService.list(relLambdaQueryWrapper);
List<Long> idList = Optional.ofNullable(flowerCustomerRelList).orElseGet(ArrayList::new)
.stream().map(WeFlowerCustomerRel::getId).collect(Collectors.toList());
idList.forEach(id -> {
weFlowerCustomerTagRels.add(WeFlowerCustomerTagRel.builder().flowerCustomerRelId(id)
.tagId(tagId)
.build());
});
weFlowerCustomerTagRelService.batchInsetWeFlowerCustomerTagRel(weFlowerCustomerTagRels);
//当前标签对应成员列表
LambdaQueryWrapper<WeFlowerCustomerTagRel> tagRelLambdaQueryWrapper = new LambdaQueryWrapper<>();
tagRelLambdaQueryWrapper.eq(WeFlowerCustomerTagRel::getTagId, tagId);
List<WeFlowerCustomerTagRel> tagRelList = weFlowerCustomerTagRelService.list(tagRelLambdaQueryWrapper);
if(CollectionUtil.isNotEmpty(delUserItemsList)){
weFlowerCustomerTagRelService.remove(new LambdaQueryWrapper<WeFlowerCustomerTagRel>()
.in(WeFlowerCustomerTagRel::getTagId,delUserItemsList));
}
List<Long> flowerCustomerRelIdList = Optional.ofNullable(tagRelList).orElseGet(ArrayList::new)
.stream().map(WeFlowerCustomerTagRel::getFlowerCustomerRelId).collect(Collectors.toList());
if (!flowerCustomerRelIdList.isEmpty()) {
LambdaQueryWrapper<WeFlowerCustomerRel> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(WeFlowerCustomerRel::getId, flowerCustomerRelIdList)
.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) {
e.printStackTrace();
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>
List<CusertomerBelongUserInfo> findCusertomerBelongUserInfo(@Param("externalUserId") String externalUserId);
void batchAddOrUpdate(@Param("weCustomers") List<WeCustomer> weCustomer);
}
......@@ -3,7 +3,9 @@ package com.linkwechat.wecom.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linkwechat.wecom.domain.WeCustomer;
import com.linkwechat.wecom.domain.WeFlowerCustomerTagRel;
import org.apache.ibatis.annotations.Param;
/**
* 客户标签关系Mapper接口
......@@ -68,4 +70,7 @@ public interface WeFlowerCustomerTagRelMapper extends BaseMapper<WeFlowerCustom
* @return
*/
public int batchInsetWeFlowerCustomerTagRel(List<WeFlowerCustomerTagRel> weFlowerCustomerTagRels);
void batchAddOrUpdate(@Param("tagRels") List<WeFlowerCustomerTagRel> tagRels);
}
package com.linkwechat.wecom.mapper;
import com.linkwechat.wecom.domain.WeGroupMessageList;
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接口
......@@ -11,4 +15,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/
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;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.IService;
import com.linkwechat.wecom.domain.WeCustomer;
import com.linkwechat.wecom.domain.WeCustomerList;
......@@ -67,11 +68,11 @@ public interface IWeCustomerService extends IService<WeCustomer>
public void makeLabel(WeMakeCustomerTag weMakeCustomerTag);
/**
* 移除客户标签
* @param weMakeCustomerTag
*/
public void removeLabel(WeMakeCustomerTag weMakeCustomerTag);
// /**
// * 移除客户标签
// * @param weMakeCustomerTag
// */
// public void removeLabel(WeMakeCustomerTag weMakeCustomerTag);
/**
......@@ -88,11 +89,7 @@ public interface IWeCustomerService extends IService<WeCustomer>
*/
public void getCustomersInfoAndSynchWeCustomer(String externalUserid,String userId);
/**
* 删除客户
* @param externalUserid
*/
public void deleteCustomersByEid(String externalUserid);
/**
* 向客户发送欢迎语
......@@ -106,12 +103,7 @@ public interface IWeCustomerService extends IService<WeCustomer>
*/
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>
WeCustomerDetailVo findWeCustomerDetail(String externalUserid);
/**
* 客户条件检索
* @param params
*/
void getCustomerByCondition(JSONObject params);
}
......@@ -8,7 +8,7 @@ import com.linkwechat.wecom.domain.WeFlowerCustomerRel;
/**
* 具有外部联系人功能企业员工也客户的关系Service接口
*
*
* @author ruoyi
* @date 2020-09-19
*/
......
......@@ -4,6 +4,7 @@ import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import com.linkwechat.wecom.domain.WeFlowerCustomerTagRel;
import org.apache.ibatis.annotations.Param;
/**
* 客户标签关系Service接口
......@@ -70,4 +71,7 @@ public interface IWeFlowerCustomerTagRelService extends IService<WeFlowerCustome
* @return
*/
public int batchInsetWeFlowerCustomerTagRel(List<WeFlowerCustomerTagRel> weFlowerCustomerTagRels);
void batchAddOrUpdate(List<WeFlowerCustomerTagRel> tagRels);
}
package com.linkwechat.wecom.service;
import com.linkwechat.wecom.domain.WeGroupMessageList;
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.vo.WeGroupMessageListVo;
import java.util.List;
......@@ -13,12 +14,6 @@ import java.util.List;
* @date 2021-10-19
*/
public interface IWeGroupMessageListService extends IService<WeGroupMessageList> {
/**
* 查询列表
*/
List<WeGroupMessageList> queryList(WeGroupMessageList weGroupMessageList);
/**
* 获取群发记录列表
*
......@@ -31,11 +26,9 @@ public interface IWeGroupMessageListService extends IService<WeGroupMessageList>
WeGroupMsgListDto getGroupMsgList(String chatType, Long startTime, Long endTime, String cursor);
/**
* 获取群发成员发送任务列表
*
* @param msgId 群发消息的id
* @param cursor 用于分页查询的游标
* @return WeGroupMsgListDto 群发成员发送任务列表
* 查询群发消息详情
* @param msgTemplateId 模板id
* @return
*/
WeGroupMsgListDto getGroupMsgTask(String msgId, String cursor);
List<WeGroupMessageListVo> getGroupMsgDetail(Long msgTemplateId);
}
......@@ -2,6 +2,7 @@ package com.linkwechat.wecom.service;
import com.linkwechat.wecom.domain.WeGroupMessageSendResult;
import com.baomidou.mybatisplus.extension.service.IService;
import com.linkwechat.wecom.domain.WeGroupMessageTask;
import com.linkwechat.wecom.domain.dto.message.WeGroupMsgListDto;
import java.util.List;
......@@ -28,4 +29,7 @@ public interface IWeGroupMessageSendResultService extends IService<WeGroupMessag
* @return WeGroupMsgListDto 群成员发送结果列表
*/
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 {
* @return
*/
WeMediaDto uploadImg(MultipartFile file);
/**
* 获取素材
* @param mediaId 素材id
* @return
*/
WeMediaDto getMediaToResponse(String mediaId);
}
......@@ -105,4 +105,9 @@ public class WeFlowerCustomerTagRelServiceImpl extends ServiceImpl<WeFlowerCusto
public int batchInsetWeFlowerCustomerTagRel(List<WeFlowerCustomerTagRel> weFlowerCustomerTagRels) {
return weFlowerCustomerTagRelMapper.batchInsetWeFlowerCustomerTagRel(weFlowerCustomerTagRels);
}
@Override
public void batchAddOrUpdate(List<WeFlowerCustomerTagRel> tagRels) {
this.baseMapper.batchAddOrUpdate(tagRels);
}
}
package com.linkwechat.wecom.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
......@@ -7,14 +8,15 @@ 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.WeGroupMessageSendResult;
import com.linkwechat.wecom.domain.WeGroupMessageTask;
import com.linkwechat.wecom.domain.dto.message.WeGroupMsgListDto;
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.mapper.WeGroupMessageSendResultMapper;
import com.linkwechat.wecom.service.IWeGroupMessageSendResultService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
......@@ -56,12 +58,12 @@ public class WeGroupMessageSendResultServiceImpl extends ServiceImpl<WeGroupMess
@Override
public WeGroupMsgListDto getGroupMsgSendResult(String msgId, String userId, String cursor) {
WeGetGroupMsgListQuery query = new WeGetGroupMsgListQuery();
query.setMsgId(msgId);
query.setUserId(userId);
query.setMsgid(msgId);
query.setUserid(userId);
query.setCursor(cursor);
WeGroupMsgListDto groupMsgSendResult = messagePushClient.getGroupMsgSendResult(query);
if(groupMsgSendResult != null && ObjectUtil.equal(0,groupMsgSendResult.getErrcode())){
if(StringUtils.isNotEmpty(groupMsgSendResult.getNextCursor())){
if (groupMsgSendResult != null && ObjectUtil.equal(0, groupMsgSendResult.getErrcode())) {
if (StringUtils.isNotEmpty(groupMsgSendResult.getNextCursor())) {
WeGroupMsgListDto clildMsgList = getGroupMsgSendResult(msgId, userId, groupMsgSendResult.getNextCursor());
List<WeGroupMsgSendDto> sendList = clildMsgList.getSendList();
sendList.addAll(clildMsgList.getSendList());
......@@ -71,4 +73,24 @@ public class WeGroupMessageSendResultServiceImpl extends ServiceImpl<WeGroupMess
}
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;
import cn.hutool.core.collection.CollectionUtil;
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.RuoYiConfig;
import com.linkwechat.common.config.ServerConfig;
import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.enums.WeErrorCodeEnum;
import com.linkwechat.common.exception.wecom.WeComException;
import com.linkwechat.common.utils.SnowFlakeUtil;
import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.common.utils.file.FileUploadUtils;
import com.linkwechat.common.utils.file.FileUtils;
import com.linkwechat.wecom.client.WeMediaClient;
import com.linkwechat.wecom.domain.WeMaterial;
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.mapper.WeMaterialMapper;
import com.linkwechat.wecom.service.IWeMaterialService;
......@@ -23,6 +29,7 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Arrays;
......@@ -157,4 +164,33 @@ public class WeMaterialServiceImpl implements IWeMaterialService {
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;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.URL;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
......@@ -114,7 +115,7 @@ public class WePosterServiceImpl extends ServiceImpl<WePosterMapper, WePoster> i
}
/**
* 生成海报图片地址
* 生成海报图片地址(合成图片+文字)
*
* @param poster
* @return
......@@ -125,6 +126,7 @@ public class WePosterServiceImpl extends ServiceImpl<WePosterMapper, WePoster> i
poster.setSampleImgPath(poster.getBackgroundImgPath());
return poster.getBackgroundImgPath();
}
Set<String> existFontId = new HashSet<>();
......@@ -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 -> {
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);
} catch (IOException e) {
e.printStackTrace();
......
package com.linkwechat.wecom.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.common.collect.Lists;
import com.linkwechat.common.config.CosConfig;
import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.enums.TaskFissionType;
import com.linkwechat.common.exception.wecom.WeComException;
......@@ -15,7 +13,6 @@ import com.linkwechat.common.utils.DateUtils;
import com.linkwechat.common.utils.QREncode;
import com.linkwechat.common.utils.SecurityUtils;
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.img.NetFileUtils;
import com.linkwechat.wecom.client.WeExternalContactClient;
......@@ -73,8 +70,7 @@ public class WeTaskFissionServiceImpl extends ServiceImpl<WeTaskFissionMapper, W
private IWeGroupCodeService weGroupCodeService;
@Autowired
private IWeCustomerService weCustomerService;
@Autowired
private IWeFlowerCustomerRelService weFlowerCustomerRelService;
@Autowired
private IWeTaskFissionCompleteRecordService weTaskFissionCompleteRecordService;
......@@ -310,16 +306,16 @@ public class WeTaskFissionServiceImpl extends ServiceImpl<WeTaskFissionMapper, W
});
}
} else {
WeTaskFissionRecord weTaskFissionRecord = weTaskFissionRecordService
.selectWeTaskFissionRecordByIdAndCustomerId(Long.valueOf(fissionId), unionId);
Optional.ofNullable(weTaskFissionRecord).orElseThrow(() -> new WeComException("任务记录信息不存在"));
List<WeFlowerCustomerRel> list = weFlowerCustomerRelService.list(new LambdaQueryWrapper<WeFlowerCustomerRel>()
.eq(WeFlowerCustomerRel::getState, WeConstans.FISSION_PREFIX + weTaskFissionRecord.getId()));
List<String> eidList = Optional.ofNullable(list).orElseGet(ArrayList::new).stream()
.map(WeFlowerCustomerRel::getExternalUserid).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(eidList)) {
customerList.addAll(weCustomerService.listByIds(eidList));
}
// WeTaskFissionRecord weTaskFissionRecord = weTaskFissionRecordService
// .selectWeTaskFissionRecordByIdAndCustomerId(Long.valueOf(fissionId), unionId);
// Optional.ofNullable(weTaskFissionRecord).orElseThrow(() -> new WeComException("任务记录信息不存在"));
// List<WeFlowerCustomerRel> list = weFlowerCustomerRelService.list(new LambdaQueryWrapper<WeFlowerCustomerRel>()
// .eq(WeFlowerCustomerRel::getState, WeConstans.FISSION_PREFIX + weTaskFissionRecord.getId()));
// List<String> eidList = Optional.ofNullable(list).orElseGet(ArrayList::new).stream()
// .map(WeFlowerCustomerRel::getExternalUserid).collect(Collectors.toList());
// if (CollectionUtil.isNotEmpty(eidList)) {
// customerList.addAll(weCustomerService.listByIds(eidList));
// }
}
return customerList;
}
......
......@@ -548,6 +548,46 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</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"
<mapper namespace="com.linkwechat.wecom.mapper.WeFlowerCustomerTagRelMapper">
<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="createTime" column="create_time" />
</resultMap>
<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>
<select id="selectWeFlowerCustomerTagRelList" parameterType="WeFlowerCustomerTagRel" resultMap="WeFlowerCustomerTagRelResult">
......@@ -31,14 +29,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertWeFlowerCustomerTagRel" parameterType="WeFlowerCustomerTagRel">
insert into we_flower_customer_tag_rel
<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="createTime != null">create_time,</if>
</trim>
<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="createTime != null">#{createTime},</if>
</trim>
......@@ -73,5 +69,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
(#{tag.id},#{tag.flowerCustomerRelId},#{tag.tagId},#{tag.createTime})
</foreach>
</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>
\ No newline at end of file
......@@ -6,12 +6,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="WeGroupMessageAttachments" id="WeGroupMessageAttachmentsResult">
<result property="id" column="id" />
<result property="msgTemplateId" column="msg_template_id" />
<result property="msgId" column="msg_id" />
<result property="msgType" column="msg_type" />
<result property="content" column="content" />
<result property="mediaId" column="media_id" />
<result property="title" column="title" />
<result property="description" column="description" />
<result property="fileUrl" column="file_url" />
<result property="linkUrl" column="link_url" />
<result property="picUrl" column="pic_url" />
<result property="appId" column="app_id" />
......
......@@ -6,17 +6,90 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="WeGroupMessageList" id="WeGroupMessageListResult">
<result property="id" column="id" />
<result property="msgTemplateId" column="msg_template_id" />
<result property="msgId" column="msg_id" />
<result property="chatType" column="chat_type" />
<result property="userId" column="user_id" />
<result property="sendTime" column="send_time" />
<result property="createType" column="create_type" />
<result property="isTask" column="is_task" />
<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>
<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>
\ No newline at end of file
......@@ -6,6 +6,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="WeGroupMessageSendResult" id="WeGroupMessageSendResultResult">
<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="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
<?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
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!