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);
} }
......
...@@ -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,6 +191,7 @@ public enum HaoBanErrCode { ...@@ -191,6 +191,7 @@ 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,"成员已存在"),
......
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