Commit c68eb1d2 by 陶光胜

Merge branch 'developer' of http://115.159.76.241/haoban3.0/haoban-manage3.0 into developer

parents 24e87b5e f04e93e7
package com.gic.haoban.manage.service.dao.mapper;
import org.apache.ibatis.annotations.Param;
import com.gic.haoban.manage.service.entity.TabHaobanWxApplication;
public interface WxApplicationMapper {
......@@ -14,4 +16,8 @@ public interface WxApplicationMapper {
int updateByPrimaryKeySelective(TabHaobanWxApplication record);
int updateByPrimaryKey(TabHaobanWxApplication record);
TabHaobanWxApplication selectBySiteIdAndWxEnterpriseId(@Param("siteId")String siteId, @Param("wxEnterpriseId")String wxEnterpriseId);
TabHaobanWxApplication selectByWxEnterpriseIdAndApplicationType(@Param("wxEnterpriseId")String wxEnterpriseId, @Param("applicationType")int applicationType);
}
\ No newline at end of file
package com.gic.haoban.manage.service.service;
import com.gic.haoban.manage.service.entity.TabHaobanWxApplication;
public interface WxApplicationService {
TabHaobanWxApplication selectBySiteIdAndWxEnterpriseId(String siteId, String wxEnterpriseId);
void insert(TabHaobanWxApplication tab);
void update(TabHaobanWxApplication tab);
TabHaobanWxApplication selectByWxEnterpriseIdAndApplicationType(String wxEnterpriseId, int applicationType);
}
package com.gic.haoban.manage.service.service.impl;
import java.util.Date;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.gic.haoban.common.utils.StringUtil;
import com.gic.haoban.manage.service.dao.mapper.WxApplicationMapper;
import com.gic.haoban.manage.service.entity.TabHaobanWxApplication;
import com.gic.haoban.manage.service.service.WxApplicationService;
@Service
public class WxApplicationServiceImpl implements WxApplicationService {
@Autowired
private WxApplicationMapper mapper;
@Override
public TabHaobanWxApplication selectBySiteIdAndWxEnterpriseId(String siteId, String wxEnterpriseId) {
return mapper.selectBySiteIdAndWxEnterpriseId(siteId,wxEnterpriseId);
}
@Override
public void insert(TabHaobanWxApplication tab) {
Date now = new Date();
tab.setCreateTime(now);
tab.setUpdateTime(now);
tab.setStatusFlag(1);
tab.setWxApplicationId(StringUtil.randomUUID());
mapper.insertSelective(tab);
}
@Override
public void update(TabHaobanWxApplication tab) {
tab.setUpdateTime(new Date());
mapper.updateByPrimaryKeySelective(tab);
}
@Override
public TabHaobanWxApplication selectByWxEnterpriseIdAndApplicationType(String wxEnterpriseId, int applicationType) {
return mapper.selectByWxEnterpriseIdAndApplicationType(wxEnterpriseId,applicationType);
}
}
......@@ -26,9 +26,11 @@ import com.gic.haoban.manage.api.service.DepartmentApiService;
import com.gic.haoban.manage.service.dao.mapper.DepartmentMapper;
import com.gic.haoban.manage.service.entity.TabHaobanDepartment;
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.service.DepartmentService;
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.wechat.api.service.qywx.QywxDepartmentApiService;
import com.github.pagehelper.PageHelper;
......@@ -55,6 +57,9 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
@Autowired
private WxEnterpriseService wxEnterpriseService;
@Autowired
private WxApplicationService wxApplicationService;
@Override
public List<DepartmentDTO> listByParentId(String parentId) {
......@@ -76,17 +81,27 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
//调微信的新增接口
String wxDepartmentId = "";
WxEnterpriseDTO enterpriseDTO = wxEnterpriseService.selectById(department.getWxEnterpriseId());
TabHaobanWxApplication application = wxApplicationService.selectByWxEnterpriseIdAndApplicationType(department.getWxEnterpriseId(),1);
if(enterpriseDTO != null) {
//JSONResponse jp = qywxDepartmentApiService.createDepartment(enterpriseDTO.getCorpid(), enterpriseDTO.getsi, departmentDTO);
if(StringUtils.isBlank(wxDepartmentId)) {
hr.setErrorCode(0);
hr.setMessage("微信新增部门失败");
return hr;
if(application != null) {
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()));
JSONResponse jp = qywxDepartmentApiService.createDepartment(enterpriseDTO.getCorpid(), application.getSiteId(), dto);
if(jp.getErrorCode() != 1) {
hr.setErrorCode(0);
hr.setMessage("微信新增部门失败");
return hr;
}
wxDepartmentId = jp.getResult().toString();
department.setWxDepartmentId(wxDepartmentId);
String departmentId = departmentService.add(department);
department.setDepartmentId(departmentId);
hr.setResult(department);
}
department.setWxDepartmentId(wxDepartmentId);
String departmentId = departmentService.add(department);
department.setDepartmentId(departmentId);
hr.setResult(department);
}
return hr;
......
......@@ -3,6 +3,7 @@ package com.gic.haoban.manage.service.service.out.impl;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -15,7 +16,9 @@ import com.gic.haoban.manage.api.dto.YwWxEnterpriseDTO;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseApiService;
import com.gic.haoban.manage.service.dao.mapper.WxEnterpriseMapper;
import com.gic.haoban.manage.service.entity.TabHaobanWxApplication;
import com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise;
import com.gic.haoban.manage.service.service.WxApplicationService;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
@Service
......@@ -27,14 +30,42 @@ public class WxEnterpriseApiServiceImpl implements WxEnterpriseApiService {
private StaffApiService staffApiService;
@Autowired
private WxEnterpriseMapper wxEnterpriseMapper;
@Autowired
private WxApplicationService wxApplicationService;
@Override
public void callbackReviceEnterprise(QywxCorpInfoSimpleDTO dto) {
WxEnterpriseDTO wxDTO = EntityUtil.changeEntityByJSON(WxEnterpriseDTO.class, dto.getClass());
String wxEnterpriseId = wxEnterpriseService.add(wxDTO);
String userId = dto.getUserid();
String name = dto.getName();
staffApiService.wxGetAdd(userId,wxEnterpriseId);
if(StringUtils.isNotBlank(userId)) {
staffApiService.wxGetAdd(userId,wxEnterpriseId);
}
String siteId = dto.getSuiteId();
String agentId = dto.getAgentid();
String agentName = dto.getAgentName();
String permanentCode = dto.getPermanentCode();
String applicationName = dto.getName();
TabHaobanWxApplication tab = wxApplicationService.selectBySiteIdAndWxEnterpriseId(siteId,wxEnterpriseId);
if(tab == null) {
tab = new TabHaobanWxApplication();
tab.setAgentId(agentId);
tab.setSiteId(siteId);
tab.setAgentName(agentName);
tab.setName(applicationName);
tab.setPermanentCode(permanentCode);
tab.setWxEnterpriseId(wxEnterpriseId);
wxApplicationService.insert(tab);
}else {
tab.setPermanentCode(permanentCode);
wxApplicationService.update(tab);
}
}
......
......@@ -161,4 +161,22 @@
update_time = #{updateTime,jdbcType=TIMESTAMP}
where wx_application_id = #{wxApplicationId,jdbcType=VARCHAR}
</update>
<select id="selectBySiteIdAndWxEnterpriseId" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
from tab_haoban_wx_application
where site_id = #{siteId,jdbcType=VARCHAR}
and status_flag = 1
and wx_enterprise_id = #{wxEnterpriseId}
</select>
<select id="selectByWxEnterpriseIdAndApplicationType" resultMap="BaseResultMap" >
select
<include refid="Base_Column_List" />
from tab_haoban_wx_application
where application_type = #{applicationType}
and status_flag = 1
and wx_enterprise_id = #{wxEnterpriseId}
</select>
</mapper>
\ No newline at end of file
......@@ -67,7 +67,7 @@ public class DepartmentContoller extends WebBaseController{
}
@RequestMapping("department-level-list")
@RequestMapping("epartment-list-level")
public HaobanResponse departmentLevelList(String parentId) {
LoginVO login = (LoginVO) AuthRequestUtil.getSessionUser();
String wxEnterpriseId = login.getWxEnterpriseId();
......
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