Commit 5748f95e by 水库浪子

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

2 parents 1aed84ba d6f585de
......@@ -3,6 +3,8 @@ package com.linkwechat.web.controller.wecom;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.nacos.common.utils.CollectionUtils;
import com.google.common.collect.Lists;
import com.linkwechat.common.annotation.Log;
import com.linkwechat.common.config.CosConfig;
import com.linkwechat.common.constant.HttpStatus;
......@@ -20,7 +22,9 @@ 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.query.WeTaskFissionStatisticQO;
import com.linkwechat.wecom.domain.vo.WeTaskFissionProgressVO;
import com.linkwechat.wecom.domain.vo.WeTaskFissionStatisticVO;
import com.linkwechat.wecom.domain.vo.WeTaskFissionTotalProgressVO;
import com.linkwechat.wecom.service.IWeTaskFissionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -35,6 +39,7 @@ import java.io.IOException;
import java.text.ParseException;
import java.util.Date;
import java.util.List;
import java.util.Objects;
/**
......@@ -58,7 +63,7 @@ public class WeTaskFissionController extends BaseController {
@ApiOperation(value = "查询任务宝列表", httpMethod = "GET")
@PreAuthorize("@ss.hasPermi('wecom:fission:list')")
@GetMapping("/list")
public TableDataInfo list(WeTaskFission weTaskFission) {
public TableDataInfo<List<WeTaskFission>> list(WeTaskFission weTaskFission) throws ParseException {
startPage();
List<WeTaskFission> list = weTaskFissionService.selectWeTaskFissionList(weTaskFission);
return getDataTable(list);
......@@ -70,7 +75,7 @@ public class WeTaskFissionController extends BaseController {
@ApiOperation(value = "查询统计信息", httpMethod = "GET")
@PreAuthorize("@ss.hasPermi('wecom:fission:stat')")
@GetMapping("/stat")
public AjaxResult statistics(WeTaskFissionStatisticQO weTaskFissionStatisticQO) throws ParseException {
public AjaxResult<WeTaskFissionStatisticVO> statistics(WeTaskFissionStatisticQO weTaskFissionStatisticQO) throws ParseException {
Date st;
Date et = DateUtils.getNowDate();
if (weTaskFissionStatisticQO.getSeven()) {
......@@ -95,7 +100,7 @@ public class WeTaskFissionController extends BaseController {
@PreAuthorize("@ss.hasPermi('wecom:fission:export')")
@Log(title = "任务宝", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(WeTaskFission weTaskFission) {
public AjaxResult export(WeTaskFission weTaskFission) throws ParseException {
List<WeTaskFission> list = weTaskFissionService.selectWeTaskFissionList(weTaskFission);
ExcelUtil<WeTaskFission> util = new ExcelUtil<WeTaskFission>(WeTaskFission.class);
return util.exportExcel(list, "fission");
......@@ -107,7 +112,7 @@ public class WeTaskFissionController extends BaseController {
@ApiOperation(value = "获取任务宝详细信息", httpMethod = "GET")
@PreAuthorize("@ss.hasPermi('wecom:fission:query')")
@GetMapping(value = "/getInfo/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
public AjaxResult<WeTaskFission> getInfo(@PathVariable("id") Long id) {
return AjaxResult.success(weTaskFissionService.selectWeTaskFissionById(id));
}
......@@ -190,7 +195,7 @@ public class WeTaskFissionController extends BaseController {
return AjaxResult.error(HttpStatus.NOT_FOUND, "数据不存在");
}
weTaskFissionService.completeFissionRecord(id, recordId, weChatUserDTO);
return AjaxResult.success(taskFission.getFissQrcode());
return AjaxResult.success("操作成功", taskFission.getFissQrcode());
}
/**
......@@ -200,7 +205,7 @@ public class WeTaskFissionController extends BaseController {
@PreAuthorize("@ss.hasPermi('wecom:fission:poster')")
@Log(title = "生成带二维码的海报", businessType = BusinessType.OTHER)
@PostMapping("/poster")
public AjaxResult posterGenerate(@RequestBody WeTaskFissionPosterDTO weTaskFissionPosterDTO) {
public AjaxResult<JSONObject> posterGenerate(@RequestBody WeTaskFissionPosterDTO weTaskFissionPosterDTO) {
String posterUrl = weTaskFissionService.fissionPosterGenerate(weTaskFissionPosterDTO);
JSONObject json = new JSONObject();
json.put("posterUrl", posterUrl);
......@@ -214,7 +219,7 @@ public class WeTaskFissionController extends BaseController {
@Log(title = "上传兑奖图片", businessType = BusinessType.OTHER)
@PostMapping("/upload")
@ApiOperation(value = "上传兑奖图片", httpMethod = "POST")
public AjaxResult upload(@RequestParam(value = "file") MultipartFile file) throws IOException {
public AjaxResult<JSONObject> upload(@RequestParam(value = "file") MultipartFile file) throws IOException {
String url = FileUploadUtils.upload2Cos(file, cosConfig);
JSONObject json = new JSONObject();
json.put("rewardImageUrl", url);
......@@ -223,14 +228,57 @@ public class WeTaskFissionController extends BaseController {
/**
* 根据任务id和unionId获取添加客户列表
* 根据任务id获取参与任务客户列表
*/
@ApiOperation(value = "根据任务id和unionId获取添加客户列表", httpMethod = "GET")
@ApiOperation(value = "根据任务id获取参与任务客户列表", httpMethod = "GET")
@PreAuthorize("@ss.hasPermi('wecom:fission:getCustomerListById')")
@Log(title = "根据任务id和unionId获取添加客户列表", businessType = BusinessType.OTHER)
@GetMapping("/getCustomerListById/{fissionId}/{unionId}")
public AjaxResult<List<WeCustomer>> getCustomerListById(@ApiParam("任务id") @PathVariable("fissionId") String fissionId
, @PathVariable("unionId") @ApiParam("微信用户id") String unionId) {
return AjaxResult.success(weTaskFissionService.getCustomerListById(unionId, fissionId));
@Log(title = "根据任务id获取参与任务客户列表", businessType = BusinessType.OTHER)
@GetMapping("/getCustomerListById/{id}")
public AjaxResult<List<WeCustomer>> getCustomerListById(@ApiParam("任务id") @PathVariable("id") String id) {
return AjaxResult.success(weTaskFissionService.getCustomerListById(null, id));
}
/**
* 获取客户邀请列表和任务进度
*/
@ApiOperation(value = "获取客户邀请列表和任务进度", httpMethod = "GET")
@PreAuthorize("@ss.hasPermi('wecom:fission:getCustomerProgress')")
@Log(title = "获取客户邀请列表和任务进度", businessType = BusinessType.OTHER)
@GetMapping("/{id}/progress/{eid}")
public AjaxResult<WeTaskFissionProgressVO> getCustomerProgress(@ApiParam("任务id") @PathVariable("id") Long id
, @PathVariable("eid") @ApiParam("客户id") String eid) {
WeTaskFission weTaskFission = weTaskFissionService.selectWeTaskFissionById(id);
if (weTaskFission != null) {
return AjaxResult.success(weTaskFissionService.getCustomerTaskProgress(weTaskFission, eid));
} else {
throw new WeComException("任务不存在");
}
}
/**
* 获取任务所有参与客户的完成情况
*/
@ApiOperation(value = "获取任务所有参与客户的完成情况", httpMethod = "GET")
@PreAuthorize("@ss.hasPermi('wecom:fission:getCustomerProgress')")
@Log(title = "获取任务所有参与客户的完成情况", businessType = BusinessType.OTHER)
@GetMapping("/{id}/progress")
public AjaxResult<List<WeTaskFissionTotalProgressVO>> getAllCustomerProgress(@ApiParam("任务id") @PathVariable("id") Long id) {
WeTaskFission weTaskFission = weTaskFissionService.selectWeTaskFissionById(id);
List<WeTaskFissionTotalProgressVO> list = Lists.newArrayList();
if (weTaskFission != null) {
List<WeCustomer> customers = weTaskFissionService.getCustomerListById(null, String.valueOf(id));
if (CollectionUtils.isNotEmpty(customers)) {
customers.stream().filter(Objects::nonNull).forEach(customer -> {
WeTaskFissionTotalProgressVO vo = new WeTaskFissionTotalProgressVO();
vo.setCustomer(customer);
vo.setProgress(weTaskFissionService.getCustomerTaskProgress(weTaskFission, customer.getUnionid()));
list.add(vo);
});
}
return AjaxResult.success(list);
} else {
throw new WeComException("任务不存在");
}
}
}
......@@ -105,10 +105,10 @@ public class WeTaskFissionRewardController extends BaseController {
* 根据微信用户id和任务id获取任务裂变奖励详细信息
*/
@ApiOperation(value = "根据微信用户id和任务id获取任务裂变奖励详细信息",httpMethod = "GET")
@PreAuthorize("@ss.hasPermi('wecom:getRewardById:query')")
@GetMapping(value = "/getRewardByFissionId/{fissionId}/{unionId}")
@PreAuthorize("@ss.hasPermi('wecom:getRewardByFissionId:query')")
@GetMapping(value = "/getRewardByFissionId/{fissionId}/{eid}")
public AjaxResult<WeTaskFissionRewardVo> getRewardByFissionId(@ApiParam("任务id") @PathVariable("fissionId") String fissionId
, @PathVariable("unionId") @ApiParam("微信用户id") String unionId) {
return AjaxResult.success(weTaskFissionRewardService.getRewardByFissionId(fissionId,unionId));
, @PathVariable("eid") @ApiParam("客户id") String eid) {
return AjaxResult.success(weTaskFissionRewardService.getRewardByFissionId(fissionId,eid));
}
}
package com.linkwechat.web.core.config;
import com.linkwechat.common.core.domain.AjaxResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.MethodParameter;
import org.springframework.http.MediaType;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
import java.util.Objects;
@RestControllerAdvice(basePackages = "com.linkwechat")
@Slf4j
public class ResponseAdvice implements ResponseBodyAdvice {
@Override
public boolean supports(MethodParameter methodParameter, Class aClass) {
return true;
}
@Override
public Object beforeBodyWrite(Object o, MethodParameter methodParameter, MediaType mediaType, Class aClass, ServerHttpRequest serverHttpRequest, ServerHttpResponse serverHttpResponse) {
if (Objects.isNull(o)) {
return AjaxResult.success().build();
}
if (o instanceof AjaxResult) {
return ((AjaxResult) o).build();
}
return o;
}
}
\ No newline at end of file
......@@ -64,7 +64,7 @@ public class BaseController
* 响应请求分页数据
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
protected TableDataInfo getDataTable(List<?> list)
protected <T>TableDataInfo getDataTable(List<T> list)
{
TableDataInfo rspData = new TableDataInfo();
rspData.setCode(HttpStatus.SUCCESS);
......@@ -78,7 +78,7 @@ public class BaseController
* 响应请求分页数据
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
protected TableDataInfo getDataTable(PageInfo<?> pageInfo)
protected <T>TableDataInfo getDataTable(PageInfo<T> pageInfo)
{
TableDataInfo rspData = new TableDataInfo();
rspData.setCode(HttpStatus.SUCCESS);
......
package com.linkwechat.common.core.domain;
import java.util.HashMap;
import com.linkwechat.common.utils.StringUtils;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.linkwechat.common.constant.HttpStatus;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Optional;
/**
* 操作消息提醒
*
*
* @author ruoyi
*/
public class AjaxResult<T> extends HashMap<String, Object>
{
private static final long serialVersionUID = 1L;
@ApiModel
@Data
public class AjaxResult<T> implements Serializable {
private static final long serialVersionUID = 7337293201809451832L;
@JsonIgnore
private HashMap<String, Object> map;
/** 状态码 */
/**
* 状态码
*/
public static final String CODE_TAG = "code";
/** 返回内容 */
@ApiModelProperty("状态码")
private int code;
/**
* 返回内容
*/
public static final String MSG_TAG = "msg";
/** 数据对象 */
@ApiModelProperty("返回内容")
private String msg;
/**
* 数据对象
*/
public static final String DATA_TAG = "data";
@ApiModelProperty("数据对象")
private T data;
/**
* 初始化一个新创建的 AjaxResult 对象,使其表示一个空消息。
*/
public AjaxResult()
{
public AjaxResult() {
this.map = new HashMap<>();
}
/**
* 初始化一个新创建的 AjaxResult 对象
*
*
* @param code 状态码
* @param msg 返回内容
* @param msg 返回内容
*/
public AjaxResult(int code, String msg)
{
super.put(CODE_TAG, code);
super.put(MSG_TAG, msg);
public AjaxResult(int code, String msg) {
this();
this.code = code;
this.msg = msg;
}
/**
* 初始化一个新创建的 AjaxResult 对象
*
*
* @param code 状态码
* @param msg 返回内容
* @param msg 返回内容
* @param data 数据对象
*/
public AjaxResult(int code, String msg, T data)
{
super.put(CODE_TAG, code);
super.put(MSG_TAG, msg);
if (StringUtils.isNotNull(data))
{
super.put(DATA_TAG, data);
}
public AjaxResult(int code, String msg, T data) {
this();
this.code = code;
this.msg = msg;
this.data = data;
}
/**
* 返回成功消息
*
*
* @return 成功消息
*/
public static AjaxResult success()
{
public static AjaxResult success() {
return AjaxResult.success("操作成功");
}
/**
* 返回成功数据
*
*
* @return 成功消息
*/
public static AjaxResult success(Object data)
{
public static <T> AjaxResult success(T data) {
return AjaxResult.success("操作成功", data);
}
/**
* 返回成功消息
*
*
* @param msg 返回内容
* @return 成功消息
*/
public static AjaxResult success(String msg)
{
public static AjaxResult success(String msg) {
return AjaxResult.success(msg, null);
}
/**
* 返回成功消息
*
* @param msg 返回内容
*
* @param msg 返回内容
* @param data 数据对象
* @return 成功消息
*/
public static AjaxResult success(String msg, Object data)
{
return new AjaxResult(HttpStatus.SUCCESS, msg, data);
public static <T> AjaxResult<T> success(String msg, T data) {
return (AjaxResult<T>) new AjaxResult(HttpStatus.SUCCESS, msg, data);
}
/**
* 返回错误消息
*
*
* @return
*/
public static AjaxResult error()
{
public static AjaxResult error() {
return AjaxResult.error("操作失败");
}
/**
* 返回错误消息
*
*
* @param msg 返回内容
* @return 警告消息
*/
public static AjaxResult error(String msg)
{
public static AjaxResult error(String msg) {
return AjaxResult.error(msg, null);
}
/**
* 返回错误消息
*
* @param msg 返回内容
*
* @param msg 返回内容
* @param data 数据对象
* @return 警告消息
*/
public static AjaxResult error(String msg, Object data)
{
public static AjaxResult error(String msg, Object data) {
return new AjaxResult(HttpStatus.ERROR, msg, data);
}
/**
* 返回错误消息
*
*
* @param code 状态码
* @param msg 返回内容
* @param msg 返回内容
* @return 警告消息
*/
public static AjaxResult error(int code, String msg)
{
public static AjaxResult error(int code, String msg) {
return new AjaxResult(code, msg, null);
}
public void put(String key, Object value) {
this.map.put(key, value);
}
public JSONObject build() {
JSONObject json = new JSONObject();
json.put("code", getCode());
json.put("msg", getMsg());
json.put("data", getData());
Optional.ofNullable(getMap()).ifPresent(m -> m.forEach(json::put));
return json;
}
}
......@@ -12,8 +12,8 @@ import lombok.Data;
@ApiModel
@Data
public class WeTaskFissionPosterDTO {
@ApiModelProperty("客户id(微信用户Id)")
private String unionId;
@ApiModelProperty("客户id")
private String eid;
@ApiModelProperty("任务id")
private Long taskFissionId;
......
package com.linkwechat.wecom.domain.vo;
import com.linkwechat.wecom.domain.WeCustomer;
import lombok.Builder;
import lombok.Data;
import java.util.List;
/**
* @author leejoker <1056650571@qq.com>
* @version 1.0
* @date 2021/3/20 13:12
*
* <p>
* 客户任务进度和邀请列表
* </p>
*/
@Data
@Builder
public class WeTaskFissionProgressVO {
private Long total;
private Long completed;
private List<WeCustomer> customers;
}
package com.linkwechat.wecom.domain.vo;
import com.linkwechat.wecom.domain.WeCustomer;
import lombok.Data;
/**
* @author leejoker <1056650571@qq.com>
* @version 1.0
* @date 2021/3/20 13:50
*/
@Data
public class WeTaskFissionTotalProgressVO {
private WeCustomer customer;
private WeTaskFissionProgressVO progress;
}
......@@ -63,8 +63,8 @@ public interface IWeTaskFissionRewardService {
/**
* 根据微信用户id和任务id获取任务裂变奖励详细信息
* @param fissionId 任务id
* @param unionId 微信用户id
* @param eid 客户id
* @return
*/
public WeTaskFissionRewardVo getRewardByFissionId(String fissionId, String unionId);
public WeTaskFissionRewardVo getRewardByFissionId(String fissionId, String eid);
}
......@@ -4,8 +4,10 @@ import com.linkwechat.wecom.domain.WeCustomer;
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.vo.WeTaskFissionProgressVO;
import com.linkwechat.wecom.domain.vo.WeTaskFissionStatisticVO;
import java.text.ParseException;
import java.util.Date;
import java.util.List;
......@@ -30,7 +32,7 @@ public interface IWeTaskFissionService {
* @param weTaskFission 任务宝
* @return 任务宝集合
*/
public List<WeTaskFission> selectWeTaskFissionList(WeTaskFission weTaskFission);
public List<WeTaskFission> selectWeTaskFissionList(WeTaskFission weTaskFission) throws ParseException;
/**
* 新增任务宝
......@@ -90,4 +92,6 @@ public interface IWeTaskFissionService {
List<WeCustomer> getCustomerListById(String unionId, String fissionId);
WeTaskFissionStatisticVO taskFissionStatistic(Long taskFissionId, Date startTime, Date endTime);
WeTaskFissionProgressVO getCustomerTaskProgress(WeTaskFission taskFission, String eid);
}
package com.linkwechat.wecom.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONUtil;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Lists;
import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.core.redis.RedisCache;
import com.linkwechat.common.enums.ChatType;
import com.linkwechat.common.exception.wecom.WeComException;
import com.linkwechat.common.utils.DateUtils;
import com.linkwechat.common.utils.SecurityUtils;
import com.linkwechat.common.utils.SnowFlakeUtil;
import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.wecom.client.WeCustomerMessagePushClient;
import com.linkwechat.wecom.domain.*;
import com.linkwechat.wecom.domain.dto.message.*;
import com.linkwechat.wecom.domain.WeCustomer;
import com.linkwechat.wecom.domain.WeCustomerMessageTimeTask;
import com.linkwechat.wecom.domain.WeGroup;
import com.linkwechat.wecom.domain.dto.message.CustomerMessagePushDto;
import com.linkwechat.wecom.domain.vo.CustomerMessagePushVo;
import com.linkwechat.wecom.mapper.WeCustomerMessageTimeTaskMapper;
import com.linkwechat.wecom.service.*;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -27,8 +24,9 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.ParseException;
import java.util.*;
import java.util.stream.Collectors;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* @description: 群发消息服务类
......@@ -85,9 +83,13 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS
// 0 发给客户
if (customerMessagePushDto.getPushType().equals(WeConstans.SEND_MESSAGE_CUSTOMER)) {
//查询客户信息列表
customers = externalUserIds(customerMessagePushDto.getPushRange(), customerMessagePushDto.getStaffId()
, customerMessagePushDto.getDepartment(), customerMessagePushDto.getTag());
if(CollectionUtils.isEmpty(customers)){
if ("all".equals(customerMessagePushDto.getTag())) {
customers = externalUserIds(WeConstans.SEND_MESSAGE_CUSTOMER_ALL, null, null, null);
} else {
customers = externalUserIds(customerMessagePushDto.getPushRange(), customerMessagePushDto.getStaffId()
, customerMessagePushDto.getDepartment(), customerMessagePushDto.getTag());
}
if (CollectionUtils.isEmpty(customers)) {
throw new WeComException("没有外部联系人");
}
}
......@@ -104,7 +106,7 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS
WeGroup weGroup = new WeGroup();
weGroup.setUserIds(customerMessagePushDto.getStaffId());
groups = weGroupService.selectWeGroupList(weGroup);
if(CollectionUtils.isEmpty(customers)){
if (CollectionUtils.isEmpty(customers)) {
throw new WeComException("没有客户群!");
}
......@@ -116,10 +118,10 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS
long messageId = SnowFlakeUtil.nextId();
//保存映射信息
int size = weCustomerMessgaeResultService.workerMappingCustomer(customerMessagePushDto, messageId,customers,groups);
int size = weCustomerMessgaeResultService.workerMappingCustomer(customerMessagePushDto, messageId, customers, groups);
//保存微信消息
weCustomerMessageService.saveWeCustomerMessage(messageId, messageOriginalId, customerMessagePushDto, size,customerMessagePushDto.content());
weCustomerMessageService.saveWeCustomerMessage(messageId, messageOriginalId, customerMessagePushDto, size, customerMessagePushDto.content());
//保存分类消息信息
weCustomerSeedMessageService.saveSeedMessage(customerMessagePushDto, messageId);
......@@ -127,11 +129,11 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS
//发送群发消息
//调用微信api发送消息
if (null == customerMessagePushDto.getSettingTime() || customerMessagePushDto.getSettingTime().equals("")) {
weCustomerMessageService.sendMessgae(customerMessagePushDto, messageId,customers,groups);
weCustomerMessageService.sendMessgae(customerMessagePushDto, messageId, customers, groups);
} else {
WeCustomerMessageTimeTask timeTask=new WeCustomerMessageTimeTask(messageId, customerMessagePushDto, customers,groups
,DateUtils.getMillionSceondsBydate(customerMessagePushDto.getSettingTime()));
WeCustomerMessageTimeTask timeTask = new WeCustomerMessageTimeTask(messageId, customerMessagePushDto, customers, groups
, DateUtils.getMillionSceondsBydate(customerMessagePushDto.getSettingTime()));
customerMessageTimeTaskMapper.saveWeCustomerMessageTimeTask(timeTask);
......@@ -156,7 +158,12 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS
public List<WeCustomer> externalUserIds(String pushRange, String staffId, String department, String tag) {
if (pushRange.equals(WeConstans.SEND_MESSAGE_CUSTOMER_ALL)) {
//从redis中读取数据
return redisCache.getCacheList(WeConstans.WECUSTOMERS_KEY);
List<WeCustomer> customers = redisCache.getCacheList(WeConstans.WECUSTOMERS_KEY);
if (CollectionUtils.isEmpty(customers)) {
customers = weCustomerService.selectWeCustomerList(null);
redisCache.setCacheList(WeConstans.WECUSTOMERS_KEY, customers);
}
return customers;
} else {
//按条件查询客户
//通过部门id查询所有的员工
......
......@@ -227,18 +227,14 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
});
List<WeFlowerCustomerRel> weFlowerCustomerRels = iWeFlowerCustomerRelService.list(new LambdaQueryWrapper<WeFlowerCustomerRel>()
.eq(WeFlowerCustomerRel::getExternalUserid, weCustomer.getExternalUserid()));
.eq(WeFlowerCustomerRel::getExternalUserid, weCustomer.getExternalUserid())
.eq(WeFlowerCustomerRel::getUserId,userId));
if (CollectionUtil.isNotEmpty(weFlowerCustomerRels)) {
List<Long> weFlowerCustomerRelIds = weFlowerCustomerRels.stream().map(WeFlowerCustomerRel::getId).collect(Collectors.toList());
iWeFlowerCustomerTagRelService.remove(
new LambdaQueryWrapper<WeFlowerCustomerTagRel>().in(WeFlowerCustomerTagRel::getFlowerCustomerRelId,
weFlowerCustomerRelIds)
);
iWeFlowerCustomerRelService.removeByIds(
weFlowerCustomerRelIds
);
iWeFlowerCustomerTagRelService.remove(new LambdaQueryWrapper<WeFlowerCustomerTagRel>()
.in(WeFlowerCustomerTagRel::getFlowerCustomerRelId, weFlowerCustomerRelIds));
iWeFlowerCustomerRelService.removeByIds(weFlowerCustomerRelIds);
}
......
package com.linkwechat.wecom.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.linkwechat.common.exception.wecom.WeComException;
import com.linkwechat.common.utils.DateUtils;
import com.linkwechat.wecom.domain.WeCustomer;
......@@ -105,9 +106,9 @@ public class WeTaskFissionRewardServiceImpl implements IWeTaskFissionRewardServi
}
@Override
public WeTaskFissionRewardVo getRewardByFissionId(String fissionId, String unionId) {
public WeTaskFissionRewardVo getRewardByFissionId(String fissionId, String eid) {
WeTaskFissionRewardVo weTaskFissionRewardVo = new WeTaskFissionRewardVo();
WeCustomer weCustomer = weCustomerService.getOne(new LambdaQueryWrapper<WeCustomer>().eq(WeCustomer::getUnionid, unionId));
WeCustomer weCustomer = weCustomerService.getOne(new LambdaQueryWrapper<WeCustomer>().eq(WeCustomer::getExternalUserid, eid));
String externalUseriId = Optional.ofNullable(weCustomer).map(WeCustomer::getExternalUserid)
.orElseThrow(() -> new WeComException("用户信息不存在"));
......@@ -116,20 +117,21 @@ public class WeTaskFissionRewardServiceImpl implements IWeTaskFissionRewardServi
.orElseThrow(() -> new WeComException("任务信息不存在"));
WeTaskFission weTaskFission = weTaskFissionService.selectWeTaskFissionById(Long.valueOf(fissionId));
Optional.ofNullable(weTaskFission).ifPresent(fission ->{
Optional.ofNullable(weTaskFission).ifPresent(fission -> {
weTaskFissionRewardVo.setRewardRule(fission.getRewardRule());
weTaskFissionRewardVo.setRewardImageUrl(fission.getRewardImageUrl());
weTaskFissionRewardVo.setRewardUrl(fission.getRewardUrl());
});
if(completeTime != null){
if (completeTime != null) {
WeTaskFissionReward fissionReward = weTaskFissionRewardMapper.selectOne(new LambdaQueryWrapper<WeTaskFissionReward>()
.eq(WeTaskFissionReward::getTaskFissionId, fissionId)
.eq(WeTaskFissionReward::getRewardUserId, externalUseriId));
weTaskFissionRewardVo.setWeTaskFissionReward(fissionReward);
//发放兑奖码之后,置为已使用
Optional.ofNullable(fissionReward).ifPresent(reward -> weTaskFissionRewardMapper.update(reward, new LambdaUpdateWrapper<WeTaskFissionReward>()
.set(WeTaskFissionReward::getRewardCodeStatus, 1).eq(WeTaskFissionReward::getId, reward.getId())));
}
return weTaskFissionRewardVo;
}
}
......@@ -23,6 +23,7 @@ import com.linkwechat.wecom.domain.dto.WeTaskFissionPosterDTO;
import com.linkwechat.wecom.domain.dto.message.CustomerMessagePushDto;
import com.linkwechat.wecom.domain.dto.message.LinkMessageDto;
import com.linkwechat.wecom.domain.vo.WeTaskFissionDailyDataVO;
import com.linkwechat.wecom.domain.vo.WeTaskFissionProgressVO;
import com.linkwechat.wecom.domain.vo.WeTaskFissionStatisticVO;
import com.linkwechat.wecom.mapper.WeTaskFissionMapper;
import com.linkwechat.wecom.service.*;
......@@ -38,6 +39,7 @@ import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
......@@ -100,7 +102,13 @@ public class WeTaskFissionServiceImpl implements IWeTaskFissionService {
* @return 任务宝
*/
@Override
public List<WeTaskFission> selectWeTaskFissionList(WeTaskFission weTaskFission) {
public List<WeTaskFission> selectWeTaskFissionList(WeTaskFission weTaskFission) throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat sdf_day = new SimpleDateFormat("yyyy-MM-dd");
if (weTaskFission.getStartTime() != null && weTaskFission.getOverTime() != null) {
weTaskFission.setStartTime(sdf.parse(sdf_day.format(weTaskFission.getStartTime()) + " 00:00:00"));
weTaskFission.setOverTime(sdf.parse(sdf_day.format(weTaskFission.getOverTime()) + " 23:59:59"));
}
return weTaskFissionMapper.selectWeTaskFissionList(weTaskFission);
}
......@@ -237,7 +245,7 @@ public class WeTaskFissionServiceImpl implements IWeTaskFissionService {
@Transactional
public String fissionPosterGenerate(WeTaskFissionPosterDTO weTaskFissionPosterDTO) {
WeCustomer weCustomer = weCustomerService.getOne(new LambdaQueryWrapper<WeCustomer>()
.eq(WeCustomer::getUnionid, weTaskFissionPosterDTO.getUnionId()));
.eq(WeCustomer::getExternalUserid, weTaskFissionPosterDTO.getEid()));
if (weCustomer != null) {
//任务表添加当前客户任务
WeTaskFissionRecord record = getTaskFissionRecordId(weTaskFissionPosterDTO.getTaskFissionId(), weCustomer.getExternalUserid(), weCustomer.getName());
......@@ -282,31 +290,28 @@ public class WeTaskFissionServiceImpl implements IWeTaskFissionService {
}
@Override
public List<WeCustomer> getCustomerListById(String unionId, String fissionId) {
WeTaskFissionRecord weTaskFissionRecord = null;
if (StringUtils.isEmpty(unionId)) {
weTaskFissionRecord = weTaskFissionRecordService
.getOne(new LambdaQueryWrapper<WeTaskFissionRecord>().eq(WeTaskFissionRecord::getTaskFissionId, fissionId));
public List<WeCustomer> getCustomerListById(String eid, String fissionId) {
WeTaskFissionRecord weTaskFissionRecord;
if (StringUtils.isEmpty(eid)) {
List<WeTaskFissionRecord> weTaskFissionRecords = weTaskFissionRecordService
.list(new LambdaQueryWrapper<WeTaskFissionRecord>().eq(WeTaskFissionRecord::getTaskFissionId, fissionId));
return Optional.ofNullable(weTaskFissionRecords).orElseGet(ArrayList::new).stream()
.map(record -> weCustomerService.selectWeCustomerById(record.getCustomerId()))
.filter(Objects::nonNull).collect(Collectors.toList());
} else {
WeCustomer weCustomer = weCustomerService.getOne(new LambdaQueryWrapper<WeCustomer>().eq(WeCustomer::getUnionid, unionId));
WeCustomer weCustomer = weCustomerService.getOne(new LambdaQueryWrapper<WeCustomer>().eq(WeCustomer::getExternalUserid, eid));
String externalUseriId = Optional.ofNullable(weCustomer).map(WeCustomer::getExternalUserid)
.orElseThrow(() -> new WeComException("用户信息不存在"));
weTaskFissionRecord = weTaskFissionRecordService
.selectWeTaskFissionRecordByIdAndCustomerId(Long.valueOf(fissionId), externalUseriId);
Optional.ofNullable(weTaskFissionRecord).map(WeTaskFissionRecord::getId)
.orElseThrow(() -> new WeComException("任务记录信息不存在"));
List<WeFlowerCustomerRel> list = weFlowerCustomerRelService.list(new LambdaQueryWrapper<WeFlowerCustomerRel>()
.eq(WeFlowerCustomerRel::getState, WeConstans.FISSION_PREFIX + weTaskFissionRecord.getId()));
List<String> eidList = Optional.ofNullable(list).orElseGet(ArrayList::new).stream()
.map(WeFlowerCustomerRel::getExternalUserid).collect(Collectors.toList());
return weCustomerService.listByIds(eidList);
}
Long recordId = Optional.ofNullable(weTaskFissionRecord).map(WeTaskFissionRecord::getId)
.orElseThrow(() -> new WeComException("任务记录信息不存在"));
List<WeFlowerCustomerRel> list = weFlowerCustomerRelService.list(new LambdaQueryWrapper<WeFlowerCustomerRel>()
.eq(WeFlowerCustomerRel::getState, WeConstans.FISSION_PREFIX + weTaskFissionRecord.getId()));
List<String> eidList = Optional.ofNullable(list).orElseGet(ArrayList::new).stream()
.map(WeFlowerCustomerRel::getExternalUserid).collect(Collectors.toList());
return weCustomerService.listByIds(eidList);
}
@Override
......@@ -343,6 +348,19 @@ public class WeTaskFissionServiceImpl implements IWeTaskFissionService {
return vo;
}
@Override
public WeTaskFissionProgressVO getCustomerTaskProgress(WeTaskFission taskFission, String eid) {
long complete = 0L;
long total = taskFission.getFissNum();
List<WeCustomer> list = getCustomerListById(eid, String.valueOf(taskFission.getId()));
if (CollectionUtils.isNotEmpty(list)) {
complete = list.size();
} else {
list = new ArrayList<>();
}
return WeTaskFissionProgressVO.builder().total(total).completed(complete).customers(list).build();
}
/*************************************** private functions **************************************/
private String getPosterQRCode(String fissionTargetId, WeTaskFissionRecord record, WeCustomer weCustomer) {
......
......@@ -41,8 +41,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="taskName != null and taskName != ''"> and task_name like concat('%', #{taskName}, '%')</if>
<if test="fissInfo != null and fissInfo != ''"> and fiss_info = #{fissInfo}</if>
<if test="fissNum != null "> and fiss_num = #{fissNum}</if>
<if test="startTime != null "> and start_time = #{startTime}</if>
<if test="overTime != null "> and over_time = #{overTime}</if>
<if test="startTime != null "> and start_time >= #{startTime}</if>
<if test="overTime != null "> <![CDATA[and over_time <= #{overTime}]]></if>
<if test="customerTagId != null and customerTagId != ''"> and customer_tag_id = #{customerTagId}</if>
<if test="customerTag != null and customerTag != ''"> and customer_tag = #{customerTag}</if>
<if test="postersId != null "> and posters_id = #{postersId}</if>
......@@ -56,6 +56,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="fissStatus != null "> and fiss_status = #{fissStatus}</if>
<if test="welcomeMsg != null and welcomeMsg != ''"> and welcome_msg = #{welcomeMsg}</if>
</where>
order by create_time desc
</select>
<select id="selectWeTaskFissionById" parameterType="Long" resultMap="WeTaskFissionResult">
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!