Commit 9d346334 by guojx

Merge remote-tracking branch 'origin/developer' into developer

parents ad65461b f21b6fe9
......@@ -150,7 +150,7 @@ public class StaffClerkRelationDTO implements Serializable {
public Integer getOpenConcatFlag() {
if(null == openConcatFlag) {
return 0 ;
return 1 ;
}
return openConcatFlag;
}
......
......@@ -2,6 +2,7 @@ package com.gic.haoban.manage.api.dto.hm;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
*
......@@ -17,6 +18,7 @@ public class HmLinkWxaDTO implements Serializable {
private static final long serialVersionUID = 6473795387449522116L;
private Long pageId ;
private Long hmId ;
private HmPageDTO page;
// 二维码
private String hmQrcode;
......@@ -29,7 +31,15 @@ public class HmLinkWxaDTO implements Serializable {
// 推荐的门店列表
private List<HmLinkStoreDTO> storeList;
// 说明
private String sm ;
private Map<String,String> remarkMap ;
public Long getHmId() {
return hmId;
}
public void setHmId(Long hmId) {
this.hmId = hmId;
}
public HmPageDTO getPage() {
return page;
......@@ -47,12 +57,13 @@ public class HmLinkWxaDTO implements Serializable {
this.pageId = pageId;
}
public String getSm() {
return sm;
public Map<String, String> getRemarkMap() {
return remarkMap;
}
public void setSm(String sm) {
this.sm = sm;
public void setRemarkMap(Map<String, String> remarkMap) {
this.remarkMap = remarkMap;
}
public String getHmQrcode() {
......
package com.gic.haoban.manage.api.service.hm;
import java.util.List;
import com.gic.api.base.commons.BasePageInfo;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
......@@ -11,6 +9,8 @@ import com.gic.haoban.manage.api.dto.hm.HmQrcodeStoreDTO;
import com.gic.haoban.manage.api.dto.qdto.hm.HmQrcodeListQDTO;
import com.gic.haoban.manage.api.dto.qdto.hm.HmQrcodeQDTO;
import java.util.List;
/**
* @author mozhu
* @date 2022/7/5 09:33
......@@ -88,7 +88,7 @@ public interface HmQrcodeApiService {
* @author mozhu
* @date 2022-07-06 15:39:01
*/
ServiceResponse delByClerkId(String clerkId,String enterpriseId);
ServiceResponse delByClerkId(String clerkId,String enterpriseId,String wxEnterpriseId);
/**
......@@ -220,4 +220,6 @@ public interface HmQrcodeApiService {
*/
ServiceResponse<List<String>> listHmIdForIndex(HmQrcodeListQDTO qdto) ;
ServiceResponse<List<String>> listHasQrcodeClerk(String enterpriseId , List<String> clerkIdList) ;
}
......@@ -129,5 +129,16 @@ public interface TabHaobanHmClerkRelationMapper {
* @return
*/
TabHaobanHmClerkRelation getHmClerkByHmIdAndStaffId(@Param("hmId") Long hmId, @Param("staffId") String staffId);
/**
* 更新状态通过id
*
* @param status
* @param relationId
* @return int
* @author mozhu
* @date 2022-07-21 16:32:43
*/
int updateStatusById(@Param("status") Integer status, @Param("relationId") Long relationId);
}
......@@ -168,7 +168,7 @@ public interface TabHaobanHmQrcodeMapper {
* @author mozhu
* @date 2022-07-12 17:39:12
*/
List<HmQrcodeGroupNumBO> getGroupIdNumByEnterpriseId(@Param("enterpriseId") String enterpriseId,@Param("groupIds") List<Long> groupIds, @Param("hmIds") List<String> hmIds);
List<HmQrcodeGroupNumBO> getGroupIdNumByEnterpriseId(@Param("wxEnterpriseId") String wxEnterpriseId, @Param("enterpriseId") String enterpriseId,@Param("groupIds") List<Long> groupIds, @Param("hmIds") List<String> hmIds);
/**
* 获取总数
......@@ -178,7 +178,7 @@ public interface TabHaobanHmQrcodeMapper {
* @author mozhu
* @date 2022-07-12 15:10:09
*/
int getTotalByEnterpriseId(@Param("enterpriseId") String enterpriseId, @Param("hmIds") List<String> hmIds);
int getTotalByEnterpriseId(@Param("wxEnterpriseId") String wxEnterpriseId, @Param("enterpriseId") String enterpriseId, @Param("hmIds") List<String> hmIds);
/**
* 批量修改 活码所属分组
......@@ -206,5 +206,17 @@ public interface TabHaobanHmQrcodeMapper {
List<String> getHmStoreForWxa(@Param("enterpriseId") String enterpriseId);
List<String> listHmIdForIndex(HmQrcodeListQDTO qdto);
/**
*
* @Title: listHasQrcodeClerk
* @Description: 返回已有单人活码的clerkId
* @author xugh
* @param enterpriseId
* @param clerkId
* @return
* @throws
*/
List<String> listHasQrcodeClerk(@Param("enterpriseId")String enterpriseId , @Param("clerkIdList")List<String> clerkIdList) ;
}
......@@ -147,4 +147,16 @@ public interface HmClerkRelationService {
*/
HmClerkRelationBO getHmClerkByHmIdAndStaffId(Long hmId,String staffId);
/**
* 更新状态通过id
*
* @param status 状态
* @param relationId 关系id
* @return int
* @author mozhu
* @date 2022-07-21 16:32:14
*/
int updateStatusById(Integer status, Long relationId);
}
package com.gic.haoban.manage.service.service.hm;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.haoban.manage.api.dto.qdto.hm.HmQrcodeListQDTO;
import com.gic.haoban.manage.api.dto.qdto.hm.HmQrcodeQDTO;
import com.gic.haoban.manage.service.pojo.bo.hm.HmQrcodeBO;
......@@ -10,6 +9,8 @@ import com.gic.haoban.manage.service.pojo.bo.hm.HmQrcodeGroupNumBO;
import java.util.List;
import org.apache.ibatis.annotations.Param;
/**
* 活码(TabHaobanHmQrcode)表服务接口
......@@ -157,7 +158,7 @@ public interface HmQrcodeService {
* @author mozhu
* @date 2022-07-12 17:38:43
*/
List<HmQrcodeGroupNumBO> getGroupIdNumByEnterpriseId(String enterpriseId,List<Long> groupIds, List<String> hmIds);
List<HmQrcodeGroupNumBO> getGroupIdNumByEnterpriseId(String wxEnterpriseId, String enterpriseId, List<Long> groupIds, List<String> hmIds);
/**
* 获取总数
......@@ -167,7 +168,7 @@ public interface HmQrcodeService {
* @author mozhu
* @date 2022-07-12 15:08:35
*/
int getTotalByEnterpriseId(String enterpriseId, List<String> hmIds);
int getTotalByEnterpriseId(String wxEnterpriseId, String enterpriseId, List<String> hmIds);
/**
* 批量修改活码分组
......@@ -185,4 +186,6 @@ public interface HmQrcodeService {
List<String> getHmStoreForWxa(String enterpriseId);
List<String> listHmIdForIndex(HmQrcodeListQDTO qdto);
List<String> listHasQrcodeClerk(String enterpriseId , List<String> clerkIdList) ;
}
......@@ -106,4 +106,9 @@ public class HmClerkRelationServiceImpl implements HmClerkRelationService {
public HmClerkRelationBO getHmClerkByHmIdAndStaffId(Long hmId, String staffId) {
return EntityUtil.changeEntityByOrika(HmClerkRelationBO.class,tabHaobanHmClerkRelationMapper.getHmClerkByHmIdAndStaffId(hmId,staffId));
}
@Override
public int updateStatusById(Integer status, Long relationId) {
return tabHaobanHmClerkRelationMapper.updateStatusById(status,relationId);
}
}
......@@ -123,13 +123,13 @@ public class HmQrcodeServiceImpl implements HmQrcodeService {
}
@Override
public List<HmQrcodeGroupNumBO> getGroupIdNumByEnterpriseId(String enterpriseId, List<Long> groupIds, List<String> hmIds) {
return tabHaobanHmQrcodeMapper.getGroupIdNumByEnterpriseId(enterpriseId, groupIds, hmIds);
public List<HmQrcodeGroupNumBO> getGroupIdNumByEnterpriseId(String wxEnterpriseId, String enterpriseId, List<Long> groupIds, List<String> hmIds) {
return tabHaobanHmQrcodeMapper.getGroupIdNumByEnterpriseId(wxEnterpriseId, enterpriseId, groupIds, hmIds);
}
@Override
public int getTotalByEnterpriseId(String enterpriseId, List<String> hmIds) {
return tabHaobanHmQrcodeMapper.getTotalByEnterpriseId(enterpriseId, hmIds);
public int getTotalByEnterpriseId(String wxEnterpriseId, String enterpriseId, List<String> hmIds) {
return tabHaobanHmQrcodeMapper.getTotalByEnterpriseId(wxEnterpriseId, enterpriseId, hmIds);
}
@Override
......@@ -180,4 +180,9 @@ public class HmQrcodeServiceImpl implements HmQrcodeService {
return tabHaobanHmQrcodeMapper.listHmIdForIndex(qdto) ;
}
@Override
public List<String> listHasQrcodeClerk(String enterpriseId, List<String> clerkIdList) {
return this.tabHaobanHmQrcodeMapper.listHasQrcodeClerk(enterpriseId, clerkIdList);
}
}
......@@ -82,7 +82,7 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
staffClerkBindLogService.pushToMq(clerkRelation.getStaffId(), optStaffId, BindTypeEnum.UNBIND.getVal(), chanelCode, clerkRelation.getStaffClerkRelationId());
//废弃活码
hmQrcodeApiService.delByClerkId(clerkId, clerkRelation.getEnterpriseId());
hmQrcodeApiService.delByClerkId(clerkId, clerkRelation.getEnterpriseId(),clerkRelation.getWxEnterpriseId());
}
return b;
}
......@@ -133,6 +133,7 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
Date now = new Date();
dto.setStaffClerkRelationId(ToolUtil.randomUUID());
dto.setStatusFlag(1);
dto.setOpenConcatFlag(1);
dto.setCreateTime(now);
dto.setUpdateTime(now);
int insert = mapper.insert(EntityUtil.changeEntityByJSON(TabHaobanStaffClerkRelation.class, dto));
......@@ -189,6 +190,7 @@ public class StaffClerkRelationServiceImpl implements StaffClerkRelationService
staffClerkRelation.setCreateTime(new Date());
staffClerkRelation.setUpdateTime(new Date());
staffClerkRelation.setStatusFlag(1);
staffClerkRelation.setOpenConcatFlag(1);
TabHaobanStaffClerkRelation relation = EntityUtil.changeEntityByJSON(TabHaobanStaffClerkRelation.class, staffClerkRelation);
mapper.insert(relation);
return uuid;
......
......@@ -52,11 +52,13 @@ import com.gic.haoban.manage.service.exception.WxApiLimitException;
import com.gic.haoban.manage.service.pojo.DealQywxExternalUserPojo;
import com.gic.haoban.manage.service.pojo.ExternalUserPojo;
import com.gic.haoban.manage.service.pojo.QywxTagSyncInfoPojo;
import com.gic.haoban.manage.service.pojo.bo.hm.HmLinkBO;
import com.gic.haoban.manage.service.pojo.bo.hm.KeyDataLinkBO;
import com.gic.haoban.manage.service.pojo.bo.welcome.WelcomeDetailBO;
import com.gic.haoban.manage.service.pojo.bo.welcome.WelcomeMediaBO;
import com.gic.haoban.manage.service.pojo.bo.welcome.WelcomeReferBO;
import com.gic.haoban.manage.service.service.*;
import com.gic.haoban.manage.service.service.hm.HmLinkService;
import com.gic.haoban.manage.service.service.hm.WxUserAddLogService;
import com.gic.haoban.manage.service.util.CommonUtil;
import com.gic.haoban.manage.service.util.EmojiFilterUtil;
......@@ -164,6 +166,8 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
private KeyDataService keyDataService;
@Autowired
private MemberTagOpenApiService memberTagOpenApiService;
@Autowired
private HmLinkService hmLinkService;
@Override
public void dealQywxExternalUser(String params) {
......@@ -315,7 +319,7 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
String externalUserId = dto.getExternalUserid();
String unionid = dto.getUnionid();
String state = dto.getState();
boolean isHmUnionid = false ;
boolean isHmUnionid = false;
log.info("新增外部联系人,wxEnterpriseId:{}", wxEnterpriseId);
if (StringUtils.isAnyBlank(wxUserId, wxEnterpriseId, name, createTime, externalUserId)) {
log.error("新增外部联系人,缺少必须字段:wxUserId:{},wxEnterpriseId:{},name:{},createTime:{},externalUserId:{}", wxUserId, wxEnterpriseId, name, createTime, externalUserId);
......@@ -333,24 +337,25 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
return;
}
String staffId = staff.getStaffId();
String staffName = staff.getStaffName() ;
String staffName = staff.getStaffName();
String staffWxUserId = staff.getWxUserId();
log.info("新增外部联系人,staff.getWxUserId():{}", staffWxUserId);
dto.setWxUserId(staffWxUserId);
StaffClerkRelationDTO staffClerkRelationDTO = null;
//活码处理 "DT" "HM"
WxUserAddLogQDTO wxUserAddLogQDTO = new WxUserAddLogQDTO();
HmQrcodeDTO hmQrcodeDTO = null;
String memberLabelId = "";
if (StringUtils.isNotBlank(state)) {
String id = state.substring(2);
if (state.contains(Manage3Constants.HM)) {
Long hmId = Convert.toLong(id);
log.info("普通活码={}",hmId);
hmQrcodeDTO = hmQrcodeApiService.getSimpleById(hmId);
log.info("普通活码={}", hmId);
HmQrcodeDTO hmQrcodeDTO = hmQrcodeApiService.getSimpleById(hmId);
if (hmQrcodeDTO == null) {
log.error("活码为空:{}", hmId);
return;
}
memberLabelId = hmQrcodeDTO.getMemberLabelId();
wxUserAddLogQDTO.setHmId(hmId);
hmQrcodeApiService.updateAddNumById(hmId, hmQrcodeDTO.getClerkId());
//处理活码导购
......@@ -379,16 +384,20 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
Long linkId = dataForHmLink.getLinkId();
Long hmId = dataForHmLink.getHmId();
unionid = dataForHmLink.getUnionid();
log.info("动态活码hmId={},linkId={},unionid={}",hmId,linkId,unionid);
isHmUnionid = true ;
log.info("动态活码hmId={},linkId={},unionid={}", hmId, linkId, unionid);
isHmUnionid = true;
wxUserAddLogQDTO.setLinkId(linkId);
wxUserAddLogQDTO.setHmId(hmId);
hmQrcodeDTO = hmQrcodeApiService.getSimpleById(hmId);
HmQrcodeDTO hmQrcodeDTO = hmQrcodeApiService.getSimpleById(hmId);
if (hmQrcodeDTO == null) {
log.error("活码动态为空{}", hmId);
log.error("活码动态为空,hmId:{}", hmId);
return;
}
staffClerkRelationDTO = staffClerkRelationService.getBindByClerkId(hmQrcodeDTO.getClerkId(), wxEnterpriseId);
HmLinkBO hmLinkBO = hmLinkService.getByLinkId(wxEnterpriseId, null, linkId);
if (hmLinkBO != null) {
memberLabelId = hmLinkBO.getMemberLabelId();
}
}
} else {
TabHaobanClerkMainStoreRelated mainStoreRelated = clerkMainStoreRelatedService.getMainStoreByStaffId(staffId, wxEnterpriseId);
......@@ -411,18 +420,19 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
return;
}
String memberId = "";
String memberId = null;
if (StringUtils.isNotBlank(unionid)) {
log.info("有unionid处理:wxEnterpriseId:{},unionid:{}", wxEnterpriseId, unionid);
dto.setUnionid(unionid);
memberId = addExternalClerkRelated(dto, staffId, staffClerkRelationDTO, wxEnterpriseRelated,isHmUnionid);
memberId = addExternalClerkRelated(dto, staffId, staffClerkRelationDTO, wxEnterpriseRelated, isHmUnionid);
} else {
log.info("发送欢迎语逻辑:wxEnterpriseId:{}", wxEnterpriseId);
addFriendByWelcome(dto,staffClerkRelationDTO);
addFriendByWelcome(dto, staffClerkRelationDTO);
}
if (StringUtils.isNotBlank(memberId) && hmQrcodeDTO != null) {
setMemberTag(staffClerkRelationDTO, hmQrcodeDTO,memberId);
if (StringUtils.isNoneBlank(memberId, memberLabelId)) {
//设置会员标签
setMemberTag(staffClerkRelationDTO, memberLabelId, memberId);
}
log.info("插入加好友日志");
......@@ -440,12 +450,13 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
/**
* 设置活码标签
*
* @param staffClerkRelationDTO
* @param hmQrcodeDTO
* @param memberLabelId
* @param memberId
*/
private void setMemberTag(StaffClerkRelationDTO staffClerkRelationDTO, HmQrcodeDTO hmQrcodeDTO,String memberId) {
String memberLabelId = hmQrcodeDTO.getMemberLabelId();
private void setMemberTag(StaffClerkRelationDTO staffClerkRelationDTO, String memberLabelId, String memberId) {
log.info("会员打标签,memberLabelId:{},memberId:{}",memberLabelId,memberId);
if (StringUtils.isNotBlank(memberLabelId)) {
MemberTagSingleDTO tagSingleDTO = new MemberTagSingleDTO();
tagSingleDTO.setEnterpriseId(staffClerkRelationDTO.getEnterpriseId());
......@@ -464,7 +475,7 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
* @param staffClerkRelationDTO
* @param wxEnterpriseRelated
*/
private String addExternalClerkRelated(MemberUnionidRelatedDTO dto, String staffId, StaffClerkRelationDTO staffClerkRelationDTO, TabHaobanWxEnterpriseRelated wxEnterpriseRelated , boolean isHmUnionid) {
private String addExternalClerkRelated(MemberUnionidRelatedDTO dto, String staffId, StaffClerkRelationDTO staffClerkRelationDTO, TabHaobanWxEnterpriseRelated wxEnterpriseRelated, boolean isHmUnionid) {
String wxUserId = dto.getWxUserId();
String wxEnterpriseId = dto.getWxEnterpriseId();
String name = dto.getExternalName();
......@@ -648,9 +659,9 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
WelcomeReferBO welcomeReferBo = getWelcomeReferBo(state);
welcomeDetailBO = welcomeService.getMatchWelcomeWithReferId(staffId, wxEnterpriseId, welcomeReferBo);
//结束临时会话模式
log.info("结束临时会话模式:userid:{},externalUserid:{}",dto.getWxUserId(),dto.getExternalUserid());
log.info("结束临时会话模式:userid:{},externalUserid:{}", dto.getWxUserId(), dto.getExternalUserid());
QywxResponseDTO qywxResponseDTO = qywxUserApiService.closeTempChat(corpid, config.getWxSuiteid(), dto.getWxUserId(), dto.getExternalUserid());
log.info("结束临时会话返回结果:{}",JSON.toJSONString(qywxResponseDTO));
log.info("结束临时会话返回结果:{}", JSON.toJSONString(qywxResponseDTO));
} else {
welcomeDetailBO = welcomeService.getMatchWelcome(staffId, wxEnterpriseId);
}
......
......@@ -323,7 +323,9 @@ public class StaffApiServiceImpl implements StaffApiService {
if (staffThirdWxEnterpriseId.contains(corpid)) {
user = qywxUserApiService.getWorkWxUser(corpid, config.getWxSuiteid(), userId);
UserDTO userSelf = qywxUserApiService.getSelfWorkWxUser(corpid, secretSetting.getSecretVal(), user.getOpen_userid());
if (user != null && userSelf != null) {
user.setName(userSelf.getName());
}
} else {
user = qywxUserApiService.getSelfWorkWxUser(corpid, secretSetting.getSecretVal(), userId);
}
......
......@@ -399,7 +399,7 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
//删除主门店
clerkMainStoreRelatedService.delMainStore(staffId, staffClerkRelation.getStoreId(), wxEnterpriseId);
//废弃活码
hmQrcodeApiService.delByClerkId(clerkId,staffClerkRelation.getEnterpriseId());
hmQrcodeApiService.delByClerkId(clerkId,staffClerkRelation.getEnterpriseId(),wxEnterpriseId);
}
@Override
......@@ -485,7 +485,7 @@ public class StaffClerkRelationApiServiceImpl implements StaffClerkRelationApiSe
ClerkSyncQDTO clerkSyncQDTO = JSON.parseObject(param, ClerkSyncQDTO.class);
Integer type = clerkSyncQDTO.getType();
String clerkId = clerkSyncQDTO.getClerkId();
ClerkDTO clerkDTO = clerkService.getClerkByClerkId(clerkId);
ClerkDTO clerkDTO = clerkService.getClerkByClerkId(clerkId,-1);
if (clerkDTO == null) {
logger.error("导购为空");
return;
......
......@@ -105,7 +105,6 @@ public class HmGroupApiServiceImpl implements HmGroupApiService {
HmGroupInfoQO groupInfoQo = new HmGroupInfoQO();
BeanUtils.copyProperties(groupQueryDTO, groupInfoQo);
groupInfoQo.setWxEnterpriseId(null);
groupInfoQo.setStatus(HmGroupStatus.ENABLE.getCode());
Page<HmGroupSettingBO> groupSettingPage = groupService.queryGroupSettingList(groupInfoQo);
......@@ -123,18 +122,27 @@ public class HmGroupApiServiceImpl implements HmGroupApiService {
log.info("导购拥有的门店权限 clerkId:{}, storeIds:{}", groupQueryDTO.getClerkId(), JSON.toJSONString(storeList));
if (!CollectionUtils.isEmpty(storeList)) {
List<String> hmIds = null;
boolean isStatic = Boolean.TRUE;
if (!storeList.contains("-1")) {
HmQrcodeListQDTO hmQrcodeListQDTO = new HmQrcodeListQDTO();
hmQrcodeListQDTO.setEnterpriseId(groupQueryDTO.getEnterpriseId());
hmQrcodeListQDTO.setStoreId(storeList);
hmIds = qrcodeService.listHmIdForIndex(hmQrcodeListQDTO);
}
List<HmQrcodeGroupNumBO> qrcodeGroupNumBoList = qrcodeService.getGroupIdNumByEnterpriseId(groupQueryDTO.getEnterpriseId(), groupIds, hmIds);
// 非超关权限
HmQrcodeListQDTO hmQrcodeListQdto = new HmQrcodeListQDTO();
hmQrcodeListQdto.setEnterpriseId(groupQueryDTO.getEnterpriseId());
hmQrcodeListQdto.setStoreId(storeList);
hmQrcodeListQdto.setWxEnterpriseId(groupQueryDTO.getWxEnterpriseId());
hmIds = qrcodeService.listHmIdForIndex(hmQrcodeListQdto);
log.info("HMid列表={}", JSON.toJSONString(hmIds));
if (CollectionUtils.isEmpty(hmIds)){
isStatic = false;
}
}
if (isStatic) {
List<HmQrcodeGroupNumBO> qrcodeGroupNumBoList = qrcodeService.getGroupIdNumByEnterpriseId(groupQueryDTO.getWxEnterpriseId(), groupQueryDTO.getEnterpriseId(), groupIds, hmIds);
if (CollectionUtils.isNotEmpty(qrcodeGroupNumBoList)) {
qrcodeGroupNumMap = qrcodeGroupNumBoList.stream()
.collect(Collectors.toMap(HmQrcodeGroupNumBO::getHmGroupId, HmQrcodeGroupNumBO::getNum, (v1, v2) -> v1));
}
}
}
for (HmGroupDTO groupDTO : result) {
Integer referNum = Optional.ofNullable(qrcodeGroupNumMap.get(groupDTO.getGroupId())).orElse(0);
groupDTO.setReferNum(referNum);
......@@ -193,11 +201,15 @@ public class HmGroupApiServiceImpl implements HmGroupApiService {
HmQrcodeListQDTO hmQrcodeListQDTO = new HmQrcodeListQDTO();
hmQrcodeListQDTO.setEnterpriseId(enterpriseId);
hmQrcodeListQDTO.setStoreId(storeList);
hmQrcodeListQDTO.setWxEnterpriseId(wxEnterpriseId);
hmIds = qrcodeService.listHmIdForIndex(hmQrcodeListQDTO);
log.info("导购拥有的活码权限列表:{}", JSON.toJSONString(hmIds));
if (CollectionUtils.isEmpty(hmIds)){
return ServiceResponse.success(0);
}
}
}
int totalReferCount = qrcodeService.getTotalByEnterpriseId(enterpriseId, hmIds);
int totalReferCount = qrcodeService.getTotalByEnterpriseId(wxEnterpriseId, enterpriseId, hmIds);
return ServiceResponse.success(totalReferCount);
}
......
......@@ -2,6 +2,7 @@ package com.gic.haoban.manage.service.service.out.impl.hm;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
......@@ -95,9 +96,9 @@ public class HmLinkApiServiceImpl implements HmLinkApiService {
@Autowired
private MemberClerkApiService memberClerkApiService;
@Autowired
private HmPageService hmPageService ;
private HmPageService hmPageService;
@Autowired
private StoreService storeService ;
private StoreService storeService;
@Override
public ServiceResponse<String> getHmLinkUrl() {
......@@ -157,8 +158,9 @@ public class HmLinkApiServiceImpl implements HmLinkApiService {
HmQrcodeBO hm = null;
HmLinkWxaDTO retDTO = new HmLinkWxaDTO();
log.info("小程序获取活码={},linkShortCode={},mixPhone={},memberId={},unionid={},门店={}{}", enterpriseId, linkShortCode,
mixPhone, memberId, unionid,inStoreId , whitchStore);
mixPhone, memberId, unionid, inStoreId, whitchStore);
HmLinkBO link = this.hmLinkService.getByLinkShortCodeCache(linkShortCode);
Map<String, String> remarkMap = new HashMap<>();
if (null == link) {
log.error("链接记录不存,linkShortCode={}", linkShortCode);
return ServiceResponse.failure(HaoBanErrCode.ERR_OTHER.getCode(), "链接记录不存");
......@@ -187,9 +189,13 @@ public class HmLinkApiServiceImpl implements HmLinkApiService {
// 直接返回门店的导购活码,如果没有返回错误
if (null == hm && StringUtils.isNotBlank(inStoreId)) {
String customRuleJson = link.getCustomRuleJson();
log.info("自定义规则={}", customRuleJson);
log.info("选门店后,whitchStore={},自定义规则={}", whitchStore, customRuleJson);
JSONObject storeRuleObj = JSONObject.parseObject(customRuleJson);
int openFlag = storeRuleObj.getIntValue("open");
// whitchStore 1推荐门店 2附件门店 3省市区门店
if (null == whitchStore) {
whitchStore = 1;
}
if (openFlag == 1) {
int dz = 0, dy = 0;
// 1推荐门店 2附件门店 3省市区门店
......@@ -199,8 +205,7 @@ public class HmLinkApiServiceImpl implements HmLinkApiService {
HmLinkStoreSettingDTO cityStore = storeRuleObj.getObject("city_store", HmLinkStoreSettingDTO.class);
dz = cityStore.getDz();
dy = cityStore.getDy();
}
if (whitchStore == 1 || whitchStore == 2) {
} else if (whitchStore == 1 || whitchStore == 2) {
HmLinkStoreSettingDTO store = storeRuleObj.getObject("store", HmLinkStoreSettingDTO.class);
if (whitchStore == 2 || (storeType == 1 && whitchStore == 1)) {
// 附近门店 或者 推荐门店
......@@ -212,12 +217,12 @@ public class HmLinkApiServiceImpl implements HmLinkApiService {
dy = store.getNdy();
}
}
hm = this.getHmFormStore(wxEnterpriseId, inStoreId, dz, dy);
hm = this.getHmFormStore(wxEnterpriseId, inStoreId, dz, dy, new ArrayList<>());
log.info("获取到的门店配置dz={},dy={},获取的活码={}", dz, dy, JSON.toJSONString(hm));
if (null == hm) {
return ServiceResponse.failure(HaoBanErrCode.ERR_OTHER.getCode(), "导购活码不存在");
}
retDTO.setSm("会员选门店活码");
remarkMap.put("sm", "会员选门店活码");
}
}
// 会员门店
......@@ -251,26 +256,33 @@ public class HmLinkApiServiceImpl implements HmLinkApiService {
String mainStoreId = member.getMainStoreId();
// 服务门店
if (null != fwStore) {
log.info("处理服务门店逻辑");
List<String> clerkIdList = new ArrayList<>() ;
if (fwStore.getZs() == 1 && StringUtils.isNotBlank(mainClerkId)) {
hm = this.getHmFromClerk(mainClerkId, wxEnterpriseId);
clerkIdList.add(mainClerkId);
}
if (null == hm && StringUtils.isNotBlank(mainStoreId)) {
hm = this.getHmFormStore(wxEnterpriseId, mainStoreId, fwStore.getDz(), fwStore.getDy());
hm = this.getHmFormStore(wxEnterpriseId, mainStoreId, fwStore.getDz(), fwStore.getDy(),
clerkIdList);
}
if(null != hm) {
retDTO.setSm("会员主门店活码");
if (null != hm) {
remarkMap.put("sm", "会员主门店活码");
}
}
// 协管门店
List<MemberStoreClerkDataDTO> list = member.getStoreClerkRel();
if (null == hm && null != xgStore && CollectionUtils.isNotEmpty(list)) {
log.info("处理协管门店逻辑");
// 排序协管导购
list = this.sortMemberClerk(enterpriseId, memberId, list);
List<String> storeIdList = new ArrayList<>();
// 协管导购
List<String> clerkIdList = new ArrayList<>();
for (MemberStoreClerkDataDTO item : list) {
String clerkId = item.getClerkIdRel();
if (clerkId.equals(mainClerkId)) {
if (mainStoreId.equals(item.getStoreIdRel())) {
log.info("协管逻辑,主门店直接过滤");
continue;
}
hm = this.getHmFromClerk(clerkId, wxEnterpriseId);
......@@ -279,11 +291,12 @@ public class HmLinkApiServiceImpl implements HmLinkApiService {
break;
}
storeIdList.add(item.getStoreIdRel());
clerkIdList.add(clerkId);
}
// 店长
if (null == hm && xgStore.getDz() == 1 && CollectionUtils.isNotEmpty(storeIdList)) {
for (String storeId : storeIdList) {
hm = this.getHmFormStore(wxEnterpriseId, storeId, 1, 0);
hm = this.getHmFormStore(wxEnterpriseId, storeId, 1, 0, clerkIdList);
if (null != hm) {
break;
}
......@@ -292,14 +305,14 @@ public class HmLinkApiServiceImpl implements HmLinkApiService {
// 店员
if (null == hm && xgStore.getDy() == 1 && CollectionUtils.isNotEmpty(storeIdList)) {
for (String storeId : storeIdList) {
hm = this.getHmFormStore(wxEnterpriseId, storeId, 0, 1);
hm = this.getHmFormStore(wxEnterpriseId, storeId, 0, 1, clerkIdList);
if (null != hm) {
break;
}
}
}
if(null != hm) {
retDTO.setSm("会员协管活码");
if (null != hm) {
remarkMap.put("sm", "会员协管活码");
}
}
}
......@@ -316,7 +329,7 @@ public class HmLinkApiServiceImpl implements HmLinkApiService {
// 活码的门店
List<HmLinkStoreDTO> storeList = this.hmLinkStoreService.listByLinkId(wxEnterpriseId, enterpriseId,
linkId);
this.setStoreAddress(enterpriseId , storeList);
this.setStoreAddress(enterpriseId, storeList);
log.info("门店规则={},推荐门店列表={}", storeType, JSON.toJSONString(storeList));
HmLinkStoreSettingDTO cityStore = storeRuleObj.getObject("city_store", HmLinkStoreSettingDTO.class);
// 是否开启省市区门店查询
......@@ -328,7 +341,9 @@ public class HmLinkApiServiceImpl implements HmLinkApiService {
}
}
if (null != hm) {
log.info("获取到单人活码={}",JSON.toJSONString(hm));
log.info("获取到单人活码={}", JSON.toJSONString(hm));
retDTO.setHmId(hm.getHmId());
remarkMap.put("clerk", hm.getClerkId());
// 判断是否已经是好友
boolean isFriend = false;
if (null != memberId) {
......@@ -339,7 +354,7 @@ public class HmLinkApiServiceImpl implements HmLinkApiService {
isFriend = true;
log.info("已经是好友,staffid={},memberId={}", staffId, memberId);
retDTO.setHmQrcode(hm.getWxQrcode());
retDTO.setSm("老好友,取单人活码");
remarkMap.put("sm", "老好友,取单人活码");
}
}
......@@ -349,37 +364,40 @@ public class HmLinkApiServiceImpl implements HmLinkApiService {
bo.setLinkId(linkId);
bo.setHmId(hm.getHmId());
String dthmKey = this.keyDataService.saveDataForLink(enterpriseId, bo);
remarkMap.put("dthmKey", dthmKey);
if (null != dthmKey) {
ServiceResponse<String> addResp = this.addQrcode(hm, dthmKey, wxEnterpriseDTO.getCorpid(), retDTO);
if (!addResp.isSuccess()) {
retDTO.setSm("创建动态活码失败,取单人活码");
if(StringUtils.isBlank(hm.getWxQrcode())) {
remarkMap.put("sm", "创建动态活码失败,取单人活码");
if (StringUtils.isBlank(hm.getWxQrcode())) {
return ServiceResponse.failure(HaoBanErrCode.ERR_OTHER.getCode(), "导购活码不存在");
}
retDTO.setHmQrcode(hm.getWxQrcode());
} else {
remarkMap.put("动态", "是");
retDTO.setHmQrcode(addResp.getResult());
}
}
}
}
// 生成动态活码
log.info(JSON.toJSONString(retDTO, true));
retDTO.setRemarkMap(remarkMap);
log.info("活码数据返回={}", JSON.toJSONString(retDTO));
return ServiceResponse.success(retDTO);
}
private void setStoreAddress(String enterpriseId ,List<HmLinkStoreDTO> storeList) {
if(CollectionUtils.isNotEmpty(storeList)) {
List<String> storeIdList = storeList.stream().map(dto->dto.getStoreId()).collect(Collectors.toList()) ;
String[] storeIds = new String[storeIdList.size()] ;
for(int i=0;i<storeIdList.size();i++) {
storeIds[i] = storeIdList.get(i) ;
}
List<StoreDTO> dtoList = this.storeService.getStores(storeIds) ;
Map<String,StoreDTO> map = dtoList.stream().collect(Collectors.toMap(StoreDTO::getStoreId, dto->dto,(k1, k2) -> k1));
storeList.forEach(item->{
if(null != map.get(item.getStoreId())) {
private void setStoreAddress(String enterpriseId, List<HmLinkStoreDTO> storeList) {
if (CollectionUtils.isNotEmpty(storeList)) {
List<String> storeIdList = storeList.stream().map(dto -> dto.getStoreId()).collect(Collectors.toList());
String[] storeIds = new String[storeIdList.size()];
for (int i = 0; i < storeIdList.size(); i++) {
storeIds[i] = storeIdList.get(i);
}
List<StoreDTO> dtoList = this.storeService.getStores(storeIds);
Map<String, StoreDTO> map = dtoList.stream()
.collect(Collectors.toMap(StoreDTO::getStoreId, dto -> dto, (k1, k2) -> k1));
storeList.forEach(item -> {
if (null != map.get(item.getStoreId())) {
item.setStoreAddress(map.get(item.getStoreId()).getStoreAddress());
}
});
......@@ -398,7 +416,7 @@ public class HmLinkApiServiceImpl implements HmLinkApiService {
List<String> mainClerkIdList = resp.getResult().stream().map(dto -> dto.getClerkId())
.collect(Collectors.toList());
List<MemberStoreClerkDataDTO> notMainClerkList = new ArrayList<>();
for (MemberStoreClerkDataDTO item : retList) {
for (MemberStoreClerkDataDTO item : list) {
if (mainClerkIdList.contains(item.getClerkIdRel())) {
retList.add(item);
} else {
......@@ -462,23 +480,35 @@ public class HmLinkApiServiceImpl implements HmLinkApiService {
return hm;
}
private HmQrcodeBO getHmFormStore(String wxEnterpriseId, String inStoreId, int dz, int dy) {
private HmQrcodeBO getHmFormStore(String wxEnterpriseId, String inStoreId, int dz, int dy,
List<String> clerkIdList) {
if (StringUtils.isBlank(inStoreId) || "-1".equals(inStoreId)) {
return null;
}
HmQrcodeBO hm = null;
if (dz == 1) {
ClerkDTO dzClerk = this.clerkService.getClerkLeaderByStoreId(inStoreId);
if (null != dzClerk) {
clerkIdList.add(dzClerk.getClerkId());
if (dz == 1) {
hm = this.getHmFromClerk(dzClerk.getClerkId(), wxEnterpriseId);
if (null != hm) {
log.info("选择门店后,获取到店长活码,clerkId={},inStoreId={}", hm.getClerkId(), inStoreId);
}
}
} else {
log.info("店长不存在,storeId={}", inStoreId);
}
}
// 店员需要过滤主导购、店长
log.info("过滤的导购={}",clerkIdList);
if (null == hm && dy == 1) {
List<HmQrcodeBO> list = this.hmQrcodeService.listByStoreId(wxEnterpriseId, inStoreId, 0);
list = list.stream().filter(dto -> !clerkIdList.contains(dto.getClerkId())).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(list)) {
log.info("选择门店下{},导购数={}", inStoreId, list.size());
hm = list.get(new Random().nextInt(list.size()));
if (null != hm) {
log.info("选择门店后,获取到店员活码,clerkId={},inStoreId={}", hm.getClerkId(), inStoreId);
}
}
}
return hm;
......
......@@ -130,7 +130,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
hmQrcodeQDTO.setHmGroupId(0L);
}
List<String> clerkIdList = setStoreClerk(hmQrcodeQDTO, wxEnterpriseId, hmId, hmType);
List<String> clerkIdList = setStoreClerk(hmQrcodeQDTO, wxEnterpriseId, hmId, hmType, true);
if (CollectionUtils.isEmpty(clerkIdList)) {
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()), "该导购已经生成过活码或未关联过好办");
}
......@@ -185,7 +185,11 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
if (clerkIdList.contains("-1")) {
List<HmQrcodeClerkBO> hmQrcodeClerkBOS = hmQrcodeService.listCanAddClerk(wxEnterpriseId, enterpriseId, hmQrcodeQDTO.getCreatorId());
clerkIdList = hmQrcodeClerkBOS.stream().map(HmQrcodeClerkBO::getClerkId).collect(Collectors.toList());
if (CollectionUtils.isEmpty(clerkIdList)) {
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_5.getCode()), "无需要生成活码导购");
}
}
for (String clerkId : clerkIdList) {
hmQrcodeQDTO.setClerkIdList(Collections.singletonList(clerkId));
hmQrcodeQDTO.setInvokingType(3);
......@@ -236,7 +240,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()), "该活码不存在");
}
Integer hmType = hmQrcodeQDTO.getHmType();
List<String> clerkIdList = setStoreClerk(hmQrcodeQDTO, wxEnterpriseId, hmId, hmType);
List<String> clerkIdList = setStoreClerk(hmQrcodeQDTO, wxEnterpriseId, hmId, hmType, false);
if (CollectionUtils.isEmpty(clerkIdList)) {
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()), "该导购已经生成过活码或未关联过好办");
}
......@@ -318,11 +322,11 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
String oldTagName = "";
String tagName = "";
if (tagItemOld != null) {
MemberTagDTO tag = this.memberTagApiService.getMemberTagById(tagItemOld.getTagId()) ;
MemberTagDTO tag = this.memberTagApiService.getMemberTagById(tagItemOld.getTagId());
oldTagName = tag.getTagName() + "-" + tagItem.getTagItemName();
}
if (tagItem != null) {
MemberTagDTO tag = this.memberTagApiService.getMemberTagById(tagItem.getTagId()) ;
MemberTagDTO tag = this.memberTagApiService.getMemberTagById(tagItem.getTagId());
tagName = tag.getTagName() + "-" + tagItem.getTagItemName();
}
logContent.append("活码标签「").append(oldTagName).append("」").append("变更为「").append(tagName).append("」");
......@@ -376,17 +380,24 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
* @param hmType
* @return
*/
private List<String> setStoreClerk(HmQrcodeQDTO hmQrcodeQDTO, String wxEnterpriseId, Long hmId, Integer hmType) {
private List<String> setStoreClerk(HmQrcodeQDTO hmQrcodeQDTO, String wxEnterpriseId, Long hmId, Integer hmType, Boolean addFlag) {
List<String> clerkIdList = hmQrcodeQDTO.getClerkIdList();
if (CollectionUtils.isEmpty(clerkIdList)) {
return null;
}
//单人活码
String clerkId = clerkIdList.get(0);
if (hmType == 2) {
//多人活码
insertHmClerkRelation(hmQrcodeQDTO, wxEnterpriseId, hmId, clerkIdList);
insertHmClerkRelation(hmQrcodeQDTO, wxEnterpriseId, hmId, clerkIdList, addFlag);
} else if (hmType == 1) {
HmQrcodeBO hmQrcodeBO = hmQrcodeService.queryByClerkId(clerkId, wxEnterpriseId);
if (addFlag && hmQrcodeBO != null) {
logger.error("已经生成过活码,clerkId:{}", clerkId);
return null;
}
//单人活码
String clerkId = clerkIdList.get(0);
}
hmQrcodeQDTO.setClerkId(clerkId);
ClerkDTO clerkDTO = clerkService.getclerkById(clerkId);
if (clerkDTO != null) {
......@@ -420,10 +431,15 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
* @param hmId
* @param clerkIdList
*/
private void insertHmClerkRelation(HmQrcodeQDTO hmQrcodeQDTO, String wxEnterpriseId, Long hmId, List<String> clerkIdList) {
List<HmClerkRelationQDTO> clerkRelationQDTOS = new ArrayList<>();
private void insertHmClerkRelation(HmQrcodeQDTO hmQrcodeQDTO, String wxEnterpriseId, Long hmId, List<String> clerkIdList, Boolean addFlag) {
Date now = new Date();
for (String clerkId : clerkIdList) {
HmClerkRelationBO hmClerkRelationBO = hmClerkRelationService.queryByHmIdAndClerkId(hmId, clerkId);
if (addFlag && hmClerkRelationBO != null) {
logger.error("该导购已经在该多人活码中,clerkId:{}", clerkId);
continue;
}
StaffClerkRelationDTO clerkRelationDTO = staffClerkRelationService.getByClerkId(clerkId);
HmClerkRelationQDTO hmClerkRelationQDTO = new HmClerkRelationQDTO();
hmClerkRelationQDTO.setRelationId(UniqueIdUtils.uniqueLong());
......@@ -458,9 +474,8 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
hmClerkRelationQDTO.setUpdateTime(now);
hmClerkRelationQDTO.setOverFlag(0);
hmClerkRelationQDTO.setAddNum(0);
clerkRelationQDTOS.add(hmClerkRelationQDTO);
hmClerkRelationService.insert(hmClerkRelationQDTO);
}
hmClerkRelationService.insertBatch(clerkRelationQDTOS);
}
......@@ -474,8 +489,8 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
}
MemberTagItemDTO tagItem = this.memberTagApiService.findMemberTagItem(hmQrcodeBO.getMemberLabelId());
if (null != tagItem) {
String tagId = tagItem.getTagId() ;
MemberTagDTO tag = this.memberTagApiService.getMemberTagById(tagId) ;
String tagId = tagItem.getTagId();
MemberTagDTO tag = this.memberTagApiService.getMemberTagById(tagId);
hmQrcodeBO.setMemberLabelName(tag.getTagName() + "-" + tagItem.getTagItemName());
hmQrcodeBO.setMemberLabelStatus(tagItem.getStatus());
}
......@@ -537,9 +552,9 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
}
@Override
public ServiceResponse delByClerkId(String clerkId, String enterpriseId) {
public ServiceResponse delByClerkId(String clerkId, String enterpriseId, String wxEnterpriseId) {
// 单人活码 直接废弃,多人活码,更新
HmQrcodeBO hmQrcodeBO = hmQrcodeService.queryByClerkId(clerkId, enterpriseId);
HmQrcodeBO hmQrcodeBO = hmQrcodeService.queryByClerkId(clerkId, wxEnterpriseId);
if (hmQrcodeBO != null) {
delById(hmQrcodeBO.getHmId());
}
......@@ -553,6 +568,9 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
for (HmClerkRelationBO hmClerkRelationBO : hmClerkRelationBOS) {
Long hmId = hmClerkRelationBO.getHmId();
List<String> clerkIds = hmClerkRelationService.getClerkIdByHmId(hmId);
hmClerkRelationService.updateStatusById(0,hmClerkRelationBO.getRelationId());
clerkIds.remove(clerkId);
// 更新活码
HmQrcodeQDTO hmQrcodeQDTO = new HmQrcodeQDTO();
......@@ -647,6 +665,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
logger.info("导购无活码,无需处理:clerkId:{}", clerkId);
continue;
}
staffClerkRelationService.updateOpenConcatFlagById(0, relationDTO.getStaffClerkRelationId());
hmQrcodeService.updateStatusById(hmQrcodeBO.getHmId(), 3);
}
}
......@@ -723,7 +742,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
@Override
public Page<HmClerkRelationDTO> getHmClerkByHmId(BasePageInfo basePageInfo, Long hmId) {
Page<HmClerkRelationBO> hmClerkByHmId = hmClerkRelationService.getHmClerkByHmId(basePageInfo, hmId);
return PageUtil.changeToCurrentPage(hmClerkByHmId,HmClerkRelationDTO.class);
return PageUtil.changeToCurrentPage(hmClerkByHmId, HmClerkRelationDTO.class);
}
/**
......@@ -762,4 +781,9 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
public ServiceResponse<List<String>> listHmIdForIndex(HmQrcodeListQDTO qdto) {
return ServiceResponse.success(hmQrcodeService.listHmIdForIndex(qdto));
}
@Override
public ServiceResponse<List<String>> listHasQrcodeClerk(String enterpriseId, List<String> clerkIdList) {
return ServiceResponse.success(hmQrcodeService.listHasQrcodeClerk(enterpriseId,clerkIdList));
}
}
......@@ -182,5 +182,13 @@
where hm_id = #{hmId} and staff_id = #{staffId} and status = 1 limit 1
</select>
<update id="updateStatusById">
update tab_haoban_hm_clerk_relation
<set>
status = #{status},update_time = now()
</set>
where relation_id = #{relationId}
</update>
</mapper>
......@@ -287,7 +287,7 @@
</update>
<update id="resetAddNumAndOverFlag">
update
update tab_haoban_hm_qrcode
<set>
add_num = 0,over_flag = 0,update_time = now()
</set>
......@@ -330,6 +330,9 @@
select distinct(a.hm_id)
from tab_haoban_hm_qrcode a left join tab_haoban_hm_clerk_relation b on a.hm_id = b.hm_id and b.status = 1
where a.enterprise_id = #{enterpriseId} and a.status_flag != 0
<if test="wxEnterpriseId != null and wxEnterpriseId != ''">
and a.wx_enterprise_id = #{wxEnterpriseId}
</if>
<if test="null != hmSelect and '' != hmSelect ">
and (a.hm_code=#{hmSelect} or a.name like '%${hmSelect}%' or a.creator_name like '%${hmSelect}%' )
</if>
......@@ -371,6 +374,9 @@
from tab_haoban_hm_qrcode
where status_flag != 0
and enterprise_id = #{enterpriseId}
<if test="wxEnterpriseId != null and wxEnterpriseId != ''">
and wx_enterprise_id = #{wxEnterpriseId}
</if>
<if test="groupIds != null and groupIds.size > 0">
and hm_group_id IN
<foreach collection="groupIds" item="id" index="index" open="(" close=")" separator=",">
......@@ -391,6 +397,9 @@
from tab_haoban_hm_qrcode
where status_flag != 0
and enterprise_id = #{enterpriseId}
<if test="wxEnterpriseId != null and wxEnterpriseId != ''">
and wx_enterprise_id = #{wxEnterpriseId}
</if>
<if test="hmIds != null and hmIds.size > 0">
and hm_id in
<foreach collection="hmIds" open="(" close=")" separator="," item="hmId">
......@@ -422,7 +431,7 @@
<sql id="canAddClerkSql">
tab_haoban_staff_clerk_relation a LEFT JOIN tab_haoban_hm_qrcode b ON a.clerk_id = b.clerk_id and b.hm_type = 1 and b.status_flag in (1,3)
WHERE a.enterprise_id = #{enterpriseId} AND a.status_flag = 1 AND a.open_concat_flag = 0
WHERE a.enterprise_id = #{enterpriseId} AND a.status_flag = 1 AND a.open_concat_flag = 1
<if test="null != storeIdList">
and a.store_id in
<foreach collection="storeIdList" item="id" index="index" open="(" close=")" separator=",">
......@@ -433,5 +442,14 @@
and b.hm_id is null
</sql>
<select id="listHasQrcodeClerk" resultType="String">
select clerk_id from tab_haoban_hm_qrcode where enterprise_id=#{enterpriseId}
and clerk_id in
<foreach collection="clerkIdList" item="id" index="index" open="(" close=")" separator=",">
#{id}
</foreach>
and hm_type = 1 and status_flag in (1,3)
</select>
</mapper>
......@@ -137,6 +137,7 @@ public class HmQrcodeController {
public RestResponse<StatisticsDTO> list(@RequestBody HmQrcodeListQO hmQrcodeListQO) {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
hmQrcodeListQO.getInFields().setEnterpriseId(loginUser.getEnterpriseId());
hmQrcodeListQO.getInFields().setWxEnterpriseId(loginUser.getWxEnterpriseId());
List<String> storeList = staffApiService.getHaoBanStoreIdsRolesByClerkId(loginUser.getClerkId(), loginUser.getWxEnterpriseId());
if (CollectionUtils.isEmpty(storeList)) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_100007.getCode()), HaoBanErrCode.ERR_100007.getMsg());
......
......@@ -21,6 +21,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSON;
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.ClerkStoreListDTO;
import com.gic.clerk.api.service.ClerkService;
import com.gic.commons.util.EntityUtil;
......@@ -31,7 +32,6 @@ import com.gic.enterprise.api.service.StoreService;
import com.gic.haoban.base.api.common.pojo.dto.WebLoginDTO;
import com.gic.haoban.common.utils.AuthWebRequestUtil;
import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.api.dto.hm.HmQrcodeListDTO;
import com.gic.haoban.manage.api.dto.hm.HmQrcodeStoreDTO;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.StaffClerkRelationApiService;
......@@ -72,6 +72,7 @@ public class HmStoreController {
@ResponseBody
public RestResponse<Object> listStoreClerk(HttpServletRequest request, BasePageInfo basePageInfo) {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
String enterpriseId = loginUser.getEnterpriseId();
String wxEnterpriseId = loginUser.getWxEnterpriseId();
// 分组id
String storeGroupId = request.getParameter("storeGroupId");
......@@ -80,7 +81,7 @@ public class HmStoreController {
// 导购参数
String clerkSearchParams = request.getParameter("clerkSearchParams");
Map<String, Object> params = new HashMap<String, Object>();
params.put("enterpriseId", loginUser.getEnterpriseId());
params.put("enterpriseId", enterpriseId);
// 2线上
params.put("status", 2);
params.put("storeGroupId", storeGroupId);
......@@ -117,12 +118,12 @@ public class HmStoreController {
retPage.setTotalPage(page.getTotalPage());
List<ClerkStoreListVO> result = EntityUtil.changeEntityListByJSON(ClerkStoreListVO.class, page.getResult());
// 好办状态
this.haobanStatus(result, wxEnterpriseId);
this.haobanStatus(result, wxEnterpriseId, enterpriseId);
retPage.setResult(result);
return RestResponse.successResult(retPage);
}
private void haobanStatus(List<ClerkStoreListVO> list, String wxEnterpriseId) {
private void haobanStatus(List<ClerkStoreListVO> list, String wxEnterpriseId, String enterpriseId) {
List<String> clerkIdList = new ArrayList<>();
if (CollectionUtils.isEmpty(list)) {
return;
......@@ -156,21 +157,16 @@ public class HmStoreController {
}
}
if (CollectionUtils.isNotEmpty(statusList)) {
List<HmQrcodeListDTO> hmList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(hmList)) {
status2List.addAll(hmList.stream().filter(dto -> dto.getStatusFlag() == 3).map(dto -> dto.getClerkId())
.collect(Collectors.toList()));
status3List.addAll(hmList.stream().filter(dto -> dto.getStatusFlag() == 1).map(dto -> dto.getClerkId())
.collect(Collectors.toList()));
ServiceResponse<List<String>> hmClerkResp = this.hmQrcodeApiService.listHasQrcodeClerk(enterpriseId,
statusList);
if (CollectionUtils.isNotEmpty(hmClerkResp.getResult())) {
status3List.addAll(hmClerkResp.getResult());
}
status4List
.addAll(statusList.stream().filter(id -> (!status2List.contains(id) && !status3List.contains(id)))
.addAll(statusList.stream().filter(id -> (!status3List.contains(id)))
.collect(Collectors.toList()));
}
logger.info("导购列表={}", status2List);
logger.info("导购列表={}", status3List);
logger.info("导购列表={}", status4List);
logger.info("导购列表未开启客户联系的={} , 已有单人活码的={}, 可以创建单人活码的={}", status2List, status3List, status4List);
list.stream().forEach(item -> {
for (ClerkListVO clerk : item.getClerkList()) {
if (status2List.contains(clerk.getClerkId())) {
......@@ -201,7 +197,7 @@ public class HmStoreController {
@ResponseBody
public RestResponse<Object> listStore(HttpServletRequest request, BasePageInfo basePageInfo) {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
String wxEnterpriseId = loginUser.getWxEnterpriseId() ;
String wxEnterpriseId = loginUser.getWxEnterpriseId();
String enterpriseId = loginUser.getEnterpriseId();
String clerkId = loginUser.getClerkId();
// 如果有权限控制,进行管辖门店过0滤
......@@ -240,7 +236,7 @@ public class HmStoreController {
page.setPageSize(basePageInfo.getPageSize());
page.setCurrentPage(basePageInfo.getPageNum());
Map<String, Object> params = new HashMap<>();
params.put("searchDto", searchDTO) ;
params.put("searchDto", searchDTO);
page.setParams(params);
logger.info("查询条件={}", JSON.toJSONString(page));
Map<String, Object> result = storeService.getStoreListPage(page);
......
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