Commit 7a6e397c by 徐高华

企微托管

parent 48202629
......@@ -2,6 +2,7 @@ package com.gic.haoban.manage.api.dto;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* tab_haoban_open_staff
......@@ -22,6 +23,9 @@ public class OpenStaffDTO implements Serializable {
* 成员id
*/
private String staffId;
private String wxUserId ;
private String wxOpenUserId ;
private String staffName ;
/**
* 创建时间
......@@ -109,10 +113,47 @@ public class OpenStaffDTO implements Serializable {
private String loginRemark ;
/**
* 关联导购
*/
List<StoreClerkDTO> clerkList ;
/**
* tab_haoban_open_staff
*/
private static final long serialVersionUID = 1L;
public List<StoreClerkDTO> getClerkList() {
return clerkList;
}
public void setClerkList(List<StoreClerkDTO> clerkList) {
this.clerkList = clerkList;
}
public String getWxOpenUserId() {
return wxOpenUserId;
}
public void setWxOpenUserId(String wxOpenUserId) {
this.wxOpenUserId = wxOpenUserId;
}
public String getWxUserId() {
return wxUserId;
}
public void setWxUserId(String wxUserId) {
this.wxUserId = wxUserId;
}
public String getStaffName() {
return staffName;
}
public void setStaffName(String staffName) {
this.staffName = staffName;
}
public String getLoginRemark() {
return loginRemark;
}
......
package com.gic.haoban.manage.api.dto;
import java.io.Serializable;
public class StoreClerkDTO implements Serializable {
private String storeId ;
private String storeName ;
private String storeCode ;
private String clerkId ;
private String clerkName ;
private String clerkCode ;
public String getStoreId() {
return storeId;
}
public void setStoreId(String storeId) {
this.storeId = storeId;
}
public String getStoreName() {
return storeName;
}
public void setStoreName(String storeName) {
this.storeName = storeName;
}
public String getStoreCode() {
return storeCode;
}
public void setStoreCode(String storeCode) {
this.storeCode = storeCode;
}
public String getClerkId() {
return clerkId;
}
public void setClerkId(String clerkId) {
this.clerkId = clerkId;
}
public String getClerkName() {
return clerkName;
}
public void setClerkName(String clerkName) {
this.clerkName = clerkName;
}
public String getClerkCode() {
return clerkCode;
}
public void setClerkCode(String clerkCode) {
this.clerkCode = clerkCode;
}
}
package com.gic.haoban.manage.api.qdto;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
public class OpenStaffPageQDTO implements Serializable {
private String wxEnterpriseId ;
private String enterpriseId ;
/**
* 1授权中 2已过期 3待验证 4待授权 0全部
*/
private int status ;
/**
* 导购
*/
private String clerkId ;
/**
* 成员
*/
private String staffParams ;
/**
* 门店分组
*/
private List<String> storeGroupIdList ;
/**
* 开始日期
*/
private Date startDate ;
/**
* 结束日期
*/
private Date endDate ;
private List<String> staffIds ;
public List<String> getStaffIds() {
return staffIds;
}
public void setStaffIds(List<String> staffIds) {
this.staffIds = staffIds;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public String getClerkId() {
return clerkId;
}
public void setClerkId(String clerkId) {
this.clerkId = clerkId;
}
public String getStaffParams() {
return staffParams;
}
public void setStaffParams(String staffParams) {
this.staffParams = staffParams;
}
public List<String> getStoreGroupIdList() {
return storeGroupIdList;
}
public void setStoreGroupIdList(List<String> storeGroupIdList) {
this.storeGroupIdList = storeGroupIdList;
}
public Date getStartDate() {
return startDate;
}
public void setStartDate(Date startDate) {
this.startDate = startDate;
}
public Date getEndDate() {
return endDate;
}
public void setEndDate(Date endDate) {
this.endDate = endDate;
}
public String getWxEnterpriseId() {
return wxEnterpriseId;
......
......@@ -146,4 +146,6 @@ public interface TabHaobanStaffClerkRelationMapper {
List<String> taskoverClerkIdList(@Param("staffId")String staffId, @Param("delTime") Date delTime) ;
List<TabHaobanStaffClerkRelation> taskoverClerkIdListAll(@Param("staffId")String staffId) ;
List<String> listAllStaffIdForOpenStaff(@Param("enterpriseId")String enterpriseId, @Param("wxEnterpriseId")String wxEnterpriseId, @Param("clerkId") String clerkId, @Param(("storeIdList")) List<String> storeIdList);
}
\ No newline at end of file
......@@ -194,4 +194,6 @@ public interface StaffClerkRelationService {
* @return
*/
List<String> listAllStaffIdByEnterpriseId(String enterpriseId,String wxEnterpriseId);
List<String> listAllStaffIdForOpenStaff(String enterpriseId,String wxEnterpriseId,String clerkId , List<String> storeIdList);
}
package com.gic.haoban.manage.service.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.BasePageInfo;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.clerk.api.dto.ClerkDTO;
import com.gic.clerk.api.service.ClerkService;
import com.gic.commons.util.PageHelperUtils;
import com.gic.commons.util.UniqueIdUtils;
import com.gic.enterprise.api.dto.StoreDTO;
import com.gic.enterprise.api.dto.StoreSearchDTO;
import com.gic.enterprise.api.service.StoreGroupService;
import com.gic.enterprise.api.service.StoreService;
import com.gic.haoban.manage.api.dto.OpenStaffDTO;
import com.gic.haoban.manage.api.dto.chat.GroupChatDTO;
import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.api.dto.StoreClerkDTO;
import com.gic.haoban.manage.api.qdto.OpenStaffPageQDTO;
import com.gic.haoban.manage.api.service.OpenStaffApiService;
import com.gic.haoban.manage.service.dao.mapper.OpenStaffMapper;
import com.gic.haoban.manage.service.entity.TabOpenStaff;
import com.gic.haoban.manage.service.service.OpenStaffService;
import com.gic.haoban.manage.service.service.StaffClerkRelationService;
import com.gic.haoban.manage.service.util.OpenUtils;
import com.github.pagehelper.PageHelper;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
@Service("openStaffService")
public class OpenStaffServiceImpl implements OpenStaffService {
......@@ -29,37 +38,45 @@ public class OpenStaffServiceImpl implements OpenStaffService {
private static final Logger log = LogManager.getLogger(OpenStaffService.class);
@Autowired
private OpenStaffMapper openStaffMapper ;
private OpenStaffMapper openStaffMapper;
@Autowired
private StaffClerkRelationService staffClerkRelationService;
@Autowired
private StoreGroupService storeGroupService;
@Autowired
private StoreService storeService;
@Autowired
private ClerkService clerkService ;
@Override
public TabOpenStaff save(TabOpenStaff tab) {
tab.setUpdateTime(new Date());
if(null == tab.getOpenStaffId()) {
if (null == tab.getOpenStaffId()) {
tab.setOpenStaffId(UniqueIdUtils.uniqueLong());
tab.setDeleteFlag(0);
tab.setCreateTime(new Date());
this.openStaffMapper.insert(tab) ;
}else {
this.openStaffMapper.update(tab) ;
this.openStaffMapper.insert(tab);
} else {
this.openStaffMapper.update(tab);
}
return tab ;
return tab;
}
@Override
public TabOpenStaff getByUUID(String uuid) {
TabOpenStaff openStaff = this.openStaffMapper.getByUUID(uuid) ;
if(null == openStaff) {
log.info("通过uuid查不到={}",uuid);
TabOpenStaff openStaff = this.openStaffMapper.getByUUID(uuid);
if (null == openStaff) {
log.info("通过uuid查不到={}", uuid);
OpenUtils.logout(uuid);
}
return openStaff;
}
@Override
public void logout(String uuid , String loginRemark , int step) {
TabOpenStaff openStaff = this.getByUUID(uuid) ;
if(null == openStaff) {
return ;
public void logout(String uuid, String loginRemark, int step) {
TabOpenStaff openStaff = this.getByUUID(uuid);
if (null == openStaff) {
return;
}
OpenUtils.logout(uuid);
openStaff.setStep(step);
......@@ -72,14 +89,66 @@ public class OpenStaffServiceImpl implements OpenStaffService {
openStaff.setKey2(null);
openStaff.setUuid(null);
openStaff.setLoginRemark(loginRemark);
this.openStaffMapper.update(openStaff) ;
this.openStaffMapper.update(openStaff);
}
@Override
public ServiceResponse<Page<OpenStaffDTO>> page(OpenStaffPageQDTO qdto, BasePageInfo basePageInfo) {
log.info("分页查询条件={}",JSONObject.toJSONString(qdto));
String wxEnterpriseId = qdto.getWxEnterpriseId();
String enterpriseId = qdto.getEnterpriseId();
List<String> storeIdList = null;
if(CollectionUtils.isNotEmpty(qdto.getStoreGroupIdList())) {
storeIdList = this.getStoreIdList(enterpriseId,qdto.getStoreGroupIdList()) ;
}
if (StringUtils.isNotBlank(qdto.getClerkId()) || CollectionUtils.isNotEmpty(storeIdList)) {
List<String> staffIds = staffClerkRelationService.listAllStaffIdForOpenStaff(enterpriseId, wxEnterpriseId, qdto.getClerkId(), storeIdList);
if (CollectionUtils.isEmpty(staffIds)) {
return ServiceResponse.success(new Page<>());
}
qdto.setStaffIds(staffIds);
}
PageHelper.startPage(basePageInfo);
List<OpenStaffDTO> list = this.openStaffMapper.list(qdto);
Set<String> staffIdList = list.stream().map(dto -> dto.getStaffId()).collect(Collectors.toSet());
List<StaffClerkRelationDTO> relationDTOList = staffClerkRelationService.listByWxEnterpriseIdAndStaffId(wxEnterpriseId, staffIdList);
relationDTOList = relationDTOList.stream().filter(o->o.getEnterpriseId().equals(enterpriseId)).collect(Collectors.toList()) ;
Map<String, ClerkDTO> clerkMap = new HashMap<>() ;
if(CollectionUtils.isNotEmpty(relationDTOList)) {
Set<String> clerkIdSet = relationDTOList.stream().map(o->o.getClerkId()).collect(Collectors.toSet()) ;
if(CollectionUtils.isNotEmpty(clerkIdSet)) {
List<ClerkDTO> clerkDTOS = this.clerkService.getClerkByIds(clerkIdSet);
clerkMap.putAll(clerkDTOS.stream().collect(Collectors.toMap(o -> o.getClerkId(), o -> o, (k1, k2) -> k1)));
}
}
log.info("导购={}", JSONObject.toJSONString(clerkMap));
for(OpenStaffDTO item : list) {
String staffId = item.getStaffId() ;
List<StoreClerkDTO> clerkList = new ArrayList<>() ;
for (StaffClerkRelationDTO clerkRelation : relationDTOList){
if (clerkRelation.getStaffId().equals(staffId)){
String storeId = clerkRelation.getStoreId() ;
String clerkId = clerkRelation.getClerkId() ;
ClerkDTO clerkDTO = clerkMap.get(clerkId) ;
if(null != clerkDTO) {
StoreClerkDTO cs = new StoreClerkDTO();
cs.setClerkId(clerkId);
cs.setClerkName(clerkDTO.getClerkName());
cs.setClerkCode(clerkDTO.getClerkCode());
StoreDTO store = this.storeService.getStore(storeId);
if(null != store) {
cs.setStoreId(storeId);
cs.setStoreName(store.getStoreName());
cs.setStoreCode(store.getStoreCode());
}
clerkList.add(cs) ;
}
}
}
item.setClerkList(clerkList);
}
Page<OpenStaffDTO> retPage = PageHelperUtils.changePageHelperToCurrentPage(list, OpenStaffDTO.class);
log.info("分页查询结果={}",JSONObject.toJSONString(retPage,true));
return ServiceResponse.success(retPage);
}
......@@ -87,4 +156,25 @@ public class OpenStaffServiceImpl implements OpenStaffService {
public List<String> listAllStaffId(String wxEnterpriseId) {
return this.openStaffMapper.listAllStaffId(wxEnterpriseId);
}
private List<String> getStoreIdList(String enterpriseId, List<String> storeGroupIds) {
StoreSearchDTO storeSearch = new StoreSearchDTO();
List<String> groupIds = storeGroupService.getStoreGroupIdsByParentGroupId(enterpriseId, storeGroupIds);
storeSearch.setStoreGroupIdList(groupIds);
storeSearch.setEnterpriseId(enterpriseId);
storeSearch.setStatus("2");
Page pageStore = new Page<>();
//-1代表不分页
pageStore.setCurrentPage(-1);
Page resultPage = storeService.storeListPage(pageStore, storeSearch);
List<StoreDTO> storeDTOList = resultPage.getResult();
if (CollectionUtils.isEmpty(storeDTOList)) {
return new ArrayList<>();
}
log.info("门店条件查询,返回={}条", storeDTOList.size());
List<String> searchStoreIds = storeDTOList.stream().map(StoreDTO::getStoreId).distinct().collect(Collectors.toList());
return searchStoreIds;
}
}
......@@ -594,4 +594,9 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
public List<String> listAllStaffIdByEnterpriseId(String enterpriseId, String wxEnterpriseId) {
return this.mapper.listAllStaffIdByEnterpriseId(enterpriseId,wxEnterpriseId);
}
@Override
public List<String> listAllStaffIdForOpenStaff(String enterpriseId, String wxEnterpriseId, String clerkId, List<String> storeIdList) {
return this.mapper.listAllStaffIdForOpenStaff(enterpriseId,wxEnterpriseId,clerkId,storeIdList);
}
}
......@@ -123,8 +123,65 @@
from tab_haoban_open_staff where uuid = #{uuid} and delete_flag = 0
</select>
<select id="list" resultMap="BaseResultMap" parameterType="com.gic.haoban.manage.api.qdto.OpenStaffPageQDTO">
select * from tab_haoban_open_staff
<select id="list" resultType="com.gic.haoban.manage.api.dto.OpenStaffDTO" parameterType="com.gic.haoban.manage.api.qdto.OpenStaffPageQDTO">
select a.open_staff_id openStaffId ,
a.wx_enterprise_id wxEnterpriseId ,
a.enterprise_id enterpriseId ,
a.staff_id staffId ,
a.create_time createTime ,
a.update_time updateTime ,
a.uuid uuid ,
a.delete_flag deleteFlag ,
a.status_flag statusFlag ,
a.step step ,
a.qw_user_id qwUserId ,
a.wx_corp_id wxCorpId ,
a.qr_code_1 qrCode1 ,
a.key_1 key1 ,
a.qr_code_2 qrCode2 ,
a.key_2 key2 ,
a.valid_flag validFlag ,
a.auth_time authTime ,
a.first_auth_time firstAuthTime ,
a.valid_qrcode_flag validQrcodeFlag ,
a.login_remark loginRemark ,
b.staff_name staffName ,
b.wx_user_id wxUserId ,
b.wx_open_user_id wxOpenUserId
from tab_haoban_open_staff a left JOIN tab_haoban_staff b on a.staff_id = b.staff_id
where a.wx_enterprise_id = #{wxEnterpriseId} and a.enterprise_id=#{enterpriseId}
<if test="status==1">
and a.status_flag = 1
</if>
<if test="status==2">
and a.status_flag = 2 and a.first_auth_time is not null
</if>
<if test="status==3">
and a.status_flag = 2 and a.valid_qrcode_flag = 1
</if>
<if test="status==4">
and a.status_flag = 2 and a.first_auth_time is null
</if>
<if test="staffParams != null and staffParams != ''">
and (b.staff_name like CONCAT('%',#{staffParams},'%') or b.wx_user_id like CONCAT('%',#{staffParams},'%') or b.wx_open_user_id like CONCAT('%',#{staffParams},'%') )
</if>
<if test="null != startDate">
and a.create_time <![CDATA[>=]]> #{startDate}
</if>
<if test="null != endDate">
and a.create_time <![CDATA[<=]]> #{endDate}
</if>
<if test="staffIds != null">
and a.staff_id IN
<foreach collection="staffIds" item="id" index="index" open="(" close=")" separator=",">
#{id,jdbcType=VARCHAR}
</foreach>
</if>
order by a.create_time desc
</select>
<select id="getByQwUserId" resultMap="BaseResultMap">
......
......@@ -443,7 +443,7 @@
select
staff_id staffId,
enterprise_id enterpriseId ,
clerk_id clerkId
clerk_id clerkId , store_id storeId
from tab_haoban_staff_clerk_relation
WHERE
wx_enterprise_id = #{wxEnterpriseId}
......@@ -491,4 +491,20 @@
select <include refid="Base_Column_List"/> from tab_haoban_staff_clerk_relation where staff_id =#{staffId} order by update_time desc
</select>
<select id="listAllStaffIdForOpenStaff" resultType="java.lang.String">
select a.staff_id
from tab_haoban_staff_clerk_relation a left join tab_haoban_staff b on b.staff_id = a.staff_id
where a.enterprise_id = #{enterpriseId} and a.status_flag=1 and b.status_flag = 1 and a.wx_enterprise_id = #{wxEnterpriseId}
<if test="null != clerkId">
and a.clerk_id = #{clerkId}
</if>
<if test="null != storeIdList">
AND a.store_id in
<foreach collection="storeIdList" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
GROUP BY a.staff_id
</select>
</mapper>
\ No newline at end of file
......@@ -5,6 +5,7 @@ import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.PageHelperUtils;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.api.dto.EnterpriseDTO;
import com.gic.enterprise.api.service.EnterpriseService;
import com.gic.haoban.base.api.common.pojo.dto.WebLoginDTO;
import com.gic.haoban.common.utils.AuthWebRequestUtil;
......@@ -66,6 +67,10 @@ public class QywxOpenController {
Page<OpenStaffDTO> page = pageResp.getResult();
Page<OpenStaffVO> retPage = PageHelperUtils.changePageToCurrentPage(page, OpenStaffVO.class);
if(CollectionUtils.isNotEmpty(retPage.getResult())) {
EnterpriseDTO en = this.enterpriseService.getEnterpriseById(enterpriseId) ;
retPage.getResult().forEach(o->{
o.setBrandName(en.getBrandName());
});
}
return RestResponse.successResult(retPage);
}
......
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