Commit 415bd64d by qwmqiuwenmin

fix

parent 1f4d59a9
......@@ -62,6 +62,12 @@ public class WxEnterpriseDTO implements Serializable {
private String memberSecret;
private String contactSecret;
private Date wxSecretKeyLastTime;
private Date contactSecretLastTime;
private Date memberSecretLastTime;
private Date createTime;
......@@ -327,7 +333,31 @@ public class WxEnterpriseDTO implements Serializable {
this.contactSecret = contactSecret;
}
public Date getWxSecretKeyLastTime() {
return wxSecretKeyLastTime;
}
public void setWxSecretKeyLastTime(Date wxSecretKeyLastTime) {
this.wxSecretKeyLastTime = wxSecretKeyLastTime;
}
public Date getContactSecretLastTime() {
return contactSecretLastTime;
}
public void setContactSecretLastTime(Date contactSecretLastTime) {
this.contactSecretLastTime = contactSecretLastTime;
}
public Date getMemberSecretLastTime() {
return memberSecretLastTime;
}
public void setMemberSecretLastTime(Date memberSecretLastTime) {
this.memberSecretLastTime = memberSecretLastTime;
}
}
......@@ -21,4 +21,6 @@ public interface MemberUnionidRelatedApiService {
String add(String wxEnterpriseId, String selfExternalUserId, String userId1);
void freshWxFrend(String wxEnterpriseId, String wxUserId);
}
......@@ -61,6 +61,12 @@ public class TabHaobanWxEnterprise implements Serializable {
private String memberSecret;
private String contactSecret;
private Date wxSecretKeyLastTime;
private Date contactSecretLastTime;
private Date memberSecretLastTime;
private Date createTime;
......@@ -316,6 +322,30 @@ public class TabHaobanWxEnterprise implements Serializable {
this.contactSecret = contactSecret;
}
public Date getWxSecretKeyLastTime() {
return wxSecretKeyLastTime;
}
public void setWxSecretKeyLastTime(Date wxSecretKeyLastTime) {
this.wxSecretKeyLastTime = wxSecretKeyLastTime;
}
public Date getContactSecretLastTime() {
return contactSecretLastTime;
}
public void setContactSecretLastTime(Date contactSecretLastTime) {
this.contactSecretLastTime = contactSecretLastTime;
}
public Date getMemberSecretLastTime() {
return memberSecretLastTime;
}
public void setMemberSecretLastTime(Date memberSecretLastTime) {
this.memberSecretLastTime = memberSecretLastTime;
}
......
......@@ -399,26 +399,34 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
List<TabHaobanWxEnterpriseRelated> list = wxEnterpriseRelatedService.getByWxEnterpriseId(wxEnterprise.getWxEnterpriseId());
String unionIdJson = qywxUserApiService.getCorpSelfExternalUseridInfo(wxEnterprise.getCorpid(), wxEnterprise.getWxSecretKey(), selfExternalUserId);
String wxRes = qywxUserApiService.listExternalUserid(wxEnterprise.getCorpid(), config.getSuiteId(), userId1);
JSONObject wxJson = JSON.parseObject(wxRes);
String externalUserId = selfExternalUserId;
// String uJ = qywxUserApiService.getExternalUseridInfo(wxEnterprise.getCorpid(), config.getSuiteId(), externalUserId);
// if(StringUtils.isNotBlank(uJ)){
// JSONObject jo = JSON.parseObject(unionIdJson);
// String external_contact = jo.getString("external_contact");
// String uj_follow_user = jo.getString("follow_user");
// if(StringUtils.isNotBlank(uj_follow_user)){
// JSONArray j = JSON.parseArray(uj_follow_user);
// String uj_userId = "";
// for (Object object : j) {
// String followJson = JSON.toJSONString(object);
// JSONObject follow = JSON.parseObject(followJson);
// uj_userId = follow.getString("userid");
// if(uj_userId.equals(userId1)){
//
// }
// }
// }
// }
if("0".equals(wxJson.getString("errcode"))){
String external_userid = wxJson.getString("external_userid");
JSONArray jsonArr = wxJson.getJSONArray(external_userid);
for (Object externalUserid : jsonArr) {
String uJ = qywxUserApiService.getExternalUseridInfo(wxEnterprise.getCorpid(), config.getSuiteId(), externalUserid.toString());
if(StringUtils.isNotBlank(uJ)){
JSONObject jo = JSON.parseObject(unionIdJson);
String external_contact = jo.getString("external_contact");
String uj_follow_user = jo.getString("follow_user");
if(StringUtils.isNotBlank(uj_follow_user)){
JSONArray j = JSON.parseArray(uj_follow_user);
String uj_userId = "";
for (Object object : j) {
String followJson = JSON.toJSONString(object);
JSONObject follow = JSON.parseObject(followJson);
uj_userId = follow.getString("userid");
if(uj_userId.equals(userId1)){
}
}
}
}
}
}
MemberUnionidRelatedDTO dto = new MemberUnionidRelatedDTO();
log.info("【新增外部联系人回调】unionIdJson={}",JSON.toJSONString(unionIdJson));
String unionId = "";
......@@ -553,4 +561,26 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
List<MemberUnionidRelatedDTO> list = memberUnionRelatedService.getByWxUserIdAndWxEnterpriseId(wxUserId,wxEnterpriseId);
return list;
}
@Override
public void freshWxFrend(String wxEnterpriseId, String wxUserId) {
WxEnterpriseDTO enterprise = wxEnterpriseService.selectById(wxEnterpriseId);
String res = qywxUserApiService.listSelfExternalUserid(enterprise.getCorpid(), enterprise.getWxSecretKey(), wxUserId);
JSONObject json = JSON.parseObject(res);
if("0".equals(json.getString("errcode"))){
String external_userid = json.getString("external_userid");
JSONArray jsonArr = json.getJSONArray(external_userid);
List<MemberUnionidRelatedDTO> list = this.getByWxUserIdAndWxEnterpriseId(wxUserId, wxEnterpriseId);
List<String> externalUserIdList = list.stream().map(student->student.getExternalUserid())
.collect(Collectors.toList());
for (Object object : jsonArr) {
if(externalUserIdList.contains(object.toString())){
continue;
}else{
//String string = qywxUserApiService.getCorpSelfExternalUseridInfo(enterprise.getCorpid(), enterprise.getWxSecretKey(), object.toString());
this.add(wxEnterpriseId, object.toString(), wxUserId);
}
}
}
}
}
......@@ -30,6 +30,9 @@
<result column="level" property="level" jdbcType="INTEGER" />
<result column="contact_flag" property="contactFlag" jdbcType="INTEGER" />
<result column="bind_flag" property="bindFlag" jdbcType="INTEGER" />
<result column="wx_secret_key_last_time" property="wxSecretKeyLastTime" jdbcType="TIMESTAMP" />
<result column="member_secret_last_time" property="memberSecretLastTime" jdbcType="TIMESTAMP"/>
<result column="contact_secret_last_time" property="contactSecretLastTime" jdbcType="TIMESTAMP"/>
<result column="status_flag" property="statusFlag" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
......@@ -38,7 +41,7 @@
wx_enterprise_id, corpid, permanent_code, corp_name, corp_type, corp_square_logo_url,
corp_user_max, corp_full_name, subject_type, verified_end_time, corp_wxqrcode, corp_scale,
corp_industry, corp_sub_industry, location, auth_info, agent, agentid, appid, name,
square_logo_url, round_logo_url, level, bind_flag, status_flag, create_time, update_time,contact_flag,wx_secret_key
square_logo_url, round_logo_url, level, bind_flag, status_flag, create_time, update_time,contact_flag,wx_secret_key,wx_secret_key_last_time,member_secret_last_time,contact_secret_last_time
,member_secret,contact_secret
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
......@@ -350,6 +353,15 @@
<if test="contactSecret != null" >
contact_secret = #{contactSecret,jdbcType=VARCHAR},
</if>
<if test="wxSecretKeyLastTime != null" >
wx_secret_key_last_time = #{wxSecretKeyLastTime,jdbcType=TIMESTAMP},
</if>
<if test="contactSecretLastTime != null" >
contact_secret_last_time = #{contactSecretLastTime,jdbcType=TIMESTAMP},
</if>
<if test="memberSecretLastTime != null" >
member_secret_last_time = #{memberSecretLastTime,jdbcType=TIMESTAMP},
</if>
</set>
where wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR}
</update>
......@@ -383,6 +395,9 @@
create_time = #{createTime,jdbcType=TIMESTAMP},
wx_secret_key = #{wxSecretKey,jdbcType=VARCHAR},
contact_secret = #{contactSecret,jdbcType=VARCHAR},
wx_secret_key_last_time = #{wxSecretKeyLastTime,jdbcType=TIMESTAMP},
contact_secret_last_time = #{contactSecretLastTime,jdbcType=TIMESTAMP},
member_secret_last_time = #{memberSecretLastTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR}
</update>
......
......@@ -83,7 +83,7 @@ public class DepartmentContoller extends WebBaseController{
private StaffDepartmentRelatedApiService staffDepartmentRelatedApiService;
@RequestMapping("department-list")
public HaobanResponse departmentList(String parentId,BasePageInfo pageInfo,String keyWord) {
LoginVO login = (LoginVO) AuthRequestUtil.getSessionUser();
LoginVO login = (LoginVO) AuthRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
logger.info("【部门列表】wxEnterpriseId={}",wxEnterpriseId);
......
......@@ -338,16 +338,18 @@ public class ClerkController extends WebBaseController{
//刷新微信好友
@RequestMapping("/fresh-wx-friend")
public HaobanResponse freshWxFrend(String staffId,String storeId,String wxEnterpriseId,String staffDepartmentRelatedId,String wxUserId) {
// StaffDTO staff = staffApiService.selectById(staffId);
// String yyyyMM = DateUtil.dateToStr(new Date(), "yyyyMM");
// if(staff == null){
// return resultResponse(HaoBanErrCode.ERR_10006);
// }
// String key = "haoban_fresh_wx_friend" + yyyyMM + staffId;
// Integer count = RedisUtil.getCache(key) == null ? 0 : (Integer)RedisUtil.getCache(key);
// if(count == null || count < 4){
// WxEnterpriseDTO enterprise = wxEnterpriseApiService.getOne(wxEnterpriseId);
// RedisUtil.setCache(key,count + 1,31 * 24 * 60 * 60l);
StaffDTO staff = staffApiService.selectById(staffId);
String yyyyMM = DateUtil.dateToStr(new Date(), "yyyyMM");
if(staff == null){
return resultResponse(HaoBanErrCode.ERR_10006);
}
String key = "haoban_fresh_wx_friend" + yyyyMM + staffId;
Integer count = RedisUtil.getCache(key) == null ? 0 : (Integer)RedisUtil.getCache(key);
if(count == null || count < 4){
WxEnterpriseDTO enterprise = wxEnterpriseApiService.getOne(wxEnterpriseId);
RedisUtil.setCache(key,count + 1,31 * 24 * 60 * 60l);
memberUnionidRelatedApiService.freshWxFrend(wxEnterpriseId, wxUserId);
// String res = qywxUserApiService.listSelfExternalUserid(enterprise.getCorpid(), enterprise.getWxSecretKey(), staff.getWxUserId());
// JSONObject json = JSON.parseObject(res);
// if("0".equals(json.getString("errcode"))){
......@@ -365,9 +367,9 @@ public class ClerkController extends WebBaseController{
// }
// }
// }
// }else{
// return resultResponse(HaoBanErrCode.ERR_10011);
// }
}else{
return resultResponse(HaoBanErrCode.ERR_10011);
}
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