Commit 01c76d49 by huangZW

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

parents 79dab2a2 bf8bb2d3
package com.gic.haoban.manage.web.controller;
import com.gic.clerk.api.dto.ClerkListDTO;
import com.gic.clerk.api.service.ClerkService;
import com.gic.enterprise.api.dto.*;
import com.gic.enterprise.api.dto.EnterpriseDTO;
import com.gic.enterprise.api.service.EnterpriseService;
import com.gic.enterprise.api.service.StoreService;
import com.gic.haoban.common.utils.EntityUtil;
import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.manage.api.dto.StaffClerkInfoDTO;
import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
import com.gic.haoban.manage.api.dto.*;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.StaffClerkRelationApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.vo.EnterpriseVo;
import com.gic.haoban.manage.web.vo.WxClerkInfoVO;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -16,6 +25,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
* Created 2020/6/3.
......@@ -34,8 +46,21 @@ public class PayController extends WebBaseController {
@Autowired
private WxEnterpriseApiService wxEnterpriseApiService;
@Autowired
private StaffClerkRelationApiService staffClerkRelationApiService;
@Autowired
private ClerkService clerkService;
@Autowired
private StoreService storeService;
@Autowired
private WxEnterpriseRelatedApiService wxEnterpriseRelatedApiService;
@Autowired
private EnterpriseService enterpriseService;
/**
* 微信成员列表
* @param userId
......@@ -43,7 +68,7 @@ public class PayController extends WebBaseController {
* @return
*/
@RequestMapping("/wx-user-list")
public HaobanResponse enterpriseList(String userId,String corpId) {
public HaobanResponse userList(String userId,String corpId) {
if (StringUtils.isAnyBlank(userId,corpId)) {
logger.info("参数异常");
return resultResponse(HaoBanErrCode.ERR_2);
......@@ -68,20 +93,69 @@ public class PayController extends WebBaseController {
* @param storeId
* @return
*/
@RequestMapping("/store-list")
public HaobanResponse enterpriseList(String storeId) {
@RequestMapping("/store-clerk-list")
public HaobanResponse storeList(String storeId,String corpId) {
WxEnterpriseDTO enterpriseDTO = wxEnterpriseApiService.getEnterpriseBycorpId(corpId);
if (enterpriseDTO==null) {
logger.info("不存在商户");
return resultResponse(HaoBanErrCode.ERR_20001);
}
StaffDTO staffDTO = staffApiService.selectByUserIdAndEnterpriseId(userId, enterpriseDTO.getWxEnterpriseId());
if (staffDTO==null) {
logger.info("不存在成员");
return resultResponse(HaoBanErrCode.ERR_6);
StoreDTO store = storeService.getStore(storeId);
if (store==null) {
logger.info("不存在门店");
return resultResponse(HaoBanErrCode.ERR_20002);
}
List<ClerkListDTO> list = clerkService.getClerkByStoreId(store.getEnterpriseId(), storeId);
List<WxClerkInfoVO> retList = EntityUtil.changeEntityListByJSON(WxClerkInfoVO.class, list);
if (CollectionUtils.isNotEmpty(retList)) {
List<StaffClerkRelationDTO> relationDTOS = staffClerkRelationApiService.listByStoreId(storeId);
Map<String, StaffClerkRelationDTO> maps = relationDTOS.stream().collect(Collectors.toMap(StaffClerkRelationDTO::getClerkId, mid -> mid));
retList.stream().forEach(wxClerkInfoVO -> {
StaffClerkRelationDTO relationDTO = maps.get(wxClerkInfoVO.getClerkId());
if (null!=relationDTO) {
wxClerkInfoVO.setStaffId(relationDTO.getStaffId());
wxClerkInfoVO.setWxUserId(relationDTO.getWxUserId());
}
});
}
return resultResponse(HaoBanErrCode.ERR_1,retList);
}
List<StaffClerkInfoDTO> list = staffClerkRelationApiService.listBindDetailByStaffId(staffDTO.getStaffId());
return resultResponse(HaoBanErrCode.ERR_1,list);
/**
* 微信企业列表
* @return
*/
@RequestMapping("/enterprise-list")
public HaobanResponse enterpriseList() {
List<EnterpriseDetailDTO> list = wxEnterpriseRelatedApiService.queryAllHasGicEnterpriseId();
Set<String> wxEnterpriseIds = list.stream().map(enterpriseDetailDTO -> {
return enterpriseDetailDTO.getWxEnterpriseId();
}).collect(Collectors.toSet());
List<String> enterpriseIds = list.stream().map(enterpriseDetailDTO -> {
return enterpriseDetailDTO.getEnterpriseId();
}).collect(Collectors.toList());
List<EnterpriseDTO> enterpriseDTOS = enterpriseService.listEnterpriseByIds(enterpriseIds);
Map<String, EnterpriseDTO> gicEntMap = enterpriseDTOS.stream().collect(Collectors.toMap(EnterpriseDTO::getEnterpriseId, _t -> _t));
List<EnterpriseVo> enterpriseVos = EntityUtil.changeEntityListByJSON(EnterpriseVo.class, list);
List<YwWxEnterpriseDTO> ywWxEnterpriseDTOS = wxEnterpriseApiService.listByIds(wxEnterpriseIds);
Map<String, YwWxEnterpriseDTO> map = ywWxEnterpriseDTOS.stream().collect(Collectors.toMap(YwWxEnterpriseDTO::getWxEnterpriseId, _t -> _t));
enterpriseVos.forEach(enterpriseVo -> {
YwWxEnterpriseDTO enterpriseDTO = map.get(enterpriseVo.getWxEnterpriseId());
EnterpriseDTO gicEnt = gicEntMap.get(enterpriseVo.getEnterpriseId());
if (null!=enterpriseDTO) {
enterpriseVo.setWxEnterpiseName(enterpriseDTO.getCorpName());
}
if (null!=gicEnt) {
enterpriseVo.setEnterpriseName(gicEnt.getEnterpriseName());
}
});
return resultResponse(HaoBanErrCode.ERR_1,enterpriseVos);
}
}
......@@ -70,7 +70,8 @@ public enum HaoBanErrCode {
ERR_10006(10006,"字典key已存在"),
ERR_10007(10007,"字典名称已存在"),
ERR_10008(10008,"title已存在"),
ERR_20001(20001,"企业微信商户不存在"),
ERR_20002(20002,"门店不存在"),
ERR_DEFINE(-888, "自定义错误"),
ERR_OTHER(-999, "未知错误code");
private int code;
......
package com.gic.haoban.manage.web.vo;
import java.io.Serializable;
/**
* Created 2018/10/22.
*
* @author hua
*/
public class EnterpriseVo implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private String wxEnterpriseId;
private String enterpriseId;
private String enterpriseName;
private String wxEnterpiseName;
public String getWxEnterpriseId() {
return wxEnterpriseId;
}
public void setWxEnterpriseId(String wxEnterpriseId) {
this.wxEnterpriseId = wxEnterpriseId;
}
public String getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public String getEnterpriseName() {
return enterpriseName;
}
public void setEnterpriseName(String enterpriseName) {
this.enterpriseName = enterpriseName;
}
public String getWxEnterpiseName() {
return wxEnterpiseName;
}
public void setWxEnterpiseName(String wxEnterpiseName) {
this.wxEnterpiseName = wxEnterpiseName;
}
}
package com.gic.haoban.manage.web.vo;
import java.io.Serializable;
/**
* Created 2020/6/4.
*
* @author hua
*/
public class WxClerkInfoVO implements Serializable {
private String enterpriseId;
private String clerkId;
private String staffId;
private String wxUserId;
private String clerkName;
private int clerkType;
public String getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public String getClerkId() {
return clerkId;
}
public void setClerkId(String clerkId) {
this.clerkId = clerkId;
}
public String getStaffId() {
return staffId;
}
public void setStaffId(String staffId) {
this.staffId = staffId;
}
public String getWxUserId() {
return wxUserId;
}
public void setWxUserId(String wxUserId) {
this.wxUserId = wxUserId;
}
public String getClerkName() {
return clerkName;
}
public void setClerkName(String clerkName) {
this.clerkName = clerkName;
}
public int getClerkType() {
return clerkType;
}
public void setClerkType(int clerkType) {
this.clerkType = clerkType;
}
}
......@@ -20,6 +20,7 @@
<!--<dubbo:registry address="zookeeper://localhost:2181|zookeeper://115.159.182.172:2199" protocol="dubbo"/>-->
<dubbo:reference interface="com.gic.haoban.manage.api.service.StaffApiService" id="staffApiService"/>
<dubbo:reference interface="com.gic.haoban.manage.api.service.StaffClerkRelationApiService" id="staffClerkRelationApiService"/>
<dubbo:reference interface="com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService" id="wxEnterpriseRelatedApiService" />
<dubbo:reference interface="com.gic.haoban.manage.api.service.ApplicationApiService" id="applicationApiService"/>
<dubbo:reference interface="com.gic.haoban.manage.api.service.WxEnterpriseApiService" id="wxEnterpriseApiService"/>
......
......@@ -13,6 +13,7 @@
<mvc:exclude-mapping path="/gic-login*"/>
<mvc:exclude-mapping path="/*test.json"/>
<mvc:exclude-mapping path="/test/*"/>
<mvc:exclude-mapping path="/pay/*"/>
<mvc:exclude-mapping path="/login"/>
<mvc:exclude-mapping path="/nationcode/get-nationcode-list"/>
<mvc:exclude-mapping path="/get-pic-code"/>
......
......@@ -4,13 +4,16 @@ import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.symmetric.AES;
import com.alibaba.dubbo.common.URL;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.gic.commons.util.ToolUtil;
import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.manage.api.dto.EnterpriseDetailDTO;
import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.api.dto.WxApplicationDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.WxApplicationApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseApiService;
import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService;
import com.gic.haoban.manage.web.anno.IgnoreLogin;
......@@ -21,6 +24,8 @@ import com.gic.haoban.manage.web.vo.LoginVO;
import com.gic.redis.data.util.RedisUtil;
import com.gic.wechat.api.dto.qywx.UserDTO;
import com.gic.wechat.api.service.qywx.QywxCorpApiService;
import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -35,6 +40,8 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
@RestController
......@@ -56,6 +63,12 @@ public class LoginController extends WebBaseController{
@Autowired
private WxEnterpriseRelatedApiService wxEnterpriseRelatedApiService;
@Autowired
private QywxSuiteApiService qywxSuiteApiService;
@Autowired
private WxApplicationApiService wxApplicationApiService;
@Autowired
private Config config;
......@@ -201,6 +214,35 @@ public class LoginController extends WebBaseController{
ModelAndView model = new ModelAndView(new RedirectView("/haoban-3/#/gic-error", false,false));
return model;
}
String wxEnterpriseId = detailDTO.getWxEnterpriseId();
WxApplicationDTO application = wxApplicationApiService.selectByWxEnterpriseIdAndApplicationType(wxEnterpriseId, 2);
if (null == application) {
logger.info("登录企业应用 没授权!{}");
ModelAndView model = new ModelAndView(new RedirectView("/haoban-3/#/gic-error", false,false));
return model;
}
WxEnterpriseDTO enterprise = wxEnterpriseApiService.getOne(wxEnterpriseId);
if (null == enterprise) {
logger.info("登录失败,不存在对应企业:{}",o);
ModelAndView model = new ModelAndView(new RedirectView("/haoban-3/#/gic-error", false,false));
return model;
}
//获取管理员列表
String adminList = qywxSuiteApiService.getAdminList(enterprise.getCorpid(), application.getSiteId(), Integer.parseInt(application.getAgentId()));
List<String> userIds = new ArrayList<String>();
if(StringUtils.isNotBlank(adminList)){
JSONArray jsonArr = JSON.parseArray(adminList);
for (Object object : jsonArr) {
JSONObject json = JSON.parseObject(JSON.toJSONString(object));
userIds.add(json.getString("userid"));
}
}
if(!userIds.contains(staff.getWxUserId())){
logger.info("登录失败,当前用户不是管理员:{}",JSON.toJSONString(userIds));
ModelAndView model = new ModelAndView(new RedirectView("/haoban-3/#/gic-error", false,false));
return model;
}
// StaffDTO staff = staffApiService.selectById("1");
LoginVO loginVO = new LoginVO();
loginVO.setWxEnterpriseId(detailDTO.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