Commit 36d4e1dc by 李昂

Merge branch 'back_end_dev' of https://gitee.com/LinkWeChat/link-wechat into back_end_dev

2 parents 63fe90fb 4a48bccd
package com.linkwechat.web.controller.wecom;
import com.linkwechat.common.core.controller.BaseController;
import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.wecom.domain.WeApp;
import com.linkwechat.wecom.service.IWeAppService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/wecom/weapp")
public class WeAppController extends BaseController {
@Autowired
IWeAppService iWeAppService;
@GetMapping("/list")
public AjaxResult list() {
return AjaxResult.success(
iWeAppService.list()
);
}
@PutMapping("/updateWeApp")
public AjaxResult updateWeApp(@RequestBody WeApp weApp){
iWeAppService.updateById(weApp);
return AjaxResult.success();
}
}
......@@ -2,6 +2,7 @@ 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;
......@@ -151,6 +152,12 @@ 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);
......@@ -222,7 +229,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", url);
json.put("rewardImageUrl", cosConfig.getImgUrlPrefix()+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}/{eid}")
@GetMapping(value = "/getRewardByFissionId/{fissionId}/{unionId}")
public AjaxResult<WeTaskFissionRewardVo> getRewardByFissionId(@ApiParam("任务id") @PathVariable("fissionId") String fissionId
, @PathVariable("eid") @ApiParam("客户id") String eid) {
return AjaxResult.success(weTaskFissionRewardService.getRewardByFissionId(fissionId,eid));
, @PathVariable("unionId") @ApiParam("客户id") String unionId) {
return AjaxResult.success(weTaskFissionRewardService.getRewardByFissionId(fissionId,unionId));
}
}
......@@ -124,7 +124,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
// .antMatchers("/common/uploadFile2Cos").anonymous()
// .antMatchers("/wecom/material/temporaryMaterialMediaId").anonymous()
.antMatchers("/wecom/portrait/**").anonymous()
.antMatchers("/wecom/fission/poster", "/wecom/fission/*/progress/*").anonymous()
.antMatchers("/wecom/fission/poster", "/wecom/fission/*/progress/*", "/wecom/reward/getRewardByFissionId/**").anonymous()
// 获取实际群活码和社群运营H5页面不需要登录
.antMatchers("/wecom/groupCode/getActualCode/**").anonymous()
.antMatchers("/wecom/community/h5/**").anonymous()
......
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;
......@@ -29,11 +30,40 @@ 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;
......@@ -52,6 +82,11 @@ public class WeApp {
private String status;
/**企业应用头像的mediaid,通过素材管理接口上传图片获得mediaid,上传后会自动裁剪成方形和圆形两个头像**/
@TableField(exist = false)
private String logoMediaid;
......
......@@ -59,16 +59,16 @@ public class WeTaskFission extends BaseEntity {
/**
* 活动开始时间
*/
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "活动开始时间", width = 30, dateFormat = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "活动开始时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "活动开始时间")
private Date startTime;
/**
* 活动结束时间
*/
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "活动结束时间", width = 30, dateFormat = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "活动结束时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "活动结束时间")
private Date overTime;
......
......@@ -48,10 +48,15 @@ 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) {
......@@ -65,6 +70,7 @@ 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));
......@@ -72,20 +78,23 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy {
//查询裂变任务详情
WeTaskFission weTaskFission = weTaskFissionService
.selectWeTaskFissionById(weTaskFissionRecord.getTaskFissionId());
Long fissNum = weTaskFissionRecord.getFissNum() + 1;
weTaskFissionRecord.setFissNum(fissNum);
Long fissNum = weTaskFissionRecord.getFissNum();
if (weFlowerCustomerRelThreadLocal.get() == null){
fissNum++;
weTaskFissionRecord.setFissNum(fissNum);
}
log.info("查询裂变任务详情 >>>>>>>>>>{}",JSONObject.toJSONString(weTaskFissionRecord));
if (weTaskFission != null){
//发送欢迎语
String welcomeMsg = weTaskFission.getWelcomeMsg();
WeWelcomeMsg.WeWelcomeMsgBuilder weWelcomeMsgBuilder = JSONObject.parseObject(welcomeMsg, WeWelcomeMsg.WeWelcomeMsgBuilder.class);
weWelcomeMsgBuilder.welcome_code(wecomCode);
WeWelcomeMsg.WeWelcomeMsgBuilder weWelcomeMsgBuilder = WeWelcomeMsg.builder().welcome_code(wecomCode);
weWelcomeMsgBuilder.text(WeWelcomeMsg.Text.builder()
.content(weTaskFission.getWelcomeMsg()).build());
weCustomerService.sendWelcomeMsg(weWelcomeMsgBuilder.build());
}
//裂变数量完成任务处理,消费兑换码
if (fissNum >= weTaskFission.getFissNum()){
log.info("裂变数量完成任务处理,消费兑换码 >>>>>>>>>>{}",fissNum);
weTaskFissionRecord.setCompleteTime(new Date());
WeTaskFissionReward reward = new WeTaskFissionReward();
reward.setTaskFissionId(weTaskFissionRecord.getTaskFissionId());
......@@ -96,8 +105,9 @@ public class WeCallBackAddExternalContactImpl extends WeEventStrategy {
fissionReward.setRewardUserId(weTaskFissionRecord.getCustomerId());
weTaskFissionRewardService.updateWeTaskFissionReward(fissionReward);
}
log.info("裂变任务处理变更 >>>>>>>>>>{}",JSONObject.toJSONString(weTaskFissionRecord));
weTaskFissionRecordService.updateWeTaskFissionRecord(weTaskFissionRecord);
log.info("裂变任务处理 >>>>>>>>>>end");
}
}
......
......@@ -56,21 +56,20 @@ public class WeiXinAuthInterceptor implements Interceptor {
private String findAccessToken(String openId){
//获取用户token
String accessToken =redisCache.getCacheObject(WeConstans.WX_AUTH_ACCESS_TOKEN+":"+ openId);
if (StringUtils.isEmpty(accessToken)){
WxTokenDto wxTokenDto = redisCache.getCacheObject(WeConstans.WX_AUTH_ACCESS_TOKEN + ":" + openId);
if (wxTokenDto == null){
//当用户token失效,则获取refreshToken
String refreshToken = redisCache.getCacheObject(WeConstans.WX_AUTH_REFRESH_ACCESS_TOKEN + ":" + openId);
if(StringUtils.isEmpty(refreshToken)){
throw new WeComException(1001,"token失效,请重新授权");
}else {
WxTokenDto wxTokenDto = wxAuthClient.refreshToken(appId, secret, grantType, refreshToken);
wxTokenDto = wxAuthClient.refreshToken(appId, grantType, refreshToken);
if(wxTokenDto != null && StringUtils.isNotEmpty(wxTokenDto.getAccessToken())){
redisCache.setCacheObject(WeConstans.WX_AUTH_ACCESS_TOKEN+":"+ openId, wxTokenDto.getAccessToken(), wxTokenDto.getExpiresIn(), TimeUnit.SECONDS);
accessToken = wxTokenDto.getAccessToken();
redisCache.setCacheObject(WeConstans.WX_AUTH_ACCESS_TOKEN+":"+ openId, wxTokenDto, wxTokenDto.getExpiresIn(), TimeUnit.SECONDS);
}
}
}
return accessToken;
return wxTokenDto.getAccessToken();
}
......
......@@ -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,6 +482,8 @@ 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);
//客户与通讯录客户关系
......
......@@ -106,27 +106,29 @@ public class WeTaskFissionRewardServiceImpl implements IWeTaskFissionRewardServi
}
@Override
public WeTaskFissionRewardVo getRewardByFissionId(String fissionId, String eid) {
public WeTaskFissionRewardVo getRewardByFissionId(String fissionId, String unionId) {
WeTaskFissionRewardVo weTaskFissionRewardVo = new WeTaskFissionRewardVo();
WeCustomer weCustomer = weCustomerService.getOne(new LambdaQueryWrapper<WeCustomer>().eq(WeCustomer::getExternalUserid, eid));
String externalUseriId = Optional.ofNullable(weCustomer).map(WeCustomer::getExternalUserid)
WeCustomer weCustomer = weCustomerService.getOne(new LambdaQueryWrapper<WeCustomer>().eq(WeCustomer::getUnionid, unionId));
String customerUnionId = Optional.ofNullable(weCustomer).map(WeCustomer::getUnionid)
.orElseThrow(() -> new WeComException("用户信息不存在"));
WeTaskFissionRecord record = weTaskFissionRecordService.selectWeTaskFissionRecordByIdAndCustomerId(Long.valueOf(fissionId), externalUseriId);
Date completeTime = Optional.ofNullable(record).map(WeTaskFissionRecord::getCompleteTime)
.orElseThrow(() -> new WeComException("任务信息不存在"));
WeTaskFissionRecord record = weTaskFissionRecordService.selectWeTaskFissionRecordByIdAndCustomerId(Long.valueOf(fissionId), customerUnionId);
if (record == null){
throw new WeComException("任务信息不存在");
}
Date completeTime = record.getCompleteTime();
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, externalUseriId));
.eq(WeTaskFissionReward::getRewardUserId, customerUnionId));
weTaskFissionRewardVo.setWeTaskFissionReward(fissionReward);
//发放兑奖码之后,置为已使用
Optional.ofNullable(fissionReward).ifPresent(reward -> weTaskFissionRewardMapper.update(reward, new LambdaUpdateWrapper<WeTaskFissionReward>()
......
......@@ -153,6 +153,7 @@ 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));
......@@ -301,18 +302,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), uid);
Optional.ofNullable(weTaskFissionRecord).map(WeTaskFissionRecord::getId)
.orElseThrow(() -> new WeComException("任务记录信息不存在"));
.selectWeTaskFissionRecordByIdAndCustomerId(Long.valueOf(fissionId), unionId);
Optional.ofNullable(weTaskFissionRecord).orElseThrow(() -> new WeComException("任务记录信息不存在"));
List<WeFlowerCustomerRel> list = weFlowerCustomerRelService.list(new LambdaQueryWrapper<WeFlowerCustomerRel>()
.eq(WeFlowerCustomerRel::getState, WeConstans.FISSION_PREFIX + weTaskFissionRecord.getId()));
List<String> eidList = Optional.ofNullable(list).orElseGet(ArrayList::new).stream()
.map(WeFlowerCustomerRel::getExternalUserid).collect(Collectors.toList());
return weCustomerService.listByIds(eidList);
if (CollectionUtil.isNotEmpty(eidList)){
return weCustomerService.listByIds(eidList);
}else {
return null;
}
}
}
......@@ -430,7 +431,8 @@ public class WeTaskFissionServiceImpl implements IWeTaskFissionService {
WeTaskFissionRecord record = WeTaskFissionRecord.builder()
.taskFissionId(taskFissionId)
.customerId(customerId)
.customerName(customerName).build();
.customerName(customerName)
.createTime(new Date()).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 0;
return weTaskFissionStaffMapper.insertWeTaskFissionStaffList(weTaskFissionStaffs);
}
/**
......
......@@ -39,7 +39,7 @@ public interface WxAuthClient {
* @return
*/
@Request(url = "/oauth2/refresh_token", type = "GET")
WxTokenDto refreshToken(String id, @Query("appid") String appId, @Query("grant_type") String grantType,
WxTokenDto refreshToken(@Query("appid") String appId, @Query("grant_type") String grantType,
@Query("refresh_token") String refreshToken);
/**
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!