You've already forked FrameTour-BE
优惠券
This commit is contained in:
@@ -1,9 +1,44 @@
|
||||
package com.ycwl.basic.controller.mobile;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ycwl.basic.model.pc.couponRecord.entity.CouponRecordEntity;
|
||||
import com.ycwl.basic.service.mobile.CouponRecordService;
|
||||
import com.ycwl.basic.utils.ApiResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/mobile/controller/v1")
|
||||
@RequestMapping("/api/mobile/coupon/v1")
|
||||
public class AppCouponController {
|
||||
|
||||
@Autowired
|
||||
private CouponRecordService couponRecordService;
|
||||
|
||||
/**
|
||||
* 根据memberId和faceId查找优惠券记录
|
||||
*/
|
||||
@GetMapping("/records")
|
||||
public ApiResponse<List<CouponRecordEntity>> getCouponRecords(
|
||||
@RequestParam Long memberId,
|
||||
@RequestParam Long faceId) {
|
||||
List<CouponRecordEntity> records = couponRecordService.queryByMemberIdAndFaceId(memberId, faceId);
|
||||
return ApiResponse.success(records);
|
||||
}
|
||||
|
||||
/**
|
||||
* 领取优惠券
|
||||
*/
|
||||
@PostMapping("/claim")
|
||||
public ApiResponse<CouponRecordEntity> claimCoupon(
|
||||
@RequestParam Long memberId,
|
||||
@RequestParam Long faceId,
|
||||
@RequestParam Integer type) {
|
||||
try {
|
||||
CouponRecordEntity record = couponRecordService.claimCoupon(memberId, faceId, type);
|
||||
return ApiResponse.success(record);
|
||||
} catch (RuntimeException e) {
|
||||
return ApiResponse.fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user