You've already forked FrameTour-BE
优惠券相关+后台
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
package com.ycwl.basic.service.mobile;
|
||||
|
||||
import com.ycwl.basic.model.pc.coupon.entity.CouponEntity;
|
||||
import com.ycwl.basic.model.pc.couponRecord.entity.CouponRecordEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface AppCouponRecordService {
|
||||
|
||||
List<CouponRecordEntity> queryByMemberIdAndFaceId(Long memberId, Long faceId);
|
||||
|
||||
CouponRecordEntity queryByMemberIdAndFaceIdAndType(Long memberId, Long faceId, Integer type);
|
||||
|
||||
CouponEntity claimCoupon(Long memberId, Long faceId, Integer type);
|
||||
}
|
@@ -1,12 +0,0 @@
|
||||
package com.ycwl.basic.service.mobile;
|
||||
|
||||
import com.ycwl.basic.model.pc.couponRecord.entity.CouponRecordEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CouponRecordService {
|
||||
|
||||
List<CouponRecordEntity> queryByMemberIdAndFaceId(Long memberId, Long faceId);
|
||||
|
||||
CouponRecordEntity claimCoupon(Long memberId, Long faceId, Integer type);
|
||||
}
|
@@ -7,7 +7,7 @@ import com.ycwl.basic.model.pc.coupon.entity.CouponEntity;
|
||||
import com.ycwl.basic.model.pc.couponRecord.entity.CouponRecordEntity;
|
||||
import com.ycwl.basic.model.pc.face.entity.FaceEntity;
|
||||
import com.ycwl.basic.repository.FaceRepository;
|
||||
import com.ycwl.basic.service.mobile.CouponRecordService;
|
||||
import com.ycwl.basic.service.mobile.AppCouponRecordService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -16,7 +16,7 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class CouponRecordServiceImpl implements CouponRecordService {
|
||||
public class AppCouponRecordServiceImpl implements AppCouponRecordService {
|
||||
|
||||
@Autowired
|
||||
private CouponRecordMapper couponRecordMapper;
|
||||
@@ -31,9 +31,14 @@ public class CouponRecordServiceImpl implements CouponRecordService {
|
||||
return couponRecordMapper.queryByMemberIdAndFaceId(memberId, faceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CouponRecordEntity queryByMemberIdAndFaceIdAndType(Long memberId, Long faceId, Integer type) {
|
||||
return couponRecordMapper.queryByMemberIdAndFaceIdAndType(memberId, faceId, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CouponRecordEntity claimCoupon(Long memberId, Long faceId, Integer type) {
|
||||
public CouponEntity claimCoupon(Long memberId, Long faceId, Integer type) {
|
||||
// 检查是否已经领取过该类型的优惠券
|
||||
CouponRecordEntity existingRecord = couponRecordMapper.queryByMemberIdAndFaceIdAndType(memberId, faceId, type);
|
||||
if (existingRecord != null) {
|
||||
@@ -64,6 +69,6 @@ public class CouponRecordServiceImpl implements CouponRecordService {
|
||||
record.setCreateTime(new Date());
|
||||
|
||||
couponRecordMapper.insert(record);
|
||||
return record;
|
||||
return coupon;
|
||||
}
|
||||
}
|
@@ -6,6 +6,7 @@ import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ycwl.basic.biz.CouponBiz;
|
||||
import com.ycwl.basic.biz.OrderBiz;
|
||||
import com.ycwl.basic.biz.TaskStatusBiz;
|
||||
import com.ycwl.basic.constant.BaseContextHandler;
|
||||
@@ -19,6 +20,7 @@ import com.ycwl.basic.mapper.*;
|
||||
import com.ycwl.basic.model.mobile.goods.*;
|
||||
import com.ycwl.basic.model.mobile.order.IsBuyRespVO;
|
||||
import com.ycwl.basic.model.mobile.order.PriceObj;
|
||||
import com.ycwl.basic.model.pc.couponRecord.resp.CouponRecordQueryResp;
|
||||
import com.ycwl.basic.model.pc.device.entity.DeviceEntity;
|
||||
import com.ycwl.basic.model.pc.face.entity.FaceEntity;
|
||||
import com.ycwl.basic.model.pc.face.resp.FaceRespVO;
|
||||
@@ -92,6 +94,8 @@ public class GoodsServiceImpl implements GoodsService {
|
||||
private TaskStatusBiz taskStatusBiz;
|
||||
@Autowired
|
||||
private DeviceRepository deviceRepository;
|
||||
@Autowired
|
||||
private CouponBiz couponBiz;
|
||||
|
||||
public ApiResponse<List<GoodsPageVO>> goodsList(GoodsReqQuery query) {
|
||||
Long scenicId = query.getScenicId();
|
||||
@@ -273,7 +277,8 @@ public class GoodsServiceImpl implements GoodsService {
|
||||
} else {
|
||||
goodsDetailVO.setIsBuy(0);
|
||||
goodsDetailVO.setPrice(priceObj.getPrice().toString());
|
||||
goodsDetailVO.setSlashPrice(priceObj.getSlashPrice().toString());
|
||||
goodsDetailVO.setOrigPrice(priceObj.getPrice());
|
||||
goodsDetailVO.setSlashPrice(priceObj.getSlashPrice());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -304,6 +309,16 @@ public class GoodsServiceImpl implements GoodsService {
|
||||
});
|
||||
}
|
||||
goodsDetailVO.setLensNum(deviceCount.get());
|
||||
CouponRecordQueryResp couponRecord = couponBiz.queryUserCouponRecord(task.getScenicId(), userId, task.getFaceId(), task.getTemplateId().toString());
|
||||
if (couponRecord != null) {
|
||||
if (couponRecord.isUsable()) {
|
||||
goodsDetailVO.setCouponId(couponRecord.getCouponId());
|
||||
goodsDetailVO.setCouponRecordId(couponRecord.getId());
|
||||
goodsDetailVO.setCouponPrice(couponRecord.getCoupon().calculateDiscountPrice(goodsDetailVO.getOrigPrice()));
|
||||
goodsDetailVO.setPrice(couponRecord.getCoupon().calculateDiscountedPrice(goodsDetailVO.getPrice()));
|
||||
}
|
||||
}
|
||||
|
||||
return ApiResponse.success(goodsDetailVO);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user