|
|
@@ -0,0 +1,88 @@
|
|
|
+package shop.alien.dining.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.ApiSort;
|
|
|
+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.vo.LifeDiscountCouponVo;
|
|
|
+import shop.alien.dining.service.DiningCouponService;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 点餐模块-优惠券控制器(Feign 调 store,供小程序:我的优惠券/详情/选券)
|
|
|
+ *
|
|
|
+ * @author ssk
|
|
|
+ * @version 1.0
|
|
|
+ * @date 2025/1/29
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Api(tags = {"微信点餐-优惠券(用户端)"})
|
|
|
+@ApiSort(3)
|
|
|
+@CrossOrigin
|
|
|
+@RestController
|
|
|
+@RequestMapping("/dining/coupon")
|
|
|
+@RequiredArgsConstructor
|
|
|
+public class DiningCouponController {
|
|
|
+
|
|
|
+ private final DiningCouponService diningCouponService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取当前用户优惠券列表(分 tab:全部/即将过期/已使用/已过期)
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "获取用户优惠券列表", notes = "需登录,请求头带 Authorization。tabType:0全部未使用,1即将过期,2已使用,3已过期")
|
|
|
+ @GetMapping("/userList")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "page", value = "页码", dataType = "int", paramType = "query", required = true),
|
|
|
+ @ApiImplicitParam(name = "size", value = "每页条数", dataType = "int", paramType = "query", required = true),
|
|
|
+ @ApiImplicitParam(name = "tabType", value = "tab类型:0全部未使用,1即将过期,2已使用,3已过期", dataType = "String", paramType = "query", required = true)
|
|
|
+ })
|
|
|
+ public R<List<LifeDiscountCouponVo>> getUserCouponList(
|
|
|
+ HttpServletRequest request,
|
|
|
+ @RequestParam(value = "page", defaultValue = "1") int page,
|
|
|
+ @RequestParam(value = "size", defaultValue = "10") int size,
|
|
|
+ @RequestParam("tabType") String tabType) {
|
|
|
+ String authorization = request.getHeader("Authorization");
|
|
|
+ return diningCouponService.getUserCouponList(authorization, page, size, tabType);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据优惠券 id 获取优惠券详情(规则、门槛等)
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "获取优惠券详情", notes = "需登录,请求头带 Authorization。counponId 与 store 接口拼写一致")
|
|
|
+ @GetMapping("/detail")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "counponId", value = "优惠券id", dataType = "String", paramType = "query", required = true)
|
|
|
+ })
|
|
|
+ public R<LifeDiscountCouponVo> getCounponDetailById(
|
|
|
+ HttpServletRequest request,
|
|
|
+ @RequestParam("counponId") String counponId) {
|
|
|
+ String authorization = request.getHeader("Authorization");
|
|
|
+ return diningCouponService.getCounponDetailById(authorization, counponId);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取该门店下用户可用/不可用优惠券列表(用于购物车/下单选券,按金额区分)
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "获取门店可用优惠券列表", notes = "需登录。按 storeId+amount 返回可用券与不可用券及原因(满减门槛等)")
|
|
|
+ @GetMapping("/storeUsableList")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "storeId", value = "门店id", dataType = "String", paramType = "query", required = true),
|
|
|
+ @ApiImplicitParam(name = "amount", value = "当前消费金额(满减门槛)", dataType = "BigDecimal", paramType = "query", required = true)
|
|
|
+ })
|
|
|
+ public R<Map<String, Object>> getStoreUserUsableCouponList(
|
|
|
+ HttpServletRequest request,
|
|
|
+ @RequestParam("storeId") String storeId,
|
|
|
+ @RequestParam("amount") BigDecimal amount) {
|
|
|
+ String authorization = request.getHeader("Authorization");
|
|
|
+ return diningCouponService.getStoreUserUsableCouponList(authorization, storeId, amount);
|
|
|
+ }
|
|
|
+}
|