Commit e88b4ecc by 墨竹

fix:创建活码定时任务改为消息队列

parent 7f9b4742
......@@ -124,13 +124,12 @@ public interface HmQrcodeApiService {
/**
* 检查员工开启联系我
*
* @param wxEnterpriseId wx企业标识
* @param enterpriseId 企业标识
* "routerName": "checkStaffOpenContactByWxEnterpriseIdMq"
* @param param 参数
* @author mozhu
* @date 2022-08-08 22:01:43
* @date 2022-08-19 15:04:37
*/
void checkStaffOpenContactByWxEnterpriseId(String wxEnterpriseId, String enterpriseId);
void checkStaffOpenContactByWxEnterpriseId(String param);
/**
......
......@@ -2,6 +2,7 @@ package com.gic.haoban.manage.service.service.out.impl.hm;
import cn.hutool.core.convert.Convert;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.clerk.api.dto.ClerkDTO;
import com.gic.clerk.api.service.ClerkService;
......@@ -29,10 +30,7 @@ import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.entity.TabHaobanStaff;
import com.gic.haoban.manage.service.pojo.bo.hm.*;
import com.gic.haoban.manage.service.pojo.bo.welcome.WelcomeDetailBO;
import com.gic.haoban.manage.service.service.StaffClerkRelationService;
import com.gic.haoban.manage.service.service.StaffService;
import com.gic.haoban.manage.service.service.WelcomeService;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.haoban.manage.service.service.*;
import com.gic.haoban.manage.service.service.hm.HmClerkRelationService;
import com.gic.haoban.manage.service.service.hm.HmGroupService;
import com.gic.haoban.manage.service.service.hm.HmQrcodeService;
......@@ -104,6 +102,8 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
private WelcomeService welcomeService;
@Autowired
private RightService rightService;
@Autowired
private WxEnterpriseRelatedService wxEnterpriseRelatedService;
@GicLogRecord(value = "新增员工活码-${#logContent}",
category = GicLogRecordCategoryEnum.HUOMA,
......@@ -767,51 +767,31 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
logger.info("该企业未与gic关联,无需开启:enterpriseId:{},wxEnterpriseId:{}", enterpriseId, wxEnterpriseId);
continue;
}
//企微已经开启联系我
List<String> wxUserIdsList = qywxUserApiService.listCorpExternalUser(wxEnterpriseDTO.getCorpid(), config.getWxSuiteid());
List<StaffClerkRelationDTO> staffClerkRelationDTOS = staffClerkRelationService.listIdsByWxUserIds(wxUserIdsList, wxEnterpriseId, enterpriseId);
if (CollectionUtils.isEmpty(staffClerkRelationDTOS)) {
logger.error("无导购关联数据");
continue;
}
for (StaffClerkRelationDTO staffClerkRelationDTO : staffClerkRelationDTOS) {
//具有联系我功能的导购创建活码
staffClerkRelationService.updateOpenConcatFlagById(1, staffClerkRelationDTO.getStaffClerkRelationId());
//创建活码
HmQrcodeQDTO hmQrcodeQDTO = new HmQrcodeQDTO();
hmQrcodeQDTO.setHmType(1);
hmQrcodeQDTO.setWxEnterpriseId(wxEnterpriseId);
hmQrcodeQDTO.setEnterpriseId(staffClerkRelationDTO.getEnterpriseId());
hmQrcodeQDTO.setName(staffClerkRelationDTO.getStaffName());
hmQrcodeQDTO.setPassFlag(1);
hmQrcodeQDTO.setStoreId(staffClerkRelationDTO.getStoreId());
hmQrcodeQDTO.setClerkIdList(Collections.singletonList(staffClerkRelationDTO.getClerkId()));
add(hmQrcodeQDTO);
}
List<StaffClerkRelationDTO> relationDTOS = staffClerkRelationService.listIdsByNotInWxUserIds(wxUserIdsList, wxEnterpriseId, enterpriseId);
if (CollectionUtils.isEmpty(relationDTOS)) {
logger.error("无导购不包含关联数据");
continue;
}
for (StaffClerkRelationDTO relationDTO : relationDTOS) {
//有活码,但是企微联系我功能 被关闭
String clerkId = relationDTO.getClerkId();
HmQrcodeBO hmQrcodeBO = hmQrcodeService.queryByClerkId(clerkId, relationDTO.getWxEnterpriseId());
if (hmQrcodeBO == null) {
logger.info("导购无活码,无需处理:clerkId:{}", clerkId);
continue;
}
staffClerkRelationService.updateOpenConcatFlagById(0, relationDTO.getStaffClerkRelationId());
hmQrcodeService.updateStatusById(hmQrcodeBO.getHmId(), 3);
JSONObject jsonObject = new JSONObject();
jsonObject.put("wxEnterpriseId",wxEnterpriseId);
jsonObject.put("enterpriseId",enterpriseId);
GicMQClient clientInstance = GICMQClientUtil.getClientInstance();
try {
clientInstance.sendMessage("checkStaffOpenContactByWxEnterpriseIdMq", jsonObject.toJSONString());
} catch (Exception e) {
logger.info("发送消息异常:{}", e);
}
}
logger.info("检查员工是否开启联系我,定时任务,end");
}
@Override
public void checkStaffOpenContactByWxEnterpriseId(String wxEnterpriseId, String enterpriseId) {
public void checkStaffOpenContactByWxEnterpriseId(String param) {
JSONObject jsonObject = JSON.parseObject(param);
String wxEnterpriseId = jsonObject.getString("wxEnterpriseId");
String enterpriseId = jsonObject.getString("enterpriseId");
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId);
if (wxEnterpriseDTO == null) {
logger.error("无wx企业:{}",wxEnterpriseId);
return;
}
logger.info("检查企业员工是否开启联系我:wxEnterpriseId:{},enterpriseId:{}",wxEnterpriseId,enterpriseId);
//查询出所有正常的导购
//企微已经开启联系我
List<String> wxUserIdsList = qywxUserApiService.listCorpExternalUser(wxEnterpriseDTO.getCorpid(), config.getWxSuiteid());
......@@ -848,6 +828,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
logger.info("导购无活码,无需处理:clerkId:{}", clerkId);
continue;
}
staffClerkRelationService.updateOpenConcatFlagById(0, relationDTO.getStaffClerkRelationId());
hmQrcodeService.updateStatusById(hmQrcodeBO.getHmId(), 3);
}
}
......
......@@ -50,10 +50,4 @@ public class ServiceTest {
hmQrcodeApiService.add(hmQrcodeQDTO);
}
@Test
public void test2() {
hmQrcodeApiService.checkStaffOpenContactByWxEnterpriseId("5bd929fd3b2c49deaa1184bcb0d669b3","ff8080815dacd3a2015dacd3ef5c0000");
}
}
package com.gic.haoban.manage.web.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ctrip.framework.apollo.ConfigService;
import com.gic.api.base.commons.Page;
import com.gic.commons.util.HttpClient;
......@@ -337,7 +338,10 @@ public class TestController extends WebBaseController {
*/
@RequestMapping("/checkStaffOpenContactByWxEnterpriseId")
public HaobanResponse checkStaffOpenContactByWxEnterpriseId(String wxEnterpriseId,String enterpriseId) {
hmQrcodeApiService.checkStaffOpenContactByWxEnterpriseId(wxEnterpriseId,enterpriseId);
JSONObject jsonObject = new JSONObject();
jsonObject.put("wxEnterpriseId",wxEnterpriseId);
jsonObject.put("enterpriseId",enterpriseId);
hmQrcodeApiService.checkStaffOpenContactByWxEnterpriseId(jsonObject.toJSONString());
return resultResponse(HaoBanErrCode.ERR_1);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment