Commit e9c1f988 by 墨竹

feat:新增获取员工二维码和openid

parent f734f942
...@@ -94,6 +94,9 @@ public class StaffDTO implements Serializable { ...@@ -94,6 +94,9 @@ public class StaffDTO implements Serializable {
private String wxOpenUseId; private String wxOpenUseId;
private String wxOpenId;
private String qrCode;
public String getClerkId() { public String getClerkId() {
return clerkId; return clerkId;
} }
...@@ -328,4 +331,20 @@ public class StaffDTO implements Serializable { ...@@ -328,4 +331,20 @@ public class StaffDTO implements Serializable {
public void setWxOpenUseId(String wxOpenUseId) { public void setWxOpenUseId(String wxOpenUseId) {
this.wxOpenUseId = wxOpenUseId; this.wxOpenUseId = wxOpenUseId;
} }
public String getWxOpenId() {
return wxOpenId;
}
public void setWxOpenId(String wxOpenId) {
this.wxOpenId = wxOpenId;
}
public String getQrCode() {
return qrCode;
}
public void setQrCode(String qrCode) {
this.qrCode = qrCode;
}
} }
...@@ -46,8 +46,10 @@ public interface StaffApiService { ...@@ -46,8 +46,10 @@ public interface StaffApiService {
int countByDepartmentId(String departmentId); int countByDepartmentId(String departmentId);
@Deprecated
void syncGicClerk(String fieldListString); void syncGicClerk(String fieldListString);
@Deprecated
void addGicClerk(GicClerkDTO clerkDTO); void addGicClerk(GicClerkDTO clerkDTO);
StaffDepartmentRelatedDTO getDepartmentIdAndCode(String departmentId, String code); StaffDepartmentRelatedDTO getDepartmentIdAndCode(String departmentId, String code);
...@@ -157,4 +159,33 @@ public interface StaffApiService { ...@@ -157,4 +159,33 @@ public interface StaffApiService {
* @date 2021-12-21 19:53:30 * @date 2021-12-21 19:53:30
*/ */
int updateOpenUserIdsByUserId(String wxEnterpriseId, String wxUserId, String wxOpenUseId); int updateOpenUserIdsByUserId(String wxEnterpriseId, String wxUserId, String wxOpenUseId);
/**
* 更新开放id员工id
*
* @param staffId 员工id
* @param openId 开放id
* @return int
*/
int updateOpenIdByStaffId(String staffId, String openId);
/**
* 更新二维码通过员工id
*
* @param staffId 员工id
* @param qrCode 二维码
* @return int
*/
int updateQrCodeByStaffId(String staffId, String qrCode);
/**
* 获取职员id二维码
*
* @param clerkId 职员id
* @return {@link String}
*/
String getQrCodeByClerkId(String clerkId);
} }
...@@ -93,4 +93,22 @@ public interface StaffMapper { ...@@ -93,4 +93,22 @@ public interface StaffMapper {
*/ */
TabHaobanStaff selectByOpenUserIdAndEnterpriseId(@Param("wxOpenUseId") String wxOpenUseId, TabHaobanStaff selectByOpenUserIdAndEnterpriseId(@Param("wxOpenUseId") String wxOpenUseId,
@Param("wxEnterpriseId") String wxEnterpriseId); @Param("wxEnterpriseId") String wxEnterpriseId);
/**
* 更新开放id员工id
*
* @param staffId 员工id
* @param openId 开放id
* @return int
*/
int updateOpenIdByStaffId(@Param("staffId") String staffId, @Param("openId") String openId);
/**
* 更新二维码通过员工id
*
* @param staffId 员工id
* @param qrCode 二维码
* @return int
*/
int updateQrCodeByStaffId(@Param("staffId") String staffId, @Param("qrCode") String qrCode);
} }
\ No newline at end of file
...@@ -45,6 +45,9 @@ public class TabHaobanStaff implements Serializable { ...@@ -45,6 +45,9 @@ public class TabHaobanStaff implements Serializable {
private String wxOpenUseId; private String wxOpenUseId;
private String wxOpenId;
private String qrCode;
public String getStaffId() { public String getStaffId() {
return staffId; return staffId;
} }
...@@ -196,4 +199,20 @@ public class TabHaobanStaff implements Serializable { ...@@ -196,4 +199,20 @@ public class TabHaobanStaff implements Serializable {
public void setWxOpenUseId(String wxOpenUseId) { public void setWxOpenUseId(String wxOpenUseId) {
this.wxOpenUseId = wxOpenUseId; this.wxOpenUseId = wxOpenUseId;
} }
public String getWxOpenId() {
return wxOpenId;
}
public void setWxOpenId(String wxOpenId) {
this.wxOpenId = wxOpenId;
}
public String getQrCode() {
return qrCode;
}
public void setQrCode(String qrCode) {
this.qrCode = qrCode;
}
} }
\ No newline at end of file
...@@ -53,16 +53,12 @@ public class StaffServiceImpl implements StaffService { ...@@ -53,16 +53,12 @@ public class StaffServiceImpl implements StaffService {
tab.setStaffId(StringUtil.randomUUID()); tab.setStaffId(StringUtil.randomUUID());
} }
tab.setStatusFlag(1); tab.setStatusFlag(1);
// if(StringUtils.isBlank(tab.getWxUserId())){
// tab.setWxUserId(tab.getStaffId());
// }
mapper.insertSelective(tab); mapper.insertSelective(tab);
return tab.getStaffId(); return tab.getStaffId();
} }
@Override @Override
public Page<TabHaobanStaff> pageStaff(Set<String> staffIds, Integer activeFlag, String keyword) { public Page<TabHaobanStaff> pageStaff(Set<String> staffIds, Integer activeFlag, String keyword) {
return mapper.pageStaff(staffIds, activeFlag, keyword); return mapper.pageStaff(staffIds, activeFlag, keyword);
} }
......
...@@ -58,11 +58,11 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -58,11 +58,11 @@ public class StaffApiServiceImpl implements StaffApiService {
private static final Logger logger = LoggerFactory.getLogger(StaffApiServiceImpl.class); private static final Logger logger = LoggerFactory.getLogger(StaffApiServiceImpl.class);
@Autowired @Autowired
StaffService staffService; private StaffService staffService;
@Autowired @Autowired
StaffMapper staffMapper; private StaffMapper staffMapper;
@Autowired @Autowired
StaffDepartmentRelatedService staffDepartmentRelatedService; private StaffDepartmentRelatedService staffDepartmentRelatedService;
@Autowired @Autowired
private StaffDepartmentRelatedMapper staffDepartmentRelatedMapper; private StaffDepartmentRelatedMapper staffDepartmentRelatedMapper;
...@@ -218,7 +218,7 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -218,7 +218,7 @@ public class StaffApiServiceImpl implements StaffApiService {
// 当前部门的所有员工id列表 // 当前部门的所有员工id列表
Set<String> staffIdSet = list.stream().map(TabHaobanStaffDepartmentRelated::getStaffId).collect(Collectors.toSet()); Set<String> staffIdSet = list.stream().map(TabHaobanStaffDepartmentRelated::getStaffId).collect(Collectors.toSet());
// 查询当前部门所有已关联导购的员工id列表 // 查询当前部门所有已关联导购的员工id列表
List<String> relationsStaffIdList = staffClerkRelationService.listRelationsStaffId(staffIdSet); List<String> relationsStaffIdList = staffClerkRelationService.listRelationsStaffId(staffIdSet);
Set<String> relationStaffSet = new HashSet<>(relationsStaffIdList); Set<String> relationStaffSet = new HashSet<>(relationsStaffIdList);
...@@ -235,19 +235,19 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -235,19 +235,19 @@ public class StaffApiServiceImpl implements StaffApiService {
PageHelper.startPage(pageInfo.getPageNum(), pageInfo.getPageSize()); PageHelper.startPage(pageInfo.getPageNum(), pageInfo.getPageSize());
Page<StaffDTO> page = PageUtil.changePageHelperToCurrentPage(staffService.pageStaff(queryStaffSet, activeFlag, ""), StaffDTO.class); Page<StaffDTO> page = PageUtil.changePageHelperToCurrentPage(staffService.pageStaff(queryStaffSet, activeFlag, ""), StaffDTO.class);
if (CollectionUtils.isEmpty(page.getResult())) { if (CollectionUtils.isEmpty(page.getResult())) {
return new Page<>(); return new Page<>();
} }
Map<String, TabHaobanStaffDepartmentRelated> map = list.stream() Map<String, TabHaobanStaffDepartmentRelated> map = list.stream()
.collect(Collectors.toMap(TabHaobanStaffDepartmentRelated::getStaffId, Function.identity(), (s1, s2) -> s2)); .collect(Collectors.toMap(TabHaobanStaffDepartmentRelated::getStaffId, Function.identity(), (s1, s2) -> s2));
page.getResult().forEach(one -> { page.getResult().forEach(one -> {
TabHaobanStaffDepartmentRelated related = map.get(one.getStaffId()); TabHaobanStaffDepartmentRelated related = map.get(one.getStaffId());
one.setDepartmentIds(Objects.isNull(related) ? null : related.getDepartmentId()); one.setDepartmentIds(Objects.isNull(related) ? null : related.getDepartmentId());
// 关联状态 // 关联状态
one.setRelationFlag(relationStaffSet.contains(one.getStaffId()) ? 1 : 0); one.setRelationFlag(relationStaffSet.contains(one.getStaffId()) ? 1 : 0);
}); });
return page; return page;
} }
...@@ -409,6 +409,10 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -409,6 +409,10 @@ public class StaffApiServiceImpl implements StaffApiService {
staff.setSex(user.getGender() == null ? 1 : Integer.parseInt(user.getGender())); staff.setSex(user.getGender() == null ? 1 : Integer.parseInt(user.getGender()));
staff.setPostion(user.getPosition()); staff.setPostion(user.getPosition());
staff.setExtendPostion(user.getExternal_position()); staff.setExtendPostion(user.getExternal_position());
String qr_code = user.getQr_code();
if (StringUtils.isNotBlank(qr_code)) {
staff.setQrCode(qr_code);
}
//成员更改或更新 //成员更改或更新
if (StringUtils.isBlank(staff.getStaffId())) { if (StringUtils.isBlank(staff.getStaffId())) {
logger.info("新增成员"); logger.info("新增成员");
...@@ -529,7 +533,7 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -529,7 +533,7 @@ public class StaffApiServiceImpl implements StaffApiService {
@Override @Override
public void wxGetAdd(String userId, String wxEnterpriseId) { public void wxGetAdd(String userId, String wxEnterpriseId) {
RedisUtil.lock("haoban_add_user" + wxEnterpriseId + userId, 2l); RedisUtil.lock("haoban_add_user" + wxEnterpriseId + userId, 2L);
ServiceResponse wxSaveNew = getWxSaveNew(userId, wxEnterpriseId); ServiceResponse wxSaveNew = getWxSaveNew(userId, wxEnterpriseId);
logger.info("信息:{}", JSONObject.toJSONString(wxSaveNew)); logger.info("信息:{}", JSONObject.toJSONString(wxSaveNew));
} }
...@@ -537,7 +541,6 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -537,7 +541,6 @@ public class StaffApiServiceImpl implements StaffApiService {
@Deprecated @Deprecated
public void wxGetAddOld(String userId, String wxEnterpriseId) { public void wxGetAddOld(String userId, String wxEnterpriseId) {
//获取微信用户信息 //获取微信用户信息
TabHaobanStaff staff = staffService.selectByUserIdAndEnterpriseId(userId, wxEnterpriseId); TabHaobanStaff staff = staffService.selectByUserIdAndEnterpriseId(userId, wxEnterpriseId);
if (staff == null) { if (staff == null) {
WxEnterpriseDTO enterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId); WxEnterpriseDTO enterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId);
...@@ -692,28 +695,6 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -692,28 +695,6 @@ public class StaffApiServiceImpl implements StaffApiService {
} else { } else {
tab.setActiveFlag(0); tab.setActiveFlag(0);
} }
String staffId = staffService.add(tab);
// Integer[] departmentId = user.getDepartment();
// for (Integer integer : departmentId) {
// TabHaobanDepartment tabDepartment = departmentService.getByWxId(integer.toString(), wxEnterpriseId);
// if(tabDepartment != null){
// TabHaobanStaffDepartmentRelated tabStaff = staffDepartmentRelatedService.getDepartmentIdAndStaffId(tabDepartment.getDepartmentId(), tab.getStaffId());
// if(tabStaff == null){
// StaffDepartmentRelatedDTO dto = new StaffDepartmentRelatedDTO();
// dto.setPhoneNumber(user.getMobile());
// dto.setWxUserId(userId);
// dto.setStaffId(staffId);
// dto.setStaffName(user.getName());
// dto.setWxEnterpriseId(wxEnterpriseId);
// dto.setStatusFlag(1);
// dto.setDepartmentId(tabDepartment.getDepartmentId());
// dto.setNationCode("86");
// dto.setStaffName(user.getName());
// staffDepartmentRelatedService.add(dto);
// }
// }
// }
} }
} else { } else {
WxEnterpriseDTO enterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId); WxEnterpriseDTO enterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId);
...@@ -734,7 +715,6 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -734,7 +715,6 @@ public class StaffApiServiceImpl implements StaffApiService {
StaffDTO staffDTO = EntityUtil.changeEntityByJSON(StaffDTO.class, staff); StaffDTO staffDTO = EntityUtil.changeEntityByJSON(StaffDTO.class, staff);
staffDTO.setWeixinPush(true); staffDTO.setWeixinPush(true);
this.staffEdit(staffDTO, departmentIds); this.staffEdit(staffDTO, departmentIds);
//String staffId = staffService.add(tab);
} }
} }
} }
...@@ -780,9 +760,6 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -780,9 +760,6 @@ public class StaffApiServiceImpl implements StaffApiService {
related.setStaffName(staffName); related.setStaffName(staffName);
staffDepartmentRelatedMapper.updateByPrimaryKeySelective(related); staffDepartmentRelatedMapper.updateByPrimaryKeySelective(related);
} }
// if (!syncGic) {
// updateGicClerk(oldStaff, staffDTO, addId, related);
// }
} }
} }
} }
...@@ -796,9 +773,6 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -796,9 +773,6 @@ public class StaffApiServiceImpl implements StaffApiService {
logger.info("【员工修改删除】tab1.getDepartmentId()={}", tab1.getDepartmentId()); logger.info("【员工修改删除】tab1.getDepartmentId()={}", tab1.getDepartmentId());
StaffDepartmentRelatedDTO related = EntityUtil.changeEntityByJSON(StaffDepartmentRelatedDTO.class, tab1); StaffDepartmentRelatedDTO related = EntityUtil.changeEntityByJSON(StaffDepartmentRelatedDTO.class, tab1);
staffDepartmentRelatedService.del(related); staffDepartmentRelatedService.del(related);
// if(org.apache.commons.lang3.StringUtils.isNotBlank(tab1.getClerkCode())){
// cleanGicClerk(tab1.getClerkCode(), tab1.getDepartmentId());
// }
} }
} }
...@@ -808,12 +782,14 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -808,12 +782,14 @@ public class StaffApiServiceImpl implements StaffApiService {
} }
} }
@Deprecated
private void wxStaffEdit(StaffDTO staffDTO, String departmentIds) { private void wxStaffEdit(StaffDTO staffDTO, String departmentIds) {
staffDTO.setWeixinPush(true); staffDTO.setWeixinPush(true);
staffEditDeal(staffDTO, departmentIds, false); staffEditDeal(staffDTO, departmentIds, false);
} }
@Deprecated
private void updateGicClerk(TabHaobanStaff oldStaff, StaffDTO staffDTO, String departmentId, TabHaobanStaffDepartmentRelated related) { private void updateGicClerk(TabHaobanStaff oldStaff, StaffDTO staffDTO, String departmentId, TabHaobanStaffDepartmentRelated related) {
logger.info("【员工修改】oldName={},name={},oldPhoneNumber={},phoneNumber={}", oldStaff.getStaffName(), staffDTO.getStaffName(), oldStaff.getPhoneNumber(), staffDTO.getPhoneNumber()); logger.info("【员工修改】oldName={},name={},oldPhoneNumber={},phoneNumber={}", oldStaff.getStaffName(), staffDTO.getStaffName(), oldStaff.getPhoneNumber(), staffDTO.getPhoneNumber());
String staffName = staffDTO.getStaffName(); String staffName = staffDTO.getStaffName();
...@@ -920,7 +896,6 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -920,7 +896,6 @@ public class StaffApiServiceImpl implements StaffApiService {
@Override @Override
public int countByDepartmentId(String departmentId) { public int countByDepartmentId(String departmentId) {
return staffDepartmentRelatedService.countByDepartmentId(departmentId); return staffDepartmentRelatedService.countByDepartmentId(departmentId);
} }
...@@ -934,18 +909,15 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -934,18 +909,15 @@ public class StaffApiServiceImpl implements StaffApiService {
public void addGicClerk(GicClerkDTO clerkDTO) { public void addGicClerk(GicClerkDTO clerkDTO) {
logger.info("同步gic店员:{}", JSONObject.toJSONString(clerkDTO)); logger.info("同步gic店员:{}", JSONObject.toJSONString(clerkDTO));
addClerkByGic(clerkDTO); addClerkByGic(clerkDTO);
} }
@Override @Override
public void syncGicClerk(String fieldListString) { public void syncGicClerk(String fieldListString) {
// logger.info("【同步店员】fieldList={}", fieldListString);
List<SyncJsonColumnDTO> fieldList = JSONArray.parseArray(fieldListString, SyncJsonColumnDTO.class); List<SyncJsonColumnDTO> fieldList = JSONArray.parseArray(fieldListString, SyncJsonColumnDTO.class);
if (fieldList.isEmpty() || true) { if (fieldList.isEmpty() || true) {
return; return;
} }
} }
...@@ -963,7 +935,6 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -963,7 +935,6 @@ public class StaffApiServiceImpl implements StaffApiService {
status = 1; status = 1;
} }
String postion = clerkDTO.getPostionName(); String postion = clerkDTO.getPostionName();
String enterpriseId = clerkDTO.getEnterpriseId();
if (StringUtils.isBlank(gicStoreId)) { if (StringUtils.isBlank(gicStoreId)) {
logger.info("【店员同步】gicStoreId为空"); logger.info("【店员同步】gicStoreId为空");
...@@ -976,7 +947,6 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -976,7 +947,6 @@ public class StaffApiServiceImpl implements StaffApiService {
} }
String departmentId = department.getDepartmentId(); String departmentId = department.getDepartmentId();
String wxEnterpriseId = department.getWxEnterpriseId(); String wxEnterpriseId = department.getWxEnterpriseId();
// StaffDTO staff = this.selectByNationcodeAndPhoneNumber(wxEnterpriseId, nationcode, phoneNumber);
StaffDTO staff = geCcheckAndInitUser(wxEnterpriseId, nationcode, phoneNumber); StaffDTO staff = geCcheckAndInitUser(wxEnterpriseId, nationcode, phoneNumber);
if (staff == null) { if (staff == null) {
if (status != 1) { if (status != 1) {
...@@ -1028,8 +998,6 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -1028,8 +998,6 @@ public class StaffApiServiceImpl implements StaffApiService {
} else { } else {
staff.setHeadImg(headPic); staff.setHeadImg(headPic);
staff.setSex(sex); staff.setSex(sex);
//staff.setPostion(postion);
// staff.setStaffName(staffName);
if (staff.getActiveFlag() != null && staff.getActiveFlag() != 1) { if (staff.getActiveFlag() != null && staff.getActiveFlag() != 1) {
staff.setStaffName(staffName); staff.setStaffName(staffName);
} }
...@@ -1062,15 +1030,6 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -1062,15 +1030,6 @@ public class StaffApiServiceImpl implements StaffApiService {
staffRelated.setClerkCode(code); staffRelated.setClerkCode(code);
staffDepartmentRelatedMapper.updateByPrimaryKey(EntityUtil.changeEntityByJSON(TabHaobanStaffDepartmentRelated.class, staffRelated)); staffDepartmentRelatedMapper.updateByPrimaryKey(EntityUtil.changeEntityByJSON(TabHaobanStaffDepartmentRelated.class, staffRelated));
} }
// ClerkDTO clerkDTO= clerkService.getClerkByCodeNoStatus(enterpriseId,code);
// if(clerkDTO != null && (!clerkDTO.getClerkName().equals(staffName) || !staff.getPhoneNumber().equals(clerkDTO.getPhoneNumber()))){
// logger.info("【员工修改】clerkDTO={}",JSON.toJSONString(clerkDTO));
// clerkDTO.setClerkName(staff.getStaffName());
// clerkDTO.setPhoneNumber(staff.getPhoneNumber());
// clerkService.updateClerk(clerkDTO);
// }
//}
this.staffEditDeal(staff, departmentIds, true); this.staffEditDeal(staff, departmentIds, true);
} }
} }
...@@ -1255,8 +1214,6 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -1255,8 +1214,6 @@ public class StaffApiServiceImpl implements StaffApiService {
} else { } else {
staff.setHeadImg(clerkDTO.getHeadImgUrl()); staff.setHeadImg(clerkDTO.getHeadImgUrl());
staff.setSex(clerkDTO.getClerkGender()); staff.setSex(clerkDTO.getClerkGender());
//staff.setPostion(postion);
// staff.setStaffName(staffName);
if (staff.getActiveFlag() != null && staff.getActiveFlag() != 1) { if (staff.getActiveFlag() != null && staff.getActiveFlag() != 1) {
staff.setStaffName(clerkDTO.getClerkName()); staff.setStaffName(clerkDTO.getClerkName());
} }
...@@ -1397,12 +1354,6 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -1397,12 +1354,6 @@ public class StaffApiServiceImpl implements StaffApiService {
@Override @Override
public List<String> listBindClerkUserId(String storeId) { public List<String> listBindClerkUserId(String storeId) {
// TabHaobanDepartment department = departmentService.selectByRelatedId(storeId);
// if(department == null){
// return Collections.EMPTY_LIST;
// }
// List<TabHaobanStaffDepartmentRelated> list = staffDepartmentRelatedService.listByDepartmentId(department.getDepartmentId());
// List<String> userIdList = list.stream().filter(s->StringUtils.isNotBlank(s.getClerkCode())).map(s->s.getWxUserId()).collect(Collectors.toList());
List<String> userIdList = new ArrayList<String>(); List<String> userIdList = new ArrayList<String>();
List<String> storeIds = new ArrayList<String>(); List<String> storeIds = new ArrayList<String>();
...@@ -1501,4 +1452,55 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -1501,4 +1452,55 @@ public class StaffApiServiceImpl implements StaffApiService {
return staffService.updateOpenUserIdsByUserId(wxEnterpriseId, wxUserId, wxOpenUseId); return staffService.updateOpenUserIdsByUserId(wxEnterpriseId, wxUserId, wxOpenUseId);
} }
@Override
public int updateOpenIdByStaffId(String staffId, String openId) {
return staffMapper.updateOpenIdByStaffId(staffId, openId);
}
@Override
public int updateQrCodeByStaffId(String staffId, String qrCode) {
return staffMapper.updateQrCodeByStaffId(staffId, qrCode);
}
@Override
public String getQrCodeByClerkId(String clerkId) {
StaffClerkRelationDTO staffClerkRelationDTO = staffClerkRelationService.getByClerkId(clerkId);
if (staffClerkRelationDTO == null) {
return "";
}
String staffId = staffClerkRelationDTO.getStaffId();
String wxEnterpriseId = staffClerkRelationDTO.getWxEnterpriseId();
SecretSettingDTO secretSetting = secretSettingService.getSecretSetting(wxEnterpriseId, SecretTypeEnum.HAOBAN_HELP.getVal());
if (null == secretSetting || secretSetting.getCheckFlag() == 0) {
logger.info("没有配置secret:wxEnterpriseId:{}", wxEnterpriseId);
return "";
}
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId);
if (wxEnterpriseDTO == null) {
logger.info("企业不存在:wxEnterpriseId:{}", wxEnterpriseId);
return "";
}
TabHaobanStaff staff = staffService.selectById(staffId);
if (staff == null) {
logger.info("员工不存在:staffId:{}", staffId);
return "";
}
String qrCode = staff.getQrCode();
if (StringUtils.isNotBlank(qrCode)) {
return qrCode;
}
//获取微信信息
String wxUserId = staff.getWxUserId();
UserDTO user = qywxUserApiService.getSelfWorkWxUser(wxEnterpriseDTO.getCorpid(), secretSetting.getSecretVal(), wxUserId);
if (null == user) {
logger.info("企业微信用户不存在:wxEnterpriseId:{}:wxUserId:{}", wxEnterpriseId, wxUserId);
return "";
}
String qr_code = user.getQr_code();
staffMapper.updateQrCodeByStaffId(staffId,qr_code);
return qr_code;
}
} }
...@@ -21,11 +21,14 @@ ...@@ -21,11 +21,14 @@
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/> <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/> <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
<result column="wx_open_user_id" property="wxOpenUseId" jdbcType="VARCHAR"/> <result column="wx_open_user_id" property="wxOpenUseId" jdbcType="VARCHAR"/>
<result column="wx_open_id" property="wxOpenId" jdbcType="VARCHAR"/>
<result column="qr_code" property="qrCode" jdbcType="VARCHAR"/>
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
staff_id, wx_user_id, phone_number, staff_name, nation_code, nick_name, sex, postion, staff_id, wx_user_id, phone_number, staff_name, nation_code, nick_name, sex, postion,
active_flag, extend_postion, status_flag, create_time, update_time,wx_enterprise_id,head_img, active_flag, extend_postion, status_flag, create_time, update_time,wx_enterprise_id,head_img,
sort,sync_postion_flag,super_manager_flag,wx_open_user_id sort,sync_postion_flag,super_manager_flag,wx_open_user_id,wx_open_id,qr_code
</sql> </sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String"> <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String">
select select
...@@ -99,6 +102,12 @@ ...@@ -99,6 +102,12 @@
<if test="wxOpenUseId != null"> <if test="wxOpenUseId != null">
wx_open_user_id, wx_open_user_id,
</if> </if>
<if test="wxOpenId != null">
wx_open_id,
</if>
<if test="qrCode != null">
qr_code,
</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="staffId != null"> <if test="staffId != null">
...@@ -158,6 +167,12 @@ ...@@ -158,6 +167,12 @@
<if test="wxOpenUseId != null"> <if test="wxOpenUseId != null">
#{wxOpenUseId}, #{wxOpenUseId},
</if> </if>
<if test="wxOpenId != null">
#{wxOpenId},
</if>
<if test="qrCode != null">
#{qrCode}
</if>
</trim> </trim>
</insert> </insert>
<update id="updateByPrimaryKeySelective" parameterType="com.gic.haoban.manage.service.entity.TabHaobanStaff"> <update id="updateByPrimaryKeySelective" parameterType="com.gic.haoban.manage.service.entity.TabHaobanStaff">
...@@ -217,6 +232,12 @@ ...@@ -217,6 +232,12 @@
<if test="wxOpenUseId != null"> <if test="wxOpenUseId != null">
wx_open_user_id = #{wxOpenUseId}, wx_open_user_id = #{wxOpenUseId},
</if> </if>
<if test="wxOpenId != null">
wx_open_id = #{wxOpenId},
</if>
<if test="qrCode != null">
qr_code = #{qrCode}
</if>
</set> </set>
where staff_id = #{staffId,jdbcType=VARCHAR} where staff_id = #{staffId,jdbcType=VARCHAR}
</update> </update>
...@@ -415,4 +436,18 @@ ...@@ -415,4 +436,18 @@
and status_flag = 1 limit 1 and status_flag = 1 limit 1
</select> </select>
<update id="updateOpenIdByStaffId" parameterType="com.gic.haoban.manage.service.entity.TabHaobanStaff">
update tab_haoban_staff
set wx_open_id = #{openId},
update_time = now()
where staff_id = #{staffId}
</update>
<update id="updateQrCodeByStaffId" parameterType="com.gic.haoban.manage.service.entity.TabHaobanStaff">
update tab_haoban_staff
set qr_code = #{qrCode},
update_time = now()
where staff_id = #{staffId}
</update>
</mapper> </mapper>
\ No newline at end of file
...@@ -29,11 +29,14 @@ import com.gic.haoban.manage.api.dto.*; ...@@ -29,11 +29,14 @@ import com.gic.haoban.manage.api.dto.*;
import com.gic.haoban.manage.api.enums.*; import com.gic.haoban.manage.api.enums.*;
import com.gic.haoban.manage.api.service.*; import com.gic.haoban.manage.api.service.*;
import com.gic.haoban.manage.api.util.notify.NoticeMessageUtil; import com.gic.haoban.manage.api.util.notify.NoticeMessageUtil;
import com.gic.haoban.manage.web.config.Config;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode; import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.qo.CommonQO; import com.gic.haoban.manage.web.qo.CommonQO;
import com.gic.haoban.manage.web.vo.*; import com.gic.haoban.manage.web.vo.*;
import com.gic.haoban.manage.web.vo.notify.CustomerFriendMemberVO; import com.gic.haoban.manage.web.vo.notify.CustomerFriendMemberVO;
import com.gic.redis.data.util.RedisUtil; import com.gic.redis.data.util.RedisUtil;
import com.gic.wechat.api.service.qywx.QywxCorpApiService;
import com.gic.wechat.api.service.qywx.QywxUserApiService;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -90,6 +93,10 @@ public class ClerkController extends WebBaseController { ...@@ -90,6 +93,10 @@ public class ClerkController extends WebBaseController {
private CustomerApiService customerApiService; private CustomerApiService customerApiService;
@Autowired @Autowired
private WxEnterpriseApiService wxEnterpriseApiService; private WxEnterpriseApiService wxEnterpriseApiService;
@Autowired
private QywxUserApiService qywxUserApiService;
@Autowired
private Config config;
//选择成员列表 //选择成员列表
@RequestMapping("/staff-list") @RequestMapping("/staff-list")
...@@ -1244,7 +1251,6 @@ public class ClerkController extends WebBaseController { ...@@ -1244,7 +1251,6 @@ public class ClerkController extends WebBaseController {
@RequestMapping("can-relation-count") @RequestMapping("can-relation-count")
@IgnoreLogin @IgnoreLogin
public HaobanResponse canRelationCount(@RequestBody @Valid CommonQO qo) { public HaobanResponse canRelationCount(@RequestBody @Valid CommonQO qo) {
List<EnterpriseDetailDTO> list = wxEnterpriseRelatedApiService.listEnterpriseByWxEnterpriseId(qo.getWxEnterpriseId()); List<EnterpriseDetailDTO> list = wxEnterpriseRelatedApiService.listEnterpriseByWxEnterpriseId(qo.getWxEnterpriseId());
if (list == null || list.isEmpty()) { if (list == null || list.isEmpty()) {
return resultResponse(HaoBanErrCode.ERR_1); return resultResponse(HaoBanErrCode.ERR_1);
...@@ -1259,6 +1265,7 @@ public class ClerkController extends WebBaseController { ...@@ -1259,6 +1265,7 @@ public class ClerkController extends WebBaseController {
return resultResponse(HaoBanErrCode.ERR_1, clerkList.size()); return resultResponse(HaoBanErrCode.ERR_1, clerkList.size());
} }
/** /**
* 根据员工id获取openId * 根据员工id获取openId
* *
...@@ -1269,7 +1276,28 @@ public class ClerkController extends WebBaseController { ...@@ -1269,7 +1276,28 @@ public class ClerkController extends WebBaseController {
@RequestMapping("getOpenIdByStaffId") @RequestMapping("getOpenIdByStaffId")
public RestResponse<String> getOpenIdByStaffId() { public RestResponse<String> getOpenIdByStaffId() {
String staffId = this.getLoginUser().getStaffId(); String staffId = this.getLoginUser().getStaffId();
String openId = ""; String wxEnterpriseId = this.getLoginUser().getWxEnterpriseId();
return RestResponse.successResult(openId); StaffDTO staffDTO = staffApiService.selectById(staffId);
if (staffDTO == null) {
int code = HaoBanErrCode.ERR_6.getCode();
return RestResponse.failure(String.valueOf(code),HaoBanErrCode.ERR_6.getMsg());
}
String wxOpenId = staffDTO.getWxOpenId();
if (StringUtils.isNotBlank(wxOpenId)) {
return RestResponse.successResult(wxOpenId);
}
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseApiService.getOne(wxEnterpriseId);
if (wxEnterpriseDTO == null) {
int code = HaoBanErrCode.ERR_400002.getCode();
return RestResponse.failure(String.valueOf(code),HaoBanErrCode.ERR_400002.getMsg());
}
String wxUserId = staffDTO.getWxUserId();
String openid = qywxUserApiService.getSelfOpenIdByUserId(wxEnterpriseDTO.getCorpid(), config.getWxSuiteid(), wxUserId);
if (StringUtils.isBlank(openid)) {
int code = HaoBanErrCode.ERR_600003.getCode();
return RestResponse.failure(String.valueOf(code),HaoBanErrCode.ERR_600003.getMsg());
}
staffApiService.updateOpenIdByStaffId(staffId,openid);
return RestResponse.successResult(openid);
} }
} }
...@@ -191,7 +191,8 @@ public enum HaoBanErrCode { ...@@ -191,7 +191,8 @@ public enum HaoBanErrCode {
ERR_500003(500003, "企业corpid不对应,需要重新登录传code"), ERR_500003(500003, "企业corpid不对应,需要重新登录传code"),
ERR_600001(600001, "成员不存在,请联系管理员后台授权通讯录权限"), ERR_600001(600001, "成员不存在,请联系管理员后台授权通讯录权限"),
ERR_600002(600002, "无手机号"), ERR_600002(600002, "无手机号"),
ERR_600003(600003, "未获取成员openid"),
ERR_10004(10004,"成员名称不能为空"), ERR_10004(10004,"成员名称不能为空"),
ERR_10005(10005,"成员已存在"), ERR_10005(10005,"成员已存在"),
ERR_10006(10006,"成员不存在"), ERR_10006(10006,"成员不存在"),
......
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