Browse Source

团购管理

zjy 1 month ago
parent
commit
d371422b4d

+ 0 - 21
alien-entity/src/main/java/shop/alien/entity/storePlantform/vo/LifeGroupBuyPlantformDto.java

@@ -1,21 +0,0 @@
-package shop.alien.entity.storePlantform.vo;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import lombok.Data;
-import shop.alien.entity.store.LifeGroupBuyMain;
-import shop.alien.entity.store.LifeGroupBuyThali;
-import shop.alien.entity.storePlantform.LifeGroupBuyMainPlantform;
-
-import java.util.List;
-
-/**
- * 团购
- */
-@Data
-@JsonInclude
-public class LifeGroupBuyPlantformDto {
-
-    private LifeGroupBuyMainPlantform lifeGroupBuyMain;
-
-    private List<LifeGroupBuyThali> lifeGroupBuyThalis;
-}

+ 9 - 4
alien-entity/src/main/java/shop/alien/entity/storePlantform/LifeGroupBuyMainPlantform.java → alien-entity/src/main/java/shop/alien/entity/storePlatform/LifeGroupBuyMainPlatform.java

@@ -1,6 +1,5 @@
-package shop.alien.entity.storePlantform;
+package shop.alien.entity.storePlatform;
 
-import com.baomidou.mybatisplus.annotation.*;
 import com.fasterxml.jackson.annotation.JsonInclude;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -14,13 +13,13 @@ import java.util.List;
  */
 @JsonInclude
 @Data
-public class LifeGroupBuyMainPlantform extends LifeGroupBuyMain {
+public class LifeGroupBuyMainPlatform extends LifeGroupBuyMain {
 
     /**
      * 有效期类型
      */
     @ApiModelProperty(value = "有效期时间")
-    private List<String> expirationDate;
+    private String expirationDate;
 
     /**
      * 有效期时间数组
@@ -34,5 +33,11 @@ public class LifeGroupBuyMainPlantform extends LifeGroupBuyMain {
     @ApiModelProperty(value = "不可用日期二维数组")
     private List<List<String>> disableDateList;
 
+    /**
+     * 图片list
+     */
+    @ApiModelProperty(value = "图片list")
+    private List<String> imageValueStr;
+
 
 }

+ 22 - 0
alien-entity/src/main/java/shop/alien/entity/storePlatform/vo/LifeGroupBuyPlatformDto.java

@@ -0,0 +1,22 @@
+package shop.alien.entity.storePlatform.vo;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+import shop.alien.entity.store.LifeGroupBuyThali;
+import shop.alien.entity.storePlatform.LifeGroupBuyMainPlatform;
+
+import java.util.List;
+
+/**
+ * 团购
+ */
+@Data
+@JsonInclude
+public class LifeGroupBuyPlatformDto {
+
+    private String isCollect;
+
+    private LifeGroupBuyMainPlatform lifeGroupBuyMain;
+
+    private List<LifeGroupThalisPlatformDto> lifeGroupBuyThalis;
+}

+ 23 - 0
alien-entity/src/main/java/shop/alien/entity/storePlatform/vo/LifeGroupThalisPlatformDto.java

@@ -0,0 +1,23 @@
+package shop.alien.entity.storePlatform.vo;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+import shop.alien.entity.store.LifeGroupBuyThali;
+import shop.alien.entity.storePlatform.LifeGroupBuyMainPlatform;
+
+import java.util.List;
+
+/**
+ * 团购
+ */
+@Data
+@JsonInclude
+public class LifeGroupThalisPlatformDto {
+
+    // 分组名称
+    private String groupName;
+
+    // 菜品
+    private List<LifeGroupBuyThali> dishes;
+
+}

+ 160 - 0
alien-store-platform/src/main/java/shop/alien/storeplatform/controller/LifeCouponPlatformController.java

@@ -0,0 +1,160 @@
+package shop.alien.storeplatform.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import io.swagger.annotations.*;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.*;
+import shop.alien.entity.result.R;
+import shop.alien.entity.store.EssentialHolidayComparison;
+import shop.alien.entity.store.LifeCoupon;
+import shop.alien.entity.store.vo.LifeCouponStatusVo;
+import shop.alien.storeplatform.service.LifeCouponPlatformService;
+
+import java.util.Map;
+
+/**
+ * 优惠券
+ */
+@Api(tags = {"商家端-优惠券"})
+@Slf4j
+@CrossOrigin
+@RestController
+@RequestMapping("/couponPlatform")
+@RequiredArgsConstructor
+public class LifeCouponPlatformController {
+
+    private final LifeCouponPlatformService lifeCouponService;
+
+    @ApiOperation("新建代金券")
+    @PostMapping("/addOrUpdateCoupon")
+    public R<LifeCoupon> addOrUpdateCoupon(@RequestBody LifeCoupon lifeCoupon) {
+        log.info("LifeCouponController.addOrUpdateCoupon?lifeCoupon={}", lifeCoupon.toString());
+        return R.data(lifeCouponService.addOrUpdateCoupon(lifeCoupon));
+    }
+
+    /**
+     * 修改库存数量
+     *
+     * @param id        主键
+     * @param singleQty 库存数量
+     * @return boolean
+     */
+    @ApiOperation("修改库存数量")
+    @GetMapping("/updateCouponSingleQty")
+    public R<Boolean> updateCouponSingleQty(@RequestParam("id") Integer id, @RequestParam("singleQty") Integer singleQty) {
+        log.info("LifeCouponController.updateCouponSingleQty?id={}&singleQty={}", id, singleQty);
+        if (lifeCouponService.updateCouponSingleQty(id, singleQty)) {
+            return R.success("成功");
+        }
+        return R.fail("失败");
+    }
+
+    @ApiOperation("代金劵列表")
+    @ApiImplicitParams({@ApiImplicitParam(name = "page", value = "页数", dataType = "Integer", paramType = "query", required = true), @ApiImplicitParam(name = "size", value = "页容", dataType = "Integer", paramType = "query", required = true), @ApiImplicitParam(name = "storeId", value = "门店id", dataType = "Integer", paramType = "query", required = true), @ApiImplicitParam(name = "status", value = "状态", dataType = "Integer", paramType = "query", required = false), @ApiImplicitParam(name = "name", value = "名称", dataType = "Integer", paramType = "query"), @ApiImplicitParam(name = "dataType", value = "数据类型: 0:正式数据, 1:草稿数据", dataType = "Integer", paramType = "query", defaultValue = "0")})
+    @GetMapping("/getCouponList")
+    private R<IPage<LifeCoupon>> getCouponList(@RequestParam(value = "page", defaultValue = "1") int page, @RequestParam(value = "size", defaultValue = "10") int size, @RequestParam("storeId") String storeId, @RequestParam("status") String status, @RequestParam(value = "name", required = false) String name, @RequestParam(value = "dataType", defaultValue = "0") Integer dataType) {
+        log.info("LifeCouponController.getCouponList?page={},size={},storeId={},status={},name={},dataType={}", page, size, storeId, status, name, dataType);
+        return R.data(lifeCouponService.getCouponList(page, size, storeId, status, name, dataType));
+    }
+
+    @ApiOperation("暂停恢复优惠券")
+    @GetMapping("/updateCoupon")
+    public R<Boolean> updateCoupon(@RequestParam("id") String id, @RequestParam("status") Integer status) {
+        log.info("LifeCouponController.updateCoupon?id={}&status={}", id, status);
+        if (lifeCouponService.updateCoupon(id, status) > 0) {
+            return R.success("成功");
+        }
+        return R.fail("失败");
+    }
+
+    @ApiOperation("优惠券详情")
+    @GetMapping("/getCouponDetail")
+    private R<LifeCoupon> getCouponDetail(@RequestParam("id") String id) {
+        log.info("LifeCouponController.getCouponDetail?id={}", id);
+        LambdaQueryWrapper<LifeCoupon> objectLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        objectLambdaQueryWrapper.eq(LifeCoupon::getId, id);
+        return R.data(lifeCouponService.getOne(objectLambdaQueryWrapper));
+    }
+
+    @ApiOperation("旧 核销订单")
+    @ApiImplicitParams({@ApiImplicitParam(name = "storeId", value = "门店id", dataType = "Integer", paramType = "query", required = true), @ApiImplicitParam(name = "quanCode", value = "券码", dataType = "Integer", paramType = "query", required = true)})
+    @GetMapping("/verify")
+    public R<Map<String, String>> verify(@RequestParam("storeId") String storeId, @RequestParam("quanCode") String quanCode) {
+        log.info("LifeCouponController.verify?storeId={},quanCode={}", storeId, quanCode);
+        return R.data(lifeCouponService.couponVerify(storeId, quanCode));
+    }
+
+    @ApiOperation("核销订单前效验")
+    @ApiImplicitParams(@ApiImplicitParam(name = "orderCode", value = "劵code", dataType = "String", paramType = "query", required = true))
+    @GetMapping("/orderVerify")
+    public R<String> orderVerify(@RequestParam("orderCode") String orderCode) {
+        log.info("LifeCouponController.orderVerify?orderCode={}", orderCode);
+        return lifeCouponService.orderVerify(orderCode);
+    }
+
+    @ApiOperation("获取优惠券状态")
+    @ApiOperationSupport(order = 1)
+    @GetMapping("/getCouponStatus")
+    @ApiImplicitParams({@ApiImplicitParam(name = "couponId", value = "优惠券id", dataType = "String", paramType = "query", required = true),})
+    public R<LifeCouponStatusVo> getCouponStatus(@RequestParam(value = "couponId") String couponId) {
+        log.info("LifeDiscountCouponController.getCouponStatus?couponId={}", couponId);
+        try {
+            LifeCouponStatusVo lifeCouponStatusVo = lifeCouponService.getCouponStatus(couponId);
+            return R.data(lifeCouponStatusVo);
+        } catch (Exception e) {
+            log.error("LifeDiscountCouponController.getCouponStatus ERROR Msg={}", e.getMessage());
+            return R.fail("查询失败");
+        }
+    }
+
+    @ApiOperation("节假日列表")
+    @ApiImplicitParams({@ApiImplicitParam(name = "page", value = "页数", dataType = "Integer", paramType = "query", required = true), @ApiImplicitParam(name = "size", value = "页容", dataType = "Integer", paramType = "query", required = true), @ApiImplicitParam(name = "year", value = "年份", dataType = "String", paramType = "query", required = false), @ApiImplicitParam(name = "openFlag", value = "是否启用(0:未启用,1:已启用)", dataType = "String", paramType = "query", required = false), @ApiImplicitParam(name = "holidayName", value = "节假日名称", dataType = "String", paramType = "query", required = false)})
+    @GetMapping("/getHolidayList")
+    private R<IPage<EssentialHolidayComparison>> getHolidayList(@RequestParam(value = "page", defaultValue = "1") int page, @RequestParam(value = "size", defaultValue = "10") int size, @RequestParam("year") String year, @RequestParam("openFlag") String openFlag, @RequestParam("holidayName") String holidayName) {
+        log.info("LifeCouponController.getHolidayList?page={},size={},year={},openFlag={},holidayName={}", page, size, year, openFlag, holidayName);
+        return R.data(lifeCouponService.getHolidayList(page, size, year, openFlag, holidayName));
+    }
+
+    @ApiOperation("保存节假日")
+    @PostMapping("/saveHoliday")
+    public R<Boolean> saveHoliday(@RequestBody EssentialHolidayComparison essentialHolidayComparison) {
+        log.info("LifeCouponController.saveHoliday?essentialHolidayComparison={}", essentialHolidayComparison.toString());
+        if (lifeCouponService.saveHoliday(essentialHolidayComparison)) {
+            return R.success("成功");
+        }
+        return R.fail("失败");
+    }
+
+    @ApiOperation("删除节假日")
+    @GetMapping("/delHoliday")
+    private R delHoliday(@RequestParam("id") String id) {
+        log.info("LifeCouponController.delHoliday?id={}", id);
+        if (lifeCouponService.delHoliday(id)) {
+            return R.success("成功");
+        }
+        return R.fail("失败");
+    }
+
+    @ApiOperation("启用禁用节假日")
+    @GetMapping("/openCloseHoliday")
+    private R openCloseHoliday(@RequestParam("id") String id) {
+        log.info("LifeCouponController.openCloseHoliday?id={}", id);
+        if (lifeCouponService.openCloseHoliday(id)) {
+            return R.success("成功");
+        }
+        return R.fail("失败");
+    }
+
+    @ApiOperation("按年份删除节假日")
+    @GetMapping("/delHolidayByYear")
+    private R delHolidayByYear(@RequestParam("year") String year) {
+        log.info("LifeCouponController.delHolidayByYear?year={}", year);
+        if (lifeCouponService.delHolidayByYear(year)) {
+            return R.success("成功");
+        }
+        return R.fail("失败");
+    }
+}
+

+ 6 - 6
alien-store-platform/src/main/java/shop/alien/storeplatform/controller/LifeGroupBuyController.java → alien-store-platform/src/main/java/shop/alien/storeplatform/controller/LifeGroupBuyPlatformController.java

@@ -12,8 +12,8 @@ import shop.alien.entity.result.R;
 import shop.alien.entity.store.LifeGroupBuyThali;
 import shop.alien.entity.store.dto.LifeGroupBuyDto;
 import shop.alien.entity.store.vo.LifeGroupBuyThaliVo;
-import shop.alien.entity.storePlantform.vo.LifeGroupBuyPlantformDto;
-import shop.alien.storeplatform.service.LifeGroupBuyService;
+import shop.alien.entity.storePlatform.vo.LifeGroupBuyPlatformDto;
+import shop.alien.storeplatform.service.LifeGroupBuyPlatformService;
 
 /**
  * 团购
@@ -25,12 +25,12 @@ import shop.alien.storeplatform.service.LifeGroupBuyService;
 @RestController
 @RequestMapping("/PcGroupBuy")
 @RequiredArgsConstructor
-public class LifeGroupBuyController {
+public class LifeGroupBuyPlatformController {
 
     /**
      * 团购服务层
      */
-    private final LifeGroupBuyService lifeGroupBuyService;
+    private final LifeGroupBuyPlatformService lifeGroupBuyService;
 
     /**
      * 保存套餐团购草稿
@@ -41,7 +41,7 @@ public class LifeGroupBuyController {
      */
     @ApiOperation("保存套餐团购草稿")
     @PostMapping("/saveDraft")
-    public R saveDraft(@RequestBody LifeGroupBuyPlantformDto lifeGroupBuyDto) {
+    public R saveDraft(@RequestBody LifeGroupBuyPlatformDto lifeGroupBuyDto) {
         log.info("LifeGroupBuyController.saveThali?lifeGroupBuyDto={}", lifeGroupBuyDto.toString());
         if (lifeGroupBuyService.saveDraft(lifeGroupBuyDto)) {
             return R.success("成功");
@@ -58,7 +58,7 @@ public class LifeGroupBuyController {
      */
     @ApiOperation("保存套餐团购(返回保存套餐)")
     @PostMapping("/saveThali")
-    public R<LifeGroupBuyThali> saveThali(@RequestBody LifeGroupBuyDto lifeGroupBuyDto) {
+    public R<LifeGroupBuyThali> saveThali(@RequestBody LifeGroupBuyPlatformDto lifeGroupBuyDto) {
         log.info("LifeGroupBuyController.saveThaliNew?lifeGroupBuyDto={}", lifeGroupBuyDto.toString());
         LifeGroupBuyThali lifeGroupBuyThali = lifeGroupBuyService.saveThali(lifeGroupBuyDto);
         return R.data(lifeGroupBuyThali);

+ 130 - 0
alien-store-platform/src/main/java/shop/alien/storeplatform/controller/StoreMenuPlatformController.java

@@ -0,0 +1,130 @@
+package shop.alien.storeplatform.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiOperationSupport;
+import io.swagger.annotations.ApiSort;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import shop.alien.entity.result.R;
+import shop.alien.entity.store.StoreMenu;
+import shop.alien.entity.store.vo.StoreMenuVo;
+import shop.alien.storeplatform.service.StoreMenuPlatformService;
+
+import java.util.List;
+
+/**
+ * 二期-门店菜单Controller
+ *
+ * @author ssk
+ * @since 2024-12-05
+ */
+@Slf4j
+@Api(tags = {"商家端-门店菜单"})
+@ApiSort(4)
+@CrossOrigin
+@RestController
+@RequestMapping("/menuPlatform")
+@RequiredArgsConstructor
+public class StoreMenuPlatformController {
+
+    private final StoreMenuPlatformService storeMenuService;
+
+    @ApiOperation("获取门店菜单")
+    @ApiOperationSupport(order = 1)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "storeId", value = "门店id", dataType = "Integer", paramType = "query", required = true),
+            @ApiImplicitParam(name = "dishType", value = "菜品类型, 0:菜单, 1:推荐", dataType = "Integer", paramType = "query"),
+            @ApiImplicitParam(name = "phoneId", value = "消息标识", dataType = "Integer", paramType = "query")
+    })
+    @GetMapping("/getMenuByStoreId")
+    public R<List<StoreMenuVo>> getMenuByStoreId(Integer storeId, Integer dishType, String phoneId) {
+        log.info("StoreMenuController.getByStoreId?id={}&dishType={}&phoneId={}", storeId, dishType, phoneId);
+        return R.data(storeMenuService.getStoreMenu(storeId, dishType, phoneId));
+    }
+
+    @ApiOperation("新增或修改门店菜单")
+    @ApiOperationSupport(order = 2)
+    @PostMapping("/saveOrUpdate")
+    public R<String> saveOrUpdate(@RequestBody StoreMenuVo storeMenuVo) {
+        log.info("StoreMenuController.saveOrUpdateMenu?storeMenu={}", storeMenuVo);
+        return storeMenuService.saveOrUpdateMenus(storeMenuVo);
+    }
+
+    @ApiOperation(value = "删除门店菜单")
+    @ApiOperationSupport(order = 3)
+    @GetMapping("/delete")
+    public R<String> delete(@RequestParam(value = "ids") List<Integer> ids, @RequestParam(value = "dishType") int dishType) {
+        log.info("StoreMenuController.delete?ids={}", ids);
+        return storeMenuService.deleteMenu(ids, dishType);
+    }
+
+    @ApiOperation("获取菜品详情")
+    @ApiOperationSupport(order = 4)
+    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "菜品id", dataType = "Integer", paramType = "query")})
+    @GetMapping("/getMenuInfo")
+    public R<StoreMenuVo> getMenuInfo(Integer id) {
+        log.info("StoreMenuController.getMenuInfo?id={}", id);
+        return R.data(storeMenuService.getMenuInfo(id));
+    }
+
+    @ApiOperation("菜品排序")
+    @ApiOperationSupport(order = 5)
+    @PostMapping("/getSortMenuInfo")
+    public R<Boolean> getSortMenuInfo(@RequestBody StoreMenuVo storeMenuVo) {
+        log.info("StoreMenuController.getSortMenuInfo?storeMenuVo={}", storeMenuVo);
+        Boolean flag = storeMenuService.getSortMenuInfo(storeMenuVo);
+        if (flag) {
+            return R.success("已更新排序");
+        } else {
+            return R.fail("排序失败");
+        }
+    }
+
+    @ApiOperation("保存菜品排序")
+    @ApiOperationSupport(order = 6)
+    @PostMapping("/saveMenuSort")
+    public R<Boolean> saveMenuSort(@RequestBody List<StoreMenu> storeMenuList) {
+        log.info("StoreMenuController.saveMenuSort?storeMenuList={}", storeMenuList);
+        Boolean flag = storeMenuService.saveMenuSort(storeMenuList);
+        if (flag) {
+            return R.success("已更新排序");
+        } else {
+            return R.fail("排序失败");
+        }
+    }
+
+    @ApiOperation("获取门店菜品推荐数量")
+    @ApiOperationSupport(order = 7)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "storeId", value = "门店id", dataType = "Integer", paramType = "query", required = true)
+    })
+    @GetMapping("/getMenuCountByStoreId")
+    public R<StoreMenuVo> getMenuCountByStoreId(Integer storeId) {
+        log.info("StoreMenuController.getMenuCountByStoreId?id={}", storeId);
+        return R.data(storeMenuService.getMenuCountByStoreId(storeId));
+    }
+
+    @ApiOperation("获取用户对该菜品是否点赞")
+    @ApiOperationSupport(order = 8)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "userId", value = "用户id", dataType = "String", paramType = "query", required = true),
+            @ApiImplicitParam(name = "menuId", value = "菜品id", dataType = "Integer", paramType = "query", required = true)
+    })
+    @GetMapping("/getMenuLikeStatus")
+    public R<Boolean> getMenuLikeStatus(String userId, Integer menuId) {
+        log.info("StoreMenuController.getMenuLikeStatus?userId={}&menuId={}", userId, menuId);
+        return R.data(storeMenuService.getMenuLikeStatus(userId, menuId));
+    }
+}
+
+

+ 58 - 0
alien-store-platform/src/main/java/shop/alien/storeplatform/service/LifeCouponPlatformService.java

@@ -0,0 +1,58 @@
+package shop.alien.storeplatform.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.IService;
+import shop.alien.entity.result.R;
+import shop.alien.entity.store.EssentialHolidayComparison;
+import shop.alien.entity.store.LifeCoupon;
+import shop.alien.entity.store.vo.LifeCouponStatusVo;
+
+import java.util.Map;
+
+/**
+ * 优惠券
+ */
+public interface LifeCouponPlatformService extends IService<LifeCoupon> {
+
+    LifeCoupon addOrUpdateCoupon(LifeCoupon lifeCoupon);
+
+    /**
+     * 修改库存数量
+     *
+     * @param id        主键
+     * @param singleQty 库存数量
+     * @return boolean
+     */
+    boolean updateCouponSingleQty(Integer id, Integer singleQty);
+
+    IPage<LifeCoupon> getCouponList(int page, int size, String storeId, String status, String name, Integer dataType);
+
+    int updateCoupon(String id, Integer status);
+
+    Map<String, String> couponVerify(String storeId, String quanCode);
+
+//    Map<String, String> newCouponVerify(String storeId, String quanCode);
+
+    /**
+     * 获取代金券状态
+     */
+    public LifeCouponStatusVo getCouponStatus(String couponId);
+
+    IPage<EssentialHolidayComparison> getHolidayList(int page, int size, String year, String openFlag, String holidayName);
+
+    boolean saveHoliday(EssentialHolidayComparison essentialHolidayComparison);
+
+    boolean delHoliday(String id);
+
+    boolean delHolidayByYear(String year);
+
+    boolean openCloseHoliday(String id);
+
+    /**
+     * 核销订单前效验
+     * @param orderCode
+     * @return
+     */
+    R<String> orderVerify(String orderCode);
+}
+

+ 5 - 5
alien-store-platform/src/main/java/shop/alien/storeplatform/service/LifeGroupBuyService.java → alien-store-platform/src/main/java/shop/alien/storeplatform/service/LifeGroupBuyPlatformService.java

@@ -7,13 +7,13 @@ import shop.alien.entity.store.LifeGroupBuyMain;
 import shop.alien.entity.store.LifeGroupBuyThali;
 import shop.alien.entity.store.dto.LifeGroupBuyDto;
 import shop.alien.entity.store.vo.LifeGroupBuyThaliVo;
-import shop.alien.entity.storePlantform.vo.LifeGroupBuyPlantformDto;
+import shop.alien.entity.storePlatform.vo.LifeGroupBuyPlatformDto;
 
 /**
  * 团购服务接口
  * @date 2025-11-11
  */
-public interface LifeGroupBuyService extends IService<LifeGroupBuyMain> {
+public interface LifeGroupBuyPlatformService extends IService<LifeGroupBuyMain> {
 
     /**
      * 保存团购草稿
@@ -23,7 +23,7 @@ public interface LifeGroupBuyService extends IService<LifeGroupBuyMain> {
      * @date 2025-11-11
      */
     @Transactional(rollbackFor = Exception.class)
-    boolean saveDraft(LifeGroupBuyPlantformDto lifeGroupBuyDto);
+    boolean saveDraft(LifeGroupBuyPlatformDto lifeGroupBuyDto);
 
     /**
      * 保存团购并返回套餐信息
@@ -32,7 +32,7 @@ public interface LifeGroupBuyService extends IService<LifeGroupBuyMain> {
      * @return 最新套餐记录
      * @date 2025-11-11
      */
-    LifeGroupBuyThali saveThali(LifeGroupBuyDto lifeGroupBuyDto);
+    LifeGroupBuyThali saveThali(LifeGroupBuyPlatformDto lifeGroupBuyDto);
 
     /**
      * 查询团购套餐列表
@@ -56,7 +56,7 @@ public interface LifeGroupBuyService extends IService<LifeGroupBuyMain> {
      * @return 团购详情
      * @date 2025-11-11
      */
-    LifeGroupBuyThaliVo getThaliById(String id, String userId);
+    LifeGroupBuyPlatformDto getThaliById(String id, String userId);
 
     /**
      * 更新团购状态

+ 95 - 0
alien-store-platform/src/main/java/shop/alien/storeplatform/service/StoreMenuPlatformService.java

@@ -0,0 +1,95 @@
+package shop.alien.storeplatform.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import shop.alien.entity.result.R;
+import shop.alien.entity.store.StoreMenu;
+import shop.alien.entity.store.vo.StoreMenuVo;
+
+import java.util.List;
+
+/**
+ * 二期-门店推荐 服务类
+ *
+ * @author ssk
+ * @since 2024-12-05
+ */
+public interface StoreMenuPlatformService extends IService<StoreMenu> {
+
+    /**
+     * 获取门店菜单
+     *
+     * @param storeId  门店id
+     * @param dishType 菜品类型, 0:菜单, 1:推荐
+     * @param phoneId  消息标识
+     * @return list
+     */
+    List<StoreMenuVo> getStoreMenu(Integer storeId, Integer dishType, String phoneId);
+
+    /**
+     * 获取菜品详情
+     *
+     * @param id 菜品id
+     * @return StoreMenuVo
+     */
+    StoreMenuVo getMenuInfo(Integer id);
+
+    /**
+     * 新增或修改门店菜单
+     *
+     * @param storeMenu 菜品信息
+     * @return 操作结果
+     */
+    R<String> saveOrUpdateMenu(StoreMenu storeMenu);
+
+    /**
+     * 新增或修改门店菜单
+     *
+     * @param storeMenuVo 菜品信息
+     * @return 操作结果
+     */
+    R<String> saveOrUpdateMenus(StoreMenuVo storeMenuVo);
+
+    /**
+     * 菜品排序
+     *
+     * @param storeMenuVo 排序信息
+     * @return 处理结果
+     */
+    Boolean getSortMenuInfo(StoreMenuVo storeMenuVo);
+
+    /**
+     * 保存菜品排序
+     *
+     * @param storeMenuList 排序列表
+     * @return 处理结果
+     */
+    Boolean saveMenuSort(List<StoreMenu> storeMenuList);
+
+    /**
+     * 删除门店菜单
+     *
+     * @param ids      菜品ID集合
+     * @param dishType 菜品类型
+     * @return 操作结果
+     */
+    R deleteMenu(List<Integer> ids, int dishType);
+
+    /**
+     * 获取门店菜品推荐数量
+     *
+     * @param storeId 门店id
+     * @return 统计数据
+     */
+    StoreMenuVo getMenuCountByStoreId(int storeId);
+
+    /**
+     * 获取用户对该菜品是否点赞
+     *
+     * @param userId 用户id
+     * @param menuId 菜品id
+     * @return boolean
+     */
+    boolean getMenuLikeStatus(String userId, Integer menuId);
+}
+
+

+ 579 - 0
alien-store-platform/src/main/java/shop/alien/storeplatform/service/impl/LifeCouponPlatformServiceImpl.java

@@ -0,0 +1,579 @@
+package shop.alien.storeplatform.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+import org.springframework.util.StringUtils;
+import shop.alien.entity.result.R;
+import shop.alien.entity.store.*;
+import shop.alien.entity.store.dto.LifeDiscountCouponStoreFriendDto;
+import shop.alien.entity.store.vo.LifeCouponStatusVo;
+import shop.alien.mapper.*;
+import shop.alien.storeplatform.service.LifeCouponPlatformService;
+import shop.alien.util.common.UniqueRandomNumGenerator;
+import shop.alien.util.common.constant.OrderStatusEnum;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.time.*;
+import java.time.format.DateTimeFormatter;
+import java.time.format.TextStyle;
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * 优惠券
+ *
+ * @author ssk
+ * @version 1.0
+ * @date 2024/12/23 15:08
+ */
+@Service
+@RequiredArgsConstructor
+public class LifeCouponPlatformServiceImpl extends ServiceImpl<LifeCouponMapper, LifeCoupon> implements LifeCouponPlatformService {
+
+    private final LifeCouponMapper lifeCouponMapper;
+
+    private final LifeUserOrderMapper lifeUserOrderMapper;
+
+    private final StoreIncomeDetailsRecordMapper storeIncomeDetailsRecordMapper;
+
+    private final StoreDictionaryMapper storeDictionaryMapper;
+
+    private final EssentialHolidayComparisonMapper essentialHolidayComparisonMapper;
+
+    private final StoreUserMapper storeUserMapper;
+
+    private final OrderCouponMiddleMapper orderCouponMiddleMapper;
+
+    private final LifeGroupBuyMainMapper lifeGroupBuyMainMapper;
+
+    private final LifeDiscountCouponMapper lifeDiscountCouponMapper;
+
+    @Override
+    public LifeCoupon addOrUpdateCoupon(LifeCoupon lifeCoupon) {
+
+        // 添加优惠tag
+        //获取经营板块id
+//        Integer businessSection = lifeCoupon.getBusinessSection();
+        //查询经营板块名称
+        StoreDictionary youhuiName = storeDictionaryMapper.selectOne(new LambdaQueryWrapper<StoreDictionary>().eq(StoreDictionary::getDictId, "180").eq(StoreDictionary::getTypeName, "youhui"));
+        //查询经营种类
+        List<String> discountTypes = lifeCoupon.getTempDiscountTag();
+        List<String> businessTypeNames = new ArrayList<>();
+        //获取经营种类名称
+        if (!CollectionUtils.isEmpty(discountTypes)) {
+            for (String businessType : discountTypes) {
+                StoreDictionary storeDictionary =
+                        storeDictionaryMapper
+                                .selectOne(
+                                        new LambdaQueryWrapper<StoreDictionary>()
+                                                .eq(StoreDictionary::getDictId, businessType).eq(StoreDictionary::getParentId, youhuiName.getId()));
+                businessTypeNames.add(storeDictionary.getDictDetail());
+            }
+            lifeCoupon.setDiscountTag(String.join(",", discountTypes));
+            lifeCoupon.setDiscountTagName(String.join(",", businessTypeNames));
+        }
+
+//        int status = 0;
+//        Date now = new Date();
+//        Date startDate = lifeCoupon.getStartDate();
+//        Date endDate = lifeCoupon.getEndDate();
+//        if (now.compareTo(startDate) >= 0 && now.compareTo(endDate) <= 0) {
+//            status = 1;
+//        } else if (now.compareTo(startDate) < 0) {
+//            status = 0;
+//        } else if (now.compareTo(endDate) >= 0) {
+//            status = 3;
+//        }
+        lifeCoupon.setStatus(1);
+        if (StringUtils.isEmpty(lifeCoupon.getId())) {
+            lifeCoupon.setType(1);
+            lifeCoupon.setCouponCode(UniqueRandomNumGenerator.generateUniqueCode(12));
+            this.save(lifeCoupon);
+        } else {
+            this.updateById(lifeCoupon);
+        }
+        return lifeCoupon;
+    }
+
+    /**
+     * 修改库存数量
+     *
+     * @param id        主键
+     * @param singleQty 库存数量
+     * @return boolean
+     */
+    @Override
+    public boolean updateCouponSingleQty(Integer id, Integer singleQty) {
+        //判断库存数为0 增加库存数修改状态为进行中
+        LambdaQueryWrapper<LifeCoupon> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+        lambdaQueryWrapper.eq(LifeCoupon :: getId, id);
+        LifeCoupon lifeCoupon = lifeCouponMapper.selectOne(lambdaQueryWrapper);
+
+        if(lifeCoupon.getSingleQty() == 0){
+        LambdaUpdateWrapper<LifeCoupon> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
+        lambdaUpdateWrapper.eq(LifeCoupon :: getId, id);
+        lambdaUpdateWrapper.set(LifeCoupon :: getSingleQty,singleQty);
+        lambdaUpdateWrapper.set(LifeCoupon :: getStatus, 5);
+        lifeCouponMapper.update(null, lambdaUpdateWrapper);
+        }
+        else{
+            LambdaUpdateWrapper<LifeCoupon> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
+            lambdaUpdateWrapper.eq(LifeCoupon :: getId, id);
+            lambdaUpdateWrapper.set(LifeCoupon :: getSingleQty,singleQty);
+            lifeCouponMapper.update(null, lambdaUpdateWrapper);
+        }
+
+        return true;
+    }
+
+    @Override
+    public IPage<LifeCoupon> getCouponList(int page, int size, String storeId, String status, String name, Integer dataType) {
+        LambdaUpdateWrapper<LifeCoupon> wrapper = new LambdaUpdateWrapper<>();
+        wrapper.eq(storeId != null && !storeId.isEmpty(), LifeCoupon::getStoreId, storeId);
+        wrapper.eq(status != null && !status.isEmpty(), LifeCoupon::getStatus, status);
+        wrapper.like(name != null && !name.isEmpty(), LifeCoupon::getName, name);
+        wrapper.eq(LifeCoupon::getType, 1);
+        wrapper.eq(LifeCoupon::getDataType, dataType);
+//        修改排序 按照status(0草稿/1待审核/2未开始/3审核拒绝/4已售罄/5进行中/6已下架/7已结束/8=2+手动下架)   审核拒绝>待审核>进行中>已售罄,已下架,已结束(同等优先级的情况下,按照审核时间的倒序显示)
+        wrapper.last("ORDER BY CASE " +
+                "WHEN status = 3 THEN 0 " +  // 审核拒绝
+                "WHEN status = 1 THEN 1 " +  // 待审核
+                "WHEN status = 5 THEN 2 " +  // 进行中
+                "WHEN status IN (4, 6, 7) THEN 3 " +  // 已售罄、已下架、已结束
+                "ELSE 4 END ASC, " +
+                "created_time DESC");
+        IPage<LifeCoupon> lifeCouponIPage = new Page<>(page, size);
+        return lifeCouponMapper.selectPage(lifeCouponIPage, wrapper);
+    }
+
+    @Override
+    public int updateCoupon(String id, Integer status) {
+        LifeCoupon coupon = lifeCouponMapper.selectById(id);
+        if (null == coupon) {
+            throw new RuntimeException("该券不存在");
+        }
+        // 已结束
+        if (LocalDate.now().isAfter(coupon.getEndDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate())) {
+            status = 7;
+        }
+        LifeCoupon lifeCoupon = new LifeCoupon();
+        lifeCoupon.setId(id);
+        lifeCoupon.setStatus(status);
+        return lifeCouponMapper.updateById(lifeCoupon);
+    }
+
+    /**
+     * 验券
+     *
+     * @param storeId
+     * @param quanCode
+     * @return
+     */
+    @Override
+    public Map<String, String> couponVerify(String storeId, String quanCode) {
+        LambdaUpdateWrapper<LifeUserOrder> wrapper = new LambdaUpdateWrapper<>();
+        wrapper.eq(LifeUserOrder::getQuanCode, quanCode);
+        LifeUserOrder order = lifeUserOrderMapper.selectOne(wrapper);
+        Map<String, String> resultMap = new HashMap<>();
+        String errMessage = "";
+        if (order == null) {
+            errMessage = "没有这张券";
+        } else {
+            if (order.getStatus() == 5) {
+                errMessage = "该券已核销";
+            }
+            if (order.getStatus() == 6) {
+                errMessage = "该券已过期";
+            }
+            if (order.getStatus() == 7) {
+                errMessage = "该券待退款";
+            }
+            if (order.getStatus() == 4) {
+                errMessage = "该券已退款";
+            }
+            if (!order.getStoreId().equals(storeId)) {
+                errMessage = "核销商家与券不一致";
+            }
+        }
+        if (!StringUtils.isEmpty(errMessage)) {
+            resultMap.put("code", "false");
+            resultMap.put("message", errMessage);
+            return resultMap;
+        }
+
+        order.setStatus(5);
+        order.setUsedTime(new Date());
+        lifeUserOrderMapper.updateById(order);
+
+        LambdaUpdateWrapper<LifeCoupon> couponWrapper = new LambdaUpdateWrapper<>();
+        couponWrapper.eq(LifeCoupon::getId, order.getQuanId());
+        LifeCoupon coupon = lifeCouponMapper.selectOne(couponWrapper);
+        // TODO 抽成比例应该从商户里取
+        BigDecimal amounts = new BigDecimal(order.getFinalPrice()).multiply(new BigDecimal(100));
+        BigDecimal commission = amounts.multiply(new BigDecimal(0.04)).setScale(0, RoundingMode.HALF_UP);
+        BigDecimal money = amounts.subtract(commission);
+
+        // 插入收入明细表数据
+        StoreIncomeDetailsRecord record = new StoreIncomeDetailsRecord();
+        record.setStoreId(Integer.parseInt(storeId));
+        record.setUserOrderId(Integer.parseInt(order.getId()));
+        record.setIncomeType(coupon.getType());
+        record.setBusinessId(Integer.parseInt(order.getQuanId()));
+        record.setCommission(commission.intValue());
+        record.setMoney(money.intValue());
+        storeIncomeDetailsRecordMapper.insert(record);
+        // 店铺账户余额增加
+        UpdateWrapper<StoreUser> updateWrapper = new UpdateWrapper();
+        updateWrapper.eq("store_id", storeId);
+        updateWrapper.eq("delete_flag", 0);
+        updateWrapper.setSql("money = money + " + money);
+        storeUserMapper.update(null, updateWrapper);
+        //发放好友优惠券
+        LifeDiscountCouponStoreFriendDto lifeDiscountCouponStoreFriendDto = new LifeDiscountCouponStoreFriendDto();
+        lifeDiscountCouponStoreFriendDto.setOrderId(Integer.parseInt(order.getId()));
+//        lifeDiscountCouponStoreFriendService.issueFriendCoupon(lifeDiscountCouponStoreFriendDto);
+        resultMap.put("code", "true");
+        resultMap.put("message", "核销成功");
+        return resultMap;
+    }
+
+    /**
+     * <p>
+     * 获取代金券状态
+     * </p>
+     *
+     * @author zhangchen
+     * @since 2025-07-14
+     */
+    @Override
+    public LifeCouponStatusVo getCouponStatus(String couponId) {
+        if (couponId == null || couponId.isEmpty()) {
+            log.error("获取代金券状态失败:couponId为空");
+            throw new IllegalArgumentException("couponId不能为空");
+        }
+        try {
+            LifeCoupon coupon = lifeCouponMapper.selectById(couponId);
+            LifeCouponStatusVo lifeCouponStatusVo = new LifeCouponStatusVo();
+            if (coupon != null) {
+                lifeCouponStatusVo.setCouponId(couponId);
+                lifeCouponStatusVo.setSingleQty(coupon.getSingleQty());
+                lifeCouponStatusVo.setBuyLimit(coupon.getBuyLimit());
+            } else {
+                // 可选:设置默认值或标记状态为无效
+                lifeCouponStatusVo.setSingleQty(0); // 或其他默认逻辑
+            }
+            return lifeCouponStatusVo;
+        } catch (Exception e) {
+            log.error("获取代金券状态失败: {}", e);
+            throw new RuntimeException("获取代金券状态失败", e); // 或者根据项目规范处理
+        }
+    }
+
+    @Override
+    public IPage<EssentialHolidayComparison> getHolidayList(int page, int size, String year, String openFlag, String holidayName) {
+        if (StringUtils.isEmpty(year)) {
+            LambdaQueryWrapper<EssentialHolidayComparison> essentialHolidayComparisonLambdaQueryWrapper = new LambdaQueryWrapper<>();
+            essentialHolidayComparisonLambdaQueryWrapper.eq(EssentialHolidayComparison::getDelFlag, 0).groupBy(EssentialHolidayComparison::getParticularYear).orderByDesc(EssentialHolidayComparison::getParticularYear);
+            IPage<EssentialHolidayComparison> essentialHolidayComparisonIPage = new Page<>(page, size);
+            return essentialHolidayComparisonMapper.selectPage(essentialHolidayComparisonIPage, essentialHolidayComparisonLambdaQueryWrapper);
+        } else {
+            LambdaQueryWrapper<EssentialHolidayComparison> essentialHolidayComparisonLambdaQueryWrapper = new LambdaQueryWrapper<>();
+            essentialHolidayComparisonLambdaQueryWrapper.eq(EssentialHolidayComparison::getDelFlag, 0)
+                    .eq(com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotEmpty(year), EssentialHolidayComparison::getParticularYear, year)
+                    .eq(com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotEmpty(openFlag), EssentialHolidayComparison::getOpenFlag, openFlag)
+                    .like(com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotEmpty(holidayName), EssentialHolidayComparison::getFestivalName, holidayName)
+                    .orderByAsc(EssentialHolidayComparison::getStartTime);
+            IPage<EssentialHolidayComparison> essentialHolidayComparisonIPage = new Page<>(page, size);
+            return essentialHolidayComparisonMapper.selectPage(essentialHolidayComparisonIPage, essentialHolidayComparisonLambdaQueryWrapper);
+        }
+    }
+
+    @Override
+    public boolean saveHoliday(EssentialHolidayComparison essentialHolidayComparison) {
+        if (ObjectUtils.isNotEmpty(essentialHolidayComparison.getId())) {
+            if (ObjectUtils.isNotEmpty(essentialHolidayComparison.getStartTime())) {
+                essentialHolidayComparison.setFestivalDate(essentialHolidayComparison.getStartTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate());
+            }
+            essentialHolidayComparisonMapper.updateById(essentialHolidayComparison);
+            return true;
+        } else {
+            if (ObjectUtils.isNotEmpty(essentialHolidayComparison.getStartTime())) {
+                essentialHolidayComparison.setFestivalDate(essentialHolidayComparison.getStartTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate());
+            }
+            essentialHolidayComparisonMapper.insert(essentialHolidayComparison);
+            return true;
+        }
+    }
+
+    @Override
+    public boolean delHoliday(String id) {
+        essentialHolidayComparisonMapper.update(null, new LambdaUpdateWrapper<EssentialHolidayComparison>().eq(EssentialHolidayComparison::getId, id).set(EssentialHolidayComparison::getDelFlag, 1));
+        return true;
+    }
+
+    @Override
+    public boolean delHolidayByYear(String year) {
+        essentialHolidayComparisonMapper.update(null, new LambdaUpdateWrapper<EssentialHolidayComparison>().eq(EssentialHolidayComparison::getParticularYear, year).set(EssentialHolidayComparison::getDelFlag, 1));
+        return true;
+    }
+
+    @Override
+    public boolean openCloseHoliday(String id) {
+        EssentialHolidayComparison essentialHolidayComparison = essentialHolidayComparisonMapper.selectById(id);
+        if (essentialHolidayComparison.getOpenFlag() == 0) {
+            essentialHolidayComparisonMapper.update(null, new LambdaUpdateWrapper<EssentialHolidayComparison>().eq(EssentialHolidayComparison::getId, id).set(EssentialHolidayComparison::getOpenFlag, 1));
+        } else {
+            essentialHolidayComparisonMapper.update(null, new LambdaUpdateWrapper<EssentialHolidayComparison>().eq(EssentialHolidayComparison::getId, id).set(EssentialHolidayComparison::getOpenFlag, 0));
+        }
+        return true;
+    }
+
+    /**
+     * 核销订单前效验
+     *
+     * @param orderCode
+     * @return
+     */
+    @Override
+    public R<String> orderVerify(String orderCode) {
+        OrderCouponMiddle orderCouponMiddle = orderCouponMiddleMapper.selectOne(new LambdaQueryWrapper<OrderCouponMiddle>().eq(OrderCouponMiddle::getCouponCode, orderCode));
+        if (!StringUtils.isEmpty(orderCouponMiddle) && orderCouponMiddle.getStatus() == 1) {
+            LifeUserOrder lifeUserOrder = lifeUserOrderMapper.selectOne(new LambdaQueryWrapper<LifeUserOrder>().eq(LifeUserOrder::getId, orderCouponMiddle.getOrderId()));
+            //类型为:1 代金券订单
+            if (lifeUserOrder.getCouponType() == 1) {
+                return couponVerification(orderCouponMiddle);
+            } else if (lifeUserOrder.getCouponType() == 2) {//类型为:2 团购订单
+                return groupVerification(orderCouponMiddle);
+            }
+        }
+        return R.fail("该劵不是待使用状态");
+    }
+
+    public static boolean isCurrentDateInAnyRange(String[] dateRanges) {
+        // 获取当前日期
+        LocalDate currentDate = LocalDate.now();
+        // 定义日期格式
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+
+        // 遍历数组中的每一对日期范围
+        for (String range : dateRanges) {
+            // 分割每一对日期(开始日期和结束日期)
+            String[] dates = range.split(",");
+            if (dates.length != 2) {
+                // 格式不正确,跳过这一对
+                continue;
+            }
+            try {
+                // 解析开始日期和结束日期
+                LocalDate startDate = LocalDate.parse(dates[0], formatter);
+                LocalDate endDate = LocalDate.parse(dates[1], formatter);
+
+                // 检查当前日期是否在范围内(包括开始和结束日期)
+                if (!currentDate.isBefore(startDate) &&
+                        !currentDate.isAfter(endDate)) {
+                    return true;
+                }
+            } catch (Exception e) {
+                // 日期解析错误,跳过这一对
+                continue;
+            }
+        }
+        // 没有任何一对日期范围包含当前日期
+        return false;
+    }
+
+    public R<String> groupVerification(OrderCouponMiddle orderCouponMiddle) {
+        LifeGroupBuyMain lifeGroupBuyMain = lifeGroupBuyMainMapper.selectOne(new LambdaQueryWrapper<LifeGroupBuyMain>().eq(LifeGroupBuyMain::getId, orderCouponMiddle.getCouponId()));
+        //团购有效期类型为:0 指定天数
+        if (lifeGroupBuyMain.getEffectiveDateType() == 0) {
+            //订单支付时间加上指定天数 为团购劵有效期
+            LifeUserOrder lifeUserOrder = lifeUserOrderMapper.selectOne(new LambdaQueryWrapper<LifeUserOrder>().eq(LifeUserOrder::getId, orderCouponMiddle.getOrderId()));
+            LocalDate localDate = lifeUserOrder.getPayTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
+            LocalDate validityPeriod = localDate.plusDays(Long.parseLong(lifeGroupBuyMain.getEffectiveDateValue()));
+            LocalDate nowDate = LocalDate.now(); // 获取当前时间
+            if (nowDate.isAfter(validityPeriod)) {
+                return R.fail("该劵不在有效期内");
+            }
+        } else if (lifeGroupBuyMain.getEffectiveDateType() == 1) {//类型为:1 指定时间段
+            String[] strings = lifeGroupBuyMain.getEffectiveDateValue().split(",");
+            String startDate = strings[0];
+            String endDate = strings[1];
+            LocalDate localStartDate = LocalDate.parse(startDate);
+            LocalDate localEndDate = LocalDate.parse(endDate);
+            LocalDate nowDate = LocalDate.now(); // 获取当前时间
+            if (nowDate.isAfter(localEndDate) || nowDate.isBefore(localStartDate)) {
+                return R.fail("该劵不在有效期内");
+            }
+        }
+        //判断订单是否在不可用日期内
+        //判断当前日期是否在不可用星期
+        if (lifeGroupBuyMain.getDisableDateType() == 1) {//限制日期: 1234567;节日id
+            LocalDate nowDate = LocalDate.now(); // 获取当前时间
+            DayOfWeek dayOfWeek = nowDate.getDayOfWeek();
+            String week = dayOfWeek.getDisplayName(TextStyle.FULL, Locale.CHINA);
+            String beforeSemicolon = lifeGroupBuyMain.getDisableDateValue().split(";")[0];
+            if (!StringUtils.isEmpty(beforeSemicolon)) {
+                List<String> collectUnavailableDate = Arrays.stream(beforeSemicolon.split(",")).map(String::trim).collect(Collectors.toList());
+                boolean isExist = collectUnavailableDate.stream().anyMatch(s -> s.equals(week));
+                if (isExist) {
+                    return R.fail("该劵在不可用日期内");
+                }
+            }
+            //判断当前日期是否在不可用节日
+            String[] strings = lifeGroupBuyMain.getDisableDateValue().split(";");
+            if (strings.length > 1) {
+                String afterSemicolon = lifeGroupBuyMain.getDisableDateValue().split(";")[1];
+                List<String> collectUnavailableDate = Arrays.stream(afterSemicolon.split(",")).map(String::trim).collect(Collectors.toList());
+                List<EssentialHolidayComparison> essentialHolidayComparisons = essentialHolidayComparisonMapper.
+                        selectList(new LambdaQueryWrapper<EssentialHolidayComparison>().in(EssentialHolidayComparison::getId, collectUnavailableDate));
+                boolean isExist = essentialHolidayComparisons.stream().anyMatch(s -> !nowDate.isBefore(s.getStartTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate())
+                        && !nowDate.isAfter(s.getEndTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate()));
+                if (isExist) {
+                    return R.fail("该劵在不可用日期内");
+                }
+            }
+        }
+        //判断当前日期是否在自定义不可用日期内
+        if (lifeGroupBuyMain.getDisableDateType() == 2) {
+            String[] customDate = lifeGroupBuyMain.getDisableDateValue().split(";");
+            boolean isExist = isCurrentDateInAnyRange(customDate);
+            if (isExist) {
+                return R.fail("该劵在不可用日期内");
+            }
+        }
+        return R.success("效验通过");
+    }
+
+    public R<String> couponVerification(OrderCouponMiddle orderCouponMiddle) {
+        LifeCoupon lifeCoupon = lifeCouponMapper.selectOne(new LambdaQueryWrapper<LifeCoupon>().eq(LifeCoupon::getId, orderCouponMiddle.getCouponId()));
+        //代金券有效期类型为:1 指定天数
+        if (lifeCoupon.getExpirationType().equals("1")) {
+            //订单支付时间加上指定天数 为团购劵有效期
+            LifeUserOrder lifeUserOrder = lifeUserOrderMapper.selectOne(new LambdaQueryWrapper<LifeUserOrder>().eq(LifeUserOrder::getId, orderCouponMiddle.getOrderId()));
+            LocalDate localDate = lifeUserOrder.getPayTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
+            LocalDate validityPeriod = localDate.plusDays(lifeCoupon.getExpirationDate());
+            LocalDate nowDate = LocalDate.now(); // 获取当前时间
+            if (nowDate.isAfter(validityPeriod)) {
+                return R.fail("该劵不在有效期内");
+            }
+        } else if (lifeCoupon.getExpirationType().equals("2")) {//类型为:2 指定时间段
+            String[] strings = lifeCoupon.getValidityPeriod().split(",");
+            long start = Long.parseLong(strings[0]);
+            long end = Long.parseLong(strings[1]);
+            LocalDate startDate = Instant.ofEpochMilli(start)
+                    .atZone(ZoneId.systemDefault())
+                    .toLocalDate();
+            LocalDate endDate = Instant.ofEpochMilli(end)
+                    .atZone(ZoneId.systemDefault())
+                    .toLocalDate();
+            LocalDate nowDate = LocalDate.now(); // 获取当前时间
+            if (nowDate.isAfter(endDate) || nowDate.isBefore(startDate)) {
+                return R.fail("该劵不在有效期内");
+            }
+        }
+
+        //判断代金券订单是否在不可用日期内
+        //判断当前日期是否在不可用星期
+        if (lifeCoupon.getUnusedType().equals("2")) {//限制日期: 1234567;节日id
+            LocalDate nowDate = LocalDate.now(); // 获取当前时间
+            DayOfWeek dayOfWeek = nowDate.getDayOfWeek();
+            String week = dayOfWeek.getDisplayName(TextStyle.FULL, Locale.CHINA);
+            String beforeSemicolon = lifeCoupon.getUnavaiLableDate().split(";")[0];
+            if (!StringUtils.isEmpty(beforeSemicolon)) {
+                List<String> collectUnavailableDate = Arrays.stream(beforeSemicolon.split(",")).map(String::trim).collect(Collectors.toList());
+                boolean isExist = collectUnavailableDate.stream().anyMatch(s -> s.equals(week));
+                if (isExist) {
+                    return R.fail("该劵在不可用日期内");
+                }
+            }
+
+            //判断当前日期是否在不可用节日
+            String[] strings = lifeCoupon.getUnavaiLableDate().split(";");
+            if (strings.length > 1) {
+                String afterSemicolon = lifeCoupon.getUnavaiLableDate().split(";")[1];
+                List<String> collectUnavailableDate = Arrays.stream(afterSemicolon.split(",")).map(String::trim).collect(Collectors.toList());
+                List<EssentialHolidayComparison> essentialHolidayComparisons = essentialHolidayComparisonMapper.
+                        selectList(new LambdaQueryWrapper<EssentialHolidayComparison>().in(EssentialHolidayComparison::getId, collectUnavailableDate));
+                boolean isExist = essentialHolidayComparisons.stream().anyMatch(s -> !nowDate.isBefore(s.getStartTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate())
+                        && !nowDate.isAfter(s.getEndTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate()));
+                if (isExist) {
+                    return R.fail("该劵在不可用日期内");
+                }
+            }
+        }
+        //判断当前日期是否在自定义不可用日期内
+        if (lifeCoupon.getUnusedType().equals("3")) {
+            String[] customDate = lifeCoupon.getUnavaiLableDate().split(";");
+            boolean isExist = isCurrentDateInAnyRange(customDate);
+            if (isExist) {
+                return R.fail("该劵在不可用日期内");
+            }
+        }
+    /*    //有效期到
+        Date date = DateUtils.calcDays(orderCouponMiddle.getCreatedTime(), lifeCoupon.getExpirationDate());
+        //开始时间段
+        int beginUseTime = Integer.parseInt(lifeCoupon.getBuyUseStartTime());
+        //结束时间段
+        int endUseTime = Integer.parseInt(lifeCoupon.getBuyUseEndTime());
+        if (new Date().after(date)) {
+            return R.fail("该劵已过期");
+        }
+        if (endUseTime < beginUseTime) {
+            if (!(LocalDateTime.now().getHour() >= beginUseTime || LocalDateTime.now().getHour() < endUseTime)) {
+                return R.fail("该劵未到使用时间");
+            }
+        } else if (endUseTime > beginUseTime) {
+            if (LocalDateTime.now().getHour() < beginUseTime || LocalDateTime.now().getHour() >= endUseTime) {
+                return R.fail("该劵未到使用时间");
+            }
+        }*/
+        // 判断是否在使用时间内
+        Integer buyUseStartTime = Integer.parseInt(lifeCoupon.getBuyUseStartTime());
+        Integer buyUseEndTime = Integer.parseInt(lifeCoupon.getBuyUseEndTime());
+        // 获取当前小时
+        LocalTime now = LocalTime.now();
+        int currentHour = now.getHour();
+        // 验证输入的小时是否有效
+        if (buyUseStartTime < 0 || buyUseStartTime > 24 || buyUseEndTime < 0 || buyUseEndTime > 24) {
+            return R.fail("小时必须在0-23之间");
+        }
+        // 处理跨天的情况,例如22点到次日3点
+        if (buyUseStartTime >= buyUseEndTime) {
+            if (currentHour < buyUseStartTime && currentHour > buyUseEndTime) {
+                return R.fail("该劵不在有效期内");
+            }
+
+        } else {
+            if (!(currentHour >= buyUseStartTime && currentHour <= buyUseEndTime)) {
+                return R.fail("该劵不在有效期内");
+            }
+        }
+
+        // 获取当天开始时间(00:00:00)
+        LocalDateTime todayStart = LocalDateTime.of(LocalDate.now(), LocalTime.MIN);
+        // 获取当天结束时间(23:59:59.999)
+        LocalDateTime todayEnd = LocalDateTime.of(LocalDate.now(), LocalTime.MAX);
+        if(!lifeCoupon.getSingleCanUse().equals("0")){
+            Integer orderNum = orderCouponMiddleMapper.selectCount(new LambdaQueryWrapper<OrderCouponMiddle>()
+                    .eq(OrderCouponMiddle :: getOrderId, orderCouponMiddle.getOrderId())
+                    .between(OrderCouponMiddle :: getUsedTime,todayStart,todayEnd)
+                    .eq(OrderCouponMiddle ::getStatus, 2)
+            );
+            if(orderNum >= Integer.parseInt(lifeCoupon.getSingleCanUse())){
+                return R.fail("该订单已经超过今日单次核销数量");
+            }
+        }
+        return R.success("效验通过");
+    }
+
+}

+ 162 - 76
alien-store-platform/src/main/java/shop/alien/storeplatform/service/impl/LifeGroupBuyServiceImpl.java → alien-store-platform/src/main/java/shop/alien/storeplatform/service/impl/LifeGroupBuyPlatformServiceImpl.java

@@ -18,11 +18,12 @@ import shop.alien.entity.store.dto.LifeGroupBuyDto;
 import shop.alien.entity.store.vo.LifeGroupBuyNameThaliVo;
 import shop.alien.entity.store.vo.LifeGroupBuyThaliVo;
 import shop.alien.entity.store.vo.StoreMenuVo;
-import shop.alien.entity.storePlantform.LifeGroupBuyMainPlantform;
-import shop.alien.entity.storePlantform.vo.LifeGroupBuyPlantformDto;
+import shop.alien.entity.storePlatform.LifeGroupBuyMainPlatform;
+import shop.alien.entity.storePlatform.vo.LifeGroupBuyPlatformDto;
+import shop.alien.entity.storePlatform.vo.LifeGroupThalisPlatformDto;
 import shop.alien.mapper.*;
 import shop.alien.mapper.storePlantform.LifeGroupBuyMainPlantformMapper;
-import shop.alien.storeplatform.service.LifeGroupBuyService;
+import shop.alien.storeplatform.service.LifeGroupBuyPlatformService;
 import shop.alien.util.common.JwtUtil;
 
 import java.math.BigDecimal;
@@ -35,7 +36,7 @@ import java.util.stream.Collectors;
  */
 @Service
 @RequiredArgsConstructor
-public class LifeGroupBuyServiceImpl extends ServiceImpl<LifeGroupBuyMainMapper, LifeGroupBuyMain> implements LifeGroupBuyService {
+public class LifeGroupBuyPlatformServiceImpl extends ServiceImpl<LifeGroupBuyMainMapper, LifeGroupBuyMain> implements LifeGroupBuyPlatformService {
 
     /**
      * 团购主表 Mapper
@@ -91,39 +92,49 @@ public class LifeGroupBuyServiceImpl extends ServiceImpl<LifeGroupBuyMainMapper,
      * @date 2025-11-11
      */
     @Override
-    public boolean saveDraft(LifeGroupBuyPlantformDto lifeGroupBuyDto) {
-        LifeGroupBuyMainPlantform lifeGroupBuyMain = lifeGroupBuyDto.getLifeGroupBuyMain();
-        List<LifeGroupBuyThali> lifeGroupBuyThalis = lifeGroupBuyDto.getLifeGroupBuyThalis();
+    public boolean saveDraft(LifeGroupBuyPlatformDto lifeGroupBuyDto) {
+        LifeGroupBuyMainPlatform lifeGroupBuyMain = lifeGroupBuyDto.getLifeGroupBuyMain();
+        List<LifeGroupBuyThali> lifeGroupBuyThalis = new ArrayList<>();
+
+        // 套餐菜品拼接
+        if (lifeGroupBuyDto.getLifeGroupBuyThalis().size() > 0 ) {
+            lifeGroupBuyDto.getLifeGroupBuyThalis().forEach(lifeGroupBuyThali -> {
+                lifeGroupBuyThali.getDishes().forEach( lifeGroupBuyDish -> {
+                    LifeGroupBuyThali row = new LifeGroupBuyThali();
+                    row.setGroupName(lifeGroupBuyThali.getGroupName());
+                    row.setDetailId(lifeGroupBuyDish.getDetailId());
+                    row.setDishName(lifeGroupBuyDish.getDishName());
+                    row.setDishesUnit(lifeGroupBuyDish.getDishesUnit());
+                    row.setQty(lifeGroupBuyDish.getQty());
+                    lifeGroupBuyThalis.add(row);
+                });
+            });
+        }
 
 
+        // 拼接有效期
         if (lifeGroupBuyMain.getEffectiveDateType() != null && lifeGroupBuyMain.getEffectiveDateType() == 1) {
-            List<String> expirationDate = lifeGroupBuyMain.getExpirationDate();
-            if (ObjectUtils.isNotEmpty(expirationDate)) {
-                lifeGroupBuyMain.setEffectiveDateValue(String.join(",", expirationDate));
+            List<String> expirationDateList = lifeGroupBuyMain.getExpirationDateList();
+            if (ObjectUtils.isNotEmpty(expirationDateList)) {
+                lifeGroupBuyMain.setEffectiveDateValue(String.join(",", expirationDateList));
             } else {
                 lifeGroupBuyMain.setEffectiveDateValue("");
             }
+        } else {
+            lifeGroupBuyMain.setEffectiveDateValue(lifeGroupBuyMain.getExpirationDate());
         }
 
+        // 拼接不可用日期(自定义不可用日期)
         if (lifeGroupBuyMain.getDisableDateType() != null && lifeGroupBuyMain.getDisableDateType() == 2) {
-            lifeGroupBuyMain.getDisableDateList()
-            if (ObjectUtils.isNotEmpty()) {
-                lifeGroupBuyMain.setEffectiveDateValue(String.join(",", disableDateList));
-            } else {
-                lifeGroupBuyMain.setEffectiveDateValue("");
-            }
+            // 二维数组拼接成String类型
+            String row = lifeGroupBuyMain.getDisableDateList().stream()
+                    .map(range -> String.join(",", range))
+                    .collect(Collectors.joining(";"));
+            // 添加不可用日期
+            lifeGroupBuyMain.setDisableDateValue(row);
         }
 
-
-
-
-
-
-
-
-
-
-
+        lifeGroupBuyMain.setWriteOff("手动核销");
 
         JSONObject currentUserInfo = JwtUtil.getCurrentUserInfo();
         Integer userId = null;
@@ -170,14 +181,57 @@ public class LifeGroupBuyServiceImpl extends ServiceImpl<LifeGroupBuyMainMapper,
      * @date 2025-11-11
      */
     @Override
-    public LifeGroupBuyThali saveThali(LifeGroupBuyDto lifeGroupBuyDto) {
+    public LifeGroupBuyThali saveThali(LifeGroupBuyPlatformDto lifeGroupBuyDto) {
+
+        LifeGroupBuyMainPlatform lifeGroupBuyMain = lifeGroupBuyDto.getLifeGroupBuyMain();
+        List<LifeGroupBuyThali> lifeGroupBuyThalis = new ArrayList<>();
+
+
+        if (lifeGroupBuyDto.getLifeGroupBuyThalis().size() > 0 ) {
+            lifeGroupBuyDto.getLifeGroupBuyThalis().forEach(lifeGroupBuyThali -> {
+                lifeGroupBuyThali.getDishes().forEach( lifeGroupBuyDish -> {
+                    LifeGroupBuyThali row = new LifeGroupBuyThali();
+                    row.setGroupName(lifeGroupBuyThali.getGroupName());
+                    row.setDetailId(lifeGroupBuyDish.getDetailId());
+                    row.setDishName(lifeGroupBuyDish.getDishName());
+                    row.setDishesUnit(lifeGroupBuyDish.getDishesUnit());
+                    row.setQty(lifeGroupBuyDish.getQty());
+                    lifeGroupBuyThalis.add(row);
+                });
+            });
+        }
+
+
+        // 拼接有效期
+        if (lifeGroupBuyMain.getEffectiveDateType() != null && lifeGroupBuyMain.getEffectiveDateType() == 1) {
+            List<String> expirationDateList = lifeGroupBuyMain.getExpirationDateList();
+            if (ObjectUtils.isNotEmpty(expirationDateList)) {
+                lifeGroupBuyMain.setEffectiveDateValue(String.join(",", expirationDateList));
+            } else {
+                lifeGroupBuyMain.setEffectiveDateValue("");
+            }
+        } else {
+            lifeGroupBuyMain.setEffectiveDateValue(lifeGroupBuyMain.getExpirationDate());
+        }
+
+        // 拼接不可用日期(自定义不可用日期)
+        if (lifeGroupBuyMain.getDisableDateType() != null && lifeGroupBuyMain.getDisableDateType() == 2) {
+            // 二维数组拼接成String类型
+            String row = lifeGroupBuyMain.getDisableDateList().stream()
+                    .map(range -> String.join(",", range))
+                    .collect(Collectors.joining(";"));
+            // 添加不可用日期
+            lifeGroupBuyMain.setDisableDateValue(row);
+        }
+
+        lifeGroupBuyMain.setWriteOff("手动核销");
+
         JSONObject currentUserInfo = JwtUtil.getCurrentUserInfo();
         Integer userId = null;
         if (!ObjectUtils.isEmpty(currentUserInfo)) {
             userId = currentUserInfo.getInteger("userId");
         }
-        LifeGroupBuyMain lifeGroupBuyMain = lifeGroupBuyDto.getLifeGroupBuyMain();
-        List<LifeGroupBuyThali> lifeGroupBuyThalis = lifeGroupBuyDto.getLifeGroupBuyThalis();
+
         LifeGroupBuyThali lifeGroupBuyThali = null;
         if (ObjectUtils.isEmpty(lifeGroupBuyMain.getId())) {
             Integer count = lifeGroupBuyMainMapper.selectCount(new LambdaQueryWrapper<LifeGroupBuyMain>().like(LifeGroupBuyMain::getCreatedTime, DateUtils.formatDate(new Date(), "yyyy-MM-dd")).eq(LifeGroupBuyMain::getStoreId, lifeGroupBuyMain.getStoreId()));
@@ -272,19 +326,27 @@ public class LifeGroupBuyServiceImpl extends ServiceImpl<LifeGroupBuyMainMapper,
      * @date 2025-11-11
      */
     @Override
-    public LifeGroupBuyThaliVo getThaliById(String id, String userId) {
+    public LifeGroupBuyPlatformDto getThaliById(String id, String userId) {
+
+        LifeGroupBuyPlatformDto dto = new LifeGroupBuyPlatformDto();
+
+        // 获取团购信息
         LifeGroupBuyMain lifeGroupBuyMain = lifeGroupBuyMainMapper.selectById(id);
-        LifeGroupBuyThaliVo lifeGroupBuyThaliVo = new LifeGroupBuyThaliVo();
-        BeanUtils.copyProperties(lifeGroupBuyMain, lifeGroupBuyThaliVo);
-        List<LifeGroupBuyThali> lifeGroupBuyThalis = lifeGroupBuyThaliMapper.selectList(new LambdaQueryWrapper<LifeGroupBuyThali>().eq(LifeGroupBuyThali::getParentId, id).eq(LifeGroupBuyThali::getDeleteFlag, 0));
+
+        // 创建 LifeGroupBuyMainPlatform 对象并复制属性
+        LifeGroupBuyMainPlatform platform = new LifeGroupBuyMainPlatform();
+        BeanUtils.copyProperties(lifeGroupBuyMain, platform);
 
         // 是否收藏了该团购
         LifeCollect lifeCollect = lifeCollectMapper.selectOne(new QueryWrapper<LifeCollect>().eq("user_id", userId).eq("coupon_id", id));
-        lifeGroupBuyThaliVo.setIsCollect("0");
+        dto.setIsCollect("0");
         if (!Objects.isNull(lifeCollect)) {
-            lifeGroupBuyThaliVo.setIsCollect("1");
+            dto.setIsCollect("1");
         }
-        //美食
+
+        // 获取团购菜品信息
+        List<LifeGroupBuyThali> lifeGroupBuyThalis = lifeGroupBuyThaliMapper.selectList(new LambdaQueryWrapper<LifeGroupBuyThali>().eq(LifeGroupBuyThali::getParentId, id).eq(LifeGroupBuyThali::getDeleteFlag, 0));
+        // 菜品拼接
         if (lifeGroupBuyMain.getGroupType() == 1) {
             for (LifeGroupBuyThali lifeGroupBuyThali : lifeGroupBuyThalis) {
                 if (StringUtils.isNotEmpty(lifeGroupBuyThali.getDetailId())) {
@@ -300,21 +362,45 @@ public class LifeGroupBuyServiceImpl extends ServiceImpl<LifeGroupBuyMainMapper,
         }
 
         Map<String, List<LifeGroupBuyThali>> collect = lifeGroupBuyThalis.stream().collect(Collectors.groupingBy(LifeGroupBuyThali::getGroupName));
-        List<LifeGroupBuyNameThaliVo> resultMap = new ArrayList<>();
+
+
+        List<LifeGroupThalisPlatformDto> thalis = new ArrayList<>();
         List<String> keys = collect.entrySet().stream().sorted(Comparator.comparingInt(i -> i.getValue().get(0).getDetailSort())).map(Map.Entry::getKey).collect(Collectors.toList());
         for (String key : keys) {
-            LifeGroupBuyNameThaliVo lifeGroupBuyNameThaliVo = new LifeGroupBuyNameThaliVo();
-            lifeGroupBuyNameThaliVo.setGroupName(key);
-            lifeGroupBuyNameThaliVo.setDetails(collect.get(key).stream().sorted(Comparator.comparingInt(LifeGroupBuyThali::getDetailSort)).collect(Collectors.toList()));
-            resultMap.add(lifeGroupBuyNameThaliVo);
+            LifeGroupThalisPlatformDto lifeGroupThalisPlatformDto = new LifeGroupThalisPlatformDto();
+            lifeGroupThalisPlatformDto.setGroupName(key);
+            lifeGroupThalisPlatformDto.setDishes(collect.get(key).stream().sorted(Comparator.comparingInt(LifeGroupBuyThali::getDetailSort)).collect(Collectors.toList()));
+            thalis.add(lifeGroupThalisPlatformDto);
         }
-        lifeGroupBuyThaliVo.setDetails(resultMap);
-        getMainImgAndDisableDate(lifeGroupBuyThaliVo);
+        dto.setLifeGroupBuyThalis(thalis);
 
-        //已售数量
-        lifeGroupBuyThaliVo.setSaleNum(lifeUserOrderMapper.countBuyGroup(id));
+        //图片
+        if (StringUtils.isNotEmpty(platform.getImageId())) {
+            List<String> imgIds = Arrays.asList(platform.getImageId().split(","));
+            List<StoreImg> storeImgs = storeImgMapper.selectList(new LambdaQueryWrapper<StoreImg>().in(StoreImg::getId, imgIds));
+            if (ObjectUtils.isNotEmpty(storeImgs)) {
+                platform.setImageValueStr(storeImgs.stream().map(StoreImg::getImgUrl).collect(Collectors.toList()));
+            }
+        }
+
+        // 拼接有效期
+        if (platform.getEffectiveDateType() != null && platform.getEffectiveDateType() == 1) {
+            if (ObjectUtils.isNotEmpty(platform.getEffectiveDateValue())) {
+                platform.setExpirationDateList(Arrays.asList(platform.getEffectiveDateValue().split(",")));
+            }
+        }
+
+        // 拼接不可用日期(自定义不可用日期)
+        if (platform.getDisableDateType() != null && platform.getDisableDateType() == 2) {
+            // String拼接成二维数组类型
+            List<List<String>> disableDateList = Arrays.stream(platform.getDisableDateValue().split(";"))
+                    .map(range -> Arrays.asList(range.split(",")))
+                    .collect(Collectors.toList());
+            platform.setDisableDateList(disableDateList);
+        }
 
-        return lifeGroupBuyThaliVo;
+        dto.setLifeGroupBuyMain(platform);
+        return dto;
     }
 
     /**
@@ -458,37 +544,37 @@ public class LifeGroupBuyServiceImpl extends ServiceImpl<LifeGroupBuyMainMapper,
             record.setReviewType("审核通过");
         } else if (record.getStatus() == 3) {
             record.setReviewType("审核拒绝");
+        }
 
-            if (Objects.nonNull(record.getStatus())) {
-                switch (record.getStatus()) {
-                    case 0:
-                        record.setStatusName("草稿");
-                        break;
-                    case 1:
-                        record.setStatusName("待审核");
-                        break;
-                    case 2:
-                        record.setStatusName("未开始");
-                        break;
-                    case 3:
-                        record.setStatusName("审核拒绝");
-                        break;
-                    case 4:
-                        record.setStatusName("已售罄");
-                        break;
-                    case 5:
-                        record.setStatusName("进行中");
-                        break;
-                    case 6:
-                        record.setStatusName("已下架");
-                        break;
-                    case 7:
-                        record.setStatusName("已结束");
-                        break;
-                    default:
-                        record.setStatusName("未知状态");
-                        break;
-                }
+        if (Objects.nonNull(record.getStatus())) {
+            switch (record.getStatus()) {
+                case 0:
+                    record.setStatusName("草稿");
+                    break;
+                case 1:
+                    record.setStatusName("待审核");
+                    break;
+                case 2:
+                    record.setStatusName("未开始");
+                    break;
+                case 3:
+                    record.setStatusName("审核拒绝");
+                    break;
+                case 4:
+                    record.setStatusName("已售罄");
+                    break;
+                case 5:
+                    record.setStatusName("进行中");
+                    break;
+                case 6:
+                    record.setStatusName("已下架");
+                    break;
+                case 7:
+                    record.setStatusName("已结束");
+                    break;
+                default:
+                    record.setStatusName("未知状态");
+                    break;
             }
         }
 

+ 285 - 0
alien-store-platform/src/main/java/shop/alien/storeplatform/service/impl/StoreMenuPlatformServiceImpl.java

@@ -0,0 +1,285 @@
+package shop.alien.storeplatform.service.impl;
+
+import cn.hutool.core.collection.CollectionUtil;
+import com.alibaba.nacos.common.utils.CollectionUtils;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.RequiredArgsConstructor;
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Service;
+import shop.alien.entity.result.R;
+import shop.alien.entity.store.LifeGroupBuyThali;
+import shop.alien.entity.store.LifeLikeRecord;
+import shop.alien.entity.store.StoreImg;
+import shop.alien.entity.store.StoreMenu;
+import shop.alien.entity.store.vo.StoreMenuVo;
+import shop.alien.mapper.LifeGroupBuyThaliMapper;
+import shop.alien.mapper.LifeLikeRecordMapper;
+import shop.alien.mapper.StoreImgMapper;
+import shop.alien.mapper.StoreMenuMapper;
+import shop.alien.storeplatform.service.StoreMenuPlatformService;
+
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * 二期-门店推荐 服务实现类
+ *
+ * @author ssk
+ * @since 2024-12-05
+ */
+@Service
+@RequiredArgsConstructor
+public class StoreMenuPlatformServiceImpl extends ServiceImpl<StoreMenuMapper, StoreMenu> implements StoreMenuPlatformService {
+
+    private final StoreMenuMapper storeMenuMapper;
+
+    private final LifeLikeRecordMapper lifeLikeRecordMapper;
+
+    private final StoreImgMapper storeImgMapper;
+
+    private final LifeGroupBuyThaliMapper lifeGroupBuyThaliMapper;
+
+    /**
+     * 获取门店菜单
+     *
+     * @param storeId  门店id
+     * @param dishType 菜品类型, 0:菜单, 1:推荐
+     * @param phoneId  消息标识
+     * @return list
+     */
+    @Override
+    public List<StoreMenuVo> getStoreMenu(Integer storeId, Integer dishType, String phoneId) {
+
+        if (dishType == 0) {
+            List<StoreMenuVo> collect = storeMenuMapper.getStoreMenuList(storeId, null);
+            return collect.stream().sorted(Comparator.comparing(StoreMenuVo::getSort)).collect(Collectors.toList());
+        } else {
+            List<StoreMenuVo> collect = storeMenuMapper.getStoreMenuList(storeId, dishType);
+            collect.forEach(item -> {
+                if (StringUtils.isNotEmpty(phoneId)) {
+                    LambdaQueryWrapper<LifeLikeRecord> query = new LambdaQueryWrapper<>();
+                    query.eq(LifeLikeRecord::getDianzanId, phoneId).eq(LifeLikeRecord::getHuifuId, item.getId());
+                    Integer i = lifeLikeRecordMapper.selectCount(query);
+                    if (i > 0) {
+                        item.setIsLike(1);
+                    } else {
+                        item.setIsLike(0);
+                    }
+                }
+            });
+            return collect.stream().sorted(Comparator.comparing(StoreMenuVo::getSort)).collect(Collectors.toList());
+        }
+    }
+
+    /**
+     * 获取菜品详情
+     *
+     * @param id 菜品id
+     * @return StoreMenuVo
+     */
+    @Override
+    public StoreMenuVo getMenuInfo(Integer id) {
+        return storeMenuMapper.getMenuInfo(id);
+    }
+
+    /**
+     * 新增或修改门店菜品
+     *
+     * @param storeMenu 菜品信息
+     * @return 处理结果
+     */
+    @Override
+    public R<String> saveOrUpdateMenu(StoreMenu storeMenu) {
+        boolean flag = false;
+        LambdaQueryWrapper<StoreMenu> storeMenuLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        //修改菜品
+        if (storeMenu.getId() != null) {
+            flag = this.updateById(storeMenu);
+            if (!flag) {
+                log.error("菜单修改失败");
+                return R.fail("菜单修改失败");
+            }
+            return R.success("菜单修改成功");
+        } else {//新增菜品
+            if (StringUtils.isEmpty(storeMenu.getDishName())) {
+                return R.fail("请输入菜品名称");
+            }
+            storeMenuLambdaQueryWrapper.eq(StoreMenu::getStoreId, storeMenu.getStoreId());
+            List<StoreMenu> menuList = this.list(storeMenuLambdaQueryWrapper);
+            if (CollectionUtil.isNotEmpty(menuList)) {
+                int maxSort = menuList.stream().map(StoreMenu::getSort).reduce(Integer::max).get();
+                storeMenu.setSort(maxSort + 1);
+            } else {
+                storeMenu.setSort(1);
+            }
+            //保存菜品
+            flag = this.save(storeMenu);
+            if (!flag) {
+                return R.fail("菜品新增失败");
+            }
+        }
+        return R.success("新增菜品成功");
+    }
+
+    /**
+     * 新增或修改门店菜品new
+     *
+     * @param storeMenuVo 菜品信息
+     * @return 处理结果
+     */
+    @Override
+    public R<String> saveOrUpdateMenus(StoreMenuVo storeMenuVo) {
+        boolean flag = false;
+        LambdaQueryWrapper<StoreMenu> storeMenuLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        int imgId = 0;
+        if (storeMenuVo.getImgId() == null || storeMenuVo.getImgId() == 0) {
+            StoreImg storeImg = new StoreImg();
+            storeImg.setStoreId(storeMenuVo.getStoreId());
+            storeImg.setImgType(7);
+            storeImg.setImgUrl(storeMenuVo.getImgUrl());
+            storeImg.setImgDescription(storeMenuVo.getDishName());
+            storeImgMapper.insert(storeImg);
+            imgId = storeImg.getId();
+        } else {
+            imgId = storeMenuVo.getImgId();
+        }
+
+        // 封装storeMenu参数
+        StoreMenu storeMenu = new StoreMenu();
+        BeanUtils.copyProperties(storeMenuVo, storeMenu);
+        storeMenu.setImgId(imgId);
+
+        //修改菜品
+        if (storeMenu.getId() != null) {
+            flag = this.updateById(storeMenu);
+            if (!flag) {
+                log.error("菜单修改失败");
+                return R.fail("菜单修改失败");
+            }
+            return R.success("菜单修改成功");
+        } else {
+            //新增菜品
+            // 校验菜品参数
+            if (StringUtils.isEmpty(storeMenu.getDishName())) {
+                return R.fail("请输入菜品名称");
+            }
+
+            storeMenuLambdaQueryWrapper.eq(StoreMenu::getStoreId, storeMenu.getStoreId());
+            List<StoreMenu> menuList = this.list(storeMenuLambdaQueryWrapper);
+            if (CollectionUtil.isNotEmpty(menuList)) {
+                int maxSort = menuList.stream().map(StoreMenu::getSort).reduce(Integer::max).get();
+                storeMenu.setSort(maxSort + 1);
+            } else {
+                storeMenu.setSort(1);
+            }
+            //保存菜品
+            flag = this.save(storeMenu);
+            if (!flag) {
+                return R.fail("菜品新增失败");
+            }
+        }
+        return R.success("新增菜品成功");
+    }
+
+    /**
+     * 菜品排序信息
+     *
+     * @param storeMenuVo 排序信息
+     * @return 处理结果
+     */
+    @Override
+    public Boolean getSortMenuInfo(StoreMenuVo storeMenuVo) {
+        boolean flag = false;
+        if (CollectionUtil.isNotEmpty(storeMenuVo.getSortList())) {
+            for (int i = 0; i < storeMenuVo.getSortList().size(); i++) {
+                LambdaQueryWrapper<StoreMenu> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+                lambdaQueryWrapper.eq(StoreMenu::getId, storeMenuVo.getSortList().get(i).getId());
+                StoreMenu storeMenu = this.getOne(lambdaQueryWrapper);
+                storeMenu.setSort(i + 1);
+                flag = this.updateById(storeMenu);
+            }
+        }
+        return flag;
+    }
+
+    @Override
+    public Boolean saveMenuSort(List<StoreMenu> storeMenuList) {
+        return this.updateBatchById(storeMenuList);
+    }
+
+    /**
+     * 删除菜品或推荐菜 根据类型区分
+     *
+     * @param ids      菜品ID合集
+     * @param dishType 0:菜品 1:推荐菜
+     * @return 处理结果
+     */
+    @Override
+    public R deleteMenu(List<Integer> ids, int dishType) {
+        QueryWrapper<StoreMenu> queryWrapperMenu = new QueryWrapper<>();
+        boolean flag = false;
+        if (dishType == 0) {
+            List<LifeGroupBuyThali> lifeGroupBuyThaliList = lifeGroupBuyThaliMapper.selectList(new LambdaQueryWrapper<LifeGroupBuyThali>().in(LifeGroupBuyThali::getDetailId, ids));
+            if (CollectionUtil.isNotEmpty(lifeGroupBuyThaliList)) {
+                return R.fail("该菜品已被团购套餐引用,不能删除");
+            }
+            flag = this.removeByIds(ids);
+        } else {
+            queryWrapperMenu.in("id", ids);
+            List<StoreMenu> storeMenuList = baseMapper.selectList(queryWrapperMenu);
+            storeMenuList.forEach(item -> {
+                item.setDishType(0);
+                this.updateById(item);
+            });
+            flag = true;
+        }
+        if (!flag) {
+            return R.fail("删除失败");
+        }
+        return R.success("删除成功");
+    }
+
+    @Override
+    public StoreMenuVo getMenuCountByStoreId(int storeId) {
+        StoreMenuVo storeMenuVo = new StoreMenuVo();
+        LambdaUpdateWrapper<StoreMenu> updateWrapper = new LambdaUpdateWrapper<>();
+        updateWrapper.eq(StoreMenu::getStoreId, storeId);
+        updateWrapper.eq(StoreMenu::getDeleteFlag, 0);
+        List<StoreMenu> storeMenuList = storeMenuMapper.selectList(updateWrapper);
+        if (CollectionUtils.isNotEmpty(storeMenuList)) {
+            storeMenuVo.setMenuCount(storeMenuList.size());
+            Map<Integer, List<StoreMenu>> groupByDishType = storeMenuList.stream()
+                    .collect(Collectors.groupingBy(StoreMenu::getDishType));
+            List<StoreMenu> suggestList = groupByDishType.get(1);
+            if (CollectionUtils.isNotEmpty(suggestList)) {
+                storeMenuVo.setSuggestCount(suggestList.size());
+            } else {
+                storeMenuVo.setSuggestCount(0);
+            }
+        } else {
+            storeMenuVo.setMenuCount(0);
+            storeMenuVo.setSuggestCount(0);
+        }
+        return storeMenuVo;
+    }
+
+    /**
+     * 获取用户对该菜品是否点赞
+     *
+     * @param userId 用户id
+     * @param menuId 菜品id
+     * @return boolean
+     */
+    @Override
+    public boolean getMenuLikeStatus(String userId, Integer menuId) {
+        return lifeLikeRecordMapper.selectCount(new QueryWrapper<LifeLikeRecord>().eq("dianzan_id", userId).eq("huifu_id", menuId).eq("delete_flag", 0)) > 0;
+    }
+}
+
+