Commit 92c09fa9 by 1539136324@qq.com

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

# Conflicts:
#	linkwe-framework/src/main/java/com/linkwechat/framework/config/SecurityConfig.java
2 parents c779b893 d363e8fd
Showing 35 changed files with 215 additions and 225 deletions
......@@ -12,7 +12,7 @@ import com.linkwechat.framework.web.service.SysPermissionService;
import com.linkwechat.framework.web.service.TokenService;
import com.linkwechat.system.service.ISysMenuService;
import com.linkwechat.wecom.client.WeAccessTokenClient;
import com.linkwechat.wecom.domain.WeCorpAccount;
import com.linkwechat.common.core.domain.entity.WeCorpAccount;
import com.linkwechat.wecom.domain.dto.WeLoginUserInfoDto;
import com.linkwechat.wecom.service.IWeCorpAccountService;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -149,11 +149,24 @@ public class SysLoginController
String token = loginService.noPwdLogin(loginInfo.getUser_info().getUserid());
ajax.put(Constants.TOKEN, token);
}
return ajax;
}
/**
* 租户登录
* @param corpId
* @param corpSecret
* @return
*/
@GetMapping("/tenantLogin")
public AjaxResult tenantLogin(String corpId,String corpSecret){
AjaxResult ajax = AjaxResult.success();
return ajax;
}
}
package com.linkwechat.web.controller.wecom;
import com.linkwechat.common.annotation.Log;
import com.linkwechat.common.constant.HttpStatus;
import com.linkwechat.common.core.controller.BaseController;
import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.core.page.TableDataInfo;
import com.linkwechat.common.enums.BusinessType;
import com.linkwechat.wecom.domain.WeCorpAccount;
import com.linkwechat.common.core.domain.entity.WeCorpAccount;
import com.linkwechat.wecom.service.IWeCorpAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
......
package com.linkwechat.web.controller.wecom;
import cn.hutool.core.collection.CollectionUtil;
import com.linkwechat.common.annotation.Log;
import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.core.controller.BaseController;
......@@ -18,6 +19,7 @@ import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
/**
......@@ -151,4 +153,25 @@ public class WeCustomerController extends BaseController
}
/**
* 查询企业微信客户列表(六感)
*/
// @PreAuthorize("@ss.hasPermi('customerManage:customer:list')")
@GetMapping("/listConcise")
public TableDataInfo listConcise(WeCustomer weCustomer)
{
startPage();
List<WeCustomer> list = weCustomerService.selectWeCustomerList(weCustomer);
if(CollectionUtil.isNotEmpty(list)){
list.stream().forEach(k->{
k.setWeFlowerCustomerRels(new ArrayList<>());
});
}
return getDataTable(list);
}
}
......@@ -153,11 +153,18 @@ public class WeCustomerPortraitController extends BaseController {
@GetMapping(value = "/findTrajectory")
public TableDataInfo findTrajectory(Integer trajectoryType){
startPage();
LambdaQueryWrapper<WeCustomerTrajectory> ne = new LambdaQueryWrapper<WeCustomerTrajectory>()
.ne(WeCustomerTrajectory::getStatus, Constants.DELETE_CODE);
if(trajectoryType != null){
ne.eq(WeCustomerTrajectory::getTrajectoryType, trajectoryType);
}
return getDataTable(
iWeCustomerTrajectoryService.list(new LambdaQueryWrapper<WeCustomerTrajectory>()
.eq(WeCustomerTrajectory::getTrajectoryType,trajectoryType)
.ne(WeCustomerTrajectory::getStatus,Constants.DELETE_CODE))
iWeCustomerTrajectoryService.list(ne)
);
}
......
......@@ -2,7 +2,6 @@ package com.linkwechat.web.controller.wecom;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONObject;
//import com.alibaba.nacos.common.utils.CollectionUtils;
import com.google.common.collect.Lists;
......@@ -152,12 +151,6 @@ public class WeTaskFissionController extends BaseController {
CopyOptions options = CopyOptions.create();
options.setIgnoreNullValue(true);
BeanUtil.copyProperties(weTaskFission, fissionTask, options);
if (CollectionUtil.isNotEmpty(weTaskFission.getTaskFissionStaffs())) {
fissionTask.setTaskFissionStaffs(weTaskFission.getTaskFissionStaffs());
}
if (CollectionUtil.isNotEmpty(weTaskFission.getTaskFissionWeGroups())) {
fissionTask.setTaskFissionWeGroups(weTaskFission.getTaskFissionWeGroups());
}
Long id = weTaskFissionService.updateWeTaskFission(fissionTask);
JSONObject json = new JSONObject();
json.put("id", id);
......@@ -229,7 +222,7 @@ public class WeTaskFissionController extends BaseController {
public AjaxResult<JSONObject> upload(@RequestParam(value = "file") MultipartFile file) throws IOException {
String url = FileUploadUtils.upload2Cos(file, cosConfig);
JSONObject json = new JSONObject();
json.put("rewardImageUrl", cosConfig.getImgUrlPrefix()+url);
json.put("rewardImageUrl", url);
return AjaxResult.success(json);
}
......
......@@ -106,9 +106,9 @@ public class WeTaskFissionRewardController extends BaseController {
*/
@ApiOperation(value = "根据微信用户id和任务id获取任务裂变奖励详细信息",httpMethod = "GET")
// @PreAuthorize("@ss.hasPermi('wecom:getRewardByFissionId:query')")
@GetMapping(value = "/getRewardByFissionId/{fissionId}/{unionId}")
@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));
}
}
......@@ -151,10 +151,16 @@ public class Constants
public static final String USER_TYPE_WECOME="11";
/** 企业管理 */
public static final String USER_TYOE_CORP_ADMIN="22";
/** 企业微信用户系统中默认用户 */
public static final String DEFAULT_WECOME_ROLE_KEY="WeCome";
/** 企业微信用户系统中默认用户 */
public static final String DEFAULT_WECOME_CORP_ADMIN="CROP_ADMIN_ROLE";
/**完成待办*/
public static final String HANDLE_SUCCESS="1";
......
......@@ -105,6 +105,9 @@ public class SysUser extends BaseEntity
/** 是否具有有效得cropId */
private boolean validCropId=false;
private WeCorpAccount weCorpAccount;
public SysUser()
{
......
package com.linkwechat.wecom.domain;
package com.linkwechat.common.core.domain.entity;
import com.linkwechat.common.core.domain.BaseEntity;
import com.linkwechat.common.utils.SnowFlakeUtil;
......@@ -76,4 +76,8 @@ public class WeCorpAccount extends BaseEntity
@ApiModelProperty("客户流失通知开关 0:关闭 1:开启")
private String customerChurnNoticeSwitch = new String("0");
@ApiModelProperty("企业管理员账号")
private String cropAccount;
}
......@@ -12,7 +12,8 @@ import com.linkwechat.common.utils.SecurityUtils;
import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.system.mapper.SysRoleMapper;
import com.linkwechat.system.service.ISysUserService;
import com.linkwechat.wecom.domain.WeUser;
import com.linkwechat.common.core.domain.entity.WeCorpAccount;
import com.linkwechat.wecom.service.IWeCorpAccountService;
import com.linkwechat.wecom.service.IWeUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -51,35 +52,57 @@ public class UserDetailsServiceImpl implements UserDetailsService
private SysRoleMapper roleMapper;
@Autowired
private IWeCorpAccountService iWeCorpAccountService;
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException
{
SysUser user = userService.selectUserByUserName(username);
if (StringUtils.isNull(user))
{
//we_user表中去查询,如果该表为空则提示用户不存在,如果不为空,则将用户记录注册到系统用户表中
WeUser weUser
= iWeUserService.getById(username);
if(null == weUser){
log.info("登录用户:{} 不存在.", username);
throw new UsernameNotFoundException("登录用户:" + username + " 不存在");
//企业管理登录
//查询企业管理相关账号
WeCorpAccount weCorpByAccount = iWeCorpAccountService.findWeCorpByAccount(username);
if(null != weCorpByAccount){
//注册到we_user表中
user=SysUser.builder()
.userName(weCorpByAccount.getCropAccount())
.nickName(weCorpByAccount.getCompanyName())
.userType(Constants.USER_TYOE_CORP_ADMIN)
.roleIds(ArrayUtil.toArray(roleMapper.selectRoleList(SysRole.builder()
.roleKey(Constants.DEFAULT_WECOME_CORP_ADMIN)
.build()).stream().map(SysRole::getRoleId).collect(Collectors.toList()), Long.class))
.password(SecurityUtils.encryptPassword(ruoYiConfig.getWeUserDefaultPwd()))
.build();
}
//注册到we_user表中
user=SysUser.builder()
.userName(weUser.getUserId())
.nickName(weUser.getName())
.userType(Constants.USER_TYPE_WECOME)
.email(weUser.getEmail())
.phonenumber(weUser.getMobile())
.sex(weUser.getGender() ==0 ? "1": weUser.getGender() .toString())
.avatar(weUser.getAvatarMediaid())
.roleIds(ArrayUtil.toArray(roleMapper.selectRoleList(SysRole.builder()
.roleKey(Constants.DEFAULT_WECOME_ROLE_KEY)
.build()).stream().map(SysRole::getRoleId).collect(Collectors.toList()), Long.class))
.password(SecurityUtils.encryptPassword(ruoYiConfig.getWeUserDefaultPwd()))
.build();
// else{
//
// //we_user表中去查询,如果该表为空则提示用户不存在,如果不为空,则将用户记录注册到系统用户表中
// WeUser weUser
// = iWeUserService.getById(username);
// if(null == weUser){
// log.info("登录用户:{} 不存在.", username);
// throw new UsernameNotFoundException("登录用户:" + username + " 不存在");
// }
//
// //注册到we_user表中
// user=SysUser.builder()
// .userName(weUser.getUserId())
// .nickName(weUser.getName())
// .userType(Constants.USER_TYPE_WECOME)
// .email(weUser.getEmail())
// .phonenumber(weUser.getMobile())
// .sex(weUser.getGender() ==0 ? "1": weUser.getGender() .toString())
// .avatar(weUser.getAvatarMediaid())
// .roleIds(ArrayUtil.toArray(roleMapper.selectRoleList(SysRole.builder()
// .roleKey(Constants.DEFAULT_WECOME_ROLE_KEY)
// .build()).stream().map(SysRole::getRoleId).collect(Collectors.toList()), Long.class))
// .password(SecurityUtils.encryptPassword(ruoYiConfig.getWeUserDefaultPwd()))
// .build();
// }
userService.insertUser(
user
);
......@@ -95,6 +118,13 @@ public class UserDetailsServiceImpl implements UserDetailsService
throw new BaseException("对不起,您的账号:" + username + " 已停用");
}
//当前登录用户为企业管理,设置corpId和密钥相关
if(user.getUserType().equals(Constants.USER_TYOE_CORP_ADMIN)){
user.setWeCorpAccount(
iWeCorpAccountService.findWeCorpByAccount(username)
);
}
return createLoginUser(user);
}
......
package com.linkwechat.quartz.task;
import com.linkwechat.wecom.service.IWeTaskFissionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @author danmo
* @description 任务状态处理
* @date 2021/4/12 14:39
**/
@Slf4j
@Component("TaskFissionStatusTask")
public class TaskFissionStatusTask {
@Autowired
private IWeTaskFissionService weTaskFissionService;
public void taskFissionExpiredStatusHandle() {
log.info("任务宝过期时间处理--------------------------start");
weTaskFissionService.updateExpiredWeTaskFission();
log.info("任务宝过期时间处理--------------------------end");
}
}
package com.linkwechat.wecom.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.linkwechat.common.utils.SnowFlakeUtil;
import lombok.AllArgsConstructor;
......@@ -30,40 +29,11 @@ public class WeApp {
/**应用id**/
private String agentId;
/**应用名称**/
private String agentName;
/**应用密钥**/
private String agentSecret;
/**应用描述**/
private String description;
/**应用图标**/
private String squareLogoUrl;
/**企业应用是否被停用(1:是;0:否)**/
private Integer close;
/**企业应用可信域名**/
private String redirectDomain;
/**企业应用是否打开地理位置上报 0:不上报;1:进入会话上报;**/
private Integer reportLocationFlag;
/**是否上报用户进入应用事件。0:不接收;1:接收**/
private Integer isreportenter;
/**应用主页url**/
private String homeUrl;
/**应用类型(1:自建应用;)**/
private Integer appType;
......@@ -82,11 +52,6 @@ public class WeApp {
private String status;
/**企业应用头像的mediaid,通过素材管理接口上传图片获得mediaid,上传后会自动裁剪成方形和圆形两个头像**/
@TableField(exist = false)
private String logoMediaid;
......
......@@ -29,8 +29,13 @@ public class WeCustomerTrajectory {
private String content;
//处理日期
private Date createDate;
//处理时间
private Time createTime;
//处理开始时间
private Time startTime;
//处理结束时间
private Time endTime;
//0:正常;1:删除;2:完成
private String status;
}
......@@ -59,16 +59,16 @@ public class WeTaskFission extends BaseEntity {
/**
* 活动开始时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "活动开始时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "活动开始时间", width = 30, dateFormat = "yyyy-MM-dd")
@ApiModelProperty(value = "活动开始时间")
private Date startTime;
/**
* 活动结束时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "活动结束时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "活动结束时间", width = 30, dateFormat = "yyyy-MM-dd")
@ApiModelProperty(value = "活动结束时间")
private Date overTime;
......
......@@ -3,8 +3,6 @@ package com.linkwechat.wecom.domain.dto;
import lombok.Builder;
import lombok.Data;
import java.util.List;
/**
* @author admin
* @date 2020-11-18
......@@ -14,8 +12,6 @@ import java.util.List;
public class WeWelcomeMsg {
private String welcome_code;
private List attachments;
private Text text;
private Image image;
......
......@@ -48,15 +48,10 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy {
private IWeTaskFissionRewardService weTaskFissionRewardService;
@Autowired
private IWeTaskFissionService weTaskFissionService;
private ThreadLocal<WeFlowerCustomerRel> weFlowerCustomerRelThreadLocal = new ThreadLocal<>();
@Override
public void eventHandle(WxCpXmlMessageVO message) {
if (message.getExternalUserId() != null) {
WeFlowerCustomerRel weFlowerCustomerRel = weFlowerCustomerRelService.getOne(new LambdaQueryWrapper<WeFlowerCustomerRel>()
.eq(WeFlowerCustomerRel::getExternalUserid, message.getExternalUserId())
.eq(WeFlowerCustomerRel::getUserId,message.getUserId()));
weFlowerCustomerRelThreadLocal.set(weFlowerCustomerRel);
weCustomerService.getCustomersInfoAndSynchWeCustomer(message.getExternalUserId());
}
if (message.getState() != null && message.getWelcomeCode() != null) {
......@@ -70,7 +65,6 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy {
//裂变任务处理
private void taskFissionRecordHandle(String state, String wecomCode, String userId, String externalUserId) {
log.info("裂变任务处理 >>>>>>>>>>start");
//查询裂变客户任务记录
String fissionRecordId = state.substring(WeConstans.FISSION_PREFIX.length());
WeTaskFissionRecord weTaskFissionRecord = weTaskFissionRecordService.selectWeTaskFissionRecordById(Long.valueOf(fissionRecordId));
......@@ -78,23 +72,20 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy {
//查询裂变任务详情
WeTaskFission weTaskFission = weTaskFissionService
.selectWeTaskFissionById(weTaskFissionRecord.getTaskFissionId());
Long fissNum = weTaskFissionRecord.getFissNum();
if (weFlowerCustomerRelThreadLocal.get() == null){
fissNum++;
weTaskFissionRecord.setFissNum(fissNum);
}
log.info("查询裂变任务详情 >>>>>>>>>>{}",JSONObject.toJSONString(weTaskFissionRecord));
Long fissNum = weTaskFissionRecord.getFissNum() + 1;
weTaskFissionRecord.setFissNum(fissNum);
if (weTaskFission != null){
//发送欢迎语
WeWelcomeMsg.WeWelcomeMsgBuilder weWelcomeMsgBuilder = WeWelcomeMsg.builder().welcome_code(wecomCode);
weWelcomeMsgBuilder.text(WeWelcomeMsg.Text.builder()
.content(weTaskFission.getWelcomeMsg()).build());
String welcomeMsg = weTaskFission.getWelcomeMsg();
WeWelcomeMsg.WeWelcomeMsgBuilder weWelcomeMsgBuilder = JSONObject.parseObject(welcomeMsg, WeWelcomeMsg.WeWelcomeMsgBuilder.class);
weWelcomeMsgBuilder.welcome_code(wecomCode);
weCustomerService.sendWelcomeMsg(weWelcomeMsgBuilder.build());
}
//裂变数量完成任务处理,消费兑换码
if (fissNum >= weTaskFission.getFissNum()){
log.info("裂变数量完成任务处理,消费兑换码 >>>>>>>>>>{}",fissNum);
weTaskFissionRecord.setCompleteTime(new Date());
WeTaskFissionReward reward = new WeTaskFissionReward();
reward.setTaskFissionId(weTaskFissionRecord.getTaskFissionId());
......@@ -105,9 +96,8 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy {
fissionReward.setRewardUserId(weTaskFissionRecord.getCustomerId());
weTaskFissionRewardService.updateWeTaskFissionReward(fissionReward);
}
log.info("裂变任务处理变更 >>>>>>>>>>{}",JSONObject.toJSONString(weTaskFissionRecord));
weTaskFissionRecordService.updateWeTaskFissionRecord(weTaskFissionRecord);
log.info("裂变任务处理 >>>>>>>>>>end");
}
}
......@@ -157,13 +147,8 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy {
WeMediaDto weMediaDto = weMaterialService
.uploadTemporaryMaterial(messageMap.getMaterialUrl(), MediaType.IMAGE.getMediaType(),messageMap.getMaterialName());
Optional.ofNullable(weMediaDto).ifPresent(media -> {
List attachments = new ArrayList();
JSONObject json = new JSONObject();
json.put("msgtype",weMediaDto.getType());
json.put(weMediaDto.getType(),WeWelcomeMsg.Image.builder().media_id(media.getMedia_id())
weWelcomeMsgBuilder.image(WeWelcomeMsg.Image.builder().media_id(media.getMedia_id())
.pic_url(media.getUrl()).build());
attachments.add(json);
weWelcomeMsgBuilder.attachments(attachments);
});
}
weCustomerService.sendWelcomeMsg(weWelcomeMsgBuilder.build());
......
......@@ -2,6 +2,7 @@ package com.linkwechat.wecom.factory.impl.customer;
import com.alibaba.fastjson.JSONObject;
import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.core.domain.entity.WeCorpAccount;
import com.linkwechat.common.enums.MessageType;
import com.linkwechat.wecom.client.WeMessagePushClient;
import com.linkwechat.wecom.domain.*;
......
......@@ -56,20 +56,21 @@ public class WeiXinAuthInterceptor implements Interceptor {
private String findAccessToken(String openId){
//获取用户token
WxTokenDto wxTokenDto = redisCache.getCacheObject(WeConstans.WX_AUTH_ACCESS_TOKEN + ":" + openId);
if (wxTokenDto == null){
String accessToken =redisCache.getCacheObject(WeConstans.WX_AUTH_ACCESS_TOKEN+":"+ openId);
if (StringUtils.isEmpty(accessToken)){
//当用户token失效,则获取refreshToken
String refreshToken = redisCache.getCacheObject(WeConstans.WX_AUTH_REFRESH_ACCESS_TOKEN + ":" + openId);
if(StringUtils.isEmpty(refreshToken)){
throw new WeComException(1001,"token失效,请重新授权");
}else {
wxTokenDto = wxAuthClient.refreshToken(appId, grantType, refreshToken);
WxTokenDto wxTokenDto = wxAuthClient.refreshToken(appId, secret, grantType, refreshToken);
if(wxTokenDto != null && StringUtils.isNotEmpty(wxTokenDto.getAccessToken())){
redisCache.setCacheObject(WeConstans.WX_AUTH_ACCESS_TOKEN+":"+ openId, wxTokenDto, wxTokenDto.getExpiresIn(), TimeUnit.SECONDS);
redisCache.setCacheObject(WeConstans.WX_AUTH_ACCESS_TOKEN+":"+ openId, wxTokenDto.getAccessToken(), wxTokenDto.getExpiresIn(), TimeUnit.SECONDS);
accessToken = wxTokenDto.getAccessToken();
}
}
}
return wxTokenDto.getAccessToken();
return accessToken;
}
......
package com.linkwechat.wecom.mapper;
import java.util.List;
import com.linkwechat.wecom.domain.WeCorpAccount;
import com.linkwechat.common.core.domain.entity.WeCorpAccount;
import org.apache.ibatis.annotations.Param;
/**
......@@ -59,4 +59,12 @@ public interface WeCorpAccountMapper
* @return
*/
public int startVailWeCorpAccount(@Param("corpId") String corpId);
/**
* 根据企业账号获取企业相关配置
* @param corpAccount
* @return
*/
WeCorpAccount findWeCorpByAccount(@Param("corpAccount") String corpAccount);
}
......@@ -58,10 +58,4 @@ public interface WeTaskFissionMapper {
* @return 结果
*/
public int deleteWeTaskFissionByIds(Long[] ids);
/**
* 更新过期任务
* @return
*/
public void updateExpiredWeTaskFission();
}
package com.linkwechat.wecom.service;
import com.linkwechat.common.core.domain.entity.WeCorpAccount;
import java.util.List;
import com.linkwechat.wecom.domain.WeCorpAccount;
import org.apache.ibatis.annotations.Param;
/**
* 企业id相关配置Service接口
......@@ -71,4 +71,7 @@ public interface IWeCorpAccountService
* 客户流失通知开关查询
*/
public String getCustomerChurnNoticeSwitch();
WeCorpAccount findWeCorpByAccount(String corpAccount);
}
......@@ -94,10 +94,4 @@ public interface IWeTaskFissionService {
WeTaskFissionStatisticVO taskFissionStatistic(Long taskFissionId, Date startTime, Date endTime);
WeTaskFissionProgressVO getCustomerTaskProgress(WeTaskFission taskFission, String eid);
/**
* 更新过期任务
* @return
*/
public void updateExpiredWeTaskFission();
}
......@@ -8,7 +8,7 @@ import com.linkwechat.common.exception.wecom.WeComException;
import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.wecom.client.WeAccessTokenClient;
import com.linkwechat.wecom.domain.WeApp;
import com.linkwechat.wecom.domain.WeCorpAccount;
import com.linkwechat.common.core.domain.entity.WeCorpAccount;
import com.linkwechat.wecom.domain.dto.WeAccessTokenDtoDto;
import com.linkwechat.wecom.service.IWeAccessTokenService;
import com.linkwechat.wecom.service.IWeAppService;
......
......@@ -5,14 +5,12 @@ import java.util.Optional;
import com.linkwechat.common.constant.Constants;
import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.utils.DateUtils;
import com.linkwechat.wecom.service.IWeAccessTokenService;
import com.linkwechat.wecom.service.IWeCorpAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.linkwechat.wecom.mapper.WeCorpAccountMapper;
import com.linkwechat.wecom.domain.WeCorpAccount;
import org.springframework.transaction.annotation.Transactional;
import com.linkwechat.common.core.domain.entity.WeCorpAccount;
/**
* 企业id相关配置Service业务层处理
......@@ -136,5 +134,10 @@ public class WeCorpAccountServiceImpl implements IWeCorpAccountService {
return noticeSwitch;
}
@Override
public WeCorpAccount findWeCorpByAccount(String corpAccount) {
return weCorpAccountMapper.findWeCorpByAccount(corpAccount);
}
}
......@@ -74,15 +74,15 @@ public class WeCustomerMessagePushServiceImpl implements IWeCustomerMessagePushS
@Transactional(rollbackFor = Exception.class)
public void addWeCustomerMessagePush(CustomerMessagePushDto customerMessagePushDto) throws JsonProcessingException, ParseException {
if ((null != customerMessagePushDto.getSettingTime() && !"".equals(customerMessagePushDto.getSettingTime()))
&& DateUtils.diffTime(new Date(), DateUtil.parse(customerMessagePushDto.getSettingTime(), "yyyy-MM-dd HH:mm")) > 0) {
throw new WeComException("发送时间不能小于当前时间");
}
// if ((null != customerMessagePushDto.getSettingTime() && !"".equals(customerMessagePushDto.getSettingTime()))
// && DateUtils.diffTime(new Date(), DateUtil.parse(customerMessagePushDto.getSettingTime(), "yyyy-MM-dd HH:mm")) > 0) {
// throw new WeComException("发送时间不能小于当前时间");
// }
/*if(StrUtil.isBlank(customerMessagePushDto.getSettingTime())){
if(StrUtil.isBlank(customerMessagePushDto.getSettingTime())){
throw new WeComException("发送时间不能为空");
}*/
}
List<WeCustomer> customers = Lists.newArrayList();
......
......@@ -482,8 +482,6 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
//客户入库
WeCustomer weCustomer = new WeCustomer();
BeanUtils.copyPropertiesASM(externalUserDetail.getExternal_contact(), weCustomer);
weCustomer.setCreateTime(new Date());
weCustomer.setUpdateTime(new Date());
this.saveOrUpdate(weCustomer);
//客户与通讯录客户关系
......
......@@ -2,6 +2,7 @@ package com.linkwechat.wecom.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.common.core.domain.entity.WeCorpAccount;
import com.linkwechat.common.enums.CommunityTaskType;
import com.linkwechat.common.exception.wecom.WeComException;
import com.linkwechat.common.utils.StringUtils;
......
......@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.common.core.domain.entity.WeCorpAccount;
import com.linkwechat.common.enums.ChatType;
import com.linkwechat.common.enums.MediaType;
import com.linkwechat.common.enums.TaskSendType;
......
......@@ -13,7 +13,7 @@ import com.linkwechat.common.utils.DateUtils;
import com.linkwechat.common.utils.SecurityUtils;
import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.wecom.client.WeMessagePushClient;
import com.linkwechat.wecom.domain.WeCorpAccount;
import com.linkwechat.common.core.domain.entity.WeCorpAccount;
import com.linkwechat.wecom.domain.WeSensitive;
import com.linkwechat.wecom.domain.WeSensitiveAuditScope;
import com.linkwechat.wecom.domain.WeUser;
......
......@@ -106,29 +106,27 @@ 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));
String customerUnionId = Optional.ofNullable(weCustomer).map(WeCustomer::getUnionid)
WeCustomer weCustomer = weCustomerService.getOne(new LambdaQueryWrapper<WeCustomer>().eq(WeCustomer::getExternalUserid, eid));
String externalUseriId = Optional.ofNullable(weCustomer).map(WeCustomer::getExternalUserid)
.orElseThrow(() -> new WeComException("用户信息不存在"));
WeTaskFissionRecord record = weTaskFissionRecordService.selectWeTaskFissionRecordByIdAndCustomerId(Long.valueOf(fissionId), customerUnionId);
if (record == null){
throw new WeComException("任务信息不存在");
}
Date completeTime = record.getCompleteTime();
WeTaskFissionRecord record = weTaskFissionRecordService.selectWeTaskFissionRecordByIdAndCustomerId(Long.valueOf(fissionId), externalUseriId);
Date completeTime = Optional.ofNullable(record).map(WeTaskFissionRecord::getCompleteTime)
.orElseThrow(() -> new WeComException("任务信息不存在"));
WeTaskFission weTaskFission = weTaskFissionService.selectWeTaskFissionById(Long.valueOf(fissionId));
Optional.ofNullable(weTaskFission).ifPresent(fission -> {
weTaskFissionRewardVo.setRewardRule(fission.getRewardRule());
weTaskFissionRewardVo.setRewardImageUrl(fission.getRewardImageUrl());
weTaskFissionRewardVo.setRewardUrl(fission.getRewardUrl());
});
if (completeTime != null) {
Optional.ofNullable(weTaskFission).ifPresent(fission -> {
weTaskFissionRewardVo.setRewardUrl(fission.getRewardUrl());
weTaskFissionRewardVo.setRewardImageUrl(fission.getRewardImageUrl());
});
WeTaskFissionReward fissionReward = weTaskFissionRewardMapper.selectOne(new LambdaQueryWrapper<WeTaskFissionReward>()
.eq(WeTaskFissionReward::getTaskFissionId, fissionId)
.eq(WeTaskFissionReward::getRewardUserId, customerUnionId));
.eq(WeTaskFissionReward::getRewardUserId, externalUseriId));
weTaskFissionRewardVo.setWeTaskFissionReward(fissionReward);
//发放兑奖码之后,置为已使用
Optional.ofNullable(fissionReward).ifPresent(reward -> weTaskFissionRewardMapper.update(reward, new LambdaUpdateWrapper<WeTaskFissionReward>()
......
......@@ -153,7 +153,6 @@ public class WeTaskFissionServiceImpl implements IWeTaskFissionService {
int updateResult = weTaskFissionMapper.updateWeTaskFission(weTaskFission);
if (updateResult > 0) {
if (CollectionUtils.isNotEmpty(weTaskFission.getTaskFissionStaffs())) {
log.info("发起成员信息:【{}】",JSONObject.toJSONString(weTaskFission.getTaskFissionStaffs()));
List<WeTaskFissionStaff> staffList = weTaskFissionStaffService.selectWeTaskFissionStaffByTaskId(weTaskFission.getId());
if (CollectionUtils.isNotEmpty(staffList)) {
weTaskFissionStaffService.deleteWeTaskFissionStaffByIds(staffList.stream().map(WeTaskFissionStaff::getId).toArray(Long[]::new));
......@@ -200,6 +199,8 @@ public class WeTaskFissionServiceImpl implements IWeTaskFissionService {
//H5生成海报页面路径
StringBuilder pageUrlBuilder = new StringBuilder(pageUrl);
pageUrlBuilder.append("?")
.append("agentId=").append("1000010")
.append("&")
.append("fissionId=").append(id)
.append("&")
.append("fissionTargetId=").append(fissStaffId)
......@@ -213,9 +214,6 @@ public class WeTaskFissionServiceImpl implements IWeTaskFissionService {
linkMessageDto.setUrl(pageUrlBuilder.toString());
CustomerMessagePushDto customerMessagePushDto = new CustomerMessagePushDto();
if (weTaskFission.getStartTime() != null){
customerMessagePushDto.setSettingTime(DateUtils.dateTime(weTaskFission.getStartTime()));
}
customerMessagePushDto.setLinkMessage(linkMessageDto);
customerMessagePushDto.setPushType("0");
customerMessagePushDto.setPushRange("1");
......@@ -303,18 +301,18 @@ public class WeTaskFissionServiceImpl implements IWeTaskFissionService {
.map(record -> weCustomerService.selectWeCustomerById(record.getCustomerId()))
.filter(Objects::nonNull).collect(Collectors.toList());
} else {
WeCustomer weCustomer = weCustomerService.getOne(new LambdaQueryWrapper<WeCustomer>().eq(WeCustomer::getUnionid, unionId));
String uid = Optional.ofNullable(weCustomer).map(WeCustomer::getUnionid)
.orElseThrow(() -> new WeComException("用户信息不存在"));
weTaskFissionRecord = weTaskFissionRecordService
.selectWeTaskFissionRecordByIdAndCustomerId(Long.valueOf(fissionId), unionId);
Optional.ofNullable(weTaskFissionRecord).orElseThrow(() -> new WeComException("任务记录信息不存在"));
.selectWeTaskFissionRecordByIdAndCustomerId(Long.valueOf(fissionId), uid);
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());
if (CollectionUtil.isNotEmpty(eidList)){
return weCustomerService.listByIds(eidList);
}else {
return null;
}
return weCustomerService.listByIds(eidList);
}
}
......@@ -365,15 +363,6 @@ public class WeTaskFissionServiceImpl implements IWeTaskFissionService {
return WeTaskFissionProgressVO.builder().total(total).completed(complete).customers(list).build();
}
/**
* 更新过期任务
* @return
*/
@Override
public void updateExpiredWeTaskFission() {
weTaskFissionMapper.updateExpiredWeTaskFission();
}
/*************************************** private functions **************************************/
private String getPosterQRCode(String fissionTargetId, WeTaskFissionRecord record, WeCustomer weCustomer) {
......@@ -441,8 +430,7 @@ public class WeTaskFissionServiceImpl implements IWeTaskFissionService {
WeTaskFissionRecord record = WeTaskFissionRecord.builder()
.taskFissionId(taskFissionId)
.customerId(customerId)
.customerName(customerName)
.createTime(new Date()).build();
.customerName(customerName).build();
List<WeTaskFissionRecord> searchExists = weTaskFissionRecordService.selectWeTaskFissionRecordList(record);
WeTaskFissionRecord recordInfo;
if (CollectionUtils.isNotEmpty(searchExists)) {
......
......@@ -54,7 +54,7 @@ public class WeTaskFissionStaffServiceImpl implements IWeTaskFissionStaffService
@Override
public int insertWeTaskFissionStaffList(List<WeTaskFissionStaff> weTaskFissionStaffs) {
return weTaskFissionStaffMapper.insertWeTaskFissionStaffList(weTaskFissionStaffs);
return 0;
}
/**
......
......@@ -39,7 +39,7 @@ public interface WxAuthClient {
* @return
*/
@Request(url = "/oauth2/refresh_token", type = "GET")
WxTokenDto refreshToken(@Query("appid") String appId, @Query("grant_type") String grantType,
WxTokenDto refreshToken(String id, @Query("appid") String appId, @Query("grant_type") String grantType,
@Query("refresh_token") String refreshToken);
/**
......
......@@ -22,10 +22,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="providerSecret" column="provider_secret" />
<result property="customerChurnNoticeSwitch" column="customer_churn_notice_switch" />
<result property="wxQrLoginRedirectUri" column="wx_qr_login_redirect_uri"/>
<result property="corpAccount" column="corp_account"/>
</resultMap>
<sql id="selectWeCorpAccountVo">
select id,chat_secret,provider_secret,company_name, corp_id, corp_secret,agent_id, agent_secret, status, del_flag, create_by, create_time, update_by, update_time,contact_secret, customer_churn_notice_switch,wx_qr_login_redirect_uri from we_corp_account
select id,chat_secret,provider_secret,company_name, corp_id, corp_secret,agent_id, agent_secret, status, del_flag, create_by, create_time, update_by, update_time,contact_secret, customer_churn_notice_switch,wx_qr_login_redirect_uri,
corp_account
from we_corp_account
</sql>
<select id="selectWeCorpAccountList" parameterType="WeCorpAccount" resultMap="WeCorpAccountResult">
......@@ -62,6 +65,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="customerChurnNoticeSwitch != null ">customer_churn_notice_switch,</if>
<if test="providerSecret != null ">provider_secret,</if>
<if test="wxQrLoginRedirectUri != null ">wx_qr_login_redirect_uri,</if>
<if test="corpAccount != null ">corp_account,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="companyName != null">#{companyName},</if>
......@@ -80,6 +85,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="customerChurnNoticeSwitch != null ">#{customerChurnNoticeSwitch},</if>
<if test="providerSecret != null ">#{providerSecret},</if>
<if test="wxQrLoginRedirectUri != null ">#{wxQrLoginRedirectUri},</if>
<if test="corpAccount != null ">#{corpAccount},</if>
</trim>
</insert>
......@@ -103,8 +109,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="providerSecret != null ">provider_secret = #{providerSecret},</if>
<if test="wxQrLoginRedirectUri != null ">wx_qr_login_redirect_uri = #{wxQrLoginRedirectUri},</if>
<if test="corpAccount != null ">crop_account = #{corpAccount},</if>
</trim>
where id = #{id}
</update>
......@@ -126,6 +131,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="findWeCorpByAccount" resultMap="WeCorpAccountResult">
<include refid="selectWeCorpAccountVo"/>
WHERE
del_flag = 0
AND corp_account = #{corpAccount}
</select>
......
......@@ -156,19 +156,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</delete>
<update id="updateExpiredWeTaskFission">
update we_task_fission as wtff,
(
select
id
from
we_task_fission wtf
where
wtf.fiss_status = 1
and now() &gt;= wtf.over_time
)as wtfl
set wtff.fiss_status = 2
where
wtff.id = wtfl.id
</update>
</mapper>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!