You've already forked FrameTour-BE
refactor(order): 重构订单购买逻辑并优化接口参数
- 调整 isBuy 方法参数顺序,增加 faceId 参数支持 - 删除冗余的购买检查方法和旧版 isBuy 重载方法 - 简化购买状态判断逻辑,移除重复代码 - 更新视频查看权限服务中的购买检查调用 - 修改人脸服务中景区 ID 类型为 Long - 调整打印机服务中人脸查询方法参数类型 - 统一订单业务类中方法签名和调用方式 - 移除订单请求模型中无用字段注释 - 增加人脸 ID 列表字段支持批量查询 - 优化任务服务中购买状态检查逻辑
This commit is contained in:
@@ -163,6 +163,8 @@ public class OrderBiz {
|
||||
}
|
||||
public IsBuyRespVO isBuy(Long scenicId, Long memberId, Long faceId, int goodsType, Long goodsId) {
|
||||
IsBuyRespVO respVO = new IsBuyRespVO();
|
||||
respVO.setGoodsType(goodsType);
|
||||
respVO.setGoodsId(goodsId);
|
||||
OrderEntity orderEntity = orderMapper.getUserBuyFaceItem(memberId, faceId, goodsType, goodsId);
|
||||
if (orderEntity != null) {
|
||||
respVO.setOrderId(orderEntity.getId());
|
||||
@@ -178,93 +180,13 @@ public class OrderBiz {
|
||||
respVO.setSlashPrice(BigDecimal.ZERO);
|
||||
return respVO;
|
||||
}
|
||||
PriceObj priceObj = queryPrice(scenicId, goodsType, goodsId);
|
||||
if (priceObj == null) {
|
||||
return respVO;
|
||||
}
|
||||
respVO.setBuy(false);
|
||||
return respVO;
|
||||
}
|
||||
|
||||
public IsBuyRespVO isBuy(Long userId, Long scenicId, int goodsType, Long goodsId) {
|
||||
IsBuyRespVO respVO = new IsBuyRespVO();
|
||||
boolean isBuy = orderRepository.checkUserBuyItem(userId, goodsType, goodsId);
|
||||
// 模板购买逻辑
|
||||
if (!isBuy) {
|
||||
if (goodsType == 0) {
|
||||
VideoEntity video = videoRepository.getVideo(goodsId);
|
||||
if (video == null) {
|
||||
return respVO;
|
||||
}
|
||||
TaskEntity task = videoTaskRepository.getTaskById(video.getTaskId());
|
||||
Long templateId = video.getTemplateId();
|
||||
// -1为整个模板购买
|
||||
OrderEntity orderEntity = orderRepository.getUserBuyItem(userId, -1, templateId);
|
||||
if (orderEntity != null && task != null) {
|
||||
respVO.setOrderId(orderEntity.getId());
|
||||
if (orderEntity.getFaceId() != null && task.getFaceId() != null) {
|
||||
isBuy = orderEntity.getFaceId().equals(task.getFaceId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 免费送逻辑,之前已经赠送了的
|
||||
if (!isBuy) {
|
||||
isBuy = switch (goodsType) {
|
||||
case 0 -> videoRepository.getUserIsBuy(userId, goodsId);
|
||||
case 1, 2 -> sourceRepository.getUserIsBuy(userId, goodsType, goodsId);
|
||||
default -> false;
|
||||
};
|
||||
} else {
|
||||
OrderEntity orderEntity = orderRepository.getUserBuyItem(userId, goodsType, goodsId);
|
||||
if (orderEntity != null) {
|
||||
respVO.setOrderId(orderEntity.getId());
|
||||
}
|
||||
}
|
||||
respVO.setBuy(isBuy);
|
||||
// 还是没买
|
||||
if (!isBuy) {
|
||||
PriceObj priceObj = queryPrice(scenicId, goodsType, goodsId);
|
||||
if (priceObj == null) {
|
||||
return respVO;
|
||||
}
|
||||
FaceEntity face = faceRepository.getFace(priceObj.getFaceId());
|
||||
respVO.setShare(true);
|
||||
if (face != null && face.getMemberId().equals(userId)) {
|
||||
respVO.setShare(false);
|
||||
}
|
||||
respVO.setFree(priceObj.isFree());
|
||||
respVO.setGoodsType(goodsType);
|
||||
respVO.setGoodsId(goodsId);
|
||||
respVO.setOrigPrice(priceObj.getPrice());
|
||||
respVO.setSlashPrice(priceObj.getSlashPrice());
|
||||
switch (goodsType) {
|
||||
case 0: // vlog
|
||||
VideoEntity video = videoRepository.getVideo(goodsId);
|
||||
TaskEntity taskById = videoTaskRepository.getTaskById(video.getTaskId());
|
||||
if (taskById != null) {
|
||||
CouponRecordQueryResp recordQueryResp = couponBiz.queryUserCouponRecord(scenicId, userId, taskById.getFaceId(), taskById.getTemplateId().toString());
|
||||
if (recordQueryResp.isUsable()) {
|
||||
respVO.setCouponId(recordQueryResp.getCouponId());
|
||||
respVO.setCouponRecordId(recordQueryResp.getId());
|
||||
CouponEntity coupon = recordQueryResp.getCoupon();
|
||||
if (coupon != null) {
|
||||
respVO.setCouponPrice(coupon.calculateDiscountPrice(priceObj.getPrice()));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
CouponRecordQueryResp recordQueryResp = couponBiz.queryUserCouponRecord(scenicId, userId, goodsId, String.valueOf(goodsType));
|
||||
if (recordQueryResp.isUsable()) {
|
||||
respVO.setCouponId(recordQueryResp.getCouponId());
|
||||
respVO.setCouponRecordId(recordQueryResp.getId());
|
||||
CouponEntity coupon = recordQueryResp.getCoupon();
|
||||
if (coupon != null) {
|
||||
respVO.setCouponPrice(coupon.calculateDiscountPrice(priceObj.getPrice()));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
respVO.setOrigPrice(priceObj.getPrice());
|
||||
respVO.setSlashPrice(priceObj.getSlashPrice());
|
||||
return respVO;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user