feat(店铺): 新增获取不同模式列表功能并扩展店铺查询条件

添加获取不同模式列表的接口,支持通过eqMode参数进行模式匹配查询
修改店铺列表查询接口,增加eqMode参数以支持更灵活的查询条件
在SearchShopQuery中新增modeList字段以支持多模式查询
This commit is contained in:
dzq 2025-12-30 08:50:22 +08:00
parent 98cee3f84e
commit 27ea67f58a
6 changed files with 37 additions and 8 deletions

View File

@ -53,18 +53,25 @@ public class ShopController {
@GetMapping("/list")
public ResponseDTO<List<ShopEntity>> getShopList(@RequestParam(required = false) String corpid,
@RequestParam(required = false) Long mode) {
@RequestParam(required = false) Long mode,
@RequestParam(required = false) Long eqMode) {
List<ShopEntity> shopList;
Long modeValue = mode != null ? mode : 4L;
if (StringUtils.isNotBlank(corpid)) {
shopList = shopApplicationService.getShopListByCorpid(corpid, modeValue);
shopList = shopApplicationService.getShopListByCorpid(corpid, modeValue, eqMode);
} else {
log.warn("getShopList接口未接收到corpid参数使用默认corpid: {}", WeixinConstants.corpid);
shopList = shopApplicationService.getShopListByCorpid(WeixinConstants.corpid, modeValue);
shopList = shopApplicationService.getShopListByCorpid(WeixinConstants.corpid, modeValue, eqMode);
}
return ResponseDTO.ok(shopList);
}
@GetMapping("/mode/list")
public ResponseDTO<List<Integer>> getModeList() {
List<Integer> modeList = shopApplicationService.getDistinctModeList();
return ResponseDTO.ok(modeList);
}
@GetMapping("/goods/list")
public ResponseDTO<List<SearchGoodsDO>> getShopGoodsList(SearchShopGoodsQuery<SearchGoodsDO> query) {
if (StringUtils.isBlank(query.getCorpid())) {

View File

@ -56,8 +56,8 @@ public class ShopApplicationService {
return new ShopDTO(shopEntity);
}
public List<ShopEntity> getShopListByCorpid(String corpid, Long mode) {
return shopService.getShopListByCorpid(corpid, mode);
public List<ShopEntity> getShopListByCorpid(String corpid, Long mode, Long eqMode) {
return shopService.getShopListByCorpid(corpid, mode, eqMode);
}
public void addShop(AddShopCommand command) {
@ -105,4 +105,8 @@ public class ShopApplicationService {
public Long countAllRecord() {
return shopService.countAllRecord();
}
public List<Integer> getDistinctModeList() {
return shopService.getDistinctModeList();
}
}

View File

@ -44,4 +44,7 @@ public interface ShopMapper extends BaseMapper<ShopEntity> {
@Select("SELECT COUNT(1) FROM shop WHERE deleted = 0")
Long countAllRecord();
@Select("SELECT DISTINCT mode FROM shop WHERE deleted = 0 AND mode IS NOT NULL ORDER BY mode")
List<Integer> selectDistinctModeList();
}

View File

@ -28,5 +28,7 @@ public interface ShopService extends IService<ShopEntity> {
Long countAllRecord();
List<ShopEntity> getShopListByCorpid(String corpid, Long mode);
List<Integer> getDistinctModeList();
List<ShopEntity> getShopListByCorpid(String corpid, Long mode, Long eqMode);
}

View File

@ -50,11 +50,20 @@ public class ShopServiceImpl extends ServiceImpl<ShopMapper, ShopEntity> impleme
}
@Override
public List<ShopEntity> getShopListByCorpid(String corpid, Long mode) {
public List<Integer> getDistinctModeList() {
return baseMapper.selectDistinctModeList();
}
@Override
public List<ShopEntity> getShopListByCorpid(String corpid, Long mode, Long eqMode) {
QueryWrapper<ShopEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("corpid", corpid)
.ne("mode", mode)
.eq("deleted", 0);
if (eqMode != null && eqMode >= 0) {
queryWrapper.eq("mode", eqMode);
} else {
queryWrapper.ne("mode", mode);
}
return this.list(queryWrapper);
}
}

View File

@ -4,6 +4,7 @@ import cn.hutool.core.util.StrUtil;
import com.agileboot.common.core.page.AbstractPageQuery;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.util.Date;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -18,6 +19,7 @@ public class SearchShopQuery<T> extends AbstractPageQuery<T> {
private String corpid;
private Integer belongType;
private Integer mode;
private List<Integer> modeList;
private Integer balanceEnable;
@Override
@ -30,6 +32,8 @@ public class SearchShopQuery<T> extends AbstractPageQuery<T> {
.eq(StrUtil.isNotEmpty(corpid), "s.corpid", corpid)
.eq(belongType != null, "s.belong_type", belongType)
.eq(mode != null, "s.mode", mode)
.in(modeList != null && !modeList.isEmpty(), "s.mode", modeList)
.eq(modeList == null || modeList.isEmpty(), "s.mode", -1)
.eq(balanceEnable != null, "s.balance_enable", balanceEnable)
.between(startTime != null && endTime != null, "s.create_time", startTime, endTime)
.groupBy("s.shop_id");