Commit 1987bab9 by 徐高华

停用主门店

parent bba94ca4
package com.gic.haoban.manage.api.service; package com.gic.haoban.manage.api.service;
import java.util.List;
import com.gic.haoban.manage.api.dto.ClerkMainStoreRelatedDTO; import com.gic.haoban.manage.api.dto.ClerkMainStoreRelatedDTO;
public interface ClerkMainStoreRelatedApiService { public interface ClerkMainStoreRelatedApiService {
...@@ -7,6 +9,8 @@ public interface ClerkMainStoreRelatedApiService { ...@@ -7,6 +9,8 @@ public interface ClerkMainStoreRelatedApiService {
void setMainStore(String staffId, String storeId, String wxEnterpriseId); void setMainStore(String staffId, String storeId, String wxEnterpriseId);
ClerkMainStoreRelatedDTO getWxEnterpriseIdAndStaffId(String wxEnterpriseId, String staffId); ClerkMainStoreRelatedDTO getWxEnterpriseIdAndStaffId(String wxEnterpriseId, String staffId);
ClerkMainStoreRelatedDTO getWxEnterpriseIdAndStaffId(String wxEnterpriseId, String staffId , List<String> storeIdList);
/** /**
* 设置刷新好友状态为已刷新 * 设置刷新好友状态为已刷新
......
...@@ -20,7 +20,7 @@ public interface TabHaobanClerkMainStoreRelatedMapper { ...@@ -20,7 +20,7 @@ public interface TabHaobanClerkMainStoreRelatedMapper {
int updateByPrimaryKey(TabHaobanClerkMainStoreRelated record); int updateByPrimaryKey(TabHaobanClerkMainStoreRelated record);
TabHaobanClerkMainStoreRelated selectByWxEnterpriseIdAndStoreId(@Param("staffId")String staffId, @Param("wxEnterpriseId")String wxEnterpriseId); TabHaobanClerkMainStoreRelated selectByWxEnterpriseIdAndStoreId(@Param("staffId")String staffId, @Param("wxEnterpriseId")String wxEnterpriseId , @Param("storeIdList") List<String> storeIdList);
List<TabHaobanClerkMainStoreRelated> listByWxEnterpriseId(@Param("wxEnterpriseId")String wxEnterpriseId); List<TabHaobanClerkMainStoreRelated> listByWxEnterpriseId(@Param("wxEnterpriseId")String wxEnterpriseId);
...@@ -32,6 +32,8 @@ public interface TabHaobanClerkMainStoreRelatedMapper { ...@@ -32,6 +32,8 @@ public interface TabHaobanClerkMainStoreRelatedMapper {
* @param wxEnterpriseId * @param wxEnterpriseId
*/ */
void delMainStore(@Param("staffId") String staffId, @Param("storeId") String storeId, @Param("wxEnterpriseId") String wxEnterpriseId); void delMainStore(@Param("staffId") String staffId, @Param("storeId") String storeId, @Param("wxEnterpriseId") String wxEnterpriseId);
void delStaffMainStore(@Param("staffId") String staffId, @Param("wxEnterpriseId") String wxEnterpriseId);
/** /**
* 删除门店 * 删除门店
......
...@@ -19,6 +19,8 @@ public interface ClerkMainStoreRelatedService { ...@@ -19,6 +19,8 @@ public interface ClerkMainStoreRelatedService {
* @return * @return
*/ */
TabHaobanClerkMainStoreRelated getMainStoreByStaffId(String staffId, String wxEnterpriseId); TabHaobanClerkMainStoreRelated getMainStoreByStaffId(String staffId, String wxEnterpriseId);
TabHaobanClerkMainStoreRelated getMainStoreByStaffId(String staffId, String wxEnterpriseId, List<String> storeIdList);
/** /**
* 删除主门店 并删除主门店好友 设置新主门店 * 删除主门店 并删除主门店好友 设置新主门店
......
...@@ -45,7 +45,7 @@ public class ClerkMainStoreRelatedServiceImpl implements ClerkMainStoreRelatedSe ...@@ -45,7 +45,7 @@ public class ClerkMainStoreRelatedServiceImpl implements ClerkMainStoreRelatedSe
@Override @Override
public TabHaobanClerkMainStoreRelated selectByWxEnterpriseIdAndStoreId(String staffId, String wxEnterpriseId) { public TabHaobanClerkMainStoreRelated selectByWxEnterpriseIdAndStoreId(String staffId, String wxEnterpriseId) {
return mapper.selectByWxEnterpriseIdAndStoreId(staffId, wxEnterpriseId); return mapper.selectByWxEnterpriseIdAndStoreId(staffId, wxEnterpriseId,null);
} }
@Override @Override
...@@ -78,16 +78,22 @@ public class ClerkMainStoreRelatedServiceImpl implements ClerkMainStoreRelatedSe ...@@ -78,16 +78,22 @@ public class ClerkMainStoreRelatedServiceImpl implements ClerkMainStoreRelatedSe
@Override @Override
public TabHaobanClerkMainStoreRelated getMainStoreByStaffId(String staffId, String wxEnterpriseId) { public TabHaobanClerkMainStoreRelated getMainStoreByStaffId(String staffId, String wxEnterpriseId) {
TabHaobanClerkMainStoreRelated mainStoreRelated = mapper.selectByWxEnterpriseIdAndStoreId(staffId, wxEnterpriseId); TabHaobanClerkMainStoreRelated mainStoreRelated = mapper.selectByWxEnterpriseIdAndStoreId(staffId, wxEnterpriseId,null);
if (null != mainStoreRelated) { if (null != mainStoreRelated) {
//String storeId = mainStoreRelated.getStoreId();
//StaffClerkRelationDTO staffClerkRelationDTO = staffClerkRelationService.getOneBindByStoreId(staffId, storeId);
//if (staffClerkRelationDTO == null) {
// logger.info("该主门店无绑定关系,重新绑定,staffId:{},storeId:{}", staffId, storeId);
// return delMainStore(staffId, storeId, wxEnterpriseId);
//}
return mainStoreRelated; return mainStoreRelated;
} }
return setStaffMainStore(staffId, wxEnterpriseId);
}
@Override
public TabHaobanClerkMainStoreRelated getMainStoreByStaffId(String staffId, String wxEnterpriseId,
List<String> storeIdList) {
TabHaobanClerkMainStoreRelated mainStoreRelated = mapper.selectByWxEnterpriseIdAndStoreId(staffId, wxEnterpriseId,storeIdList);
if (null != mainStoreRelated) {
return mainStoreRelated;
}
this.mapper.delStaffMainStore(staffId, wxEnterpriseId);
return setStaffMainStore(staffId, wxEnterpriseId); return setStaffMainStore(staffId, wxEnterpriseId);
} }
...@@ -106,10 +112,10 @@ public class ClerkMainStoreRelatedServiceImpl implements ClerkMainStoreRelatedSe ...@@ -106,10 +112,10 @@ public class ClerkMainStoreRelatedServiceImpl implements ClerkMainStoreRelatedSe
StaffClerkRelationDTO staffClerkRelationDTO = clerkRelationDTOS.get(0); StaffClerkRelationDTO staffClerkRelationDTO = clerkRelationDTOS.get(0);
String lockKey = "set-main-store:" + staffId; String lockKey = "set-main-store:" + staffId;
RedisUtil.lock(lockKey, 3L); RedisUtil.lock(lockKey, 3L);
TabHaobanClerkMainStoreRelated mainStoreRelated = mapper.selectByWxEnterpriseIdAndStoreId(staffId, wxEnterpriseId); TabHaobanClerkMainStoreRelated mainStoreRelated = mapper.selectByWxEnterpriseIdAndStoreId(staffId, wxEnterpriseId,null);
if (null == mainStoreRelated) { if (null == mainStoreRelated) {
this.setMainStore(staffId, staffClerkRelationDTO.getStoreId(), wxEnterpriseId); this.setMainStore(staffId, staffClerkRelationDTO.getStoreId(), wxEnterpriseId);
mainStoreRelated = mapper.selectByWxEnterpriseIdAndStoreId(staffId, wxEnterpriseId); mainStoreRelated = mapper.selectByWxEnterpriseIdAndStoreId(staffId, wxEnterpriseId,null);
} }
RedisUtil.unlock(lockKey); RedisUtil.unlock(lockKey);
return mainStoreRelated; return mainStoreRelated;
......
...@@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date; import java.util.Date;
import java.util.List;
import static org.slf4j.LoggerFactory.getLogger; import static org.slf4j.LoggerFactory.getLogger;
...@@ -39,6 +40,12 @@ public class ClerkMainStoreRelatedApiServiceImpl implements ClerkMainStoreRelate ...@@ -39,6 +40,12 @@ public class ClerkMainStoreRelatedApiServiceImpl implements ClerkMainStoreRelate
public ClerkMainStoreRelatedDTO getWxEnterpriseIdAndStaffId(String wxEnterpriseId, String staffId) { public ClerkMainStoreRelatedDTO getWxEnterpriseIdAndStaffId(String wxEnterpriseId, String staffId) {
return EntityUtil.changeEntityByJSON(ClerkMainStoreRelatedDTO.class, clerkMainStoreRelatedService.getMainStoreByStaffId(staffId, wxEnterpriseId)); return EntityUtil.changeEntityByJSON(ClerkMainStoreRelatedDTO.class, clerkMainStoreRelatedService.getMainStoreByStaffId(staffId, wxEnterpriseId));
} }
@Override
public ClerkMainStoreRelatedDTO getWxEnterpriseIdAndStaffId(String wxEnterpriseId, String staffId,
List<String> storeIdList) {
return EntityUtil.changeEntityByJSON(ClerkMainStoreRelatedDTO.class, clerkMainStoreRelatedService.getMainStoreByStaffId(staffId, wxEnterpriseId,storeIdList));
}
@Override @Override
public void setFreshFriend(String wxEnterpriseId, String staffId) { public void setFreshFriend(String wxEnterpriseId, String staffId) {
......
...@@ -148,6 +148,12 @@ ...@@ -148,6 +148,12 @@
where staff_id = #{staffId,jdbcType=VARCHAR} where staff_id = #{staffId,jdbcType=VARCHAR}
and wx_enterprise_id = #{wxEnterpriseId} and wx_enterprise_id = #{wxEnterpriseId}
and status_flag = 1 and status_flag = 1
<if test="null != storeIdList">
and store_id IN
<foreach collection="storeIdList" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
limit 1 limit 1
</select> </select>
...@@ -171,7 +177,18 @@ ...@@ -171,7 +177,18 @@
and wx_enterprise_id = #{wxEnterpriseId} and wx_enterprise_id = #{wxEnterpriseId}
and status_flag = 1 and status_flag = 1
</update> </update>
<update id="delStaffMainStore">
update tab_haoban_clerk_main_store_related
set
status_flag = 0,
update_time = now()
where
staff_id=#{staffId}
and wx_enterprise_id = #{wxEnterpriseId}
and status_flag = 1
</update>
<update id="delByStoreIds"> <update id="delByStoreIds">
update tab_haoban_clerk_main_store_related update tab_haoban_clerk_main_store_related
set set
......
...@@ -116,9 +116,6 @@ public class StoreController extends WebBaseController { ...@@ -116,9 +116,6 @@ public class StoreController extends WebBaseController {
logger.info("没有关联任何商户导购:{}", wxEnterpriseId); logger.info("没有关联任何商户导购:{}", wxEnterpriseId);
return resultResponse(HaoBanErrCode.ERR_1); return resultResponse(HaoBanErrCode.ERR_1);
} }
//主门店
ClerkMainStoreRelatedDTO mainDTO = clerkMainStoreRelatedApiService.getWxEnterpriseIdAndStaffId(wxEnterpriseId, staffId);
String mainStoreId = mainDTO == null ? "" : mainDTO.getStoreId();
Map<String,Boolean> map = new HashMap<>(); Map<String,Boolean> map = new HashMap<>();
for (StaffClerkRelationDTO staffClerkRelationDTO : bindRelationList) { for (StaffClerkRelationDTO staffClerkRelationDTO : bindRelationList) {
String storeId = staffClerkRelationDTO.getStoreId() ; String storeId = staffClerkRelationDTO.getStoreId() ;
...@@ -168,9 +165,6 @@ public class StoreController extends WebBaseController { ...@@ -168,9 +165,6 @@ public class StoreController extends WebBaseController {
} }
//主门店标志 //主门店标志
int mainStoreFlag = 0; int mainStoreFlag = 0;
if (mainStoreId.equals(store.getStoreId())) {
mainStoreFlag = 1;
}
EnterpriseDetailDTO enterpriseDetailDTO = enterpriseTypeMap.get(enterpriseId); EnterpriseDetailDTO enterpriseDetailDTO = enterpriseTypeMap.get(enterpriseId);
staffDepartmentRelatedApiService.listByStaffId(staffId); staffDepartmentRelatedApiService.listByStaffId(staffId);
StaffStoreVO vo = new StaffStoreVO(); StaffStoreVO vo = new StaffStoreVO();
...@@ -194,7 +188,20 @@ public class StoreController extends WebBaseController { ...@@ -194,7 +188,20 @@ public class StoreController extends WebBaseController {
vo.setCorpName(wxEnterpriseDTO.getCorpName()); vo.setCorpName(wxEnterpriseDTO.getCorpName());
list.add(vo); list.add(vo);
} }
if(org.apache.commons.collections.CollectionUtils.isEmpty(list)) {
return resultResponse(HaoBanErrCode.ERR_1, list);
}
List<String> storeIdList = list.stream().map(dto->dto.getStoreId()).collect(Collectors.toList()) ;
// 处理主门店
ClerkMainStoreRelatedDTO mainDTO = clerkMainStoreRelatedApiService.getWxEnterpriseIdAndStaffId(wxEnterpriseId, staffId,storeIdList);
String mainStoreId = mainDTO == null ? "" : mainDTO.getStoreId();
if(null != mainStoreId) {
list.forEach(item->{
if(item.getStoreId().equals(mainStoreId)) {
item.setMainStoreFlag(1);
}
});
}
return resultResponse(HaoBanErrCode.ERR_1, list); return resultResponse(HaoBanErrCode.ERR_1, list);
} }
......
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