| | |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.xiaopeng.api.feignClient.account.XpAppUserCouponClient; |
| | | import com.xiaopeng.api.model.operation.XpCoupon; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.log.annotation.AdminOperationLog; |
| | | import com.xiaopeng.common.log.enums.AdminBusinessType; |
| | | import com.xiaopeng.common.log.enums.AdminOperationType; |
| | | import com.xiaopeng.operation.query.XpCouponListQuery; |
| | | import com.xiaopeng.operation.service.IXpCouponService; |
| | | import com.xiaopeng.operation.vo.XpBannerListVo; |
| | | import io.swagger.annotations.ApiOperation; |
| | | 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.*; |
| | | |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | import java.util.List; |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @author mitao |
| | | * @since 2026-02-03 |
| | | */ |
| | | @Controller |
| | | @RestController |
| | | @RequestMapping("") |
| | | public class XpCouponController { |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | @PostMapping("/inner/xp-coupon/getCouponById") |
| | | @PostMapping("/logan/inner/xp-coupon/getCouponById") |
| | | public R<XpCoupon> getCouponById(@RequestParam Long couponId){ |
| | | XpCoupon xpCoupon = xpCouponService.getById(couponId); |
| | | return R.ok(xpCoupon); |
| | | } |
| | | |
| | | |
| | | // 优惠券列表 |
| | | /** |
| | | * 优惠券列表 |
| | | */ |
| | | @PostMapping("/v1/api/xp-coupon/list") |
| | | @ApiOperation(value = "优惠券列表",tags = {"管理后台-优惠券列表"},response = XpCoupon.class) |
| | | @ApiOperation(value = "优惠券列表",tags = {"管理后台-优惠券"},response = XpCoupon.class) |
| | | public R<Page<XpCoupon>> list(@RequestBody XpCouponListQuery query ){ |
| | | return R.ok(xpCouponService.getList(query)); |
| | | } |
| | | |
| | | |
| | | // 添加优惠券 |
| | | |
| | | |
| | | /** |
| | | * // 添加优惠券 |
| | | * @param xpCoupon |
| | | * @return |
| | | */ |
| | | @PostMapping("/v1/api/xp-coupon/add") |
| | | @ApiOperation(value = "添加优惠券",tags = {"管理后台-添加优惠券"},response = XpCoupon.class) |
| | | @ApiOperation(value = "添加优惠券",tags = {"管理后台-优惠券"},response = XpCoupon.class) |
| | | @AdminOperationLog( |
| | | businessType = AdminBusinessType.COUPON_MANAGEMENT, |
| | | operationType = AdminOperationType.ADD, |
| | | content = "添加优惠券", |
| | | appendRequestData = true |
| | | ) |
| | | public R<?> add(@RequestBody XpCoupon xpCoupon){ |
| | | xpCouponService.save(xpCoupon); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 优惠券详情 |
| | | */ |
| | | @GetMapping("/v1/api/xp-coupon/queryById") |
| | | @ApiOperation(value = "优惠券详情",tags = {"管理后台-优惠券"},response = XpCoupon.class) |
| | | public R<XpCoupon> queryById(@RequestParam Long id){ |
| | | XpCoupon xpCoupon = xpCouponService.getById(id); |
| | | return R.ok(xpCoupon); |
| | | } |
| | | |
| | | |
| | | |
| | | @Resource XpAppUserCouponClient xpAppUserCouponClient; |
| | | |
| | | /** |
| | | * 删除优惠券 |
| | | */ |
| | | @DeleteMapping("/v1/api/xp-coupon/deleteById") |
| | | @ApiOperation(value = "删除优惠券",tags = {"管理后台-优惠券"},response = XpCoupon.class) |
| | | @AdminOperationLog( |
| | | businessType = AdminBusinessType.COUPON_MANAGEMENT, |
| | | operationType = AdminOperationType.DELETE, |
| | | contentExpression = "'删除优惠券,id=' + #p0", |
| | | appendRequestData = false |
| | | ) |
| | | public R<?> deleteById(@RequestParam Long id){ |
| | | |
| | | if (!xpAppUserCouponClient.isHolding(id)){ |
| | | xpCouponService.removeById(id); |
| | | return R.ok(); |
| | | } |
| | | else{ |
| | | return R.fail("该优惠券已有用户使用,无法作废 / 删除"); |
| | | } |
| | | } |
| | | |
| | | } |