Commit bec9173b by danmo

Merge remote-tracking branch 'origin/back_end_dev' into back_end_dev

2 parents a638b1b8 af301ed5
Showing 42 changed files with 735 additions and 66 deletions
...@@ -18,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -18,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.text.ParseException;
import java.util.List; import java.util.List;
/** /**
...@@ -50,7 +51,7 @@ public class WeCustomerMessagePushController extends BaseController { ...@@ -50,7 +51,7 @@ public class WeCustomerMessagePushController extends BaseController {
public AjaxResult add(@RequestBody CustomerMessagePushDto customerMessagePushDto) { public AjaxResult add(@RequestBody CustomerMessagePushDto customerMessagePushDto) {
try { try {
weCustomerMessagePushService.addWeCustomerMessagePush(customerMessagePushDto); weCustomerMessagePushService.addWeCustomerMessagePush(customerMessagePushDto);
} catch (JsonProcessingException e) { } catch (JsonProcessingException | ParseException e) {
e.printStackTrace(); e.printStackTrace();
return AjaxResult.error("群发失败"); return AjaxResult.error("群发失败");
} }
...@@ -104,5 +105,4 @@ public class WeCustomerMessagePushController extends BaseController { ...@@ -104,5 +105,4 @@ public class WeCustomerMessagePushController extends BaseController {
return AjaxResult.success(); return AjaxResult.success();
} }
} }
...@@ -133,9 +133,9 @@ public class WeMaterialController extends BaseController { ...@@ -133,9 +133,9 @@ public class WeMaterialController extends BaseController {
return AjaxResult.success(); return AjaxResult.success();
} }
@PreAuthorize("@ss.hasPermi('wechat:material:temporaryMaterialMediaId')") //@PreAuthorize("@ss.hasPermi('wechat:material:temporaryMaterialMediaId')")
@Log(title = "获取素材media_id", businessType = BusinessType.OTHER) @Log(title = "获取素材media_id", businessType = BusinessType.OTHER)
@PostMapping("/temporaryMaterialMediaId") @GetMapping("/temporaryMaterialMediaId")
@ApiOperation("获取素材media_id") @ApiOperation("获取素材media_id")
public AjaxResult temporaryMaterialMediaId(@RequestParam(value = "url") String url, @RequestParam(value = "type") String type,@RequestParam(value = "name") String name){ public AjaxResult temporaryMaterialMediaId(@RequestParam(value = "url") String url, @RequestParam(value = "type") String type,@RequestParam(value = "name") String name){
WeMediaDto weMediaDto = materialService.uploadTemporaryMaterial(url, type,name); WeMediaDto weMediaDto = materialService.uploadTemporaryMaterial(url, type,name);
......
package com.linkwechat.web.controller.wecom; package com.linkwechat.web.controller.wecom;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.linkwechat.common.annotation.Log; import com.linkwechat.common.annotation.Log;
import com.linkwechat.common.constant.WeConstans; import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.core.controller.BaseController; import com.linkwechat.common.core.controller.BaseController;
...@@ -8,6 +10,7 @@ import com.linkwechat.common.core.domain.AjaxResult; ...@@ -8,6 +10,7 @@ import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.core.page.TableDataInfo; import com.linkwechat.common.core.page.TableDataInfo;
import com.linkwechat.common.enums.BusinessType; import com.linkwechat.common.enums.BusinessType;
import com.linkwechat.common.utils.Threads; import com.linkwechat.common.utils.Threads;
import com.linkwechat.wecom.domain.WeTag;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContext; import org.springframework.security.core.context.SecurityContext;
...@@ -23,6 +26,8 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -23,6 +26,8 @@ import org.springframework.web.bind.annotation.RestController;
import com.linkwechat.wecom.domain.WeTagGroup; import com.linkwechat.wecom.domain.WeTagGroup;
import com.linkwechat.wecom.service.IWeTagGroupService; import com.linkwechat.wecom.service.IWeTagGroupService;
import java.util.List;
/** /**
* 标签组Controller * 标签组Controller
* *
...@@ -60,6 +65,18 @@ public class WeTagGroupController extends BaseController ...@@ -60,6 +65,18 @@ public class WeTagGroupController extends BaseController
@PostMapping @PostMapping
public AjaxResult add(@RequestBody WeTagGroup weTagGroup) public AjaxResult add(@RequestBody WeTagGroup weTagGroup)
{ {
//校验标签组名称与标签名称是否相同
if(StrUtil.isNotBlank(weTagGroup.getGourpName())){
List<WeTag> weTags = weTagGroup.getWeTags();
if(CollectionUtil.isNotEmpty(weTags)){
if(weTags.stream().filter(m -> m.getName().equals(weTagGroup.getGourpName())).findAny().isPresent()){
return AjaxResult.error("标签组名称与标签名不可重复");
}
}
}
weTagGroupService.insertWeTagGroup(weTagGroup); weTagGroupService.insertWeTagGroup(weTagGroup);
return AjaxResult.success(); return AjaxResult.success();
......
...@@ -3,6 +3,7 @@ package com.linkwechat.web.controller.wecom; ...@@ -3,6 +3,7 @@ package com.linkwechat.web.controller.wecom;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.linkwechat.common.annotation.Log; import com.linkwechat.common.annotation.Log;
import com.linkwechat.common.config.CosConfig; import com.linkwechat.common.config.CosConfig;
import com.linkwechat.common.constant.HttpStatus;
import com.linkwechat.common.core.controller.BaseController; import com.linkwechat.common.core.controller.BaseController;
import com.linkwechat.common.core.domain.AjaxResult; import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.core.page.TableDataInfo; import com.linkwechat.common.core.page.TableDataInfo;
...@@ -10,6 +11,7 @@ import com.linkwechat.common.enums.BusinessType; ...@@ -10,6 +11,7 @@ import com.linkwechat.common.enums.BusinessType;
import com.linkwechat.common.utils.file.FileUploadUtils; import com.linkwechat.common.utils.file.FileUploadUtils;
import com.linkwechat.common.utils.poi.ExcelUtil; import com.linkwechat.common.utils.poi.ExcelUtil;
import com.linkwechat.wecom.domain.WeTaskFission; import com.linkwechat.wecom.domain.WeTaskFission;
import com.linkwechat.wecom.domain.dto.WeChatUserDTO;
import com.linkwechat.wecom.domain.dto.WeTaskFissionPosterDTO; import com.linkwechat.wecom.domain.dto.WeTaskFissionPosterDTO;
import com.linkwechat.wecom.service.IWeTaskFissionService; import com.linkwechat.wecom.service.IWeTaskFissionService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -29,7 +31,7 @@ import java.util.List; ...@@ -29,7 +31,7 @@ import java.util.List;
* @author leejoker * @author leejoker
* @date 2021-01-20 * @date 2021-01-20
*/ */
@Api(description = "任务宝Controller") @Api("任务宝Controller")
@RestController @RestController
@RequestMapping("/wecom/fission") @RequestMapping("/wecom/fission")
public class WeTaskFissionController extends BaseController { public class WeTaskFissionController extends BaseController {
...@@ -108,6 +110,24 @@ public class WeTaskFissionController extends BaseController { ...@@ -108,6 +110,24 @@ public class WeTaskFissionController extends BaseController {
} }
/** /**
* 添加群裂变完成记录
*/
@ApiOperation(value = "添加群裂变完成记录", httpMethod = "POST")
@PreAuthorize("@ss.hasPermi('wecom:fission:complete')")
@Log(title = "添加群裂变完成记录", businessType = BusinessType.OTHER)
@PostMapping("/complete/{id}/records/{recordId}")
public AjaxResult completeRecord(@PathVariable("id") Long id,
@PathVariable("recordId") Long recordId,
@RequestBody WeChatUserDTO weChatUserDTO) {
WeTaskFission taskFission = weTaskFissionService.selectWeTaskFissionById(id);
if (taskFission == null) {
return AjaxResult.error(HttpStatus.NOT_FOUND, "数据不存在");
}
weTaskFissionService.completeFissionRecord(id, recordId, weChatUserDTO);
return AjaxResult.success(taskFission.getFissQrcode());
}
/**
* 生成带二维码的海报 * 生成带二维码的海报
*/ */
@ApiOperation(value = "生成带二维码的海报", httpMethod = "POST") @ApiOperation(value = "生成带二维码的海报", httpMethod = "POST")
......
...@@ -105,7 +105,7 @@ token: ...@@ -105,7 +105,7 @@ token:
mybatis-plus: mybatis-plus:
mapper-locations: classpath*:mapper/**/*Mapper.xml mapper-locations: classpath*:mapper/**/*Mapper.xml
type-aliases-package: com.linkwechat.**.domain type-aliases-package: com.linkwechat.**.domain
type-handlers-package: com.linkwechat.framework.handler.** type-handlers-package: com.linkwechat.framework.handler.GenericTypeHandler,com.linkwechat.framework.handler.StringArrayJoinTypeHandler
configuration: configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
global-config: global-config:
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
<typeHandlers> <typeHandlers>
<typeHandler handler="com.linkwechat.framework.handler.StringArrayJoinTypeHandler"/> <typeHandler handler="com.linkwechat.framework.handler.StringArrayJoinTypeHandler"/>
<typeHandler handler="com.linkwechat.framework.handler.GenericTypeHandler"/>
<typeHandler handler="com.linkwechat.framework.handler.ListTypeHandler"/>
</typeHandlers> </typeHandlers>
</configuration> </configuration>
...@@ -69,6 +69,7 @@ ...@@ -69,6 +69,7 @@
<dependency> <dependency>
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId> <artifactId>fastjson</artifactId>
<version>1.2.56</version>
</dependency> </dependency>
<!-- io常用工具类 --> <!-- io常用工具类 -->
......
...@@ -387,4 +387,25 @@ public class WeConstans { ...@@ -387,4 +387,25 @@ public class WeConstans {
public static final String THIRD_APP_PARAM_TIP = "agentId"; public static final String THIRD_APP_PARAM_TIP = "agentId";
public static final String WECUSTOMERS_KEY="weCustomer"; public static final String WECUSTOMERS_KEY="weCustomer";
/**
* 发给客户
*/
public static final String SEND_MESSAGE_CUSTOMER = "0";
/**
* 发给客户群
*/
public static final String SEND_MESSAGE_GROUP="1";
/**
* 消息范围 1 指定客户
*/
public static final String SEND_MESSAGE_CUSTOMER_ALL = "0";
/**
* 消息范围 1 指定客户
*/
public static final String SEND_MESSAGE_CUSTOMER_PART="1";
} }
package com.linkwechat.common.enums;
import lombok.Getter;
import java.util.Optional;
import java.util.stream.Stream;
/**
* 群发消息类型 0 文本消息 1 图片消息 2 链接消息 3 小程序消息 4 图文消息
*/
@SuppressWarnings("all")
@Getter
public enum GroupMessageType {
/**
* 文本消息
*/
TEXT("0", "text"),
/**
* 图片消息
*/
IMAGE("1", "image"),
/**
* 链接消息
*/
LINK("2", "link"),
/**
* 小程序消息
*/
MINIPROGRAM("3", "miniprogram"),
/**
* 图文消息
*/
TEXT_IMAGE("4", "text_image"),
;
/**
* 媒体类型
*/
String messageType;
/**
* 数据值
*/
String type;
GroupMessageType(String type, String messageType) {
this.type = type;
this.messageType = messageType;
}
public static Optional<GroupMessageType> of(String type) {
return Stream.of(values()).filter(s -> s.type.equals(type)).findFirst();
}
}
...@@ -189,4 +189,10 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils ...@@ -189,4 +189,10 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
} }
return lDate; return lDate;
} }
public static long getMillionSceondsBydate(String date) throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat(YYYY_MM_DD_HH_MM_SS);
long millionSeconds = sdf.parse(date).getTime();//毫秒
return millionSeconds;
}
} }
...@@ -125,7 +125,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter ...@@ -125,7 +125,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
.antMatchers("/wecom/user/getUserInfo").anonymous() .antMatchers("/wecom/user/getUserInfo").anonymous()
// .antMatchers("/common/uploadFile2Cos").anonymous() // .antMatchers("/common/uploadFile2Cos").anonymous()
.antMatchers("/wecom/material/temporaryMaterialMediaId").anonymous()
// 除上面外的所有请求全部需要鉴权认证 // 除上面外的所有请求全部需要鉴权认证
.anyRequest().authenticated() .anyRequest().authenticated()
.and() .and()
......
package com.linkwechat.framework.handler;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.linkwechat.wecom.domain.dto.message.CustomerMessagePushDto;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
* 用以mysql中json格式的字段,进行转换的自定义转换器,转换为实体类的T类型 属性
* @param <T>
*/
@SuppressWarnings("all")
@MappedTypes(value = {JSONObject.class, CustomerMessagePushDto.class})
@MappedJdbcTypes(value = {JdbcType.VARCHAR}, includeNullJdbcType = true)
public class GenericTypeHandler<T extends Object> extends BaseTypeHandler<T> {
private Class<T> clazz;
public GenericTypeHandler(Class<T> clazz) {
if (clazz == null) {
throw new IllegalArgumentException("Type argument cannot be null");
}
this.clazz = clazz;
}
/**
* 设置非空参数
* @param ps
* @param i
* @param parameter
* @param jdbcType
* @throws SQLException
*/
@Override
public void setNonNullParameter(PreparedStatement ps, int i, T parameter, JdbcType jdbcType) throws SQLException {
ps.setString(i, JSON.toJSONString(parameter));
}
/**
* 根据列名,获取可以为空的结果
* @param rs
* @param columnName
* @return
* @throws SQLException
*/
@Override
public T getNullableResult(ResultSet rs, String columnName) throws SQLException {
String sqlJson = rs.getString(columnName);
if (null != sqlJson) {
return JSONObject.parseObject(sqlJson, clazz);
}
return null;
}
/**
* 根据列索引,获取可以为空的结果
* @param rs
* @param columnIndex
* @return
* @throws SQLException
*/
@Override
public T getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
String sqlJson = rs.getString(columnIndex);
if (null != sqlJson) {
return JSONObject.parseObject(sqlJson, clazz);
}
return null;
}
@Override
public T getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
String sqlJson = cs.getString(columnIndex);
if (null != sqlJson) {
return JSONObject.parseObject(sqlJson, clazz);
}
return null;
}
}
\ No newline at end of file \ No newline at end of file
package com.linkwechat.framework.handler;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.wecom.domain.WeCustomer;
import com.linkwechat.wecom.domain.WeGroup;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.ibatis.type.*;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
/**
* 处理jsonArray字符串为pojoList
* @param <T>
*/
//支持的java对象
@SuppressWarnings("all")
@Slf4j
@MappedTypes(value = {WeCustomer.class,WeGroup.class})
@MappedJdbcTypes({JdbcType.VARCHAR})
public class ListTypeHandler<T extends Object> implements TypeHandler<List<T>> {
private List getListByJsonArrayString(String content,String filedName) {
if (StringUtils.isEmpty(content)) {
return new ArrayList<>();
}
if(filedName!=null && "customers_info".equals(filedName)){
return JSONObject.parseArray(content, WeCustomer.class);
}
if(filedName!=null && "groups_info".equals(filedName)){
return JSONObject.parseArray(content, WeGroup.class);
}
return null;
}
/**
* 用于定义在Mybatis设置参数时该如何把Java类型的参数转换为对应的数据库类型
*
* <PRE>
* PreparedStatement pstmt = con.prepareStatement("UPDATE EMPLOYEES
* SET SALARY = ? WHERE ID = ?");
* pstmt.setBigDecimal(1, 153833.00)
* pstmt.setInt(2, 110592)
* </PRE>
*
* @param preparedStatement An object that represents a precompiled SQL statement
* @param i 当前参数的位置
* @param t 当前参数的Java对象
* @param jdbcType 当前参数的数据库类型
* @throws SQLException
*/
@Override
public void setParameter(PreparedStatement preparedStatement, int i, List<T> t, JdbcType jdbcType) throws SQLException {
if (CollectionUtils.isEmpty(t)) {
preparedStatement.setString(i, null);
} else {
preparedStatement.setString(i, JSON.toJSONString(t).replaceAll("[\ud800\udc00-\udbff\udfff\ud800-\udfff]", ""));
}
}
@Override
public List<T> getResult(ResultSet resultSet, String s) throws SQLException {
log.info("序列化集合字段:{}",s);
return getListByJsonArrayString(resultSet.getString(s),s);
}
@Override
public List<T> getResult(ResultSet resultSet, int i) throws SQLException {
return getListByJsonArrayString(resultSet.getString(i),null);
}
@Override
public List<T> getResult(CallableStatement callableStatement, int i) throws SQLException {
return getListByJsonArrayString(callableStatement.getString(i),null);
}
}
\ No newline at end of file \ No newline at end of file
...@@ -2,16 +2,16 @@ package com.linkwechat.quartz.task; ...@@ -2,16 +2,16 @@ package com.linkwechat.quartz.task;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.linkwechat.common.constant.WeConstans; import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.core.elasticsearch.ElasticSearch; import com.linkwechat.common.core.elasticsearch.ElasticSearch;
import com.linkwechat.common.core.redis.RedisCache; import com.linkwechat.common.core.redis.RedisCache;
import com.linkwechat.common.utils.StringUtils; import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.wecom.domain.WeCustomer; import com.linkwechat.wecom.domain.WeCustomer;
import com.linkwechat.wecom.service.IWeChatContactMappingService; import com.linkwechat.wecom.domain.WeCustomerMessageTimeTask;
import com.linkwechat.wecom.service.IWeCustomerService; import com.linkwechat.wecom.mapper.WeCustomerMessageTimeTaskMapper;
import com.linkwechat.wecom.service.IWeSensitiveActHitService; import com.linkwechat.wecom.service.*;
import com.linkwechat.wecom.service.IWeSensitiveService;
import com.tencent.wework.FinanceUtils; import com.tencent.wework.FinanceUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
...@@ -25,6 +25,7 @@ import org.springframework.stereotype.Component; ...@@ -25,6 +25,7 @@ import org.springframework.stereotype.Component;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.concurrent.Semaphore;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Consumer; import java.util.function.Consumer;
...@@ -48,6 +49,12 @@ public class RyTask { ...@@ -48,6 +49,12 @@ public class RyTask {
private IWeSensitiveActHitService weSensitiveActHitService; private IWeSensitiveActHitService weSensitiveActHitService;
@Autowired @Autowired
private IWeCustomerService weCustomerService; private IWeCustomerService weCustomerService;
@Autowired
private WeCustomerMessageTimeTaskMapper customerMessageTimeTaskMapper;
@Autowired
private IWeCustomerMessageService weCustomerMessageService;
public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) { public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) {
System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i)); System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i));
...@@ -95,17 +102,17 @@ public class RyTask { ...@@ -95,17 +102,17 @@ public class RyTask {
} }
} }
public void WeCustomers(){ public void WeCustomers() {
//查询系统所有客户 //查询系统所有客户
List<WeCustomer> cacheList = redisCache.getCacheList(WeConstans.WECUSTOMERS_KEY); List<WeCustomer> cacheList = redisCache.getCacheList(WeConstans.WECUSTOMERS_KEY);
if(CollectionUtils.isEmpty(cacheList)){ if (CollectionUtils.isEmpty(cacheList)) {
List<WeCustomer> customers = weCustomerService.selectWeCustomerList(null); List<WeCustomer> customers = weCustomerService.selectWeCustomerList(null);
redisCache.setCacheList(WeConstans.WECUSTOMERS_KEY,customers); redisCache.setCacheList(WeConstans.WECUSTOMERS_KEY, customers);
}else { } else {
List<WeCustomer> customers = weCustomerService.selectWeCustomerList(null); List<WeCustomer> customers = weCustomerService.selectWeCustomerList(null);
List<WeCustomer> weCustomers = redisCache.getCacheList(WeConstans.WECUSTOMERS_KEY); List<WeCustomer> weCustomers = redisCache.getCacheList(WeConstans.WECUSTOMERS_KEY);
if(CollectionUtils.isNotEmpty(weCustomers) && weCustomers.size()<customers.size()){ if (CollectionUtils.isNotEmpty(weCustomers) && weCustomers.size() < customers.size()) {
redisCache.setCacheList(WeConstans.WECUSTOMERS_KEY,customers); redisCache.setCacheList(WeConstans.WECUSTOMERS_KEY, customers);
} }
} }
} }
...@@ -130,4 +137,51 @@ public class RyTask { ...@@ -130,4 +137,51 @@ public class RyTask {
log.info("执行有参方法: params:{},{}", corpId, secret); log.info("执行有参方法: params:{},{}", corpId, secret);
} }
/**
* 扫描群发消息定时任务
*/
public void messageTask() {
//获的当前时间的毫秒数
long currentTime = System.currentTimeMillis();
//customerMessageTimeTaskMapper
List<WeCustomerMessageTimeTask> weCustomerMessageTimeTasks = customerMessageTimeTaskMapper.selectWeCustomerMessageTimeTaskGteSettingTime(currentTime);
final Semaphore semaphore = new Semaphore(5);
if (CollectionUtils.isNotEmpty(weCustomerMessageTimeTasks)) {
weCustomerMessageTimeTasks.forEach(
s -> {
try {
semaphore.acquire();
if (s.getMessageInfo() != null && s.getMessageId() != null || (s.getMessageInfo().getPushType().equals(WeConstans.SEND_MESSAGE_CUSTOMER)
&& CollectionUtils.isNotEmpty(s.getCustomersInfo())) ||(s.getMessageInfo().getPushType().equals(WeConstans.SEND_MESSAGE_GROUP)
&& CollectionUtils.isNotEmpty(s.getGroupsInfo()))) {
weCustomerMessageService.sendMessgae(s.getMessageInfo(), s.getMessageId(), s.getCustomersInfo(), s.getGroupsInfo());
//更新消息处理状态
customerMessageTimeTaskMapper.updateTaskSolvedById(s.getTaskId());
}
semaphore.release();
} catch (JsonProcessingException | InterruptedException e) {
log.error("定时群发消息处理异常:ex:{}", e);
e.printStackTrace();
}
}
);
}
}
} }
package com.linkwechat.wecom.domain;
import com.baomidou.mybatisplus.annotation.TableName;
import com.linkwechat.common.core.domain.BaseEntity;
import com.linkwechat.wecom.domain.dto.message.CustomerMessagePushDto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* 群发消息定时任务表
* @author Kewen
*/
@Data
@TableName("we_customer_messageTimeTask")
public class WeCustomerMessageTimeTask extends BaseEntity {
public WeCustomerMessageTimeTask(Long messageId, CustomerMessagePushDto messageInfo, List<WeCustomer> customersInfo, List<WeGroup> groupsInfo, Long settingTime) {
this.messageId = messageId;
this.messageInfo = messageInfo;
this.customersInfo = customersInfo;
this.groupsInfo = groupsInfo;
this.settingTime = settingTime;
}
public WeCustomerMessageTimeTask() {
}
/**
* 任务id
*/
private Long taskId;
/**
* 消息id
*/
private Long messageId;
/**
* 消息原始信息
*/
private CustomerMessagePushDto messageInfo;
/**
* 客户信息列表
*/
private List<WeCustomer> customersInfo;
/**
* 客户群组信息列表
*/
private List<WeGroup> groupsInfo;
/**
* 定时时间的毫秒数
*/
private Long settingTime;
/**
* 0 未解决 1 已解决
*/
private Integer solved;
}
...@@ -115,6 +115,10 @@ public class WeUser ...@@ -115,6 +115,10 @@ public class WeUser
private String remark; private String remark;
private String departmentStr;
/** 转化成企业微信需要的dto对象 */ /** 转化成企业微信需要的dto对象 */
public WeUserDto transformWeUserDto(){ public WeUserDto transformWeUserDto(){
......
package com.linkwechat.wecom.domain.dto;
import lombok.Data;
/**
* @author leejoker <1056650571@qq.com>
* @version 1.0
* @date 2021/2/9 14:58
*/
@Data
public class WeChatUserDTO {
private String userid;
private String unionid;
private String name;
}
...@@ -11,6 +11,6 @@ import lombok.Data; ...@@ -11,6 +11,6 @@ import lombok.Data;
public class WeTaskFissionPosterDTO { public class WeTaskFissionPosterDTO {
private String userId; private String userId;
private Long taskFissionId; private Long taskFissionId;
private String fissStaffId; private String fissionTargetId;
private Long posterId; private Long posterId;
} }
...@@ -78,5 +78,10 @@ public class CustomerMessagePushVo { ...@@ -78,5 +78,10 @@ public class CustomerMessagePushVo {
*/ */
private Integer timedTask; private Integer timedTask;
/**
* 消息发送状态 0 未发送 1 已发送
*/
private String checkStatus;
} }
...@@ -46,4 +46,9 @@ public class WeChatSideVo { ...@@ -46,4 +46,9 @@ public class WeChatSideVo {
@JsonFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd")
private Date createTime; private Date createTime;
/**
* 封面地址
*/
private String coverUrl;
} }
...@@ -21,4 +21,13 @@ public interface WeCustomerMessageMapper extends BaseMapper<WeCustomerMessage> { ...@@ -21,4 +21,13 @@ public interface WeCustomerMessageMapper extends BaseMapper<WeCustomerMessage> {
* @return int * @return int
*/ */
int updateWeCustomerMessageActualSend(@Param("messageId") Long messageId,@Param("actualSend") Integer actualSend); int updateWeCustomerMessageActualSend(@Param("messageId") Long messageId,@Param("actualSend") Integer actualSend);
/**
* 更新消息发送状态
* @param messageId id
* @param status 消息发送状态 0 未发送 1 已发送
* @return int
*/
int updateWeCustomerMessageCheckStatusById(@Param("messageId") Long messageId,@Param("status") String status);
} }
package com.linkwechat.wecom.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linkwechat.wecom.domain.WeCustomerMessageTimeTask;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 群发消息 定时任务表 Mapper接口
*
* @author kewen
* @date 2021-02-09
*/
public interface WeCustomerMessageTimeTaskMapper extends BaseMapper<WeCustomerMessageTimeTask> {
/**
* 查询群发任务列表
*
* @param timeMillis 当前时间毫秒数
* @return {@link WeCustomerMessageTimeTask}s
*/
List<WeCustomerMessageTimeTask> selectWeCustomerMessageTimeTaskGteSettingTime(@Param("timeMillis") long timeMillis);
/**
* 保存群发任务
*
* @param customerMessageTimeTask 群发任务信息
* @return int
*/
int saveWeCustomerMessageTimeTask(WeCustomerMessageTimeTask customerMessageTimeTask);
/**
* 更新群发定时任务处理状态
*
* @param taskId 任务id
* @return int
*/
int updateTaskSolvedById(@Param("taskId") Long taskId);
}
...@@ -5,6 +5,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; ...@@ -5,6 +5,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.linkwechat.wecom.domain.dto.message.CustomerMessagePushDto; import com.linkwechat.wecom.domain.dto.message.CustomerMessagePushDto;
import com.linkwechat.wecom.domain.vo.CustomerMessagePushVo; import com.linkwechat.wecom.domain.vo.CustomerMessagePushVo;
import java.text.ParseException;
import java.util.List; import java.util.List;
/** /**
...@@ -19,7 +20,7 @@ public interface IWeCustomerMessagePushService { ...@@ -19,7 +20,7 @@ public interface IWeCustomerMessagePushService {
* *
*@param customerMessagePushDto 原始数据信息 *@param customerMessagePushDto 原始数据信息
*/ */
public void addWeCustomerMessagePush(CustomerMessagePushDto customerMessagePushDto) throws JsonProcessingException; public void addWeCustomerMessagePush(CustomerMessagePushDto customerMessagePushDto) throws JsonProcessingException, ParseException;
/** /**
* 群发消息列表 * 群发消息列表
......
package com.linkwechat.wecom.service; package com.linkwechat.wecom.service;
import com.linkwechat.wecom.domain.WeTaskFission; import com.linkwechat.wecom.domain.WeTaskFission;
import com.linkwechat.wecom.domain.dto.WeChatUserDTO;
import com.linkwechat.wecom.domain.dto.WeTaskFissionPosterDTO; import com.linkwechat.wecom.domain.dto.WeTaskFissionPosterDTO;
import java.util.List; import java.util.List;
...@@ -74,4 +75,12 @@ public interface IWeTaskFissionService { ...@@ -74,4 +75,12 @@ public interface IWeTaskFissionService {
* @return * @return
*/ */
public String fissionPosterGenerate(WeTaskFissionPosterDTO weTaskFissionPosterDTO); public String fissionPosterGenerate(WeTaskFissionPosterDTO weTaskFissionPosterDTO);
/**
* 添加裂变完成记录
*
* @param taskFissionId
* @param taskFissionRecordId
*/
public void completeFissionRecord(Long taskFissionId, Long taskFissionRecordId, WeChatUserDTO weChatUserDTO);
} }
...@@ -8,9 +8,11 @@ import com.linkwechat.common.constant.WeConstans; ...@@ -8,9 +8,11 @@ import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.utils.SnowFlakeUtil; import com.linkwechat.common.utils.SnowFlakeUtil;
import com.linkwechat.common.utils.StringUtils; import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.wecom.client.WeCustomerMessagePushClient; import com.linkwechat.wecom.client.WeCustomerMessagePushClient;
import com.linkwechat.wecom.domain.WeCustomerMessage;
import com.linkwechat.wecom.domain.WeCustomerMessageOriginal; import com.linkwechat.wecom.domain.WeCustomerMessageOriginal;
import com.linkwechat.wecom.domain.dto.message.*; import com.linkwechat.wecom.domain.dto.message.*;
import com.linkwechat.wecom.domain.vo.CustomerMessagePushVo; import com.linkwechat.wecom.domain.vo.CustomerMessagePushVo;
import com.linkwechat.wecom.mapper.WeCustomerMessageMapper;
import com.linkwechat.wecom.mapper.WeCustomerMessageOriginalMapper; import com.linkwechat.wecom.mapper.WeCustomerMessageOriginalMapper;
import com.linkwechat.wecom.mapper.WeCustomerMessgaeResultMapper; import com.linkwechat.wecom.mapper.WeCustomerMessgaeResultMapper;
import com.linkwechat.wecom.service.IWeCustomerMessageOriginalService; import com.linkwechat.wecom.service.IWeCustomerMessageOriginalService;
...@@ -29,6 +31,7 @@ import java.util.concurrent.atomic.AtomicInteger; ...@@ -29,6 +31,7 @@ import java.util.concurrent.atomic.AtomicInteger;
* @author kewen * @author kewen
* @date 2020-12-12 * @date 2020-12-12
*/ */
@SuppressWarnings("all")
@Service @Service
public class WeCustomerMessageOriginalServiceImpl extends ServiceImpl<WeCustomerMessageOriginalMapper, WeCustomerMessageOriginal> implements IWeCustomerMessageOriginalService { public class WeCustomerMessageOriginalServiceImpl extends ServiceImpl<WeCustomerMessageOriginalMapper, WeCustomerMessageOriginal> implements IWeCustomerMessageOriginalService {
...@@ -47,6 +50,9 @@ public class WeCustomerMessageOriginalServiceImpl extends ServiceImpl<WeCustomer ...@@ -47,6 +50,9 @@ public class WeCustomerMessageOriginalServiceImpl extends ServiceImpl<WeCustomer
@Autowired @Autowired
private ObjectMapper objectMapper; private ObjectMapper objectMapper;
@Autowired
private WeCustomerMessageMapper customerMessageMapper;
@Override @Override
public List<CustomerMessagePushVo> customerMessagePushs(String sender, String content, String pushType, String beginTime, String endTime) { public List<CustomerMessagePushVo> customerMessagePushs(String sender, String content, String pushType, String beginTime, String endTime) {
return weCustomerMessageOriginalMapper.selectCustomerMessagePushs(sender, content, pushType, beginTime, endTime); return weCustomerMessageOriginalMapper.selectCustomerMessagePushs(sender, content, pushType, beginTime, endTime);
...@@ -130,7 +136,8 @@ public class WeCustomerMessageOriginalServiceImpl extends ServiceImpl<WeCustomer ...@@ -130,7 +136,8 @@ public class WeCustomerMessageOriginalServiceImpl extends ServiceImpl<WeCustomer
if (d.getStatus().equals(WeConstans.sendMessageStatusEnum.SEND.getStatus())) { if (d.getStatus().equals(WeConstans.sendMessageStatusEnum.SEND.getStatus())) {
atomicInteger.incrementAndGet(); atomicInteger.incrementAndGet();
//更新消息发送状态
customerMessageMapper.updateWeCustomerMessageCheckStatusById(messageId,WeConstans.sendMessageStatusEnum.SEND.getStatus());
} }
weCustomerMessgaeResultMapper.updateWeCustomerMessgaeResult(messageId, d.getChat_id(), d.getExternal_userid(), d.getStatus(), d.getSend_time()); weCustomerMessgaeResultMapper.updateWeCustomerMessgaeResult(messageId, d.getChat_id(), d.getExternal_userid(), d.getStatus(), d.getSend_time());
......
package com.linkwechat.wecom.service.impl; package com.linkwechat.wecom.service.impl;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONUtil;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
...@@ -16,6 +17,7 @@ import com.linkwechat.wecom.client.WeCustomerMessagePushClient; ...@@ -16,6 +17,7 @@ import com.linkwechat.wecom.client.WeCustomerMessagePushClient;
import com.linkwechat.wecom.domain.*; import com.linkwechat.wecom.domain.*;
import com.linkwechat.wecom.domain.dto.message.*; import com.linkwechat.wecom.domain.dto.message.*;
import com.linkwechat.wecom.domain.vo.CustomerMessagePushVo; import com.linkwechat.wecom.domain.vo.CustomerMessagePushVo;
import com.linkwechat.wecom.mapper.WeCustomerMessageTimeTaskMapper;
import com.linkwechat.wecom.service.*; import com.linkwechat.wecom.service.*;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -24,6 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -24,6 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.text.ParseException;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -65,9 +68,12 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS ...@@ -65,9 +68,12 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS
@Autowired @Autowired
private RedisCache redisCache; private RedisCache redisCache;
@Autowired
private WeCustomerMessageTimeTaskMapper customerMessageTimeTaskMapper;
@Override @Override
@Transactional @Transactional
public void addWeCustomerMessagePush(CustomerMessagePushDto customerMessagePushDto) throws JsonProcessingException { public void addWeCustomerMessagePush(CustomerMessagePushDto customerMessagePushDto) throws JsonProcessingException, ParseException {
if ((null != customerMessagePushDto.getSettingTime() && !"".equals(customerMessagePushDto.getSettingTime())) if ((null != customerMessagePushDto.getSettingTime() && !"".equals(customerMessagePushDto.getSettingTime()))
&& DateUtils.diffTime(new Date(), DateUtil.parse(customerMessagePushDto.getSettingTime(), "yyyy-MM-dd HH:mm:ss")) > 0) { && DateUtils.diffTime(new Date(), DateUtil.parse(customerMessagePushDto.getSettingTime(), "yyyy-MM-dd HH:mm:ss")) > 0) {
...@@ -77,7 +83,7 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS ...@@ -77,7 +83,7 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS
List<WeCustomer> customers = Lists.newArrayList(); List<WeCustomer> customers = Lists.newArrayList();
List<WeGroup> groups = new ArrayList<>(); List<WeGroup> groups = new ArrayList<>();
// 0 发给客户 // 0 发给客户
if (customerMessagePushDto.getPushType().equals("0")) { if (customerMessagePushDto.getPushType().equals(WeConstans.SEND_MESSAGE_CUSTOMER)) {
//查询客户信息列表 //查询客户信息列表
customers = externalUserIds(customerMessagePushDto.getPushRange(), customerMessagePushDto.getStaffId() customers = externalUserIds(customerMessagePushDto.getPushRange(), customerMessagePushDto.getStaffId()
, customerMessagePushDto.getDepartment(), customerMessagePushDto.getTag()); , customerMessagePushDto.getDepartment(), customerMessagePushDto.getTag());
...@@ -87,7 +93,7 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS ...@@ -87,7 +93,7 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS
} }
// 0 发给客户群 // 0 发给客户群
if (customerMessagePushDto.getPushType().equals("1")) { if (customerMessagePushDto.getPushType().equals(WeConstans.SEND_MESSAGE_GROUP)) {
if (customerMessagePushDto.getStaffId() == null || customerMessagePushDto.getStaffId().equals("")) { if (customerMessagePushDto.getStaffId() == null || customerMessagePushDto.getStaffId().equals("")) {
throw new WeComException("请选择人员!"); throw new WeComException("请选择人员!");
...@@ -118,29 +124,19 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS ...@@ -118,29 +124,19 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS
//保存分类消息信息 //保存分类消息信息
weCustomerSeedMessageService.saveSeedMessage(customerMessagePushDto, messageId); weCustomerSeedMessageService.saveSeedMessage(customerMessagePushDto, messageId);
log.info("消息发送信息:{}", JSONUtil.toJsonStr(customerMessagePushDto));
CustomerMessagePushDto customerMessagePushDto1 = JSONUtil.toBean(JSONUtil.parseObj(JSONUtil.toJsonStr(customerMessagePushDto)), CustomerMessagePushDto.class);
//发送群发消息 //发送群发消息
//调用微信api发送消息 //调用微信api发送消息
if (null == customerMessagePushDto.getSettingTime() || customerMessagePushDto.getSettingTime().equals("")) { if (null == customerMessagePushDto.getSettingTime() || customerMessagePushDto.getSettingTime().equals("")) {
weCustomerMessageService.sendMessgae(customerMessagePushDto, messageId,customers,groups); weCustomerMessageService.sendMessgae(customerMessagePushDto, messageId,customers,groups);
} else { } else {
//发送时间不能小于当前时间 WeCustomerMessageTimeTask timeTask=new WeCustomerMessageTimeTask(messageId, customerMessagePushDto, customers,groups
//定时发送消息(异步执行) ,DateUtils.getMillionSceondsBydate(customerMessagePushDto.getSettingTime()));
//保存消息体到数据库,增加一个发送状态(0 已发送 1 未发送)
//定义一个任务执行队列 customerMessageTimeTaskMapper.saveWeCustomerMessageTimeTask(timeTask);
//把任务放入执行队列
//任务执行 sendMessgae(WeMessagePush weMessagePush) 方法
Timer timer = new Timer();
List<WeCustomer> finalCustomers = customers;
List<WeGroup> finalGroups = groups;
timer.schedule(new TimerTask() {
@SneakyThrows
@Override
public void run() {
weCustomerMessageService.sendMessgae(customerMessagePushDto, messageId, finalCustomers, finalGroups);
}
}, DateUtil.parse(customerMessagePushDto.getSettingTime(), "yyyy-MM-dd HH:mm:ss"));
} }
...@@ -161,7 +157,7 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS ...@@ -161,7 +157,7 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS
* @return {@link List}s 客户的外部联系人id列表 * @return {@link List}s 客户的外部联系人id列表
*/ */
public List<WeCustomer> externalUserIds(String pushRange, String staffId, String department, String tag) { public List<WeCustomer> externalUserIds(String pushRange, String staffId, String department, String tag) {
if (pushRange.equals("0")) { if (pushRange.equals(WeConstans.SEND_MESSAGE_CUSTOMER_ALL)) {
//从redis中读取数据 //从redis中读取数据
return redisCache.getCacheList(WeConstans.WECUSTOMERS_KEY); return redisCache.getCacheList(WeConstans.WECUSTOMERS_KEY);
} else { } else {
......
...@@ -5,7 +5,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; ...@@ -5,7 +5,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.linkwechat.common.constant.WeConstans; import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.enums.ChatType; import com.linkwechat.common.enums.ChatType;
import com.linkwechat.common.exception.wecom.WeComException; import com.linkwechat.common.enums.GroupMessageType;
import com.linkwechat.common.utils.SecurityUtils; import com.linkwechat.common.utils.SecurityUtils;
import com.linkwechat.common.utils.StringUtils; import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.wecom.client.WeCustomerMessagePushClient; import com.linkwechat.wecom.client.WeCustomerMessagePushClient;
...@@ -31,6 +31,7 @@ import java.util.stream.Collectors; ...@@ -31,6 +31,7 @@ import java.util.stream.Collectors;
* @author kewen * @author kewen
* @date 2020-12-12 * @date 2020-12-12
*/ */
@SuppressWarnings("all")
@Service @Service
public class WeCustomerMessageServiceImpl extends ServiceImpl<WeCustomerMessageMapper, WeCustomerMessage> implements IWeCustomerMessageService { public class WeCustomerMessageServiceImpl extends ServiceImpl<WeCustomerMessageMapper, WeCustomerMessage> implements IWeCustomerMessageService {
...@@ -90,7 +91,7 @@ public class WeCustomerMessageServiceImpl extends ServiceImpl<WeCustomerMessageM ...@@ -90,7 +91,7 @@ public class WeCustomerMessageServiceImpl extends ServiceImpl<WeCustomerMessageM
//发送群发消息 //发送群发消息
//发送类类型: 给单个客户发,群发 //发送类类型: 给单个客户发,群发
//发给客户 //发给客户
if (customerMessagePushDto.getPushType().equals("0")) { if (customerMessagePushDto.getPushType().equals(WeConstans.SEND_MESSAGE_CUSTOMER)) {
WeCustomerMessagePushDto messagePushDto = new WeCustomerMessagePushDto(); WeCustomerMessagePushDto messagePushDto = new WeCustomerMessagePushDto();
messagePushDto.setChat_type(ChatType.of(customerMessagePushDto.getPushType()).getName()); messagePushDto.setChat_type(ChatType.of(customerMessagePushDto.getPushType()).getName());
...@@ -106,7 +107,7 @@ public class WeCustomerMessageServiceImpl extends ServiceImpl<WeCustomerMessageM ...@@ -106,7 +107,7 @@ public class WeCustomerMessageServiceImpl extends ServiceImpl<WeCustomerMessageM
} }
//发给客户群 //发给客户群
if (customerMessagePushDto.getPushType().equals("1")) { if (customerMessagePushDto.getPushType().equals(WeConstans.SEND_MESSAGE_GROUP)) {
if (CollectionUtils.isNotEmpty(groups)) { if (CollectionUtils.isNotEmpty(groups)) {
List<String> owners = groups.stream().map(WeGroup::getOwner).collect(Collectors.toList()); List<String> owners = groups.stream().map(WeGroup::getOwner).collect(Collectors.toList());
...@@ -140,21 +141,21 @@ public class WeCustomerMessageServiceImpl extends ServiceImpl<WeCustomerMessageM ...@@ -140,21 +141,21 @@ public class WeCustomerMessageServiceImpl extends ServiceImpl<WeCustomerMessageM
public void childMessage(WeCustomerMessagePushDto weCustomerMessagePushDto, CustomerMessagePushDto customerMessagePushDto) { public void childMessage(WeCustomerMessagePushDto weCustomerMessagePushDto, CustomerMessagePushDto customerMessagePushDto) {
// 消息类型 0 文本消息 1 图片消息 2 链接消息 3 小程序消息 // 消息类型 0 文本消息 1 图片消息 2 链接消息 3 小程序消息
if (customerMessagePushDto.getMessageType().equals("0")) { if (customerMessagePushDto.getMessageType().equals(GroupMessageType.TEXT.getType())) {
weCustomerMessagePushDto.setImage(null); weCustomerMessagePushDto.setImage(null);
weCustomerMessagePushDto.setLink(null); weCustomerMessagePushDto.setLink(null);
weCustomerMessagePushDto.setMiniprogram(null); weCustomerMessagePushDto.setMiniprogram(null);
weCustomerMessagePushDto.setText(customerMessagePushDto.getTextMessage()); weCustomerMessagePushDto.setText(customerMessagePushDto.getTextMessage());
} }
if (customerMessagePushDto.getMessageType().equals("1")) { if (customerMessagePushDto.getMessageType().equals(GroupMessageType.IMAGE.getMessageType())) {
weCustomerMessagePushDto.setImage(customerMessagePushDto.getImageMessage()); weCustomerMessagePushDto.setImage(customerMessagePushDto.getImageMessage());
weCustomerMessagePushDto.setLink(null); weCustomerMessagePushDto.setLink(null);
weCustomerMessagePushDto.setMiniprogram(null); weCustomerMessagePushDto.setMiniprogram(null);
weCustomerMessagePushDto.setText(null); weCustomerMessagePushDto.setText(null);
} }
if (customerMessagePushDto.getMessageType().equals("2")) { if (customerMessagePushDto.getMessageType().equals(GroupMessageType.LINK.getType())) {
weCustomerMessagePushDto.setImage(null); weCustomerMessagePushDto.setImage(null);
weCustomerMessagePushDto.setLink(customerMessagePushDto.getLinkMessage()); weCustomerMessagePushDto.setLink(customerMessagePushDto.getLinkMessage());
weCustomerMessagePushDto.setMiniprogram(null); weCustomerMessagePushDto.setMiniprogram(null);
...@@ -162,7 +163,7 @@ public class WeCustomerMessageServiceImpl extends ServiceImpl<WeCustomerMessageM ...@@ -162,7 +163,7 @@ public class WeCustomerMessageServiceImpl extends ServiceImpl<WeCustomerMessageM
} }
if (customerMessagePushDto.getMessageType().equals("3")) { if (customerMessagePushDto.getMessageType().equals(GroupMessageType.MINIPROGRAM.getType())) {
weCustomerMessagePushDto.setImage(null); weCustomerMessagePushDto.setImage(null);
weCustomerMessagePushDto.setLink(null); weCustomerMessagePushDto.setLink(null);
weCustomerMessagePushDto.setMiniprogram(customerMessagePushDto.getMiniprogramMessage()); weCustomerMessagePushDto.setMiniprogram(customerMessagePushDto.getMiniprogramMessage());
...@@ -170,7 +171,7 @@ public class WeCustomerMessageServiceImpl extends ServiceImpl<WeCustomerMessageM ...@@ -170,7 +171,7 @@ public class WeCustomerMessageServiceImpl extends ServiceImpl<WeCustomerMessageM
} }
if(customerMessagePushDto.getMessageType().equals("4")){ if(customerMessagePushDto.getMessageType().equals(GroupMessageType.TEXT_IMAGE.getType())){
weCustomerMessagePushDto.setImage(customerMessagePushDto.getImageMessage()); weCustomerMessagePushDto.setImage(customerMessagePushDto.getImageMessage());
weCustomerMessagePushDto.setLink(null); weCustomerMessagePushDto.setLink(null);
weCustomerMessagePushDto.setMiniprogram(null); weCustomerMessagePushDto.setMiniprogram(null);
...@@ -179,5 +180,4 @@ public class WeCustomerMessageServiceImpl extends ServiceImpl<WeCustomerMessageM ...@@ -179,5 +180,4 @@ public class WeCustomerMessageServiceImpl extends ServiceImpl<WeCustomerMessageM
} }
} }
...@@ -111,7 +111,6 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto ...@@ -111,7 +111,6 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
*/ */
@Override @Override
public List<WeCustomer> selectWeCustomerList(WeCustomer weCustomer) { public List<WeCustomer> selectWeCustomerList(WeCustomer weCustomer) {
return weCustomerMapper.selectWeCustomerList(weCustomer); return weCustomerMapper.selectWeCustomerList(weCustomer);
} }
......
...@@ -98,8 +98,9 @@ public class WeEmpleCodeServiceImpl extends ServiceImpl<WeEmpleCodeMapper, WeEmp ...@@ -98,8 +98,9 @@ public class WeEmpleCodeServiceImpl extends ServiceImpl<WeEmpleCodeMapper, WeEmp
*/ */
@Override @Override
public List<WeEmpleCode> selectWeEmpleCodeList(WeEmpleCode weEmpleCode) { public List<WeEmpleCode> selectWeEmpleCodeList(WeEmpleCode weEmpleCode) {
List<WeEmpleCode> weEmpleCodeList = this.baseMapper.selectWeEmpleCodeList(weEmpleCode); List<WeEmpleCode> weEmpleCodeList = this.baseMapper.selectWeEmpleCodeList(weEmpleCode);
if (weEmpleCodeList != null) { if (CollectionUtil.isNotEmpty(weEmpleCodeList)) {
weEmpleCodeList.forEach(empleCode -> { weEmpleCodeList.forEach(empleCode -> {
List<WeEmpleCodeUseScop> weEmpleCodeUseScopList = empleCode.getWeEmpleCodeUseScops(); List<WeEmpleCodeUseScop> weEmpleCodeUseScopList = empleCode.getWeEmpleCodeUseScops();
if (CollectionUtil.isNotEmpty(weEmpleCodeUseScopList)) { if (CollectionUtil.isNotEmpty(weEmpleCodeUseScopList)) {
......
...@@ -21,6 +21,7 @@ import org.springframework.stereotype.Service; ...@@ -21,6 +21,7 @@ import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.io.File; import java.io.File;
import java.io.InputStream;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.util.Arrays; import java.util.Arrays;
...@@ -141,7 +142,8 @@ public class WeMaterialServiceImpl implements IWeMaterialService { ...@@ -141,7 +142,8 @@ public class WeMaterialServiceImpl implements IWeMaterialService {
conn = (HttpURLConnection) materialUrl.openConnection(); conn = (HttpURLConnection) materialUrl.openConnection();
conn.setRequestMethod("GET"); conn.setRequestMethod("GET");
conn.setConnectTimeout(20 * 1000); conn.setConnectTimeout(20 * 1000);
return weMediaClient.upload(conn.getInputStream(), name, type); InputStream inputStream = conn.getInputStream();
return weMediaClient.upload(inputStream, name, type);
}catch (Exception e){ }catch (Exception e){
e.printStackTrace(); e.printStackTrace();
log.error("上传临时文件失败......url:{},type:{},name:{},ex:{},st:{}",url,type,name,e.getMessage(),e.getStackTrace()); log.error("上传临时文件失败......url:{},type:{},name:{},ex:{},st:{}",url,type,name,e.getMessage(),e.getStackTrace());
......
...@@ -70,7 +70,6 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper, WeTagGr ...@@ -70,7 +70,6 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper, WeTagGr
if (CollectionUtil.isEmpty(weTags)) { if (CollectionUtil.isEmpty(weTags)) {
this.save(weTagGroup); this.save(weTagGroup);
} else { } else {
WeCropGropTagDtlDto weCropGropTagDtlDto = weCropTagClient.addCorpTag(WeCropGroupTagDto.transformAddTag(weTagGroup)); WeCropGropTagDtlDto weCropGropTagDtlDto = weCropTagClient.addCorpTag(WeCropGroupTagDto.transformAddTag(weTagGroup));
......
...@@ -3,13 +3,19 @@ package com.linkwechat.wecom.service.impl; ...@@ -3,13 +3,19 @@ package com.linkwechat.wecom.service.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.linkwechat.common.config.CosConfig;
import com.linkwechat.common.constant.WeConstans; import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.enums.TaskFissionType; import com.linkwechat.common.enums.TaskFissionType;
import com.linkwechat.common.exception.wecom.WeComException;
import com.linkwechat.common.utils.DateUtils; import com.linkwechat.common.utils.DateUtils;
import com.linkwechat.common.utils.QREncode;
import com.linkwechat.common.utils.SecurityUtils; import com.linkwechat.common.utils.SecurityUtils;
import com.linkwechat.common.utils.StringUtils; import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.common.utils.file.FileUploadUtils;
import com.linkwechat.common.utils.img.NetFileUtils;
import com.linkwechat.wecom.client.WeExternalContactClient; import com.linkwechat.wecom.client.WeExternalContactClient;
import com.linkwechat.wecom.domain.*; import com.linkwechat.wecom.domain.*;
import com.linkwechat.wecom.domain.dto.WeChatUserDTO;
import com.linkwechat.wecom.domain.dto.WeExternalContactDto; import com.linkwechat.wecom.domain.dto.WeExternalContactDto;
import com.linkwechat.wecom.domain.dto.WeTaskFissionPosterDTO; import com.linkwechat.wecom.domain.dto.WeTaskFissionPosterDTO;
import com.linkwechat.wecom.domain.dto.message.CustomerMessagePushDto; import com.linkwechat.wecom.domain.dto.message.CustomerMessagePushDto;
...@@ -18,11 +24,17 @@ import com.linkwechat.wecom.mapper.WeTaskFissionMapper; ...@@ -18,11 +24,17 @@ import com.linkwechat.wecom.mapper.WeTaskFissionMapper;
import com.linkwechat.wecom.service.*; import com.linkwechat.wecom.service.*;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.text.ParseException;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -52,6 +64,12 @@ public class WeTaskFissionServiceImpl implements IWeTaskFissionService { ...@@ -52,6 +64,12 @@ public class WeTaskFissionServiceImpl implements IWeTaskFissionService {
private IWePosterService wePosterService; private IWePosterService wePosterService;
@Autowired @Autowired
private IWeGroupCodeService weGroupCodeService; private IWeGroupCodeService weGroupCodeService;
@Autowired
private IWeMaterialService weMaterialService;
@Autowired
private IWeTaskFissionCompleteRecordService weTaskFissionCompleteRecordService;
@Autowired
private CosConfig cosConfig;
@Value("${H5.url}") @Value("${H5.url}")
private String pageUrl; private String pageUrl;
...@@ -181,7 +199,7 @@ public class WeTaskFissionServiceImpl implements IWeTaskFissionService { ...@@ -181,7 +199,7 @@ public class WeTaskFissionServiceImpl implements IWeTaskFissionService {
} }
try { try {
weCustomerMessagePushService.addWeCustomerMessagePush(customerMessagePushDto); weCustomerMessagePushService.addWeCustomerMessagePush(customerMessagePushDto);
} catch (JsonProcessingException e) { } catch (JsonProcessingException | ParseException e) {
e.printStackTrace(); e.printStackTrace();
log.error("发送任务失败》》》》》》》》》》》params:{},ex:{}", JSONObject.toJSONString(customerMessagePushDto), e); log.error("发送任务失败》》》》》》》》》》》params:{},ex:{}", JSONObject.toJSONString(customerMessagePushDto), e);
} }
...@@ -195,7 +213,7 @@ public class WeTaskFissionServiceImpl implements IWeTaskFissionService { ...@@ -195,7 +213,7 @@ public class WeTaskFissionServiceImpl implements IWeTaskFissionService {
WeUser user = weUserService.selectWeUserById(weTaskFissionPosterDTO.getUserId()); WeUser user = weUserService.selectWeUserById(weTaskFissionPosterDTO.getUserId());
if (user != null) { if (user != null) {
WeTaskFissionRecord record = getTaskFissionRecordId(weTaskFissionPosterDTO.getTaskFissionId(), user.getUserId(), user.getName()); WeTaskFissionRecord record = getTaskFissionRecordId(weTaskFissionPosterDTO.getTaskFissionId(), user.getUserId(), user.getName());
String qrcode = getPosterQRCode(weTaskFissionPosterDTO.getFissStaffId(), record); String qrcode = getPosterQRCode(weTaskFissionPosterDTO.getFissionTargetId(), record, user);
WePoster poster = wePosterService.selectOne(weTaskFissionPosterDTO.getPosterId()); WePoster poster = wePosterService.selectOne(weTaskFissionPosterDTO.getPosterId());
poster.getPosterSubassemblyList().stream().filter(Objects::nonNull) poster.getPosterSubassemblyList().stream().filter(Objects::nonNull)
.filter(wePosterSubassembly -> wePosterSubassembly.getType() == 3).forEach(wePosterSubassembly -> { .filter(wePosterSubassembly -> wePosterSubassembly.getType() == 3).forEach(wePosterSubassembly -> {
...@@ -207,14 +225,48 @@ public class WeTaskFissionServiceImpl implements IWeTaskFissionService { ...@@ -207,14 +225,48 @@ public class WeTaskFissionServiceImpl implements IWeTaskFissionService {
} }
} }
private String getPosterQRCode(String fissStaffId, WeTaskFissionRecord record) { @Override
public void completeFissionRecord(Long taskFissionId, Long taskFissionRecordId, WeChatUserDTO weChatUserDTO) {
WeTaskFissionCompleteRecord wfcr = new WeTaskFissionCompleteRecord();
wfcr.setTaskFissionId(taskFissionId);
wfcr.setFissionRecordId(taskFissionRecordId);
String userId = StringUtils.isBlank(weChatUserDTO.getUserid()) ? weChatUserDTO.getUnionid() : weChatUserDTO.getUserid();
wfcr.setCustomerId(userId);
wfcr.setCustomerName(weChatUserDTO.getName());
List<WeTaskFissionCompleteRecord> list = weTaskFissionCompleteRecordService.selectWeTaskFissionCompleteRecordList(wfcr);
if (CollectionUtils.isEmpty(list)) {
wfcr.setCreateBy(SecurityUtils.getUsername());
wfcr.setCreateTime(new Date());
weTaskFissionCompleteRecordService.insertWeTaskFissionCompleteRecord(wfcr);
}
}
private String getPosterQRCode(String fissionTargetId, WeTaskFissionRecord record, WeUser user) {
String qrCode;
Long taskFissionId = record.getTaskFissionId();
WeTaskFission taskFission = weTaskFissionMapper.selectWeTaskFissionById(taskFissionId);
Integer taskFissionType = taskFission.getFissionType();
if (TaskFissionType.USER_FISSION.getCode().equals(taskFissionType)) {
qrCode = getUserFissionQrcode(fissionTargetId, record);
} else if (TaskFissionType.GROUP_FISSION.getCode().equals(taskFissionType)) {
qrCode = getGroupFissionQrcode(taskFissionId, fissionTargetId, record, user);
} else {
throw new WeComException("错误的任务类型");
}
if (StringUtils.isBlank(qrCode)) {
throw new WeComException("生成的二维码为空");
}
return qrCode;
}
private String getUserFissionQrcode(String fissionTargetId, WeTaskFissionRecord record) {
WeExternalContactDto dto = null; WeExternalContactDto dto = null;
if (StringUtils.isNotBlank(record.getConfigId())) { if (StringUtils.isNotBlank(record.getConfigId())) {
dto = weExternalContactClient.getContactWay(record.getConfigId()); dto = weExternalContactClient.getContactWay(record.getConfigId());
} }
if (dto == null) { if (dto == null) {
//获取二维码 //获取二维码
WeExternalContactDto.WeContactWay contactWay = posterContactWay(fissStaffId, record.getId()); WeExternalContactDto.WeContactWay contactWay = posterContactWay(fissionTargetId, record.getId());
dto = weExternalContactClient.addContactWay(contactWay); dto = weExternalContactClient.addContactWay(contactWay);
record.setConfigId(dto.getConfig_id()); record.setConfigId(dto.getConfig_id());
int updateResult = weTaskFissionRecordService.updateWeTaskFissionRecord(record); int updateResult = weTaskFissionRecordService.updateWeTaskFissionRecord(record);
...@@ -225,11 +277,32 @@ public class WeTaskFissionServiceImpl implements IWeTaskFissionService { ...@@ -225,11 +277,32 @@ public class WeTaskFissionServiceImpl implements IWeTaskFissionService {
return dto.getQr_code(); return dto.getQr_code();
} }
private WeExternalContactDto.WeContactWay posterContactWay(String fissUserId, Long recordId) { private String getGroupFissionQrcode(Long taskFissionId, String fissionTargetId, WeTaskFissionRecord record, WeUser user) {
String qrCode = record.getConfigId();
String avatar = user.getAvatarMediaid();
WeMaterial file = weMaterialService.findWeMaterialById(Long.parseLong(avatar));
if (StringUtils.isBlank(qrCode)) {
String content = "/wecom/fission/complete/" + taskFissionId + "/records/" + record.getId();
BufferedImage bufferedImage = QREncode.crateQRCode(content, file.getMaterialUrl());
if (bufferedImage != null) {
try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
ImageIO.write(bufferedImage, "png", byteArrayOutputStream);
NetFileUtils.StreamMultipartFile streamMultipartFile = new NetFileUtils.StreamMultipartFile(System.currentTimeMillis() + ".jpg", byteArrayOutputStream.toByteArray());
qrCode = FileUploadUtils.upload2Cos(streamMultipartFile, cosConfig);
} catch (Exception e) {
log.warn("生成海报二维码异常, fissionTargetId={}, record={}, user={}, exception={}", fissionTargetId, record, user, ExceptionUtils.getStackTrace(e));
throw new WeComException("生成二维码异常");
}
}
}
return qrCode;
}
private WeExternalContactDto.WeContactWay posterContactWay(String fissionTargetId, Long recordId) {
WeExternalContactDto.WeContactWay wcw = new WeExternalContactDto.WeContactWay(); WeExternalContactDto.WeContactWay wcw = new WeExternalContactDto.WeContactWay();
wcw.setScene(2); wcw.setScene(2);
wcw.setType(1); wcw.setType(1);
wcw.setUser(new String[]{fissUserId}); wcw.setUser(new String[]{fissionTargetId});
wcw.setState(WeConstans.FISSION_PREFIX + recordId); wcw.setState(WeConstans.FISSION_PREFIX + recordId);
return wcw; return wcw;
} }
......
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.util.ArrayUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.common.constant.WeConstans; import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.core.redis.RedisCache; import com.linkwechat.common.core.redis.RedisCache;
...@@ -16,6 +17,7 @@ import com.linkwechat.wecom.service.IWeCustomerService; ...@@ -16,6 +17,7 @@ import com.linkwechat.wecom.service.IWeCustomerService;
import com.linkwechat.wecom.service.IWeDepartmentService; import com.linkwechat.wecom.service.IWeDepartmentService;
import com.linkwechat.wecom.service.IWeGroupService; import com.linkwechat.wecom.service.IWeGroupService;
import com.linkwechat.wecom.service.IWeUserService; import com.linkwechat.wecom.service.IWeUserService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -80,6 +82,10 @@ public class WeUserServiceImpl extends ServiceImpl<WeUserMapper,WeUser> implemen ...@@ -80,6 +82,10 @@ public class WeUserServiceImpl extends ServiceImpl<WeUserMapper,WeUser> implemen
@Override @Override
public List<WeUser> selectWeUserList(WeUser weUser) public List<WeUser> selectWeUserList(WeUser weUser)
{ {
String[] department = weUser.getDepartment();
if(ArrayUtil.isNotEmpty(department)){
weUser.setDepartmentStr(StringUtils.join(department, ","));
}
return weUserMapper.selectWeUserList(weUser); return weUserMapper.selectWeUserList(weUser);
} }
......
...@@ -30,7 +30,8 @@ ...@@ -30,7 +30,8 @@
wm.material_url, wm.material_url,
wm.content, wm.content,
wc.media_type, wc.media_type,
wcc.create_time wcc.create_time,
wm.cover_url
FROM FROM
we_chat_collection wcc we_chat_collection wcc
LEFT JOIN we_material wm ON wcc.material_id = wm.id LEFT JOIN we_material wm ON wcc.material_id = wm.id
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
wm.material_url, wm.material_url,
wm.content, wm.content,
wc.media_type, wc.media_type,
wm.cover_url,
( (
SELECT SELECT
COUNT(1) COUNT(1)
......
...@@ -31,8 +31,9 @@ ...@@ -31,8 +31,9 @@
FROM FROM
we_chat_side we_chat_side
<where> <where>
del_flag=0
<if test="h5!=null and h5!='' and h5=='1'.toString()"> <if test="h5!=null and h5!='' and h5=='1'.toString()">
`using`=0 AND `using`=0
</if> </if>
</where> </where>
</select> </select>
......
...@@ -4,7 +4,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -4,7 +4,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.linkwechat.wecom.mapper.WeCustomerMapper"> <mapper namespace="com.linkwechat.wecom.mapper.WeCustomerMapper">
<resultMap type="WeCustomer" id="WeCustomerResult"> <resultMap type="com.linkwechat.wecom.domain.WeCustomer" id="WeCustomerResult">
<id property="externalUserid" column="external_userid" /> <id property="externalUserid" column="external_userid" />
<result property="name" column="name" /> <result property="name" column="name" />
<result property="avatar" column="avatar" /> <result property="avatar" column="avatar" />
......
...@@ -21,5 +21,14 @@ ...@@ -21,5 +21,14 @@
message_id=#{messageId} message_id=#{messageId}
</where> </where>
</update> </update>
<update id="updateWeCustomerMessageCheckStatusById">
UPDATE we_customer_message
<set>
check_status=#{status}
</set>
<where>
message_id=#{messageId}
</where>
</update>
</mapper> </mapper>
...@@ -17,7 +17,8 @@ ...@@ -17,7 +17,8 @@
wcm.expect_send, wcm.expect_send,
wcm.actual_send, wcm.actual_send,
wcm.timed_task, wcm.timed_task,
wcm.msgid wcm.msgid,
wcm.check_status
FROM FROM
we_customer_messageOriginal wcmo we_customer_messageOriginal wcmo
LEFT JOIN we_customer_message wcm ON wcmo.message_original_Id = wcm.original_id LEFT JOIN we_customer_message wcm ON wcmo.message_original_Id = wcm.original_id
......
<?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.WeCustomerMessageTimeTaskMapper">
<resultMap id="tasks" type="com.linkwechat.wecom.domain.WeCustomerMessageTimeTask">
<id column="task_id" property="taskId"/>
<result column="message_id" property="messageId"/>
<result column="message_info" property="messageInfo" typeHandler="com.linkwechat.framework.handler.GenericTypeHandler"/>
<result column="customers_info" property="customersInfo" typeHandler="com.linkwechat.framework.handler.ListTypeHandler"/>
<result column="groups_info" property="groupsInfo" typeHandler="com.linkwechat.framework.handler.ListTypeHandler"/>
<result column="setting_time" property="settingTime"/>
</resultMap>
<insert id="saveWeCustomerMessageTimeTask">
INSERT INTO we_customer_messageTimeTask (
message_id,
message_info,
customers_info,
groups_info,
setting_time,
create_by,
create_time,
update_by,
update_time
)
VALUES
(
#{messageId},
#{messageInfo,jdbcType=OTHER,typeHandler=com.linkwechat.framework.handler.GenericTypeHandler},
#{customersInfo,jdbcType=OTHER,typeHandler=com.linkwechat.framework.handler.ListTypeHandler},
#{groupsInfo,jdbcType=OTHER,typeHandler=com.linkwechat.framework.handler.ListTypeHandler},
#{settingTime},
#{createBy},
#{createTime},
#{updateBy},
#{updateTime}
)
</insert>
<update id="updateTaskSolvedById">
UPDATE we_customer_messageTimeTask
<set>
solved=1
</set>
<where>
task_id=#{taskId}
</where>
</update>
<select id="selectWeCustomerMessageTimeTaskGteSettingTime" resultMap="tasks">
SELECT
task_id,
message_id,
message_info,
customers_info,
groups_info,
setting_time
FROM
we_customer_messageTimeTask
<where>
setting_time <![CDATA[<=]]> #{timeMillis} AND solved=0
</where>
</select>
</mapper>
\ No newline at end of file \ No newline at end of file
...@@ -31,7 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -31,7 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
wm.material_url wm.material_url
FROM FROM
we_msg_tlp wmt we_msg_tlp wmt
INNER JOIN we_material wm ON wmt.media_id=wm.id LEFT JOIN we_material wm ON wmt.media_id=wm.id
<where> <where>
<if test="welcomeMsg != null and welcomeMsg != ''"> and wmt.welcome_msg like CONCAT('%',#{welcomeMsg,jdbcType=VARCHAR},'%') </if> <if test="welcomeMsg != null and welcomeMsg != ''"> and wmt.welcome_msg like CONCAT('%',#{welcomeMsg,jdbcType=VARCHAR},'%') </if>
<if test="welcomeMsgTplType !=null "> and wmt.welcome_msg_tpl_type = #{welcomeMsgTplType}</if> <if test="welcomeMsgTplType !=null "> and wmt.welcome_msg_tpl_type = #{welcomeMsgTplType}</if>
......
...@@ -44,7 +44,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -44,7 +44,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="mobile != null and mobile != ''"> and mobile = #{mobile}</if> <if test="mobile != null and mobile != ''"> and mobile = #{mobile}</if>
<if test="email != null and email != ''"> and email = #{email}</if> <if test="email != null and email != ''"> and email = #{email}</if>
<if test="wxAccount != null and wxAccount != ''"> and wx_account = #{wxAccount}</if> <if test="wxAccount != null and wxAccount != ''"> and wx_account = #{wxAccount}</if>
<if test="department != null and department.length > 0 "> and FIND_IN_SET(#{department},department)</if> <if test="departmentStr != null and departmentStr != '' "> and FIND_IN_SET(#{departmentStr},department)</if>
<if test="position != null and position != ''"> and position = #{position}</if> <if test="position != null and position != ''"> and position = #{position}</if>
<if test="isLeaderInDept != null "> and is_leader_in_dept = #{isLeaderInDept}</if> <if test="isLeaderInDept != null "> and is_leader_in_dept = #{isLeaderInDept}</if>
<if test="joinTime != null "> and join_time = #{joinTime}</if> <if test="joinTime != null "> and join_time = #{joinTime}</if>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!