You've already forked FrameTour-BE
优惠券相关+后台
This commit is contained in:
@@ -1,42 +1,45 @@
|
||||
package com.ycwl.basic.controller.mobile;
|
||||
|
||||
import com.ycwl.basic.constant.BaseContextHandler;
|
||||
import com.ycwl.basic.model.mobile.coupon.req.ClaimCouponReq;
|
||||
import com.ycwl.basic.model.pc.coupon.entity.CouponEntity;
|
||||
import com.ycwl.basic.model.pc.couponRecord.entity.CouponRecordEntity;
|
||||
import com.ycwl.basic.service.mobile.CouponRecordService;
|
||||
import com.ycwl.basic.service.mobile.AppCouponRecordService;
|
||||
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/coupon/v1")
|
||||
public class AppCouponController {
|
||||
|
||||
@Autowired
|
||||
private CouponRecordService couponRecordService;
|
||||
private AppCouponRecordService appCouponRecordService;
|
||||
|
||||
/**
|
||||
* 根据memberId和faceId查找优惠券记录
|
||||
* 根据memberId、faceId和type查找优惠券记录
|
||||
*/
|
||||
@GetMapping("/records")
|
||||
public ApiResponse<List<CouponRecordEntity>> getCouponRecords(
|
||||
@RequestParam Long memberId,
|
||||
@RequestParam Long faceId) {
|
||||
List<CouponRecordEntity> records = couponRecordService.queryByMemberIdAndFaceId(memberId, faceId);
|
||||
return ApiResponse.success(records);
|
||||
@GetMapping("/record")
|
||||
public ApiResponse<CouponRecordEntity> getCouponRecords(
|
||||
@RequestParam Long faceId,
|
||||
@RequestParam Integer type) {
|
||||
CouponRecordEntity record = appCouponRecordService.queryByMemberIdAndFaceIdAndType(Long.valueOf(BaseContextHandler.getUserId()), faceId, type);
|
||||
return ApiResponse.success(record);
|
||||
}
|
||||
|
||||
/**
|
||||
* 领取优惠券
|
||||
*/
|
||||
@PostMapping("/claim")
|
||||
public ApiResponse<CouponRecordEntity> claimCoupon(
|
||||
@RequestParam Long memberId,
|
||||
@RequestParam Long faceId,
|
||||
@RequestParam Integer type) {
|
||||
public ApiResponse<CouponEntity> claimCoupon(@RequestBody ClaimCouponReq request) {
|
||||
request.setMemberId(Long.valueOf(BaseContextHandler.getUserId()));
|
||||
try {
|
||||
CouponRecordEntity record = couponRecordService.claimCoupon(memberId, faceId, type);
|
||||
return ApiResponse.success(record);
|
||||
CouponEntity coupon = appCouponRecordService.claimCoupon(
|
||||
request.getMemberId(),
|
||||
request.getFaceId(),
|
||||
request.getType()
|
||||
);
|
||||
return ApiResponse.success(coupon);
|
||||
} catch (RuntimeException e) {
|
||||
return ApiResponse.fail(e.getMessage());
|
||||
}
|
||||
|
@@ -0,0 +1,22 @@
|
||||
package com.ycwl.basic.controller.pc;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.ycwl.basic.model.pc.couponRecord.req.CouponRecordPageQueryReq;
|
||||
import com.ycwl.basic.model.pc.couponRecord.resp.CouponRecordPageResp;
|
||||
import com.ycwl.basic.service.pc.CouponRecordService;
|
||||
import com.ycwl.basic.utils.ApiResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/coupon/record/v1")
|
||||
public class CouponRecordController {
|
||||
|
||||
@Autowired
|
||||
private CouponRecordService couponRecordService;
|
||||
|
||||
@PostMapping("/page")
|
||||
public ApiResponse<PageInfo<CouponRecordPageResp>> pageQuery(@RequestBody CouponRecordPageQueryReq query) {
|
||||
return couponRecordService.pageQuery(query);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user