Commit c63a0615 by 陶光胜

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

parents 68ab5e8e e5211af3
......@@ -33,4 +33,6 @@ public interface StaffApiService {
public StaffDTO selectByUserId(String userId);
public StaffDepartmentRelatedDTO getDepartmentIdAndStaffId(String departmentId, String staffId);
}
......@@ -34,4 +34,6 @@ public interface StaffDepartmentRelatedMapper {
int delByUserid(@Param("userid") String userId);
TabHaobanStaffDepartmentRelated getDepartmentIdAndStaffId(@Param("departmentId")String departmentId, @Param("staffId")String staffId);
}
\ No newline at end of file
......@@ -19,4 +19,6 @@ public interface StaffDepartmentRelatedService {
void del(StaffDepartmentRelatedDTO related);
void delByUserid(String userid);
TabHaobanStaffDepartmentRelated getDepartmentIdAndStaffId(String departmentId, String staffId);
}
......@@ -3,6 +3,7 @@ package com.gic.haoban.manage.service.service;
import java.util.Set;
import com.gic.haoban.manage.service.entity.TabHaobanStaff;
import com.gic.haoban.manage.service.entity.TabHaobanStaffDepartmentRelated;
import com.github.pagehelper.Page;
public interface StaffService {
......@@ -20,4 +21,5 @@ public interface StaffService {
void updateByPrimaryKey(TabHaobanStaff tab);
int delByuserid(String staffId);
}
......@@ -64,5 +64,10 @@ public class StaffDepartmentRelatedServiceImpl implements StaffDepartmentRelated
}
@Override
public TabHaobanStaffDepartmentRelated getDepartmentIdAndStaffId(String departmentId, String staffId) {
return mapper.getDepartmentIdAndStaffId(departmentId,staffId);
}
}
......@@ -34,8 +34,7 @@ public class WxEnterpriseServiceImpl implements WxEnterpriseService {
@Override
public WxEnterpriseDTO selectById(String wxEnterpriseId) {
//TabHaobanWxEnterprise wx
return null;
return EntityUtil.changeEntityByJSON(WxEnterpriseDTO.class, mapper.selectByPrimaryKey(wxEnterpriseId));
}
@Override
......
......@@ -11,6 +11,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.gic.api.base.commons.JSONResponse;
import com.gic.api.base.commons.Page;
......@@ -82,6 +83,8 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
String wxDepartmentId = "";
WxEnterpriseDTO enterpriseDTO = wxEnterpriseService.selectById(department.getWxEnterpriseId());
TabHaobanWxApplication application = wxApplicationService.selectByWxEnterpriseIdAndApplicationType(department.getWxEnterpriseId(),1);
logger.info("【部门新增】enterpriseDTO = {}",JSON.toJSONString(enterpriseDTO));
logger.info("【部门新增】application = {}",JSON.toJSONString(application));
if(enterpriseDTO != null) {
if(application != null) {
com.gic.wechat.api.dto.qywx.DepartmentDTO dto = new com.gic.wechat.api.dto.qywx.DepartmentDTO();
......@@ -90,14 +93,18 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
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);
if(jp.getErrorCode() != 1) {
logger.info("【部门新增】jp = {}",JSON.toJSONString(jp));
if(jp.getErrorCode() != 0) {
hr.setErrorCode(0);
hr.setMessage("微信新增部门失败");
return hr;
}
wxDepartmentId = jp.getResult().toString();
logger.info("【部门新增】wxDepartmentId = {}",wxDepartmentId);
department.setWxDepartmentId(wxDepartmentId);
department.setLevel(parent.getLevel() + 1);
String departmentId = departmentService.add(department);
department.setDepartmentId(departmentId);
hr.setResult(department);
......@@ -124,7 +131,7 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
TabHaobanDepartment parent = departmentService.selectById(department.getParentDepartmentId());
dto.setParentid(Integer.valueOf(parent.getWxDepartmentId()));
JSONResponse jp = qywxDepartmentApiService.updateDepartment(enterpriseDTO.getCorpid(), application.getSiteId(), dto);
if(jp.getErrorCode() != 1) {
if(jp.getErrorCode() != 0) {
hr.setErrorCode(0);
hr.setMessage("微信修改部门失败");
return hr;
......@@ -161,7 +168,7 @@ public class DepartmentApiServiceImpl implements DepartmentApiService {
if(enterpriseDTO != null) {
if(application != null) {
JSONResponse jp = qywxDepartmentApiService.deleteDepartment(enterpriseDTO.getCorpid(), application.getSiteId(), Integer.parseInt(department.getWxDepartmentId()));
if(jp.getErrorCode() != 1) {
if(jp.getErrorCode() != 0) {
hr.setErrorCode(0);
hr.setMessage("微信删除部门失败");
return hr;
......
......@@ -8,11 +8,14 @@ import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.JSONResponse;
import com.gic.api.base.commons.Page;
import com.gic.commons.util.EntityUtil;
......@@ -20,7 +23,6 @@ import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.common.utils.PageUtil;
import com.gic.haoban.common.utils.UuidUtil;
import com.gic.haoban.manage.api.dto.DepartmentDTO;
import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.api.dto.StaffDepartmentRelatedDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
......@@ -43,6 +45,7 @@ import com.github.pagehelper.PageHelper;
@Service
public class StaffApiServiceImpl implements StaffApiService {
private static Logger logger = LoggerFactory.getLogger(StaffApiServiceImpl.class);
@Autowired
StaffService staffService;
@Autowired
......@@ -88,13 +91,15 @@ public class StaffApiServiceImpl implements StaffApiService {
if(application != null) {
UserDTO userDTO = new UserDTO();
userDTO.setCorpid(enterpriseDTO.getCorpid());
List<Integer> wxDepartmentIdArrIntegers = new ArrayList<Integer>();
String[] departmentIdArr = departmentIds.split(",");
Integer[] wxDepartmentIdArrIntegers = new Integer[departmentIdArr.length];
int index = 0;
for (String string : departmentIdArr) {
TabHaobanDepartment tabs = departmentService.selectById(string);
wxDepartmentIdArrIntegers.add(Integer.parseInt(tabs.getWxDepartmentId()));
wxDepartmentIdArrIntegers[0] = Integer.parseInt(tabs.getWxDepartmentId());
index ++;
}
userDTO.setDepartment((Integer[]) wxDepartmentIdArrIntegers.toArray());
userDTO.setDepartment(wxDepartmentIdArrIntegers);
userDTO.setGender("女");
userDTO.setMobile(staff.getPhoneNumber());
userDTO.setName(staff.getStaffName());
......@@ -102,13 +107,15 @@ public class StaffApiServiceImpl implements StaffApiService {
if(activeFlag == 1) {
userDTO.setTo_invite(true);
}
logger.info("【店员新增】userDTO = {}",JSON.toJSONString(userDTO));
JSONResponse jp = qywxUserApiService.createWorkWxUser(userDTO, enterpriseDTO.getCorpid(), application.getSiteId());
if(jp.getErrorCode() != 1) {
logger.info("【店员新增】jp = {}",JSON.toJSONString(jp));
if(jp.getErrorCode() != 0) {
hr.setErrorCode(0);
hr.setDetailError("微信新增失败");
return hr;
}
wxUserId = jp.getResult().toString();
wxUserId = staffId;
}
}
......@@ -174,12 +181,27 @@ public class StaffApiServiceImpl implements StaffApiService {
if(related != null) {
List<TabHaobanStaffDepartmentRelated> relatedList = staffDepartmentRelatedService.listStaffDepartmentByStaffId(related.getStaffId());
//只在当前门店
if(relatedList.size() <= 1) {
//微信接口删除
if(relatedList.size() == 1) {
TabHaobanStaff staff = staffService.selectById(relatedList.get(0).getStaffId());
WxEnterpriseDTO enterpriseDTO = wxEnterpriseService.selectById(staff.getWxEnterpriseId());
TabHaobanWxApplication application = wxApplicationService.selectByWxEnterpriseIdAndApplicationType(staff.getWxEnterpriseId(),1);
if(enterpriseDTO != null) {
if(application != null) {
JSONResponse jp = qywxUserApiService.deleteWorkWxUser(enterpriseDTO.getCorpid(), application.getSiteId(), staff.getWxUserId());
}
}
staffDepartmentRelatedService.del(related);
//走修改流程
}else {
String departmentIds = "";
for (TabHaobanStaffDepartmentRelated tabHaobanStaffDepartmentRelated : relatedList) {
if(!staffDepartmentStaffRelatedId.equals(tabHaobanStaffDepartmentRelated.getStaffDepartmentRelatedId())) {
departmentIds += tabHaobanStaffDepartmentRelated.getDepartmentId() + ",";
}
}
departmentIds = departmentIds.substring(0,departmentIds.length() - 1);
TabHaobanStaff staff = staffService.selectById(relatedList.get(0).getStaffId());
staffEdit(EntityUtil.changeEntityByJSON(StaffDTO.class, staff), departmentIds);
}
}
......@@ -263,6 +285,28 @@ public class StaffApiServiceImpl implements StaffApiService {
}
}
}
WxEnterpriseDTO enterpriseDTO = wxEnterpriseService.selectById(oldStaff.getWxEnterpriseId());
TabHaobanWxApplication application = wxApplicationService.selectByWxEnterpriseIdAndApplicationType(oldStaff.getWxEnterpriseId(),1);
if(enterpriseDTO != null) {
if(application != null) {
UserDTO userDTO = new UserDTO();
userDTO.setCorpid(enterpriseDTO.getCorpid());
List<Integer> wxDepartmentIdArrIntegers = new ArrayList<Integer>();
String[] departmentIdArr = departmentIds.split(",");
for (String string : departmentIdArr) {
TabHaobanDepartment tabs = departmentService.selectById(string);
wxDepartmentIdArrIntegers.add(Integer.parseInt(tabs.getWxDepartmentId()));
}
userDTO.setDepartment((Integer[]) wxDepartmentIdArrIntegers.toArray());
userDTO.setGender("女");
userDTO.setMobile(staffDTO.getPhoneNumber());
userDTO.setName(staffDTO.getStaffName());
userDTO.setUserid(oldStaff.getWxUserId());
JSONResponse jp = qywxUserApiService.updateWorkWxUser(userDTO, enterpriseDTO.getCorpid(), application.getSiteId());
}
}
}
@Override
......@@ -276,4 +320,10 @@ public class StaffApiServiceImpl implements StaffApiService {
return EntityUtil.changeEntityByJSON(StaffDTO.class, staffService.selectByUserId(userId));
}
@Override
public StaffDepartmentRelatedDTO getDepartmentIdAndStaffId(String departmentId, String staffId) {
TabHaobanStaffDepartmentRelated tab = staffDepartmentRelatedService.getDepartmentIdAndStaffId(departmentId,staffId);
return EntityUtil.changeEntityByJSON(StaffDepartmentRelatedDTO.class, tab);
}
}
......@@ -198,4 +198,14 @@
status_flag = 0
where wx_user_id = #{userid,jdbcType=VARCHAR}
</update>
<select id="getDepartmentIdAndStaffId" resultMap="BaseResultMap" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
from tab_haoban_staff_department_related
where staff_id = #{staffId,jdbcType=VARCHAR}
and department_id = #{departmentId}
and status_flag = 1
</select>
</mapper>
\ No newline at end of file
......@@ -6,6 +6,8 @@ import java.util.Map;
import java.util.stream.Collectors;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -34,6 +36,8 @@ import com.gic.haoban.manage.web.vo.StoreVo;
@RestController
public class DepartmentContoller extends WebBaseController{
private static Logger logger = LoggerFactory.getLogger(DepartmentContoller.class);
@Autowired
private DepartmentApiService departmentApiService;
......@@ -45,6 +49,7 @@ public class DepartmentContoller extends WebBaseController{
public HaobanResponse departmentList(String parentId,BasePageInfo pageInfo,String keyword) {
LoginVO login = (LoginVO) AuthRequestUtil.getSessionUser();
String wxEnterpriseId = login.getWxEnterpriseId();
logger.info("【部门列表】wxEnterpriseId={}",wxEnterpriseId);
Page<DepartmentDTO> page = new Page<DepartmentDTO>();
List<DepartmentDTO> list = new ArrayList<DepartmentDTO>();
......@@ -71,6 +76,7 @@ public class DepartmentContoller extends WebBaseController{
public HaobanResponse departmentLevelList(String parentId) {
LoginVO login = (LoginVO) AuthRequestUtil.getSessionUser();
String wxEnterpriseId = login.getWxEnterpriseId();
logger.info("【部门层级列表】wxEnterpriseId={}",wxEnterpriseId);
List<DepartmentDTO> list = new ArrayList<DepartmentDTO>();
if(StringUtils.isNotBlank(parentId)) {
list = departmentApiService.listByParentId(parentId);
......@@ -98,6 +104,7 @@ public class DepartmentContoller extends WebBaseController{
department.setWxEnterpriseId(dto.getWxEnterpriseId());
department.setChainId(dto.getChainId() + Constant.ID_SEPARATOR + dto.getDepartmentId());
department.setIsStore(0);
department.setLevel(dto.getLevel() + 1);
departmentApiService.add(department);
return resultResponse(HaoBanErrCode.ERR_1);
......
......@@ -39,7 +39,7 @@ public class LoginController extends WebBaseController{
LoginVO loginVO = new LoginVO();
StaffDTO staff = staffApiService.selectById("1");
logger.info("【好办登录】staff={}",JSON.toJSONString(staff));
loginVO.setWxEnterpriseId("1");
loginVO.setWxEnterpriseId(staff.getWxEnterpriseId());
loginVO.setStaffDTO(staff);
AuthRequestUtil.setSessionUser(loginVO);
return resultResponse(HaoBanErrCode.ERR_1, loginVO);
......@@ -48,7 +48,8 @@ public class LoginController extends WebBaseController{
@RequestMapping("get-login-qrcode")
public HaobanResponse getLoginQrcode(){
String url = qywxCorpApiService.getGrantAuthorizationUrl(siteId, redirectUri);
String url = "https://open.work.weixin.qq.com/wwopen/sso/3rd_qrConnect?appid=wweac4ef962720aa12&"+redirectUri+"&state=web_login@gyoss9&usertype=admin";
//String url = qywxCorpApiService.getGrantAuthorizationUrl(siteId, redirectUri);
return resultResponse(HaoBanErrCode.ERR_1,url);
}
......
......@@ -20,6 +20,7 @@ import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.api.dto.StaffDepartmentRelatedDTO;
import com.gic.haoban.manage.api.service.DepartmentApiService;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.StaffDepartmentRelatedApiService;
import com.gic.haoban.manage.web.auth.AuthRequestUtil;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.vo.LoginVO;
......@@ -36,11 +37,12 @@ public class StaffController extends WebBaseController{
@RequestMapping("staff-add")
public HaobanResponse staffAdd(StaffDTO staffDTO,String departmentIds){
LoginVO login = (LoginVO) AuthRequestUtil.getAppLoginUser();
LoginVO login = (LoginVO) AuthRequestUtil.getSessionUser();
String wxEnterpriseId = login.getWxEnterpriseId();
String staffName = staffDTO.getStaffName();
String phoneNumber = staffDTO.getPhoneNumber();
String nationcode = staffDTO.getNationCode();
staffDTO.setWxEnterpriseId(wxEnterpriseId);
if(StringUtils.isBlank(staffName)) {
return resultResponse(HaoBanErrCode.ERR_10004);
}
......@@ -48,7 +50,7 @@ public class StaffController extends WebBaseController{
if(staff != null) {
return resultResponse(HaoBanErrCode.ERR_10005);
}
HaobanResponse hr = staffApiService.add(staff,departmentIds);
HaobanResponse hr = staffApiService.add(staffDTO,departmentIds);
return resultResponse(HaoBanErrCode.ERR_1);
}
......@@ -70,9 +72,18 @@ public class StaffController extends WebBaseController{
@RequestMapping("staff-list")
public HaobanResponse staffList(String departmentId,Integer activeFlag,String keyword,BasePageInfo pageInfo){
Page<StaffDTO> page = staffApiService.pageStaff(departmentId,activeFlag,keyword,pageInfo);
List<StaffDTO> list = page.getResult();
for (StaffDTO staffDTO : list) {
logger.info("【成员列表】departmentId={},staffId={}",departmentId,staffDTO.getStaffId());
StaffDepartmentRelatedDTO related = staffApiService.getDepartmentIdAndStaffId(departmentId,staffDTO.getStaffId());
logger.info("【成员列表】related={}",JSON.toJSONString(related));
if(related != null) {
staffDTO.setStaffDepartmentRelatedId(related.getStaffDepartmentRelatedId());
}
}
logger.info("【员工列表】page={}",JSON.toJSONString(page));
PageResult<StaffDTO> pageVo = new PageResult<>();
pageVo.setList(page.getResult());
pageVo.setList(list);
pageVo.setPageNum(page.getCurrentPage());
pageVo.setPages(page.getPages());
pageVo.setPageSize(page.getPageSize());
......
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