Commit df55175f by fudahua

Merge remote-tracking branch 'origin/developer' into developer

parents 9d88ee0e a9878b56
...@@ -120,7 +120,7 @@ public interface DepartmentApiService { ...@@ -120,7 +120,7 @@ public interface DepartmentApiService {
List<DepartmentDTO> listByChainId(String chainId,String wxEnterpriseId); List<DepartmentDTO> listByChainId(String chainId,String wxEnterpriseId);
void initwxDepartment(String corpid, String suiteid, String wxEnterpriseId); void initwxDepartment(String corpid, String contactSecret, String wxEnterpriseId);
/** /**
* 回收站的数量 * 回收站的数量
* @param wxEnterpriseId * @param wxEnterpriseId
......
...@@ -47,7 +47,7 @@ public interface StaffApiService { ...@@ -47,7 +47,7 @@ public interface StaffApiService {
StaffDepartmentRelatedDTO getDepartmentIdAndCode(String departmentId, String code); StaffDepartmentRelatedDTO getDepartmentIdAndCode(String departmentId, String code);
void initWxUser(String corpid, String suiteid, String wxEnterpriseId, Integer wxDepartmentId); void initWxUser(String corpid, String contactSecret, String wxEnterpriseId, Integer wxDepartmentId);
public List<String> listUnBindClerk(String storeId); public List<String> listUnBindClerk(String storeId);
......
...@@ -40,11 +40,9 @@ import com.gic.haoban.manage.api.service.DepartmentApiService; ...@@ -40,11 +40,9 @@ import com.gic.haoban.manage.api.service.DepartmentApiService;
import com.gic.haoban.manage.service.dao.mapper.DepartmentMapper; import com.gic.haoban.manage.service.dao.mapper.DepartmentMapper;
import com.gic.haoban.manage.service.entity.TabHaobanDepartment; import com.gic.haoban.manage.service.entity.TabHaobanDepartment;
import com.gic.haoban.manage.service.entity.TabHaobanStaffDepartmentRelated; import com.gic.haoban.manage.service.entity.TabHaobanStaffDepartmentRelated;
import com.gic.haoban.manage.service.entity.TabHaobanWxApplication;
import com.gic.haoban.manage.service.entity.TabHaobanWxEnterpriseRelated; import com.gic.haoban.manage.service.entity.TabHaobanWxEnterpriseRelated;
import com.gic.haoban.manage.service.service.DepartmentService; import com.gic.haoban.manage.service.service.DepartmentService;
import com.gic.haoban.manage.service.service.StaffDepartmentRelatedService; import com.gic.haoban.manage.service.service.StaffDepartmentRelatedService;
import com.gic.haoban.manage.service.service.WxApplicationService;
import com.gic.haoban.manage.service.service.WxEnterpriseService; import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.wechat.api.service.qywx.QywxDepartmentApiService; import com.gic.wechat.api.service.qywx.QywxDepartmentApiService;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
...@@ -66,8 +64,6 @@ public class DepartmentApiServiceImpl implements DepartmentApiService { ...@@ -66,8 +64,6 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
@Autowired @Autowired
private WxEnterpriseService wxEnterpriseService; private WxEnterpriseService wxEnterpriseService;
@Autowired @Autowired
private WxApplicationService wxApplicationService;
@Autowired
private StoreService storeService; private StoreService storeService;
@Autowired @Autowired
private StoreGroupService storeGroupService; private StoreGroupService storeGroupService;
...@@ -98,39 +94,36 @@ public class DepartmentApiServiceImpl implements DepartmentApiService { ...@@ -98,39 +94,36 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
//调微信的新增接口 //调微信的新增接口
String wxDepartmentId = ""; String wxDepartmentId = "";
WxEnterpriseDTO enterpriseDTO = wxEnterpriseService.selectById(department.getWxEnterpriseId()); WxEnterpriseDTO enterpriseDTO = wxEnterpriseService.selectById(department.getWxEnterpriseId());
TabHaobanWxApplication application = wxApplicationService.selectByWxEnterpriseIdAndApplicationType(department.getWxEnterpriseId(),1);
logger.info("【部门新增】enterpriseDTO = {}",JSON.toJSONString(enterpriseDTO)); logger.info("【部门新增】enterpriseDTO = {}",JSON.toJSONString(enterpriseDTO));
if(enterpriseDTO != null) { if(enterpriseDTO != null) {
if(application != null) { Integer sort = department.getSort();
Integer sort = department.getSort(); if(sort == null) {
if(sort == null) { int maxSort = departmentMapper.selectMaxSort(department.getParentDepartmentId());
int maxSort = departmentMapper.selectMaxSort(department.getParentDepartmentId()); department.setSort(maxSort + 1);
department.setSort(maxSort + 1);
}
com.gic.wechat.api.dto.qywx.DepartmentDTO dto = new com.gic.wechat.api.dto.qywx.DepartmentDTO();
dto.setCorpid(enterpriseDTO.getCorpid());
dto.setName(department.getDepartmentName());
dto.setOrder(department.getSort());
TabHaobanDepartment parent = departmentService.selectById(department.getParentDepartmentId());
dto.setParentid(Integer.valueOf(parent.getWxDepartmentId()));
logger.info("【部门新增】corpid() = {},siteId={},dto={}",enterpriseDTO.getCorpid(),application.getSiteId(),JSON.toJSONString(dto));
JSONResponse jp = qywxDepartmentApiService.createDepartment(enterpriseDTO.getCorpid(), application.getSiteId(), dto);
logger.info("【部门新增】jp = {}",JSON.toJSONString(jp));
if(jp.getErrorCode() != 0) {
hr.setCode(0);
hr.setMessage("微信新增部门失败");
return hr;
}
wxDepartmentId = jp.getResult().toString();
logger.info("【部门新增】wxDepartmentId = {}",wxDepartmentId);
department.setWxDepartmentId(wxDepartmentId);
department.setLevel(parent.getLevel() + 1);
setGicEnterpriseId(department);
String departmentId = departmentService.add(department);
department.setDepartmentId(departmentId);
hr.setResult(department);
} }
com.gic.wechat.api.dto.qywx.DepartmentDTO dto = new com.gic.wechat.api.dto.qywx.DepartmentDTO();
dto.setCorpid(enterpriseDTO.getCorpid());
dto.setName(department.getDepartmentName());
dto.setOrder(department.getSort());
TabHaobanDepartment parent = departmentService.selectById(department.getParentDepartmentId());
dto.setParentid(Integer.valueOf(parent.getWxDepartmentId()));
logger.info("【部门新增】corpid() = {},siteId={},dto={}",enterpriseDTO.getCorpid(),enterpriseDTO.getContactSecret(),JSON.toJSONString(dto));
JSONResponse jp = qywxDepartmentApiService.createSelfDepartment(enterpriseDTO.getCorpid(), enterpriseDTO.getContactSecret(), dto);
logger.info("【部门新增】jp = {}",JSON.toJSONString(jp));
if(jp.getErrorCode() != 0) {
hr.setCode(0);
hr.setMessage("微信新增部门失败");
return hr;
}
wxDepartmentId = jp.getResult().toString();
logger.info("【部门新增】wxDepartmentId = {}",wxDepartmentId);
department.setWxDepartmentId(wxDepartmentId);
department.setLevel(parent.getLevel() + 1);
setGicEnterpriseId(department);
String departmentId = departmentService.add(department);
department.setDepartmentId(departmentId);
hr.setResult(department);
} }
return hr; return hr;
...@@ -172,23 +165,20 @@ public class DepartmentApiServiceImpl implements DepartmentApiService { ...@@ -172,23 +165,20 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
} }
logger.info("【部门修改】tab={}",JSON.toJSONString(tab)); logger.info("【部门修改】tab={}",JSON.toJSONString(tab));
WxEnterpriseDTO enterpriseDTO = wxEnterpriseService.selectById(tab.getWxEnterpriseId()); WxEnterpriseDTO enterpriseDTO = wxEnterpriseService.selectById(tab.getWxEnterpriseId());
TabHaobanWxApplication application = wxApplicationService.selectByWxEnterpriseIdAndApplicationType(tab.getWxEnterpriseId(),1);
if(enterpriseDTO != null) { if(enterpriseDTO != null) {
if(application != null) { com.gic.wechat.api.dto.qywx.DepartmentDTO dto = new com.gic.wechat.api.dto.qywx.DepartmentDTO();
com.gic.wechat.api.dto.qywx.DepartmentDTO dto = new com.gic.wechat.api.dto.qywx.DepartmentDTO(); dto.setCorpid(enterpriseDTO.getCorpid());
dto.setCorpid(enterpriseDTO.getCorpid()); dto.setName(department.getDepartmentName());
dto.setName(department.getDepartmentName()); dto.setOrder(department.getSort());
dto.setOrder(department.getSort()); TabHaobanDepartment parent = departmentService.selectById(department.getParentDepartmentId());
TabHaobanDepartment parent = departmentService.selectById(department.getParentDepartmentId()); dto.setParentid(Integer.valueOf(parent.getWxDepartmentId()));
dto.setParentid(Integer.valueOf(parent.getWxDepartmentId())); dto.setId(Integer.valueOf(tab.getWxDepartmentId()));
dto.setId(Integer.valueOf(tab.getWxDepartmentId())); JSONResponse jp = qywxDepartmentApiService.updateSelfDepartment(enterpriseDTO.getCorpid(), enterpriseDTO.getContactSecret(), dto);
JSONResponse jp = qywxDepartmentApiService.updateDepartment(enterpriseDTO.getCorpid(), application.getSiteId(), dto); logger.info("【部门修改】jp={}",JSON.toJSONString(jp));
logger.info("【部门修改】jp={}",JSON.toJSONString(jp)); if(jp.getErrorCode() != 0) {
if(jp.getErrorCode() != 0) { hr.setCode(0);
hr.setCode(0); hr.setMessage("微信修改部门失败");
hr.setMessage("微信修改部门失败"); return hr;
return hr;
}
} }
} }
...@@ -224,15 +214,12 @@ public class DepartmentApiServiceImpl implements DepartmentApiService { ...@@ -224,15 +214,12 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
return hr; return hr;
} }
WxEnterpriseDTO enterpriseDTO = wxEnterpriseService.selectById(department.getWxEnterpriseId()); WxEnterpriseDTO enterpriseDTO = wxEnterpriseService.selectById(department.getWxEnterpriseId());
TabHaobanWxApplication application = wxApplicationService.selectByWxEnterpriseIdAndApplicationType(department.getWxEnterpriseId(),1);
if(enterpriseDTO != null) { if(enterpriseDTO != null) {
if(application != null) { JSONResponse jp = qywxDepartmentApiService.deleteSelfDepartment(enterpriseDTO.getCorpid(), enterpriseDTO.getContactSecret(), Integer.parseInt(department.getWxDepartmentId()));
JSONResponse jp = qywxDepartmentApiService.deleteDepartment(enterpriseDTO.getCorpid(), application.getSiteId(), Integer.parseInt(department.getWxDepartmentId())); if(jp.getErrorCode() != 0) {
if(jp.getErrorCode() != 0) { hr.setCode(0);
hr.setCode(0); hr.setMessage("微信删除部门失败");
hr.setMessage("微信删除部门失败"); return hr;
return hr;
}
} }
} }
...@@ -293,15 +280,12 @@ public class DepartmentApiServiceImpl implements DepartmentApiService { ...@@ -293,15 +280,12 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
//调微信的新增接口 //调微信的新增接口
TabHaobanDepartment department = departmentService.selectById(departmentId); TabHaobanDepartment department = departmentService.selectById(departmentId);
WxEnterpriseDTO enterpriseDTO = wxEnterpriseService.selectById(department.getWxEnterpriseId()); WxEnterpriseDTO enterpriseDTO = wxEnterpriseService.selectById(department.getWxEnterpriseId());
TabHaobanWxApplication application = wxApplicationService.selectByWxEnterpriseIdAndApplicationType(department.getWxEnterpriseId(),1);
if(enterpriseDTO != null) { if(enterpriseDTO != null) {
if(application != null) { JSONResponse jp = qywxDepartmentApiService.deleteSelfDepartment(enterpriseDTO.getCorpid(), enterpriseDTO.getContactSecret(), Integer.parseInt(department.getWxDepartmentId()));
JSONResponse jp = qywxDepartmentApiService.deleteDepartment(enterpriseDTO.getCorpid(), application.getSiteId(), Integer.parseInt(department.getWxDepartmentId())); if(jp.getErrorCode() != 0) {
if(jp.getErrorCode() != 0) { hr.setCode(0);
hr.setCode(0); hr.setMessage("微信删除部门失败");
hr.setMessage("微信删除部门失败"); return hr;
return hr;
}
} }
} }
...@@ -349,29 +333,26 @@ public class DepartmentApiServiceImpl implements DepartmentApiService { ...@@ -349,29 +333,26 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
//调微信的新增接口 //调微信的新增接口
String wxDepartmentId = ""; String wxDepartmentId = "";
WxEnterpriseDTO enterpriseDTO = wxEnterpriseService.selectById(tab.getWxEnterpriseId()); WxEnterpriseDTO enterpriseDTO = wxEnterpriseService.selectById(tab.getWxEnterpriseId());
TabHaobanWxApplication application = wxApplicationService.selectByWxEnterpriseIdAndApplicationType(tab.getWxEnterpriseId(),1);
logger.info("【部门新增】enterpriseDTO = {}",JSON.toJSONString(enterpriseDTO)); logger.info("【部门新增】enterpriseDTO = {}",JSON.toJSONString(enterpriseDTO));
if(enterpriseDTO != null) { if(enterpriseDTO != null) {
if(application != null) { com.gic.wechat.api.dto.qywx.DepartmentDTO dto = new com.gic.wechat.api.dto.qywx.DepartmentDTO();
com.gic.wechat.api.dto.qywx.DepartmentDTO dto = new com.gic.wechat.api.dto.qywx.DepartmentDTO(); dto.setCorpid(enterpriseDTO.getCorpid());
dto.setCorpid(enterpriseDTO.getCorpid()); dto.setName(tab.getDepartmentName());
dto.setName(tab.getDepartmentName()); dto.setOrder(tab.getSort());
dto.setOrder(tab.getSort()); TabHaobanDepartment parent = departmentService.selectById(parentId);
TabHaobanDepartment parent = departmentService.selectById(parentId); dto.setParentid(Integer.valueOf(parent.getWxDepartmentId()));
dto.setParentid(Integer.valueOf(parent.getWxDepartmentId())); logger.info("【部门新增】corpid() = {},siteId={},dto={}",enterpriseDTO.getCorpid(),enterpriseDTO.getContactSecret(),JSON.toJSONString(dto));
logger.info("【部门新增】corpid() = {},siteId={},dto={}",enterpriseDTO.getCorpid(),application.getSiteId(),JSON.toJSONString(dto)); JSONResponse jp = qywxDepartmentApiService.createSelfDepartment(enterpriseDTO.getCorpid(), enterpriseDTO.getContactSecret(), dto);
JSONResponse jp = qywxDepartmentApiService.createDepartment(enterpriseDTO.getCorpid(), application.getSiteId(), dto); logger.info("【部门新增】jp = {}",JSON.toJSONString(jp));
logger.info("【部门新增】jp = {}",JSON.toJSONString(jp)); if(jp.getErrorCode() != 0) {
if(jp.getErrorCode() != 0) { hr.setCode(0);
hr.setCode(0); hr.setMessage("微信新增部门失败");
hr.setMessage("微信新增部门失败"); return hr;
return hr;
}
wxDepartmentId = jp.getResult().toString();
tab.setWxDepartmentId(wxDepartmentId);
tab.setParentDepartmentId(parentId);
logger.info("【部门新增】wxDepartmentId = {}",wxDepartmentId);
} }
wxDepartmentId = jp.getResult().toString();
tab.setWxDepartmentId(wxDepartmentId);
tab.setParentDepartmentId(parentId);
logger.info("【部门新增】wxDepartmentId = {}",wxDepartmentId);
} }
departmentService.repairRecycle(tab); departmentService.repairRecycle(tab);
...@@ -495,7 +476,7 @@ public class DepartmentApiServiceImpl implements DepartmentApiService { ...@@ -495,7 +476,7 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
} }
@Override @Override
public void initwxDepartment(String corpid, String suiteid, String wxEnterpriseId) { public void initwxDepartment(String corpid, String contactSecret, String wxEnterpriseId) {
// List<com.gic.wechat.api.dto.qywx.DepartmentDTO> list = this.qywxDepartmentApiService.listDepartment(corpid, suiteid, null); // List<com.gic.wechat.api.dto.qywx.DepartmentDTO> list = this.qywxDepartmentApiService.listDepartment(corpid, suiteid, null);
// logger.info("企业所有部门数据:{}", JSON.toJSONString(list)); // logger.info("企业所有部门数据:{}", JSON.toJSONString(list));
// //
...@@ -517,56 +498,17 @@ public class DepartmentApiServiceImpl implements DepartmentApiService { ...@@ -517,56 +498,17 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
// //
// DepartmentDTO parent = EntityUtil.changeEntityByJSON(DepartmentDTO.class,departmentService.selectById(parentId)); // DepartmentDTO parent = EntityUtil.changeEntityByJSON(DepartmentDTO.class,departmentService.selectById(parentId));
// this.addSon(subList, wxEnterpriseId, parent,corpid,suiteid); // this.addSon(subList, wxEnterpriseId, parent,corpid,suiteid);
List<com.gic.wechat.api.dto.qywx.DepartmentDTO> list = this.qywxDepartmentApiService.listDepartment(corpid, suiteid, null); List<com.gic.wechat.api.dto.qywx.DepartmentDTO> list = this.qywxDepartmentApiService.listSelfDepartment(corpid, contactSecret, null);
logger.info("企业所有部门数据:{}", JSON.toJSONString(list)); logger.info("企业所有部门数据:{}", JSON.toJSONString(list));
if(CollectionUtils.isNotEmpty(list)){ if(CollectionUtils.isNotEmpty(list)){
this.addAllDepartment(list, 0, wxEnterpriseId, corpid, suiteid); this.addAllDepartment(list, 0, wxEnterpriseId, corpid, contactSecret);
}
}
public void addSon(List<com.gic.wechat.api.dto.qywx.DepartmentDTO> list ,String wxEnterpriseId,DepartmentDTO parent,String corpid, String suiteid){
for (com.gic.wechat.api.dto.qywx.DepartmentDTO departmentDTO : list) {
String parentId = addDepartment(departmentDTO, wxEnterpriseId, parent,corpid,suiteid);
DepartmentDTO parent2 = EntityUtil.changeEntityByJSON(DepartmentDTO.class,departmentService.selectById(parentId));
List<com.gic.wechat.api.dto.qywx.DepartmentDTO> subList2 = new ArrayList<>();
for (com.gic.wechat.api.dto.qywx.DepartmentDTO departmentDTO2 : list) {
if(departmentDTO.getId().equals(departmentDTO2.getParentid())){
subList2.add(departmentDTO);
}
}
while(!subList2.isEmpty()){
addSon(subList2, wxEnterpriseId, parent2,corpid,suiteid);
}
} }
} }
private String addDepartment(com.gic.wechat.api.dto.qywx.DepartmentDTO departmentDTO,String wxEnterpriseId,DepartmentDTO parent,String corpid,String suiteid ){
String parentId = "";
TabHaobanDepartment exist = this.departmentService.getByWxId(departmentDTO.getId() + "", wxEnterpriseId);
logger.info("分组是否存在:{}", JSON.toJSONString(exist));
if(exist == null){
com.gic.haoban.manage.api.dto.DepartmentDTO dto = new com.gic.haoban.manage.api.dto.DepartmentDTO();
dto.setDepartmentName(departmentDTO.getName());
dto.setLevel(parent.getLevel() + 1);
dto.setWxEnterpriseId(wxEnterpriseId);
dto.setWxDepartmentId(departmentDTO.getId()+"");
dto.setParentDepartmentId(parent.getDepartmentId());
dto.setChainId(parent.getChainId() + Constant.ID_SEPARATOR + parent.getDepartmentId());
dto.setChainName(parent.getChainName() + Constant.NAME_SEPARATOR + parent.getDepartmentName());
dto.setSort(departmentDTO.getOrder());
dto.setIsStore(0);
parentId = this.departmentService.add(dto);
this.staffApiService.initWxUser(corpid, suiteid, wxEnterpriseId, departmentDTO.getId());
}else{
parentId = exist.getDepartmentId();
}
return parentId;
}
private void addAllDepartment(List<com.gic.wechat.api.dto.qywx.DepartmentDTO> list, Integer parentId, private void addAllDepartment(List<com.gic.wechat.api.dto.qywx.DepartmentDTO> list, Integer parentId,
String wxEnterpriseId, String corpid, String suiteid){ String wxEnterpriseId, String corpid, String contactSecret){
int level = 1; int level = 1;
String chainId = "0"; String chainId = "0";
String chainName = "0"; String chainName = "0";
...@@ -597,8 +539,8 @@ public class DepartmentApiServiceImpl implements DepartmentApiService { ...@@ -597,8 +539,8 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
dto.setIsStore(0); dto.setIsStore(0);
this.departmentService.add(dto); this.departmentService.add(dto);
} }
this.addAllDepartment(list, departmentDTO.getId(), wxEnterpriseId, corpid, suiteid); this.addAllDepartment(list, departmentDTO.getId(), wxEnterpriseId, corpid, contactSecret);
this.staffApiService.initWxUser(corpid, suiteid, wxEnterpriseId, departmentDTO.getId()); this.staffApiService.initWxUser(corpid, contactSecret, wxEnterpriseId, departmentDTO.getId());
} }
} }
} }
...@@ -650,15 +592,12 @@ public class DepartmentApiServiceImpl implements DepartmentApiService { ...@@ -650,15 +592,12 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
//调微信的删除接口 //调微信的删除接口
TabHaobanDepartment department = departmentService.selectById(departmentId); TabHaobanDepartment department = departmentService.selectById(departmentId);
WxEnterpriseDTO enterpriseDTO = wxEnterpriseService.selectById(department.getWxEnterpriseId()); WxEnterpriseDTO enterpriseDTO = wxEnterpriseService.selectById(department.getWxEnterpriseId());
TabHaobanWxApplication application = wxApplicationService.selectByWxEnterpriseIdAndApplicationType(department.getWxEnterpriseId(),1);
if(enterpriseDTO != null) { if(enterpriseDTO != null) {
if(application != null) { JSONResponse jp = qywxDepartmentApiService.deleteSelfDepartment(enterpriseDTO.getCorpid(), enterpriseDTO.getContactSecret(), Integer.parseInt(department.getWxDepartmentId()));
JSONResponse jp = qywxDepartmentApiService.deleteDepartment(enterpriseDTO.getCorpid(), application.getSiteId(), Integer.parseInt(department.getWxDepartmentId())); if(jp.getErrorCode() != 0) {
if(jp.getErrorCode() != 0) { hr.setCode(0);
hr.setCode(0); hr.setMessage("微信删除部门失败");
hr.setMessage("微信删除部门失败"); return hr;
return hr;
}
} }
} }
......
...@@ -157,18 +157,14 @@ public class MessageApiServiceImpl implements MessageApiService { ...@@ -157,18 +157,14 @@ public class MessageApiServiceImpl implements MessageApiService {
QywxCallBackDTO dto = JSON.parseObject(param, QywxCallBackDTO.class); QywxCallBackDTO dto = JSON.parseObject(param, QywxCallBackDTO.class);
log.info("【处理微信回调】dto={}",JSON.toJSONString(param)); log.info("【处理微信回调】dto={}",JSON.toJSONString(param));
if(dto != null){ if(dto != null){
String siteId = dto.getSuiteId();
String corpId = dto.getAuthCorpId(); String corpId = dto.getAuthCorpId();
TabHaobanWxEnterprise enterprise = this.enterpriseService.getEnterpriseBycorpId(corpId); TabHaobanWxEnterprise enterprise = this.enterpriseService.getEnterpriseBycorpId(corpId);
if(enterprise != null){ if(enterprise != null){
TabHaobanWxApplication application = wxApplicationService.selectBySiteIdAndWxEnterpriseId(siteId, enterprise.getWxEnterpriseId()); if(dto.getChangeType().endsWith("party")){
if(application != null && application.getApplicationType() == 1){ this.dealDepartment(dto);
if(dto.getChangeType().endsWith("party")){ }else {
this.dealDepartment(dto); this.dealUser(dto);
}else { }
this.dealUser(dto);
}
}
} }
} }
} }
......
...@@ -47,17 +47,14 @@ import com.gic.haoban.manage.service.dao.mapper.StaffMapper; ...@@ -47,17 +47,14 @@ import com.gic.haoban.manage.service.dao.mapper.StaffMapper;
import com.gic.haoban.manage.service.entity.TabHaobanDepartment; import com.gic.haoban.manage.service.entity.TabHaobanDepartment;
import com.gic.haoban.manage.service.entity.TabHaobanStaff; import com.gic.haoban.manage.service.entity.TabHaobanStaff;
import com.gic.haoban.manage.service.entity.TabHaobanStaffDepartmentRelated; import com.gic.haoban.manage.service.entity.TabHaobanStaffDepartmentRelated;
import com.gic.haoban.manage.service.entity.TabHaobanWxApplication;
import com.gic.haoban.manage.service.service.DepartmentService; import com.gic.haoban.manage.service.service.DepartmentService;
import com.gic.haoban.manage.service.service.StaffDepartmentRelatedService; import com.gic.haoban.manage.service.service.StaffDepartmentRelatedService;
import com.gic.haoban.manage.service.service.StaffService; import com.gic.haoban.manage.service.service.StaffService;
import com.gic.haoban.manage.service.service.UserLoginLogService; import com.gic.haoban.manage.service.service.UserLoginLogService;
import com.gic.haoban.manage.service.service.WxApplicationService;
import com.gic.haoban.manage.service.service.WxEnterpriseService; import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.wechat.api.dto.qywx.UserDTO; import com.gic.wechat.api.dto.qywx.UserDTO;
import com.gic.wechat.api.service.qywx.QywxUserApiService; import com.gic.wechat.api.service.qywx.QywxUserApiService;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.google.i18n.phonenumbers.PhoneNumberUtil;
@Service @Service
public class StaffApiServiceImpl implements StaffApiService { public class StaffApiServiceImpl implements StaffApiService {
...@@ -77,8 +74,6 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -77,8 +74,6 @@ public class StaffApiServiceImpl implements StaffApiService {
@Autowired @Autowired
private WxEnterpriseService wxEnterpriseService; private WxEnterpriseService wxEnterpriseService;
@Autowired @Autowired
private WxApplicationService wxApplicationService;
@Autowired
private DepartmentService departmentService; private DepartmentService departmentService;
@Autowired @Autowired
private ClerkService clerkService; private ClerkService clerkService;
...@@ -126,41 +121,38 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -126,41 +121,38 @@ public class StaffApiServiceImpl implements StaffApiService {
//调接口获取 //调接口获取
String wxUserId = ""; String wxUserId = "";
WxEnterpriseDTO enterpriseDTO = wxEnterpriseService.selectById(staff.getWxEnterpriseId()); WxEnterpriseDTO enterpriseDTO = wxEnterpriseService.selectById(staff.getWxEnterpriseId());
TabHaobanWxApplication application = wxApplicationService.selectByWxEnterpriseIdAndApplicationType(staff.getWxEnterpriseId(),1);
if(enterpriseDTO != null) { if(enterpriseDTO != null) {
if(application != null) { UserDTO userDTO = new UserDTO();
UserDTO userDTO = new UserDTO(); userDTO.setCorpid(enterpriseDTO.getCorpid());
userDTO.setCorpid(enterpriseDTO.getCorpid()); String[] departmentIdArr = departmentIds.split(",");
String[] departmentIdArr = departmentIds.split(","); Integer[] wxDepartmentIdArrIntegers = new Integer[departmentIdArr.length];
Integer[] wxDepartmentIdArrIntegers = new Integer[departmentIdArr.length]; int index = 0;
int index = 0; for (String string : departmentIdArr) {
for (String string : departmentIdArr) { TabHaobanDepartment tabs = departmentService.selectById(string);
TabHaobanDepartment tabs = departmentService.selectById(string); wxDepartmentIdArrIntegers[index] = Integer.parseInt(tabs.getWxDepartmentId());
wxDepartmentIdArrIntegers[index] = Integer.parseInt(tabs.getWxDepartmentId()); index ++;
index ++; }
} userDTO.setDepartment(wxDepartmentIdArrIntegers);
userDTO.setDepartment(wxDepartmentIdArrIntegers); userDTO.setGender(staff.getSex() == null ? null:staff.getSex().toString());
userDTO.setGender(staff.getSex() == null ? null:staff.getSex().toString()); userDTO.setMobile(staff.getPhoneNumber());
userDTO.setMobile(staff.getPhoneNumber()); userDTO.setName(staff.getStaffName());
userDTO.setName(staff.getStaffName()); userDTO.setUserid(staffId);
userDTO.setUserid(staffId); userDTO.setAlias(staff.getNickName());
userDTO.setAlias(staff.getNickName()); userDTO.setExternal_position(tab.getExtendPostion());
userDTO.setExternal_position(tab.getExtendPostion()); userDTO.setPosition(tab.getPostion());
userDTO.setPosition(tab.getPostion()); if(activeFlag == 1) {
if(activeFlag == 1) { userDTO.setTo_invite(true);
userDTO.setTo_invite(true);
}
logger.info("【店员新增】userDTO = {}",JSON.toJSONString(userDTO));
JSONResponse jp = qywxUserApiService.createWorkWxUser(userDTO, enterpriseDTO.getCorpid(), application.getSiteId());
logger.info("【店员新增】jp = {}",JSON.toJSONString(jp));
if(jp.getErrorCode() != 0) {
hr.setCode(0);
hr.setMessage("微信新增失败");
return hr;
}
staffService.add(tab);
wxUserId = staffId;
} }
logger.info("【店员新增】userDTO = {}",JSON.toJSONString(userDTO));
JSONResponse jp = qywxUserApiService.createSelfWorkWxUser(userDTO, enterpriseDTO.getCorpid(), enterpriseDTO.getContactSecret());
logger.info("【店员新增】jp = {}",JSON.toJSONString(jp));
if(jp.getErrorCode() != 0) {
hr.setCode(0);
hr.setMessage("微信新增失败");
return hr;
}
staffService.add(tab);
wxUserId = staffId;
} }
if(StringUtils.isNotBlank(wxUserId)){ if(StringUtils.isNotBlank(wxUserId)){
String[] departmentIdArr = departmentIds.split(","); String[] departmentIdArr = departmentIds.split(",");
...@@ -229,12 +221,9 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -229,12 +221,9 @@ public class StaffApiServiceImpl implements StaffApiService {
if(relatedList.size() == 1) { if(relatedList.size() == 1) {
TabHaobanStaff staff = staffService.selectById(relatedList.get(0).getStaffId()); TabHaobanStaff staff = staffService.selectById(relatedList.get(0).getStaffId());
WxEnterpriseDTO enterpriseDTO = wxEnterpriseService.selectById(staff.getWxEnterpriseId()); WxEnterpriseDTO enterpriseDTO = wxEnterpriseService.selectById(staff.getWxEnterpriseId());
TabHaobanWxApplication application = wxApplicationService.selectByWxEnterpriseIdAndApplicationType(staff.getWxEnterpriseId(),1);
if(enterpriseDTO != null) { if(enterpriseDTO != null) {
if(application != null) { JSONResponse jp = qywxUserApiService.deleteSelfWorkWxUser(enterpriseDTO.getCorpid(), enterpriseDTO.getContactSecret(), staff.getWxUserId());
JSONResponse jp = qywxUserApiService.deleteWorkWxUser(enterpriseDTO.getCorpid(), application.getSiteId(), staff.getWxUserId()); logger.info("【删除成员】jp={}",JSON.toJSONString(jp));
logger.info("【删除成员】jp={}",JSON.toJSONString(jp));
}
} }
staffDepartmentRelatedService.del(related); staffDepartmentRelatedService.del(related);
staffService.delByuserid(relatedList.get(0).getStaffId()); staffService.delByuserid(relatedList.get(0).getStaffId());
...@@ -297,89 +286,77 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -297,89 +286,77 @@ public class StaffApiServiceImpl implements StaffApiService {
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);
TabHaobanWxApplication application = wxApplicationService.selectByWxEnterpriseIdAndApplicationType(wxEnterpriseId,1);
if(application == null){
application = wxApplicationService.selectByWxEnterpriseIdAndApplicationType(wxEnterpriseId,2);
}
if(enterpriseDTO != null) { if(enterpriseDTO != null) {
if(application != null) { Date now = new Date();
Date now = new Date(); UserDTO user = qywxUserApiService.getSelfWorkWxUser(enterpriseDTO.getCorpid(), enterpriseDTO.getContactSecret(), userId);
UserDTO user = qywxUserApiService.getWorkWxUser(enterpriseDTO.getCorpid(), application.getSiteId(), userId); logger.info("【新增用户】user={}",JSON.toJSONString(user));
logger.info("【新增用户】user={}",JSON.toJSONString(user)); TabHaobanStaff tab = new TabHaobanStaff();
TabHaobanStaff tab = new TabHaobanStaff(); tab.setWxUserId(userId);
tab.setWxUserId(userId); tab.setCreateTime(now);
tab.setCreateTime(now); tab.setUpdateTime(now);
tab.setUpdateTime(now); tab.setStatusFlag(1);
tab.setStatusFlag(1); tab.setWxEnterpriseId(wxEnterpriseId);
tab.setWxEnterpriseId(wxEnterpriseId); tab.setPhoneNumber(user.getMobile());
tab.setPhoneNumber(user.getMobile()); if (StringUtils.isNotBlank(user.getName())) {
if (StringUtils.isNotBlank(user.getName())) { tab.setStaffName(EmojiParser.removeAllEmojis(user.getName()));
tab.setStaffName(EmojiParser.removeAllEmojis(user.getName())); }
} if (StringUtils.isNotBlank(user.getAlias())) {
if (StringUtils.isNotBlank(user.getAlias())) { tab.setNickName(EmojiParser.removeAllEmojis(user.getAlias()));
tab.setNickName(EmojiParser.removeAllEmojis(user.getAlias())); }
}
// tab.setNickName(user.getAlias()); // tab.setNickName(user.getAlias());
tab.setNationCode("86"); tab.setNationCode("86");
tab.setSex(user.getGender() == null ? 1:Integer.parseInt(user.getGender())); tab.setSex(user.getGender() == null ? 1:Integer.parseInt(user.getGender()));
tab.setActiveFlag(1);
tab.setPostion(user.getPosition());
tab.setExtendPostion(user.getExternal_position());
if(user.getStatus() != null && user.getStatus() == 1){
tab.setActiveFlag(1); tab.setActiveFlag(1);
tab.setPostion(user.getPosition()); } else {
tab.setExtendPostion(user.getExternal_position()); tab.setActiveFlag(0);
if(user.getStatus() != null && user.getStatus() == 1){ }
tab.setActiveFlag(1); String staffId = staffService.add(tab);
} else {
tab.setActiveFlag(0); Integer[] departmentId = user.getDepartment();
} for (Integer integer : departmentId) {
String staffId = staffService.add(tab); TabHaobanDepartment tabDepartment = departmentService.getByWxId(integer.toString(), wxEnterpriseId);
if(tabDepartment != null){
Integer[] departmentId = user.getDepartment(); TabHaobanStaffDepartmentRelated tabStaff = staffDepartmentRelatedService.getDepartmentIdAndStaffId(tabDepartment.getDepartmentId(), tab.getStaffId());
for (Integer integer : departmentId) { if(tabStaff == null){
TabHaobanDepartment tabDepartment = departmentService.getByWxId(integer.toString(), wxEnterpriseId); StaffDepartmentRelatedDTO dto = new StaffDepartmentRelatedDTO();
if(tabDepartment != null){ dto.setPhoneNumber(user.getMobile());
TabHaobanStaffDepartmentRelated tabStaff = staffDepartmentRelatedService.getDepartmentIdAndStaffId(tabDepartment.getDepartmentId(), tab.getStaffId()); dto.setWxUserId(userId);
if(tabStaff == null){ dto.setStaffId(staffId);
StaffDepartmentRelatedDTO dto = new StaffDepartmentRelatedDTO(); dto.setStaffName(user.getName());
dto.setPhoneNumber(user.getMobile()); dto.setWxEnterpriseId(wxEnterpriseId);
dto.setWxUserId(userId); dto.setStatusFlag(1);
dto.setStaffId(staffId); dto.setDepartmentId(tabDepartment.getDepartmentId());
dto.setStaffName(user.getName()); dto.setNationCode("86");
dto.setWxEnterpriseId(wxEnterpriseId); dto.setStaffName(user.getName());
dto.setStatusFlag(1); staffDepartmentRelatedService.add(dto);
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);
TabHaobanWxApplication application = wxApplicationService.selectByWxEnterpriseIdAndApplicationType(wxEnterpriseId,1);
if(application == null){
application = wxApplicationService.selectByWxEnterpriseIdAndApplicationType(wxEnterpriseId,2);
}
if(enterpriseDTO != null) { if(enterpriseDTO != null) {
if(application != null) { UserDTO user = qywxUserApiService.getSelfWorkWxUser(enterpriseDTO.getCorpid(), enterpriseDTO.getContactSecret(), userId);
UserDTO user = qywxUserApiService.getWorkWxUser(enterpriseDTO.getCorpid(), application.getSiteId(), userId); logger.info("【修改用户】user={}",JSON.toJSONString(user));
logger.info("【修改用户】user={}",JSON.toJSONString(user)); Integer[] departmentId = user.getDepartment();
Integer[] departmentId = user.getDepartment(); String departmentIds = "";
String departmentIds = ""; for (Integer integer : departmentId) {
for (Integer integer : departmentId) { TabHaobanDepartment tabDepartment = departmentService.getByWxId(integer.toString(), wxEnterpriseId);
TabHaobanDepartment tabDepartment = departmentService.getByWxId(integer.toString(), wxEnterpriseId); if(tabDepartment != null){
if(tabDepartment != null){ departmentIds += tabDepartment.getDepartmentId() + ",";
departmentIds += tabDepartment.getDepartmentId() + ",";
}
}
if(StringUtils.isNotBlank(departmentIds)){
departmentIds = departmentIds.substring(1,departmentIds.length() - 1);
} }
StaffDTO staffDTO = EntityUtil.changeEntityByJSON(StaffDTO.class, staff);
staffDTO.setWeixinPush(true);
this.staffEdit(staffDTO, departmentIds);
//String staffId = staffService.add(tab);
} }
if(StringUtils.isNotBlank(departmentIds)){
departmentIds = departmentIds.substring(1,departmentIds.length() - 1);
}
StaffDTO staffDTO = EntityUtil.changeEntityByJSON(StaffDTO.class, staff);
staffDTO.setWeixinPush(true);
this.staffEdit(staffDTO, departmentIds);
//String staffId = staffService.add(tab);
} }
} }
} }
...@@ -492,31 +469,28 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -492,31 +469,28 @@ public class StaffApiServiceImpl implements StaffApiService {
Boolean weixinPush = staffDTO.getWeixinPush(); Boolean weixinPush = staffDTO.getWeixinPush();
if(weixinPush == null || !weixinPush){ if(weixinPush == null || !weixinPush){
WxEnterpriseDTO enterpriseDTO = wxEnterpriseService.selectById(oldStaff.getWxEnterpriseId()); WxEnterpriseDTO enterpriseDTO = wxEnterpriseService.selectById(oldStaff.getWxEnterpriseId());
TabHaobanWxApplication application = wxApplicationService.selectByWxEnterpriseIdAndApplicationType(oldStaff.getWxEnterpriseId(),1);
if(enterpriseDTO != null) { if(enterpriseDTO != null) {
if(application != null) { UserDTO userDTO = new UserDTO();
UserDTO userDTO = new UserDTO(); userDTO.setCorpid(enterpriseDTO.getCorpid());
userDTO.setCorpid(enterpriseDTO.getCorpid()); userDTO.setAlias(staffDTO.getNickName());
userDTO.setAlias(staffDTO.getNickName());
String[] departmentIdArr = departmentIds.split(",");
String[] departmentIdArr = departmentIds.split(","); Integer[] wxDepartmentIdArrIntegers = new Integer[departmentIdArr.length];
Integer[] wxDepartmentIdArrIntegers = new Integer[departmentIdArr.length]; int index = 0;
int index = 0; for (String string : departmentIdArr) {
for (String string : departmentIdArr) { TabHaobanDepartment tabs = departmentService.selectById(string);
TabHaobanDepartment tabs = departmentService.selectById(string); wxDepartmentIdArrIntegers[index] = Integer.parseInt(tabs.getWxDepartmentId());
wxDepartmentIdArrIntegers[index] = Integer.parseInt(tabs.getWxDepartmentId()); index ++;
index ++;
}
userDTO.setDepartment(wxDepartmentIdArrIntegers);
userDTO.setGender(staffDTO.getSex() == null ?"":staffDTO.getSex().toString());
userDTO.setMobile(staffDTO.getPhoneNumber());
userDTO.setName(staffDTO.getStaffName());
userDTO.setUserid(oldStaff.getWxUserId());
userDTO.setPosition(staffDTO.getPostion());
userDTO.setExternal_position(staffDTO.getExtendPostion());
JSONResponse jp = qywxUserApiService.updateWorkWxUser(userDTO, enterpriseDTO.getCorpid(), application.getSiteId());
} }
userDTO.setDepartment(wxDepartmentIdArrIntegers);
userDTO.setGender(staffDTO.getSex() == null ?"":staffDTO.getSex().toString());
userDTO.setMobile(staffDTO.getPhoneNumber());
userDTO.setName(staffDTO.getStaffName());
userDTO.setUserid(oldStaff.getWxUserId());
userDTO.setPosition(staffDTO.getPostion());
userDTO.setExternal_position(staffDTO.getExtendPostion());
JSONResponse jp = qywxUserApiService.updateSelfWorkWxUser(userDTO, enterpriseDTO.getCorpid(), enterpriseDTO.getContactSecret());
} }
} }
} }
...@@ -773,12 +747,11 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -773,12 +747,11 @@ public class StaffApiServiceImpl implements StaffApiService {
return staff; return staff;
} }
WxEnterpriseDTO enterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId); WxEnterpriseDTO enterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId);
TabHaobanWxApplication application = wxApplicationService.selectByWxEnterpriseIdAndApplicationType(wxEnterpriseId, 1);
if (null == enterpriseDTO || application == null) { if (null == enterpriseDTO ) {
return null; return null;
} }
String userId = qywxUserApiService.getWxUserIdByPhonenumber(enterpriseDTO.getCorpid(), application.getSiteId(), phoneNumber); String userId = qywxUserApiService.getSelfWxUserIdByPhonenumber(enterpriseDTO.getCorpid(), enterpriseDTO.getContactSecret(), phoneNumber);
logger.info("获取userId:{},{}", phoneNumber, userId); logger.info("获取userId:{},{}", phoneNumber, userId);
if (userId == null) { if (userId == null) {
return null; return null;
...@@ -793,8 +766,8 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -793,8 +766,8 @@ public class StaffApiServiceImpl implements StaffApiService {
} }
@Override @Override
public void initWxUser(String corpid, String suiteid, String wxEnterpriseId, Integer wxDepartmentId) { public void initWxUser(String corpid, String contactSecret, String wxEnterpriseId, Integer wxDepartmentId) {
List<UserDTO> list = this.qywxUserApiService.listDepartmentUser(corpid, suiteid, wxDepartmentId.toString(), 0); List<UserDTO> list = this.qywxUserApiService.listSelfDepartmentUser(corpid, contactSecret, wxDepartmentId.toString(), 0);
if(CollectionUtils.isNotEmpty(list)){ if(CollectionUtils.isNotEmpty(list)){
for(UserDTO dto : list){ for(UserDTO dto : list){
this.wxGetAdd(dto.getUserid(), wxEnterpriseId); this.wxGetAdd(dto.getUserid(), wxEnterpriseId);
......
...@@ -47,10 +47,6 @@ public class WxEnterpriseApiServiceImpl implements WxEnterpriseApiService { ...@@ -47,10 +47,6 @@ public class WxEnterpriseApiServiceImpl implements WxEnterpriseApiService {
private WxEnterpriseMapper wxEnterpriseMapper; private WxEnterpriseMapper wxEnterpriseMapper;
@Autowired @Autowired
private WxApplicationService wxApplicationService; private WxApplicationService wxApplicationService;
@Autowired
private QywxDepartmentApiService qywxDepartmentApiService;
@Autowired
private DepartmentService departmentService;
@Override @Override
public void callbackReviceEnterprise(QywxCorpInfoSimpleDTO dto) { public void callbackReviceEnterprise(QywxCorpInfoSimpleDTO dto) {
......
...@@ -48,7 +48,7 @@ public class AdminController extends WebBaseController{ ...@@ -48,7 +48,7 @@ public class AdminController extends WebBaseController{
public HaobanResponse adminList() { public HaobanResponse adminList() {
LoginVO login = (LoginVO) AuthRequestUtil.getLoginUser(); LoginVO login = (LoginVO) AuthRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId(); String wxEnterpriseId = login.getWxEnterpriseId();
WxApplicationDTO application = wxApplicationApiService.selectByWxEnterpriseIdAndApplicationType(wxEnterpriseId, 1); WxApplicationDTO application = wxApplicationApiService.selectByWxEnterpriseIdAndApplicationType(wxEnterpriseId, 2);
WxEnterpriseDTO enterprise = wxEnterpriseApiService.getOne(wxEnterpriseId); WxEnterpriseDTO enterprise = wxEnterpriseApiService.getOne(wxEnterpriseId);
logger.info("【管理员查询】corpid={},siteId={},agentId={}",enterprise.getCorpid(),application.getSiteId(),application.getAgentId()); logger.info("【管理员查询】corpid={},siteId={},agentId={}",enterprise.getCorpid(),application.getSiteId(),application.getAgentId());
String adminList = qywxSuiteApiService.getAdminList(enterprise.getCorpid(), application.getSiteId(), Integer.parseInt(application.getAgentId())); String adminList = qywxSuiteApiService.getAdminList(enterprise.getCorpid(), application.getSiteId(), Integer.parseInt(application.getAgentId()));
......
...@@ -102,13 +102,18 @@ public class ApplicationController extends WebBaseController{ ...@@ -102,13 +102,18 @@ public class ApplicationController extends WebBaseController{
} }
@RequestMapping("has-bind-contract") @RequestMapping("has-bind-contract")
public HaobanResponse hasBindContract(){ public HaobanResponse hasBindContract(){
LoginVO login = AuthRequestUtil.getSessionUser(); LoginVO login = (LoginVO) AuthRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId(); String wxEnterpriseId = login.getWxEnterpriseId();
WxApplicationDTO wxApplicationDTO = this.wxApplicationApiService.selectByWxEnterpriseIdAndApplicationType(wxEnterpriseId, 1); WxEnterpriseDTO enterpriseDTO = this.wxEnterpriseApiService.getOne(wxEnterpriseId);
if(wxApplicationDTO != null){ if(enterpriseDTO != null){
return resultResponse(HaoBanErrCode.ERR_1, true); if(StringUtils.isNotBlank(enterpriseDTO.getContactSecret()) && enterpriseDTO.getContactFlag() != null && enterpriseDTO.getContactFlag() == 1){
this.departmentApiService.initwxDepartment(enterpriseDTO.getCorpid(), enterpriseDTO.getContactSecret(), enterpriseDTO.getWxEnterpriseId());
enterpriseDTO.setContactFlag(1);
wxEnterpriseApiService.update(enterpriseDTO);
}
} }
return resultResponse(HaoBanErrCode.ERR_1, false);
return resultResponse(HaoBanErrCode.ERR_1, true);
} }
@RequestMapping("get-auth-url") @RequestMapping("get-auth-url")
...@@ -136,7 +141,7 @@ public class ApplicationController extends WebBaseController{ ...@@ -136,7 +141,7 @@ public class ApplicationController extends WebBaseController{
applicationDTO.setAgentName(dto.getAgentName()); applicationDTO.setAgentName(dto.getAgentName());
applicationDTO.setSiteId(dto.getSuiteId()); applicationDTO.setSiteId(dto.getSuiteId());
wxApplicationApiService.addSuite(applicationDTO); wxApplicationApiService.addSuite(applicationDTO);
this.departmentApiService.initwxDepartment(dto.getCorpid(), suiteId, enterpriseDTO.getWxEnterpriseId()); this.departmentApiService.initwxDepartment(dto.getCorpid(), enterpriseDTO.getContactSecret(), enterpriseDTO.getWxEnterpriseId());
enterpriseDTO.setContactFlag(1); enterpriseDTO.setContactFlag(1);
wxEnterpriseApiService.update(enterpriseDTO); wxEnterpriseApiService.update(enterpriseDTO);
} }
......
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