|
@@ -1,5 +1,6 @@
|
|
|
package shop.alien.store.controller;
|
|
package shop.alien.store.controller;
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson2.JSON;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
@@ -19,9 +20,13 @@ import shop.alien.entity.store.StorePrice;
|
|
|
import shop.alien.entity.store.dto.CuisineComboDto;
|
|
import shop.alien.entity.store.dto.CuisineComboDto;
|
|
|
import shop.alien.entity.store.dto.CuisineTypeResponseDto;
|
|
import shop.alien.entity.store.dto.CuisineTypeResponseDto;
|
|
|
import shop.alien.entity.store.dto.TablewareFeeDto;
|
|
import shop.alien.entity.store.dto.TablewareFeeDto;
|
|
|
|
|
+import shop.alien.entity.store.StoreCuisineCategory;
|
|
|
|
|
+import shop.alien.entity.store.vo.CuisineSelectCategoryVo;
|
|
|
|
|
+import shop.alien.entity.store.vo.CuisineSelectDishVo;
|
|
|
import shop.alien.entity.store.vo.PriceListVo;
|
|
import shop.alien.entity.store.vo.PriceListVo;
|
|
|
import shop.alien.mapper.StoreCuisineMapper;
|
|
import shop.alien.mapper.StoreCuisineMapper;
|
|
|
import shop.alien.store.annotation.TrackEvent;
|
|
import shop.alien.store.annotation.TrackEvent;
|
|
|
|
|
+import shop.alien.store.service.StoreCuisineCategoryService;
|
|
|
import shop.alien.store.service.StoreCuisineComboService;
|
|
import shop.alien.store.service.StoreCuisineComboService;
|
|
|
import shop.alien.store.service.StoreCuisineService;
|
|
import shop.alien.store.service.StoreCuisineService;
|
|
|
import shop.alien.store.service.StoreInfoService;
|
|
import shop.alien.store.service.StoreInfoService;
|
|
@@ -34,6 +39,9 @@ import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+import java.util.Objects;
|
|
|
|
|
+import java.util.Set;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 美食价目表
|
|
* 美食价目表
|
|
@@ -64,6 +72,8 @@ public class StoreCuisineController {
|
|
|
|
|
|
|
|
private final StoreCuisineComboService storeCuisineComboService;
|
|
private final StoreCuisineComboService storeCuisineComboService;
|
|
|
|
|
|
|
|
|
|
+ private final StoreCuisineCategoryService storeCuisineCategoryService;
|
|
|
|
|
+
|
|
|
private final StoreProductDiscountService storeProductDiscountService;
|
|
private final StoreProductDiscountService storeProductDiscountService;
|
|
|
|
|
|
|
|
@ApiOperation("新增美食套餐或单品")
|
|
@ApiOperation("新增美食套餐或单品")
|
|
@@ -534,8 +544,6 @@ public class StoreCuisineController {
|
|
|
priceListVo.add(vo);
|
|
priceListVo.add(vo);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- // 回填 store_product_discount_rule:当前生效优惠与估算折后价(美食价目 productId=菜品 id)
|
|
|
|
|
- storeProductDiscountService.fillActiveDiscountForPriceList(priceListVo);
|
|
|
|
|
return R.data(priceListVo);
|
|
return R.data(priceListVo);
|
|
|
}else{
|
|
}else{
|
|
|
Page<StorePrice> page = new Page<>(pageNum, pageSize);
|
|
Page<StorePrice> page = new Page<>(pageNum, pageSize);
|
|
@@ -578,8 +586,6 @@ public class StoreCuisineController {
|
|
|
priceListVo.add(vo);
|
|
priceListVo.add(vo);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- // 同上,通用价目 productId=store_price.id
|
|
|
|
|
- storeProductDiscountService.fillActiveDiscountForPriceList(priceListVo);
|
|
|
|
|
return R.data(priceListVo);
|
|
return R.data(priceListVo);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -654,6 +660,111 @@ public class StoreCuisineController {
|
|
|
|
|
|
|
|
return R.data(storeInfo.getTablewareFee());
|
|
return R.data(storeInfo.getTablewareFee());
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation("选择菜品:按门店菜品分类分组,支持名称模糊;含当前生效优惠(store_product_discount_rule)")
|
|
|
|
|
+ @ApiOperationSupport(order = 11)
|
|
|
|
|
+ @ApiImplicitParams({
|
|
|
|
|
+ @ApiImplicitParam(name = "storeId", value = "门店ID", dataType = "Integer", paramType = "query", required = true),
|
|
|
|
|
+ @ApiImplicitParam(name = "name", value = "名称模糊搜索(可选)", dataType = "String", paramType = "query")
|
|
|
|
|
+ })
|
|
|
|
|
+ @GetMapping("/selectDishesByCategory")
|
|
|
|
|
+ public R<List<CuisineSelectCategoryVo>> selectDishesByCategory(
|
|
|
|
|
+ @RequestParam Integer storeId,
|
|
|
|
|
+ @RequestParam(required = false) String name) {
|
|
|
|
|
+ log.info("StoreCuisineController.selectDishesByCategory?storeId={},name={}", storeId, name);
|
|
|
|
|
+ if (storeId == null) {
|
|
|
|
|
+ return R.fail("门店ID不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ LambdaQueryWrapper<StoreCuisine> qw = new LambdaQueryWrapper<>();
|
|
|
|
|
+ qw.eq(StoreCuisine::getStoreId, storeId)
|
|
|
|
|
+ .eq(StoreCuisine::getShelfStatus, 1)
|
|
|
|
|
+ .eq(StoreCuisine::getStatus, 1);
|
|
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isNotBlank(name)) {
|
|
|
|
|
+ qw.like(StoreCuisine::getName, name.trim());
|
|
|
|
|
+ }
|
|
|
|
|
+ qw.orderByDesc(StoreCuisine::getCreatedTime);
|
|
|
|
|
+ List<StoreCuisine> cuisines = storeCuisineService.list(qw);
|
|
|
|
|
+ if (cuisines == null || cuisines.isEmpty()) {
|
|
|
|
|
+ return R.data(new ArrayList<>());
|
|
|
|
|
+ }
|
|
|
|
|
+ List<StoreCuisineCategory> categories = storeCuisineCategoryService.getCategoryList(storeId);
|
|
|
|
|
+ Set<Integer> activeCategoryIds = categories.stream()
|
|
|
|
|
+ .map(StoreCuisineCategory::getId)
|
|
|
|
|
+ .filter(Objects::nonNull)
|
|
|
|
|
+ .collect(Collectors.toSet());
|
|
|
|
|
+
|
|
|
|
|
+ List<CuisineSelectCategoryVo> groups = new ArrayList<>();
|
|
|
|
|
+ for (StoreCuisineCategory cat : categories) {
|
|
|
|
|
+ List<CuisineSelectDishVo> dishes = new ArrayList<>();
|
|
|
|
|
+ for (StoreCuisine c : cuisines) {
|
|
|
|
|
+ if (parseCategoryIdList(c.getCategoryIds()).contains(cat.getId())) {
|
|
|
|
|
+ dishes.add(toSelectDishVo(c));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!dishes.isEmpty()) {
|
|
|
|
|
+ CuisineSelectCategoryVo g = new CuisineSelectCategoryVo();
|
|
|
|
|
+ g.setCategoryId(cat.getId());
|
|
|
|
|
+ g.setCategoryName(cat.getCategoryName());
|
|
|
|
|
+ g.setSort(cat.getSort());
|
|
|
|
|
+ g.setDishes(dishes);
|
|
|
|
|
+ groups.add(g);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ List<CuisineSelectDishVo> uncategorized = new ArrayList<>();
|
|
|
|
|
+ for (StoreCuisine c : cuisines) {
|
|
|
|
|
+ List<Integer> cidList = parseCategoryIdList(c.getCategoryIds());
|
|
|
|
|
+ boolean placed = false;
|
|
|
|
|
+ for (Integer cid : cidList) {
|
|
|
|
|
+ if (activeCategoryIds.contains(cid)) {
|
|
|
|
|
+ placed = true;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!placed) {
|
|
|
|
|
+ uncategorized.add(toSelectDishVo(c));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!uncategorized.isEmpty()) {
|
|
|
|
|
+ CuisineSelectCategoryVo g = new CuisineSelectCategoryVo();
|
|
|
|
|
+ g.setCategoryId(0);
|
|
|
|
|
+ g.setCategoryName("未分类");
|
|
|
|
|
+ g.setSort(Integer.MAX_VALUE);
|
|
|
|
|
+ g.setDishes(uncategorized);
|
|
|
|
|
+ groups.add(g);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ List<CuisineSelectDishVo> flat = new ArrayList<>();
|
|
|
|
|
+ for (CuisineSelectCategoryVo g : groups) {
|
|
|
|
|
+ flat.addAll(g.getDishes());
|
|
|
|
|
+ }
|
|
|
|
|
+ storeProductDiscountService.fillActiveDiscountForSelectDishes(flat);
|
|
|
|
|
+ return R.data(groups);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /** 解析 store_cuisine.category_ids(JSON 数组) */
|
|
|
|
|
+ private static List<Integer> parseCategoryIdList(String categoryIdsJson) {
|
|
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isBlank(categoryIdsJson)) {
|
|
|
|
|
+ return new ArrayList<>();
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ List<Integer> ids = JSON.parseArray(categoryIdsJson, Integer.class);
|
|
|
|
|
+ return ids == null ? new ArrayList<>() : ids;
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ return new ArrayList<>();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static CuisineSelectDishVo toSelectDishVo(StoreCuisine c) {
|
|
|
|
|
+ CuisineSelectDishVo vo = new CuisineSelectDishVo();
|
|
|
|
|
+ vo.setId(c.getId());
|
|
|
|
|
+ vo.setStoreId(c.getStoreId());
|
|
|
|
|
+ vo.setName(c.getName());
|
|
|
|
|
+ vo.setTotalPrice(c.getTotalPrice());
|
|
|
|
|
+ vo.setCuisineType(c.getCuisineType());
|
|
|
|
|
+ vo.setImages(c.getImages());
|
|
|
|
|
+ return vo;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|