Commit 31a6a76c by qwmqiuwenmin

fix

parent 0ccc09d8
......@@ -309,6 +309,9 @@ public class StaffApiServiceImpl implements StaffApiService {
if(enterpriseDTO != null) {
Date now = new Date();
UserDTO user = qywxUserApiService.getSelfWorkWxUser(enterpriseDTO.getCorpid(), enterpriseDTO.getContactSecret(), userId);
if(user == null){
return;
}
logger.info("【新增用户】user={}",JSON.toJSONString(user));
TabHaobanStaff tab = new TabHaobanStaff();
tab.setWxUserId(userId);
......
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.JSONResponse;
import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService;
import com.gic.redis.data.util.RedisUtil;
import com.gic.wechat.api.dto.qywx.DepartmentDTO;
import com.gic.wechat.api.dto.qywx.QywxXcxSendMessageDTO;
import com.gic.wechat.api.dto.qywx.UserDTO;
import com.gic.wechat.api.service.qywx.QywxDepartmentApiService;
import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
......@@ -35,98 +36,98 @@ public class ServiceTest {
@Test
public void test() {
//wxEnterpriseRelatedApiService.listEnterpriseByWxEnterpriseId("073e89a37eb14acabf258e59a57359b6");
System.err.println(RedisUtil.getCache("init-enterprise-ca66a01b79474c40b3e7c7f93daf1a3b"));
}
@Test
public void test1() {
String res = qywxUserApiService.leaveClerkExternal("ww9ede832a84b7ae5f"
, "01YQ-pcdYzF3K0So8uCFfkB5i8D5EBW7KcVB4qA8Ktk", 0, 1000);
JSONArray jsonArray = JSONArray.parseArray(res);
jsonArray.forEach(o -> {
JSONObject mid = (JSONObject) o;
qywxUserApiService.leaveClerkReTransfer("ww9ede832a84b7ae5f"
, "01YQ-pcdYzF3K0So8uCFfkB5i8D5EBW7KcVB4qA8Ktk", mid.getString("handover_userid")
, mid.getString("handover_userid"), mid.getString("external_userid"));
});
System.out.println(res);
}
@Test
public void test2() {
UserDTO userDTO = new UserDTO();
userDTO.setUserid("niweizhong");
userDTO.setName("空闻大师");
userDTO.setDepartment(new Integer[]{4});
userDTO.setMobile("17605628855");
userDTO.setCorpid("ww9ede832a84b7ae5f");
JSONResponse workWxUser = qywxUserApiService.createWorkWxUser(userDTO, "ww9ede832a84b7ae5f", "ww7d6566614055cf27");
System.out.println(JSONObject.toJSONString(workWxUser));
}
@Test
public void list() {
List<DepartmentDTO> list = qywxDepartmentApiService.listSelfDepartment("ww9ede832a84b7ae5f"
, "3aOw7jbcHlHkDmOi5TuG42Ta8NqskOhZxy5urrmaGl8", 1);
Iterator<DepartmentDTO> iterator = list.iterator();
// while (iterator.hasNext()) {
// DepartmentDTO next = iterator.next();
// if(!next.getParentid().equals("1")) {
// iterator.remove();
// }
// }
System.out.println(JSONObject.toJSONString(list));
}
@Test
public void addDepart() {
DepartmentDTO dto = new DepartmentDTO();
// dto.set
// JSONResponse department = qywxDepartmentApiService.createDepartment("ww9ede832a84b7ae5f"
// , "ww7d6566614055cf27", null);
// List<DepartmentDTO> list = (List<DepartmentDTO>) department;
// System.out.println(JSONObject.toJSONString(list));
}
@Test
public void getUser() {
DepartmentDTO dto = new DepartmentDTO();
// dto.set
UserDTO phonenumber = qywxUserApiService.getWxUserByPhonenumber("ww9ede832a84b7ae5f"
, "ww7d6566614055cf27", "13735457631");
// String phonenumber = phonenumber;
// UserDTO phonenumber = (UserDTO) useridBymobile;
System.out.println(JSONObject.toJSONString(phonenumber));
}
@Test
public void createSelfUser() {
UserDTO userDTO = new UserDTO();
userDTO.setUserid("niweizhong2");
userDTO.setName("空闻大师2");
userDTO.setDepartment(new Integer[]{5072});
userDTO.setMobile("17605628851");
userDTO.setCorpid("ww9ede832a84b7ae5f");
JSONResponse workWxUser = qywxUserApiService.createSelfWorkWxUser(userDTO, "ww9ede832a84b7ae5f",
"3aOw7jbcHlHkDmOi5TuG42Ta8NqskOhZxy5urrmaGl8");
System.out.println(JSONObject.toJSONString(workWxUser));
}
@Test
public void sendMessage() {
QywxXcxSendMessageDTO messageDTO = new QywxXcxSendMessageDTO();
messageDTO.setAppid("wx6054e7be35015afc");
ArrayList<String> userIDs = new ArrayList<>();
userIDs.add("9ae4c4f1277340a186b16a17d937c72c");
messageDTO.setUserIds(userIDs);
messageDTO.setTitle("我的测试test");
messageDTO.setDescription("我的测试test11111");
boolean ret = qywxSuiteApiService.sendMessage("ww9ede832a84b7ae5f",
"ww2c34dc56739bb105", messageDTO);
System.out.println(JSONObject.toJSONString(ret));
}
// @Test
// public void test1() {
// String res = qywxUserApiService.leaveClerkExternal("ww9ede832a84b7ae5f"
// , "01YQ-pcdYzF3K0So8uCFfkB5i8D5EBW7KcVB4qA8Ktk", 0, 1000);
// JSONArray jsonArray = JSONArray.parseArray(res);
// jsonArray.forEach(o -> {
// JSONObject mid = (JSONObject) o;
// qywxUserApiService.leaveClerkReTransfer("ww9ede832a84b7ae5f"
// , "01YQ-pcdYzF3K0So8uCFfkB5i8D5EBW7KcVB4qA8Ktk", mid.getString("handover_userid")
// , mid.getString("handover_userid"), mid.getString("external_userid"));
// });
// System.out.println(res);
// }
//
// @Test
// public void test2() {
// UserDTO userDTO = new UserDTO();
// userDTO.setUserid("niweizhong");
// userDTO.setName("空闻大师");
// userDTO.setDepartment(new Integer[]{4});
// userDTO.setMobile("17605628855");
// userDTO.setCorpid("ww9ede832a84b7ae5f");
// JSONResponse workWxUser = qywxUserApiService.createWorkWxUser(userDTO, "ww9ede832a84b7ae5f", "ww7d6566614055cf27");
// System.out.println(JSONObject.toJSONString(workWxUser));
// }
//
// @Test
// public void list() {
//
// List<DepartmentDTO> list = qywxDepartmentApiService.listSelfDepartment("ww9ede832a84b7ae5f"
// , "3aOw7jbcHlHkDmOi5TuG42Ta8NqskOhZxy5urrmaGl8", 1);
// Iterator<DepartmentDTO> iterator = list.iterator();
//// while (iterator.hasNext()) {
//// DepartmentDTO next = iterator.next();
//// if(!next.getParentid().equals("1")) {
//// iterator.remove();
//// }
//// }
// System.out.println(JSONObject.toJSONString(list));
// }
//
// @Test
// public void addDepart() {
// DepartmentDTO dto = new DepartmentDTO();
//// dto.set
//// JSONResponse department = qywxDepartmentApiService.createDepartment("ww9ede832a84b7ae5f"
//// , "ww7d6566614055cf27", null);
//// List<DepartmentDTO> list = (List<DepartmentDTO>) department;
//// System.out.println(JSONObject.toJSONString(list));
// }
//
// @Test
// public void getUser() {
// DepartmentDTO dto = new DepartmentDTO();
//// dto.set
// UserDTO phonenumber = qywxUserApiService.getWxUserByPhonenumber("ww9ede832a84b7ae5f"
// , "ww7d6566614055cf27", "13735457631");
//// String phonenumber = phonenumber;
//// UserDTO phonenumber = (UserDTO) useridBymobile;
// System.out.println(JSONObject.toJSONString(phonenumber));
// }
//
// @Test
// public void createSelfUser() {
// UserDTO userDTO = new UserDTO();
// userDTO.setUserid("niweizhong2");
// userDTO.setName("空闻大师2");
// userDTO.setDepartment(new Integer[]{5072});
// userDTO.setMobile("17605628851");
// userDTO.setCorpid("ww9ede832a84b7ae5f");
// JSONResponse workWxUser = qywxUserApiService.createSelfWorkWxUser(userDTO, "ww9ede832a84b7ae5f",
// "3aOw7jbcHlHkDmOi5TuG42Ta8NqskOhZxy5urrmaGl8");
// System.out.println(JSONObject.toJSONString(workWxUser));
// }
//
//
// @Test
// public void sendMessage() {
// QywxXcxSendMessageDTO messageDTO = new QywxXcxSendMessageDTO();
// messageDTO.setAppid("wx6054e7be35015afc");
// ArrayList<String> userIDs = new ArrayList<>();
// userIDs.add("9ae4c4f1277340a186b16a17d937c72c");
// messageDTO.setUserIds(userIDs);
// messageDTO.setTitle("我的测试test");
// messageDTO.setDescription("我的测试test11111");
// boolean ret = qywxSuiteApiService.sendMessage("ww9ede832a84b7ae5f",
// "ww2c34dc56739bb105", messageDTO);
// System.out.println(JSONObject.toJSONString(ret));
// }
}
......@@ -23,12 +23,9 @@ import com.gic.clerk.api.dto.ClerkDTO;
import com.gic.clerk.api.service.ClerkService;
import com.gic.commons.util.DateUtil;
import com.gic.commons.util.EntityUtil;
import com.gic.enterprise.api.dto.EnterpriseDTO;
import com.gic.enterprise.api.dto.StoreDTO;
import com.gic.enterprise.api.service.EnterpriseService;
import com.gic.enterprise.api.service.StoreService;
import com.gic.haoban.app.customer.service.api.service.DistributeApiService;
import com.gic.haoban.base.api.common.ServiceResponse;
import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.communicate.api.service.SyncHaobanToGicServiceApi;
import com.gic.haoban.manage.api.dto.DepartmentDTO;
......@@ -47,7 +44,6 @@ import com.gic.haoban.manage.web.anno.HttpLimit;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.interceptor.WebInterceptor;
import com.gic.haoban.manage.web.vo.ClerkVo;
import com.gic.haoban.manage.web.vo.StoreVO;
import com.gic.redis.data.util.RedisUtil;
import com.gic.wechat.api.service.qywx.QywxUserApiService;
......@@ -169,7 +165,8 @@ public class ClerkController extends WebBaseController{
if(size > 20){
ClerkDTO clerk = clerkService.getClerkByClerkCode(departmentDTO.getEnterpriseId(), related.getClerkCode());
if(clerk != null){
dto.setMemberCount(distributeApiService.getClerkMemberCount(departmentDTO.getEnterpriseId(), clerk.getClerkId(), storeId));
dto.setMemberCount(0);
// dto.setMemberCount(distributeApiService.getClerkMemberCount(departmentDTO.getEnterpriseId(), clerk.getClerkId(), storeId));
}
}else{
dto.setMemberCount(0);
......@@ -305,10 +302,10 @@ public class ClerkController extends WebBaseController{
staffApiService.del(staffDepartmentRelatedId);
}else{
ClerkDTO clerk = clerkService.getClerkByClerkCode(departmentDTO.getEnterpriseId(), related.getClerkCode());
if(clerk != null && distributeApiService.getClerkMemberCount(departmentDTO.getEnterpriseId(), clerk.getClerkId(), storeId) == 0){
syncHaobanToGicServiceApi.delGicClerk(clerk.getClerkId());
staffApiService.del(staffDepartmentRelatedId);
}
// if(clerk != null && distributeApiService.getClerkMemberCount(departmentDTO.getEnterpriseId(), clerk.getClerkId(), storeId) == 0){
// syncHaobanToGicServiceApi.delGicClerk(clerk.getClerkId());
// staffApiService.del(staffDepartmentRelatedId);
// }
}
}
if(flag){
......@@ -341,36 +338,36 @@ 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);
String res = qywxUserApiService.listSelfExternalUserid(enterprise.getCorpid(), enterprise.getWxSecretKey(), staff.getWxUserId());
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 = memberUnionidRelatedApiService.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());
memberUnionidRelatedApiService.add(wxEnterpriseId, object.toString(), wxUserId);
}
}
}
}else{
return resultResponse(HaoBanErrCode.ERR_10011);
}
// 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);
// String res = qywxUserApiService.listSelfExternalUserid(enterprise.getCorpid(), enterprise.getWxSecretKey(), staff.getWxUserId());
// 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 = memberUnionidRelatedApiService.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());
// memberUnionidRelatedApiService.add(wxEnterpriseId, object.toString(), wxUserId);
// }
// }
// }
// }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