成功开店代码改造

This commit is contained in:
shuo.wang
2025-07-02 17:53:46 +08:00
parent 8b94e49334
commit cb69bef277
10 changed files with 55 additions and 48 deletions

View File

@@ -2,6 +2,7 @@ package com.cool.store.dao;
import com.cool.store.entity.StoreDO;
import com.cool.store.mapper.StoreMapper;
import com.cool.store.response.MiniShopsResponse;
import com.google.common.collect.Lists;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@@ -63,11 +64,11 @@ public class StoreDao {
return storeMapper.listByMobile(mobile);
}
public List<StoreDO> getSubStoreByRegionIds(List<String> regionIdList) {
if(CollectionUtils.isEmpty(regionIdList)) {
public List<MiniShopsResponse> getSubStoreByRegionIdsAndMobile(List<String> regionIdList, String mobile) {
if(CollectionUtils.isEmpty(regionIdList)&&StringUtils.isBlank(mobile)) {
return new ArrayList<>();
}
return storeMapper.getSubStoreByRegionIds(regionIdList);
return storeMapper.getSubStoreByRegionIdsAndMobile(regionIdList,mobile);
}

View File

@@ -33,7 +33,11 @@ public class SysRoleDao {
if(CollectionUtils.isEmpty(roleIds)) {
return Lists.newArrayList();
}
return sysRoleMapper.getRoleByRoleIds( roleIds);
List<SysRoleDO> roleByRoleIds = sysRoleMapper.getRoleByRoleIds(roleIds);
if(CollectionUtils.isEmpty(roleByRoleIds)) {
return Lists.newArrayList();
}
return roleByRoleIds;
}
/**

View File

@@ -1,6 +1,7 @@
package com.cool.store.mapper;
import com.cool.store.entity.StoreDO;
import com.cool.store.response.MiniShopsResponse;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@@ -31,7 +32,7 @@ public interface StoreMapper {
*/
List<StoreDO> listByMobile(@Param("mobile") String mobile);
List<StoreDO> getSubStoreByRegionIds(@Param("regionIdList") List<String> regionIdList);
List<MiniShopsResponse> getSubStoreByRegionIdsAndMobile(@Param("regionIdList") List<String> regionIdList, @Param("mobile") String mobile);
/**
* 分页查询门店数据
* @return

View File

@@ -90,15 +90,27 @@
</where>
</select>
<select id="getSubStoreByRegionIds" resultMap="BaseResultMap">
select *
<select id="getSubStoreByRegionIdsAndMobile" resultType="com.cool.store.response.MiniShopsResponse">
select store_id as storeId, store_name as shopName, store_num as shopCode, store_address as detailAddress,
from store_${enterpriseId}
where is_delete = 'effective'
and (
<if test="regionIdList != null and regionIdList.size >0 ">
<foreach collection="regionIdList" item="regionId" separator=" or " open="and (" close=" )">
<foreach collection="regionIdList" item="regionId" separator=" or " open=" (" close=" )">
region_path like concat('%/', #{regionId}, '/%')
</foreach>
</if>
<if test="mobile!=null and mobile !=''">
<choose>
<when test="regionIdList != null and regionIdList.size >0 ">
or `extend_field` like concat('%', #{mobile}, '%')
</when>
<otherwise>
`extend_field` like concat('%', #{mobile}, '%')
</otherwise>
</choose>
</if>
)
</select>
<select id="list" resultMap="BaseResultMap">

View File

@@ -20,4 +20,5 @@ public class MiniShopsResponse {
private String ylsCode;
@ApiModelProperty("店铺详细地址")
private String detailAddress;
private String storeId;
}

View File

@@ -107,7 +107,7 @@ public interface ShopService {
Boolean dataHandler(Long shopId);
List<MiniShopsResponse> getShopListSuccessOpen(Long lineId);
PageInfo<MiniShopsResponse> getShopListSuccessOpen(Long lineId,Integer pageNum,Integer pageSize,String storeName);
ShopResponse getShopNameAndCode(Long shopId,Long lineId);

View File

@@ -23,6 +23,6 @@ public interface StoreService {
*/
PageInfo<StoreDTO> getStoreExtendFieldInfo(Integer pageSize,Integer pageNum);
List<StoreDO> getStoreListByMobile(String mobile);
PageInfo<MiniShopsResponse> getStoreListByMobile(String mobile,Integer pageNum,Integer pageSize,String storeName);
}

View File

@@ -600,26 +600,16 @@ public class ShopServiceImpl implements ShopService {
}
@Override
public List<MiniShopsResponse> getShopListSuccessOpen(Long lineId) {
public PageInfo<MiniShopsResponse> getShopListSuccessOpen(Long lineId,Integer pageNum,Integer pageSize,String storeName) {
LineInfoDO lineInfoDO = lineInfoDAO.getLineInfo(lineId);
List<StoreDO> storeDOS = storeDao.listByMobile(lineInfoDO.getMobile());
List<StoreDO> storeListByMobile = storeService.getStoreListByMobile(lineInfoDO.getMobile());
if (CollectionUtils.isEmpty(storeDOS)&&CollectionUtils.isEmpty(storeListByMobile)){
return new ArrayList<>();
PageInfo<MiniShopsResponse> storeListByMobile = storeService.getStoreListByMobile(lineInfoDO.getMobile(),pageNum,pageSize,storeName);
if (CollectionUtils.isEmpty(storeListByMobile.getList())){
return new PageInfo<>();
}
storeDOS.addAll(storeListByMobile);
List<MiniShopsResponse> responses = new ArrayList<>();
for (StoreDO storeDO : storeDOS){
MiniShopsResponse response = new MiniShopsResponse();
response.setShopName(storeDO.getStoreName());
response.setShopCode(storeDO.getStoreNum());
response.setYlsCode("ZXA8_"+storeDO.getStoreNum());
response.setDetailAddress(storeDO.getStoreAddress());
responses.add(response);
for (MiniShopsResponse response : storeListByMobile.getList()){
response.setYlsCode("ZXA8_"+response.getShopCode());
}
//对shopCode 去重
responses = responses.stream().filter(x -> x.getShopCode() != null).distinct().collect(Collectors.toList());
return responses;
return storeListByMobile;
}
@Override

View File

@@ -27,10 +27,7 @@ import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
@@ -72,31 +69,28 @@ public class StoreServiceImpl implements StoreService {
}
@Override
public List<StoreDO> getStoreListByMobile(String mobile) {
public PageInfo<MiniShopsResponse> getStoreListByMobile(String mobile,Integer pageNum,Integer pageSize,String storeName) {
//根据手机号查询 标品userId
EnterpriseUserDO enterpriseUserDO = enterpriseUserDAO.selectByMobile(mobile);
if (enterpriseUserDO == null){
return Collections.emptyList();
return new PageInfo<>();
}
//获取用户职位
List<Long> userRoleIds = enterpriseUserRoleDao.getUserRoleIds(enterpriseUserDO.getUserId());
if (CollectionUtils.isEmpty(userRoleIds)){
return Collections.emptyList();
}
//查询职位详情,筛选掉店外职位
List<SysRoleDO> roleIds = sysRoleDao.selectRoleByRoleIds(userRoleIds);
List<SysRoleDO> sysRoleDOS = roleIds.stream().filter(role -> "store_inside".equals(role.getPositionType())).collect(Collectors.toList());
if (CollectionUtils.isEmpty(sysRoleDOS)){
return Collections.emptyList();
}
List<String> regionIds = new ArrayList<>();
if (CollectionUtils.isNotEmpty(sysRoleDOS)){
//获取用户管辖门店
List<UserAuthMappingDO> userAuthMapping = userAuthMappingService.listUserAuthMappingByUserId(enterpriseUserDO.getUserId());
if(CollectionUtils.isEmpty(userAuthMapping)){
return Collections.emptyList();
if (CollectionUtils.isNotEmpty(userAuthMapping)){
regionIds.addAll(userAuthMapping.stream().map(UserAuthMappingDO::getMappingId).collect(Collectors.toList()));
}
List<String> regionIds = userAuthMapping.stream().map(UserAuthMappingDO::getMappingId).collect(Collectors.toList());
List<StoreDO> list = storeDao.getSubStoreByRegionIds(regionIds);
return list;
}
PageHelper.startPage(pageNum,pageSize);
List<MiniShopsResponse> list = storeDao.getSubStoreByRegionIdsAndMobile(regionIds,mobile);
return new PageInfo<>(list);
}

View File

@@ -117,8 +117,12 @@ public class MiniShopController {
}
@ApiOperation("成功开店的门店")
@GetMapping("/getShopListSuccessOpen")
public ResponseResult<List<MiniShopsResponse>> getShopListSuccessOpen(@RequestParam("lineId")Long lineId) {
return ResponseResult.success(shopService.getShopListSuccessOpen(lineId));
public ResponseResult<PageInfo<MiniShopsResponse>> getShopListSuccessOpen(@RequestParam("lineId")Long lineId,
@RequestParam(value = "pageSize",defaultValue = "10")Integer pageSize,
@RequestParam(value = "pageNum",defaultValue = "1")Integer pageNum,
@RequestParam(value = "storeName",required = false,defaultValue = "storeName") String storeName
) {
return ResponseResult.success(shopService.getShopListSuccessOpen(lineId,pageNum,pageSize,storeName));
}
@ApiOperation("获取推荐铺位和我创建的")