Commit 9da8cd9d by fudahua

Merge remote-tracking branch 'origin/master'

parents c73a354d 6e0afeae
......@@ -6,6 +6,7 @@
<groupId>com.gic</groupId>
<artifactId>gic-pom-base</artifactId>
<version>3.0-SNAPSHOT</version>
<relativePath/>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -6,7 +6,8 @@ package com.gic.haoban.manage.api.enums;
public enum AlertTypeEnum {
QYWX_TAG_SYNC(1, "企微标签同步", null),
QUNFA_MESSAGE(2, "企微群发", null),
FRIEND_ADD(3, "企微好友添加", null),;
FRIEND_ADD(3, "企微好友添加", null),
CLOUD_STORE_CHANGE(4, "观云台门店进回收站", null),;
private Integer type;
private String name;
private String dingUrl;
......
......@@ -11,19 +11,19 @@ public enum AppPageType {
//任务详情(会话、话务、不良评价)
TASK_DETAIL(3, "hbapp_task_detail"),
//日报详情
DAILY_DETAIL(4, "hbapp_task_daily_report_detail"),
DAILY_DETAIL(4, "hbapp_task_daily_report_detail"),
//指标管理详情
PERFORMANCE_DETAIL(5, "hbapp_task_kpi_detail"),
PERFORMANCE_DETAIL(5, "hbapp_task_kpi_detail"),
//顾客详情
CUSTOMER_DETAIL(6, "hbapp_customer_detail"),
CUSTOMER_DETAIL(6, "hbapp_customer_detail"),
//会员列表
MEMBER_LIST(7, "hbapp_customer_list"),
MEMBER_LIST(7, "hbapp_customer_list"),
//分配会员
DISTRIBUTE_MEMBER(8, "hbapp_customer_distribute"),
DISTRIBUTE_MEMBER(8, "hbapp_customer_distribute"),
//任务列表
TASK_LIST(9, "hbapp_task_list"),
TASK_LIST(9, "hbapp_task_list_new"),
//商品详情
GOOD_DETAIL(10, "hbapp_commodity_detail"),
GOOD_DETAIL(10, "hbapp_commodity_detail"),
//我的关联记录
MY_RELATED_RECORD(11, "store_relate_my_record_list"),
//门店关联记录
......@@ -34,9 +34,9 @@ public enum AppPageType {
FACE_ARRIVAL(14, "hbapp_customer_bind_faceId"),
//完善标签
PERFECT_TAG(15, "hbapp_customer_edit_tag"),
//销售线索任务列表
MARKET_CLUE_TASK(16, "hbapp_sales_lead_main"),
//话务任务逾期提醒
//销售线索任务列表(hbapp_sales_lead_main废弃,改为新的hbapp_marketing_task_list)
MARKET_CLUE_TASK(16, "hbapp_marketing_task_list"),
//话务任务
TEL_WITHIN_TIME_LIMIT(17, "hbapp_marketing_task_list"),
;
......
package com.gic.haoban.manage.api.service;
import com.gic.haoban.manage.api.dto.StaffDepartmentRelatedDTO;
import java.util.List;
import java.util.Map;
import com.gic.haoban.manage.api.dto.StaffDepartmentRelatedDTO;
public interface StaffDepartmentRelatedApiService {
......@@ -25,41 +25,49 @@ public interface StaffDepartmentRelatedApiService {
*/
StaffDepartmentRelatedDTO getByStaffDepartmentRelatedId(String staffDepartmentRelatedId);
void deleteCode(StaffDepartmentRelatedDTO dto);
void deleteCode(StaffDepartmentRelatedDTO dto);
StaffDepartmentRelatedDTO getOneByClerkCodeAndDepartmentId(String clerkCode, String departmentId);
StaffDepartmentRelatedDTO getOneByStaffIdAndDepartmentId(String staffId, String departmentId);
Map<String,String> getWxUserIdByClerkId(String clerkId);
String getPageUrl(int type,String data);
//发送消息,单人发送
boolean sendSingleMessage(String clerkId,String title,String content,String pageUrl);
Map<String, String> getWxUserIdByClerkId(String clerkId);
String getPageUrl(int type, String data);
/**
* 发送消息,单人发送
*
* @param clerkId
* @param title
* @param content
* @param pageUrl
* @return
*/
boolean sendSingleMessage(String clerkId, String title, String content, String pageUrl);
/**
* 单人消息发送通用方法
*
* @param clerkId : 接收人id
* @param title : 通知标题
* @param clerkId : 接收人id
* @param title : 通知标题
* @param contentMap : 时间集合, key 为类型, value : 内容(例如 接收事件 : 事件内容)
* @param pageUrl : 跳转地址
* @param pageUrl : 跳转地址
* @return : 返回是否发送成功
*/
Boolean sendSingleMessage(String clerkId, String title, Map<String, String> contentMap, String pageUrl);
//发送消息,带审核理由
public boolean sendAuditMessage(String clerkId, String title,String content, String pageUrl,int auditStatus, String auditReason);
boolean sendAuditMessage(String clerkId, String title, String content, String pageUrl, int auditStatus, String auditReason);
List<StaffDepartmentRelatedDTO> listByStaffIds(List<String> staffIds);
public void sendClerkBind(String staffId,String clerkCode,String storeId,int auditStatus,String auditReason);
public void sendStaffBind(String staffId,String clerkCode,String storeId,int auditStatus,String auditReason);
public void sendClerkAdd (String clerkName,String clerkCode,String storeId,int auditStatus,String auditReason);
void sendClerkBind(String staffId, String clerkCode, String storeId, int auditStatus, String auditReason);
void sendStaffBind(String staffId, String clerkCode, String storeId, int auditStatus, String auditReason);
void sendClerkAdd(String clerkName, String clerkCode, String storeId, int auditStatus, String auditReason);
public void sendClerkDel (String clerkName,String clerkCode,String storeId,int auditStatus,String auditReason);
void sendClerkDel(String clerkName, String clerkCode, String storeId, int auditStatus, String auditReason);
}
......@@ -6,6 +6,7 @@
<groupId>com.gic</groupId>
<artifactId>gic-pom-base</artifactId>
<version>3.0-SNAPSHOT</version>
<relativePath/>
</parent>
<modelVersion>4.0.0</modelVersion>
......@@ -14,8 +15,6 @@
<packaging>war</packaging>
<name>haoban-manage3-operation-web Maven Webapp</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
......
......@@ -2,30 +2,28 @@ package com.gic.haoban.manage.web.controller.test;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.Page;
import com.gic.commons.util.EntityUtil;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.common.utils.CheckContainUtil;
import com.gic.commons.util.GICMQClientUtil;
import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.manage.api.dto.TestDTO;
import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.api.enums.QuartzEnum;
import com.gic.haoban.manage.api.enums.SyncTaskTypeEnum;
import com.gic.haoban.manage.api.service.DealSyncOperationApiService;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.TestApiService;
import com.gic.haoban.manage.api.service.TestService;
import com.gic.haoban.manage.web.controller.WebBaseController;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.qo.TestQo;
import com.gic.haoban.manage.web.vo.TestVo;
import com.gic.haoban.manage.web.qo.QywxTagSyncInfoQo;
import com.gic.mq.sdk.GicMQClient;
import com.gic.sharing.core.service.api.service.MqApiService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static org.slf4j.LoggerFactory.getLogger;
......@@ -44,6 +42,12 @@ public class TestController extends WebBaseController {
@Autowired
private MqApiService mqApiService;
@Autowired
private StaffApiService staffApiService;
@Autowired
private DealSyncOperationApiService dealSyncOperationApiService;
//
// @RequestMapping("/testList")
// @ResponseBody
......@@ -135,4 +139,56 @@ public class TestController extends WebBaseController {
}
return resultResponse(HaoBanErrCode.ERR_1);
}
/**
* 刷新好友
*
* @return
*/
@RequestMapping("/flush-friend-batch")
@ResponseBody
public HaobanResponse flushFriend(String key) {
if (StringUtils.isBlank(key)) {
return resultResponse(HaoBanErrCode.ERR_0);
}
String[] split = key.split(",");
for (String staffId : split) {
StaffDTO staff = staffApiService.selectById(staffId);
if (null == staff) {
continue;
}
String wxEnterpriseId = staff.getWxEnterpriseId();
String wxUserId = staff.getWxUserId();
String taskName = "刷新企业微信好友(" + staff.getStaffName() + ")";
String taskId = dealSyncOperationApiService.createWxFriendTaskSingle(staff.getWxEnterpriseId(), taskName, staffId, staff.getStaffName(), SyncTaskTypeEnum.FRIEND_SINGLE.getType());
if (StringUtils.isNotBlank(taskId)) {
dealSyncOperationApiService.dealWxFriendClerkSingle(taskId, wxUserId, staffId, wxEnterpriseId);
}
}
return resultResponse(HaoBanErrCode.ERR_1);
}
/**
* 刷新单个标签同步到队列
*
* @return
*/
@RequestMapping("/qywx-tag-mq")
@ResponseBody
public HaobanResponse qywxTagMq(String key) {
if (StringUtils.isBlank(key)) {
return resultResponse(HaoBanErrCode.ERR_0);
}
JSONArray jsonArray = JSONArray.parseArray(key);
List<String> mqList = jsonArray.stream().map(qo -> JSONObject.toJSONString(qo)).collect(Collectors.toList());
GicMQClient clientInstance = GICMQClientUtil.getClientInstance();
try {
clientInstance.sendBatchMessages("qywxTagSyncDeal", mqList);
} catch (Exception e) {
e.printStackTrace();
logger.info("批量异常:{}", e);
}
return resultResponse(HaoBanErrCode.ERR_1);
}
}
package com.gic.haoban.manage.web.qo;
import java.io.Serializable;
import java.util.List;
/**
* Created 2021/7/19.
*
* @author hua
*/
public class QywxTagSyncInfoQo implements Serializable {
/**
* 任务id
*/
private String taskId;
/**
* 任务类型 0标签同步 1会员标签同步
* #taskTypeEnum
*/
private int taskType;
/**
* 数据id 对应memberId
*/
private String dataId;
/**
* 同步类型
*/
private int syncType;
private Integer times = 0;
/**
* 批量导入时
*/
private List<String> memberIds;
/**
* 非必传
*/
private String wxEnterpriseId;
/**
* 非必传
*/
private String enterpriseId;
public String getWxEnterpriseId() {
return wxEnterpriseId;
}
public void setWxEnterpriseId(String wxEnterpriseId) {
this.wxEnterpriseId = wxEnterpriseId;
}
public String getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public List<String> getMemberIds() {
return memberIds;
}
public void setMemberIds(List<String> memberIds) {
this.memberIds = memberIds;
}
public int getSyncType() {
return syncType;
}
public void setSyncType(int syncType) {
this.syncType = syncType;
}
/**
* 同步的id
*/
private Integer syncLogId;
public Integer getTimes() {
return times;
}
public void setTimes(Integer times) {
this.times = times;
}
public Integer getSyncLogId() {
return syncLogId;
}
public void setSyncLogId(Integer syncLogId) {
this.syncLogId = syncLogId;
}
public String getTaskId() {
return taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
public int getTaskType() {
return taskType;
}
public void setTaskType(int taskType) {
this.taskType = taskType;
}
public String getDataId() {
return dataId;
}
public void setDataId(String dataId) {
this.dataId = dataId;
}
}
......@@ -51,6 +51,9 @@
<dubbo:reference interface="com.gic.haoban.manage.api.service.HandoverOperationApiService"
id="handoverOperationApiService"/>
<dubbo:reference interface="com.gic.haoban.manage.api.service.DealSyncOperationApiService"
id="dealSyncOperationApiService"/>
<dubbo:reference interface="com.gic.sharing.core.service.api.service.MqApiService"
id="mqApiService"/>
......
......@@ -6,6 +6,7 @@
<groupId>com.gic</groupId>
<artifactId>gic-pom-base</artifactId>
<version>3.0-SNAPSHOT</version>
<relativePath/>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -51,6 +51,6 @@ public interface StaffClerkBindLogMapper {
public List<TabHaobanStaffClerkBindLog> listStaffClerkBindLog(@Param("wxEnterpriseId") String wxEnterpriseId, @Param("clerkIds") List<String> clerkIds
, @Param("staffIds") List<String> staffIds, @Param("enterpriseIds") List<String> enterpriseIds, @Param("optType") int optType, @Param("search") String search);
public List<TabHaobanStaffClerkBindLog> StaffClerkUnBindLog(@Param("wxEnterpriseId") String wxEnterpriseId, @Param("clerkId") String clerkIds
public List<TabHaobanStaffClerkBindLog> staffClerkUnBindLog(@Param("wxEnterpriseId") String wxEnterpriseId, @Param("clerkId") String clerkIds
, @Param("enterpriseId") String enterpriseIds, @Param("optType") int optType);
}
\ No newline at end of file
......@@ -193,4 +193,12 @@ public interface TabHaobanExternalClerkRelatedMapper {
* @return
*/
List<TabHaobanExternalClerkRelated> listByExternalUserId(@Param("wxEnterpriseId") String wxEnterpriseId, @Param("externalUserId") String externalUserId);
/**
* 根据会员id更新新老会员id
*
* @param memberId
* @return
*/
int updateMemberIdByMemberId(@Param("memberId") String memberId, @Param("oldMemberId") String oldMemberId);
}
\ No newline at end of file
......@@ -58,4 +58,13 @@ public interface ExternalClerkRelatedService {
*/
List<TabHaobanExternalClerkRelated> listExternalByExternalUserid(String wxEnterpriseId, String externalUserid);
/**
* 校验会员id与unionid的对应 主要修复会员合并是没有更新会老的情况
*
* @param memberId
* @param unionId
* @return
*/
String checkAndUpdateMemberByUnonId(String enterpriseId, String memberId, String unionId);
}
......@@ -5,6 +5,14 @@ import java.util.Date;
import java.util.List;
import java.util.Set;
import com.alibaba.fastjson.JSONObject;
import com.gic.member.api.dto.MemberDTO;
import com.gic.member.api.service.MemberService;
import com.gic.search.engine.api.dto.ESResponseQuerySingle;
import com.gic.search.engine.api.dto.dynamic.DynamicSearchDTO;
import com.gic.search.engine.api.service.dynamic.ESDataDynamicOperationApiService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import com.alibaba.dubbo.config.annotation.Service;
......@@ -16,12 +24,22 @@ import com.gic.haoban.manage.service.dao.mapper.TabHaobanExternalClerkRelatedMap
import com.gic.haoban.manage.service.entity.TabHaobanExternalClerkRelated;
import com.gic.haoban.manage.service.service.ExternalClerkRelatedService;
import static org.slf4j.LoggerFactory.getLogger;
@Service
public class ExternalClerkRelatedServiceImpl implements ExternalClerkRelatedService {
private static final Logger logger = getLogger(ExternalClerkRelatedServiceImpl.class);
@Autowired
private TabHaobanExternalClerkRelatedMapper mapper;
@Autowired
private ESDataDynamicOperationApiService esDataDynamicOperationApiService;
@Autowired
private MemberService memberService;
@Override
public void insert(TabHaobanExternalClerkRelated related) {
String clerkId = related.getClerkId();
......@@ -110,4 +128,38 @@ public class ExternalClerkRelatedServiceImpl implements ExternalClerkRelatedServ
public List<TabHaobanExternalClerkRelated> listExternalByExternalUserid(String wxEnterpriseId, String externalUserid) {
return mapper.listByExternalUserId(wxEnterpriseId, externalUserid);
}
@Override
public String checkAndUpdateMemberByUnonId(String enterpriseId, String memberId, String unionId) {
String returnFields = "id";
try {
JSONObject searchJson = new JSONObject();
searchJson.put("id", memberId);
DynamicSearchDTO search = new DynamicSearchDTO();
search.setSearchJson(searchJson);
search.setEnterpriseId(enterpriseId);
search.setColumnCategoryCode("member");
if (StringUtils.isNotBlank(returnFields)) {
search.setReturnFileds(returnFields);
}
ESResponseQuerySingle single = esDataDynamicOperationApiService.queryDataSingle(search);
JSONObject res = single.getRes();
logger.info("返回数据:{}", JSONObject.toJSONString(res));
if (res != null && res.size() > 0) {
return memberId;
}
MemberDTO memberDTO = memberService.getMemberByUnionid(unionId, enterpriseId);
if (null == memberDTO || memberDTO.getMemberId() == null) {
logger.info("会员不存在:{}", unionId);
return null;
}
//更新会员id
mapper.updateMemberIdByMemberId(memberDTO.getMemberId(), memberId);
return memberDTO.getMemberId();
} catch (Exception e) {
logger.info("异常:{}", e);
logger.info("从搜索引擎中搜索会员数据异常, memberId : {}", memberId);
}
return null;
}
}
......@@ -95,7 +95,7 @@ public class StaffClerkBindLogServiceImpl implements StaffClerkBindLogService {
@Override
public Page<StaffClerkBindLogDetailDTO> pageUnBindLog(String wxEnterpriseId, String clerkId, String enterpriseId, int optType, BasePageInfo pageInfo) {
PageHelper.startPage(pageInfo);
List<TabHaobanStaffClerkBindLog> clerkBindLogList = staffClerkBindLogMapper.StaffClerkUnBindLog(wxEnterpriseId, clerkId, enterpriseId, optType);
List<TabHaobanStaffClerkBindLog> clerkBindLogList = staffClerkBindLogMapper.staffClerkUnBindLog(wxEnterpriseId, clerkId, enterpriseId, optType);
Page<StaffClerkBindLogDetailDTO> retPage = PageUtil.changePageHelperToCurrentPage(new PageInfo<>(clerkBindLogList), StaffClerkBindLogDetailDTO.class);
return retPage;
}
......
......@@ -136,7 +136,8 @@ public class CheckQywxSettingApiServiceImpl implements CheckQywxSettingApiServic
}
//告警是否拦截重复告警 防止批量触发
if (StringUtils.isNotBlank(messageDTO.getKey())) {
RBucket<Object> bucket = RedisUtil.getRedisClient().getBucket(messageDTO.getKey());
String key = messageDTO.getKey() + messageDTO.getAlertType();
RBucket<Object> bucket = RedisUtil.getRedisClient().getBucket(key);
boolean b = bucket.trySet(1, 60L, TimeUnit.SECONDS);
if (!b) {
return;
......
......@@ -5,6 +5,8 @@ import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.Page;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.GICMQClientUtil;
import com.gic.haoban.app.customer.dto.SearchComputeDTO;
import com.gic.haoban.app.customer.dto.SearchDataDTO;
import com.gic.haoban.app.customer.enums.GicQywxSyncTypeEnum;
import com.gic.haoban.app.customer.enums.QywxSyncTaskTypeEnum;
import com.gic.haoban.base.api.common.BasePageInfo;
......@@ -18,14 +20,26 @@ import com.gic.haoban.manage.service.dao.mapper.TabHaobanExternalClerkRelatedMap
import com.gic.haoban.manage.service.entity.MemberUnionidRelated;
import com.gic.haoban.manage.service.entity.TabHaobanExternalClerkRelated;
import com.gic.haoban.manage.service.pojo.QywxTagSyncInfoPojo;
import com.gic.member.api.dto.MemberDTO;
import com.gic.member.api.service.MemberApiService;
import com.gic.member.api.service.MemberService;
import com.gic.mq.sdk.GicMQClient;
import com.gic.search.engine.api.constant.MemberDataEnum;
import com.gic.search.engine.api.constant.OperateEnum;
import com.gic.search.engine.api.dto.ESResponseQueryBatch;
import com.gic.search.engine.api.dto.ESResponseQuerySingle;
import com.gic.search.engine.api.dto.dynamic.DynamicSearchDTO;
import com.gic.search.engine.api.service.dynamic.ESDataDynamicOperationApiService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
......@@ -217,4 +231,5 @@ public class ExternalClerkRelatedApiServiceImpl implements ExternalClerkRelatedA
List<TabHaobanExternalClerkRelated> list = tabHaobanExternalClerkRelatedMapper.listByMemberId(memberId);
return EntityUtil.changeEntityListNew(ExternalClerkRelatedShortInfoDTO.class, list);
}
}
......@@ -677,9 +677,13 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
logger.info("该企业下没有配置需要同步的:{},{}", externalUserId, clerkRelated.getEnterpriseId());
continue;
}
String memberId = externalClerkRelatedService.checkAndUpdateMemberByUnonId(clerkRelated.getEnterpriseId(), clerkRelated.getMemberId(), clerkRelated.getUnionid());
if (null == memberId) {
logger.info("会员不存在:{}", externalUserId);
continue;
}
//该会员打的标签
List<MemberTagDTO> gicItems = memberTagService.listMemberTag(clerkRelated.getEnterpriseId(), clerkRelated.getMemberId());
List<MemberTagDTO> gicItems = memberTagService.listMemberTag(clerkRelated.getEnterpriseId(), memberId);
Set<String> noSyncTagItemIds = new HashSet<>();
if (!CollectionUtils.isEmpty(gicItems)) {
noSyncTagItemIds = gicItems.stream().filter(item -> !entQywxSyncTagItemIds.contains(item.getTagsId())).map(dto -> dto.getTagsId()).collect(Collectors.toSet());
......@@ -692,9 +696,9 @@ public class QywxTagApiServiceImpl implements QywxTagApiService {
logger.info("该企业会员需要打的标签:{}", JSONObject.toJSONString(entMemberNeedSetQywxKeys));
//更新标签 会自动同步
if (CollectionUtils.isEmpty(saveTagIds)) {
saveMemberTags(new HashSet<>(), clerkRelated.getEnterpriseId(), clerkRelated.getMemberId(), clerkRelated.getClerkId());
saveMemberTags(new HashSet<>(), clerkRelated.getEnterpriseId(), memberId, clerkRelated.getClerkId());
} else {
saveMemberTags(saveTagIds, clerkRelated.getEnterpriseId(), clerkRelated.getMemberId(), clerkRelated.getClerkId());
saveMemberTags(saveTagIds, clerkRelated.getEnterpriseId(), memberId, clerkRelated.getClerkId());
}
// hasSaveMemberId.add(clerkRelated.getMemberId());
// //同步企业的标签到企业微信
......
......@@ -14,11 +14,9 @@ import com.gic.haoban.manage.service.config.Config;
import com.gic.haoban.manage.service.dao.mapper.StaffDepartmentRelatedMapper;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanStaffClerkRelationMapper;
import com.gic.haoban.manage.service.dao.mapper.WxEnterpriseMapper;
import com.gic.haoban.manage.service.dao.mapper.WxEnterpriseRelatedMapper;
import com.gic.haoban.manage.service.entity.TabHaobanStaffClerkRelation;
import com.gic.haoban.manage.service.entity.TabHaobanStaffDepartmentRelated;
import com.gic.haoban.manage.service.entity.TabHaobanWxEnterprise;
import com.gic.haoban.manage.service.service.DepartmentService;
import com.gic.haoban.manage.service.service.StaffDepartmentRelatedService;
import com.gic.wechat.api.dto.qywx.ItemDTO;
import com.gic.wechat.api.dto.qywx.QywxXcxSendMessageDTO;
......@@ -37,7 +35,7 @@ import java.util.*;
@Service
public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRelatedApiService {
private static Logger logger= LoggerFactory.getLogger(StaffDepartmentRelatedApiServiceImpl.class);
private static final Logger logger = LoggerFactory.getLogger(StaffDepartmentRelatedApiServiceImpl.class);
@Autowired
private StaffDepartmentRelatedService staffDepartmentRelatedService;
......@@ -50,10 +48,6 @@ public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRela
@Autowired
private WxEnterpriseMapper wxEnterpriseMapper;
@Autowired
private WxEnterpriseRelatedMapper wxEnterpriseRelatedMapper;
@Autowired
private DepartmentService departmentService;
@Autowired
private Config config;
@Autowired
private TabHaobanStaffClerkRelationMapper tabHaobanStaffClerkRelationMapper;
......@@ -61,20 +55,19 @@ public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRela
private StaffApiService staffApiService;
@Override
public List<StaffDepartmentRelatedDTO> listByDepartmentId(
String departmentId) {
public List<StaffDepartmentRelatedDTO> listByDepartmentId(String departmentId) {
List<TabHaobanStaffDepartmentRelated> list = staffDepartmentRelatedService.listByDepartmentId(departmentId);
List<StaffDepartmentRelatedDTO> resultList = EntityUtil.changeEntityListByJSON(StaffDepartmentRelatedDTO.class, list);
return resultList;
}
@Override
public List<StaffDepartmentRelatedDTO> listByDepartmentIds(
List<String> departmentIds) {
public List<StaffDepartmentRelatedDTO> listByDepartmentIds(List<String> departmentIds) {
List<TabHaobanStaffDepartmentRelated> list = staffDepartmentRelatedMapper.listByDepartmentIds(departmentIds);
List<StaffDepartmentRelatedDTO> resultList = EntityUtil.changeEntityListByJSON(StaffDepartmentRelatedDTO.class, list);
return resultList;
}
@Override
public void updateById(StaffDepartmentRelatedDTO dto) {
TabHaobanStaffDepartmentRelated tab = EntityUtil.changeEntityByJSON(TabHaobanStaffDepartmentRelated.class, dto);
......@@ -187,13 +180,13 @@ public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRela
String wxUserId = staffDTO.getWxUserId();
String corpId = tabHaobanWxEnterprise.getCorpid();
String name = staffDTO.getStaffName();
if(content.length()>30){
if (content.length() > 30) {
content = content.substring(0, 26);
content = content+"...";
content = content + "...";
}
//先发送下,试试
QywxXcxSendMessageDTO messageDTO = new QywxXcxSendMessageDTO();
List<ItemDTO> items = new ArrayList();;
List<ItemDTO> items = new ArrayList();
ItemDTO dto1 = new ItemDTO();
ItemDTO dto2 = new ItemDTO();
ItemDTO dto3 = new ItemDTO();
......@@ -269,17 +262,18 @@ public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRela
}
//导购删除,,审核记录,,消息发送
public void sendClerkDel (String clerkName,String clerkCode,String storeId,int auditStatus,String auditReason){
//TODO huang 发送店长,门店关联记录列表
String messageTitle = "门店导购变更";
String messageContent ="删除导购:"+ clerkName+"("+clerkCode+")";
@Override
public void sendClerkDel(String clerkName, String clerkCode, String storeId, int auditStatus, String auditReason) {
//TODO huang 发送店长,门店关联记录列表
String messageTitle = "门店导购变更";
String messageContent = "删除导购:" + clerkName + "(" + clerkCode + ")";
JSONObject jsonObject = new JSONObject();
jsonObject.put("storeId", storeId);
String data = jsonObject.toJSONString();
ClerkDTO gicClerk = clerkService.getClerkLeaderByStoreId(storeId);
if(gicClerk == null){
logger.info("店长不存在,发送消息失败{}",storeId);
return ;
ClerkDTO gicClerk = clerkService.getClerkLeaderByStoreId(storeId);
if (gicClerk == null) {
logger.info("店长不存在,发送消息失败{}", storeId);
return;
}
TabHaobanStaffClerkRelation tab = tabHaobanStaffClerkRelationMapper.getOneByClerkId(gicClerk.getClerkId());
if(tab == null){
......@@ -301,17 +295,17 @@ public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRela
String corpId = map.get("corpId");
String name = map.get("clerkName");
if(jodd.util.StringUtil.isEmpty(wxUserId)){
logger.info("wxUserId不存在============clerkId={}",clerkId);
if (jodd.util.StringUtil.isEmpty(wxUserId)) {
logger.info("wxUserId不存在============clerkId={}", clerkId);
return false;
}
if(content.length()>30){
if (content.length() > 30) {
content = content.substring(0, 26);
content = content+"...";
content = content + "...";
}
//先发送下,试试
QywxXcxSendMessageDTO messageDTO = new QywxXcxSendMessageDTO();
List<ItemDTO> items = new ArrayList();;
List<ItemDTO> items = new ArrayList();
ItemDTO dto1 = new ItemDTO();
ItemDTO dto2 = new ItemDTO();
dto1.setKey("接收人");
......@@ -320,8 +314,8 @@ public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRela
dto2.setValue(content);
items.add(dto1);
items.add(dto2);
ArrayList<String> list = new ArrayList<>();
list.add(wxUserId);
ArrayList<String> list = new ArrayList<>();
list.add(wxUserId);
messageDTO.setAppid(config.getAppid());
messageDTO.setUserIds(list);
messageDTO.setPage(pageUrl);
......@@ -391,22 +385,22 @@ public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRela
@Override
public boolean sendAuditMessage(String staffId, String title,
String content, String pageUrl,int auditStatus, String auditReason) {
Map<String,String> map = getWxUserIdByStaffId(staffId);
Map<String, String> map = getWxUserIdByStaffId(staffId);
String wxUserId = map.get("wxUserId");
String corpId = map.get("corpId");
String name = map.get("staffName");
if(jodd.util.StringUtil.isEmpty(wxUserId)){
logger.info("wxUserId不存在============clerkId={}",staffId);
if (StringUtils.isEmpty(wxUserId)) {
logger.info("wxUserId不存在============clerkId={}", staffId);
return false;
}
if(content.length()>30){
if (content.length() > 30) {
content = content.substring(0, 26);
content = content+"...";
content = content + "...";
}
//先发送下,试试
QywxXcxSendMessageDTO messageDTO = new QywxXcxSendMessageDTO();
List<ItemDTO> items = new ArrayList();;
List<ItemDTO> items = new ArrayList();
ItemDTO dto1 = new ItemDTO();
ItemDTO dto2 = new ItemDTO();
ItemDTO dto3 = new ItemDTO();
......@@ -440,6 +434,7 @@ public class StaffDepartmentRelatedApiServiceImpl implements StaffDepartmentRela
logger.info("发送===============》{}",b);
return b;
}
@Override
public String getPageUrl(int type, String data) {
String baseUrl = "/pages/route/index";
......
......@@ -215,7 +215,7 @@
</if>
order by create_time desc
</select>
<select id="StaffClerkUnBindLog" resultMap="BaseResultMap">
<select id="staffClerkUnBindLog" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_staff_clerk_bind_log
......
......@@ -437,7 +437,11 @@
and audit_type = 3
and audit_status = 0
and enterprise_id = #{enterpriseId,jdbcType=VARCHAR}
and (related_Id = #{clerkCode} or old_value like concat ('%',#{phoneNumber},'%'))
and (related_Id = #{clerkCode}
<if test="phoneNumber != null and phoneNumber != ''">
or old_value like concat ('%',#{phoneNumber},'%')
</if>
)
</select>
</mapper>
\ No newline at end of file
......@@ -573,4 +573,15 @@
and status_flag = 1
and external_user_id = #{externalUserId}
</select>
<update id="updateMemberIdByMemberId">
UPDATE
tab_haoban_external_clerk_related
SET
member_id=#{memberId},
update_time = now()
where
member_id = #{oldMemberId}
and status_flag = 1
</update>
</mapper>
\ No newline at end of file
import com.gic.haoban.common.utils.UuidUtil;
import com.gic.haoban.manage.api.service.ExternalClerkRelatedApiService;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanOperationSettingMapper;
import com.gic.haoban.manage.service.entity.TabHaobanOperationSetting;
import com.gic.haoban.manage.service.service.ExternalClerkRelatedService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -22,14 +24,13 @@ public class TestOperDatabase {
@Autowired
private TabHaobanOperationSettingMapper tabHaobanOperationSettingMapper;
@Autowired
private ExternalClerkRelatedService externalClerkRelatedService;
@Test
public void testOperSetting() {
TabHaobanOperationSetting setting = new TabHaobanOperationSetting();
setting.setClerkPhoneFlag(1);
setting.setCreateTime(new Date());
setting.setSettingId(UuidUtil.randomUUID());
setting.setWxEnterpriseId("123123");
tabHaobanOperationSettingMapper.insert(setting);
String s = externalClerkRelatedService.checkAndUpdateMemberByUnonId("ff8080815dacd3a2015dacd3ef5c0000", "ff8080817b95cd7e017b95f2c0ec009d", "orXl9t9_320bmRutZoL8YEpPAc00");
System.out.println(s);
}
}
......@@ -6,17 +6,14 @@
<groupId>com.gic</groupId>
<artifactId>gic-pom-base</artifactId>
<version>3.0-SNAPSHOT</version>
<relativePath/>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>haoban-manage3-web</artifactId>
<version>${libraryVersion}</version>
<packaging>war</packaging>
<name>haoban-manage3-web Maven Webapp</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<haobanService>1.0-SNAPSHOT</haobanService>
......
package com.gic.haoban.manage.web.controller;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.hutool.core.collection.CollectionUtil;
import com.gic.cloud.common.api.base.Page;
import com.gic.cloud.data.api.dto.AdsGicLogHaobanStoreIntervalLoginDDTO;
import com.gic.cloud.data.api.dto.AdsGicLogHaobanStoreLoginDDTO;
import com.gic.cloud.data.api.dto.AreaLoginDTO;
import com.gic.cloud.data.api.dto.HaobanClerkLoginDTO;
import com.gic.cloud.data.api.dto.HaobanLoginInfoDTO;
import com.gic.cloud.data.api.dto.MemberAnalyzeParamsDTO;
import com.gic.cloud.data.api.dto.*;
import com.gic.cloud.data.api.service.MaidianDataService;
import com.gic.cloud.web.service.api.dto.CloudStoreGroupDTO;
import com.gic.cloud.web.service.api.service.CloudStoreGroupService;
import com.gic.commons.util.EntityUtil;
import com.gic.haoban.common.utils.ExcelUtils;
import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.redis.data.util.RedisUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.SimpleDateFormat;
import java.util.*;
@RestController
@RequestMapping("web")
public class MaidianDataController extends WebBaseController{
private static Logger logger = LoggerFactory.getLogger(MaidianDataController.class);
@Autowired
private MaidianDataService maidianDataService;
@Autowired
private CloudStoreGroupService cloudStoreGroupService;
@Autowired
private WxEnterpriseRelatedApiService wxEnterpriseRelatedApiService;
//首页-分组列表
public class MaidianDataController extends WebBaseController {
private static final Logger logger = LoggerFactory.getLogger(MaidianDataController.class);
@Autowired
private MaidianDataService maidianDataService;
@Autowired
private CloudStoreGroupService cloudStoreGroupService;
//首页-分组列表
@RequestMapping("/use-haoban3-service")
public HaobanResponse useHaoban3Service(String wxEnterpriseId) {
Object o = RedisUtil.getCache("usesMaidianWxEnterpriseId");
boolean b = false;
if(o == null){
}else {
String wxEnterpriseIds = o.toString();
if(wxEnterpriseIds.contains(wxEnterpriseId)||"-1".equals(wxEnterpriseIds)){
b = true;
}
}
return resultResponse(HaoBanErrCode.ERR_1,b);
Object o = RedisUtil.getCache("usesMaidianWxEnterpriseId");
boolean b = false;
if (o != null) {
String wxEnterpriseIds = o.toString();
if (wxEnterpriseIds.contains(wxEnterpriseId) || "-1".equals(wxEnterpriseIds)) {
b = true;
}
}
return resultResponse(HaoBanErrCode.ERR_1, b);
}
//首页-分组列表
//首页-分组列表
@RequestMapping("/cloud-grouplist-pid")
public HaobanResponse cloudGrouplistPid(String enterpriseId) {
Map<String, Object> returnMap = new HashMap<String, Object>();
List<CloudStoreGroupDTO> list = cloudStoreGroupService.queryAllStoreGroupByStoreGroupId(enterpriseId);
if(CollectionUtil.isEmpty(list)){
list = new ArrayList<>();
if (CollectionUtil.isEmpty(list)) {
list = new ArrayList<>();
}
returnMap.put("list", list);
return resultResponse(HaoBanErrCode.ERR_1,returnMap);
return resultResponse(HaoBanErrCode.ERR_1, returnMap);
}
//首页-企业概况
//首页-企业概况
@RequestMapping("/total-activation-data")
public HaobanResponse totalActivationData(MemberAnalyzeParamsDTO paramsDTO) {
paramsDTO.setWebFlag(1);
paramsDTO.setWebFlag(1);
Map<String, Object> returnMap = new HashMap<String, Object>();
AdsGicLogHaobanStoreLoginDDTO dto = maidianDataService.totalActivationData(paramsDTO);
if(dto == null){
return resultResponse(HaoBanErrCode.ERR_1,returnMap);
if (dto == null) {
return resultResponse(HaoBanErrCode.ERR_1, returnMap);
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
paramsDTO.setStartDate(sdf.format(new Date()));
AdsGicLogHaobanStoreLoginDDTO today = maidianDataService.totalActivationData(paramsDTO);
if(today == null){
today = new AdsGicLogHaobanStoreLoginDDTO();
if (today == null) {
today = new AdsGicLogHaobanStoreLoginDDTO();
}
returnMap.put("loginClerkCnt", dto.getLoginClerkCnt()) ;
returnMap.put("activeClerkCnt", dto.getActiveClerkCnt()) ;
returnMap.put("loginClerkTimes", dto.getLoginClerkTimes()) ;
returnMap.put("notActiveClerkCnt", dto.getNotActiveClerkCnt()) ;
returnMap.put("totalClerkCnt", dto.getTotalClerkCnt()) ;
returnMap.put("notLoginClerkCnt", dto.getNotLoginClerkCnt()) ;
if(dto.getLoginClerkCnt() == null||dto.getLoginClerkCnt()==0){
returnMap.put("avgLoginTimes",0) ;
returnMap.put("avgVisitTime", 0) ;
}else {
returnMap.put("avgLoginTimes", dto.getLoginClerkTimes()/dto.getLoginClerkCnt()) ;
returnMap.put("avgVisitTime", dto.getStayTime()/dto.getLoginClerkCnt()) ;
returnMap.put("loginClerkCnt", dto.getLoginClerkCnt());
returnMap.put("activeClerkCnt", dto.getActiveClerkCnt());
returnMap.put("loginClerkTimes", dto.getLoginClerkTimes());
returnMap.put("notActiveClerkCnt", dto.getNotActiveClerkCnt());
returnMap.put("totalClerkCnt", dto.getTotalClerkCnt());
returnMap.put("notLoginClerkCnt", dto.getNotLoginClerkCnt());
if (dto.getLoginClerkCnt() == null || dto.getLoginClerkCnt() == 0) {
returnMap.put("avgLoginTimes", 0);
returnMap.put("avgVisitTime", 0);
} else {
returnMap.put("avgLoginTimes", dto.getLoginClerkTimes() / dto.getLoginClerkCnt());
returnMap.put("avgVisitTime", dto.getStayTime() / dto.getLoginClerkCnt());
}
returnMap.put("toDayLoginClerkCnt", today.getLoginClerkCnt()) ;
returnMap.put("toDayLoginClerkCnt", today.getLoginClerkCnt());
return resultResponse(HaoBanErrCode.ERR_1,returnMap);
return resultResponse(HaoBanErrCode.ERR_1, returnMap);
}
//首页-好办登陆信息总人数概况
@RequestMapping("/total-login-data")
public HaobanResponse totalLoginData(MemberAnalyzeParamsDTO paramsDTO,int datesType) {
paramsDTO.setWebFlag(1);
public HaobanResponse totalLoginData(MemberAnalyzeParamsDTO paramsDTO, int datesType) {
paramsDTO.setWebFlag(1);
Map<String, Object> returnMap = new HashMap<String, Object>();
List<HaobanLoginInfoDTO> resultList = new ArrayList<HaobanLoginInfoDTO>();
if(datesType == 1){
//近7日
List<AdsGicLogHaobanStoreLoginDDTO> list = maidianDataService.totalLoginData(paramsDTO);
resultList = EntityUtil.changeEntityListByJSON(HaobanLoginInfoDTO.class, list);
}else {
//当日
List<AdsGicLogHaobanStoreIntervalLoginDDTO> list = maidianDataService.totalLoginInternalData(paramsDTO);
resultList = EntityUtil.changeEntityListByJSON(HaobanLoginInfoDTO.class, list);
if (datesType == 1) {
//近7日
List<AdsGicLogHaobanStoreLoginDDTO> list = maidianDataService.totalLoginData(paramsDTO);
resultList = EntityUtil.changeEntityListByJSON(HaobanLoginInfoDTO.class, list);
} else {
//当日
List<AdsGicLogHaobanStoreIntervalLoginDDTO> list = maidianDataService.totalLoginInternalData(paramsDTO);
resultList = EntityUtil.changeEntityListByJSON(HaobanLoginInfoDTO.class, list);
}
for(HaobanLoginInfoDTO dto : resultList){
if(dto.getLoginClerkCnt() == 0){
dto.setAvgVisitTime("0");
dto.setAvgLoginTimes("0");
}else{
dto.setAvgVisitTime((double)dto.getStayTime()/dto.getLoginClerkCnt()+"");
dto.setAvgLoginTimes(dto.getLoginClerkTimes()/dto.getLoginClerkCnt()+"");
}
for (HaobanLoginInfoDTO dto : resultList) {
if (dto.getLoginClerkCnt() == 0) {
dto.setAvgVisitTime("0");
dto.setAvgLoginTimes("0");
} else {
dto.setAvgVisitTime((double) dto.getStayTime() / dto.getLoginClerkCnt() + "");
dto.setAvgLoginTimes(dto.getLoginClerkTimes() / dto.getLoginClerkCnt() + "");
}
}
if(CollectionUtil.isEmpty(resultList)){
resultList = new ArrayList<>();
if (CollectionUtil.isEmpty(resultList)) {
resultList = new ArrayList<>();
}
returnMap.put("result", resultList) ;
return resultResponse(HaoBanErrCode.ERR_1,returnMap);
returnMap.put("result", resultList);
return resultResponse(HaoBanErrCode.ERR_1, returnMap);
}
//首页-区域排行
@RequestMapping("/area-login-ranking")
public HaobanResponse areaLoginRanking(MemberAnalyzeParamsDTO paramsDTO) {
paramsDTO.setWebFlag(1);
paramsDTO.setWebFlag(1);
Map<String, Object> returnMap = new HashMap<String, Object>();
List<AreaLoginDTO> list = maidianDataService.areaLoginRanking(paramsDTO);
if(CollectionUtil.isEmpty(list)){
list = new ArrayList<>();
if (CollectionUtil.isEmpty(list)) {
list = new ArrayList<>();
}
returnMap.put("result", list) ;
return resultResponse(HaoBanErrCode.ERR_1,returnMap);
returnMap.put("result", list);
return resultResponse(HaoBanErrCode.ERR_1, returnMap);
}
//激活明细-激活趋势图
@RequestMapping("/activite-date")
public HaobanResponse activiteDate(MemberAnalyzeParamsDTO paramsDTO) {
paramsDTO.setWebFlag(1);
paramsDTO.setWebFlag(1);
Map<String, Object> returnMap = new HashMap<String, Object>();
List<HaobanLoginInfoDTO> resultList = new ArrayList<HaobanLoginInfoDTO>();
//近7日
List<AdsGicLogHaobanStoreLoginDDTO> list = maidianDataService.totalLoginData(paramsDTO);
resultList = EntityUtil.changeEntityListByJSON(HaobanLoginInfoDTO.class, list);
if(CollectionUtil.isEmpty(resultList)){
resultList = new ArrayList<>();
List<AdsGicLogHaobanStoreLoginDDTO> list = maidianDataService.totalLoginData(paramsDTO);
resultList = EntityUtil.changeEntityListByJSON(HaobanLoginInfoDTO.class, list);
if (CollectionUtil.isEmpty(resultList)) {
resultList = new ArrayList<>();
}
returnMap.put("result", resultList) ;
return resultResponse(HaoBanErrCode.ERR_1,returnMap);
returnMap.put("result", resultList);
return resultResponse(HaoBanErrCode.ERR_1, returnMap);
}
//激活明细-激活列表
@RequestMapping("/activite-list")
public HaobanResponse activiteList(MemberAnalyzeParamsDTO paramsDTO) {
paramsDTO.setWebFlag(1);
Page<HaobanClerkLoginDTO> page= maidianDataService.pageActiviteList(paramsDTO);
return resultResponse(HaoBanErrCode.ERR_1,page);
paramsDTO.setWebFlag(1);
Page<HaobanClerkLoginDTO> page = maidianDataService.pageActiviteList(paramsDTO);
return resultResponse(HaoBanErrCode.ERR_1, page);
}
//导出-激活明细-激活列表
@RequestMapping("/export-activite-list")
public HaobanResponse exportActiviteList(HttpServletRequest request,HttpServletResponse response,MemberAnalyzeParamsDTO paramsDTO) {
paramsDTO.setWebFlag(1);
public HaobanResponse exportActiviteList(HttpServletRequest request, HttpServletResponse response, MemberAnalyzeParamsDTO paramsDTO) {
paramsDTO.setWebFlag(1);
paramsDTO.setCurrentPage(1);
paramsDTO.setPageSize(Integer.MAX_VALUE);
Page<HaobanClerkLoginDTO> page= maidianDataService.pageActiviteList(paramsDTO);
List<String> titleList = Arrays.asList( "导购姓名","导购代码","归属门店","最后登录时间","活跃状态");
List<String> fileList = Arrays.asList("clerkName", "clerkCode", "storeName", "lastLoginTime", "activationStatus");
try {
ExcelUtils.xls(response, request, "详情报表", page.getList(), fileList, titleList);
} catch (Exception e) {
logger.info(e.getMessage(),e);
}
Page<HaobanClerkLoginDTO> page = maidianDataService.pageActiviteList(paramsDTO);
List<String> titleList = Arrays.asList("导购姓名", "导购代码", "归属门店", "最后登录时间", "活跃状态");
List<String> fileList = Arrays.asList("clerkName", "clerkCode", "storeName", "lastLoginTime", "activationStatus");
try {
ExcelUtils.xls(response, request, "详情报表", page.getList(), fileList, titleList);
} catch (Exception e) {
logger.info(e.getMessage(), e);
}
return resultResponse(HaoBanErrCode.ERR_1);
}
//导出-登陆明细-明细列表
@RequestMapping("/export-login-detail-list")
public HaobanResponse exportLoginDetailList(HttpServletRequest request,HttpServletResponse response,MemberAnalyzeParamsDTO paramsDTO) {
paramsDTO.setWebFlag(1);
//默认排序
if(StringUtils.isEmpty(paramsDTO.getSortColumn())) {
paramsDTO.setSortColumn("lastLoginTime");
}
if(StringUtils.isEmpty(paramsDTO.getSortType())) {
paramsDTO.setSortType("desc");
}
public HaobanResponse exportLoginDetailList(HttpServletRequest request, HttpServletResponse response, MemberAnalyzeParamsDTO paramsDTO) {
paramsDTO.setWebFlag(1);
//默认排序
if (StringUtils.isEmpty(paramsDTO.getSortColumn())) {
paramsDTO.setSortColumn("lastLoginTime");
}
if (StringUtils.isEmpty(paramsDTO.getSortType())) {
paramsDTO.setSortType("desc");
}
paramsDTO.setCurrentPage(1);
paramsDTO.setPageSize(Integer.MAX_VALUE);
Map<String, Object> returnMap = new HashMap<String, Object>();
Page<HaobanClerkLoginDTO> page= maidianDataService.pageClerkLogin(paramsDTO);
if(paramsDTO.getLoginStatus() == 1){
//已登陆
try {
List<String> titleList = Arrays.asList( "导购姓名","导购代码","归属门店","最后登录时间","登录次数","平均访问总时长");
List<String> fileList = Arrays.asList("clerkName", "clerkCode", "storeName", "lastLoginTime", "loginTimes", "avgVisitTimeString");
ExcelUtils.xls(response, request, "详情报表", page.getList(), fileList, titleList);
} catch (Exception e) {
logger.info(e.getMessage(),e);
}
}else{
//未登陆
try {
List<String> titleList = Arrays.asList( "导购姓名","导购代码","归属门店","最后登录时间");
List<String> fileList = Arrays.asList("clerkName", "clerkCode", "storeName", "lastLoginTime");
ExcelUtils.xls(response, request, "详情报表", page.getList(), fileList, titleList);
} catch (Exception e) {
logger.info(e.getMessage(),e);
}
}
return resultResponse(HaoBanErrCode.ERR_1);
Page<HaobanClerkLoginDTO> page = maidianDataService.pageClerkLogin(paramsDTO);
if (paramsDTO.getLoginStatus() == 1) {
//已登陆
try {
List<String> titleList = Arrays.asList("导购姓名", "导购代码", "归属门店", "最后登录时间", "登录次数", "平均访问总时长");
List<String> fileList = Arrays.asList("clerkName", "clerkCode", "storeName", "lastLoginTime", "loginTimes", "avgVisitTimeString");
ExcelUtils.xls(response, request, "详情报表", page.getList(), fileList, titleList);
} catch (Exception e) {
logger.info(e.getMessage(), e);
}
} else {
//未登陆
try {
List<String> titleList = Arrays.asList("导购姓名", "导购代码", "归属门店", "最后登录时间");
List<String> fileList = Arrays.asList("clerkName", "clerkCode", "storeName", "lastLoginTime");
ExcelUtils.xls(response, request, "详情报表", page.getList(), fileList, titleList);
} catch (Exception e) {
logger.info(e.getMessage(), e);
}
}
return resultResponse(HaoBanErrCode.ERR_1);
}
//登陆明细-明细列表
@RequestMapping("/login-detail-list")
public HaobanResponse loginDetailList(MemberAnalyzeParamsDTO paramsDTO) {
paramsDTO.setWebFlag(1);
//默认排序
if(StringUtils.isEmpty(paramsDTO.getSortColumn())) {
paramsDTO.setSortColumn("lastLoginTime");
}
if(StringUtils.isEmpty(paramsDTO.getSortType())) {
paramsDTO.setSortType("desc");
}
paramsDTO.setWebFlag(1);
//默认排序
if (StringUtils.isEmpty(paramsDTO.getSortColumn())) {
paramsDTO.setSortColumn("lastLoginTime");
}
if (StringUtils.isEmpty(paramsDTO.getSortType())) {
paramsDTO.setSortType("desc");
}
Map<String, Object> returnMap = new HashMap<String, Object>();
Page<HaobanClerkLoginDTO> page= maidianDataService.pageClerkLogin(paramsDTO);
returnMap.put("result", page) ;
return resultResponse(HaoBanErrCode.ERR_1,returnMap);
Page<HaobanClerkLoginDTO> page = maidianDataService.pageClerkLogin(paramsDTO);
returnMap.put("result", page);
return resultResponse(HaoBanErrCode.ERR_1, returnMap);
}
//区域排行-区域图表
@RequestMapping("area-ranking-date")
public HaobanResponse areaRankingDate(MemberAnalyzeParamsDTO paramsDTO) {
paramsDTO.setWebFlag(1);
paramsDTO.setWebFlag(1);
Map<String, Object> returnMap = new HashMap<String, Object>();
List<AreaLoginDTO> list = maidianDataService.areaRankingDate(paramsDTO);
returnMap.put("result", list) ;
return resultResponse(HaoBanErrCode.ERR_1,returnMap);
returnMap.put("result", list);
return resultResponse(HaoBanErrCode.ERR_1, returnMap);
}
//区域排行-区域列表
@RequestMapping("/area-ranking-list")
public HaobanResponse areaRankingList(MemberAnalyzeParamsDTO paramsDTO) {
paramsDTO.setWebFlag(1);
//默认排序
if(StringUtils.isEmpty(paramsDTO.getSortColumn())) {
paramsDTO.setSortColumn("loginRate");
}
if(StringUtils.isEmpty(paramsDTO.getSortType())) {
paramsDTO.setSortType("desc");
}
paramsDTO.setAreaType("store");
paramsDTO.setWebFlag(1);
//默认排序
if (StringUtils.isEmpty(paramsDTO.getSortColumn())) {
paramsDTO.setSortColumn("loginRate");
}
if (StringUtils.isEmpty(paramsDTO.getSortType())) {
paramsDTO.setSortType("desc");
}
paramsDTO.setAreaType("store");
Map<String, Object> returnMap = new HashMap<String, Object>();
Page<AreaLoginDTO> page = maidianDataService.areaRankingList(paramsDTO);
returnMap.put("result", page) ;
return resultResponse(HaoBanErrCode.ERR_1,returnMap);
returnMap.put("result", page);
return resultResponse(HaoBanErrCode.ERR_1, returnMap);
}
//导出-区域排行-区域列表
@RequestMapping("/export-area-ranking-list")
public HaobanResponse exportAreaRankingList(HttpServletRequest request,HttpServletResponse response,MemberAnalyzeParamsDTO paramsDTO) {
paramsDTO.setWebFlag(1);
//默认排序
if(StringUtils.isEmpty(paramsDTO.getSortColumn())) {
paramsDTO.setSortColumn("loginRate");
}
if(StringUtils.isEmpty(paramsDTO.getSortType())) {
paramsDTO.setSortType("desc");
}
paramsDTO.setAreaType("store");
paramsDTO.setCurrentPage(1);
paramsDTO.setPageSize(Integer.MAX_VALUE);
public HaobanResponse exportAreaRankingList(HttpServletRequest request, HttpServletResponse response, MemberAnalyzeParamsDTO paramsDTO) {
paramsDTO.setWebFlag(1);
//默认排序
if (StringUtils.isEmpty(paramsDTO.getSortColumn())) {
paramsDTO.setSortColumn("loginRate");
}
if (StringUtils.isEmpty(paramsDTO.getSortType())) {
paramsDTO.setSortType("desc");
}
paramsDTO.setAreaType("store");
paramsDTO.setCurrentPage(1);
paramsDTO.setPageSize(Integer.MAX_VALUE);
Page<AreaLoginDTO> page = maidianDataService.areaRankingList(paramsDTO);
List<String> titleList = Arrays.asList( "门店名称","门店code","分组名称","登录率","登录人数");
List<String> fileList = Arrays.asList("exportName", "storeCode", "storeGroupName", "loginRateString", "loginClerkCnt");
try {
ExcelUtils.xls(response, request, "详情报表", page.getList(), fileList, titleList);
} catch (Exception e) {
logger.info(e.getMessage(),e);
}
return resultResponse(HaoBanErrCode.ERR_1);
List<String> titleList = Arrays.asList("门店名称", "门店code", "分组名称", "登录率", "登录人数");
List<String> fileList = Arrays.asList("exportName", "storeCode", "storeGroupName", "loginRateString", "loginClerkCnt");
try {
ExcelUtils.xls(response, request, "详情报表", page.getList(), fileList, titleList);
} catch (Exception e) {
logger.info(e.getMessage(), e);
}
return resultResponse(HaoBanErrCode.ERR_1);
}
}
......@@ -5,6 +5,7 @@ import com.gic.haoban.manage.api.dto.OperationSettingDTO;
import com.gic.haoban.manage.api.service.OperationSettingApiService;
import com.gic.haoban.manage.web.anno.HttpLimit;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -30,7 +31,7 @@ public class SettingController extends WebBaseController {
private HaobanResponse operationSettingSaveOrUpdate(OperationSettingDTO dto) {
// 保存或更新操作设置
if (Objects.isNull(dto)
|| Objects.isNull(dto.getWxEnterpriseId())) {
|| StringUtils.isEmpty(dto.getWxEnterpriseId())) {
return resultResponse(HaoBanErrCode.ERR_2);
}
operationSettingApiService.saveOrUpdate(dto);
......
......@@ -9,25 +9,21 @@ import com.gic.clerk.api.service.ClerkNewService;
import com.gic.clerk.api.service.ClerkService;
import com.gic.commons.util.DateUtil;
import com.gic.commons.util.ExcelUtils;
import com.gic.enterprise.api.dto.*;
import com.gic.enterprise.api.dto.EnterpriseDTO;
import com.gic.enterprise.api.service.*;
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.base.api.common.BasePageInfo;
import com.gic.haoban.base.api.common.PageResult;
import com.gic.haoban.base.api.common.ServiceResponse;
import com.gic.haoban.common.utils.EntityUtil;
import com.gic.haoban.common.utils.HaobanResponse;
import com.gic.haoban.manage.api.dto.*;
import com.gic.haoban.manage.api.dto.DepartmentDTO;
import com.gic.haoban.manage.api.enums.BindTypeEnum;
import com.gic.haoban.manage.api.enums.ChannelCodeEnum;
import com.gic.haoban.manage.api.service.*;
import com.gic.haoban.manage.web.auth.AuthRequestUtil;
import com.gic.haoban.manage.web.errCode.HaoBanErrCode;
import com.gic.haoban.manage.web.qo.StaffEditJsonQO;
import com.gic.haoban.manage.web.vo.ClerkInfoVo;
import com.gic.haoban.manage.web.vo.StaffExportVO;
import com.gic.haoban.manage.web.vo.StaffVO;
import com.gic.wechat.api.service.qywx.QywxUserApiService;
......@@ -40,563 +36,521 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.stream.Collectors;
@RestController
public class StaffController extends WebBaseController{
private static Logger logger = LoggerFactory.getLogger(StaffController.class);
@Autowired
private StaffApiService staffApiService;
@Autowired
private DepartmentApiService departmentApiService;
@Autowired
private StaffDepartmentRelatedApiService staffDepartmentRelatedApiService;
@Autowired
private QywxUserApiService qywxUserApiService;
@Autowired
private WxEnterpriseApiService wxEnterpriseApiService;
@Autowired
private WxApplicationApiService wxApplicationApiService;
@Autowired
private ClerkService clerkService;
@Autowired
private ClerkNewService clerkNewService;
@Autowired
private StoreService storeService;
@Autowired
private StaffClerkRelationApiService staffClerkRelationApiService;
@Autowired
private WxEnterpriseRelatedApiService wxEnterpriseRelatedApiService;
@Autowired
private EnterpriseService enterpriseService;
@Autowired
private ClerkMainStoreRelatedApiService clerkMainStoreRelatedApiService;
@RequestMapping("staff-add")
public HaobanResponse staffAdd(StaffDTO staffDTO,String departmentIds){
LoginDTO login = (LoginDTO) AuthRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
String staffName = staffDTO.getStaffName();
String phoneNumber = staffDTO.getPhoneNumber();
String nationcode = staffDTO.getNationCode();
staffDTO.setWxEnterpriseId(wxEnterpriseId);
if(StringUtils.isBlank(staffName)) {
return resultResponse(HaoBanErrCode.ERR_10004);
}
StaffDTO staff = staffApiService.selectByNationcodeAndPhoneNumber(wxEnterpriseId,nationcode,phoneNumber);
if(staff != null) {
return resultResponse(HaoBanErrCode.ERR_10005);
}
ServiceResponse hr = staffApiService.add(staffDTO,departmentIds);
if(hr.getCode() == 0){
return resultResponse(HaoBanErrCode.ERR_DEFINE, hr.getMessage(), null, hr.getMessage());
}
return resultResponse(HaoBanErrCode.ERR_1);
}
@RequestMapping("staff-sel")
public HaobanResponse staffSel(String staffId,String staffDepartmentRelatedId){
StaffDTO staff = staffApiService.selectById(staffId);
List<StaffDepartmentRelatedDTO> list = staffApiService.listStaffDepartmentByStaffId(staffId);
List<DepartmentDTO> departmentList = new ArrayList<DepartmentDTO>();
for (StaffDepartmentRelatedDTO staffDepartmentRelatedDTO : list) {
DepartmentDTO dto = departmentApiService.selectById(staffDepartmentRelatedDTO.getDepartmentId());
departmentList.add(dto);
}
staff.setDepartmentList(departmentList);
return resultResponse(HaoBanErrCode.ERR_1,staff);
}
@RequestMapping("staff-list")
public HaobanResponse staffList(String departmentId,Integer activeFlag,String keyWord,BasePageInfo pageInfo){
LoginDTO login = (LoginDTO) AuthRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
List<String> departmentIdSet = new ArrayList<>();
departmentIdSet.add(departmentId);
List<DepartmentDTO> sonDepartmentList = departmentApiService.listSonByDepartmentIds(departmentIdSet, wxEnterpriseId);
List<String> departmentIds = sonDepartmentList.stream().map(DepartmentDTO::getDepartmentId).collect(Collectors.toList());
Page<StaffDTO> page = staffApiService.pageStaff(departmentIds,activeFlag,keyWord,pageInfo);
List<StaffDTO> list = page.getResult();
logger.info("pages={},totalPage={}",page.getCurrentPage(),page.getTotalPage());
PageResult<StaffDTO> pageVo = new PageResult<>();
public class StaffController extends WebBaseController {
private static final Logger logger = LoggerFactory.getLogger(StaffController.class);
@Autowired
private StaffApiService staffApiService;
@Autowired
private DepartmentApiService departmentApiService;
@Autowired
private StaffDepartmentRelatedApiService staffDepartmentRelatedApiService;
@Autowired
private QywxUserApiService qywxUserApiService;
@Autowired
private WxEnterpriseApiService wxEnterpriseApiService;
@Autowired
private WxApplicationApiService wxApplicationApiService;
@Autowired
private ClerkService clerkService;
@Autowired
private ClerkNewService clerkNewService;
@Autowired
private StoreService storeService;
@Autowired
private StaffClerkRelationApiService staffClerkRelationApiService;
@Autowired
private WxEnterpriseRelatedApiService wxEnterpriseRelatedApiService;
@Autowired
private EnterpriseService enterpriseService;
@Autowired
private ClerkMainStoreRelatedApiService clerkMainStoreRelatedApiService;
@RequestMapping("staff-add")
public HaobanResponse staffAdd(StaffDTO staffDTO, String departmentIds) {
LoginDTO login = (LoginDTO) AuthRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
String staffName = staffDTO.getStaffName();
String phoneNumber = staffDTO.getPhoneNumber();
String nationcode = staffDTO.getNationCode();
staffDTO.setWxEnterpriseId(wxEnterpriseId);
if (StringUtils.isBlank(staffName)) {
return resultResponse(HaoBanErrCode.ERR_10004);
}
StaffDTO staff = staffApiService.selectByNationcodeAndPhoneNumber(wxEnterpriseId, nationcode, phoneNumber);
if (staff != null) {
return resultResponse(HaoBanErrCode.ERR_10005);
}
ServiceResponse hr = staffApiService.add(staffDTO, departmentIds);
if (hr.getCode() == 0) {
return resultResponse(HaoBanErrCode.ERR_DEFINE, hr.getMessage(), null, hr.getMessage());
}
return resultResponse(HaoBanErrCode.ERR_1);
}
@RequestMapping("staff-sel")
public HaobanResponse staffSel(String staffId) {
StaffDTO staff = staffApiService.selectById(staffId);
List<StaffDepartmentRelatedDTO> list = staffApiService.listStaffDepartmentByStaffId(staffId);
List<DepartmentDTO> departmentList = new ArrayList<DepartmentDTO>();
for (StaffDepartmentRelatedDTO staffDepartmentRelatedDTO : list) {
DepartmentDTO dto = departmentApiService.selectById(staffDepartmentRelatedDTO.getDepartmentId());
departmentList.add(dto);
}
staff.setDepartmentList(departmentList);
return resultResponse(HaoBanErrCode.ERR_1, staff);
}
@RequestMapping("staff-list")
public HaobanResponse staffList(String departmentId, Integer activeFlag, String keyWord, BasePageInfo pageInfo) {
LoginDTO login = (LoginDTO) AuthRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
List<String> departmentIdSet = new ArrayList<>();
departmentIdSet.add(departmentId);
List<DepartmentDTO> sonDepartmentList = departmentApiService.listSonByDepartmentIds(departmentIdSet, wxEnterpriseId);
List<String> departmentIds = sonDepartmentList.stream().map(DepartmentDTO::getDepartmentId).collect(Collectors.toList());
Page<StaffDTO> page = staffApiService.pageStaff(departmentIds, activeFlag, keyWord, pageInfo);
List<StaffDTO> list = page.getResult();
logger.info("pages={},totalPage={}", page.getCurrentPage(), page.getTotalPage());
PageResult<StaffDTO> pageVo = new PageResult<>();
pageVo.setList(list);
pageVo.setPageNum(page.getCurrentPage());
pageVo.setPages(page.getPages());
pageVo.setPageSize(page.getPageSize());
pageVo.setTotal(page.getTotalCount());
return resultResponse(HaoBanErrCode.ERR_1, pageVo);
}
@RequestMapping("staff-del")
public HaobanResponse staffDel(String staffDepartmentStaffRelatedId){
StaffDepartmentRelatedDTO related = staffDepartmentRelatedApiService.getByStaffDepartmentRelatedId(staffDepartmentStaffRelatedId);
if(related == null){
return resultResponse(HaoBanErrCode.ERR_8);
}
DepartmentDTO department = departmentApiService.selectById(related.getDepartmentId());
if(department.getTempFlag() != null && department.getTempFlag() == 1){
return resultResponse(HaoBanErrCode.ERR_10014);
}
staffApiService.del(staffDepartmentStaffRelatedId);
return resultResponse(HaoBanErrCode.ERR_1);
}
@RequestMapping("staff-batch-del")
public HaobanResponse staffBatchDel(String staffDepartmentRelatedIds){
if(StringUtils.isBlank(staffDepartmentRelatedIds)){
return resultResponse(HaoBanErrCode.ERR_2);
}
String[] staffArr = staffDepartmentRelatedIds.split(",");
int size = staffArr.length;
for (String string : staffArr) {
StaffDepartmentRelatedDTO related = staffDepartmentRelatedApiService.getByStaffDepartmentRelatedId(string);
if(related == null){
continue;
}
DepartmentDTO department = departmentApiService.selectById(related.getDepartmentId());
if(department.getTempFlag() != null && department.getTempFlag() == 1){
if(size == 1){
return resultResponse(HaoBanErrCode.ERR_10014);
}
continue;
}
staffApiService.del(string);
}
return resultResponse(HaoBanErrCode.ERR_1);
}
@RequestMapping("staff-edit")
public HaobanResponse staffEdit(StaffDTO staffDTO,String departmentIds){
String staffId = staffDTO.getStaffId();
StaffDTO staff = staffApiService.selectById(staffId);
if(staff == null) {
return resultResponse(HaoBanErrCode.ERR_10006);
}
String phoneNumber = staffDTO.getPhoneNumber();
String nationcode = staffDTO.getNationCode();
String wxEnterpriseId = staff.getWxEnterpriseId();
StaffDTO old = staffApiService.selectByNationcodeAndPhoneNumber(wxEnterpriseId,nationcode,phoneNumber);
if(old != null && !old.getStaffId().equals(staffId)){
return resultResponse(HaoBanErrCode.ERR_10005);
}
staffApiService.staffEdit(staffDTO,departmentIds);
return resultResponse(HaoBanErrCode.ERR_1);
}
@RequestMapping("staff-invite")
public HaobanResponse staffInvite(String staffIds){
if(StringUtils.isBlank(staffIds)){
return resultResponse(HaoBanErrCode.ERR_2);
}
String[] staffArr = staffIds.split(",");
List<String> userArr = new ArrayList<>();
String wxEnterpriseId = "";
for (String staffId : staffArr) {
StaffDTO staff = staffApiService.selectById(staffId);
if(staff != null){
String userId = staff.getWxUserId();
wxEnterpriseId = staff.getWxEnterpriseId();
userArr.add(userId);
}
}
WxEnterpriseDTO enterpriseDTO = wxEnterpriseApiService.getOne(wxEnterpriseId);
WxApplicationDTO application = wxApplicationApiService.selectByWxEnterpriseIdAndApplicationType(wxEnterpriseId,1);
if(enterpriseDTO != null) {
if(application != null) {
qywxUserApiService.inviteUser(enterpriseDTO.getCorpid(), application.getSiteId(), userArr);
}
}
return resultResponse(HaoBanErrCode.ERR_1);
}
@RequestMapping("staff-batch-edit-department")
public HaobanResponse staffBatchEditDepartment(String params){
List<StaffEditJsonQO> list = JSON.parseArray(params, StaffEditJsonQO.class);
for (StaffEditJsonQO staffEditJsonQO : list) {
String staffDepartmentRelatedId = staffEditJsonQO.getStaffDepartmentRelatedId();
String departmentIds = staffEditJsonQO.getCurrDepartmentIds();
StaffDepartmentRelatedDTO related = staffDepartmentRelatedApiService.getByStaffDepartmentRelatedId(staffDepartmentRelatedId);
if(related != null) {
StaffDTO staff = staffApiService.selectById(related.getStaffId());
if(staff != null) {
staffApiService.staffEdit(staff, departmentIds);
}
}
}
return resultResponse(HaoBanErrCode.ERR_1);
}
@RequestMapping("get-clerk-info")
public HaobanResponse getClerkInfo(String clerkId){
StaffVO staffVO = new StaffVO();
ClerkDTO clerk = clerkService.getClerkByClerkId(clerkId);
if(clerk != null) {
String storeId = clerk.getStoreId();
StoreDTO storeDTO = storeService.getStore(storeId);
staffVO.setStaffName(clerk.getClerkName());
staffVO.setNationCode(clerk.getNationcode());
staffVO.setPhoneNumber(clerk.getPhoneNumber());
staffVO.setPosition(clerk.getPositionName());
staffVO.setHeadImg(clerk.getHeadImgUrl());
staffVO.setDepartmentName(storeDTO==null?"":storeDTO.getStoreName());
}
return resultResponse(HaoBanErrCode.ERR_1,staffVO);
}
@RequestMapping("get-staff-info")
public HaobanResponse getStaffInfo(String staffId){
StaffVO staffVO = new StaffVO();
StaffDTO staff = staffApiService.selectById(staffId);
if(staff != null) {
List<StaffDepartmentRelatedDTO> list = staffDepartmentRelatedApiService.listByStaffId(staffId);
staffVO.setStaffName(staff.getStaffName());
staffVO.setNationCode(staff.getNationCode());
staffVO.setPhoneNumber(staff.getPhoneNumber());
staffVO.setPosition(staff.getPostion());
staffVO.setHeadImg(staff.getHeadImg());
if(CollectionUtil.isNotEmpty(list)){
String departmentId = list.get(0).getDepartmentId();
DepartmentDTO departmentDTO = departmentApiService.selectById(departmentId);
if(departmentDTO != null){
staffVO.setDepartmentName(departmentDTO.getDepartmentName());
}
}
}
return resultResponse(HaoBanErrCode.ERR_1,staffVO);
}
/**
* 成员关联关系接口
* @param staffId
* @return
*/
@RequestMapping("staff-clerk-relation")
public HaobanResponse staffClerkList(String staffId){
StaffDTO staff = staffApiService.selectById(staffId);
if(staff == null) {
return resultResponse(HaoBanErrCode.ERR_10007);
}
List<StaffClerkInfoDTO> retList = staffClerkRelationApiService.listBindDetailByStaffId(staffId);
if (CollectionUtils.isEmpty(retList)) {
return resultResponse(HaoBanErrCode.ERR_1);
}
ClerkMainStoreRelatedDTO mainStoreRelatedDTO = clerkMainStoreRelatedApiService.getWxEnterpriseIdAndStaffId(staff.getWxEnterpriseId(), staffId);
if (null != mainStoreRelatedDTO) {
retList.forEach(dto -> {
if (dto.getStoreId().equals(mainStoreRelatedDTO.getStoreId())) {
dto.setMainStoreFlag(1);
} else {
dto.setMainStoreFlag(0);
}
});
}
return resultResponse(HaoBanErrCode.ERR_1,retList);
}
/**
* 成员关联关系接口
* @param staffId
* @return
*/
@RequestMapping("del-clerk-relation")
public HaobanResponse delStaffClerkList(String staffId,String clerkId){
LoginDTO login = (LoginDTO) AuthRequestUtil.getLoginUser();
StaffDTO staffDTO = login.getStaffDTO();
if (staffDTO==null) {
logger.info("登录异常");
return resultResponse(HaoBanErrCode.ERR_4);
}
StaffDTO staff = staffApiService.selectById(staffId);
if(staff == null) {
return resultResponse(HaoBanErrCode.ERR_10007);
}
boolean b = staffClerkRelationApiService.unbindByStaffAndClerkId(staffDTO.getStaffId(), clerkId);
return resultResponse(HaoBanErrCode.ERR_1,b);
}
//获取门店详情
public boolean isEnterpriseOver(String eid) {
com.gic.enterprise.api.dto.EnterpriseDTO enterprise = enterpriseService.getEnterpriseByEid(eid);
if (enterprise == null) {
return true;
}
if (enterprise.getExpireTime() == null) {
if (enterprise.getEnabledState() == null) {
return false;
} else if (enterprise.getEnabledState() == 1) {
return false;
} else {
return true;
}
} else if (enterprise.getExpireTime().getTime() > System.currentTimeMillis() && enterprise.getEnabledState() == 1) {
return false;
}
return true;
}
/**
* 成员关联关系搜索接口
* @param search
* @return
*/
@RequestMapping("search-clerk-relation")
public HaobanResponse staffClerkSearch(String search){
LoginDTO login = (LoginDTO) AuthRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
if (null == wxEnterpriseId) {
return resultResponse(HaoBanErrCode.ERR_4);
}
List<EnterpriseDetailDTO> list = wxEnterpriseRelatedApiService.listEnterpriseByWxEnterpriseId(wxEnterpriseId);
if (CollectionUtil.isEmpty(list)) {
return resultResponse(HaoBanErrCode.ERR_10010);
}
List<String> enterpriseIds = list.stream().filter(dto->{
boolean over = isEnterpriseOver(dto.getEnterpriseId());
return !over;
}).map(EnterpriseDetailDTO::getEnterpriseId).collect(Collectors.toList());
List<String> storeIds = wxEnterpriseRelatedApiService.listStoreIdByWxEnterpriseId(wxEnterpriseId);
if (CollectionUtils.isEmpty(storeIds)) {
logger.info("没有权限门店");
return resultResponse(HaoBanErrCode.ERR_1);
}
List<ClerkDTO> clerkDTOList = clerkNewService.listClerkByEnterpriseIdAndSearch(enterpriseIds, storeIds, search);
List<ClerkInfoVo> retList = EntityUtil.changeEntityListByJSON(ClerkInfoVo.class, clerkDTOList);
if (CollectionUtils.isNotEmpty(retList)) {
List<String> clerkIds = retList.stream().map(ClerkInfoVo::getClerkId).collect(Collectors.toList());
List<StaffClerkRelationDTO> dtos = staffClerkRelationApiService.listByClerkIds(clerkIds);
if (CollectionUtils.isNotEmpty(dtos)) {
Map<String, StaffClerkRelationDTO> hasRelationClerkIds = dtos.stream().collect(Collectors.toMap(StaffClerkRelationDTO::getClerkId, mid -> mid));
retList.forEach(clerkInfoVo -> {
if (hasRelationClerkIds.containsKey(clerkInfoVo.getClerkId())) {
clerkInfoVo.setRelationStatus(1);
StaffDTO staffDTO = staffApiService.selectById(hasRelationClerkIds.get(clerkInfoVo.getClerkId()).getStaffId());
if (staffDTO !=null) {
clerkInfoVo.setStaffName(staffDTO.getStaffName());
clerkInfoVo.setStaffId(staffDTO.getStaffId());
}
}
StoreDTO store = storeService.getStore(clerkInfoVo.getStoreId());
if (null != store) {
clerkInfoVo.setStoreName(store.getStoreName());
}
});
}
}
return resultResponse(HaoBanErrCode.ERR_1,retList);
//todo 还没好
}
/**
* 新建关联
* @param staffId
* @return
*/
@RequestMapping("add-clerk-relation")
public HaobanResponse staffClerkSearch(String staffId,String clerkId){
LoginDTO login = (LoginDTO) AuthRequestUtil.getLoginUser();
StaffDTO loginStaffDTO = login.getStaffDTO();
if (null == loginStaffDTO) {
return resultResponse(HaoBanErrCode.ERR_4);
}
if (StringUtils.isAnyBlank(staffId,clerkId)) {
return resultResponse(HaoBanErrCode.ERR_2);
}
StaffDTO staffDTO = staffApiService.selectById(staffId);
if (null == staffDTO) {
return resultResponse(HaoBanErrCode.ERR_10007);
}
ClerkDTO clerkDTO = clerkService.getClerkByClerkId(clerkId);
if (null == clerkDTO) {
return resultResponse(HaoBanErrCode.ERR_5);
}
StaffClerkRelationDTO relationDTO = new StaffClerkRelationDTO();
relationDTO.setClerkCode(clerkDTO.getClerkCode());
relationDTO.setClerkId(clerkId);
relationDTO.setStaffId(staffId);
relationDTO.setEnterpriseId(clerkDTO.getEnterpriseId());
relationDTO.setStoreId(clerkDTO.getStoreId());
relationDTO.setWxEnterpriseId(staffDTO.getWxEnterpriseId());
relationDTO.setWxUserId(staffDTO.getWxUserId());
ServiceResponse response = staffClerkRelationApiService.bindStaffClerk(relationDTO,loginStaffDTO.getStaffId(),ChannelCodeEnum.ADMIN_BIND.getCode());
logger.info("返回信息:{}", JSONObject.toJSONString(response));
if (response.getCode()==1) {
return resultResponse(HaoBanErrCode.ERR_1);
}else{
HaoBanErrCode errDefine = HaoBanErrCode.ERR_DEFINE;
errDefine.setMsg(response.getMessage());
return resultResponse(errDefine);
}
}
/**
* 绑定日志
* @return
*/
@RequestMapping("staff-clerk-bind-log")
public HaobanResponse bindLogs(String search,String enterpriseId,@RequestParam(defaultValue = "-1") Integer optType,BasePageInfo qo){
LoginDTO login = (LoginDTO) AuthRequestUtil.getLoginUser();
StaffDTO loginStaffDTO = login.getStaffDTO();
if (null == loginStaffDTO) {
return resultResponse(HaoBanErrCode.ERR_4);
}
Page<StaffClerkBindLogDetailDTO> page = staffClerkRelationApiService.pageStaffClerkBindLog(loginStaffDTO.getWxEnterpriseId(), search, enterpriseId, optType, qo);
return resultResponse(HaoBanErrCode.ERR_1,page);
}
/**
*
* @Description 会员导出
* @return 返回值类型: <pre>
* @author 作者: qwm
* @date 时间: 2020年12月18日 上午11:11:35 <pre>
*/
@RequestMapping("staff-export")
public HaobanResponse staffExport(HttpServletResponse response, HttpServletRequest request){
BasePageInfo pageInfo = new BasePageInfo();
int pageSize = 1000;
int pageNum = 1;
pageInfo.setPageNum(pageNum);
pageInfo.setPageSize(pageSize);
String departmentId=request.getParameter("departmentId");
List<String> departmentIdSet = new ArrayList<>();
departmentIdSet.add(departmentId);
LoginDTO login = (LoginDTO) AuthRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
WxEnterpriseDTO enterprise = wxEnterpriseApiService.getOne(wxEnterpriseId);
String wxEnterpriseName = "";
if(enterprise != null){
wxEnterpriseName = enterprise.getCorpName();
}
List<DepartmentDTO> relationList = departmentApiService.listSonByDepartmentIds(departmentIdSet,wxEnterpriseId);
Map<String,DepartmentDTO> departmentMap = relationList.stream().collect(Collectors.toMap(DepartmentDTO::getDepartmentId, s -> s));
List<String> departmentIds = relationList.stream().map(DepartmentDTO::getDepartmentId).collect(Collectors.toList());
Page<StaffDTO> page = staffApiService.pageStaff(departmentIds,null,null,pageInfo);
List<StaffDTO> list = page.getResult();
logger.info("pages={},totalPage={}",page.getCurrentPage(),page.getTotalPage());
while(page.getCurrentPage() < page.getTotalPage()){
pageNum ++ ;
pageInfo.setPageNum(pageNum);
page = staffApiService.pageStaff(departmentIds,null,null,pageInfo);
List<StaffDTO> sonList = page.getResult();
if(CollectionUtils.isNotEmpty(sonList)){
list.addAll(sonList);
}
logger.info("sonList={}",sonList.size());
}
List<StaffExportVO> voList = new ArrayList<>();
for (StaffDTO staffDTO : list) {
StaffExportVO vo = new StaffExportVO();
vo.setStaffId(staffDTO.getStaffId());
vo.setPhoneNumber(staffDTO.getPhoneNumber());
vo.setStaffName(staffDTO.getStaffName());
vo.setPosition(staffDTO.getPostion());
vo.setDepartmentName(departmentMap.get(staffDTO.getDepartmentIds()) == null?null:departmentMap.get(staffDTO.getDepartmentIds()).getDepartmentName());
String active = "是";
if(staffDTO.getActiveFlag() == null || staffDTO.getActiveFlag() == 0){
active = "否";
}
vo.setActiveFlag(active);
voList.add(vo);
}
//拼接导购信息
mergeClerkInfo(voList, wxEnterpriseId);
String fileName = wxEnterpriseName + "通讯录" + DateUtil.dateToStr(new Date(), DateUtil.FORMAT_DATE_8);
List<String> fileList = new ArrayList<>();
List<String> titleList = new ArrayList<>();
titleList.add("姓名");
titleList.add("职务");
titleList.add("部门");
titleList.add("手机号");
titleList.add("使用状态");
titleList.add("关联导购");
fileList.add("staffName");
fileList.add("position");
fileList.add("departmentName");
fileList.add("phoneNumber");
fileList.add("activeFlag");
fileList.add("clerkName");
try {
ExcelUtils.csv(response, request, fileName, voList, fileList, titleList);
} catch (Exception e) {
e.printStackTrace();
logger.info("导出失败");
}
}
@RequestMapping("staff-del")
public HaobanResponse staffDel(String staffDepartmentStaffRelatedId) {
StaffDepartmentRelatedDTO related = staffDepartmentRelatedApiService.getByStaffDepartmentRelatedId(staffDepartmentStaffRelatedId);
if (related == null) {
return resultResponse(HaoBanErrCode.ERR_8);
}
DepartmentDTO department = departmentApiService.selectById(related.getDepartmentId());
if (department.getTempFlag() != null && department.getTempFlag() == 1) {
return resultResponse(HaoBanErrCode.ERR_10014);
}
staffApiService.del(staffDepartmentStaffRelatedId);
return resultResponse(HaoBanErrCode.ERR_1);
}
@RequestMapping("staff-batch-del")
public HaobanResponse staffBatchDel(String staffDepartmentRelatedIds) {
if (StringUtils.isBlank(staffDepartmentRelatedIds)) {
return resultResponse(HaoBanErrCode.ERR_2);
}
String[] staffArr = staffDepartmentRelatedIds.split(",");
int size = staffArr.length;
for (String string : staffArr) {
StaffDepartmentRelatedDTO related = staffDepartmentRelatedApiService.getByStaffDepartmentRelatedId(string);
if (related == null) {
continue;
}
DepartmentDTO department = departmentApiService.selectById(related.getDepartmentId());
if (department.getTempFlag() != null && department.getTempFlag() == 1) {
if (size == 1) {
return resultResponse(HaoBanErrCode.ERR_10014);
}
continue;
}
staffApiService.del(string);
}
return resultResponse(HaoBanErrCode.ERR_1);
}
@RequestMapping("staff-edit")
public HaobanResponse staffEdit(StaffDTO staffDTO, String departmentIds) {
String staffId = staffDTO.getStaffId();
StaffDTO staff = staffApiService.selectById(staffId);
if (staff == null) {
return resultResponse(HaoBanErrCode.ERR_10006);
}
String phoneNumber = staffDTO.getPhoneNumber();
String nationcode = staffDTO.getNationCode();
String wxEnterpriseId = staff.getWxEnterpriseId();
StaffDTO old = staffApiService.selectByNationcodeAndPhoneNumber(wxEnterpriseId, nationcode, phoneNumber);
if (old != null && !old.getStaffId().equals(staffId)) {
return resultResponse(HaoBanErrCode.ERR_10005);
}
staffApiService.staffEdit(staffDTO, departmentIds);
return resultResponse(HaoBanErrCode.ERR_1);
}
@RequestMapping("staff-invite")
public HaobanResponse staffInvite(String staffIds) {
if (StringUtils.isBlank(staffIds)) {
return resultResponse(HaoBanErrCode.ERR_2);
}
String[] staffArr = staffIds.split(",");
List<String> userArr = new ArrayList<>();
String wxEnterpriseId = "";
for (String staffId : staffArr) {
StaffDTO staff = staffApiService.selectById(staffId);
if (staff != null) {
String userId = staff.getWxUserId();
wxEnterpriseId = staff.getWxEnterpriseId();
userArr.add(userId);
}
}
WxEnterpriseDTO enterpriseDTO = wxEnterpriseApiService.getOne(wxEnterpriseId);
WxApplicationDTO application = wxApplicationApiService.selectByWxEnterpriseIdAndApplicationType(wxEnterpriseId, 1);
if (enterpriseDTO != null) {
if (application != null) {
qywxUserApiService.inviteUser(enterpriseDTO.getCorpid(), application.getSiteId(), userArr);
}
}
return resultResponse(HaoBanErrCode.ERR_1);
}
@RequestMapping("staff-batch-edit-department")
public HaobanResponse staffBatchEditDepartment(String params) {
List<StaffEditJsonQO> list = JSON.parseArray(params, StaffEditJsonQO.class);
for (StaffEditJsonQO staffEditJsonQO : list) {
String staffDepartmentRelatedId = staffEditJsonQO.getStaffDepartmentRelatedId();
String departmentIds = staffEditJsonQO.getCurrDepartmentIds();
StaffDepartmentRelatedDTO related = staffDepartmentRelatedApiService.getByStaffDepartmentRelatedId(staffDepartmentRelatedId);
if (related != null) {
StaffDTO staff = staffApiService.selectById(related.getStaffId());
if (staff != null) {
staffApiService.staffEdit(staff, departmentIds);
}
}
}
return resultResponse(HaoBanErrCode.ERR_1);
}
@RequestMapping("get-clerk-info")
public HaobanResponse getClerkInfo(String clerkId) {
StaffVO staffVO = new StaffVO();
ClerkDTO clerk = clerkService.getClerkByClerkId(clerkId);
if (clerk != null) {
String storeId = clerk.getStoreId();
StoreDTO storeDTO = storeService.getStore(storeId);
staffVO.setStaffName(clerk.getClerkName());
staffVO.setNationCode(clerk.getNationcode());
staffVO.setPhoneNumber(clerk.getPhoneNumber());
staffVO.setPosition(clerk.getPositionName());
staffVO.setHeadImg(clerk.getHeadImgUrl());
staffVO.setDepartmentName(storeDTO == null ? "" : storeDTO.getStoreName());
}
return resultResponse(HaoBanErrCode.ERR_1, staffVO);
}
@RequestMapping("get-staff-info")
public HaobanResponse getStaffInfo(String staffId) {
StaffVO staffVO = new StaffVO();
StaffDTO staff = staffApiService.selectById(staffId);
if (staff != null) {
List<StaffDepartmentRelatedDTO> list = staffDepartmentRelatedApiService.listByStaffId(staffId);
staffVO.setStaffName(staff.getStaffName());
staffVO.setNationCode(staff.getNationCode());
staffVO.setPhoneNumber(staff.getPhoneNumber());
staffVO.setPosition(staff.getPostion());
staffVO.setHeadImg(staff.getHeadImg());
if (CollectionUtil.isNotEmpty(list)) {
String departmentId = list.get(0).getDepartmentId();
DepartmentDTO departmentDTO = departmentApiService.selectById(departmentId);
if (departmentDTO != null) {
staffVO.setDepartmentName(departmentDTO.getDepartmentName());
}
}
}
return resultResponse(HaoBanErrCode.ERR_1, staffVO);
}
/**
* 成员关联关系接口
*
* @param staffId
* @return
*/
@RequestMapping("staff-clerk-relation")
public HaobanResponse staffClerkList(String staffId) {
StaffDTO staff = staffApiService.selectById(staffId);
if (staff == null) {
return resultResponse(HaoBanErrCode.ERR_10007);
}
List<StaffClerkInfoDTO> retList = staffClerkRelationApiService.listBindDetailByStaffId(staffId);
if (CollectionUtils.isEmpty(retList)) {
return resultResponse(HaoBanErrCode.ERR_1);
}
ClerkMainStoreRelatedDTO mainStoreRelatedDTO = clerkMainStoreRelatedApiService.getWxEnterpriseIdAndStaffId(staff.getWxEnterpriseId(), staffId);
if (null != mainStoreRelatedDTO) {
retList.forEach(dto -> {
if (dto.getStoreId().equals(mainStoreRelatedDTO.getStoreId())) {
dto.setMainStoreFlag(1);
} else {
dto.setMainStoreFlag(0);
}
});
}
return resultResponse(HaoBanErrCode.ERR_1, retList);
}
/**
* 成员关联关系接口
*
* @param staffId
* @return
*/
@RequestMapping("del-clerk-relation")
public HaobanResponse delStaffClerkList(String staffId, String clerkId) {
LoginDTO login = (LoginDTO) AuthRequestUtil.getLoginUser();
StaffDTO staffDTO = login.getStaffDTO();
if (staffDTO == null) {
logger.info("登录异常");
return resultResponse(HaoBanErrCode.ERR_4);
}
StaffDTO staff = staffApiService.selectById(staffId);
if (staff == null) {
return resultResponse(HaoBanErrCode.ERR_10007);
}
boolean b = staffClerkRelationApiService.unbindByStaffAndClerkId(staffDTO.getStaffId(), clerkId);
return resultResponse(HaoBanErrCode.ERR_1, b);
}
//获取门店详情
public boolean isEnterpriseOver(String eid) {
com.gic.enterprise.api.dto.EnterpriseDTO enterprise = enterpriseService.getEnterpriseByEid(eid);
if (enterprise == null) {
return true;
}
if (enterprise.getExpireTime() == null) {
if (enterprise.getEnabledState() == null) {
return false;
} else return enterprise.getEnabledState() != 1;
} else
return enterprise.getExpireTime().getTime() <= System.currentTimeMillis() || enterprise.getEnabledState() != 1;
}
/**
* 成员关联关系搜索接口
*
* @param search
* @return
*/
@RequestMapping("search-clerk-relation")
public HaobanResponse staffClerkSearch(String search) {
LoginDTO login = (LoginDTO) AuthRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
if (null == wxEnterpriseId) {
return resultResponse(HaoBanErrCode.ERR_4);
}
List<EnterpriseDetailDTO> list = wxEnterpriseRelatedApiService.listEnterpriseByWxEnterpriseId(wxEnterpriseId);
if (CollectionUtil.isEmpty(list)) {
return resultResponse(HaoBanErrCode.ERR_10010);
}
List<String> enterpriseIds = list.stream().filter(dto -> {
boolean over = isEnterpriseOver(dto.getEnterpriseId());
return !over;
}).map(EnterpriseDetailDTO::getEnterpriseId).collect(Collectors.toList());
List<String> storeIds = wxEnterpriseRelatedApiService.listStoreIdByWxEnterpriseId(wxEnterpriseId);
if (CollectionUtils.isEmpty(storeIds)) {
logger.info("没有权限门店");
return resultResponse(HaoBanErrCode.ERR_1);
}
List<ClerkDTO> clerkDTOList = clerkNewService.listClerkByEnterpriseIdAndSearch(enterpriseIds, storeIds, search);
List<ClerkInfoVo> retList = EntityUtil.changeEntityListByJSON(ClerkInfoVo.class, clerkDTOList);
if (CollectionUtils.isNotEmpty(retList)) {
List<String> clerkIds = retList.stream().map(ClerkInfoVo::getClerkId).collect(Collectors.toList());
List<StaffClerkRelationDTO> dtos = staffClerkRelationApiService.listByClerkIds(clerkIds);
if (CollectionUtils.isNotEmpty(dtos)) {
Map<String, StaffClerkRelationDTO> hasRelationClerkIds = dtos.stream().collect(Collectors.toMap(StaffClerkRelationDTO::getClerkId, mid -> mid));
retList.forEach(clerkInfoVo -> {
if (hasRelationClerkIds.containsKey(clerkInfoVo.getClerkId())) {
clerkInfoVo.setRelationStatus(1);
StaffDTO staffDTO = staffApiService.selectById(hasRelationClerkIds.get(clerkInfoVo.getClerkId()).getStaffId());
if (staffDTO != null) {
clerkInfoVo.setStaffName(staffDTO.getStaffName());
clerkInfoVo.setStaffId(staffDTO.getStaffId());
}
}
StoreDTO store = storeService.getStore(clerkInfoVo.getStoreId());
if (null != store) {
clerkInfoVo.setStoreName(store.getStoreName());
}
});
}
}
return resultResponse(HaoBanErrCode.ERR_1, retList);
}
/**
* 新建关联
*
* @param staffId
* @return
*/
@RequestMapping("add-clerk-relation")
public HaobanResponse staffClerkSearch(String staffId, String clerkId) {
LoginDTO login = (LoginDTO) AuthRequestUtil.getLoginUser();
StaffDTO loginStaffDTO = login.getStaffDTO();
if (null == loginStaffDTO) {
return resultResponse(HaoBanErrCode.ERR_4);
}
if (StringUtils.isAnyBlank(staffId, clerkId)) {
return resultResponse(HaoBanErrCode.ERR_2);
}
StaffDTO staffDTO = staffApiService.selectById(staffId);
if (null == staffDTO) {
return resultResponse(HaoBanErrCode.ERR_10007);
}
ClerkDTO clerkDTO = clerkService.getClerkByClerkId(clerkId);
if (null == clerkDTO) {
return resultResponse(HaoBanErrCode.ERR_5);
}
StaffClerkRelationDTO relationDTO = new StaffClerkRelationDTO();
relationDTO.setClerkCode(clerkDTO.getClerkCode());
relationDTO.setClerkId(clerkId);
relationDTO.setStaffId(staffId);
relationDTO.setEnterpriseId(clerkDTO.getEnterpriseId());
relationDTO.setStoreId(clerkDTO.getStoreId());
relationDTO.setWxEnterpriseId(staffDTO.getWxEnterpriseId());
relationDTO.setWxUserId(staffDTO.getWxUserId());
ServiceResponse response = staffClerkRelationApiService.bindStaffClerk(relationDTO, loginStaffDTO.getStaffId(), ChannelCodeEnum.ADMIN_BIND.getCode());
logger.info("返回信息:{}", JSONObject.toJSONString(response));
if (response.getCode() == 1) {
return resultResponse(HaoBanErrCode.ERR_1);
} else {
HaoBanErrCode errDefine = HaoBanErrCode.ERR_DEFINE;
errDefine.setMsg(response.getMessage());
return resultResponse(errDefine);
}
}
/**
* 绑定日志
*
* @return
*/
@RequestMapping("staff-clerk-bind-log")
public HaobanResponse bindLogs(String search, String enterpriseId, @RequestParam(defaultValue = "-1") Integer optType, BasePageInfo qo) {
LoginDTO login = (LoginDTO) AuthRequestUtil.getLoginUser();
StaffDTO loginStaffDTO = login.getStaffDTO();
if (null == loginStaffDTO) {
return resultResponse(HaoBanErrCode.ERR_4);
}
Page<StaffClerkBindLogDetailDTO> page = staffClerkRelationApiService.pageStaffClerkBindLog(loginStaffDTO.getWxEnterpriseId(), search, enterpriseId, optType, qo);
return resultResponse(HaoBanErrCode.ERR_1, page);
}
/**
* @return 返回值类型: <pre>
* @author 作者: qwm
* @date 时间: 2020年12月18日 上午11:11:35 <pre>
* @Description 会员导出
*/
@RequestMapping("staff-export")
public HaobanResponse staffExport(HttpServletRequest request, HttpServletResponse response, String departmentId, Integer activeFlag, String keyWord, BasePageInfo pageInfo) {
pageInfo.setPageSize(Integer.MAX_VALUE);
List<String> departmentIdSet = new ArrayList<>();
departmentIdSet.add(departmentId);
LoginDTO login = (LoginDTO) AuthRequestUtil.getLoginUser();
String wxEnterpriseId = login.getWxEnterpriseId();
List<DepartmentDTO> relationList = departmentApiService.listSonByDepartmentIds(departmentIdSet, wxEnterpriseId);
Map<String, DepartmentDTO> departmentMap = relationList.stream().collect(Collectors.toMap(DepartmentDTO::getDepartmentId, s -> s));
List<String> departmentIds = relationList.stream().map(DepartmentDTO::getDepartmentId).collect(Collectors.toList());
Page<StaffDTO> page = staffApiService.pageStaff(departmentIds, activeFlag, keyWord, pageInfo);
List<StaffDTO> list = page.getResult();
List<StaffExportVO> voList = new ArrayList<>();
for (StaffDTO staffDTO : list) {
StaffExportVO vo = new StaffExportVO();
vo.setStaffId(staffDTO.getStaffId());
vo.setPhoneNumber(staffDTO.getPhoneNumber());
vo.setStaffName(staffDTO.getStaffName());
vo.setPosition(staffDTO.getPostion());
vo.setDepartmentName(departmentMap.get(staffDTO.getDepartmentIds()) == null ? null : departmentMap.get(staffDTO.getDepartmentIds()).getDepartmentName());
vo.setActiveFlag((staffDTO.getActiveFlag() == null || staffDTO.getActiveFlag() == 0) ? "否" : "是");
voList.add(vo);
}
//拼接导购信息
WxEnterpriseDTO enterprise = wxEnterpriseApiService.getOne(wxEnterpriseId);
String wxEnterpriseName = "";
if (enterprise != null) {
wxEnterpriseName = enterprise.getCorpName();
}
mergeClerkInfo(voList, wxEnterpriseId);
String fileName = wxEnterpriseName + "通讯录" + DateUtil.dateToStr(new Date(), DateUtil.FORMAT_DATE_8);
List<String> titleList = Arrays.asList("姓名", "职务", "部门", "手机号", "使用状态", "关联导购");
List<String> fileList = Arrays.asList("staffName", "position", "departmentName", "phoneNumber", "activeFlag", "clerkName");
try {
ExcelUtils.xls(response, request, fileName, voList, fileList, titleList);
} catch (Exception e) {
e.printStackTrace();
logger.info("导出失败");
}
return null;
}
private void mergeClerkInfo(List<StaffExportVO> list,String wxEnterpriseId){
BasePageInfo pageInfoRelation = new BasePageInfo();
int pageSizeRelation = 1000;
int pageNumRelation = 1;
pageInfoRelation.setPageNum(pageNumRelation);
pageInfoRelation.setPageSize(pageSizeRelation);
Page<StaffClerkRelationDTO> bindPage = staffClerkRelationApiService.pageByWxEnterpriseId(wxEnterpriseId,pageInfoRelation);
List<StaffClerkRelationDTO> bindList = bindPage.getResult();
Set<String> clerkIdList = bindList.stream().map(StaffClerkRelationDTO::getClerkId).collect(Collectors.toSet());
List<ClerkDTO> clerkList = clerkService.getClerkByClerkIds(clerkIdList);
while (bindPage.getCurrentPage() < bindPage.getTotalPage()) {
pageNumRelation ++ ;
pageInfoRelation.setPageNum(pageNumRelation);
bindPage = staffClerkRelationApiService.pageByWxEnterpriseId(wxEnterpriseId,pageInfoRelation);
List<StaffClerkRelationDTO> sonList = bindPage.getResult();
Set<String> clerkSonIdList = sonList.stream().map(StaffClerkRelationDTO::getClerkId).collect(Collectors.toSet());
List<ClerkDTO> sonClerkList = clerkService.getClerkByClerkIds(clerkSonIdList);
if(CollectionUtils.isNotEmpty(sonClerkList)){
clerkList.addAll(sonClerkList);
}
if(CollectionUtils.isNotEmpty(sonList)){
bindList.addAll(sonList);
}
}
Map<String,List<StaffClerkRelationDTO>> bindMap = bindList.stream().collect(Collectors.groupingBy(StaffClerkRelationDTO::getStaffId));
Map<String,ClerkDTO> clerkMap = clerkList.stream().collect(Collectors.toMap(ClerkDTO::getClerkId, s -> s, (v1, v2) -> v2));
for (StaffExportVO staffDTO : list) {
List<StaffClerkRelationDTO> relationList = bindMap.get(staffDTO.getStaffId());
if(CollectionUtils.isNotEmpty(relationList)){
String clerkName = "";
for (StaffClerkRelationDTO staffClerkRelationDTO : relationList) {
ClerkDTO clerk = clerkMap.get(staffClerkRelationDTO.getClerkId());
if(clerk != null){
clerkName += clerk.getClerkName() + ",";
}
}
if(StringUtils.isNoneBlank(clerkName)){
clerkName = clerkName.substring(0,clerkName.length() - 1);
}
staffDTO.setClerkName(clerkName);
}
}
}
}
private void mergeClerkInfo(List<StaffExportVO> list, String wxEnterpriseId) {
BasePageInfo pageInfoRelation = new BasePageInfo();
int pageSizeRelation = 1000;
int pageNumRelation = 1;
pageInfoRelation.setPageNum(pageNumRelation);
pageInfoRelation.setPageSize(pageSizeRelation);
Page<StaffClerkRelationDTO> bindPage = staffClerkRelationApiService.pageByWxEnterpriseId(wxEnterpriseId, pageInfoRelation);
List<StaffClerkRelationDTO> bindList = bindPage.getResult();
Set<String> clerkIdList = bindList.stream().map(StaffClerkRelationDTO::getClerkId).collect(Collectors.toSet());
List<ClerkDTO> clerkList = clerkService.getClerkByClerkIds(clerkIdList);
while (bindPage.getCurrentPage() < bindPage.getTotalPage()) {
pageNumRelation++;
pageInfoRelation.setPageNum(pageNumRelation);
bindPage = staffClerkRelationApiService.pageByWxEnterpriseId(wxEnterpriseId, pageInfoRelation);
List<StaffClerkRelationDTO> sonList = bindPage.getResult();
Set<String> clerkSonIdList = sonList.stream().map(StaffClerkRelationDTO::getClerkId).collect(Collectors.toSet());
List<ClerkDTO> sonClerkList = clerkService.getClerkByClerkIds(clerkSonIdList);
if (CollectionUtils.isNotEmpty(sonClerkList)) {
clerkList.addAll(sonClerkList);
}
if (CollectionUtils.isNotEmpty(sonList)) {
bindList.addAll(sonList);
}
}
Map<String, List<StaffClerkRelationDTO>> bindMap = bindList.stream().collect(Collectors.groupingBy(StaffClerkRelationDTO::getStaffId));
Map<String, ClerkDTO> clerkMap = clerkList.stream().collect(Collectors.toMap(ClerkDTO::getClerkId, s -> s, (v1, v2) -> v2));
for (StaffExportVO staffDTO : list) {
List<StaffClerkRelationDTO> relationList = bindMap.get(staffDTO.getStaffId());
if (CollectionUtils.isNotEmpty(relationList)) {
StringBuffer clerkName = new StringBuffer();
for (StaffClerkRelationDTO staffClerkRelationDTO : relationList) {
ClerkDTO clerk = clerkMap.get(staffClerkRelationDTO.getClerkId());
if (clerk != null) {
clerkName.append(clerk.getClerkName()).append(",");
}
}
if (StringUtils.isNoneBlank(clerkName.toString())) {
clerkName = new StringBuffer(clerkName.substring(0, clerkName.length() - 1));
}
staffDTO.setClerkName(clerkName.toString());
}
}
}
}
......@@ -9,27 +9,30 @@
http://www.springframework.org/schema/context/spring-context.xsd
http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<context:component-scan base-package="com.gic.haoban" />
<context:component-scan base-package="com.gic.haoban"/>
<!-- 应用名称 -->
<dubbo:application name="haoban-manage3-web"/>
<dubbo:application name="haoban-manage3-web"/>
<dubbo:protocol name="dubbo" port="30009"/>
<!-- 使用zookeeper注册中心暴露服务地址 -->
<!-- <dubbo:registry address="zookeeper://192.168.1.118:2181" protocol="dubbo" id="localAdd"/> -->
<!--<dubbo:registry address="zookeeper://115.159.182.172:2199" protocol="dubbo" id="remoteAdd"/>-->
<!--<dubbo:registry address="zookeeper://localhost:2181|zookeeper://115.159.182.172:2199" protocol="dubbo"/>-->
<dubbo:protocol name="dubbo" port="30009"/>
<!-- 使用zookeeper注册中心暴露服务地址 -->
<!-- <dubbo:registry address="zookeeper://192.168.1.118:2181" protocol="dubbo" id="localAdd"/> -->
<!--<dubbo:registry address="zookeeper://115.159.182.172:2199" protocol="dubbo" id="remoteAdd"/>-->
<!--<dubbo:registry address="zookeeper://localhost:2181|zookeeper://115.159.182.172:2199" protocol="dubbo"/>-->
<dubbo:reference interface="com.gic.haoban.manage.api.service.StaffApiService" id="staffApiService"/>
<dubbo:reference interface="com.gic.haoban.manage.api.service.StaffClerkRelationApiService" id="staffClerkRelationApiService"/>
<dubbo:reference interface="com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService" id="wxEnterpriseRelatedApiService" />
<dubbo:reference interface="com.gic.haoban.manage.api.service.StaffApiService" id="staffApiService"
timeout="15000"/>
<dubbo:reference interface="com.gic.haoban.manage.api.service.StaffClerkRelationApiService"
id="staffClerkRelationApiService"/>
<dubbo:reference interface="com.gic.haoban.manage.api.service.WxEnterpriseRelatedApiService"
id="wxEnterpriseRelatedApiService"/>
<dubbo:reference interface="com.gic.haoban.manage.api.service.ApplicationApiService" id="applicationApiService"/>
<dubbo:reference interface="com.gic.haoban.manage.api.service.WxEnterpriseApiService" id="wxEnterpriseApiService"/>
<dubbo:reference interface="com.gic.haoban.manage.api.service.ClerkMainStoreRelatedApiService"
id="clerkMainStoreRelatedApiService"/>
<dubbo:reference interface="com.gic.haoban.manage.api.service.ClerkMainStoreRelatedApiService"
id="clerkMainStoreRelatedApiService"/>
<dubbo:reference interface="com.gic.enterprise.api.service.EnterpriseService" id="enterpriseService"/>
<dubbo:reference interface="com.gic.enterprise.api.service.StoreService" id="storeService"/>
<dubbo:reference interface="com.gic.enterprise.api.service.DepartmentService" id="departmentService"/>
<dubbo:reference interface="com.gic.haoban.manage.api.service.DepartmentApiService" id="departmentApiService">
......
......@@ -6,6 +6,7 @@
<groupId>com.gic</groupId>
<artifactId>gic-pom-base</artifactId>
<version>3.0-SNAPSHOT</version>
<relativePath/>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -112,9 +112,11 @@ public class AuditController extends WebBaseController {
List<StaffClerkBindLogDetailDTO> list = page.getResult();
List<StaffClerkBindLogDetailVO> voList = new ArrayList<StaffClerkBindLogDetailVO>();
for (StaffClerkBindLogDetailDTO staffClerkBindLogDetailDTO : list) {
StaffClerkBindLogDetailVO vo = EntityUtil.changeEntityByJSON(StaffClerkBindLogDetailVO.class, staffClerkBindLogDetailDTO);
vo.setUnbindReason(ChannelCodeEnum.getNameByCode(vo.getChannelCode()));
voList.add(vo);
if (staffClerkBindLogDetailDTO.getChannelCode() != ChannelCodeEnum.AUDIT_BIND.getCode()) {
StaffClerkBindLogDetailVO vo = EntityUtil.changeEntityByJSON(StaffClerkBindLogDetailVO.class, staffClerkBindLogDetailDTO);
vo.setUnbindReason(ChannelCodeEnum.getNameByCode(vo.getChannelCode()));
voList.add(vo);
}
}
Page<StaffClerkBindLogDetailVO> pageVO = new Page<>();
pageVO.setCurrentPage(page.getCurrentPage());
......
......@@ -225,7 +225,11 @@ public class ClerkController extends WebBaseController{
// 查询操作配置
OperationSettingDTO dto = operationSettingApiService.getByWxEnterpriseId(wxEnterpriseId);
if (Objects.isNull(dto)) {
return resultResponse(HaoBanErrCode.ERR_8);
OperationSettingVO vo = new OperationSettingVO();
vo.setWxEnterpriseId(wxEnterpriseId);
// 为空情况初始默认不生效
vo.setEffectFlag(0);
return resultResponse(HaoBanErrCode.ERR_1, vo);
}
OperationSettingVO vo = EntityUtil.changeEntity(OperationSettingVO.class, dto);
// 是否开启导购编辑,如果不开启,默认无效
......@@ -249,12 +253,20 @@ public class ClerkController extends WebBaseController{
String nationcode = staffDTO.getNationCode();
String postion = staffDTO.getPostion();
Integer sex = staffDTO.getSex();
if(StringUtils.isAnyBlank(staffName,phoneNumber,commitName)) {
if(StringUtils.isAnyBlank(staffName, commitName)) {
return resultResponse(HaoBanErrCode.ERR_10004);
}
if(!GooglePhoneNumberUtil.checkPhoneNumber(phoneNumber, nationcode)){
if (StringUtils.isEmpty(clerkCode)) {
return resultResponse(HaoBanErrCode.ERR_111116);
}
if(StringUtils.isNotEmpty(phoneNumber) &&
!GooglePhoneNumberUtil.checkPhoneNumber(phoneNumber, nationcode)){
return resultResponse(HaoBanErrCode.ERR_10012);
}
// 导购code校验-字母和数字
if (!clerkCode.matches("[a-zA-Z0-9]+")) {
return resultResponse(HaoBanErrCode.ERR_10023);
}
if(version == null){
StaffDTO staff = staffApiService.selectByNationcodeAndPhoneNumber(wxEnterpriseId,nationcode,phoneNumber);
if(staff != null) {
......@@ -278,7 +290,12 @@ public class ClerkController extends WebBaseController{
return resultResponse(HaoBanErrCode.ERR_10013);
}
AuditSettingDTO dto = auditSettingApiService.findSettingByWxEnterpriseId(wxEnterpriseId);
if(dto.getClerkChangeFlag() == 1){
// 企业绑定详情-导购编辑权限
WxEnterpriseRelationDetailDTO enterpriseBindInfo = wxEnterpriseRelatedApiService
.getEnterpriseBindInfo(wxEnterpriseId, enterpriseId);
if(dto.getAuditFlag() == 1
&& dto.getClerkChangeFlag() == 1
&& enterpriseBindInfo.getClerkEditFlag() == 1) {
AuditDTO auditDTO =auditApiService.findByBindRelatedIdAndAuditType(clerkCode, AuditType.CLERK_ADD.getCode());
if(auditDTO !=null){
logger.info("已经存在了审核记录,待审核{}",clerkCode);
......
......@@ -218,6 +218,8 @@ public enum HaoBanErrCode {
ERR_10022(10022, "已有刷新在执行中,请不要重复刷新"),
ERR_10023(10023, "code格式不正确"),
ERR_11122(11122,"手机号已存在"),
ERR_11123(11123, "请到好办端刷新企业微信好友"),
......
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