Commit f96bc87b by 徐高华

Merge branch 'developer' of http://git.gicdev.com/haoban3.0/haoban-manage3.0.git into developer

parents 5193951f c389618b
......@@ -5,7 +5,9 @@ package com.gic.haoban.manage.api.enums;
*/
public enum SecretTypeEnum {
CONTACT_CUSTOMER(1, "顾客联系"),
// 2和3废弃
CONTACT_SECRET(2, "通讯录"),
// 3和5公用
HAOBAN_HELP(3, "好办助手"),
MEMBER_WAPP(4, "会员小程序"),
CUSTOMIZED_APP(5, "自建代开发"),
......
......@@ -304,7 +304,6 @@ public interface MemberUnionidRelatedApiService {
MemberUnionidRelatedDTO getById(String memberUnionidRelatedId);
/**
* 更新对外联系人id
*
......@@ -315,4 +314,26 @@ public interface MemberUnionidRelatedApiService {
*/
void updateSelfExternalUseridById(String selfExternalUserid, String memberUnionidRelatedId);
/**
* 更新新userid corpid
*
* @param wxEnterpriseId wx企业标识
* @return {@link ServiceResponse }
* @author mozhu
* @date 2022-06-30 13:54:12
*/
ServiceResponse updateNewUseridCorpid(String wxEnterpriseId);
/**
* 更新新userid corpid mq
* "routerName": "updateNewUseridCorpidMq"
*
* @param params 参数个数
* @author mozhu
* @date 2022-06-30 13:56:27
*/
void updateNewUseridCorpidMq(String params);
}
package com.gic.haoban.manage.web.controller;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.Page;
import com.gic.authcenter.commons.dto.AuthcenterUserDetails;
......@@ -43,19 +20,9 @@ import com.gic.haoban.base.api.common.ServiceResponse;
import com.gic.haoban.common.utils.EntityUtil;
import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.common.utils.UuidUtil;
import com.gic.haoban.manage.api.dto.BindStoreInfoDTO;
import com.gic.haoban.manage.api.dto.DepartmentDTO;
import com.gic.haoban.manage.api.dto.EnterpriseDetailDTO;
import com.gic.haoban.manage.api.dto.StoreOrGroupInfoDTO;
import com.gic.haoban.manage.api.dto.StoreRangeInfoDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseRelationDetailDTO;
import com.gic.haoban.manage.api.dto.YwWxEnterpriseDTO;
import com.gic.haoban.manage.api.dto.*;
import com.gic.haoban.manage.api.enums.ChannelCodeEnum;
import com.gic.haoban.manage.api.service.DepartmentApiService;
import com.gic.haoban.manage.api.service.ExternalClerkRelatedApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService;
import com.gic.haoban.manage.api.service.*;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.qo.WxEnterpriseBindQo;
import com.gic.haoban.manage.web.vo.EnterpriseDetailVo;
......@@ -66,8 +33,20 @@ import com.gic.redis.data.util.RedisUtil;
import com.gic.wechat.api.service.qywx.QywxUserApiService;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.hutool.core.collection.CollectionUtil;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
@RestController
public class EnterpriseController extends WebBaseController {
......@@ -96,6 +75,8 @@ public class EnterpriseController extends WebBaseController {
private GroupSendOperateApiService groupSendOperateApiService;
@Autowired
private StoreGroupService storeGroupService ;
@Autowired
private MemberUnionidRelatedApiService memberUnionidRelatedApiService;
private static final String QYWX_TAG_OPRN_KEY = "qywx-tag-open";
private static final String QYWX_TAG_OPRN_KEY_LOCK = "qywx-tag-open-lock";
......@@ -644,4 +625,22 @@ public class EnterpriseController extends WebBaseController {
WxEnterpriseRelationDetailDTO bindInfo = wxEnterpriseRelatedApiService.getEnterpriseBindInfo(wxEnterpriseId, enterpriseId);
return resultResponse(HaoBanErrCode.ERR_1, bindInfo);
}
/**
* 转换corpid、userid、external_userid
* @param wxEnterpriseId
* @return
*/
@RequestMapping("/updateNewUseridCorpid")
public HaobanResponse updateNewUseridCorpid(String wxEnterpriseId) {
ServiceResponse serviceResponse = memberUnionidRelatedApiService.updateNewUseridCorpid(wxEnterpriseId);
int code = serviceResponse.getCode();
if (HaoBanErrCode.ERR_1.getCode() == code) {
return resultResponse(HaoBanErrCode.ERR_1);
} else {
String message = serviceResponse.getMessage();
return resultResponse(HaoBanErrCode.ERR_0, message);
}
}
}
......@@ -68,4 +68,48 @@ public interface MemberUnionidRelatedMapper {
int updateExternalUserIdByOldExternalUserId(@Param("newExternalUserId") String new_external_userid,
@Param("oldExternalUserId") String external_userid,
@Param("wxEnterpriseId") String wxEnterpriseId);
/**
* 更新用户id wx企业id
*
* @param wxEnterpriseId wx企业标识
* @return int
* @author mozhu
* @date 2022-06-30 16:32:46
*/
int updateUserIdByWxEnterpriseId(@Param("wxEnterpriseId")String wxEnterpriseId);
/**
* 更新自建外部用户id
*
* @param new_external_userid 新外部标识
* @param external_userid 外部用户标识
* @param wxEnterpriseId wx企业标识
* @return int
* @author mozhu
* @date 2022-06-30 16:35:21
*/
int updateSelfExternalUserIdByOldSelfExternalUserId(@Param("newExternalUserId") String new_external_userid,
@Param("oldExternalUserId") String external_userid,
@Param("wxEnterpriseId") String wxEnterpriseId);
/**
* wx企业id查询数据
*
* @param wxEnterpriseId wx企业标识
* @return {@link List }<{@link MemberUnionidRelated }>
* @author mozhu
* @date 2022-06-30 17:35:50
*/
List<MemberUnionidRelated> listByWxEnterpriseId(@Param("wxEnterpriseId") String wxEnterpriseId);
/**
* 更新外部userid wx企业id
*
* @param wxEnterpriseId wx企业标识
* @return int
* @author mozhu
* @date 2022-06-30 19:36:00
*/
int updateExternalUseridByWxEnterpriseId(String wxEnterpriseId);
}
\ No newline at end of file
package com.gic.haoban.manage.service.dao.mapper;
import java.util.List;
import com.gic.api.base.commons.Page;
import com.gic.haoban.manage.api.dto.StaffDepartmentRelatedDTO;
import com.gic.haoban.manage.service.entity.TabHaobanStaffDepartmentRelated;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface StaffDepartmentRelatedMapper {
int deleteByPrimaryKey(String staffDepartmentRelatedId);
......@@ -58,4 +56,14 @@ public interface StaffDepartmentRelatedMapper {
@Param("wxEnterpriseId") String wxEnterpriseId,
@Param("staffId") String staffId
);
/**
* 更新用户id wx企业id
*
* @param wxEnterpriseId wx企业标识
* @return int
* @author mozhu
* @date 2022-06-30 16:25:33
*/
int updateUserIdByWxEnterpriseId(@Param("wxEnterpriseId") String wxEnterpriseId);
}
\ No newline at end of file
......@@ -147,5 +147,29 @@ public interface StaffMapper {
void delOtherStaffByWxUserId(@Param("wxUserId") String wxUserId,
@Param("staffId") String staffId,
@Param("wxEnterpriseId") String wxEnterpriseId);
/**
* wx企业id员工列表
*
* @param wxEnterpriseId wx企业标识
* @return {@link List }<{@link TabHaobanStaff }>
* @author mozhu
* @date 2022-06-30 14:04:05
*/
List<TabHaobanStaff> listByWxEnterpriseId(@Param("wxEnterpriseId") String wxEnterpriseId);
/**
* 更新wx用户id通过员工id
*
* @param wxEnterpriseId wx企业标识
* @param newWxUserId 新wx用户id
* @param oldWxUserId 老wx用户id
* @return int
* @author mozhu
* @date 2022-06-30 15:53:13
*/
int updateUserIdByUserId(@Param("wxEnterpriseId") String wxEnterpriseId,
@Param("newWxUserId") String newWxUserId,
@Param("oldWxUserId") String oldWxUserId);
}
\ No newline at end of file
......@@ -370,4 +370,13 @@ public interface TabHaobanExternalClerkRelatedMapper {
int countByMemberId(@Param("memberId") String memberId,
@Param("enterpriseId") String enterpriseId);
/**
* 更新用户id wx企业id
*
* @param wxEnterpriseId wx企业标识
* @return int
* @author mozhu
* @date 2022-06-30 16:36:11
*/
int updateUserIdByWxEnterpriseId(@Param("wxEnterpriseId") String wxEnterpriseId);
}
\ No newline at end of file
......@@ -178,4 +178,14 @@ public interface TabHaobanStaffClerkRelationMapper {
@Param("memberIdList") List<String> memberIdList,
@Param("clerkIdList") List<String> clerkIdList,
@Param("enterpriseId") String enterpriseId);
/**
* 更新用户id wx企业id
*
* @param wxEnterpriseId wx企业标识
* @return int
* @author mozhu
* @date 2022-06-30 16:21:31
*/
int updateUserIdByWxEnterpriseId(@Param("wxEnterpriseId") String wxEnterpriseId);
}
\ No newline at end of file
......@@ -29,4 +29,15 @@ public interface WxApplicationMapper {
* @date 2021-12-21 22:00:54
*/
TabHaobanWxApplication selectByCorpId(@Param("corpid") String corpid,@Param("applicationType") Integer applicationType);
/**
* 更新corpid通过id
*
* @param wxApplicationId 天气应用程序id
* @param corpid corpid
* @return int
* @author mozhu
* @date 2022-06-30 19:19:19
*/
int updateCorpidById(@Param("wxApplicationId") String wxApplicationId, @Param("corpid") String corpid);
}
\ No newline at end of file
......@@ -57,4 +57,19 @@ public interface WxEnterpriseMapper {
* @date 2021-12-30 20:40:59
*/
int updateExternalFlagById(@Param("externalFlag") Integer externalFlag, @Param("wxEnterpriseId") String wxEnterpriseId);
/**
* 更新是否转化userid
*
* @param useridFlag userid国旗
* @param corpid corpid
* @param wxEnterpriseId wx企业标识
* @return int
* @author mozhu
* @date 2022-06-30 18:46:44
*/
int updateUseridFlagById(@Param("useridFlag") Integer useridFlag,
@Param("corpid") String corpid,
@Param("wxEnterpriseId") String wxEnterpriseId);
}
\ No newline at end of file
......@@ -5,7 +5,9 @@ package com.gic.haoban.manage.service.errorcode;
*/
public enum HaoBanErrCode {
ERR_0001("10100001", "参数没有传"),;
ERR_0001("10100001", "参数没有传"),
ERR_10012("10012","企业微信不存在"),
;
private String code;
private String msg;
......
package com.gic.haoban.manage.service.service;
import java.util.Collection;
import java.util.List;
import com.gic.haoban.manage.api.dto.ExternalClerkRelatedDTO;
import com.gic.haoban.manage.api.dto.MemberUnionidRelatedDTO;
import com.gic.haoban.manage.service.entity.TabHaobanExternalClerkRelated;
import java.util.Collection;
import java.util.List;
public interface ExternalClerkRelatedService {
void insert(TabHaobanExternalClerkRelated related);
......@@ -66,4 +66,14 @@ public interface ExternalClerkRelatedService {
* @return
*/
String checkAndUpdateMemberByUnonId(String enterpriseId, String memberId, String unionId);
/**
* 更新用户id wx企业id
*
* @param wxEnterpriseId wx企业标识
* @return int
* @author mozhu
* @date 2022-06-30 16:35:47
*/
int updateUserIdByWxEnterpriseId(String wxEnterpriseId);
}
package com.gic.haoban.manage.service.service;
import com.gic.api.base.commons.Page;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.manage.api.dto.MemberUnionidRelatedDTO;
import com.gic.haoban.manage.service.entity.MemberUnionidRelated;
import com.github.pagehelper.PageInfo;
import java.util.List;
......@@ -68,4 +71,37 @@ public interface MemberUnionRelatedService {
* @return
*/
List<MemberUnionidRelatedDTO> listBySelfExternalUserId(String wxUserId, String wxEnterpriseId, String selfExternalUserId);
/**
* 更新用户id wx企业id
*
* @param wxEnterpriseId wx企业标识
* @return int
* @author mozhu
* @date 2022-06-30 16:32:21
*/
int updateUserIdByWxEnterpriseId(String wxEnterpriseId);
/**
* 更新外部userid wx企业id
*
* @param wxEnterpriseId wx企业标识
* @return int
* @author mozhu
* @date 2022-06-30 19:34:27
*/
int updateExternalUseridByWxEnterpriseId(String wxEnterpriseId);
/**
* 分页查询外部联系人id
*
* @param wxEnterpriseId wx企业标识
* @param basePageInfo 基本信息页
* @return {@link Page }<{@link MemberUnionidRelatedDTO }>
* @author mozhu
* @date 2022-06-30 17:34:06
*/
PageInfo<MemberUnionidRelated> listByWxEnterpriseId(String wxEnterpriseId, BasePageInfo basePageInfo);
}
......@@ -140,4 +140,15 @@ public interface StaffClerkRelationService {
* @return {@link Set<String>}
*/
List<String> listRelationsStaffId(Set<String> staffIdList);
/**
* 更新用户id wx企业id
*
* @param wxEnterpriseId wx企业标识
* @return int
* @author mozhu
* @date 2022-06-30 16:21:06
*/
int updateUserIdByWxEnterpriseId(String wxEnterpriseId);
}
......@@ -46,4 +46,15 @@ public interface StaffDepartmentRelatedService {
public int update(TabHaobanStaffDepartmentRelated tab);
/**
* 更新用户id wx企业id
*
* @param wxEnterpriseId wx企业标识
* @return int
* @author mozhu
* @date 2022-06-30 16:24:59
*/
int updateUserIdByWxEnterpriseId(String wxEnterpriseId);
}
package com.gic.haoban.manage.service.service;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.service.entity.TabHaobanStaff;
import com.github.pagehelper.Page;
......@@ -15,7 +17,7 @@ public interface StaffService {
String add(TabHaobanStaff tab);
Page<TabHaobanStaff> pageStaff(List<String> staffIds, Integer activeFlag,
String keyword,List<String> departmentIds,String wxEnterpriseId,Integer relationFlag);
String keyword, List<String> departmentIds, String wxEnterpriseId, Integer relationFlag);
void updateByPrimaryKey(TabHaobanStaff tab);
......@@ -53,7 +55,7 @@ public interface StaffService {
* @author mozhu
* @date 2022-01-12 17:19:28
*/
TabHaobanStaff selectByPhoneNumberOrUserIdAndEnterpriseId(String phoneNumber,String userId, String wxEnterpriseId);
TabHaobanStaff selectByPhoneNumberOrUserIdAndEnterpriseId(String phoneNumber, String userId, String wxEnterpriseId);
List<StaffDTO> listByUserIdsAndWxEnterpriseId(List<String> userIds, String wxEnterpriseId);
......@@ -116,5 +118,28 @@ public interface StaffService {
* @param wxEnterpriseId wx企业标识
*/
void delOtherStaffByWxUserId(String wxUserId, String staffId, String wxEnterpriseId);
/**
* 分页获取staff
*
* @param wxEnterpriseId wx企业标识
* @param basePageInfo 基本信息页
* @return {@link List }<{@link StaffDTO }>
* @author mozhu
* @date 2022-06-30 13:58:48
*/
com.gic.api.base.commons.Page<StaffDTO> getPageStaffIdsByWxEnterpriseId(String wxEnterpriseId, BasePageInfo basePageInfo);
/**
* 更新wx用户id通过员工id
*
* @param wxEnterpriseId wx企业标识
* @param newWxUserId 新wx用户id
* @param oldWxUserId 老wx用户id
* @return int
* @author mozhu
* @date 2022-06-30 15:54:34
*/
int updateUserIdByUserId(String wxEnterpriseId, String newWxUserId, String oldWxUserId);
}
......@@ -53,4 +53,16 @@ public interface WxEnterpriseService {
* @return
*/
List<TabHaobanWxEnterprise> listAll();
/**
* 更新userid
*
* @param useridFlag userid国旗
* @param corpid corpid
* @param wxEnterpriseId wx企业标识
* @return int
* @author mozhu
* @date 2022-06-30 18:49:31
*/
int updateUseridFlagById(Integer useridFlag, String corpid, String wxEnterpriseId);
}
......@@ -208,4 +208,9 @@ public class ExternalClerkRelatedServiceImpl implements ExternalClerkRelatedServ
}
return null;
}
@Override
public int updateUserIdByWxEnterpriseId(String wxEnterpriseId) {
return mapper.updateUserIdByWxEnterpriseId(wxEnterpriseId);
}
}
package com.gic.haoban.manage.service.service.impl;
import com.gic.commons.util.EntityUtil;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.common.utils.StringUtil;
import com.gic.haoban.manage.api.dto.MemberUnionidRelatedDTO;
import com.gic.haoban.manage.service.dao.mapper.MemberUnionidRelatedMapper;
import com.gic.haoban.manage.service.entity.MemberUnionidRelated;
import com.gic.haoban.manage.service.service.MemberUnionRelatedService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -99,4 +102,21 @@ public class MemberUnionRelatedServiceImpl implements MemberUnionRelatedService
List<MemberUnionidRelated> retList = mapper.listBySelfExternalUserId(wxUserId, wxEnterpriseId, selfExternalUserId);
return EntityUtil.changeEntityListNew(MemberUnionidRelatedDTO.class, retList);
}
@Override
public int updateUserIdByWxEnterpriseId(String wxEnterpriseId) {
return mapper.updateUserIdByWxEnterpriseId(wxEnterpriseId);
}
@Override
public int updateExternalUseridByWxEnterpriseId(String wxEnterpriseId) {
return mapper.updateExternalUseridByWxEnterpriseId(wxEnterpriseId);
}
@Override
public PageInfo<MemberUnionidRelated> listByWxEnterpriseId(String wxEnterpriseId, BasePageInfo basePageInfo) {
PageHelper.startPage(basePageInfo);
List<MemberUnionidRelated> memberUnionidRelateds = mapper.listByWxEnterpriseId(wxEnterpriseId);
return new PageInfo<>(memberUnionidRelateds);
}
}
......@@ -295,4 +295,9 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
public List<String> listRelationsStaffId(Set<String> staffIdList) {
return mapper.listRelationsStaffId(staffIdList);
}
@Override
public int updateUserIdByWxEnterpriseId(String wxEnterpriseId) {
return mapper.updateUserIdByWxEnterpriseId(wxEnterpriseId);
}
}
......@@ -99,4 +99,8 @@ public class StaffDepartmentRelatedServiceImpl implements StaffDepartmentRelated
return mapper.updateByPrimaryKeySelective(tab);
}
@Override
public int updateUserIdByWxEnterpriseId(String wxEnterpriseId) {
return mapper.updateUserIdByWxEnterpriseId(wxEnterpriseId);
}
}
package com.gic.haoban.manage.service.service.impl;
import com.gic.commons.util.EntityUtil;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.common.utils.PageUtil;
import com.gic.haoban.common.utils.StringUtil;
import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.service.dao.mapper.StaffMapper;
......@@ -9,6 +12,8 @@ import com.gic.haoban.manage.service.service.MemberUnionRelatedService;
import com.gic.haoban.manage.service.service.StaffClerkRelationService;
import com.gic.haoban.manage.service.service.StaffService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
......@@ -163,4 +168,16 @@ public class StaffServiceImpl implements StaffService {
public void delOtherStaffByWxUserId(String wxUserId, String staffId, String wxEnterpriseId) {
mapper.delOtherStaffByWxUserId(wxUserId, staffId, wxEnterpriseId);
}
@Override
public com.gic.api.base.commons.Page<StaffDTO> getPageStaffIdsByWxEnterpriseId(String wxEnterpriseId, BasePageInfo basePageInfo) {
PageHelper.startPage(basePageInfo);
List<TabHaobanStaff> tabHaobanStaffs = mapper.listByWxEnterpriseId(wxEnterpriseId);
return PageUtil.changePageHelperToCurrentPage(new PageInfo<>(tabHaobanStaffs),StaffDTO.class);
}
@Override
public int updateUserIdByUserId(String wxEnterpriseId, String newWxUserId, String oldWxUserId) {
return mapper.updateUserIdByUserId(wxEnterpriseId, newWxUserId, oldWxUserId);
}
}
......@@ -94,4 +94,9 @@ public class WxEnterpriseServiceImpl implements WxEnterpriseService {
public List<TabHaobanWxEnterprise> listAll() {
return mapper.listAll();
}
@Override
public int updateUseridFlagById(Integer useridFlag, String corpid, String wxEnterpriseId) {
return mapper.updateUseridFlagById(useridFlag, corpid, wxEnterpriseId);
}
}
......@@ -28,6 +28,7 @@ import com.gic.haoban.app.customer.enums.QywxSyncTaskTypeEnum;
import com.gic.haoban.app.customer.service.api.service.CustomerApiService;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.base.api.common.ServiceResponse;
import com.gic.haoban.base.api.common.errCode.HaoBanErrCodeCommon;
import com.gic.haoban.common.utils.PageUtil;
import com.gic.haoban.manage.api.constants.Manage3Constants;
import com.gic.haoban.manage.api.dto.*;
......@@ -142,6 +143,8 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
private MemberStoreService memberStoreService;
@Autowired
private ImageService imageService;
@Autowired
private StaffDepartmentRelatedService staffDepartmentRelatedService;
@Override
public void dealQywxExternalUser(String params) {
......@@ -766,7 +769,7 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
dto.setAvatar(StringUtils.isBlank(dto.getAvatar()) ? midRelatedDto.getAvatar() : dto.getAvatar());
dto.setMemberUnionidRelatedId(midRelatedDto.getMemberUnionidRelatedId());
if (StringUtils.isAnyBlank(dto.getExternalUserid(),dto.getSelfExternalUserid())) {
if (StringUtils.isAnyBlank(dto.getExternalUserid(), dto.getSelfExternalUserid())) {
log.error("加好友异常、请检查配置是否正常(如:检查客户联系回调、老好办助手回调、代开发回调(是否配置多个回调、企微权限是否正常、密钥是否正确)、好办权限等),wxEnterpriseId:{}", wxEnterpriseId);
return null;
}
......@@ -1977,6 +1980,139 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
return EntityUtil.changeEntityNew(MemberUnionidRelatedDTO.class, memberUnionidRelated);
}
@Override
public ServiceResponse updateNewUseridCorpid(String wxEnterpriseId) {
String lockKey = "updateNewUseridCorpid_" + wxEnterpriseId;
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId);
ServiceResponse serviceResponse = new ServiceResponse();
if (wxEnterpriseDTO == null) {
serviceResponse.setCode(HaoBanErrCodeCommon.ERR_0.getCode());
serviceResponse.setMessage("企微不存在");
return serviceResponse;
}
if (RedisUtil.isLocked(lockKey)) {
log.info("redis锁,lockKey:{}", lockKey);
String corpName = wxEnterpriseDTO.getCorpName();
serviceResponse.setCode(HaoBanErrCodeCommon.ERR_0.getCode());
serviceResponse.setMessage(corpName + "已经在转换中,请勿重复操作!");
return serviceResponse;
}
SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(wxEnterpriseId, SecretTypeEnum.CUSTOMIZED_APP.getVal());
if (secretSetting == null) {
serviceResponse.setCode(HaoBanErrCodeCommon.ERR_0.getCode());
serviceResponse.setMessage("代开发密钥不存在");
return serviceResponse;
}
String corpid = wxEnterpriseDTO.getCorpid();
RedisUtil.lock(lockKey, 2L, TimeUnit.HOURS, 0L);
wxEnterpriseService.updateUseridFlagById(2, null, wxEnterpriseId);
JSONObject jsonObject = new JSONObject();
jsonObject.put("corpid", corpid);
jsonObject.put("wxEnterpriseId", wxEnterpriseId);
jsonObject.put("secret", secretSetting.getSecretVal());
GicMQClient clientInstance = GICMQClientUtil.getClientInstance();
try {
clientInstance.sendMessage("updateNewUseridCorpidMq", jsonObject.toJSONString());
} catch (Exception e) {
log.info("企微转换id发送消息队列异常:{}", e.getMessage(), e);
}
serviceResponse.setCode(HaoBanErrCodeCommon.ERR_1.getCode());
return serviceResponse;
}
@Override
public void updateNewUseridCorpidMq(String params) {
if (StringUtils.isBlank(params)) {
log.error("传入为空");
return;
}
log.info("转换corpid、userid start params:{}", params);
JSONObject jsonObject = JSON.parseObject(params);
String wxEnterpriseId = jsonObject.getString("wxEnterpriseId");
String corpid = jsonObject.getString("corpid");
String secret = jsonObject.getString("secret");
// 限流器
RRateLimiter rateLimiter = RedisUtil.getRedisClient().getRateLimiter("haoban:manage3:updateNewUseridCorpid:limit");
// 每1秒产生5个令牌
rateLimiter.trySetRate(RateType.OVERALL, 5, 1, RateIntervalUnit.SECONDS);
BasePageInfo basePageInfo = new BasePageInfo();
int pageNum = 1;
while (true) {
rateLimiter.acquire();
basePageInfo.setPageNum(pageNum);
basePageInfo.setPageSize(1000);
Page<StaffDTO> staffDTOPage = staffService.getPageStaffIdsByWxEnterpriseId(wxEnterpriseId, basePageInfo);
List<StaffDTO> staffDTOList = staffDTOPage.getResult();
if (CollectionUtil.isEmpty(staffDTOList)) {
break;
}
List<String> stringList = staffDTOList.stream().map(StaffDTO::getWxUserId).distinct().collect(Collectors.toList());
List<QywxNewUseridDTO> qywxNewUseridDTOList = qywxUserApiService.getSelfUseridToOpenuserid(corpid, secret, stringList);
if (CollectionUtils.isEmpty(qywxNewUseridDTOList)) {
log.error("调用企微无权限");
continue;
}
for (QywxNewUseridDTO qywxNewUseridDTO : qywxNewUseridDTOList) {
String userid = qywxNewUseridDTO.getUserid();
String openUserid = qywxNewUseridDTO.getOpen_userid();
log.info("转换新的userid,userid:{},openUserid:{}", userid, openUserid);
staffService.updateUserIdByUserId(wxEnterpriseId, openUserid, userid);
}
pageNum++;
}
//更新导购员工关联关系表
staffClerkRelationService.updateUserIdByWxEnterpriseId(wxEnterpriseId);
//更新员工部门关联关系表
staffDepartmentRelatedService.updateUserIdByWxEnterpriseId(wxEnterpriseId);
//更新好友关系表
memberUnionRelatedService.updateUserIdByWxEnterpriseId(wxEnterpriseId);
//更新会员好友关系表
externalClerkRelatedService.updateUserIdByWxEnterpriseId(wxEnterpriseId);
//更新自建外部联系人id
memberUnionRelatedService.updateExternalUseridByWxEnterpriseId(wxEnterpriseId);
log.info("转换corpid、userid end params:{}", params);
//迁移完成
updateUseridFlagById(wxEnterpriseId, corpid);
}
/**
* 迁移完成
*
* @param wxEnterpriseId
* @param corpid
*/
private void updateUseridFlagById(String wxEnterpriseId, String corpid) {
String serviceCorpid = config.getCorpid();
String openCorpid = qywxUserApiService.toOpenCorpid(corpid, serviceCorpid);
TabHaobanWxApplication tabHaobanWxApplication = wxApplicationMapper.selectByCorpId(corpid, 3);
if (tabHaobanWxApplication == null) {
log.info("代开发应用不存在:{}", corpid);
return;
}
String[] openidType = {"1", "3"};
//调用完成接口
boolean flag = qywxUserApiService.finishOpenidMigration(corpid, serviceCorpid, tabHaobanWxApplication.getAgentId(), openidType);
if (flag) {
wxApplicationMapper.updateCorpidById(tabHaobanWxApplication.getWxApplicationId(), openCorpid);
wxEnterpriseService.updateUseridFlagById(1, openCorpid, wxEnterpriseId);
} else {
wxEnterpriseService.updateUseridFlagById(3, openCorpid, wxEnterpriseId);
}
String lockKey = "updateNewUseridCorpid_" + wxEnterpriseId;
RedisUtil.unlock(lockKey);
}
/**
* 获取客户详情列表
*
......
......@@ -251,4 +251,38 @@
where external_userid = #{oldExternalUserId}
and wx_enterprise_id = #{wxEnterpriseId}
</update>
<update id="updateUserIdByWxEnterpriseId">
UPDATE tab_haoban_member_unionid_related a
LEFT JOIN tab_haoban_external_clerk_related b ON a.member_unionid_related_id = b.member_unionid_related_id
SET a.wx_user_id = b.wx_user_id,update_time= now()
WHERE
a.wx_enterprise_id = #{wxEnterpriseId}
AND b.status_flag IN ( 1, 3, 4 )
</update>
<update id="updateSelfExternalUserIdByOldSelfExternalUserId">
UPDATE
tab_haoban_member_unionid_related
SET self_external_userid = #{newExternalUserId},
update_time = now()
where self_external_userid = #{oldExternalUserId}
and wx_enterprise_id = #{wxEnterpriseId}
</update>
<select id="listByWxEnterpriseId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_member_unionid_related
where wx_enterprise_id = #{wxEnterpriseId}
and status_flag = 1
</select>
<update id="updateExternalUseridByWxEnterpriseId">
UPDATE
tab_haoban_member_unionid_related
SET self_external_userid = external_userid,
update_time = now()
where wx_enterprise_id = #{wxEnterpriseId}
</update>
</mapper>
\ No newline at end of file
......@@ -347,4 +347,13 @@
where status_flag = 1
and wx_enterprise_id = #{wxEnterpriseId} and staff_id = #{staffId}
</select>
<update id="updateUserIdByWxEnterpriseId" parameterType="java.lang.String">
UPDATE tab_haoban_staff_department_related a
LEFT JOIN tab_haoban_staff b ON a.staff_id = b.staff_id
SET a.wx_user_id = b.wx_user_id,update_time= now()
WHERE
a.wx_enterprise_id = #{wxEnterpriseId}
AND a.status_flag = 1 and b.status_flag = 1;
</update>
</mapper>
\ No newline at end of file
......@@ -506,5 +506,22 @@
and status_flag = 1
and staff_id != #{staffId}
</update>
<select id="listByWxEnterpriseId" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List"/>
from tab_haoban_staff
and wx_enterprise_id = #{wxEnterpriseId}
and status_flag = 1
</select>
<update id="updateUserIdByUserId" parameterType="java.lang.String">
update tab_haoban_staff
set wx_user_id = #{newWxUserId},
update_time = now()
where wx_enterprise_id = #{wxEnterpriseId}
and wx_user_id = #{oldWxUserId}
</update>
</mapper>
\ No newline at end of file
......@@ -570,7 +570,8 @@
SET member_id=#{memberId},
status_flag = 1,
update_time = now()
where member_id = #{oldMemberId} and enterprise_id = #{enterpriseId}
where member_id = #{oldMemberId}
and enterprise_id = #{enterpriseId}
</update>
<update id="updateStatusByMemberId">
......@@ -601,7 +602,8 @@
external_user_id
from tab_haoban_external_clerk_related
where wx_enterprise_id = #{wxEnterpriseId}
AND status_flag = 1 and external_user_id is not null
AND status_flag = 1
and external_user_id is not null
</select>
......@@ -618,10 +620,10 @@
select count(*)
from tab_haoban_external_clerk_related
where wx_enterprise_id = #{wxEnterpriseId}
and enterprise_id = #{enterpriseId}
and wx_user_id = #{wxUserId}
and clerk_id = #{clerkId}
AND status_flag = 1
and enterprise_id = #{enterpriseId}
and wx_user_id = #{wxUserId}
and clerk_id = #{clerkId}
AND status_flag = 1
</select>
......@@ -674,10 +676,19 @@
order by create_time desc limit 1
</select>
<select id="countByMemberId" resultType="int">
select
count(*)
select count(*)
from tab_haoban_external_clerk_related
where enterprise_id = #{enterpriseId} and member_id = #{memberId}
and status_flag = 1
where enterprise_id = #{enterpriseId}
and member_id = #{memberId}
and status_flag = 1
</select>
<update id="updateUserIdByWxEnterpriseId">
UPDATE tab_haoban_external_clerk_related a
LEFT JOIN tab_haoban_staff b ON a.staff_id = b.staff_id
SET a.wx_user_id = b.wx_user_id,update_time= now()
WHERE
a.wx_enterprise_id = #{wxEnterpriseId}
AND a.status_flag IN ( 1, 3, 4 );
</update>
</mapper>
\ No newline at end of file
......@@ -440,4 +440,13 @@
</foreach>;
</select>
<update id="updateUserIdByWxEnterpriseId" parameterType="java.lang.String">
UPDATE tab_haoban_staff_clerk_relation a
LEFT JOIN tab_haoban_staff b ON a.staff_id = b.staff_id
SET a.wx_user_id = b.wx_user_id,update_time= now()
WHERE
a.wx_enterprise_id = #{wxEnterpriseId}
AND a.status_flag = 1 and b.status_flag = 1
</update>
</mapper>
\ No newline at end of file
......@@ -202,4 +202,13 @@
</if>
limit 1
</select>
<update id="updateCorpidById">
update tab_haoban_wx_application
set corpid = #{corpId},
update_time = now()
where wx_application_id = #{wxApplicationId}
and status_flag = 1
</update>
</mapper>
\ No newline at end of file
......@@ -472,9 +472,18 @@
<update id="updateExternalFlagById">
update tab_haoban_wx_enterprise
set external_flag = #{externalFlag},
update_time = now()
update_time = now()
where wx_enterprise_id = #{wxEnterpriseId}
</update>
<update id="updateUseridFlagById">
update tab_haoban_wx_enterprise
set userid_flag = #{externalFlag},
<if test="corpid != null">
corpid = #{corpid},
</if>
update_time = now()
where wx_enterprise_id = #{wxEnterpriseId}
</update>
</mapper>
\ No newline at end of file
......@@ -7,6 +7,7 @@ import com.gic.haoban.common.utils.EntityUtil;
import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.manage.api.dto.*;
import com.gic.haoban.manage.api.service.*;
import com.gic.haoban.manage.web.config.Config;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.qo.QywxXcxSendMessageQo;
import com.gic.redis.data.util.GicRateLimiter;
......@@ -28,6 +29,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ExecutorService;
......@@ -77,6 +79,8 @@ public class TestController extends WebBaseController {
private StaffApiService staffApiService;
@Autowired
private WxApplicationApiService wxApplicationApiService;
@Autowired
private Config config;
@RequestMapping("/send-message-test")
public HaobanResponse testSendMessage(QywxXcxSendMessageQo qo) {
......@@ -289,4 +293,32 @@ public class TestController extends WebBaseController {
}
return qywxNewUseridDTOS.get(0).getOpen_userid();
}
/**
* 代开发完成升级
* @param corpid
* @param agentid
* @param openidType
* @return
*/
@RequestMapping("/finishOpenidMigration")
public HaobanResponse finishOpenidMigration(String corpid, String agentid, String openidType) {
String[] openidTypeSplit = openidType.split(",");
boolean flag = qywxUserApiService.finishOpenidMigration(corpid, config.getCorpid(), agentid, openidTypeSplit);
return resultResponse(HaoBanErrCode.ERR_1, flag);
}
/**
* 转自建userid
* @param corpid
* @param secret
* @param userIds
* @return
*/
@RequestMapping("/getSelfUseridToOpenuserid")
public HaobanResponse getSelfUseridToOpenuserid(String corpid, String secret, String userIds) {
String[] split = userIds.split(",");
List<QywxNewUseridDTO> list = qywxUserApiService.getSelfUseridToOpenuserid(corpid, secret, Arrays.asList(split));
return resultResponse(HaoBanErrCode.ERR_1, list);
}
}
......@@ -135,11 +135,14 @@ public class WxEnterpriseInfoController extends WebBaseController {
return resultResponse(HaoBanErrCode.ERR_1, wellDoneLoginInfoVo);
}
if (StringUtils.isNotBlank(loginStaff.getPhoneNumber())) {
DictDTO loginUserId = managerDictService.getSMSDict("app_login_phone_num", loginStaff.getPhoneNumber());
logger.info("伪登录:{},userId:{}", loginStaff.getPhoneNumber(), JSONObject.toJSONString(loginUserId));
if (null != loginUserId) {
String dictValue = loginUserId.getDictValue();
if (StringUtils.isNotBlank(loginStaff.getPhoneNumber()) || StringUtils.isNotBlank(loginStaff.getWxOpenUseId())) {
DictDTO loginUserDict = managerDictService.getSMSDict("app_login_phone_num", loginStaff.getPhoneNumber());
if(null == loginUserDict) {
loginUserDict = managerDictService.getSMSDict("app_login_phone_num", loginStaff.getWxOpenUseId());
}
logger.info("伪登录:{}userId:{},loginUser={}", loginStaff.getPhoneNumber(),loginStaff.getWxOpenUseId(), JSONObject.toJSONString(loginUserDict));
if (null != loginUserDict) {
String dictValue = loginUserDict.getDictValue();
List<StaffDTO> staffDTOS = new ArrayList<>();
List<StaffDTO> phoneDtos = staffApiService.listByPhoneNumber(dictValue);
List<StaffDTO> userDtos = staffApiService.listByWxUserId(dictValue,loginStaff.getWxEnterpriseId());
......@@ -151,7 +154,7 @@ public class WxEnterpriseInfoController extends WebBaseController {
}
if (CollectionUtils.isNotEmpty(staffDTOS)) {
if (staffDTOS.size() > 1) {
String dictName = loginUserId.getDictName();
String dictName = loginUserDict.getDictName();
loginStaff = staffDTOS.stream().filter(staffDTO -> dictName.indexOf(staffDTO.getWxEnterpriseId()) > 0).findFirst().orElse(loginStaff);
} else {
loginStaff = staffDTOS.get(0);
......@@ -228,13 +231,6 @@ public class WxEnterpriseInfoController extends WebBaseController {
}
private RestResponse<String> getRefreshTokenResult(String refreshToken) {
if (StringUtils.isBlank(refreshToken)) {
return RestResponse.failure(String.valueOf(HaoBanErrCode.ERR_30010.getCode()), HaoBanErrCode.ERR_30010.getMsg());
}
return RestResponse.successResult(refreshToken);
}
/**
* 刷新token
*
......
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