Commit 1c63a19d by 徐高华

权限

parent 51be8ac1
...@@ -38,9 +38,12 @@ import com.gic.clerk.api.service.PowerService; ...@@ -38,9 +38,12 @@ import com.gic.clerk.api.service.PowerService;
import com.gic.commons.util.DateUtil; import com.gic.commons.util.DateUtil;
import com.gic.commons.util.EntityUtil; import com.gic.commons.util.EntityUtil;
import com.gic.commons.webapi.reponse.RestResponse; import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.api.constant.EnterpriseServiceEnum;
import com.gic.enterprise.api.dto.EnterpriseDTO; import com.gic.enterprise.api.dto.EnterpriseDTO;
import com.gic.enterprise.api.dto.EnterpriseUsingPermissionDto;
import com.gic.enterprise.api.dto.StoreDTO; import com.gic.enterprise.api.dto.StoreDTO;
import com.gic.enterprise.api.dto.StoreSearchDTO; import com.gic.enterprise.api.dto.StoreSearchDTO;
import com.gic.enterprise.api.dto.enterprise.EnterpriseUsingStatusDTO;
import com.gic.enterprise.api.service.EnterpriseService; import com.gic.enterprise.api.service.EnterpriseService;
import com.gic.enterprise.api.service.EnterpriseUseForbidService; import com.gic.enterprise.api.service.EnterpriseUseForbidService;
import com.gic.enterprise.api.service.StoreService; import com.gic.enterprise.api.service.StoreService;
...@@ -96,6 +99,7 @@ import com.gic.haoban.manage.web.vo.ClerkEditInfoVO; ...@@ -96,6 +99,7 @@ import com.gic.haoban.manage.web.vo.ClerkEditInfoVO;
import com.gic.haoban.manage.web.vo.ClerkListVO; import com.gic.haoban.manage.web.vo.ClerkListVO;
import com.gic.haoban.manage.web.vo.ClerkStoreVO; import com.gic.haoban.manage.web.vo.ClerkStoreVO;
import com.gic.haoban.manage.web.vo.OperationSettingVO; import com.gic.haoban.manage.web.vo.OperationSettingVO;
import com.gic.haoban.manage.web.vo.RightVO;
import com.gic.haoban.manage.web.vo.StaffStoreVO; import com.gic.haoban.manage.web.vo.StaffStoreVO;
import com.gic.haoban.manage.web.vo.StaffVO; import com.gic.haoban.manage.web.vo.StaffVO;
import com.gic.haoban.manage.web.vo.StoreClerkVO; import com.gic.haoban.manage.web.vo.StoreClerkVO;
...@@ -155,13 +159,13 @@ public class WxStaffController extends WebBaseController { ...@@ -155,13 +159,13 @@ public class WxStaffController extends WebBaseController {
@Autowired @Autowired
private HaobanRoleApiService haobanRoleApiService; private HaobanRoleApiService haobanRoleApiService;
@Autowired @Autowired
private PowerService powerService ; private PowerService powerService;
@Autowired @Autowired
private EnterpriseUseForbidService enterpriseUseForbidService ; private EnterpriseUseForbidService enterpriseUseForbidService;
//选择成员列表 // 选择成员列表
@RequestMapping("/staff-list") @RequestMapping("/staff-list")
public HaobanResponse staffList(String storeId, Integer manageFlag, String clerkId,String wxEnterpriseId) { public HaobanResponse staffList(String storeId, Integer manageFlag, String clerkId, String wxEnterpriseId) {
List<String> storeIds = new ArrayList<>(); List<String> storeIds = new ArrayList<>();
if (manageFlag != null && manageFlag == 1) { if (manageFlag != null && manageFlag == 1) {
List<String> roleStoreIds = staffApiService.getHaoBanStoreIdsRolesByClerkId(clerkId, wxEnterpriseId); List<String> roleStoreIds = staffApiService.getHaoBanStoreIdsRolesByClerkId(clerkId, wxEnterpriseId);
...@@ -180,7 +184,8 @@ public class WxStaffController extends WebBaseController { ...@@ -180,7 +184,8 @@ public class WxStaffController extends WebBaseController {
for (StaffDTO staffDTO : resultlist) { for (StaffDTO staffDTO : resultlist) {
String enterpriseId = staffDTO.getEnterpriseId(); String enterpriseId = staffDTO.getEnterpriseId();
long memberCount = distributeApiService.getClerkMemberCount(enterpriseId, staffDTO.getClerkId(), storeId); long memberCount = distributeApiService.getClerkMemberCount(enterpriseId, staffDTO.getClerkId(), storeId);
logger.info("【获取会员数】enterpriseId={},clerkId={},storeId={},memberCount={}", enterpriseId, staffDTO.getClerkId(), storeId, memberCount); logger.info("【获取会员数】enterpriseId={},clerkId={},storeId={},memberCount={}", enterpriseId,
staffDTO.getClerkId(), storeId, memberCount);
staffDTO.setMemberCount(Convert.toInt(memberCount, 0)); staffDTO.setMemberCount(Convert.toInt(memberCount, 0));
resultList.add(EntityUtil.changeEntityNew(StaffVO.class, staffDTO)); resultList.add(EntityUtil.changeEntityNew(StaffVO.class, staffDTO));
} }
...@@ -199,7 +204,8 @@ public class WxStaffController extends WebBaseController { ...@@ -199,7 +204,8 @@ public class WxStaffController extends WebBaseController {
* @return * @return
*/ */
@RequestMapping("/store-clerks") @RequestMapping("/store-clerks")
public HaobanResponse storeClerks(BasePageInfo basePageInfo, String clerkId, String enterpriseId, String storeId, Integer manageFlag,String wxEnterpriseId) { public HaobanResponse storeClerks(BasePageInfo basePageInfo, String clerkId, String enterpriseId, String storeId,
Integer manageFlag, String wxEnterpriseId) {
List<String> storeIds = new ArrayList<>(); List<String> storeIds = new ArrayList<>();
if (manageFlag != null && manageFlag == 1) { if (manageFlag != null && manageFlag == 1) {
List<String> roleStoreIds = staffApiService.getHaoBanStoreIdsRolesByClerkId(clerkId, wxEnterpriseId); List<String> roleStoreIds = staffApiService.getHaoBanStoreIdsRolesByClerkId(clerkId, wxEnterpriseId);
...@@ -213,14 +219,17 @@ public class WxStaffController extends WebBaseController { ...@@ -213,14 +219,17 @@ public class WxStaffController extends WebBaseController {
if (storeIds.contains("-1")) { if (storeIds.contains("-1")) {
storeIds = null; storeIds = null;
} }
Page<ClerkDTO> clerkDTOPage = clerkService.pageClerkByNameOrCode(enterpriseId, null, storeIds, basePageInfo.getPageNum(), basePageInfo.getPageSize()); Page<ClerkDTO> clerkDTOPage = clerkService.pageClerkByNameOrCode(enterpriseId, null, storeIds,
basePageInfo.getPageNum(), basePageInfo.getPageSize());
List<ClerkDTO> clerkDTOS = clerkDTOPage.getResult(); List<ClerkDTO> clerkDTOS = clerkDTOPage.getResult();
if (CollectionUtils.isEmpty(clerkDTOS)) { if (CollectionUtils.isEmpty(clerkDTOS)) {
return resultResponse(HaoBanErrCode.ERR_10016); return resultResponse(HaoBanErrCode.ERR_10016);
} }
Set<String> clerkCodeList = clerkDTOS.stream().map(ClerkDTO::getClerkCode).collect(Collectors.toSet()); Set<String> clerkCodeList = clerkDTOS.stream().map(ClerkDTO::getClerkCode).collect(Collectors.toSet());
List<StaffClerkRelationDTO> bindRelationList = staffClerkRelationApiService.listBindCode(wxEnterpriseId, enterpriseId, clerkCodeList); List<StaffClerkRelationDTO> bindRelationList = staffClerkRelationApiService.listBindCode(wxEnterpriseId,
Map<String, StaffClerkRelationDTO> bindCodeMap = bindRelationList.stream().collect(Collectors.toMap(StaffClerkRelationDTO::getClerkCode, s -> s)); enterpriseId, clerkCodeList);
Map<String, StaffClerkRelationDTO> bindCodeMap = bindRelationList.stream()
.collect(Collectors.toMap(StaffClerkRelationDTO::getClerkCode, s -> s));
List<StoreClerkVO> resultList = new ArrayList<>(); List<StoreClerkVO> resultList = new ArrayList<>();
for (ClerkDTO dto : clerkDTOS) { for (ClerkDTO dto : clerkDTOS) {
String clerkCode = dto.getClerkCode(); String clerkCode = dto.getClerkCode();
...@@ -247,7 +256,7 @@ public class WxStaffController extends WebBaseController { ...@@ -247,7 +256,7 @@ public class WxStaffController extends WebBaseController {
return resultResponse(HaoBanErrCode.ERR_1, page); return resultResponse(HaoBanErrCode.ERR_1, page);
} }
//门店成员列表 // 门店成员列表
@RequestMapping("/clerk-edit-flag") @RequestMapping("/clerk-edit-flag")
public HaobanResponse clerkEditFlag(String wxEnterpriseId, String storeId) { public HaobanResponse clerkEditFlag(String wxEnterpriseId, String storeId) {
if (StringUtils.isAnyBlank(storeId)) { if (StringUtils.isAnyBlank(storeId)) {
...@@ -257,12 +266,12 @@ public class WxStaffController extends WebBaseController { ...@@ -257,12 +266,12 @@ public class WxStaffController extends WebBaseController {
if (storeDTO == null) { if (storeDTO == null) {
return resultResponse(HaoBanErrCode.ERR_10009); return resultResponse(HaoBanErrCode.ERR_10009);
} }
WxEnterpriseRelationDetailDTO enterpriseBindInfo = wxEnterpriseRelatedApiService.getEnterpriseBindInfo(wxEnterpriseId, storeDTO.getEnterpriseId()); WxEnterpriseRelationDetailDTO enterpriseBindInfo = wxEnterpriseRelatedApiService
.getEnterpriseBindInfo(wxEnterpriseId, storeDTO.getEnterpriseId());
return resultResponse(HaoBanErrCode.ERR_1, ClerkEditInfoVO.info(enterpriseBindInfo.getClerkEditFlag())); return resultResponse(HaoBanErrCode.ERR_1, ClerkEditInfoVO.info(enterpriseBindInfo.getClerkEditFlag()));
} }
/** /**
* 会员小程序-获取后台认证配置 * 会员小程序-获取后台认证配置
* *
...@@ -297,7 +306,8 @@ public class WxStaffController extends WebBaseController { ...@@ -297,7 +306,8 @@ public class WxStaffController extends WebBaseController {
} }
AuditSettingVO auditSettingVO = new AuditSettingVO(); AuditSettingVO auditSettingVO = new AuditSettingVO();
ClerkMainStoreRelatedDTO mainStore = clerkMainStoreRelatedApiService.getWxEnterpriseIdAndStaffId(wxEnterpriseId, staffId); ClerkMainStoreRelatedDTO mainStore = clerkMainStoreRelatedApiService.getWxEnterpriseIdAndStaffId(wxEnterpriseId,
staffId);
if (mainStore == null) { if (mainStore == null) {
logger.info("该门店不存在"); logger.info("该门店不存在");
return resultResponse(HaoBanErrCode.ERR_400023); return resultResponse(HaoBanErrCode.ERR_400023);
...@@ -308,7 +318,8 @@ public class WxStaffController extends WebBaseController { ...@@ -308,7 +318,8 @@ public class WxStaffController extends WebBaseController {
logger.info("该门店不存在"); logger.info("该门店不存在");
return resultResponse(HaoBanErrCode.ERR_400023); return resultResponse(HaoBanErrCode.ERR_400023);
} }
WxEnterpriseRelationDetailDTO enterpriseBindInfo = wxEnterpriseRelatedApiService.getEnterpriseBindInfo(wxEnterpriseId, storeDTO.getEnterpriseId()); WxEnterpriseRelationDetailDTO enterpriseBindInfo = wxEnterpriseRelatedApiService
.getEnterpriseBindInfo(wxEnterpriseId, storeDTO.getEnterpriseId());
if (null == enterpriseBindInfo) { if (null == enterpriseBindInfo) {
logger.info("该企业未关联"); logger.info("该企业未关联");
return resultResponse(HaoBanErrCode.ERR_400022); return resultResponse(HaoBanErrCode.ERR_400022);
...@@ -321,7 +332,7 @@ public class WxStaffController extends WebBaseController { ...@@ -321,7 +332,7 @@ public class WxStaffController extends WebBaseController {
Integer agreeExternalUseridFlag = wxEnterpriseDTO.getAgreeExternalUseridFlag(); Integer agreeExternalUseridFlag = wxEnterpriseDTO.getAgreeExternalUseridFlag();
int memberOpenCardFlag = enterpriseBindInfo.getMemberOpenCardFlag(); int memberOpenCardFlag = enterpriseBindInfo.getMemberOpenCardFlag();
boolean agreeExternalUserid = agreeExternalUseridFlag == null || agreeExternalUseridFlag != 1; boolean agreeExternalUserid = agreeExternalUseridFlag == null || agreeExternalUseridFlag != 1;
//同一开平并且未同意转换 // 同一开平并且未同意转换
if (memberOpenCardFlag == 0 && agreeExternalUserid) { if (memberOpenCardFlag == 0 && agreeExternalUserid) {
auditSettingVO.setMemberOpenCardFlag(0); auditSettingVO.setMemberOpenCardFlag(0);
} else { } else {
...@@ -340,10 +351,11 @@ public class WxStaffController extends WebBaseController { ...@@ -340,10 +351,11 @@ public class WxStaffController extends WebBaseController {
return resultResponse(HaoBanErrCode.ERR_1, vo); return resultResponse(HaoBanErrCode.ERR_1, vo);
} }
//新增店员 // 新增店员
@HttpLimit @HttpLimit
@RequestMapping("/staff-add") @RequestMapping("/staff-add")
public HaobanResponse staffAdd(StaffDTO staffDTO, String storeId, String clerkCode, String commitName, Integer version) { public HaobanResponse staffAdd(StaffDTO staffDTO, String storeId, String clerkCode, String commitName,
Integer version) {
String wxEnterpriseId = staffDTO.getWxEnterpriseId(); String wxEnterpriseId = staffDTO.getWxEnterpriseId();
String staffName = staffDTO.getStaffName(); String staffName = staffDTO.getStaffName();
...@@ -357,14 +369,13 @@ public class WxStaffController extends WebBaseController { ...@@ -357,14 +369,13 @@ public class WxStaffController extends WebBaseController {
if (StringUtils.isEmpty(clerkCode)) { if (StringUtils.isEmpty(clerkCode)) {
return resultResponse(HaoBanErrCode.ERR_111116); return resultResponse(HaoBanErrCode.ERR_111116);
} }
if (StringUtils.isNotEmpty(phoneNumber) && if (StringUtils.isNotEmpty(phoneNumber) && !GooglePhoneNumberUtil.checkPhoneNumber(phoneNumber, nationcode)) {
!GooglePhoneNumberUtil.checkPhoneNumber(phoneNumber, nationcode)) {
return resultResponse(HaoBanErrCode.ERR_10012); return resultResponse(HaoBanErrCode.ERR_10012);
} }
// 导购code校验-字母和数字 // 导购code校验-字母和数字
//if (!clerkCode.matches("[a-zA-Z0-9]+")) { // if (!clerkCode.matches("[a-zA-Z0-9]+")) {
// return resultResponse(HaoBanErrCode.ERR_10023); // return resultResponse(HaoBanErrCode.ERR_10023);
//} // }
if (version == null) { if (version == null) {
StaffDTO staff = staffApiService.selectByNationcodeAndPhoneNumber(wxEnterpriseId, nationcode, phoneNumber); StaffDTO staff = staffApiService.selectByNationcodeAndPhoneNumber(wxEnterpriseId, nationcode, phoneNumber);
if (staff != null) { if (staff != null) {
...@@ -372,14 +383,14 @@ public class WxStaffController extends WebBaseController { ...@@ -372,14 +383,14 @@ public class WxStaffController extends WebBaseController {
} }
} }
com.gic.enterprise.api.dto.StoreDTO store = storeService.getStoreByIdNoStatus(storeId); com.gic.enterprise.api.dto.StoreDTO store = storeService.getStoreByIdNoStatus(storeId);
//校验手机是否唯一 // 校验手机是否唯一
if (store == null) { if (store == null) {
return resultResponse(HaoBanErrCode.ERR_10009); return resultResponse(HaoBanErrCode.ERR_10009);
} }
String enterpriseId = store.getEnterpriseId(); String enterpriseId = store.getEnterpriseId();
boolean b = auditApiService.judgeHavePhoneNumberOrCode(enterpriseId, clerkCode, phoneNumber, wxEnterpriseId); boolean b = auditApiService.judgeHavePhoneNumberOrCode(enterpriseId, clerkCode, phoneNumber, wxEnterpriseId);
if (b) { if (b) {
//待审核中存在code或该手机号 // 待审核中存在code或该手机号
return resultResponse(HaoBanErrCode.ERR_10021); return resultResponse(HaoBanErrCode.ERR_10021);
} }
ClerkDTO clerk = clerkService.getClerkByCodeNoDel(store.getEnterpriseId(), clerkCode); ClerkDTO clerk = clerkService.getClerkByCodeNoDel(store.getEnterpriseId(), clerkCode);
...@@ -389,12 +400,13 @@ public class WxStaffController extends WebBaseController { ...@@ -389,12 +400,13 @@ public class WxStaffController extends WebBaseController {
} }
AuditSettingDTO dto = auditSettingApiService.findSettingByWxEnterpriseId(wxEnterpriseId); AuditSettingDTO dto = auditSettingApiService.findSettingByWxEnterpriseId(wxEnterpriseId);
if (dto.getAuditFlag() == 1 && dto.getClerkChangeFlag() == 1) { if (dto.getAuditFlag() == 1 && dto.getClerkChangeFlag() == 1) {
AuditDTO auditDTO = auditApiService.findByBindRelatedIdAndAuditType(clerkCode, AuditType.CLERK_ADD.getCode(), wxEnterpriseId, enterpriseId); AuditDTO auditDTO = auditApiService.findByBindRelatedIdAndAuditType(clerkCode,
AuditType.CLERK_ADD.getCode(), wxEnterpriseId, enterpriseId);
if (auditDTO != null) { if (auditDTO != null) {
logger.info("已经存在了审核记录,待审核{}", clerkCode); logger.info("已经存在了审核记录,待审核{}", clerkCode);
return resultResponse(HaoBanErrCode.ERR_10018); return resultResponse(HaoBanErrCode.ERR_10018);
} }
//需要审核 // 需要审核
StaffDTO staff = staffApiService.selectById(staffDTO.getStaffId()); StaffDTO staff = staffApiService.selectById(staffDTO.getStaffId());
AuditDTO audit = new AuditDTO(); AuditDTO audit = new AuditDTO();
audit.setCommitStaffName(commitName); audit.setCommitStaffName(commitName);
...@@ -423,7 +435,7 @@ public class WxStaffController extends WebBaseController { ...@@ -423,7 +435,7 @@ public class WxStaffController extends WebBaseController {
auditApiService.insert(audit); auditApiService.insert(audit);
return resultResponse(HaoBanErrCode.ERR_1); return resultResponse(HaoBanErrCode.ERR_1);
} else { } else {
//不用审核 // 不用审核
StaffDTO staff = staffApiService.selectById(staffDTO.getStaffId()); StaffDTO staff = staffApiService.selectById(staffDTO.getStaffId());
AuditDTO audit = new AuditDTO(); AuditDTO audit = new AuditDTO();
audit.setCommitStaffName(commitName); audit.setCommitStaffName(commitName);
...@@ -452,15 +464,16 @@ public class WxStaffController extends WebBaseController { ...@@ -452,15 +464,16 @@ public class WxStaffController extends WebBaseController {
audit.setRelatedId(clerkCode); audit.setRelatedId(clerkCode);
auditApiService.insert(audit); auditApiService.insert(audit);
} }
//只新增gic那边的,不新增好办这边 // 只新增gic那边的,不新增好办这边
boolean flag = syncHaobanToGicApiService.syncClerkToGicClerkAdd(storeId, clerkCode, sex, staffName, phoneNumber, nationcode, postion); boolean flag = syncHaobanToGicApiService.syncClerkToGicClerkAdd(storeId, clerkCode, sex, staffName, phoneNumber,
nationcode, postion);
if (!flag) { if (!flag) {
return resultResponse(HaoBanErrCode.ERR_10010); return resultResponse(HaoBanErrCode.ERR_10010);
} }
return resultResponse(HaoBanErrCode.ERR_1); return resultResponse(HaoBanErrCode.ERR_1);
} }
//删除店员 // 删除店员
@HttpLimit @HttpLimit
@RequestMapping("/staff-del") @RequestMapping("/staff-del")
public HaobanResponse staffDel(String wxEnterpriseId, String storeId, String clerkIds, String staffId) { public HaobanResponse staffDel(String wxEnterpriseId, String storeId, String clerkIds, String staffId) {
...@@ -468,16 +481,17 @@ public class WxStaffController extends WebBaseController { ...@@ -468,16 +481,17 @@ public class WxStaffController extends WebBaseController {
return resultResponse(HaoBanErrCode.ERR_2); return resultResponse(HaoBanErrCode.ERR_2);
} }
com.gic.enterprise.api.dto.StoreDTO store = storeService.getStoreByIdNoStatus(storeId); com.gic.enterprise.api.dto.StoreDTO store = storeService.getStoreByIdNoStatus(storeId);
//校验手机是否唯一 // 校验手机是否唯一
if (store == null) { if (store == null) {
return resultResponse(HaoBanErrCode.ERR_400001); return resultResponse(HaoBanErrCode.ERR_400001);
} }
AuditSettingDTO dto = auditSettingApiService.findSettingByWxEnterpriseId(wxEnterpriseId); AuditSettingDTO dto = auditSettingApiService.findSettingByWxEnterpriseId(wxEnterpriseId);
if (dto.getClerkChangeFlag() == 1) { if (dto.getClerkChangeFlag() == 1) {
//需要审核 // 需要审核
String[] clerkIdArr = clerkIds.split(","); String[] clerkIdArr = clerkIds.split(",");
for (String clerkId : clerkIdArr) { for (String clerkId : clerkIdArr) {
AuditDTO auditDTO = auditApiService.findByBindRelatedIdAndAuditType(clerkId, AuditType.CLERK_DEL.getCode(), wxEnterpriseId, store.getEnterpriseId()); AuditDTO auditDTO = auditApiService.findByBindRelatedIdAndAuditType(clerkId,
AuditType.CLERK_DEL.getCode(), wxEnterpriseId, store.getEnterpriseId());
if (auditDTO != null) { if (auditDTO != null) {
logger.info("已经存在了审核记录,待审核{}", clerkId); logger.info("已经存在了审核记录,待审核{}", clerkId);
continue; continue;
...@@ -512,7 +526,7 @@ public class WxStaffController extends WebBaseController { ...@@ -512,7 +526,7 @@ public class WxStaffController extends WebBaseController {
auditApiService.insert(audit); auditApiService.insert(audit);
} }
} else { } else {
//无需审核 // 无需审核
String[] clerkIdArr = clerkIds.split(","); String[] clerkIdArr = clerkIds.split(",");
for (String clerkId : clerkIdArr) { for (String clerkId : clerkIdArr) {
ClerkDTO clerkDTO = clerkService.getClerkByClerkId(clerkId); ClerkDTO clerkDTO = clerkService.getClerkByClerkId(clerkId);
...@@ -571,7 +585,7 @@ public class WxStaffController extends WebBaseController { ...@@ -571,7 +585,7 @@ public class WxStaffController extends WebBaseController {
} }
String yyyyMM = DateUtil.dateToStr(new Date(dateTime), "yyyyMMdd"); String yyyyMM = DateUtil.dateToStr(new Date(dateTime), "yyyyMMdd");
String key = null; String key = null;
//设置主门店缓存 // 设置主门店缓存
if (Objects.equals(type, 1)) { if (Objects.equals(type, 1)) {
int i = cn.hutool.core.date.DateUtil.weekOfYear(new Date()); int i = cn.hutool.core.date.DateUtil.weekOfYear(new Date());
key = "haoban_set_main_store_" + i + ":" + staffId; key = "haoban_set_main_store_" + i + ":" + staffId;
...@@ -585,8 +599,7 @@ public class WxStaffController extends WebBaseController { ...@@ -585,8 +599,7 @@ public class WxStaffController extends WebBaseController {
RedisUtil.delCache(key); RedisUtil.delCache(key);
} }
// 设置主导购
//设置主导购
@HttpLimit @HttpLimit
@RequestMapping("/set-main-store") @RequestMapping("/set-main-store")
public HaobanResponse setMainStore(String staffId, String storeId, String wxEnterpriseId, String dateStr) { public HaobanResponse setMainStore(String staffId, String storeId, String wxEnterpriseId, String dateStr) {
...@@ -595,7 +608,7 @@ public class WxStaffController extends WebBaseController { ...@@ -595,7 +608,7 @@ public class WxStaffController extends WebBaseController {
if (staff == null) { if (staff == null) {
return resultResponse(HaoBanErrCode.ERR_10006); return resultResponse(HaoBanErrCode.ERR_10006);
} }
//给测试使用 // 给测试使用
if (StringUtils.isNotBlank(dateStr)) { if (StringUtils.isNotBlank(dateStr)) {
curDate = cn.hutool.core.date.DateUtil.parse(dateStr); curDate = cn.hutool.core.date.DateUtil.parse(dateStr);
} }
...@@ -611,8 +624,7 @@ public class WxStaffController extends WebBaseController { ...@@ -611,8 +624,7 @@ public class WxStaffController extends WebBaseController {
return resultResponse(HaoBanErrCode.ERR_1); return resultResponse(HaoBanErrCode.ERR_1);
} }
// 设置主导购
//设置主导购
@HttpLimit @HttpLimit
@RequestMapping("/check-main-store") @RequestMapping("/check-main-store")
public HaobanResponse checkMainStore(String staffId, String storeId, String wxEnterpriseId, String dateStr) { public HaobanResponse checkMainStore(String staffId, String storeId, String wxEnterpriseId, String dateStr) {
...@@ -621,7 +633,7 @@ public class WxStaffController extends WebBaseController { ...@@ -621,7 +633,7 @@ public class WxStaffController extends WebBaseController {
if (staff == null) { if (staff == null) {
return resultResponse(HaoBanErrCode.ERR_10006); return resultResponse(HaoBanErrCode.ERR_10006);
} }
//给测试使用 // 给测试使用
if (StringUtils.isNotBlank(dateStr)) { if (StringUtils.isNotBlank(dateStr)) {
curDate = cn.hutool.core.date.DateUtil.parse(dateStr); curDate = cn.hutool.core.date.DateUtil.parse(dateStr);
} }
...@@ -629,18 +641,18 @@ public class WxStaffController extends WebBaseController { ...@@ -629,18 +641,18 @@ public class WxStaffController extends WebBaseController {
String key = "haoban_set_main_store_" + i + ":" + staffId; String key = "haoban_set_main_store_" + i + ":" + staffId;
Object hasSet = RedisUtil.getCache(key); Object hasSet = RedisUtil.getCache(key);
if (hasSet == null) { if (hasSet == null) {
//可修改 // 可修改
return resultResponse(HaoBanErrCode.ERR_1, 1); return resultResponse(HaoBanErrCode.ERR_1, 1);
} else { } else {
//不可以设置 // 不可以设置
return resultResponse(HaoBanErrCode.ERR_1, 0); return resultResponse(HaoBanErrCode.ERR_1, 0);
} }
} }
// 刷新微信好友
//刷新微信好友
@RequestMapping("/fresh-wx-friend") @RequestMapping("/fresh-wx-friend")
public HaobanResponse freshWxFrend(String staffId, String storeId, String wxEnterpriseId, String staffDepartmentRelatedId, @RequestParam(defaultValue = "0") Integer flushType) { public HaobanResponse freshWxFrend(String staffId, String storeId, String wxEnterpriseId,
String staffDepartmentRelatedId, @RequestParam(defaultValue = "0") Integer flushType) {
StaffDTO staff = staffApiService.selectById(staffId); StaffDTO staff = staffApiService.selectById(staffId);
String yyyyMM = DateUtil.dateToStr(new Date(), "yyyyMMdd"); String yyyyMM = DateUtil.dateToStr(new Date(), "yyyyMMdd");
if (staff == null) { if (staff == null) {
...@@ -654,7 +666,8 @@ public class WxStaffController extends WebBaseController { ...@@ -654,7 +666,8 @@ public class WxStaffController extends WebBaseController {
} }
if (flushType == 0) { if (flushType == 0) {
String taskName = "刷新企业微信好友(" + staff.getStaffName() + ")"; String taskName = "刷新企业微信好友(" + staff.getStaffName() + ")";
String taskId = dealSyncOperationApiService.createWxFriendTaskSingle(wxEnterpriseId, taskName, staffId, staff.getStaffName(), SyncTaskTypeEnum.FRIEND_SINGLE.getType()); String taskId = dealSyncOperationApiService.createWxFriendTaskSingle(wxEnterpriseId, taskName, staffId,
staff.getStaffName(), SyncTaskTypeEnum.FRIEND_SINGLE.getType());
if (StringUtils.isNotBlank(taskId)) { if (StringUtils.isNotBlank(taskId)) {
dealSyncOperationApiService.dealWxFriendClerkSingle(taskId, staffId, staffId, wxEnterpriseId); dealSyncOperationApiService.dealWxFriendClerkSingle(taskId, staffId, staffId, wxEnterpriseId);
} else { } else {
...@@ -662,7 +675,8 @@ public class WxStaffController extends WebBaseController { ...@@ -662,7 +675,8 @@ public class WxStaffController extends WebBaseController {
} }
} else { } else {
String taskName = "刷新门店好友"; String taskName = "刷新门店好友";
String taskId = dealSyncOperationApiService.createWxFriendTaskSingle(wxEnterpriseId, taskName, staffId, staff.getStaffName(), SyncTaskTypeEnum.FRIEND_STORE.getType()); String taskId = dealSyncOperationApiService.createWxFriendTaskSingle(wxEnterpriseId, taskName, staffId,
staff.getStaffName(), SyncTaskTypeEnum.FRIEND_STORE.getType());
if (StringUtils.isNotBlank(taskId)) { if (StringUtils.isNotBlank(taskId)) {
dealSyncOperationApiService.dealWxFriendStore(taskId, storeId, wxEnterpriseId); dealSyncOperationApiService.dealWxFriendStore(taskId, storeId, wxEnterpriseId);
} else { } else {
...@@ -670,7 +684,7 @@ public class WxStaffController extends WebBaseController { ...@@ -670,7 +684,7 @@ public class WxStaffController extends WebBaseController {
} }
} }
RedisUtil.setCache(key, 1, 31 * 24 * 60 * 60L); RedisUtil.setCache(key, 1, 31 * 24 * 60 * 60L);
//刷新状态变更 // 刷新状态变更
clerkMainStoreRelatedApiService.setFreshFriend(wxEnterpriseId, staffId); clerkMainStoreRelatedApiService.setFreshFriend(wxEnterpriseId, staffId);
return resultResponse(HaoBanErrCode.ERR_1); return resultResponse(HaoBanErrCode.ERR_1);
} }
...@@ -703,15 +717,15 @@ public class WxStaffController extends WebBaseController { ...@@ -703,15 +717,15 @@ public class WxStaffController extends WebBaseController {
public HaobanResponse checkFreshFriend(String staffId, String storeId, String wxEnterpriseId) { public HaobanResponse checkFreshFriend(String staffId, String storeId, String wxEnterpriseId) {
String yyyyMM = DateUtil.dateToStr(new Date(), "yyyyMMdd"); String yyyyMM = DateUtil.dateToStr(new Date(), "yyyyMMdd");
String key = "haoban_fresh_wx_friend" + yyyyMM + staffId; String key = "haoban_fresh_wx_friend" + yyyyMM + staffId;
//1代表能刷新 0 不能刷新 // 1代表能刷新 0 不能刷新
Integer count = RedisUtil.getCache(key) == null ? 1 : 0; Integer count = RedisUtil.getCache(key) == null ? 1 : 0;
return resultResponse(HaoBanErrCode.ERR_1, count); return resultResponse(HaoBanErrCode.ERR_1, count);
} }
// 精确查,根据手机号或者code,查找
//精确查,根据手机号或者code,查找
@RequestMapping("query-clerk-list-by-code") @RequestMapping("query-clerk-list-by-code")
public HaobanResponse queryClerkListByCode(String keyword, String wxEnterpriseId, String staffId, Integer manageFlag) { public HaobanResponse queryClerkListByCode(String keyword, String wxEnterpriseId, String staffId,
Integer manageFlag) {
if (StringUtils.isAnyBlank(staffId, wxEnterpriseId, keyword)) { if (StringUtils.isAnyBlank(staffId, wxEnterpriseId, keyword)) {
return resultResponse(HaoBanErrCode.ERR_2); return resultResponse(HaoBanErrCode.ERR_2);
} }
...@@ -737,17 +751,18 @@ public class WxStaffController extends WebBaseController { ...@@ -737,17 +751,18 @@ public class WxStaffController extends WebBaseController {
List<ClerkDTO> clerkList = new ArrayList<>(); List<ClerkDTO> clerkList = new ArrayList<>();
if (manageFlag == -1) { if (manageFlag == -1) {
clerkList.addAll(clerkService.listClerkEnableHaoban(enterpriseIdList, keyword)); clerkList.addAll(clerkService.listClerkEnableHaoban(enterpriseIdList, keyword));
clerkList.addAll(clerkNewService.listClerkByEnterpriseIdAndSearchAndClerkType(enterpriseIdList, storeIds, keyword)); clerkList.addAll(
clerkNewService.listClerkByEnterpriseIdAndSearchAndClerkType(enterpriseIdList, storeIds, keyword));
} else if (manageFlag == 1) { } else if (manageFlag == 1) {
clerkList.addAll(clerkService.listClerkEnableHaoban(enterpriseIdList, keyword)); clerkList.addAll(clerkService.listClerkEnableHaoban(enterpriseIdList, keyword));
} else { } else {
clerkList.addAll(clerkNewService.listClerkByEnterpriseIdAndSearchAndClerkType(enterpriseIdList, storeIds, keyword)); clerkList.addAll(
clerkNewService.listClerkByEnterpriseIdAndSearchAndClerkType(enterpriseIdList, storeIds, keyword));
} }
List<ClerkStoreVO> clerkStoreList = buildClerkRelation(clerkList, enterpriseIdList, wxEnterpriseId); List<ClerkStoreVO> clerkStoreList = buildClerkRelation(clerkList, enterpriseIdList, wxEnterpriseId);
return resultResponse(HaoBanErrCode.ERR_1, clerkStoreList); return resultResponse(HaoBanErrCode.ERR_1, clerkStoreList);
} }
/** /**
* 未关联导购列表 * 未关联导购列表
* *
...@@ -782,7 +797,8 @@ public class WxStaffController extends WebBaseController { ...@@ -782,7 +797,8 @@ public class WxStaffController extends WebBaseController {
* @param enterpriseIdList * @param enterpriseIdList
* @return * @return
*/ */
private List<ClerkStoreVO> buildClerkRelation(List<ClerkDTO> clerkList, List<String> enterpriseIdList, String wxEnterpriseId) { private List<ClerkStoreVO> buildClerkRelation(List<ClerkDTO> clerkList, List<String> enterpriseIdList,
String wxEnterpriseId) {
List<ClerkStoreVO> clerkStoreList = new ArrayList<>(); List<ClerkStoreVO> clerkStoreList = new ArrayList<>();
if (CollectionUtil.isEmpty(clerkList)) { if (CollectionUtil.isEmpty(clerkList)) {
return clerkStoreList; return clerkStoreList;
...@@ -791,7 +807,8 @@ public class WxStaffController extends WebBaseController { ...@@ -791,7 +807,8 @@ public class WxStaffController extends WebBaseController {
Map<String, EnterpriseDTO> map = com.gic.commons.util.CollectionUtil.toMap(enterpriselist, "enterpriseId"); Map<String, EnterpriseDTO> map = com.gic.commons.util.CollectionUtil.toMap(enterpriselist, "enterpriseId");
List<String> clerkIds = clerkList.stream().map(s -> s.getClerkId()).collect(Collectors.toList()); List<String> clerkIds = clerkList.stream().map(s -> s.getClerkId()).collect(Collectors.toList());
List<StaffClerkRelationDTO> clerkRelations = staffClerkRelationApiService.listByClerkIds(clerkIds); List<StaffClerkRelationDTO> clerkRelations = staffClerkRelationApiService.listByClerkIds(clerkIds);
Map<String, StaffClerkRelationDTO> clerkBindMap = com.gic.commons.util.CollectionUtil.toMap(clerkRelations, "clerkId"); Map<String, StaffClerkRelationDTO> clerkBindMap = com.gic.commons.util.CollectionUtil.toMap(clerkRelations,
"clerkId");
for (ClerkDTO clerk : clerkList) { for (ClerkDTO clerk : clerkList) {
String enterpriseId = clerk.getEnterpriseId(); String enterpriseId = clerk.getEnterpriseId();
...@@ -814,10 +831,11 @@ public class WxStaffController extends WebBaseController { ...@@ -814,10 +831,11 @@ public class WxStaffController extends WebBaseController {
vo.setBindFlag(staffClerkRelationDTO == null ? 0 : 1); vo.setBindFlag(staffClerkRelationDTO == null ? 0 : 1);
vo.setStaffId(staffClerkRelationDTO == null ? "" : staffClerkRelationDTO.getStaffId()); vo.setStaffId(staffClerkRelationDTO == null ? "" : staffClerkRelationDTO.getStaffId());
vo.setStoreId(clerk.getStoreId()); vo.setStoreId(clerk.getStoreId());
//区经 // 区经
if (clerkType == 2) { if (clerkType == 2) {
vo.setManageFlag(1); vo.setManageFlag(1);
vo.setManageStoreCount(staffApiService.getCountHaoBanStoreIdsByClerkId(clerkId, wxEnterpriseId).getStoreCount()); vo.setManageStoreCount(
staffApiService.getCountHaoBanStoreIdsByClerkId(clerkId, wxEnterpriseId).getStoreCount());
} else { } else {
vo.setManageFlag(0); vo.setManageFlag(0);
vo.setManageStoreCount(0); vo.setManageStoreCount(0);
...@@ -844,7 +862,8 @@ public class WxStaffController extends WebBaseController { ...@@ -844,7 +862,8 @@ public class WxStaffController extends WebBaseController {
logger.error("手机号为空,不进行查询,staffId:{}", staffId); logger.error("手机号为空,不进行查询,staffId:{}", staffId);
return ret; return ret;
} }
List<ClerkDTO> clerkList = clerkNewService.listClerkByEnterpriseIdAndSearchAndClerkType(enterpriseIdList, storeIdList, phoneNumber); List<ClerkDTO> clerkList = clerkNewService.listClerkByEnterpriseIdAndSearchAndClerkType(enterpriseIdList,
storeIdList, phoneNumber);
if (CollectionUtils.isNotEmpty(clerkList)) { if (CollectionUtils.isNotEmpty(clerkList)) {
ret.addAll(clerkList); ret.addAll(clerkList);
} }
...@@ -861,7 +880,8 @@ public class WxStaffController extends WebBaseController { ...@@ -861,7 +880,8 @@ public class WxStaffController extends WebBaseController {
if (StringUtils.isEmpty(clerkDTO.getPhoneNumber())) { if (StringUtils.isEmpty(clerkDTO.getPhoneNumber())) {
continue; continue;
} }
List<ClerkDTO> clerkList = clerkNewService.listClerkByEnterpriseIdAndSearchAndClerkType(enterpriseIdList, storeIdList, clerkDTO.getPhoneNumber()); List<ClerkDTO> clerkList = clerkNewService.listClerkByEnterpriseIdAndSearchAndClerkType(enterpriseIdList,
storeIdList, clerkDTO.getPhoneNumber());
if (CollectionUtils.isNotEmpty(clerkList)) { if (CollectionUtils.isNotEmpty(clerkList)) {
ret.addAll(clerkList); ret.addAll(clerkList);
} }
...@@ -869,8 +889,10 @@ public class WxStaffController extends WebBaseController { ...@@ -869,8 +889,10 @@ public class WxStaffController extends WebBaseController {
if (CollectionUtils.isEmpty(clerkDTOS)) { if (CollectionUtils.isEmpty(clerkDTOS)) {
return ret; return ret;
} }
return ret.stream().filter(mid -> (!clerkIds.contains(mid.getClerkId()))).collect( return ret.stream().filter(mid -> (!clerkIds.contains(mid.getClerkId())))
Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(n -> n.getClerkId()))), ArrayList::new)); .collect(Collectors.collectingAndThen(
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(n -> n.getClerkId()))),
ArrayList::new));
} }
/** /**
...@@ -884,7 +906,8 @@ public class WxStaffController extends WebBaseController { ...@@ -884,7 +906,8 @@ public class WxStaffController extends WebBaseController {
*/ */
@HttpLimit @HttpLimit
@RequestMapping("bind-staff") @RequestMapping("bind-staff")
public HaobanResponse bindStaff(String clerkId, String staffId, Integer auditType, Integer manageFlag,String wxEnterpriseId) { public HaobanResponse bindStaff(String clerkId, String staffId, Integer auditType, Integer manageFlag,
String wxEnterpriseId) {
if (StringUtils.isAnyBlank(clerkId, staffId)) { if (StringUtils.isAnyBlank(clerkId, staffId)) {
return resultResponse(HaoBanErrCode.ERR_2); return resultResponse(HaoBanErrCode.ERR_2);
} }
...@@ -899,17 +922,19 @@ public class WxStaffController extends WebBaseController { ...@@ -899,17 +922,19 @@ public class WxStaffController extends WebBaseController {
if (staff == null) { if (staff == null) {
return resultResponse(HaoBanErrCode.ERR_10006); return resultResponse(HaoBanErrCode.ERR_10006);
} }
AuditDTO auditDTO = auditApiService.findByBindRelatedIdAndAuditType(clerkId, AuditType.CLERK_BIND.getCode(), wxEnterpriseId, clerk.getEnterpriseId()); AuditDTO auditDTO = auditApiService.findByBindRelatedIdAndAuditType(clerkId, AuditType.CLERK_BIND.getCode(),
wxEnterpriseId, clerk.getEnterpriseId());
if (auditDTO != null) { if (auditDTO != null) {
return resultResponse(HaoBanErrCode.ERR_10018); return resultResponse(HaoBanErrCode.ERR_10018);
} }
String storeId = ""; String storeId = "";
String storeName = ""; String storeName = "";
if (manageFlag != null && manageFlag == 1) { if (manageFlag != null && manageFlag == 1) {
//区经无门店 // 区经无门店
} else { } else {
storeId = clerk.getStoreId(); storeId = clerk.getStoreId();
StaffClerkRelationDTO haveClerkCode = staffClerkRelationApiService.getOneByStoreIdAndStaffId(storeId, staffId); StaffClerkRelationDTO haveClerkCode = staffClerkRelationApiService.getOneByStoreIdAndStaffId(storeId,
staffId);
if (haveClerkCode != null) { if (haveClerkCode != null) {
return resultResponse(HaoBanErrCode.ERR_10020); return resultResponse(HaoBanErrCode.ERR_10020);
} }
...@@ -922,10 +947,11 @@ public class WxStaffController extends WebBaseController { ...@@ -922,10 +947,11 @@ public class WxStaffController extends WebBaseController {
String clerkCode = clerk.getClerkCode(); String clerkCode = clerk.getClerkCode();
String enterpriseId = clerk.getEnterpriseId(); String enterpriseId = clerk.getEnterpriseId();
String wxUserId = staff.getWxUserId(); String wxUserId = staff.getWxUserId();
StaffClerkRelationDTO staffClerkRelation = staffClerkRelationApiService.getByCodeAndEnterpriseId(clerkCode, enterpriseId); StaffClerkRelationDTO staffClerkRelation = staffClerkRelationApiService.getByCodeAndEnterpriseId(clerkCode,
enterpriseId);
if (auditType == 2) { if (auditType == 2) {
//无需审核 // 无需审核
if (staffClerkRelation == null) { if (staffClerkRelation == null) {
staffClerkRelation = new StaffClerkRelationDTO(); staffClerkRelation = new StaffClerkRelationDTO();
} }
...@@ -937,12 +963,14 @@ public class WxStaffController extends WebBaseController { ...@@ -937,12 +963,14 @@ public class WxStaffController extends WebBaseController {
staffClerkRelation.setStaffId(staffId); staffClerkRelation.setStaffId(staffId);
staffClerkRelation.setManageFlag(manageFlag); staffClerkRelation.setManageFlag(manageFlag);
ServiceResponse serviceResponse = staffClerkRelationApiService.wxBindStaffClerk(staffClerkRelation, staffId, ChannelCodeEnum.SELF_BIND.getCode()); ServiceResponse serviceResponse = staffClerkRelationApiService.wxBindStaffClerk(staffClerkRelation, staffId,
ChannelCodeEnum.SELF_BIND.getCode());
if (!serviceResponse.isSuccess()) { if (!serviceResponse.isSuccess()) {
return resultResponse(HaoBanErrCode.ERR_DEFINE, serviceResponse.getMessage(), null, serviceResponse.getMessage()); return resultResponse(HaoBanErrCode.ERR_DEFINE, serviceResponse.getMessage(), null,
serviceResponse.getMessage());
} }
//无需审核 // 无需审核
AuditDTO audit = new AuditDTO(); AuditDTO audit = new AuditDTO();
audit.setCommitStaffName(staff.getStaffName()); audit.setCommitStaffName(staff.getStaffName());
audit.setCommitStaffId(staffId); audit.setCommitStaffId(staffId);
...@@ -968,10 +996,11 @@ public class WxStaffController extends WebBaseController { ...@@ -968,10 +996,11 @@ public class WxStaffController extends WebBaseController {
audit.setCommitTime(new Date()); audit.setCommitTime(new Date());
audit.setAuditType(2); audit.setAuditType(2);
auditApiService.insert(audit); auditApiService.insert(audit);
StaffClerkRelationDTO resultDTO = staffClerkRelationApiService.getByCodeAndEnterpriseId(clerkCode, clerk.getEnterpriseId()); StaffClerkRelationDTO resultDTO = staffClerkRelationApiService.getByCodeAndEnterpriseId(clerkCode,
clerk.getEnterpriseId());
return resultResponse(HaoBanErrCode.ERR_1, resultDTO); return resultResponse(HaoBanErrCode.ERR_1, resultDTO);
} else { } else {
//需要审核 // 需要审核
AuditDTO audit = new AuditDTO(); AuditDTO audit = new AuditDTO();
audit.setCommitStaffName(staff.getStaffName()); audit.setCommitStaffName(staff.getStaffName());
audit.setCommitStaffId(staffId); audit.setCommitStaffId(staffId);
...@@ -1010,18 +1039,17 @@ public class WxStaffController extends WebBaseController { ...@@ -1010,18 +1039,17 @@ public class WxStaffController extends WebBaseController {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("storeId", storeId); jsonObject.put("storeId", storeId);
NoticeMessageUtil.sendNoticeMessage(clerk.getEnterpriseId() NoticeMessageUtil.sendNoticeMessage(clerk.getEnterpriseId(), gicClerk.getClerkId(),
, gicClerk.getClerkId() NoticeMessageTypeEnum.STORE_ACCOUNT.getType(), null, fieldMap, jsonObject);
, NoticeMessageTypeEnum.STORE_ACCOUNT.getType()
, null, fieldMap, jsonObject);
return resultResponse(HaoBanErrCode.ERR_1); return resultResponse(HaoBanErrCode.ERR_1);
} }
} }
//解绑 // 解绑
@RequestMapping("unbind-staff") @RequestMapping("unbind-staff")
public HaobanResponse unBindStaff(String wxEnterpriseId ,String clerkId, String clerkCode, String staffId, String storeId, String enterpriseId, Integer manageFlag) { public HaobanResponse unBindStaff(String wxEnterpriseId, String clerkId, String clerkCode, String staffId,
String storeId, String enterpriseId, Integer manageFlag) {
logger.info("解绑 操作人:{},备操作人:{},操作门店:{}", staffId, clerkId, storeId); logger.info("解绑 操作人:{},备操作人:{},操作门店:{}", staffId, clerkId, storeId);
if (StringUtils.isAnyBlank(clerkId, clerkCode, staffId)) { if (StringUtils.isAnyBlank(clerkId, clerkCode, staffId)) {
return resultResponse(HaoBanErrCode.ERR_2); return resultResponse(HaoBanErrCode.ERR_2);
...@@ -1034,11 +1062,13 @@ public class WxStaffController extends WebBaseController { ...@@ -1034,11 +1062,13 @@ public class WxStaffController extends WebBaseController {
if (staff == null) { if (staff == null) {
return resultResponse(HaoBanErrCode.ERR_10006); return resultResponse(HaoBanErrCode.ERR_10006);
} }
StaffClerkRelationDTO staffClerkRelation = staffClerkRelationApiService.getByCodeAndEnterpriseId(clerkCode, enterpriseId); StaffClerkRelationDTO staffClerkRelation = staffClerkRelationApiService.getByCodeAndEnterpriseId(clerkCode,
enterpriseId);
if (staffClerkRelation == null) { if (staffClerkRelation == null) {
return resultResponse(HaoBanErrCode.ERR_111145); return resultResponse(HaoBanErrCode.ERR_111145);
} }
staffClerkRelationApiService.unbindByStaffAndClerkId(staffId, clerkId, ChannelCodeEnum.SELF_UNBIND.getCode(),wxEnterpriseId); staffClerkRelationApiService.unbindByStaffAndClerkId(staffId, clerkId, ChannelCodeEnum.SELF_UNBIND.getCode(),
wxEnterpriseId);
return resultResponse(HaoBanErrCode.ERR_1); return resultResponse(HaoBanErrCode.ERR_1);
} }
...@@ -1050,14 +1080,17 @@ public class WxStaffController extends WebBaseController { ...@@ -1050,14 +1080,17 @@ public class WxStaffController extends WebBaseController {
* @return * @return
*/ */
@RequestMapping("store-clerk-list") @RequestMapping("store-clerk-list")
public HaobanResponse storeClerkList(String storeId, String enterpriseId,String wxEnterpriseId) { public HaobanResponse storeClerkList(String storeId, String enterpriseId, String wxEnterpriseId) {
List<ClerkDTO> list = clerkService.listClerkByNameOrCode(enterpriseId, null, Collections.singletonList(storeId)); List<ClerkDTO> list = clerkService.listClerkByNameOrCode(enterpriseId, null,
Collections.singletonList(storeId));
if (CollectionUtils.isEmpty(list)) { if (CollectionUtils.isEmpty(list)) {
return resultResponse(HaoBanErrCode.ERR_10016); return resultResponse(HaoBanErrCode.ERR_10016);
} }
Set<String> clerkCodeList = list.stream().map(ClerkDTO::getClerkCode).collect(Collectors.toSet()); Set<String> clerkCodeList = list.stream().map(ClerkDTO::getClerkCode).collect(Collectors.toSet());
List<StaffClerkRelationDTO> bindRelationList = staffClerkRelationApiService.listBindCode(wxEnterpriseId, enterpriseId, clerkCodeList); List<StaffClerkRelationDTO> bindRelationList = staffClerkRelationApiService.listBindCode(wxEnterpriseId,
Map<String, StaffClerkRelationDTO> bindCodeMap = bindRelationList.stream().collect(Collectors.toMap(StaffClerkRelationDTO::getClerkCode, s -> s)); enterpriseId, clerkCodeList);
Map<String, StaffClerkRelationDTO> bindCodeMap = bindRelationList.stream()
.collect(Collectors.toMap(StaffClerkRelationDTO::getClerkCode, s -> s));
List<BindClerkVO> bindList = new ArrayList<>(); List<BindClerkVO> bindList = new ArrayList<>();
List<BindClerkVO> unBindList = new ArrayList<>(); List<BindClerkVO> unBindList = new ArrayList<>();
for (ClerkDTO dto : list) { for (ClerkDTO dto : list) {
...@@ -1072,7 +1105,7 @@ public class WxStaffController extends WebBaseController { ...@@ -1072,7 +1105,7 @@ public class WxStaffController extends WebBaseController {
if (StringUtils.isNotBlank(dto.getNationcode())) { if (StringUtils.isNotBlank(dto.getNationcode())) {
vo.setNationCode(dto.getNationcode()); vo.setNationCode(dto.getNationcode());
} }
}else { } else {
vo.setPhoneNumber(""); vo.setPhoneNumber("");
vo.setNationCode(""); vo.setNationCode("");
} }
...@@ -1095,14 +1128,17 @@ public class WxStaffController extends WebBaseController { ...@@ -1095,14 +1128,17 @@ public class WxStaffController extends WebBaseController {
* @return * @return
*/ */
@RequestMapping("clerk-manage-list") @RequestMapping("clerk-manage-list")
public RestResponse clerkManageList(String enterpriseId,String wxEnterpriseId) { public RestResponse clerkManageList(String enterpriseId, String wxEnterpriseId) {
List<ClerkDTO> list = clerkService.listClerkEnableHaoban(Collections.singletonList(enterpriseId), null); List<ClerkDTO> list = clerkService.listClerkEnableHaoban(Collections.singletonList(enterpriseId), null);
if (CollectionUtils.isEmpty(list)) { if (CollectionUtils.isEmpty(list)) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_10016.getCode()), HaoBanErrCode.ERR_10016.getMsg()); return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_10016.getCode()),
HaoBanErrCode.ERR_10016.getMsg());
} }
Set<String> clerkCodeList = list.stream().map(ClerkDTO::getClerkCode).collect(Collectors.toSet()); Set<String> clerkCodeList = list.stream().map(ClerkDTO::getClerkCode).collect(Collectors.toSet());
List<StaffClerkRelationDTO> bindRelationList = staffClerkRelationApiService.listBindCode(wxEnterpriseId, enterpriseId, clerkCodeList); List<StaffClerkRelationDTO> bindRelationList = staffClerkRelationApiService.listBindCode(wxEnterpriseId,
Map<String, StaffClerkRelationDTO> bindCodeMap = bindRelationList.stream().collect(Collectors.toMap(StaffClerkRelationDTO::getClerkCode, s -> s)); enterpriseId, clerkCodeList);
Map<String, StaffClerkRelationDTO> bindCodeMap = bindRelationList.stream()
.collect(Collectors.toMap(StaffClerkRelationDTO::getClerkCode, s -> s));
List<BindClerkVO> bindList = new ArrayList<>(); List<BindClerkVO> bindList = new ArrayList<>();
List<BindClerkVO> unBindList = new ArrayList<>(); List<BindClerkVO> unBindList = new ArrayList<>();
for (ClerkDTO dto : list) { for (ClerkDTO dto : list) {
...@@ -1138,17 +1174,22 @@ public class WxStaffController extends WebBaseController { ...@@ -1138,17 +1174,22 @@ public class WxStaffController extends WebBaseController {
return resultResponse(HaoBanErrCode.ERR_2); return resultResponse(HaoBanErrCode.ERR_2);
} }
List<StaffStoreVO> list = new ArrayList<>(); List<StaffStoreVO> list = new ArrayList<>();
List<EnterpriseDetailDTO> enterpriseList = wxEnterpriseRelatedApiService.listEnterpriseByWxEnterpriseId(wxEnterpriseId); List<EnterpriseDetailDTO> enterpriseList = wxEnterpriseRelatedApiService
List<String> enterpriseIdList = enterpriseList.stream().map(EnterpriseDetailDTO::getEnterpriseId).collect(Collectors.toList()); .listEnterpriseByWxEnterpriseId(wxEnterpriseId);
List<StaffClerkRelationDTO> bindRelationList = staffClerkRelationApiService.listBindCodeByStaffId(enterpriseIdList, staffId); List<String> enterpriseIdList = enterpriseList.stream().map(EnterpriseDetailDTO::getEnterpriseId)
//主门店 .collect(Collectors.toList());
ClerkMainStoreRelatedDTO mainDTO = clerkMainStoreRelatedApiService.getWxEnterpriseIdAndStaffId(wxEnterpriseId, staffId); List<StaffClerkRelationDTO> bindRelationList = staffClerkRelationApiService
.listBindCodeByStaffId(enterpriseIdList, staffId);
// 主门店
ClerkMainStoreRelatedDTO mainDTO = clerkMainStoreRelatedApiService.getWxEnterpriseIdAndStaffId(wxEnterpriseId,
staffId);
String storeId = mainDTO == null ? "" : mainDTO.getStoreId(); String storeId = mainDTO == null ? "" : mainDTO.getStoreId();
for (StaffClerkRelationDTO staffClerkRelationDTO : bindRelationList) { for (StaffClerkRelationDTO staffClerkRelationDTO : bindRelationList) {
ClerkDTO clerk = clerkService.getClerkByClerkCode(staffClerkRelationDTO.getEnterpriseId(), staffClerkRelationDTO.getClerkCode()); ClerkDTO clerk = clerkService.getClerkByClerkCode(staffClerkRelationDTO.getEnterpriseId(),
staffClerkRelationDTO.getClerkCode());
if (clerk != null) { if (clerk != null) {
StoreDTO store = storeService.getStore(clerk.getStoreId()); StoreDTO store = storeService.getStore(clerk.getStoreId());
//主门店标志 // 主门店标志
int mainStoreFlag = 0; int mainStoreFlag = 0;
if (StringUtils.isEmpty(storeId)) { if (StringUtils.isEmpty(storeId)) {
mainStoreFlag = 0; mainStoreFlag = 0;
...@@ -1301,7 +1342,8 @@ public class WxStaffController extends WebBaseController { ...@@ -1301,7 +1342,8 @@ public class WxStaffController extends WebBaseController {
statusFlags.add(status); statusFlags.add(status);
} }
StaffDTO staff = staffApiService.selectById(staffId); StaffDTO staff = staffApiService.selectById(staffId);
Page<ExternalClerkRelatedDTO> page = externalClerkRelatedApiService.pageExternalClerk(staff.getWxEnterpriseId(), staffId, statusFlags, pageInfo); Page<ExternalClerkRelatedDTO> page = externalClerkRelatedApiService.pageExternalClerk(staff.getWxEnterpriseId(),
staffId, statusFlags, pageInfo);
PageResult2 retPage = PageUtil.getPageInfo(page); PageResult2 retPage = PageUtil.getPageInfo(page);
return resultResponse(HaoBanErrCode.ERR_1, retPage); return resultResponse(HaoBanErrCode.ERR_1, retPage);
} }
...@@ -1331,7 +1373,8 @@ public class WxStaffController extends WebBaseController { ...@@ -1331,7 +1373,8 @@ public class WxStaffController extends WebBaseController {
if (staffDTO == null) { if (staffDTO == null) {
return RestResponse.failure(HaoBanErrCode.ERR_6.getCode() + "", HaoBanErrCode.ERR_6.getMsg()); return RestResponse.failure(HaoBanErrCode.ERR_6.getCode() + "", HaoBanErrCode.ERR_6.getMsg());
} }
int friendCount = externalClerkRelatedApiService.countFriendCountByClerkId(qo.getWxEnterpriseId(), qo.getEnterpriseId(), staffDTO.getStaffId(), qo.getClerkId()); int friendCount = externalClerkRelatedApiService.countFriendCountByClerkId(qo.getWxEnterpriseId(),
qo.getEnterpriseId(), staffDTO.getStaffId(), qo.getClerkId());
int memberCount = customerApiService.countMember(qo.getEnterpriseId(), qo.getStoreId(), qo.getClerkId()); int memberCount = customerApiService.countMember(qo.getEnterpriseId(), qo.getStoreId(), qo.getClerkId());
ret.setFriendCount(friendCount); ret.setFriendCount(friendCount);
...@@ -1347,7 +1390,8 @@ public class WxStaffController extends WebBaseController { ...@@ -1347,7 +1390,8 @@ public class WxStaffController extends WebBaseController {
*/ */
@RequestMapping("can-relation-count") @RequestMapping("can-relation-count")
public RestResponse canRelationCount(@RequestBody @Valid CommonQO qo) { public RestResponse canRelationCount(@RequestBody @Valid CommonQO qo) {
List<StaffClerkInfoDTO> staffClerkInfoDTOS = staffClerkRelationApiService.listBindDetailByStaffId(qo.getStaffId()); List<StaffClerkInfoDTO> staffClerkInfoDTOS = staffClerkRelationApiService
.listBindDetailByStaffId(qo.getStaffId());
if (CollectionUtils.isEmpty(staffClerkInfoDTOS)) { if (CollectionUtils.isEmpty(staffClerkInfoDTOS)) {
return RestResponse.successResult(0); return RestResponse.successResult(0);
} }
...@@ -1365,7 +1409,6 @@ public class WxStaffController extends WebBaseController { ...@@ -1365,7 +1409,6 @@ public class WxStaffController extends WebBaseController {
return RestResponse.successResult(storeWidgetService.getClerkWidgetStore(clerkId)); return RestResponse.successResult(storeWidgetService.getClerkWidgetStore(clerkId));
} }
/** /**
* 根据员工id获取openId * 根据员工id获取openId
* *
...@@ -1373,8 +1416,8 @@ public class WxStaffController extends WebBaseController { ...@@ -1373,8 +1416,8 @@ public class WxStaffController extends WebBaseController {
* @author mozhu * @author mozhu
* @date 2021-12-29 10:42:24 * @date 2021-12-29 10:42:24
*/ */
@RequestMapping(value = "getOpenIdByStaffId", method = {RequestMethod.POST, RequestMethod.GET}) @RequestMapping(value = "getOpenIdByStaffId", method = { RequestMethod.POST, RequestMethod.GET })
public RestResponse<String> getOpenIdByStaffId(String staffId,String wxEnterpriseId) { public RestResponse<String> getOpenIdByStaffId(String staffId, String wxEnterpriseId) {
StaffDTO staffDTO = staffApiService.selectById(staffId); StaffDTO staffDTO = staffApiService.selectById(staffId);
if (staffDTO == null) { if (staffDTO == null) {
int code = HaoBanErrCode.ERR_6.getCode(); int code = HaoBanErrCode.ERR_6.getCode();
...@@ -1393,7 +1436,8 @@ public class WxStaffController extends WebBaseController { ...@@ -1393,7 +1436,8 @@ public class WxStaffController extends WebBaseController {
if (qwDTO.needOpenUserId3th()) { if (qwDTO.needOpenUserId3th()) {
wxUserId = staffDTO.getWxOpenUseId(); wxUserId = staffDTO.getWxOpenUseId();
} }
String openid = qywxUserApiService.getSelfOpenIdByUserId(qwDTO.getThirdCorpid(), config.getWxSuiteid(), wxUserId); String openid = qywxUserApiService.getSelfOpenIdByUserId(qwDTO.getThirdCorpid(), config.getWxSuiteid(),
wxUserId);
if (StringUtils.isBlank(openid)) { if (StringUtils.isBlank(openid)) {
int code = HaoBanErrCode.ERR_600003.getCode(); int code = HaoBanErrCode.ERR_600003.getCode();
return RestResponse.failure(String.valueOf(code), HaoBanErrCode.ERR_600003.getMsg()); return RestResponse.failure(String.valueOf(code), HaoBanErrCode.ERR_600003.getMsg());
...@@ -1402,30 +1446,32 @@ public class WxStaffController extends WebBaseController { ...@@ -1402,30 +1446,32 @@ public class WxStaffController extends WebBaseController {
return RestResponse.successResult(openid); return RestResponse.successResult(openid);
} }
/** /**
* 根据角色查询菜单 * 根据角色查询菜单
* *
* @return * @return
*/ */
@RequestMapping(value = "/queryMenuCodesByClerkType", method = RequestMethod.GET) @RequestMapping(value = "/queryMenuCodesByClerkType", method = RequestMethod.GET)
public RestResponse<HaobanRoleDTO> queryMenuByClerkType(Integer clerkType, String staffId , String wxEnterpriseId) { public RestResponse<HaobanRoleDTO> queryMenuByClerkType(Integer clerkType, String staffId, String wxEnterpriseId) {
if (clerkType == null) { if (clerkType == null) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_2.getCode()), HaoBanErrCode.ERR_2.getMsg()); return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_2.getCode()), HaoBanErrCode.ERR_2.getMsg());
} }
if (clerkType == -1) { if (clerkType == -1) {
logger.info("导购类型为-1,游客获取系统级别的导购权限"); logger.info("导购类型为-1,游客获取系统级别的导购权限");
//游客获取系统级别的导购权限 // 游客获取系统级别的导购权限
ServiceResponse<HaobanRoleDTO> serviceResponse = haobanRoleApiService.getMenuByWxEnterpriseIdAndClerkType("-1", RoleClerkTypeEnum.CLERK.getCode(), 0); ServiceResponse<HaobanRoleDTO> serviceResponse = haobanRoleApiService
.getMenuByWxEnterpriseIdAndClerkType("-1", RoleClerkTypeEnum.CLERK.getCode(), 0);
return RestResponse.successResult(serviceResponse.getResult()); return RestResponse.successResult(serviceResponse.getResult());
} }
if (StringUtils.isBlank(staffId) || "-1".equals(staffId)) { if (StringUtils.isBlank(staffId) || "-1".equals(staffId)) {
logger.info("未登录游客获取系统级别的导购权限"); logger.info("未登录游客获取系统级别的导购权限");
//游客获取系统级别的导购权限 // 游客获取系统级别的导购权限
ServiceResponse<HaobanRoleDTO> serviceResponse = haobanRoleApiService.getMenuByWxEnterpriseIdAndClerkType("-1", RoleClerkTypeEnum.CLERK.getCode(), 0); ServiceResponse<HaobanRoleDTO> serviceResponse = haobanRoleApiService
.getMenuByWxEnterpriseIdAndClerkType("-1", RoleClerkTypeEnum.CLERK.getCode(), 0);
return RestResponse.successResult(serviceResponse.getResult()); return RestResponse.successResult(serviceResponse.getResult());
} }
ServiceResponse<HaobanRoleDTO> serviceResponse = haobanRoleApiService.getMenuByWxEnterpriseIdAndClerkType(wxEnterpriseId, clerkType, 1); ServiceResponse<HaobanRoleDTO> serviceResponse = haobanRoleApiService
.getMenuByWxEnterpriseIdAndClerkType(wxEnterpriseId, clerkType, 1);
return RestResponse.successResult(serviceResponse.getResult()); return RestResponse.successResult(serviceResponse.getResult());
} }
...@@ -1436,7 +1482,7 @@ public class WxStaffController extends WebBaseController { ...@@ -1436,7 +1482,7 @@ public class WxStaffController extends WebBaseController {
* @return * @return
*/ */
@RequestMapping(value = "/getCountHaoBanStoreIdsByClerkId", method = RequestMethod.GET) @RequestMapping(value = "/getCountHaoBanStoreIdsByClerkId", method = RequestMethod.GET)
public RestResponse<StoreRoleVO> getCountHaoBanStoreIdsByClerkId(String clerkId,String wxEnterpriseId) { public RestResponse<StoreRoleVO> getCountHaoBanStoreIdsByClerkId(String clerkId, String wxEnterpriseId) {
StoreRoleDTO storeRoleDTO = staffApiService.getCountHaoBanStoreIdsByClerkId(clerkId, wxEnterpriseId); StoreRoleDTO storeRoleDTO = staffApiService.getCountHaoBanStoreIdsByClerkId(clerkId, wxEnterpriseId);
StoreRoleVO storeRoleVO = new StoreRoleVO(); StoreRoleVO storeRoleVO = new StoreRoleVO();
storeRoleVO.setStoreCount(storeRoleDTO.getStoreCount()); storeRoleVO.setStoreCount(storeRoleDTO.getStoreCount());
...@@ -1451,7 +1497,7 @@ public class WxStaffController extends WebBaseController { ...@@ -1451,7 +1497,7 @@ public class WxStaffController extends WebBaseController {
* @return * @return
*/ */
@RequestMapping(value = "/getHaoBanStoreIdsRolesByClerkId", method = RequestMethod.GET) @RequestMapping(value = "/getHaoBanStoreIdsRolesByClerkId", method = RequestMethod.GET)
public RestResponse<List<String>> getHaoBanStoreIdsRolesByClerkId(String clerkId,String wxEnterpriseId) { public RestResponse<List<String>> getHaoBanStoreIdsRolesByClerkId(String clerkId, String wxEnterpriseId) {
List<String> storeIds = staffApiService.getHaoBanStoreIdsRolesByClerkId(clerkId, wxEnterpriseId); List<String> storeIds = staffApiService.getHaoBanStoreIdsRolesByClerkId(clerkId, wxEnterpriseId);
return RestResponse.successResult(storeIds); return RestResponse.successResult(storeIds);
} }
...@@ -1462,13 +1508,14 @@ public class WxStaffController extends WebBaseController { ...@@ -1462,13 +1508,14 @@ public class WxStaffController extends WebBaseController {
* @return * @return
*/ */
@RequestMapping(value = "/getEnterpriseStoreListByStaffId", method = RequestMethod.GET) @RequestMapping(value = "/getEnterpriseStoreListByStaffId", method = RequestMethod.GET)
public RestResponse<List<StaffStoreVO>> getEnterpriseStoreListByStaffId(String staffId,String wxEnterpriseId ,Integer manageFlag, String gicEnterpriseId) { public RestResponse<List<StaffStoreVO>> getEnterpriseStoreListByStaffId(String staffId, String wxEnterpriseId,
Integer manageFlag, String gicEnterpriseId) {
if (manageFlag == null) { if (manageFlag == null) {
return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_2.getCode()), HaoBanErrCode.ERR_2.getMsg()); return RestResponse.failure(Convert.toStr(HaoBanErrCode.ERR_2.getCode()), HaoBanErrCode.ERR_2.getMsg());
} }
List<StaffClerkRelationDTO> bindRelationList = new ArrayList<>(); List<StaffClerkRelationDTO> bindRelationList = new ArrayList<>();
List<StaffStoreVO> list = new ArrayList<>(); List<StaffStoreVO> list = new ArrayList<>();
//区经商户 // 区经商户
if (manageFlag == 1) { if (manageFlag == 1) {
bindRelationList = staffClerkRelationApiService.listManageBindByStaffId(staffId); bindRelationList = staffClerkRelationApiService.listManageBindByStaffId(staffId);
if (CollectionUtils.isEmpty(bindRelationList)) { if (CollectionUtils.isEmpty(bindRelationList)) {
...@@ -1512,8 +1559,9 @@ public class WxStaffController extends WebBaseController { ...@@ -1512,8 +1559,9 @@ public class WxStaffController extends WebBaseController {
} }
return RestResponse.successResult(list); return RestResponse.successResult(list);
} }
//门店列表 // 门店列表
List<EnterpriseDetailDTO> enterpriseList = wxEnterpriseRelatedApiService.listEnterpriseByWxEnterpriseId(wxEnterpriseId); List<EnterpriseDetailDTO> enterpriseList = wxEnterpriseRelatedApiService
.listEnterpriseByWxEnterpriseId(wxEnterpriseId);
if (CollectionUtils.isEmpty(enterpriseList)) { if (CollectionUtils.isEmpty(enterpriseList)) {
logger.info("没有关联任何商户:{}", wxEnterpriseId); logger.info("没有关联任何商户:{}", wxEnterpriseId);
return RestResponse.successResult(); return RestResponse.successResult();
...@@ -1527,7 +1575,8 @@ public class WxStaffController extends WebBaseController { ...@@ -1527,7 +1575,8 @@ public class WxStaffController extends WebBaseController {
return RestResponse.successResult(); return RestResponse.successResult();
} }
Map<String, EnterpriseDetailDTO> enterpriseTypeMap = enterpriseList.stream().collect(Collectors.toMap(dto -> dto.getEnterpriseId(), dto -> dto)); Map<String, EnterpriseDetailDTO> enterpriseTypeMap = enterpriseList.stream()
.collect(Collectors.toMap(dto -> dto.getEnterpriseId(), dto -> dto));
bindRelationList = staffClerkRelationApiService.listBindCodeByStaffId(enterpriseIdList, staffId); bindRelationList = staffClerkRelationApiService.listBindCodeByStaffId(enterpriseIdList, staffId);
if (CollectionUtils.isEmpty(bindRelationList)) { if (CollectionUtils.isEmpty(bindRelationList)) {
logger.info("没有关联任何商户导购:{}", wxEnterpriseId); logger.info("没有关联任何商户导购:{}", wxEnterpriseId);
...@@ -1561,7 +1610,7 @@ public class WxStaffController extends WebBaseController { ...@@ -1561,7 +1610,7 @@ public class WxStaffController extends WebBaseController {
if (enterpriseDTO == null) { if (enterpriseDTO == null) {
continue; continue;
} }
//主门店标志 // 主门店标志
int mainStoreFlag = 0; int mainStoreFlag = 0;
EnterpriseDetailDTO enterpriseDetailDTO = enterpriseTypeMap.get(enterpriseId); EnterpriseDetailDTO enterpriseDetailDTO = enterpriseTypeMap.get(enterpriseId);
staffDepartmentRelatedApiService.listByStaffId(staffId); staffDepartmentRelatedApiService.listByStaffId(staffId);
...@@ -1592,8 +1641,9 @@ public class WxStaffController extends WebBaseController { ...@@ -1592,8 +1641,9 @@ public class WxStaffController extends WebBaseController {
} }
List<String> storeIdList = list.stream().map(dto -> dto.getStoreId()).collect(Collectors.toList()); List<String> storeIdList = list.stream().map(dto -> dto.getStoreId()).collect(Collectors.toList());
// 处理主门店 // 处理主门店
if(StringUtils.isBlank(gicEnterpriseId)) { if (StringUtils.isBlank(gicEnterpriseId)) {
ClerkMainStoreRelatedDTO mainDTO = clerkMainStoreRelatedApiService.getWxEnterpriseIdAndStaffId(wxEnterpriseId, staffId, storeIdList); ClerkMainStoreRelatedDTO mainDTO = clerkMainStoreRelatedApiService
.getWxEnterpriseIdAndStaffId(wxEnterpriseId, staffId, storeIdList);
String mainStoreId = mainDTO == null ? "" : mainDTO.getStoreId(); String mainStoreId = mainDTO == null ? "" : mainDTO.getStoreId();
if (null != mainStoreId) { if (null != mainStoreId) {
list.forEach(item -> { list.forEach(item -> {
...@@ -1616,60 +1666,65 @@ public class WxStaffController extends WebBaseController { ...@@ -1616,60 +1666,65 @@ public class WxStaffController extends WebBaseController {
return RestResponse.successResult(0); return RestResponse.successResult(0);
} }
List<Integer> statusFlags = Arrays.asList(3, 4); List<Integer> statusFlags = Arrays.asList(3, 4);
int countExternalClerk = externalClerkRelatedApiService.getCountExternalClerk(staff.getWxEnterpriseId(), staffId, statusFlags); int countExternalClerk = externalClerkRelatedApiService.getCountExternalClerk(staff.getWxEnterpriseId(),
staffId, statusFlags);
return RestResponse.successResult(countExternalClerk); return RestResponse.successResult(countExternalClerk);
} }
// 区经门店列表 // 区经门店列表
@RequestMapping("/list-clerk-store") @RequestMapping("/list-clerk-store")
public RestResponse<Object> listClerkStore(String wxEnterpriseId , String enterpriseId,String clerkId, @RequestParam(defaultValue="20")int pageSize , @RequestParam(defaultValue="1")int currentPage , String storeSearchParams) { public RestResponse<Object> listClerkStore(String wxEnterpriseId, String enterpriseId, String clerkId,
List<String> storeIdList = this.staffApiService.getHaoBanStoreIdsRolesByClerkId(clerkId, wxEnterpriseId) ; @RequestParam(defaultValue = "20") int pageSize, @RequestParam(defaultValue = "1") int currentPage,
String storeSearchParams) {
List<String> storeIdList = this.staffApiService.getHaoBanStoreIdsRolesByClerkId(clerkId, wxEnterpriseId);
if (CollectionUtils.isEmpty(storeIdList)) { if (CollectionUtils.isEmpty(storeIdList)) {
return RestResponse.failure("-1", "无授权门店"); return RestResponse.failure("-1", "无授权门店");
} }
List<StoreListVO> voList = new ArrayList<>(); List<StoreListVO> voList = new ArrayList<>();
int totalCount = 0 ; int totalCount = 0;
List<StoreDTO> storeDTOList = new ArrayList<>() ; List<StoreDTO> storeDTOList = new ArrayList<>();
if(storeIdList.get(0).contains("-1")) { if (storeIdList.get(0).contains("-1")) {
String storeWidgetId = this.powerService.getStoreWidgetId(new Date(), clerkId); String storeWidgetId = this.powerService.getStoreWidgetId(new Date(), clerkId);
logger.info("权限-所有门店storeWidgetId={}",storeWidgetId); logger.info("权限-所有门店storeWidgetId={}", storeWidgetId);
Page<Object> pageParam = new Page<Object>(); Page<Object> pageParam = new Page<Object>();
pageParam.setCurrentPage(currentPage); pageParam.setCurrentPage(currentPage);
pageParam.setPageSize(pageSize); pageParam.setPageSize(pageSize);
Page<StoreDTO> page = storeWidgetService.getStoreWidgetStore(storeWidgetId, null, enterpriseId, pageParam, null,null); Page<StoreDTO> page = storeWidgetService.getStoreWidgetStore(storeWidgetId, null, enterpriseId, pageParam,
null, null);
if (page != null) { if (page != null) {
storeDTOList = page.getResult(); storeDTOList = page.getResult();
totalCount = page.getTotalCount(); totalCount = page.getTotalCount();
} }
}else { } else {
totalCount = storeIdList.size(); totalCount = storeIdList.size();
int start = pageSize * (currentPage-1) ; int start = pageSize * (currentPage - 1);
if(start<totalCount) { if (start < totalCount) {
int end = start +pageSize ; int end = start + pageSize;
if(end>totalCount) { if (end > totalCount) {
end = totalCount ; end = totalCount;
} }
List<String> subStoreIdList = storeIdList.subList(start, end) ; List<String> subStoreIdList = storeIdList.subList(start, end);
if(CollectionUtils.isNotEmpty(subStoreIdList)) { if (CollectionUtils.isNotEmpty(subStoreIdList)) {
logger.info("分页当前页storeid数={}",subStoreIdList.size()); logger.info("分页当前页storeid数={}", subStoreIdList.size());
String[] arr = new String[subStoreIdList.size()] ; String[] arr = new String[subStoreIdList.size()];
List<StoreDTO> storeList = this.storeService.getStores(subStoreIdList.toArray(arr)); List<StoreDTO> storeList = this.storeService.getStores(subStoreIdList.toArray(arr));
Map<String,StoreDTO> storeMap = storeList.stream().collect(Collectors.toMap(StoreDTO::getStoreId, o->o,(k1,k2)->k1)) ; Map<String, StoreDTO> storeMap = storeList.stream()
for(String id : subStoreIdList) { .collect(Collectors.toMap(StoreDTO::getStoreId, o -> o, (k1, k2) -> k1));
if(null != storeMap.get(id)) { for (String id : subStoreIdList) {
storeDTOList.add(storeMap.get(id)) ; if (null != storeMap.get(id)) {
storeDTOList.add(storeMap.get(id));
} }
} }
} }
} }
} }
if(CollectionUtils.isNotEmpty(storeDTOList)) { if (CollectionUtils.isNotEmpty(storeDTOList)) {
for(StoreDTO store : storeDTOList) { for (StoreDTO store : storeDTOList) {
StoreListVO vo = new StoreListVO(); StoreListVO vo = new StoreListVO();
vo.setStoreId(store.getStoreId()); vo.setStoreId(store.getStoreId());
vo.setStoreName(store.getStoreName()); vo.setStoreName(store.getStoreName());
vo.setStoreCode(store.getStoreCode()); vo.setStoreCode(store.getStoreCode());
voList.add(vo) ; voList.add(vo);
} }
} }
Page<StoreListVO> page = new Page<>(); Page<StoreListVO> page = new Page<>();
...@@ -1680,19 +1735,19 @@ public class WxStaffController extends WebBaseController { ...@@ -1680,19 +1735,19 @@ public class WxStaffController extends WebBaseController {
return RestResponse.successResult(page); return RestResponse.successResult(page);
} }
@RequestMapping("/search-clerk-store-page") @RequestMapping("/search-clerk-store-page")
public RestResponse<Object> listClerkStorePage(String wxEnterpriseId , String enterpriseId,String clerkId, @RequestParam(defaultValue="20")int pageSize , @RequestParam(defaultValue="1")int currentPage , String storeSearchParams) { public RestResponse<Object> listClerkStorePage(String wxEnterpriseId, String enterpriseId, String clerkId,
@RequestParam(defaultValue = "20") int pageSize, @RequestParam(defaultValue = "1") int currentPage,
String storeSearchParams) {
// 如果有权限控制,进行管辖门店过0滤 // 如果有权限控制,进行管辖门店过0滤
List<String> authStoreIdList = this.staffApiService.getHaoBanStoreIdsRolesByClerkId(clerkId, wxEnterpriseId); List<String> authStoreIdList = this.staffApiService.getHaoBanStoreIdsRolesByClerkId(clerkId, wxEnterpriseId);
if (CollectionUtils.isEmpty(authStoreIdList)) { if (CollectionUtils.isEmpty(authStoreIdList)) {
return RestResponse.failure("-1", "无授权门店"); return RestResponse.failure("-1", "无授权门店");
} }
Page page = this.page(wxEnterpriseId, enterpriseId, clerkId, pageSize, currentPage, storeSearchParams, authStoreIdList) ; Page page = this.page(wxEnterpriseId, enterpriseId, clerkId, pageSize, currentPage, storeSearchParams,
authStoreIdList);
List<StoreDTO> storeList = (List<StoreDTO>) page.getResult(); List<StoreDTO> storeList = (List<StoreDTO>) page.getResult();
List<StoreListVO> retList = this.toList(storeList) ; List<StoreListVO> retList = this.toList(storeList);
Page<StoreListVO> retPage = new Page<>(); Page<StoreListVO> retPage = new Page<>();
retPage.setResult(retList); retPage.setResult(retList);
retPage.setTotalCount(page.getTotalCount()); retPage.setTotalCount(page.getTotalCount());
...@@ -1701,15 +1756,16 @@ public class WxStaffController extends WebBaseController { ...@@ -1701,15 +1756,16 @@ public class WxStaffController extends WebBaseController {
return RestResponse.successResult(retPage); return RestResponse.successResult(retPage);
} }
private Page page(String wxEnterpriseId, String enterpriseId, String clerkId,
private Page page(String wxEnterpriseId , String enterpriseId,String clerkId, @RequestParam(defaultValue="20")int pageSize , @RequestParam(defaultValue="1")int currentPage , String storeSearchParams , List<String> authStoreIdList) { @RequestParam(defaultValue = "20") int pageSize, @RequestParam(defaultValue = "1") int currentPage,
String storeSearchParams, List<String> authStoreIdList) {
StoreSearchDTO searchDTO = new StoreSearchDTO(); StoreSearchDTO searchDTO = new StoreSearchDTO();
searchDTO.setRecycleStoreCount(0); searchDTO.setRecycleStoreCount(0);
searchDTO.setMemberCountFlag(0); searchDTO.setMemberCountFlag(0);
searchDTO.setSearchName(storeSearchParams); searchDTO.setSearchName(storeSearchParams);
// 企业ID // 企业ID
searchDTO.setEnterpriseId(enterpriseId); searchDTO.setEnterpriseId(enterpriseId);
if(!authStoreIdList.contains("-1")) { if (!authStoreIdList.contains("-1")) {
searchDTO.setAuthStoreIdList(authStoreIdList); searchDTO.setAuthStoreIdList(authStoreIdList);
} }
// 门店参数 // 门店参数
...@@ -1722,10 +1778,10 @@ public class WxStaffController extends WebBaseController { ...@@ -1722,10 +1778,10 @@ public class WxStaffController extends WebBaseController {
logger.info("查询条件={}", JSON.toJSONString(page)); logger.info("查询条件={}", JSON.toJSONString(page));
Map<String, Object> result = storeService.getStoreListPage(page); Map<String, Object> result = storeService.getStoreListPage(page);
page = (Page) result.get("page"); page = (Page) result.get("page");
return page ; return page;
} }
private List<StoreListVO> toList(List<StoreDTO> storeList){ private List<StoreListVO> toList(List<StoreDTO> storeList) {
List<StoreListVO> retList = new ArrayList<StoreListVO>(); List<StoreListVO> retList = new ArrayList<StoreListVO>();
StoreListVO vo = null; StoreListVO vo = null;
for (StoreDTO dto : storeList) { for (StoreDTO dto : storeList) {
...@@ -1735,21 +1791,22 @@ public class WxStaffController extends WebBaseController { ...@@ -1735,21 +1791,22 @@ public class WxStaffController extends WebBaseController {
vo.setStoreCode(dto.getStoreCode()); vo.setStoreCode(dto.getStoreCode());
retList.add(vo); retList.add(vo);
} }
return retList ; return retList;
} }
//区经门店查询 // 区经门店查询
@RequestMapping("search-clerk-store") @RequestMapping("search-clerk-store")
public RestResponse<Object> listClerkStoreByParams(String wxEnterpriseId, String enterpriseId, String clerkId, String storeSearchParams) { public RestResponse<Object> listClerkStoreByParams(String wxEnterpriseId, String enterpriseId, String clerkId,
if(StringUtils.isEmpty(storeSearchParams)) { String storeSearchParams) {
return RestResponse.failure("-1", "查询条件为空") ; if (StringUtils.isEmpty(storeSearchParams)) {
return RestResponse.failure("-1", "查询条件为空");
} }
// 如果有权限控制,进行管辖门店过0滤 // 如果有权限控制,进行管辖门店过0滤
List<String> authStoreIdList = this.staffApiService.getHaoBanStoreIdsRolesByClerkId(clerkId, wxEnterpriseId); List<String> authStoreIdList = this.staffApiService.getHaoBanStoreIdsRolesByClerkId(clerkId, wxEnterpriseId);
if (CollectionUtils.isEmpty(authStoreIdList)) { if (CollectionUtils.isEmpty(authStoreIdList)) {
return RestResponse.failure("-1", "无授权门店"); return RestResponse.failure("-1", "无授权门店");
} }
Page page = this.page(wxEnterpriseId, enterpriseId, clerkId, 20, 1, storeSearchParams, authStoreIdList) ; Page page = this.page(wxEnterpriseId, enterpriseId, clerkId, 20, 1, storeSearchParams, authStoreIdList);
List<StoreDTO> storeList = (List<StoreDTO>) page.getResult(); List<StoreDTO> storeList = (List<StoreDTO>) page.getResult();
return RestResponse.successResult(toList(storeList)); return RestResponse.successResult(toList(storeList));
} }
...@@ -1758,30 +1815,33 @@ public class WxStaffController extends WebBaseController { ...@@ -1758,30 +1815,33 @@ public class WxStaffController extends WebBaseController {
* 门店导购查询 * 门店导购查询
*/ */
@RequestMapping("list-clerk") @RequestMapping("list-clerk")
public RestResponse<Object> listClerk(String enterpriseId , String wxEnterpriseId , String clerkId ,String clerkSearchParams , BasePageInfo basePageInfo) { public RestResponse<Object> listClerk(String enterpriseId, String wxEnterpriseId, String clerkId,
ClerkDTO clerk = this.clerkService.getclerkById(clerkId) ; String clerkSearchParams, BasePageInfo basePageInfo) {
int clerkType = clerk.getClerkType() ; ClerkDTO clerk = this.clerkService.getclerkById(clerkId);
List<ClerkListVO> resultList = null ; int clerkType = clerk.getClerkType();
if(clerkType != 1) { List<ClerkListVO> resultList = null;
if (clerkType != 1) {
return RestResponse.failure("-1", "非店长身份"); return RestResponse.failure("-1", "非店长身份");
} }
List<ClerkListDTO> clerkList = clerkService.getClerkByStoreId(enterpriseId, clerk.getStoreId()); List<ClerkListDTO> clerkList = clerkService.getClerkByStoreId(enterpriseId, clerk.getStoreId());
if (CollectionUtils.isNotEmpty(clerkList) && StringUtils.isNotEmpty(clerkSearchParams)) { if (CollectionUtils.isNotEmpty(clerkList) && StringUtils.isNotEmpty(clerkSearchParams)) {
clerkList = clerkList.stream().filter(dto->dto.getClerkCode().contains(clerkSearchParams) || dto.getClerkName().contains(clerkSearchParams)).collect(Collectors.toList()) ; clerkList = clerkList.stream().filter(dto -> dto.getClerkCode().contains(clerkSearchParams)
|| dto.getClerkName().contains(clerkSearchParams)).collect(Collectors.toList());
} }
if (CollectionUtils.isEmpty(clerkList)) { if (CollectionUtils.isEmpty(clerkList)) {
return RestResponse.failure("-1", "无导购"); return RestResponse.failure("-1", "无导购");
} }
resultList = EntityUtil.changeEntityListByJSON(ClerkListVO.class, clerkList); resultList = EntityUtil.changeEntityListByJSON(ClerkListVO.class, clerkList);
List<String> clerkIdList = resultList.stream().map(dto->dto.getClerkId()).collect(Collectors.toList()) ; List<String> clerkIdList = resultList.stream().map(dto -> dto.getClerkId()).collect(Collectors.toList());
List<StaffClerkRelationDTO> relationList = this.staffClerkRelationApiService.listByClerkIdsWxEnterpriseId(clerkIdList, wxEnterpriseId) ; List<StaffClerkRelationDTO> relationList = this.staffClerkRelationApiService
if(CollectionUtils.isEmpty(relationList)) { .listByClerkIdsWxEnterpriseId(clerkIdList, wxEnterpriseId);
if (CollectionUtils.isEmpty(relationList)) {
return RestResponse.failure("-1", "无导购"); return RestResponse.failure("-1", "无导购");
} }
List<String> retlationIdList = relationList.stream().map(dto->dto.getClerkId()).collect(Collectors.toList()) ; List<String> retlationIdList = relationList.stream().map(dto -> dto.getClerkId()).collect(Collectors.toList());
resultList.removeIf(item->{ resultList.removeIf(item -> {
return !retlationIdList.contains(item.getClerkId()) ; return !retlationIdList.contains(item.getClerkId());
}) ; });
Page<ClerkListVO> retPage = new Page<>(); Page<ClerkListVO> retPage = new Page<>();
retPage.setPageSize(resultList.size()); retPage.setPageSize(resultList.size());
retPage.setCurrentPage(1); retPage.setCurrentPage(1);
...@@ -1795,21 +1855,33 @@ public class WxStaffController extends WebBaseController { ...@@ -1795,21 +1855,33 @@ public class WxStaffController extends WebBaseController {
* 判断成员是否授权获取敏感信息 * 判断成员是否授权获取敏感信息
*/ */
@RequestMapping("get-sensitive-status") @RequestMapping("get-sensitive-status")
public RestResponse<Object> getSensitiveStatus(String staffId){ public RestResponse<Object> getSensitiveStatus(String staffId) {
int result = staffApiService.getSensitiveStatus(staffId); int result = staffApiService.getSensitiveStatus(staffId);
return RestResponse.successResult(result) ; return RestResponse.successResult(result);
} }
@RequestMapping("update-qr-code") @RequestMapping("update-qr-code")
public RestResponse<Object> updateQrCode(String staffId , String qrCode){ public RestResponse<Object> updateQrCode(String staffId, String qrCode) {
this.staffApiService.updateQrCodeByStaffId(staffId, qrCode) ; this.staffApiService.updateQrCodeByStaffId(staffId, qrCode);
return RestResponse.successResult() ; return RestResponse.successResult();
} }
// 判断是否有内容中台权限 // 判断是否有内容中台权限
@RequestMapping("hascontent-right") @RequestMapping("has-content-right")
public RestResponse<Object> hasContentRight(String enterpriseId , String staffId) { public RestResponse<Object> hasContentRight(String enterpriseId) {
this.enterpriseUseForbidService.getUseEnterpriseByCode("", enterpriseId) ; ServiceResponse<List<EnterpriseUsingStatusDTO>> resp = this.enterpriseUseForbidService.getUseEnterpriseByCode(EnterpriseServiceEnum.CONTENT.getRightMenuCode(), enterpriseId);
return RestResponse.successResult(true) ; logger.info("内容中台权限={},{}",JSON.toJSONString(resp),enterpriseId);
List<EnterpriseUsingStatusDTO> list = resp.getResult() ;
RightVO vo = new RightVO();
if(CollectionUtils.isEmpty(list)) {
return RestResponse.successResult(vo);
}
EnterpriseUsingStatusDTO dto = list.get(0) ;
if(dto.getVaild()) {
vo.setStatus(1);
}else {
vo.setStatus(2);
}
return RestResponse.successResult(vo);
} }
} }
package com.gic.haoban.manage.web.vo;
import java.io.Serializable;
public class RightVO implements Serializable{
/**
* @Fields serialVersionUID : TODO(用一句话描述这个变量表示什么)
*/
private static final long serialVersionUID = 70105969355665707L;
// 0未购买 1正常 2已过期
private int status ;
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
}
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