Commit 87223fcc by 墨竹

feat:1:新增活码门店接口查询;2:解绑多人活码逻辑处理

parent bd44112e
package com.gic.haoban.manage.api.dto.hm;
import java.io.Serializable;
/**
* @author mozhu
* @date 2022/7/8 15:05
*/
public class HmQrcodeStoreDTO implements Serializable {
private static final long serialVersionUID = -6704478183404897385L;
private String enterpriseId;
private Integer overFlag;
private String storeName;
private String storeId;
private String storeCode;
public String getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public Integer getOverFlag() {
return overFlag;
}
public void setOverFlag(Integer overFlag) {
this.overFlag = overFlag;
}
public String getStoreName() {
return storeName;
}
public void setStoreName(String storeName) {
this.storeName = storeName;
}
public String getStoreId() {
return storeId;
}
public void setStoreId(String storeId) {
this.storeId = storeId;
}
public String getStoreCode() {
return storeCode;
}
public void setStoreCode(String storeCode) {
this.storeCode = storeCode;
}
}
......@@ -3,9 +3,12 @@ package com.gic.haoban.manage.api.service.hm;
import com.gic.haoban.base.api.common.PageResult2;
import com.gic.haoban.manage.api.dto.hm.HmQrcodeDTO;
import com.gic.haoban.manage.api.dto.hm.HmQrcodeListDTO;
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
......@@ -108,4 +111,15 @@ public interface HmQrcodeApiService {
void checkStaffOpenContact(String param);
/**
* 活码门店ids
*
* @param enterpriseId 企业标识
* @return {@link List }<{@link HmQrcodeStoreDTO }>
* @author mozhu
* @date 2022-07-08 15:07:15
*/
List<HmQrcodeStoreDTO> getHmStoreByEnterpriseId(String enterpriseId);
}
......@@ -69,7 +69,7 @@ public interface TabHaobanHmClerkRelationMapper {
* @author mozhu
* @date 2022-07-07 13:33:22
*/
HmClerkRelationBO queryByHmIdAndClerkId(@Param("hmId") Long hmId, @Param("clerkId") String clerkId);
TabHaobanHmClerkRelation queryByHmIdAndClerkId(@Param("hmId") Long hmId, @Param("clerkId") String clerkId);
/**
* 更新 addnum
......@@ -89,5 +89,27 @@ public interface TabHaobanHmClerkRelationMapper {
* @date 2022-07-07 13:53:36
*/
void resetAddNumAndOverFlag();
/**
* 查询职员id
*
* @param clerkId 职员id
* @param enterpriseId 企业标识
* @return {@link List }<{@link TabHaobanHmClerkRelation }>
* @author mozhu
* @date 2022-07-08 14:49:18
*/
List<TabHaobanHmClerkRelation> queryByClerkId(@Param("clerkId") String clerkId,@Param("enterpriseId") String enterpriseId);
/**
* 根据导购id获取hmid
*
* @param hmId hm id
* @return {@link List }<{@link String }>
* @author mozhu
* @date 2022-07-08 14:56:59
*/
List<String> getClerkIdByHmId(@Param("hmId") Long hmId);
}
......@@ -145,5 +145,15 @@ public interface TabHaobanHmQrcodeMapper {
TabHaobanHmQrcode queryByClerkIdAndOverFlag(@Param("clerkId") String clerkId,
@Param("wxEnterpriseId") String wxEnterpriseId,
@Param("overFlag") Integer overFlag);
/**
* 活码门店ids
*
* @param enterpriseId 企业标识
* @return {@link List }<{@link TabHaobanHmQrcode }>
* @author mozhu
* @date 2022-07-08 15:10:57
*/
List<TabHaobanHmQrcode> getHmStoreByEnterpriseId(@Param("enterpriseId") String enterpriseId);
}
......@@ -89,4 +89,25 @@ public interface HmClerkRelationService {
* @date 2022-07-07 13:53:13
*/
void resetAddNumAndOverFlag();
/**
* 查询职员id
*
* @param clerkId 职员id
* @param enterpriseId 企业标识
* @return {@link List }<{@link HmClerkRelationBO }>
* @author mozhu
* @date 2022-07-08 14:48:51
*/
List<HmClerkRelationBO> queryByClerkId(String clerkId, String enterpriseId);
/**
* 获取导购id
*
* @param hmId hm id
* @return {@link List }<{@link String }>
* @author mozhu
* @date 2022-07-08 14:59:26
*/
List<String> getClerkIdByHmId(Long hmId);
}
......@@ -133,4 +133,14 @@ public interface HmQrcodeService {
* @date 2022-07-07 16:18:13
*/
int updateStatusById(Long hmId,Integer statusFlag);
/**
* 活码门店ids
*
* @param enterpriseId 企业标识
* @return {@link List }<{@link HmQrcodeBO }>
* @author mozhu
* @date 2022-07-08 15:09:50
*/
List<HmQrcodeBO> getHmStoreByEnterpriseId(String enterpriseId);
}
......@@ -56,7 +56,7 @@ public class HmClerkRelationServiceImpl implements HmClerkRelationService {
@Override
public HmClerkRelationBO queryByHmIdAndClerkId(Long hmId, String clerkId) {
return tabHaobanHmClerkRelationMapper.queryByHmIdAndClerkId(hmId,clerkId);
return EntityUtil.changeEntityByOrika(HmClerkRelationBO.class,tabHaobanHmClerkRelationMapper.queryByHmIdAndClerkId(hmId,clerkId));
}
@Override
......@@ -68,4 +68,14 @@ public class HmClerkRelationServiceImpl implements HmClerkRelationService {
public void resetAddNumAndOverFlag() {
tabHaobanHmClerkRelationMapper.resetAddNumAndOverFlag();
}
@Override
public List<HmClerkRelationBO> queryByClerkId(String clerkId, String enterpriseId) {
return EntityUtil.changeEntityListByJSON(HmClerkRelationBO.class,tabHaobanHmClerkRelationMapper.queryByClerkId(clerkId,enterpriseId));
}
@Override
public List<String> getClerkIdByHmId(Long hmId) {
return tabHaobanHmClerkRelationMapper.getClerkIdByHmId(hmId);
}
}
......@@ -99,4 +99,9 @@ public class HmQrcodeServiceImpl implements HmQrcodeService {
public int updateStatusById(Long hmId, Integer statusFlag) {
return tabHaobanHmQrcodeMapper.updateStatusById(statusFlag, hmId);
}
@Override
public List<HmQrcodeBO> getHmStoreByEnterpriseId(String enterpriseId) {
return EntityUtil.changeEntityListNew(HmQrcodeBO.class,tabHaobanHmQrcodeMapper.getHmStoreByEnterpriseId(enterpriseId));
}
}
......@@ -12,6 +12,7 @@ import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.api.dto.WxEnterpriseDTO;
import com.gic.haoban.manage.api.dto.hm.HmQrcodeDTO;
import com.gic.haoban.manage.api.dto.hm.HmQrcodeListDTO;
import com.gic.haoban.manage.api.dto.hm.HmQrcodeStoreDTO;
import com.gic.haoban.manage.api.dto.qdto.hm.HmClerkRelationQDTO;
import com.gic.haoban.manage.api.dto.qdto.hm.HmQrcodeListQDTO;
import com.gic.haoban.manage.api.dto.qdto.hm.HmQrcodeQDTO;
......@@ -26,6 +27,7 @@ import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.haoban.manage.service.service.hm.HmClerkRelationService;
import com.gic.haoban.manage.service.service.hm.HmQrcodeService;
import com.gic.haoban.manage.service.util.QwFriendLimitCountUtil;
import com.gic.redis.data.util.RedisUtil;
import com.gic.wechat.api.dto.qywx.welcome.QywxExternalcontactDTO;
import com.gic.wechat.api.dto.qywx.welcome.QywxExternalcontactResultDTO;
import com.gic.wechat.api.service.qywx.QywxUserApiService;
......@@ -40,6 +42,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
* @author mozhu
......@@ -97,7 +100,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
qywxExternalcontactDTO.setRemark(hmQrcodeQDTO.getName());
qywxExternalcontactDTO.setSkipVerify(hmQrcodeQDTO.getPassFlag() == 1);
qywxExternalcontactDTO.setState("HM" + hmId);
List<String> userIds = staffClerkRelationService.listWxUserIdByClerkIds(clerkIdList,wxEnterpriseId);
List<String> userIds = staffClerkRelationService.listWxUserIdByClerkIds(clerkIdList, wxEnterpriseId);
qywxExternalcontactDTO.setUser(userIds);
QywxExternalcontactResultDTO qywxExternalcontactResultDTO = qywxUserApiService.addContactWay(wxEnterpriseDTO.getCorpid(), config.getWxSuiteid(), qywxExternalcontactDTO);
if (qywxExternalcontactResultDTO != null) {
......@@ -129,7 +132,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
qywxExternalcontactDTO.setRemark(hmQrcodeQDTO.getName());
qywxExternalcontactDTO.setSkipVerify(hmQrcodeQDTO.getPassFlag() == 1);
qywxExternalcontactDTO.setState("HM" + hmId);
List<String> userIds = staffClerkRelationService.listWxUserIdByClerkIds(clerkIdList,wxEnterpriseId);
List<String> userIds = staffClerkRelationService.listWxUserIdByClerkIds(clerkIdList, wxEnterpriseId);
qywxExternalcontactDTO.setUser(userIds);
boolean flag = qywxUserApiService.updateContactWay(wxEnterpriseDTO.getCorpid(), config.getWxSuiteid(), qywxExternalcontactDTO);
if (!flag) {
......@@ -165,7 +168,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
String clerkId = clerkIdList.get(0);
HmQrcodeBO hmQrcodeBO = hmQrcodeService.queryByClerkId(clerkId, wxEnterpriseId);
if (hmQrcodeBO != null) {
logger.error("该导购已经生成过活码:{}",clerkId);
logger.error("该导购已经生成过活码:{}", clerkId);
return null;
}
hmQrcodeQDTO.setClerkId(clerkId);
......@@ -236,17 +239,28 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
@Override
public boolean delByClerkId(String clerkId, String enterpriseId) {
//单人活码 直接废弃,多人活码,更新
// 单人活码 直接废弃,多人活码,更新
HmQrcodeBO hmQrcodeBO = hmQrcodeService.queryByClerkId(clerkId, enterpriseId);
if (hmQrcodeBO == null) {
logger.error("无活码:clerkId:{}", clerkId);
return false;
if (hmQrcodeBO != null) {
delById(hmQrcodeBO.getHmId());
}
delById(hmQrcodeBO.getHmId());
// TODO: 2022/7/7 多人活码逻辑
// 多人活码逻辑
List<HmClerkRelationBO> hmClerkRelationBOS = hmClerkRelationService.queryByClerkId(clerkId, enterpriseId);
if (CollectionUtils.isEmpty(hmClerkRelationBOS)) {
logger.info("无多人活码");
return true;
}
for (HmClerkRelationBO hmClerkRelationBO : hmClerkRelationBOS) {
Long hmId = hmClerkRelationBO.getHmId();
List<String> clerkIds = hmClerkRelationService.getClerkIdByHmId(hmId);
clerkIds.remove(clerkId);
// 更新活码
HmQrcodeQDTO hmQrcodeQDTO = new HmQrcodeQDTO();
hmQrcodeQDTO.setHmId(hmId);
hmQrcodeQDTO.setClerkIdList(clerkIds);
update(hmQrcodeQDTO);
}
return true;
}
......@@ -300,7 +314,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
//查询出所有正常的导购
String wxEnterpriseId = tabHaobanWxEnterpris.getWxEnterpriseId();
//企微已经开启联系我
String wxUserIds = qywxUserApiService.listCorpExternalUser(tabHaobanWxEnterpris.getCorpid(), config.getWxSuiteid());
String wxUserIds = qywxUserApiService.listCorpExternalUser(tabHaobanWxEnterpris.getCorpid(), config.getWxSuiteid());
String[] split = wxUserIds.split(",");
List<String> wxUserIdsList = Arrays.asList(split);
List<StaffClerkRelationDTO> staffClerkRelationDTOS = staffClerkRelationService.listIdsByWxOpenUserIds(wxUserIdsList, wxEnterpriseId);
......@@ -310,7 +324,7 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
}
for (StaffClerkRelationDTO staffClerkRelationDTO : staffClerkRelationDTOS) {
//具有联系我功能的导购创建活码
staffClerkRelationService.updateOpenConcatFlagById(1,staffClerkRelationDTO.getStaffClerkRelationId());
staffClerkRelationService.updateOpenConcatFlagById(1, staffClerkRelationDTO.getStaffClerkRelationId());
//创建活码
HmQrcodeQDTO hmQrcodeQDTO = new HmQrcodeQDTO();
hmQrcodeQDTO.setHmType(1);
......@@ -333,13 +347,24 @@ public class HmQrcodeApiServiceImpl implements HmQrcodeApiService {
String clerkId = relationDTO.getClerkId();
HmQrcodeBO hmQrcodeBO = hmQrcodeService.queryByClerkId(clerkId, relationDTO.getWxEnterpriseId());
if (hmQrcodeBO == null) {
logger.info("导购无活码,无需处理:clerkId:{}",clerkId);
logger.info("导购无活码,无需处理:clerkId:{}", clerkId);
continue;
}
hmQrcodeService.updateStatusById(hmQrcodeBO.getHmId(),3);
hmQrcodeService.updateStatusById(hmQrcodeBO.getHmId(), 3);
}
}
logger.info("检查员工是否开启联系我,定时任务,end");
}
@Override
public List<HmQrcodeStoreDTO> getHmStoreByEnterpriseId(String enterpriseId) {
String key = "HM:STORE:" + enterpriseId;
Object cache = RedisUtil.getCache(key);
if (cache != null) {
return (List<HmQrcodeStoreDTO>) cache;
}
List<HmQrcodeStoreDTO> hmQrcodeStoreDTOS = EntityUtil.changeEntityListByOrika(HmQrcodeStoreDTO.class, hmQrcodeService.getHmStoreByEnterpriseId(enterpriseId));
RedisUtil.setCache(key, hmQrcodeStoreDTOS, 10L, TimeUnit.MINUTES);
return hmQrcodeStoreDTOS;
}
}
......@@ -21,9 +21,15 @@
<result property="addNum" column="add_num" jdbcType="INTEGER"/>
</resultMap>
<sql id="Base_Column_List">
hm_id, wx_user_id, wx_enterprise_id, enterprise_id, store_id,
store_name, store_code, clerk_id, clerk_name, clerk_code, status,
create_time, update_time, over_flag, add_num
</sql>
<!--查询单个-->
<select id="queryById" resultMap="TabHaobanHmClerkRelationMap">
select *
select <include refid="Base_Column_List"></include>
from tab_haoban_hm_clerk_relation
where relation_id = #{relationId}
</select>
......@@ -113,7 +119,7 @@
<!--查询单个-->
<select id="queryByHmIdAndClerkId" resultMap="TabHaobanHmClerkRelationMap">
select *
select <include refid="Base_Column_List"></include>
from tab_haoban_hm_clerk_relation
where clerk_id = #{clerkId}
and hm_id = #{hmId}
......@@ -138,8 +144,21 @@
<set>
add_num = 0,over_flag = 0,update_time = now()
</set>
where status != 0
where status = 1
</update>
<select id="queryByClerkId" resultMap="TabHaobanHmClerkRelationMap">
select <include refid="Base_Column_List"></include>
from tab_haoban_hm_clerk_relation
where clerk_id = #{clerkId} and enterprise_id = #{enterpriseId} and status = 1
</select>
<select id="getClerkIdByHmId" resultType="string">
select clerk_id
from tab_haoban_hm_clerk_relation
where hm_id = #{hmId}
</select>
</mapper>
......@@ -34,9 +34,18 @@
<result property="hmGroupId" column="hm_group_id" jdbcType="INTEGER"/>
</resultMap>
<sql id="Base_Column_List">
hm_id, hm_code, hm_type, wx_enterprise_id, enterprise_id, name, creator_id,
creator_name, modifier_id, modifier_name, create_time, update_time,
member_label_id, pass_flag, welcome_id, status_flag, add_num, over_flag,
wx_config_id, wx_qrcode, wx_user_id, store_id, store_name, store_code,
clerk_id, clerk_name, clerk_code, hm_user_num, hm_group_id
</sql>
<!--查询单个-->
<select id="queryById" resultMap="TabHaobanHmQrcodeMap">
select *
select
<include refid="Base_Column_List"></include>
from tab_haoban_hm_qrcode
where hm_id = #{hmId}
</select>
......@@ -44,7 +53,7 @@
<!--查询指定行数据-->
<select id="queryListByPage" resultMap="TabHaobanHmQrcodeMap">
select
*
<include refid="Base_Column_List"></include>
from tab_haoban_hm_qrcode
<where>
<if test="hmCode != null and hmCode != ''">
......@@ -238,15 +247,17 @@
</update>
<select id="listByClerkId" resultMap="TabHaobanHmQrcodeMap">
select *
select
<include refid="Base_Column_List"></include>
from tab_haoban_hm_qrcode
where enterprise_id = #{enterpriseId}
and clerk_id = #{clerkId}
and status_flag in (1, 3)
and clerk_id = #{clerkId}
and status_flag in (1, 3)
</select>
<select id="listByStoreId" resultMap="TabHaobanHmQrcodeMap">
select *
select
<include refid="Base_Column_List"></include>
from tab_haoban_hm_qrcode
where store_id = #{storeId} and status_flag in (1,3) and wx_enterprise_id = #{wxEnterpriseId}
<if test="overFlag != null">
......@@ -276,16 +287,31 @@
<select id="queryByClerkId" resultMap="TabHaobanHmQrcodeMap">
select *
select
<include refid="Base_Column_List"></include>
from tab_haoban_hm_qrcode
where clerk_id = #{clerkId} and status_flag in (1,3) and wx_enterprise_id = #{wxEnterpriseId}
</select>
<select id="queryByClerkIdAndOverFlag" resultMap="TabHaobanHmQrcodeMap">
select *
select
<include refid="Base_Column_List"></include>
from tab_haoban_hm_qrcode
where clerk_id = #{clerkId} and status_flag = 1
and wx_enterprise_id = #{wxEnterpriseId} and over_flag = #{overFlag}
and wx_enterprise_id = #{wxEnterpriseId} and over_flag = #{overFlag}
</select>
<select id="getHmStoreByEnterpriseId" resultMap="TabHaobanHmQrcodeMap">
select store_id storeId,
store_name storeName,
store_code storeCode,
enterprise_id enterpriseId,
MIN(over_flag) overFlag
from tab_haoban_hm_qrcode
where status_flag in (1, 3)
and enterprise_id = #{enterpriseId}
GROUP BY store_id
</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