Commit 11db84a0 by fudahua

好友会员数量以及关联数量

parent 816f6f0f
......@@ -193,4 +193,12 @@ public interface ExternalClerkRelatedApiService {
* @date 2021-12-13 15:37:57
*/
boolean updateNewExternalUserid(String wxEnterpriseId);
/**
* 获取导购的好有数
*
* @param clerkId
* @return
*/
public int countFriendCountByClerkId(String wxEnterpriseId, String enterpriseId, String wxUserId, String clerkId);
}
......@@ -252,4 +252,18 @@ public interface TabHaobanExternalClerkRelatedMapper {
int updateExternalUserIdByOldExternalUserId(@Param("externalUserId") String externalUserId,
@Param("oldExternalUserId") String oldExternalUserId,
@Param("wxEnterpriseId") String wxEnterpriseId);
/**
* 获取好友数量
*
* @param wxEnterpriseId 企业id
* @param enterpriseId 商户id
* @param wxUserId 企业微信导购账号
* @param clerkId 导购id
* @return
*/
int countByClerkId(@Param("wxEnterpriseId") String wxEnterpriseId,
@Param("enterpriseId") String enterpriseId,
@Param("wxUserId") String wxUserId,
@Param("clerkId") String clerkId);
}
\ No newline at end of file
......@@ -376,4 +376,9 @@ public class ExternalClerkRelatedApiServiceImpl implements ExternalClerkRelatedA
return new PageInfo<>(tabHaobanWxEnterpriseList);
}
@Override
public int countFriendCountByClerkId(String wxEnterpriseId, String enterpriseId, String wxUserId, String clerkId) {
return tabHaobanExternalClerkRelatedMapper.countByClerkId(wxEnterpriseId, enterpriseId, wxUserId, clerkId);
}
}
......@@ -591,4 +591,13 @@
and wx_enterprise_id = #{wxEnterpriseId}
</update>
<select id="countByClerkId" resultType="Integer">
select count(*)
from tab_haoban_external_clerk_related
where wx_enterprise_id = #{wxEnterpriseId}
and enterprise_id = #{enterpriseId}
and wx_user_id = #{wxUserId}
and clerk_id = #{clerkId}
AND status_flag = 1
</select>
</mapper>
\ No newline at end of file
......@@ -14,6 +14,7 @@ import com.gic.enterprise.api.dto.EnterpriseDTO;
import com.gic.enterprise.api.dto.StoreDTO;
import com.gic.enterprise.api.service.EnterpriseService;
import com.gic.enterprise.api.service.StoreService;
import com.gic.haoban.app.customer.service.api.service.CustomerApiService;
import com.gic.haoban.app.customer.service.api.service.DistributeApiService;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.base.api.common.PageResult2;
......@@ -29,6 +30,7 @@ import com.gic.haoban.manage.api.service.*;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.qo.CommonQO;
import com.gic.haoban.manage.web.vo.*;
import com.gic.haoban.manage.web.vo.notify.CustomerFriendMemberVO;
import com.gic.redis.data.util.RedisUtil;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -83,6 +85,9 @@ public class ClerkController extends WebBaseController {
@Autowired
private OperationSettingApiService operationSettingApiService;
@Autowired
private CustomerApiService customerApiService;
//选择成员列表
@RequestMapping("/staff-list")
public HaobanResponse staffList(String storeId) {
......@@ -640,17 +645,59 @@ public class ClerkController extends WebBaseController {
return !over;
}).map(s->s.getEnterpriseId()).collect(Collectors.toList());
List<String> storeIds = wxEnterpriseRelatedApiService.listStoreIdByWxEnterpriseId(wxEnterpriseId);
List<ClerkDTO> clerkList = this.getClerkListBySearch(enterpriseIdList, storeIds, keyword, staffId);
List<ClerkDTO> clerkList = clerkNewService.listClerkByEnterpriseIdAndSearch(enterpriseIdList, storeIds, keyword);
// List<ClerkDTO> clerkList = this.getClerkListBySearch(enterpriseIdList, storeIds, keyword, staffId);
// List<ClerkDTO> clerkList = clerkNewService.listClerkByEnterpriseIdAndSearch(enterpriseIdList, storeIds, keyword);
List<ClerkStoreVO> clerkStoreList = new ArrayList<>();
if(CollectionUtil.isEmpty(clerkList)){
List<ClerkStoreVO> clerkStoreList = buildClerkRelation(clerkList, enterpriseIdList);
return resultResponse(HaoBanErrCode.ERR_1,clerkStoreList);
}
/**
* 未关联导购列表
*
* @param keyword
* @param wxEnterpriseId
* @param staffId
* @return
*/
@RequestMapping("query-unbind-clerk-list")
public HaobanResponse queryUnbindClerkList(String wxEnterpriseId, String staffId) {
if (StringUtils.isAnyBlank(staffId, wxEnterpriseId)) {
return resultResponse(HaoBanErrCode.ERR_2);
}
List<EnterpriseDetailDTO> list = wxEnterpriseRelatedApiService.listEnterpriseByWxEnterpriseId(wxEnterpriseId);
if (list == null || list.isEmpty()) {
return resultResponse(HaoBanErrCode.ERR_1);
}
List<String> enterpriseIdList = list.stream().filter(s -> {
boolean over = isEnterpriseOver(s.getEnterpriseId());
return !over;
}).map(s -> s.getEnterpriseId()).collect(Collectors.toList());
List<String> storeIds = wxEnterpriseRelatedApiService.listStoreIdByWxEnterpriseId(wxEnterpriseId);
List<ClerkDTO> clerkList = this.getUnbindClerkList(enterpriseIdList, storeIds, staffId);
List<ClerkStoreVO> clerkStoreList = buildClerkRelation(clerkList, enterpriseIdList);
return resultResponse(HaoBanErrCode.ERR_1, clerkStoreList);
}
/**
* 组装关联导购的显示信息 view
*
* @param clerkList
* @param enterpriseIdList
* @return
*/
private List<ClerkStoreVO> buildClerkRelation(List<ClerkDTO> clerkList, List<String> enterpriseIdList) {
List<ClerkStoreVO> clerkStoreList = new ArrayList<>();
if (CollectionUtil.isEmpty(clerkList)) {
return clerkStoreList;
}
List<EnterpriseDTO> enterpriselist = enterpriseService.listEnterpriseByIds(enterpriseIdList);
Map<String,EnterpriseDTO> map = com.gic.commons.util.CollectionUtil.toMap(enterpriselist,"enterpriseId");
List<String> clerkIds = clerkList.stream().map(s->s.getClerkId()).collect(Collectors.toList());
Map<String, EnterpriseDTO> map = com.gic.commons.util.CollectionUtil.toMap(enterpriselist, "enterpriseId");
List<String> clerkIds = clerkList.stream().map(s -> s.getClerkId()).collect(Collectors.toList());
List<StaffClerkRelationDTO> clerkRelations = staffClerkRelationApiService.listByClerkIds(clerkIds);
Map<String,StaffClerkRelationDTO> clerkBindMap = com.gic.commons.util.CollectionUtil.toMap(clerkRelations, "clerkId");
Map<String, StaffClerkRelationDTO> clerkBindMap = com.gic.commons.util.CollectionUtil.toMap(clerkRelations, "clerkId");
for (ClerkDTO clerk : clerkList) {
String enterpriseId = clerk.getEnterpriseId();
......@@ -662,34 +709,32 @@ public class ClerkController extends WebBaseController {
vo.setClerkCode(clerk.getClerkCode());
vo.setClerkName(clerk.getClerkName());
vo.setClerkType(clerk.getClerkType());
vo.setEnterpriseName(enterpriseDTO == null?"":enterpriseDTO.getEnterpriseName());
vo.setEnterpriseName(enterpriseDTO == null ? "" : enterpriseDTO.getEnterpriseName());
vo.setHeadImg(clerk.getHeadImgUrl());
vo.setPhoneNumber(clerk.getPhoneNumber());
vo.setNationCode(clerk.getNationcode());
StoreDTO store = storeService.getStore(clerk.getStoreId());
vo.setStoreName(store == null?"":store.getStoreName());
vo.setStoreAddress(store == null?"":store.getStoreAddress());
vo.setBindFlag(staffClerkRelationDTO==null ? 0:1);
vo.setStaffId(staffClerkRelationDTO==null ? "":staffClerkRelationDTO.getStaffId());
vo.setStoreName(store == null ? "" : store.getStoreName());
vo.setStoreAddress(store == null ? "" : store.getStoreAddress());
vo.setBindFlag(staffClerkRelationDTO == null ? 0 : 1);
vo.setStaffId(staffClerkRelationDTO == null ? "" : staffClerkRelationDTO.getStaffId());
vo.setStoreId(clerk.getStoreId());
clerkStoreList.add(vo);
}
if(CollectionUtil.isNotEmpty(clerkStoreList)){
clerkStoreList = clerkStoreList.stream().filter(s->org.apache.commons.lang.StringUtils.isNotBlank(s.getStoreId())).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(clerkStoreList)) {
clerkStoreList = clerkStoreList.stream().filter(s -> org.apache.commons.lang.StringUtils.isNotBlank(s.getStoreId())).collect(Collectors.toList());
}
return resultResponse(HaoBanErrCode.ERR_1,clerkStoreList);
return clerkStoreList;
}
/**
* @param enterpriseIdList
* @param storeIdList
* @param search
* @param staffId
* @return
*/
private List<ClerkDTO> getClerkListBySearch(List<String> enterpriseIdList, List<String> storeIdList, String search, String staffId) {
private List<ClerkDTO> getUnbindClerkList(List<String> enterpriseIdList, List<String> storeIdList, String staffId) {
List<ClerkDTO> ret = new ArrayList<ClerkDTO>();
if (StringUtils.isBlank(search)) {
StaffDTO staffDTO = staffApiService.selectById(staffId);
if (staffDTO != null) {
List<ClerkDTO> clerkList = clerkNewService.listClerkByEnterpriseIdAndSearch(enterpriseIdList, storeIdList, staffDTO.getPhoneNumber());
......@@ -699,26 +744,26 @@ public class ClerkController extends WebBaseController {
}
List<StaffClerkInfoDTO> staffClerkInfoDTOS = staffClerkRelationApiService.listBindDetailByStaffId(staffId);
if (CollectionUtils.isNotEmpty(staffClerkInfoDTOS)) {
if (CollectionUtils.isEmpty(staffClerkInfoDTOS)) {
return ret;
}
Set<String> clerkIds = staffClerkInfoDTOS.stream().map(mid -> mid.getClerkId()).collect(Collectors.toSet());
List<ClerkDTO> clerkDTOS = clerkService.getClerkByClerkIds(clerkIds);
for (ClerkDTO clerkDTO : clerkDTOS) {
List<ClerkDTO> clerkList = clerkNewService.listClerkByEnterpriseIdAndSearch(enterpriseIdList, storeIdList, clerkDTO.getPhoneNumber());
if (CollectionUtils.isNotEmpty(clerkList)) {
ret.addAll(clerkList);
}
if (StringUtils.isEmpty(clerkDTO.getPhoneNumber())) {
continue;
}
} else {
List<ClerkDTO> clerkList = clerkNewService.listClerkByEnterpriseIdAndSearch(enterpriseIdList, storeIdList, search);
List<ClerkDTO> clerkList = clerkNewService.listClerkByEnterpriseIdAndSearch(enterpriseIdList, storeIdList, clerkDTO.getPhoneNumber());
if (CollectionUtils.isNotEmpty(clerkList)) {
ret.addAll(clerkList);
}
}
if (CollectionUtils.isEmpty(clerkDTOS)) {
return ret;
}
return ret.stream().filter(mid -> (!clerkIds.contains(mid.getClerkId()))).collect(Collectors.toList());
}
//绑定
@HttpLimit
......@@ -1138,7 +1183,40 @@ public class ClerkController extends WebBaseController {
@RequestMapping("customer-info")
@IgnoreLogin
public HaobanResponse customerInfo(@RequestBody @Valid CommonQO qo) {
CustomerFriendMemberVO ret = new CustomerFriendMemberVO();
StaffDTO staffDTO = staffApiService.selectById(qo.getStaffId());
if (staffDTO == null) {
return resultResponse(HaoBanErrCode.ERR_6);
}
int friendCount = externalClerkRelatedApiService.countFriendCountByClerkId(qo.getWxEnterpriseId(), qo.getEnterpriseId(), staffDTO.getWxUserId(), qo.getClerkId());
int memberCount = customerApiService.countMember(qo.getEnterpriseId(), qo.getStoreId(), qo.getClerkId());
ret.setFriendCount(friendCount);
ret.setMemberCount(memberCount);
return resultResponse(HaoBanErrCode.ERR_1, ret);
}
/**
* 我的-好友会员数
*
* @return
*/
@RequestMapping("can-relation-count")
@IgnoreLogin
public HaobanResponse canRelationCount(@RequestBody @Valid CommonQO qo) {
List<EnterpriseDetailDTO> list = wxEnterpriseRelatedApiService.listEnterpriseByWxEnterpriseId(qo.getWxEnterpriseId());
if (list == null || list.isEmpty()) {
return resultResponse(HaoBanErrCode.ERR_1);
}
List<String> enterpriseIdList = list.stream().filter(s -> {
boolean over = isEnterpriseOver(s.getEnterpriseId());
return !over;
}).map(s -> s.getEnterpriseId()).collect(Collectors.toList());
List<String> storeIds = wxEnterpriseRelatedApiService.listStoreIdByWxEnterpriseId(qo.getWxEnterpriseId());
List<ClerkDTO> clerkList = this.getUnbindClerkList(enterpriseIdList, storeIds, qo.getStaffId());
return resultResponse(HaoBanErrCode.ERR_1,clerkList.size());
}
}
package com.gic.haoban.manage.web.vo.notify;
import java.io.Serializable;
/**
* Created 2021/12/20.
*
* @author hua
*/
public class CustomerFriendMemberVO implements Serializable {
private int friendCount;
private int memberCount;
public int getFriendCount() {
return friendCount;
}
public void setFriendCount(int friendCount) {
this.friendCount = friendCount;
}
public int getMemberCount() {
return memberCount;
}
public void setMemberCount(int memberCount) {
this.memberCount = memberCount;
}
}
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