Commit 269abff9 by 墨竹

fix:员工列表超时接口优化

parent 30083c62
...@@ -100,6 +100,8 @@ public class StaffDTO implements Serializable { ...@@ -100,6 +100,8 @@ public class StaffDTO implements Serializable {
private String defaultGicEid; private String defaultGicEid;
private Integer addNum; private Integer addNum;
private Integer activeStatus; private Integer activeStatus;
private String enterpriseId;
private String storeId;
public String getDefaultGicEid() { public String getDefaultGicEid() {
return defaultGicEid; return defaultGicEid;
...@@ -382,4 +384,20 @@ public class StaffDTO implements Serializable { ...@@ -382,4 +384,20 @@ public class StaffDTO implements Serializable {
public void setActiveStatus(Integer activeStatus) { public void setActiveStatus(Integer activeStatus) {
this.activeStatus = activeStatus; this.activeStatus = activeStatus;
} }
public String getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public String getStoreId() {
return storeId;
}
public void setStoreId(String storeId) {
this.storeId = storeId;
}
} }
...@@ -279,4 +279,15 @@ public interface StaffApiService { ...@@ -279,4 +279,15 @@ public interface StaffApiService {
*/ */
boolean isManager(String clerkId); boolean isManager(String clerkId);
/**
* 绑定的员工列表
*
* @param storeIds 存储id
* @param wxEnterpriseId wx企业标识
* @return {@link List }<{@link StaffDTO }>
* @author mozhu
* @date 2022-10-21 00:25:46
*/
List<StaffDTO> listBindStoreIds(List<String> storeIds,String wxEnterpriseId);
} }
package com.gic.haoban.manage.service.dao.mapper; package com.gic.haoban.manage.service.dao.mapper;
import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.service.entity.TabHaobanStaff; import com.gic.haoban.manage.service.entity.TabHaobanStaff;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -133,4 +134,16 @@ public interface StaffMapper { ...@@ -133,4 +134,16 @@ public interface StaffMapper {
* @date 2022-07-25 16:36:07 * @date 2022-07-25 16:36:07
*/ */
int resetAddNum(); int resetAddNum();
/**
* 绑定的员工列表(暂时取100条,后续和前端一起改为分页接口)
*
* @param storeIds 存储id
* @param wxEnterpriseId wx企业标识
* @return {@link List }<{@link StaffDTO }>
* @author mozhu
* @date 2022-10-21 00:26:47
*/
List<StaffDTO> listBindStoreIds(@Param("storeIds") List<String> storeIds,
@Param("wxEnterpriseId") String wxEnterpriseId);
} }
\ No newline at end of file
...@@ -1018,4 +1018,9 @@ public class StaffApiServiceImpl implements StaffApiService { ...@@ -1018,4 +1018,9 @@ public class StaffApiServiceImpl implements StaffApiService {
} }
return false; return false;
} }
@Override
public List<StaffDTO> listBindStoreIds(List<String> storeIds, String wxEnterpriseId) {
return staffMapper.listBindStoreIds(storeIds,wxEnterpriseId);
}
} }
...@@ -28,7 +28,8 @@ ...@@ -28,7 +28,8 @@
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
staff_id, wx_user_id, phone_number, staff_name, nation_code, nick_name, sex, postion, staff_id
, wx_user_id, phone_number, staff_name, nation_code, nick_name, sex, postion,
active_flag, extend_postion, status_flag, create_time, update_time,wx_enterprise_id,head_img, active_flag, extend_postion, status_flag, create_time, update_time,wx_enterprise_id,head_img,
sort,sync_postion_flag,super_manager_flag,wx_open_user_id,wx_open_id,qr_code,add_num,active_status sort,sync_postion_flag,super_manager_flag,wx_open_user_id,wx_open_id,qr_code,add_num,active_status
</sql> </sql>
...@@ -38,7 +39,7 @@ ...@@ -38,7 +39,7 @@
from tab_haoban_staff from tab_haoban_staff
where staff_id = #{staffId,jdbcType=VARCHAR} and status_flag = 1 where staff_id = #{staffId,jdbcType=VARCHAR} and status_flag = 1
</select> </select>
<update id="delOtherStaffByWxUserId"> <update id="delOtherStaffByWxUserId">
update tab_haoban_staff update tab_haoban_staff
...@@ -282,11 +283,11 @@ ...@@ -282,11 +283,11 @@
select select
a.* a.*
<if test="departmentIds != null and departmentIds.size() > 0"> <if test="departmentIds != null and departmentIds.size() > 0">
, b.department_id departmentIds , b.department_id departmentIds
</if> </if>
from tab_haoban_staff a from tab_haoban_staff a
<if test="departmentIds != null and departmentIds.size() > 0"> <if test="departmentIds != null and departmentIds.size() > 0">
left join tab_haoban_staff_department_related b on a.staff_id = b.staff_id and b.status_flag = 1 left join tab_haoban_staff_department_related b on a.staff_id = b.staff_id and b.status_flag = 1
</if> </if>
where a.status_flag = 1 and a.wx_enterprise_id = #{wxEnterpriseId} where a.status_flag = 1 and a.wx_enterprise_id = #{wxEnterpriseId}
<if test="keyword != null and keyword != ''"> <if test="keyword != null and keyword != ''">
...@@ -314,7 +315,7 @@ ...@@ -314,7 +315,7 @@
</foreach> </foreach>
</if> </if>
<if test="departmentIds != null and departmentIds.size() > 0"> <if test="departmentIds != null and departmentIds.size() > 0">
group by a.staff_id group by a.staff_id
</if> </if>
order by a.create_time desc order by a.create_time desc
</select> </select>
...@@ -358,7 +359,7 @@ ...@@ -358,7 +359,7 @@
<foreach collection="userIds" item="id" index="index" open="(" close=")" separator=","> <foreach collection="userIds" item="id" index="index" open="(" close=")" separator=",">
#{id,jdbcType=VARCHAR} #{id,jdbcType=VARCHAR}
</foreach> </foreach>
or or
wx_open_user_id IN wx_open_user_id IN
<foreach collection="userIds" item="id" index="index" open="(" close=")" separator=","> <foreach collection="userIds" item="id" index="index" open="(" close=")" separator=",">
#{id,jdbcType=VARCHAR} #{id,jdbcType=VARCHAR}
...@@ -467,16 +468,17 @@ ...@@ -467,16 +468,17 @@
<update id="updateAddNumById" parameterType="java.lang.String"> <update id="updateAddNumById" parameterType="java.lang.String">
update tab_haoban_staff update tab_haoban_staff
set add_num = add_num +1, set add_num = add_num + 1,
update_time = now() update_time = now()
where staff_id = #{staffId} and status_flag = 1 where staff_id = #{staffId}
and status_flag = 1
</update> </update>
<update id="updateActiveStatusById" > <update id="updateActiveStatusById">
update tab_haoban_staff update tab_haoban_staff
set active_status = #{activeStatus}, set active_status = #{activeStatus},
update_time = now() update_time = now()
where staff_id = #{staffId} where staff_id = #{staffId}
</update> </update>
...@@ -489,4 +491,29 @@ ...@@ -489,4 +491,29 @@
where status_flag = 1 where status_flag = 1
</update> </update>
<select id="listBindStoreIds" resultType="com.gic.haoban.manage.api.dto.StaffDTO">
select
a.staff_id staffId,
a.phone_number phoneNumber,
a.staff_name staffName,
a.head_img headImg,
a.wx_enterprise_id wxEnterpriseId,
b.clerk_id clerkId,
b.clerk_code clerkCode,
b.enterprise_id enterpriseId,
b.store_id storeId
from tab_haoban_staff a
left join tab_haoban_staff_clerk_relation b on a.staff_id = b.staff_id
where a.wx_enterprise_id = #{wxEnterpriseId}
and a.status_flag = 1 and b.status_flag = 1
<if test="null != storeIds and storeIds.size gt 0">
and b.store_id in
<foreach collection="storeIds" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
limit 100
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -119,25 +119,19 @@ public class WxStaffController extends WebBaseController { ...@@ -119,25 +119,19 @@ public class WxStaffController extends WebBaseController {
if (storeIds.contains("-1")) { if (storeIds.contains("-1")) {
storeIds = null; storeIds = null;
} }
List<StaffClerkRelationDTO> list = staffClerkRelationApiService.listByStoreIds(storeIds); List<StaffDTO> resultlist = staffApiService.listBindStoreIds(storeIds, wxEnterpriseId);
List<String> staffIds = list.stream().map(StaffClerkRelationDTO::getStaffId).collect(Collectors.toList());
List<StaffDTO> resultlist = staffApiService.listByIds(staffIds);
Map<String, StaffDTO> map = com.gic.commons.util.CollectionUtil.toMap(resultlist, "staffId");
List<StaffVO> resultList = new ArrayList<>(); List<StaffVO> resultList = new ArrayList<>();
for (StaffClerkRelationDTO staffClerkRelationDTO : list) { for (StaffDTO staffDTO : resultlist) {
String staffId = staffClerkRelationDTO.getStaffId(); String enterpriseId = staffDTO.getEnterpriseId();
logger.info("员工id为:{}", staffId); String clerkCode = staffDTO.getClerkCode();
StaffDTO staffDTO = map.get(staffId); ClerkDTO clerk = clerkService.getClerkByClerkCode(enterpriseId, clerkCode);
if (staffDTO != null) { if (clerk != null) {
ClerkDTO clerk = clerkService.getClerkByClerkCode(staffClerkRelationDTO.getEnterpriseId(), staffClerkRelationDTO.getClerkCode()); long memberCount = distributeApiService.getClerkMemberCount(enterpriseId, clerk.getClerkId(), storeId);
if (clerk != null) { logger.info("【获取会员数】enterpriseId={},clerkId={},storeId={},memberCount={}", enterpriseId, clerk.getClerkId(), storeId, memberCount);
long memberCount = distributeApiService.getClerkMemberCount(staffClerkRelationDTO.getEnterpriseId(), clerk.getClerkId(), storeId); staffDTO.setMemberCount(Convert.toInt(memberCount, 0));
logger.info("【获取会员数】enterpriseId={},clerkId={},storeId={},memberCount={}", staffClerkRelationDTO.getEnterpriseId(), clerk.getClerkId(), storeId, memberCount); staffDTO.setClerkId(clerk.getClerkId());
staffDTO.setMemberCount(Convert.toInt(memberCount, 0)); staffDTO.setClerkCode(clerk.getClerkCode());
staffDTO.setClerkId(clerk.getClerkId()); resultList.add(EntityUtil.changeEntityNew(StaffVO.class, staffDTO));
staffDTO.setClerkCode(clerk.getClerkCode());
resultList.add(EntityUtil.changeEntityNew(StaffVO.class, staffDTO));
}
} }
} }
return resultResponse(HaoBanErrCode.ERR_1, resultList); return resultResponse(HaoBanErrCode.ERR_1, resultList);
...@@ -335,7 +329,7 @@ public class WxStaffController extends WebBaseController { ...@@ -335,7 +329,7 @@ public class WxStaffController extends WebBaseController {
return resultResponse(HaoBanErrCode.ERR_10009); return resultResponse(HaoBanErrCode.ERR_10009);
} }
String enterpriseId = store.getEnterpriseId(); String enterpriseId = store.getEnterpriseId();
boolean b = auditApiService.judgeHavePhoneNumberOrCode(enterpriseId, clerkCode, phoneNumber,wxEnterpriseId); boolean b = auditApiService.judgeHavePhoneNumberOrCode(enterpriseId, clerkCode, phoneNumber, wxEnterpriseId);
if (b) { if (b) {
//待审核中存在code或该手机号 //待审核中存在code或该手机号
return resultResponse(HaoBanErrCode.ERR_10021); return resultResponse(HaoBanErrCode.ERR_10021);
...@@ -347,7 +341,7 @@ public class WxStaffController extends WebBaseController { ...@@ -347,7 +341,7 @@ public class WxStaffController extends WebBaseController {
} }
AuditSettingDTO dto = auditSettingApiService.findSettingByWxEnterpriseId(wxEnterpriseId); AuditSettingDTO dto = auditSettingApiService.findSettingByWxEnterpriseId(wxEnterpriseId);
if (dto.getAuditFlag() == 1 && dto.getClerkChangeFlag() == 1) { if (dto.getAuditFlag() == 1 && dto.getClerkChangeFlag() == 1) {
AuditDTO auditDTO = auditApiService.findByBindRelatedIdAndAuditType(clerkCode, AuditType.CLERK_ADD.getCode(),wxEnterpriseId,enterpriseId); AuditDTO auditDTO = auditApiService.findByBindRelatedIdAndAuditType(clerkCode, AuditType.CLERK_ADD.getCode(), wxEnterpriseId, enterpriseId);
if (auditDTO != null) { if (auditDTO != null) {
logger.info("已经存在了审核记录,待审核{}", clerkCode); logger.info("已经存在了审核记录,待审核{}", clerkCode);
return resultResponse(HaoBanErrCode.ERR_10018); return resultResponse(HaoBanErrCode.ERR_10018);
...@@ -435,7 +429,7 @@ public class WxStaffController extends WebBaseController { ...@@ -435,7 +429,7 @@ public class WxStaffController extends WebBaseController {
//需要审核 //需要审核
String[] clerkIdArr = clerkIds.split(","); String[] clerkIdArr = clerkIds.split(",");
for (String clerkId : clerkIdArr) { for (String clerkId : clerkIdArr) {
AuditDTO auditDTO = auditApiService.findByBindRelatedIdAndAuditType(clerkId, AuditType.CLERK_DEL.getCode(),wxEnterpriseId,store.getEnterpriseId()); AuditDTO auditDTO = auditApiService.findByBindRelatedIdAndAuditType(clerkId, AuditType.CLERK_DEL.getCode(), wxEnterpriseId, store.getEnterpriseId());
if (auditDTO != null) { if (auditDTO != null) {
logger.info("已经存在了审核记录,待审核{}", clerkId); logger.info("已经存在了审核记录,待审核{}", clerkId);
continue; continue;
...@@ -859,7 +853,7 @@ public class WxStaffController extends WebBaseController { ...@@ -859,7 +853,7 @@ public class WxStaffController extends WebBaseController {
if (staff == null) { if (staff == null) {
return resultResponse(HaoBanErrCode.ERR_10006); return resultResponse(HaoBanErrCode.ERR_10006);
} }
AuditDTO auditDTO = auditApiService.findByBindRelatedIdAndAuditType(clerkId, AuditType.CLERK_BIND.getCode(),wxEnterpriseId,clerk.getEnterpriseId()); AuditDTO auditDTO = auditApiService.findByBindRelatedIdAndAuditType(clerkId, AuditType.CLERK_BIND.getCode(), wxEnterpriseId, clerk.getEnterpriseId());
if (auditDTO != null) { if (auditDTO != null) {
return resultResponse(HaoBanErrCode.ERR_10018); return resultResponse(HaoBanErrCode.ERR_10018);
} }
......
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