Commit 3b1ab9ea by 墨竹

fix:加好友逻辑修改

parent a05e5257
......@@ -176,4 +176,16 @@ public interface HmQrcodeApiService {
*/
HmClerkRelationDTO getOneHmClerkByHmId(Long hmId);
/**
* 根据活码id和staffId随机找一个
*
* @param hmId hm id
* @param staffId 员工id
* @return {@link HmClerkRelationDTO }
* @author mozhu
* @date 2022-07-15 17:24:01
*/
HmClerkRelationDTO getOneHmClerkByHmIdAndStaffId(Long hmId,String staffId);
}
......@@ -113,7 +113,7 @@ public interface TabHaobanHmClerkRelationMapper {
/**
* 根据导购信息获取hmid
* 根据hmid 获取导购信息
*
* @param hmId hm id
* @return {@link List }<{@link TabHaobanHmClerkRelation }>
......@@ -122,5 +122,12 @@ public interface TabHaobanHmClerkRelationMapper {
*/
List<TabHaobanHmClerkRelation> getHmClerkByHmId(@Param("hmId") Long hmId);
/**
* 根据hmid 获取导购信息
* @param hmId
* @param staffId
* @return
*/
TabHaobanHmClerkRelation getHmClerkByHmIdAndStaffId(@Param("hmId") Long hmId, @Param("staffId") String staffId);
}
......@@ -121,4 +121,16 @@ public interface HmClerkRelationService {
*/
List<HmClerkRelationBO> getHmClerkByHmId(Long hmId);
/**
* 获取导购
*
* @param hmId hm id
* @param staffId 员工id
* @return {@link HmClerkRelationBO }
* @author mozhu
* @date 2022-07-15 17:26:53
*/
HmClerkRelationBO getHmClerkByHmIdAndStaffId(Long hmId,String staffId);
}
......@@ -84,4 +84,8 @@ public class HmClerkRelationServiceImpl implements HmClerkRelationService {
return EntityUtil.changeEntityListByJSON(HmClerkRelationBO.class,tabHaobanHmClerkRelationMapper.getHmClerkByHmId(hmId));
}
@Override
public HmClerkRelationBO getHmClerkByHmIdAndStaffId(Long hmId, String staffId) {
return EntityUtil.changeEntityByOrika(HmClerkRelationBO.class,tabHaobanHmClerkRelationMapper.getHmClerkByHmIdAndStaffId(hmId,staffId));
}
}
......@@ -351,13 +351,17 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
staffClerkRelationDTO = staffClerkRelationService.getBindByClerkId(hmQrcodeDTO.getClerkId(), wxEnterpriseId);
} else if (hmQrcodeDTO.getHmType() == 2) {
HmClerkRelationDTO hmClerkRelationDTO = null;
//有主门店导购绑定主导购,没有主门店导购绑定第一个导购,其余随机
TabHaobanClerkMainStoreRelated mainStoreRelated = clerkMainStoreRelatedService.getMainStoreByStaffId(staffId, wxEnterpriseId);
if (mainStoreRelated != null) {
StaffClerkRelationDTO relationDTO = staffClerkRelationService.getOneBindByStoreId(staffId, mainStoreRelated.getStoreId());
hmClerkRelationDTO = hmQrcodeApiService.getHmClerkByHmIdAndClerkId(refId, relationDTO.getClerkId());
if (hmClerkRelationDTO == null) {
hmClerkRelationDTO = hmQrcodeApiService.getOneHmClerkByHmIdAndStaffId(refId, staffId);
if (hmClerkRelationDTO == null) {
hmClerkRelationDTO = hmQrcodeApiService.getOneHmClerkByHmId(refId);
}
}
} else {
hmClerkRelationDTO = hmQrcodeApiService.getOneHmClerkByHmId(refId);
}
......
......@@ -119,7 +119,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId);
if (wxEnterpriseDTO == null) {
logger.error("未查询到微信企业");
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()),"微信企业不存在");
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()), "微信企业不存在");
}
hmQrcodeQDTO.setHmId(UniqueIdUtils.uniqueLong());
......@@ -136,7 +136,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
}
List<String> clerkIdList = setStoreClerk(hmQrcodeQDTO, wxEnterpriseId, hmId, hmType);
if (CollectionUtils.isEmpty(clerkIdList)) {
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()),"该导购已经生成过活码或未关联过好办");
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()), "该导购已经生成过活码或未关联过好办");
}
//生成活码
QywxExternalcontactDTO qywxExternalcontactDTO = new QywxExternalcontactDTO();
......@@ -147,13 +147,13 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
qywxExternalcontactDTO.setState("HM" + hmId);
List<String> userIds = staffClerkRelationService.listWxUserIdByClerkIds(clerkIdList, wxEnterpriseId);
if (CollectionUtils.isEmpty(userIds)) {
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()),"导购未关联好办");
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()), "导购未关联好办");
}
qywxExternalcontactDTO.setUser(userIds);
logger.info("新增活码参数:{}", JSON.toJSONString(qywxExternalcontactDTO));
QywxExternalcontactResultDTO qywxExternalcontactResultDTO = qywxUserApiService.addContactWay(wxEnterpriseDTO.getCorpid(), config.getWxSuiteid(), qywxExternalcontactDTO);
if (qywxExternalcontactResultDTO.getErrcode() != 0) {
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_0.getCode()),"创建活码失败:"+qywxExternalcontactResultDTO.getErrmsg());
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_0.getCode()), "创建活码失败:" + qywxExternalcontactResultDTO.getErrmsg());
}
hmQrcodeQDTO.setWxQrcode(qywxExternalcontactResultDTO.getQr_code());
hmQrcodeQDTO.setWxConfigId(qywxExternalcontactResultDTO.getConfig_id());
......@@ -173,11 +173,11 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId);
if (wxEnterpriseDTO == null) {
logger.error("未查询到微信企业");
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()),"微信企业不存在");
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()), "微信企业不存在");
}
List<String> clerkIdList = hmQrcodeQDTO.getClerkIdList();
if (CollectionUtils.isEmpty(clerkIdList)) {
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_5.getCode()),"导购不允许为空");
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_5.getCode()), "导购不允许为空");
}
if (clerkIdList.contains("-1")) {
List<TabHaobanStaffClerkRelation> tabHaobanStaffClerkRelations = staffClerkRelationService.listByWxEnterpriseId(wxEnterpriseId);
......@@ -221,14 +221,14 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(wxEnterpriseId);
if (wxEnterpriseDTO == null) {
logger.error("未查询到微信企业");
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()),"微信企业不存在");
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()), "微信企业不存在");
}
Long hmId = hmQrcodeQDTO.getHmId();
Integer hmType = hmQrcodeQDTO.getHmType();
List<String> clerkIdList = setStoreClerk(hmQrcodeQDTO, wxEnterpriseId, hmId, hmType);
if (CollectionUtils.isEmpty(clerkIdList)) {
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()),"该导购已经生成过活码或未关联过好办");
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()), "该导购已经生成过活码或未关联过好办");
}
//更新活码
QywxExternalcontactDTO qywxExternalcontactDTO = new QywxExternalcontactDTO();
......@@ -239,13 +239,13 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
qywxExternalcontactDTO.setState("HM" + hmId);
List<String> userIds = staffClerkRelationService.listWxUserIdByClerkIds(clerkIdList, wxEnterpriseId);
if (CollectionUtils.isEmpty(userIds)) {
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()),"导购未关联好办");
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()), "导购未关联好办");
}
qywxExternalcontactDTO.setUser(userIds);
QywxResponseDTO qywxResponseDTO = qywxUserApiService.updateContactWay(wxEnterpriseDTO.getCorpid(), config.getWxSuiteid(), qywxExternalcontactDTO);
if (qywxResponseDTO.getErrcode() != 0) {
logger.error("更新企微活码失败");
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_0.getCode()),qywxResponseDTO.getErrmsg());
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_0.getCode()), qywxResponseDTO.getErrmsg());
}
int updateResult = hmQrcodeService.update(hmQrcodeQDTO);
......@@ -262,6 +262,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
/**
* 修改活码操作日志
*
* @param hmQrcodeQDTO
* @param hmId
*/
......@@ -448,7 +449,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
if (hmGroupSettingBO != null) {
hmQrcodeBO.setHmGroupName(hmGroupSettingBO.getGroupName());
}
MemberTagDTO memberTagDTO = memberTagApiService.getMemberTagById( hmQrcodeBO.getMemberLabelId());
MemberTagDTO memberTagDTO = memberTagApiService.getMemberTagById(hmQrcodeBO.getMemberLabelId());
if (memberTagDTO != null) {
hmQrcodeBO.setMemberLabelName(memberTagDTO.getTagName());
}
......@@ -492,17 +493,17 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
public ServiceResponse delById(Long hmId) {
HmQrcodeBO hmQrcodeBO = hmQrcodeService.queryById(hmId);
if (hmQrcodeBO == null) {
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()),"活码不存在");
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()), "活码不存在");
}
String wxConfigId = hmQrcodeBO.getWxConfigId();
if (StringUtils.isBlank(wxConfigId)) {
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()),"活码未生成");
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()), "活码未生成");
}
WxEnterpriseDTO wxEnterpriseDTO = wxEnterpriseService.selectById(hmQrcodeBO.getWxEnterpriseId());
QywxResponseDTO qywxResponseDTO = qywxUserApiService.delContactWay(wxEnterpriseDTO.getCorpid(), config.getWxSuiteid(), wxConfigId);
int errcode = qywxResponseDTO.getErrcode();
if (errcode != 0) {
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()),qywxResponseDTO.getErrmsg());
return ServiceResponse.failure(Convert.toStr(HaoBanErrCodeCommon.ERR_8.getCode()), qywxResponseDTO.getErrmsg());
}
hmQrcodeService.deleteById(hmId);
setLoggerContext(hmQrcodeBO.getEnterpriseId(), hmQrcodeBO.getWxEnterpriseId(), hmQrcodeBO.getModifierId(), hmQrcodeBO.getModifierName());
......@@ -645,7 +646,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
public Page<HmClerkRelationDTO> getHmClerkByHmId(BasePageInfo basePageInfo, Long hmId) {
PageHelper.startPage(basePageInfo);
List<HmClerkRelationBO> hmClerkByHmId = hmClerkRelationService.getHmClerkByHmId(hmId);
return PageUtil.changePageHelperToCurrentPage(new PageInfo<>(hmClerkByHmId),HmClerkRelationDTO.class);
return PageUtil.changePageHelperToCurrentPage(new PageInfo<>(hmClerkByHmId), HmClerkRelationDTO.class);
}
/**
......@@ -657,8 +658,8 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
*/
@Override
public ServiceResponse<Boolean> batchUpdateHmQrcodeGroup(List<Long> hmIds, Long groupId) {
if (CollectionUtils.isEmpty(hmIds) || groupId == null){
return ServiceResponse.failure(HaoBanErrCodeCommon.ERR_2.getCode()+"", HaoBanErrCodeCommon.ERR_2.getMsg());
if (CollectionUtils.isEmpty(hmIds) || groupId == null) {
return ServiceResponse.failure(HaoBanErrCodeCommon.ERR_2.getCode() + "", HaoBanErrCodeCommon.ERR_2.getMsg());
}
int updateCount = hmQrcodeService.batchUpdateQrcodeGroup(hmIds, groupId);
return ServiceResponse.success(updateCount > 0);
......@@ -666,12 +667,17 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
@Override
public HmClerkRelationDTO getHmClerkByHmIdAndClerkId(Long hmId, String clerkId) {
return EntityUtil.changeEntityNew(HmClerkRelationDTO.class,hmClerkRelationService.queryByHmIdAndClerkId(hmId, clerkId));
return EntityUtil.changeEntityNew(HmClerkRelationDTO.class, hmClerkRelationService.queryByHmIdAndClerkId(hmId, clerkId));
}
@Override
public HmClerkRelationDTO getOneHmClerkByHmId(Long hmId) {
HmClerkRelationBO hmClerkRelationBO = hmClerkRelationService.getHmClerkByHmId(hmId).get(0);
return EntityUtil.changeEntityNew(HmClerkRelationDTO.class,hmClerkRelationBO);
return EntityUtil.changeEntityNew(HmClerkRelationDTO.class, hmClerkRelationBO);
}
@Override
public HmClerkRelationDTO getOneHmClerkByHmIdAndStaffId(Long hmId, String staffId) {
return EntityUtil.changeEntityNew(HmClerkRelationDTO.class, hmClerkRelationService.getHmClerkByHmIdAndStaffId(hmId, staffId));
}
}
......@@ -176,5 +176,11 @@
where hm_id = #{hmId} and status = 1
</select>
<select id="getHmClerkByHmIdAndStaffId" resultMap="TabHaobanHmClerkRelationMap">
select <include refid="Base_Column_List"></include>
from tab_haoban_hm_clerk_relation
where hm_id = #{hmId} and staff_id = #{staffId} and status = 1 limit 1
</select>
</mapper>
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