You've already forked FrameTour-BE
优惠券
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
package com.ycwl.basic.service.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.utils.ApiResponse;
|
||||
|
||||
public interface CouponRecordService {
|
||||
ApiResponse<PageInfo<CouponRecordPageResp>> pageQuery(CouponRecordPageQueryReq query);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.ycwl.basic.service.pc.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.ycwl.basic.mapper.CouponRecordMapper;
|
||||
import com.ycwl.basic.model.pc.couponRecord.entity.CouponRecordEntity;
|
||||
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.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class CouponRecordServiceImpl extends ServiceImpl<CouponRecordMapper, CouponRecordEntity> implements CouponRecordService {
|
||||
|
||||
@Autowired
|
||||
private CouponRecordMapper couponRecordMapper;
|
||||
|
||||
@Override
|
||||
public ApiResponse<PageInfo<CouponRecordPageResp>> pageQuery(CouponRecordPageQueryReq query) {
|
||||
PageHelper.startPage(query.getPageNum(), query.getPageSize());
|
||||
List<CouponRecordPageResp> list = couponRecordMapper.selectByPageQuery(query);
|
||||
PageInfo<CouponRecordPageResp> pageInfo = new PageInfo<>(list);
|
||||
return ApiResponse.success(pageInfo);
|
||||
}
|
||||
}
|
||||
@@ -524,6 +524,7 @@ public class OrderServiceImpl implements OrderService {
|
||||
order.setCouponId(null);
|
||||
if (couponRecord != null) {
|
||||
if (couponRecord.isUsable()) {
|
||||
log.info("优惠券可用,优惠券记录ID:{},优惠券ID:{}", couponRecord.getId(), couponRecord.getCouponId());
|
||||
order.setCouponId(couponRecord.getCouponId());
|
||||
order.setCouponRecordId(couponRecord.getId());
|
||||
order.setCouponPrice(couponRecord.getCoupon().calculateDiscountPrice(order.getPrice()));
|
||||
|
||||
Reference in New Issue
Block a user