Skip to content

Commit

Permalink
Merge remote-tracking branch 'jadon/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
HaoNanSheng committed Feb 17, 2023
2 parents d43b4a3 + 4628c5d commit 6888d96
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.linkwechat.common.core.page.TableDataInfo;
import com.linkwechat.common.enums.BusinessType;
import com.linkwechat.common.exception.CustomException;
import com.linkwechat.common.exception.wecom.WeComException;
import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.common.utils.file.FileUtils;
import com.linkwechat.domain.qr.query.WeQrAddQuery;
Expand All @@ -26,10 +27,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;

/**
Expand Down Expand Up @@ -58,6 +56,9 @@ public AjaxResult addQrCode(@RequestBody @Validated WeQrAddQuery weQrAddQuery) {
@Log(title = "活码管理", businessType = BusinessType.UPDATE)
@PutMapping("/update")
public AjaxResult updateQrCode(@RequestBody @Validated WeQrAddQuery weQrAddQuery) {
if(Objects.isNull(weQrAddQuery.getQrId())){
throw new WeComException("活码ID不能为空!");
}
weQrCodeService.updateQrCode(weQrAddQuery);
return AjaxResult.success();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,16 @@ public Queue quQrCodeChange() {
return new Queue(rabbitMQSettingConfig.getWeQrCodeChangeQu());
}

/**
* 活码删除队列
*
* @return
*/
@Bean
public Queue quQrCodeDel() {
return new Queue(rabbitMQSettingConfig.getWeQrCodeDelQu());
}

/**
* 同步商品图册队列
*
Expand Down Expand Up @@ -513,7 +523,7 @@ public Binding bindingExchangeChatMsgCheck() {
}

/**
* 活码队列绑定交换机
* 活码变更队列绑定交换机
*
* @return
*/
Expand All @@ -522,6 +532,16 @@ public Binding bindingExchangeQrCodeChange() {
return BindingBuilder.bind(quQrCodeChange()).to(qrCodeChangeEx()).with(rabbitMQSettingConfig.getWeQrCodeChangeRk()).noargs();
}

/**
* 活码删除队列绑定交换机
*
* @return
*/
@Bean
public Binding bindingExchangeQrCodeDel() {
return BindingBuilder.bind(quQrCodeDel()).to(qrCodeChangeEx()).with(rabbitMQSettingConfig.getWeQrCodeDelRk()).noargs();
}


/**
* 同步商品图册绑定交换机
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ public class RabbitMQSettingConfig {
@Value("${wecom.mq.route.qr-code-change:Rk_QrCodeChange}")
private String weQrCodeChangeRk;

//活码删除路由
@Value("${wecom.mq.route.qr-code-del:Rk_QrCodeDel}")
private String weQrCodeDelRk;

//商品图册同步路由
@Value("${wecom.mq.route.sync.product:Rk_Product}")
private String weProductRk;
Expand Down Expand Up @@ -242,6 +246,10 @@ public class RabbitMQSettingConfig {
@Value("${wecom.mq.queue.qr-code-change:Qu_QrCodeChange}")
private String weQrCodeChangeQu;

//活码删除队列
@Value("${wecom.mq.queue.qr-code-del:Qu_QrCodeDel}")
private String weQrCodeDelQu;

//商品图册同步队列
@Value("${wecom.mq.queue.sync.product:Qu_Product}")
private String weProductQu;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ public class WeCustomersVo {
private Integer addMethod;

//添加时间
@JsonFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date firstAddTime;


@JsonFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date birthday;

//0-未知 1-男性 2-女性
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
Expand Down Expand Up @@ -41,6 +42,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -69,7 +71,7 @@ public class WeQrCodeServiceImpl extends ServiceImpl<WeQrCodeMapper, WeQrCode> i
@Autowired
private IWeCorpAccountService weCorpAccountService;

@Autowired
@Resource
private QwCustomerClient qwCustomerClient;

@Autowired
Expand Down Expand Up @@ -109,24 +111,58 @@ public void addQrCode(WeQrAddQuery weQrAddQuery) {
@Transactional(rollbackFor = {WeComException.class,Exception.class})
@Override
public void updateQrCode(WeQrAddQuery weQrAddQuery) {
WeQrCode qrCode = getById(weQrAddQuery.getQrId());
if(Objects.isNull(qrCode)){
throw new WeComException("无效活码ID");
}
//校验排期是否存在冲突
checkScope(weQrAddQuery.getQrUserInfos());
WeAddWayQuery weContactWay = weQrAddQuery.getWeContactWay();
WeResultVo weResultVo = qwCustomerClient.updateContactWay(weContactWay).getData();
if (weResultVo != null && ObjectUtil.equal(0, weResultVo.getErrCode())) {
WeQrCode weQrCode = weQrAddQuery.getWeQrCodeEntity(null, null);
if (updateById(weQrCode)) {
//修改标签数据
tagRelService.updateBatchByQrId(weQrCode.getId(), weQrAddQuery.getQrTags());
//修改活码范围数据
scopeService.updateBatchByQrId(weQrCode.getId(), weQrAddQuery.getQrUserInfos());
//修改活码素材
attachmentsService.updateBatchByQrId(weQrCode.getId(), weQrAddQuery.getAttachments());

WeQrCode weQrCode = null;
//当类型相同时
if(ObjectUtil.equal(qrCode.getType(),weQrAddQuery.getQrType())){
WeAddWayQuery weContactWay = weQrAddQuery.getWeContactWay();
WeResultVo weResultVo = qwCustomerClient.updateContactWay(weContactWay).getData();
if(Objects.isNull(weResultVo)){
throw new WeComException("活码生成失败!");
}
rabbitTemplate.convertAndSend(mqSettingConfig.getWeQrCodeChangeEx(),mqSettingConfig.getWeQrCodeChangeRk(),String.valueOf(weQrCode.getId()));
if (ObjectUtil.notEqual(0, weResultVo.getErrCode())) {
throw new WeComException(weResultVo.getErrCode(), WeErrorCodeEnum.parseEnum(weResultVo.getErrCode()).getErrorMsg());
}
weQrCode = weQrAddQuery.getWeQrCodeEntity(null, null);
}else {
throw new WeComException(weResultVo.getErrCode(), WeErrorCodeEnum.parseEnum(weResultVo.getErrCode()).getErrorMsg());
WeAddWayQuery weContactWay = weQrAddQuery.getWeContactWay();
weContactWay.setState(qrCode.getState());
WeAddWayVo weResultVo = qwCustomerClient.addContactWay(weContactWay).getData();
if(Objects.isNull(weResultVo)){
throw new WeComException("活码生成失败!");
}
if (ObjectUtil.notEqual(0, weResultVo.getErrCode())) {
throw new WeComException(weResultVo.getErrCode(), WeErrorCodeEnum.parseEnum(weResultVo.getErrCode()).getErrorMsg());
}
weQrCode = weQrAddQuery.getWeQrCodeEntity(weResultVo.getConfigId(), weResultVo.getQrCode());
//删除原活码
//JSONObject delQrCodeInfo = new JSONObject();
//员工活码类型为 1
//delQrCodeInfo.put("type","1");
//delQrCodeInfo.put("configId",qrCode.getConfigId());
//rabbitTemplate.convertAndSend(mqSettingConfig.getWeQrCodeChangeEx(),mqSettingConfig.getWeQrCodeDelRk(),delQrCodeInfo.toJSONString());
ThreadUtil.execAsync(() ->{
WeContactWayQuery weContactWayQuery = new WeContactWayQuery();
weContactWayQuery.setConfig_id(qrCode.getConfigId());
qwCustomerClient.delContactWay(weContactWayQuery);
});
}

if (updateById(weQrCode)) {
//修改标签数据
tagRelService.updateBatchByQrId(weQrCode.getId(), weQrAddQuery.getQrTags());
//修改活码范围数据
scopeService.updateBatchByQrId(weQrCode.getId(), weQrAddQuery.getQrUserInfos());
//修改活码素材
attachmentsService.updateBatchByQrId(weQrCode.getId(), weQrAddQuery.getAttachments());
}
rabbitTemplate.convertAndSend(mqSettingConfig.getWeQrCodeChangeEx(),mqSettingConfig.getWeQrCodeChangeRk(),String.valueOf(weQrCode.getId()));
}

@Override
Expand Down

0 comments on commit 6888d96

Please sign in to comment.