You've already forked FrameTour-BE
补充全免费逻辑
This commit is contained in:
@@ -2,18 +2,21 @@ package com.ycwl.basic.service.impl.mobile;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ycwl.basic.biz.OrderBiz;
|
||||
import com.ycwl.basic.constant.BaseContextHandler;
|
||||
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.face.resp.FaceRespVO;
|
||||
import com.ycwl.basic.model.pc.scenic.entity.ScenicConfigEntity;
|
||||
import com.ycwl.basic.model.pc.scenic.resp.ScenicRespVO;
|
||||
import com.ycwl.basic.model.pc.source.req.SourceReqQuery;
|
||||
import com.ycwl.basic.model.pc.source.resp.SourceRespVO;
|
||||
import com.ycwl.basic.model.pc.task.entity.TaskEntity;
|
||||
import com.ycwl.basic.model.pc.video.entity.MemberVideoEntity;
|
||||
import com.ycwl.basic.model.pc.video.req.VideoReqQuery;
|
||||
import com.ycwl.basic.model.pc.video.resp.VideoRespVO;
|
||||
import com.ycwl.basic.repository.OrderRepository;
|
||||
import com.ycwl.basic.repository.ScenicRepository;
|
||||
import com.ycwl.basic.repository.VideoTaskRepository;
|
||||
import com.ycwl.basic.service.mobile.GoodsService;
|
||||
@@ -54,6 +57,10 @@ public class GoodsServiceImpl implements GoodsService {
|
||||
private TaskService taskTaskService;
|
||||
@Autowired
|
||||
private ScenicRepository scenicRepository;
|
||||
@Autowired
|
||||
private OrderRepository orderRepository;
|
||||
@Autowired
|
||||
private OrderBiz orderBiz;
|
||||
|
||||
public ApiResponse<List<GoodsPageVO>> goodsList(GoodsReqQuery query) {
|
||||
//查询原素材
|
||||
@@ -174,39 +181,6 @@ public class GoodsServiceImpl implements GoodsService {
|
||||
return ApiResponse.success(goodsDetailVOList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResponse<BigDecimal> queryPrice(GoodsPriceQueryReq queryPriceData) {
|
||||
Integer goodsType = queryPriceData.getGoodsType();
|
||||
|
||||
if (goodsType == 0) {//成片vlog
|
||||
//成片的价格就是成片所用template的价格
|
||||
Long videoId = queryPriceData.getGoodsId();
|
||||
VideoRespVO videoRespVO = videoMapper.getById(videoId);
|
||||
if (videoRespVO == null) {
|
||||
return ApiResponse.fail("该vlog不存在或已失效");
|
||||
}
|
||||
BigDecimal templatePrice = videoRespVO.getTemplatePrice();
|
||||
if (templatePrice == null) {
|
||||
return ApiResponse.fail("该vlog使用的模板价格或状态异常,请联系管理员");
|
||||
}
|
||||
return ApiResponse.success(templatePrice);
|
||||
|
||||
} else if (goodsType == 1 || goodsType == 2) {//原素材
|
||||
//原素材的价格就是原素材对应景区定的价格
|
||||
Long scenicId = queryPriceData.getScenicId();
|
||||
ScenicRespVO scenicRespVO = scenicMapper.getById(scenicId);
|
||||
if (scenicRespVO == null) {
|
||||
return ApiResponse.fail("该景区不存在或状态异常,请联系管理员");
|
||||
}
|
||||
BigDecimal price = scenicRespVO.getPrice();
|
||||
if (price == null) {
|
||||
return ApiResponse.fail("该景区的原片价格未设定或状态异常,请联系管理员");
|
||||
}
|
||||
return ApiResponse.success(price);
|
||||
}
|
||||
return ApiResponse.fail("不合法的商品,请联系管理员");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResponse<VideoGoodsDetailVO> videoGoodsDetail(Long userId, Long videoId) {
|
||||
VideoGoodsDetailVO goodsDetailVO = new VideoGoodsDetailVO();
|
||||
@@ -222,21 +196,31 @@ public class GoodsServiceImpl implements GoodsService {
|
||||
goodsDetailVO.setVideoUrl(videoRespVO.getVideoUrl());
|
||||
goodsDetailVO.setTemplateCoverUrl(videoRespVO.getTemplateCoverUrl());
|
||||
goodsDetailVO.setCreateTime(videoRespVO.getCreateTime());
|
||||
MemberVideoEntity entity = videoMapper.queryUserVideo(userId, videoId);
|
||||
if (entity == null) {
|
||||
if (userId == null) {
|
||||
goodsDetailVO.setIsBuy(0);
|
||||
goodsDetailVO.setShare(true);
|
||||
goodsDetailVO.setPrice("未登录");
|
||||
} else if (entity.getIsBuy() == 1) {
|
||||
goodsDetailVO.setIsBuy(1);
|
||||
} else {
|
||||
goodsDetailVO.setIsBuy(0);
|
||||
BigDecimal templatePrice = videoRespVO.getTemplatePrice();
|
||||
BigDecimal slashPrice = videoRespVO.getSlashPrice();
|
||||
// 使用DecimalFormat格式化输出
|
||||
DecimalFormat df = new DecimalFormat("0.00");
|
||||
goodsDetailVO.setPrice(templatePrice == null ? "" : df.format(templatePrice.setScale(2, RoundingMode.HALF_UP)));
|
||||
goodsDetailVO.setSlashPrice(slashPrice == null ? null : df.format(slashPrice.setScale(2, RoundingMode.HALF_UP)));
|
||||
MemberVideoEntity entity = videoMapper.queryUserVideo(userId, videoId);
|
||||
if (entity == null) {
|
||||
goodsDetailVO.setIsBuy(0);
|
||||
goodsDetailVO.setShare(true);
|
||||
goodsDetailVO.setPrice("未登录");
|
||||
} else {
|
||||
goodsDetailVO.setShare(false);
|
||||
goodsDetailVO.setFaceId(entity.getFaceId());
|
||||
goodsDetailVO.setIsBuy(entity.getIsBuy());
|
||||
if (Integer.valueOf(0).equals(entity.getIsBuy())) {
|
||||
PriceObj priceObj = orderBiz.queryPrice(videoRespVO.getScenicId(), 0, videoId);
|
||||
if (priceObj.isFree()) {
|
||||
goodsDetailVO.setIsBuy(1);
|
||||
} else {
|
||||
goodsDetailVO.setIsBuy(0);
|
||||
goodsDetailVO.setPrice(priceObj.getPrice().toString());
|
||||
goodsDetailVO.setSlashPrice(priceObj.getSlashPrice().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
TaskEntity task = videoTaskRepository.getTaskById(videoRespVO.getTaskId());
|
||||
JSONObject paramJson = JSON.parseObject(task.getTaskParams());
|
||||
@@ -248,9 +232,6 @@ public class GoodsServiceImpl implements GoodsService {
|
||||
deviceCount = paramJson.keySet().stream().filter(StringUtils::isNumeric).count();
|
||||
}
|
||||
goodsDetailVO.setLensNum((int) deviceCount);
|
||||
if (entity != null) {
|
||||
goodsDetailVO.setFaceId(entity.getFaceId());
|
||||
}
|
||||
return ApiResponse.success(goodsDetailVO);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user