Commit 22ba25cd by danmo

1、重构发送欢迎语

2、修改活码详情sql
1 parent a564f800
Showing 18 changed files with 531 additions and 90 deletions
package com.linkwechat.web.controller.wecom;
import com.github.pagehelper.PageInfo;
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.query.qr.WeQrAddQuery;
import com.linkwechat.wecom.domain.query.qr.WeQrCodeListQuery;
import com.linkwechat.wecom.domain.vo.qr.WeQrCodeDetailVo;
import com.linkwechat.wecom.domain.vo.qr.WeQrCodeScanCountVo;
import com.linkwechat.wecom.service.IWeQrCodeService;
import com.linkwechat.wecom.service.event.WeEventPublisherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @author danmo
* @description 活码管理
* @date 2021/11/12 18:22
**/
@RestController
@RequestMapping(value = "wecom/qr/")
@Api(tags = "活码管理")
public class WeQrCodeController extends BaseController {
@Autowired
private IWeQrCodeService weQrCodeService;
@Autowired
private WeEventPublisherService weEventPublisherService;
@ApiOperation(value = "新增活码", httpMethod = "POST")
@Log(title = "活码管理", businessType = BusinessType.INSERT)
@PostMapping("/add")
public AjaxResult addQrCode(@RequestBody @Validated WeQrAddQuery weQrAddQuery) {
weQrCodeService.addQrCode(weQrAddQuery);
return AjaxResult.success();
}
@ApiOperation(value = "修改活码", httpMethod = "POST")
@Log(title = "活码管理", businessType = BusinessType.UPDATE)
@PutMapping("/update")
public AjaxResult updateQrCode(@RequestBody @Validated WeQrAddQuery weQrAddQuery) {
weQrCodeService.updateQrCode(weQrAddQuery);
return AjaxResult.success();
}
@ApiOperation(value = "获取活码详情", httpMethod = "GET")
@Log(title = "活码管理", businessType = BusinessType.SELECT)
@GetMapping("/get/{id}")
public AjaxResult<WeQrCodeDetailVo> getQrDetail(@PathVariable("id") Long Id) {
WeQrCodeDetailVo qrDetail = weQrCodeService.getQrDetail(Id);
return AjaxResult.success(qrDetail);
}
@ApiOperation(value = "获取活码列表", httpMethod = "GET")
@Log(title = "活码管理", businessType = BusinessType.SELECT)
@GetMapping("/list")
public TableDataInfo<WeQrCodeDetailVo> getQrCodeList(WeQrCodeListQuery qrCodeListQuery) {
startPage();
PageInfo<WeQrCodeDetailVo> qrCodeList = weQrCodeService.getQrCodeList(qrCodeListQuery);
return getDataTable(qrCodeList);
}
@ApiOperation(value = "删除活码", httpMethod = "DELETE")
@Log(title = "活码管理", businessType = BusinessType.SELECT)
@DeleteMapping("/del/{ids}")
public AjaxResult<WeQrCodeDetailVo> delQrCode(@PathVariable("ids") List<Long> ids) {
weQrCodeService.delQrCode(ids);
return AjaxResult.success();
}
@ApiOperation(value = "获取活码统计", httpMethod = "GET")
@Log(title = "活码管理", businessType = BusinessType.SELECT)
@GetMapping("/scan/count")
public AjaxResult<WeQrCodeScanCountVo> getWeQrCodeScanCount(WeQrCodeListQuery qrCodeListQuery) {
WeQrCodeScanCountVo weQrCodeScanCount = weQrCodeService.getWeQrCodeScanCount(qrCodeListQuery);
return AjaxResult.success(weQrCodeScanCount);
}
@GetMapping("/test")
public AjaxResult test() {
weEventPublisherService.register("123","213","213","123");
return AjaxResult.success();
}
}
package com.linkwechat.wecom.domain.dto; package com.linkwechat.wecom.domain.dto;
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 com.linkwechat.wecom.domain.WeQrAttachments;
import com.linkwechat.wecom.domain.query.WeAddMsgTemplateQuery;
import io.swagger.annotations.ApiModelProperty;
import lombok.experimental.SuperBuilder; import lombok.experimental.SuperBuilder;
import lombok.Data; import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/** /**
* @author admin * @author admin
* @date 2020-11-18 * @date 2020-11-18
...@@ -20,6 +31,8 @@ public class WeWelcomeMsg { ...@@ -20,6 +31,8 @@ public class WeWelcomeMsg {
private MiniProgram miniprogram; private MiniProgram miniprogram;
private List<WeAddMsgTemplateQuery.Attachments> attachments;
@Data @Data
@SuperBuilder @SuperBuilder
public static class Text { public static class Text {
...@@ -83,4 +96,31 @@ public class WeWelcomeMsg { ...@@ -83,4 +96,31 @@ public class WeWelcomeMsg {
*/ */
private String page; private String page;
} }
public void setAttachments(List<WeQrAttachments> messageTemplates) {
this.attachments = new ArrayList<>(16);
if (CollectionUtil.isNotEmpty(messageTemplates)) {
messageTemplates.forEach(messageTemplate -> {
if (ObjectUtil.equal(MessageType.IMAGE.getMessageType(), messageTemplate.getMsgType())) {
WeAddMsgTemplateQuery.Attachments images = new WeAddMsgTemplateQuery.Images(messageTemplate.getMsgType(), messageTemplate.getMediaId(),
messageTemplate.getPicUrl());
attachments.add(images);
} else if (ObjectUtil.equal(MessageType.LINK.getMessageType(), messageTemplate.getMsgType())) {
WeAddMsgTemplateQuery.Attachments links = new WeAddMsgTemplateQuery.Links(messageTemplate.getMsgType(), messageTemplate.getTitle(),
messageTemplate.getPicUrl(), messageTemplate.getDescription(), messageTemplate.getLinkUrl());
attachments.add(links);
} else if (ObjectUtil.equal(MessageType.MINIPROGRAM.getMessageType(), messageTemplate.getMsgType())) {
WeAddMsgTemplateQuery.Attachments miniprograms = new WeAddMsgTemplateQuery.Miniprograms(messageTemplate.getMsgType(), messageTemplate.getTitle(),
messageTemplate.getMediaId(), messageTemplate.getAppId(), messageTemplate.getLinkUrl());
attachments.add(miniprograms);
} else if (ObjectUtil.equal(MessageType.VIDEO.getMessageType(), messageTemplate.getMsgType())) {
WeAddMsgTemplateQuery.Attachments videos = new WeAddMsgTemplateQuery.Videos(messageTemplate.getMsgType(), messageTemplate.getMediaId());
attachments.add(videos);
} else if (ObjectUtil.equal(MessageType.FILE.getMessageType(), messageTemplate.getMsgType())) {
WeAddMsgTemplateQuery.Attachments files = new WeAddMsgTemplateQuery.Files(messageTemplate.getMsgType(), messageTemplate.getMediaId());
attachments.add(files);
}
});
}
}
} }
...@@ -50,9 +50,8 @@ public class WeAddMsgTemplateQuery { ...@@ -50,9 +50,8 @@ public class WeAddMsgTemplateQuery {
} }
public void setAttachments(List<WeMessageTemplate> messageTemplates) { public void setAttachments(List<WeMessageTemplate> messageTemplates) {
final int size = 10;
this.attachments = new ArrayList<>(16); this.attachments = new ArrayList<>(16);
if (CollectionUtil.isNotEmpty(messageTemplates) && messageTemplates.size() < size) { if (CollectionUtil.isNotEmpty(messageTemplates)) {
messageTemplates.forEach(messageTemplate -> { messageTemplates.forEach(messageTemplate -> {
if (ObjectUtil.equal(MessageType.IMAGE.getMessageType(), 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(),
...@@ -74,8 +73,6 @@ public class WeAddMsgTemplateQuery { ...@@ -74,8 +73,6 @@ public class WeAddMsgTemplateQuery {
attachments.add(files); attachments.add(files);
} }
}); });
} else {
throw new WeComException("仅支持最多同时发送9个附件");
} }
} }
......
package com.linkwechat.wecom.domain.query;
import org.springframework.context.ApplicationEvent;
/**
* @author danmo
* @description 客户欢迎语
* @date 2021/11/13 18:54
**/
public class WeCustomerWelcomeQuery extends ApplicationEvent {
/**
* 客户id
*/
private String externalUserId;
/**
* 员工id
*/
private String userId;
/**
* 欢迎语code
*/
private String welcomeCode;
/**
* 添加渠道
*/
private String state;
public WeCustomerWelcomeQuery(Object source, String externalUserId, String userId, String welcomeCode, String state) {
super(source);
this.externalUserId = externalUserId;
this.userId = userId;
this.welcomeCode = welcomeCode;
this.state = state;
}
public String getExternalUserId() {
return externalUserId;
}
public void setExternalUserId(String externalUserId) {
this.externalUserId = externalUserId;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getWelcomeCode() {
return welcomeCode;
}
public void setWelcomeCode(String welcomeCode) {
this.welcomeCode = welcomeCode;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
}
...@@ -16,6 +16,8 @@ import lombok.Data; ...@@ -16,6 +16,8 @@ import lombok.Data;
import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List; import java.util.List;
/** /**
...@@ -31,18 +33,21 @@ public class WeQrAddQuery { ...@@ -31,18 +33,21 @@ public class WeQrAddQuery {
private Long qrId; private Long qrId;
@ApiModelProperty("名称") @ApiModelProperty("名称")
@NotEmpty(message = "活码名称不能为空")
private String qrName; private String qrName;
@ApiModelProperty("分组id") @ApiModelProperty("分组id")
@NotNull(message = "分组ID不能为空")
private Long qrGroupId; private Long qrGroupId;
@ApiModelProperty("是否自动添加 1-是 0-否") @ApiModelProperty("是否自动添加 1-是 0-否 默认是 1")
private Integer qrAutoAdd; private Integer qrAutoAdd = 1;
@ApiModelProperty("标签id列表") @ApiModelProperty("标签id列表")
private List<String> qrTags; private List<String> qrTags;
@ApiModelProperty("活码类型 1-单人, 2-多人") @ApiModelProperty("活码类型 1-单人, 2-多人")
@NotNull(message = "活码类型不能为空")
private Integer qrType; private Integer qrType;
@ApiModelProperty("排班类型 1-全天 2-自动") @ApiModelProperty("排班类型 1-全天 2-自动")
...@@ -52,6 +57,7 @@ public class WeQrAddQuery { ...@@ -52,6 +57,7 @@ public class WeQrAddQuery {
private List<WeQrUserInfoQuery> qrUserInfos; private List<WeQrUserInfoQuery> qrUserInfos;
@ApiModelProperty("欢迎语素材列表") @ApiModelProperty("欢迎语素材列表")
@NotNull(message = "欢迎语素材列表不能为空")
private List<WeMessageTemplate> attachments; private List<WeMessageTemplate> attachments;
@ApiModelProperty(value = "渠道",hidden = true) @ApiModelProperty(value = "渠道",hidden = true)
......
...@@ -7,7 +7,7 @@ import lombok.Data; ...@@ -7,7 +7,7 @@ import lombok.Data;
import java.util.List; import java.util.List;
/** /**
* @author sxw * @author danmo
* @description 活码适用范围出参 * @description 活码适用范围出参
* @date 2021/11/8 22:33 * @date 2021/11/8 22:33
**/ **/
...@@ -15,6 +15,9 @@ import java.util.List; ...@@ -15,6 +15,9 @@ import java.util.List;
@Data @Data
public class WeQrScopeVo { public class WeQrScopeVo {
@ApiModelProperty(value = "活码id")
private Long qrId;
@ApiModelProperty(value = "消息类型 0 默认排期 1 自定义排期") @ApiModelProperty(value = "消息类型 0 默认排期 1 自定义排期")
private Integer type; private Integer type;
......
...@@ -16,6 +16,7 @@ import com.linkwechat.wecom.domain.dto.customer.CutomerTagEdit; ...@@ -16,6 +16,7 @@ import com.linkwechat.wecom.domain.dto.customer.CutomerTagEdit;
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.*; import com.linkwechat.wecom.service.*;
import com.linkwechat.wecom.service.event.WeEventPublisherService;
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;
...@@ -54,11 +55,7 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy { ...@@ -54,11 +55,7 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy {
private ThreadLocal<WeFlowerCustomerRel> weFlowerCustomerRelThreadLocal = new ThreadLocal<>(); private ThreadLocal<WeFlowerCustomerRel> weFlowerCustomerRelThreadLocal = new ThreadLocal<>();
@Autowired @Autowired
private IWeGroupCodeService weGroupCodeService; private WeEventPublisherService weEventPublisherService;
@Autowired
private WeCustomerClient weCustomerClient;
@Override @Override
...@@ -132,8 +129,8 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy { ...@@ -132,8 +129,8 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy {
private void empleCodeHandle(String state, String wecomCode, String userId, String externalUserId) { private void empleCodeHandle(String state, String wecomCode, String userId, String externalUserId) {
if(StringUtils.isNotEmpty(userId) && StringUtils.isNotEmpty(externalUserId)){ if(StringUtils.isNotEmpty(userId) && StringUtils.isNotEmpty(externalUserId)){
try { try {
weEventPublisherService.register(externalUserId,userId,wecomCode,state);
log.info("执行发送欢迎语>>>>>>>>>>>>>>>"); /*log.info("执行发送欢迎语>>>>>>>>>>>>>>>");
WeWelcomeMsg.WeWelcomeMsgBuilder weWelcomeMsgBuilder = WeWelcomeMsg.builder().welcome_code(wecomCode); WeWelcomeMsg.WeWelcomeMsgBuilder weWelcomeMsgBuilder = WeWelcomeMsg.builder().welcome_code(wecomCode);
WeEmpleCodeDto messageMap = weEmpleCodeService.selectWelcomeMsgByState(state); WeEmpleCodeDto messageMap = weEmpleCodeService.selectWelcomeMsgByState(state);
if (StringUtils.isNotNull(messageMap)) { if (StringUtils.isNotNull(messageMap)) {
...@@ -192,7 +189,7 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy { ...@@ -192,7 +189,7 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy {
} }
weCustomerService.sendWelcomeMsg(weWelcomeMsgBuilder.build()); weCustomerService.sendWelcomeMsg(weWelcomeMsgBuilder.build());
} }*/
} catch (Exception e) { } catch (Exception e) {
log.error("执行发送欢迎语失败!", e.getMessage()); log.error("执行发送欢迎语失败!", e.getMessage());
......
...@@ -14,6 +14,7 @@ import com.linkwechat.wecom.domain.dto.WeWelcomeMsg; ...@@ -14,6 +14,7 @@ import com.linkwechat.wecom.domain.dto.WeWelcomeMsg;
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.*; import com.linkwechat.wecom.service.*;
import com.linkwechat.wecom.service.event.WeEventPublisherService;
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;
...@@ -45,15 +46,22 @@ public class WeCallBackAddHalfExternalContactImpl extends WeEventStrategy { ...@@ -45,15 +46,22 @@ public class WeCallBackAddHalfExternalContactImpl extends WeEventStrategy {
@Autowired @Autowired
private IWeMaterialService weMaterialService; private IWeMaterialService weMaterialService;
@Autowired
private WeEventPublisherService weEventPublisherService;
@Override @Override
public void eventHandle(WxCpXmlMessageVO message) { public void eventHandle(WxCpXmlMessageVO message) {
try { try {
if (message.getExternalUserId() != null) { if (message.getExternalUserId() != null) {
weCustomerService.getCustomersInfoAndSynchWeCustomer(message.getExternalUserId(),message.getUserId()); weCustomerService.getCustomersInfoAndSynchWeCustomer(message.getExternalUserId(),message.getUserId());
} }
//向扫码客户发送欢迎语
if (message.getState() != null && message.getWelcomeCode() != null) { if (message.getState() != null && message.getWelcomeCode() != null) {
weEventPublisherService.register(message.getExternalUserId(),message.getUserId(),message.getWelcomeCode(),message.getState());
}
//向扫码客户发送欢迎语
/*if (message.getState() != null && message.getWelcomeCode() != null) {
log.info("执行发送欢迎语>>>>>>>>>>>>>>>"); log.info("执行发送欢迎语>>>>>>>>>>>>>>>");
weEventPublisherService.register(message.getExternalUserId(),message.getUserId(),message.getWelcomeCode(),message.getState());
WeWelcomeMsg.WeWelcomeMsgBuilder weWelcomeMsgBuilder = WeWelcomeMsg.builder().welcome_code(message.getWelcomeCode()); WeWelcomeMsg.WeWelcomeMsgBuilder weWelcomeMsgBuilder = WeWelcomeMsg.builder().welcome_code(message.getWelcomeCode());
WeEmpleCodeDto messageMap = weEmpleCodeService.selectWelcomeMsgByScenario(message.getState(),message.getUserId()); WeEmpleCodeDto messageMap = weEmpleCodeService.selectWelcomeMsgByScenario(message.getState(),message.getUserId());
String empleCodeId = messageMap.getEmpleCodeId(); String empleCodeId = messageMap.getEmpleCodeId();
...@@ -95,7 +103,7 @@ public class WeCallBackAddHalfExternalContactImpl extends WeEventStrategy { ...@@ -95,7 +103,7 @@ public class WeCallBackAddHalfExternalContactImpl extends WeEventStrategy {
} }
weCustomerService.sendWelcomeMsg(weWelcomeMsgBuilder.build()); weCustomerService.sendWelcomeMsg(weWelcomeMsgBuilder.build());
} }
} }*/
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
log.error("执行发送欢迎语失败!",e); log.error("执行发送欢迎语失败!",e);
......
...@@ -6,6 +6,7 @@ import com.linkwechat.wecom.domain.WeQrCode; ...@@ -6,6 +6,7 @@ import com.linkwechat.wecom.domain.WeQrCode;
import com.linkwechat.wecom.domain.query.qr.WeQrCodeListQuery; import com.linkwechat.wecom.domain.query.qr.WeQrCodeListQuery;
import com.linkwechat.wecom.domain.vo.qr.WeQrCodeDetailVo; import com.linkwechat.wecom.domain.vo.qr.WeQrCodeDetailVo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
...@@ -25,14 +26,14 @@ public interface WeQrCodeMapper extends BaseMapper<WeQrCode> { ...@@ -25,14 +26,14 @@ public interface WeQrCodeMapper extends BaseMapper<WeQrCode> {
* @param qrId 活码id * @param qrId 活码id
* @return * @return
*/ */
WeQrCodeDetailVo getQrDetailByQrId(Long qrId); WeQrCodeDetailVo getQrDetailByQrId(@Param("qrId") Long qrId);
/** /**
* 根据活码id批量查询详情 * 根据活码id批量查询详情
* @param qrIds 活码id * @param qrIds 活码id
* @return * @return
*/ */
List<WeQrCodeDetailVo> getQrDetailByQrIds(List<Long> qrIds); List<WeQrCodeDetailVo> getQrDetailByQrIds(@Param("qrIds") List<Long> qrIds);
/** /**
* 查询活码列表id * 查询活码列表id
......
...@@ -2,6 +2,7 @@ package com.linkwechat.wecom.mapper; ...@@ -2,6 +2,7 @@ package com.linkwechat.wecom.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.annotation.SqlParser; import com.baomidou.mybatisplus.annotation.SqlParser;
import com.linkwechat.wecom.domain.vo.qr.WeQrScopeVo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
...@@ -21,5 +22,6 @@ import com.linkwechat.wecom.domain.WeQrScope; ...@@ -21,5 +22,6 @@ import com.linkwechat.wecom.domain.WeQrScope;
public interface WeQrScopeMapper extends BaseMapper<WeQrScope> { public interface WeQrScopeMapper extends BaseMapper<WeQrScope> {
List<WeQrScopeVo> getWeQrScopeByQrIds(@Param("qrIds") List<Long> qrIds);
} }
...@@ -54,6 +54,4 @@ public interface IWeQrCodeService extends IService<WeQrCode> { ...@@ -54,6 +54,4 @@ public interface IWeQrCodeService extends IService<WeQrCode> {
* @return WeQrCodeScanCountVo * @return WeQrCodeScanCountVo
*/ */
WeQrCodeScanCountVo getWeQrCodeScanCount(WeQrCodeListQuery qrCodeListQuery); WeQrCodeScanCountVo getWeQrCodeScanCount(WeQrCodeListQuery qrCodeListQuery);
}
}
package com.linkwechat.wecom.service; package com.linkwechat.wecom.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.linkwechat.wecom.domain.query.qr.WeQrUserInfoQuery;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.linkwechat.wecom.domain.WeQrScope; import com.linkwechat.wecom.domain.WeQrScope;
import com.linkwechat.wecom.domain.query.qr.WeQrUserInfoQuery;
import com.linkwechat.wecom.domain.vo.qr.WeQrScopeVo;
import java.util.List; import java.util.List;
...@@ -37,4 +35,11 @@ public interface IWeQrScopeService extends IService<WeQrScope> { ...@@ -37,4 +35,11 @@ public interface IWeQrScopeService extends IService<WeQrScope> {
* @param qrUserInfos 适用范围列表 * @param qrUserInfos 适用范围列表
*/ */
void updateBatchByQrId(Long qrId, List<WeQrUserInfoQuery> qrUserInfos); void updateBatchByQrId(Long qrId, List<WeQrUserInfoQuery> qrUserInfos);
/**
* 根据活码id查询适用范围
* @param qrIds 活码id
* @return
*/
List<WeQrScopeVo> getWeQrScopeByQrIds(List<Long> qrIds);
} }
package com.linkwechat.wecom.service.event;
import com.linkwechat.wecom.domain.query.WeCustomerWelcomeQuery;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Service;
/**
* @author danmo
* @description 注册事件发布
* @date 2021/11/13 19:01
**/
@Service
@Slf4j
public class WeEventPublisherService implements ApplicationEventPublisherAware {
private ApplicationEventPublisher applicationEventPublisher;
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.applicationEventPublisher = applicationEventPublisher;
}
/**
* 发布欢迎语事件
*/
public void register(String externalUserId, String userId, String welcomeCode, String state) {
log.info("发布发送欢迎语事件:externalUserId:{},userId:{},welcomeCode:{},state:{}",externalUserId,userId,welcomeCode,state);
applicationEventPublisher.publishEvent(new WeCustomerWelcomeQuery(this, externalUserId,userId,welcomeCode,state));
}
}
...@@ -7,6 +7,7 @@ import cn.hutool.core.util.RandomUtil; ...@@ -7,6 +7,7 @@ import cn.hutool.core.util.RandomUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.linkwechat.common.utils.StringUtils; import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.wecom.domain.query.qr.WeQrUserInfoQuery; import com.linkwechat.wecom.domain.query.qr.WeQrUserInfoQuery;
import com.linkwechat.wecom.domain.vo.qr.WeQrScopeVo;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.wecom.mapper.WeQrScopeMapper; import com.linkwechat.wecom.mapper.WeQrScopeMapper;
...@@ -85,4 +86,9 @@ public class IWeQrScopeServiceImpl extends ServiceImpl<WeQrScopeMapper, WeQrScop ...@@ -85,4 +86,9 @@ public class IWeQrScopeServiceImpl extends ServiceImpl<WeQrScopeMapper, WeQrScop
this.saveBatchByQrId(qrId,qrUserInfos); this.saveBatchByQrId(qrId,qrUserInfos);
} }
} }
@Override
public List<WeQrScopeVo> getWeQrScopeByQrIds(List<Long> qrIds) {
return this.baseMapper.getWeQrScopeByQrIds(qrIds);
}
} }
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.collection.ListUtil;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.thread.ThreadUtil; import cn.hutool.core.thread.ThreadUtil;
...@@ -20,6 +21,7 @@ import com.linkwechat.wecom.domain.query.qr.WeQrCodeListQuery; ...@@ -20,6 +21,7 @@ import com.linkwechat.wecom.domain.query.qr.WeQrCodeListQuery;
import com.linkwechat.wecom.domain.query.qr.WeQrUserInfoQuery; import com.linkwechat.wecom.domain.query.qr.WeQrUserInfoQuery;
import com.linkwechat.wecom.domain.vo.qr.WeQrCodeDetailVo; import com.linkwechat.wecom.domain.vo.qr.WeQrCodeDetailVo;
import com.linkwechat.wecom.domain.vo.qr.WeQrCodeScanCountVo; import com.linkwechat.wecom.domain.vo.qr.WeQrCodeScanCountVo;
import com.linkwechat.wecom.domain.vo.qr.WeQrScopeVo;
import com.linkwechat.wecom.mapper.WeQrCodeMapper; import com.linkwechat.wecom.mapper.WeQrCodeMapper;
import com.linkwechat.wecom.service.*; import com.linkwechat.wecom.service.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -98,6 +100,9 @@ public class WeQrCodeServiceImpl extends ServiceImpl<WeQrCodeMapper, WeQrCode> i ...@@ -98,6 +100,9 @@ public class WeQrCodeServiceImpl extends ServiceImpl<WeQrCodeMapper, WeQrCode> i
@Override @Override
public WeQrCodeDetailVo getQrDetail(Long qrId) { public WeQrCodeDetailVo getQrDetail(Long qrId) {
WeQrCodeDetailVo weQrCodeDetailVo = this.baseMapper.getQrDetailByQrId(qrId);
List<WeQrScopeVo> weQrScopeVoList = scopeService.getWeQrScopeByQrIds(ListUtil.toList(qrId));
weQrCodeDetailVo.setQrUserInfos(weQrScopeVoList);
return this.baseMapper.getQrDetailByQrId(qrId); return this.baseMapper.getQrDetailByQrId(qrId);
} }
...@@ -107,6 +112,13 @@ public class WeQrCodeServiceImpl extends ServiceImpl<WeQrCodeMapper, WeQrCode> i ...@@ -107,6 +112,13 @@ public class WeQrCodeServiceImpl extends ServiceImpl<WeQrCodeMapper, WeQrCode> i
List<Long> qrCodeIdList = this.baseMapper.getQrCodeList(qrCodeListQuery); List<Long> qrCodeIdList = this.baseMapper.getQrCodeList(qrCodeListQuery);
if (CollectionUtil.isNotEmpty(qrCodeIdList)) { if (CollectionUtil.isNotEmpty(qrCodeIdList)) {
List<WeQrCodeDetailVo> qrDetailByQrIds = this.baseMapper.getQrDetailByQrIds(qrCodeIdList); List<WeQrCodeDetailVo> qrDetailByQrIds = this.baseMapper.getQrDetailByQrIds(qrCodeIdList);
List<WeQrScopeVo> weQrScopeVoList = scopeService.getWeQrScopeByQrIds(qrCodeIdList);
Map<Long, List<WeQrScopeVo>> weQrScopeMap = Optional.ofNullable(weQrScopeVoList).orElseGet(ArrayList::new).stream().collect(Collectors.groupingBy(WeQrScopeVo::getQrId));
for (WeQrCodeDetailVo qrCodeDetail: qrDetailByQrIds) {
if(weQrScopeMap.get(qrCodeDetail.getId()) != null){
qrCodeDetail.setQrUserInfos(weQrScopeMap.get(qrCodeDetail.getId()));
}
}
weQrCodeList.addAll(qrDetailByQrIds); weQrCodeList.addAll(qrDetailByQrIds);
} }
PageInfo<Long> pageIdInfo = new PageInfo<>(qrCodeIdList); PageInfo<Long> pageIdInfo = new PageInfo<>(qrCodeIdList);
......
package com.linkwechat.wecom.service.welcome;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.linkwechat.common.enums.MessageType;
import com.linkwechat.wecom.client.WeCustomerClient;
import com.linkwechat.wecom.domain.WeQrAttachments;
import com.linkwechat.wecom.domain.WeQrCode;
import com.linkwechat.wecom.domain.WeTag;
import com.linkwechat.wecom.domain.dto.WeMediaDto;
import com.linkwechat.wecom.domain.dto.WeResultDto;
import com.linkwechat.wecom.domain.dto.WeWelcomeMsg;
import com.linkwechat.wecom.domain.query.WeCustomerWelcomeQuery;
import com.linkwechat.wecom.domain.vo.WeMakeCustomerTag;
import com.linkwechat.wecom.domain.vo.qr.WeQrCodeDetailVo;
import com.linkwechat.wecom.domain.vo.tag.WeTagVo;
import com.linkwechat.wecom.service.IWeCustomerService;
import com.linkwechat.wecom.service.IWeMaterialService;
import com.linkwechat.wecom.service.IWeQrCodeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* @author danmo
* @description 发送欢迎语业务
* @date 2021/11/13 18:51
**/
@Service
@Slf4j
public class WelcomeService implements ApplicationListener<WeCustomerWelcomeQuery> {
@Autowired
private IWeQrCodeService weQrCodeService;
@Autowired
private IWeCustomerService weCustomerService;
@Autowired
private WeCustomerClient weCustomerClient;
@Autowired
private IWeMaterialService weMaterialService;
@Override
@Async
public void onApplicationEvent(WeCustomerWelcomeQuery query) {
log.info("开始发送欢迎语:query:{}", JSONObject.toJSONString(query));
WeQrCode weQrCode = weQrCodeService.getOne(new LambdaQueryWrapper<WeQrCode>()
.eq(WeQrCode::getState, query.getState())
.eq(WeQrCode::getDelFlag, 0).last("limit 1"));
List<WeQrAttachments> qrAttachments = new ArrayList<>();
if (weQrCode != null) {
WeQrCodeDetailVo qrDetail = weQrCodeService.getQrDetail(weQrCode.getId());
qrAttachments.addAll(qrDetail.getQrAttachments());
makeCustomerTag(query.getExternalUserId(), query.getUserId(), qrDetail.getQrTags());
} else {
log.info("未查询到对应活码信息");
}
WeResultDto resultDto = sendWelcomeMsg(query, qrAttachments);
log.info("结束发送欢迎语:result:{}", JSONObject.toJSONString(resultDto));
}
/**
* 客户打标签
*
* @param externaUserId 客户id
* @param userId 员工id
* @param qrTags 标签id
*/
private void makeCustomerTag(String externaUserId, String userId, List<WeTagVo> qrTags) {
if (CollectionUtil.isNotEmpty(qrTags)) {
List<WeTag> weTagList = qrTags.stream().map(tag -> {
WeTag weTag = new WeTag();
weTag.setName(tag.getTagName());
weTag.setTagId(tag.getTagId());
return weTag;
}).collect(Collectors.toList());
WeMakeCustomerTag makeCustomerTag = new WeMakeCustomerTag();
makeCustomerTag.setExternalUserid(externaUserId);
makeCustomerTag.setUserId(userId);
makeCustomerTag.setAddTag(weTagList);
try {
weCustomerService.makeLabel(makeCustomerTag);
} catch (Exception e) {
log.info("发送欢迎语客户打标签失败 ex:{}", e);
}
}
}
/**
* 发送欢迎语
*
* @param query 客户信息
* @param qrAttachments 素材
* @return
*/
private WeResultDto sendWelcomeMsg(WeCustomerWelcomeQuery query, List<WeQrAttachments> qrAttachments) {
WeWelcomeMsg welcomeMsg = WeWelcomeMsg.builder().welcome_code(query.getWelcomeCode()).build();
if(CollectionUtil.isNotEmpty(qrAttachments)){
WeQrAttachments weQrAttachments = qrAttachments.stream()
.filter(qrAttachment -> ObjectUtil.equal(MessageType.TEXT.getMessageType(), qrAttachment.getMsgType()))
.findFirst().orElseGet(null);
if(weQrAttachments != null){
welcomeMsg.setText(WeWelcomeMsg.Text.builder().content(weQrAttachments.getContent()).build());
}
getMediaId(qrAttachments);
welcomeMsg.setAttachments(qrAttachments);
}else {
welcomeMsg.setText(WeWelcomeMsg.Text.builder().content("默认欢迎语").build());
}
return weCustomerClient.sendWelcomeMsg(welcomeMsg);
}
void getMediaId(List<WeQrAttachments> 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());
}
});
}
}
...@@ -20,45 +20,31 @@ ...@@ -20,45 +20,31 @@
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap> </resultMap>
<!-- <resultMap type="com.linkwechat.wecom.domain.vo.qr.WeQrCodeDetailVo" id="WeQrCodeDetailResult">--> <resultMap type="com.linkwechat.wecom.domain.vo.qr.WeQrCodeDetailVo" id="WeQrCodeDetailResult">
<!-- <result property="id" column="id" jdbcType="INTEGER"/>--> <result property="id" column="id" jdbcType="INTEGER"/>
<!-- <result property="name" column="name" jdbcType="VARCHAR"/>--> <result property="name" column="name" jdbcType="VARCHAR"/>
<!-- <result property="groupId" column="group_id" jdbcType="INTEGER"/>--> <result property="groupId" column="group_id" jdbcType="INTEGER"/>
<!-- <result property="autoAdd" column="auto_add" jdbcType="INTEGER"/>--> <result property="autoAdd" column="auto_add" jdbcType="INTEGER"/>
<!-- <result property="type" column="type" jdbcType="INTEGER"/>--> <result property="type" column="type" jdbcType="INTEGER"/>
<!-- <result property="ruleType" column="rule_type" jdbcType="INTEGER"/>--> <result property="ruleType" column="rule_type" jdbcType="INTEGER"/>
<!-- <result property="state" column="state" jdbcType="VARCHAR"/>--> <result property="state" column="state" jdbcType="VARCHAR"/>
<!-- <result property="configId" column="config_id" jdbcType="VARCHAR"/>--> <result property="configId" column="config_id" jdbcType="VARCHAR"/>
<!-- <result property="qrCode" column="qr_code" jdbcType="VARCHAR"/>--> <result property="qrCode" column="qr_code" jdbcType="VARCHAR"/>
<!-- <collection property="qrTags" ofType="com.linkwechat.wecom.domain.vo.tag.WeTagVo">--> <collection property="qrTags" ofType="com.linkwechat.wecom.domain.vo.tag.WeTagVo">
<!-- <result property="tagId" column="tag_id" jdbcType="INTEGER"/>--> <result property="tagId" column="tag_id" jdbcType="INTEGER"/>
<!-- </collection>--> </collection>
<!-- <collection property="qrUserInfos" ofType="com.linkwechat.wecom.domain.vo.qr.WeQrScopeVo">--> <collection property="qrAttachments" ofType="com.linkwechat.wecom.domain.WeQrAttachments">
<!-- <result property="type" column="type" jdbcType="INTEGER"/>--> <result property="msgType" column="msg_type" jdbcType="VARCHAR"/>
<!-- <result property="beginTime" column="begin_time" jdbcType="VARCHAR"/>--> <result property="content" column="content" jdbcType="VARCHAR"/>
<!-- <result property="endTime" column="end_time" jdbcType="VARCHAR"/>--> <result property="title" column="title" jdbcType="VARCHAR"/>
<!-- <result property="workCycle" column="work_cycle" jdbcType="VARCHAR"/>--> <result property="description" column="description" jdbcType="VARCHAR"/>
<!-- <collection property="qrUserInfos" ofType="com.linkwechat.wecom.domain.vo.qr.WeQrScopeUserVo">--> <result property="picUrl" column="pic_url" jdbcType="VARCHAR"/>
<!-- <result property="userId" column="user_id" jdbcType="VARCHAR"/>--> <result property="linkUrl" column="link_url" jdbcType="VARCHAR"/>
<!-- <result property="userName" column="user_name" jdbcType="VARCHAR"/>--> <result property="mediaId" column="media_id" jdbcType="VARCHAR"/>
<!-- </collection>--> <result property="fileUrl" column="file_url" jdbcType="VARCHAR"/>
<!-- <collection property="qrUserInfos" ofType="com.linkwechat.wecom.domain.vo.qr.WeQrScopePartyVo">--> <result property="appId" column="app_id" jdbcType="VARCHAR"/>
<!-- <result property="party" column="party" jdbcType="VARCHAR"/>--> </collection>
<!-- <result property="partyName" column="party_name" jdbcType="VARCHAR"/>--> </resultMap>
<!-- </collection>-->
<!-- </collection>-->
<!-- <collection property="qrAttachments" ofType="com.linkwechat.wecom.domain.WeQrAttachments">-->
<!-- <result property="msgType" column="msg_type" jdbcType="VARCHAR"/>-->
<!-- <result property="content" column="content" jdbcType="VARCHAR"/>-->
<!-- <result property="title" column="title" jdbcType="VARCHAR"/>-->
<!-- <result property="description" column="description" jdbcType="VARCHAR"/>-->
<!-- <result property="picUrl" column="pic_url" jdbcType="VARCHAR"/>-->
<!-- <result property="linkUrl" column="link_url" jdbcType="VARCHAR"/>-->
<!-- <result property="mediaId" column="media_id" jdbcType="VARCHAR"/>-->
<!-- <result property="fileUrl" column="file_url" jdbcType="VARCHAR"/>-->
<!-- <result property="appId" column="app_id" jdbcType="VARCHAR"/>-->
<!-- </collection>-->
<!-- </resultMap>-->
<sql id="selectWeQrCodeVo"> <sql id="selectWeQrCodeVo">
select id, name, group_id, auto_add, type, rule_type, state, scan_num, config_id, qr_code, create_by, create_time, update_by, update_time, del_flag from we_qr_code select id, name, group_id, auto_add, type, rule_type, state, scan_num, config_id, qr_code, create_by, create_time, update_by, update_time, del_flag from we_qr_code
...@@ -79,16 +65,6 @@ ...@@ -79,16 +65,6 @@
wqc.qr_code, wqc.qr_code,
wqtr.tag_id, wqtr.tag_id,
(select name from we_tag wt where wt.tag_id = wqtr.tag_id limit 1) as tag_name, (select name from we_tag wt where wt.tag_id = wqtr.tag_id limit 1) as tag_name,
wqs.scope_id,
wqs.scope_type,
wqs.`type`,
wqs.begin_time,
wqs.end_time,
wqs.work_cycle,
wqs.user_id,
if(wqs.user_id is null,null,(select wu.user_name from we_user wu where wu.user_id = wqs.user_id limit 1)) as user_name,
wqs.party,
if(wqs.party is null,null,(select wd.name from we_department wd where wd.id= wqs.party limit 1)) as party_name,
wqa.msg_type, wqa.msg_type,
wqa.content, wqa.content,
wqa.title, wqa.title,
...@@ -106,22 +82,22 @@ ...@@ -106,22 +82,22 @@
where 1=1 where 1=1
</sql> </sql>
<!-- <select id="getQrDetailByQrId" resultMap="WeQrCodeDetailResult">--> <select id="getQrDetailByQrId" resultMap="WeQrCodeDetailResult">
<!-- <include refid="selectWeQrCodeDetailVo"/>--> <include refid="selectWeQrCodeDetailVo"/>
<!-- <if test="qrId != null">--> <if test="qrId != null">
<!-- and wqc.id = #{qrId}--> and wqc.id = #{qrId}
<!-- </if>--> </if>
<!-- </select>--> </select>
<!-- <select id="getQrDetailByQrIds" resultMap="WeQrCodeDetailResult">--> <select id="getQrDetailByQrIds" resultMap="WeQrCodeDetailResult">
<!-- <include refid="selectWeQrCodeDetailVo"/>--> <include refid="selectWeQrCodeDetailVo"/>
<!-- <if test="qrIds != null and qrIds.size > 0">--> <if test="qrIds != null and qrIds.size > 0">
<!-- and wqc.id in--> and wqc.id in
<!-- <foreach item="qrId" collection="qrIds" index="index" open="(" separator="," close=")">--> <foreach item="qrId" collection="qrIds" index="index" open="(" separator="," close=")">
<!-- #{qrId}--> #{qrId}
<!-- </foreach>--> </foreach>
<!-- </if>--> </if>
<!-- </select>--> </select>
<select id="getQrCodeList" resultType="java.lang.Long"> <select id="getQrCodeList" resultType="java.lang.Long">
select select
......
...@@ -21,8 +21,49 @@ ...@@ -21,8 +21,49 @@
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap> </resultMap>
<resultMap id="QrScopeResult" type="com.linkwechat.wecom.domain.vo.qr.WeQrScopeVo">
<result property="qrId" column="qr_id" jdbcType="INTEGER"/>
<result property="type" column="type" jdbcType="INTEGER"/>
<result property="beginTime" column="begin_time" jdbcType="VARCHAR"/>
<result property="endTime" column="end_time" jdbcType="VARCHAR"/>
<result property="workCycle" column="work_cycle" jdbcType="VARCHAR"/>
<collection property="weQrUserList" ofType="com.linkwechat.wecom.domain.vo.qr.WeQrScopeUserVo">
<result property="userId" column="user_id" jdbcType="VARCHAR"/>
<result property="userName" column="user_name" jdbcType="VARCHAR"/>
</collection>
<collection property="weQrPartyList" ofType="com.linkwechat.wecom.domain.vo.qr.WeQrScopePartyVo">
<result property="party" column="party" jdbcType="VARCHAR"/>
<result property="partyName" column="party_name" jdbcType="VARCHAR"/>
</collection>
</resultMap>
<sql id="selectWeQrScopeVo"> <sql id="selectWeQrScopeVo">
select id, qr_id, scope_id, type, scope_type, party, user_id, work_cycle, begin_time, end_time, create_by, create_time, update_by, update_time, del_flag from we_qr_scope select id, qr_id, scope_id, type, scope_type, party, user_id, work_cycle, begin_time, end_time, create_by, create_time, update_by, update_time, del_flag from we_qr_scope
</sql> </sql>
<select id="getWeQrScopeByQrIds" resultMap="QrScopeResult">
select
wqs.qr_id,
wqs.scope_id,
wqs.scope_type,
wqs.`type`,
wqs.begin_time,
wqs.end_time,
wqs.work_cycle,
wqs.user_id,
if(wqs.user_id is null,null,(select wu.user_name from we_user wu where wu.user_id = wqs.user_id limit 1)) as user_name,
wqs.party,
if(wqs.party is null,null,(select wd.name from we_department wd where wd.id= wqs.party limit 1)) as party_name
from we_qr_scope wqs
<where>
<if test="qrIds != null and qrIds.size > 0">
and wqs.qr_id in
<foreach item="qrId" collection="qrIds" index="index" open="(" separator="," close=")">
#{qrId}
</foreach>
</if>
and wqs.del_flag = 0
</where>
</select>
</mapper> </mapper>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!