You've already forked FrameTour-BE
0元购逻辑,直接送
This commit is contained in:
93
src/main/java/com/ycwl/basic/biz/OrderBiz.java
Normal file
93
src/main/java/com/ycwl/basic/biz/OrderBiz.java
Normal file
@ -0,0 +1,93 @@
|
||||
package com.ycwl.basic.biz;
|
||||
|
||||
import com.ycwl.basic.mapper.FaceMapper;
|
||||
import com.ycwl.basic.mapper.VideoMapper;
|
||||
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.ScenicEntity;
|
||||
import com.ycwl.basic.model.pc.template.resp.TemplateRespVO;
|
||||
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.TemplateRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class OrderBiz {
|
||||
|
||||
@Autowired
|
||||
private VideoMapper videoMapper;
|
||||
@Autowired
|
||||
private ScenicRepository scenicRepository;
|
||||
@Autowired
|
||||
private TemplateRepository templateRepository;
|
||||
@Autowired
|
||||
private FaceMapper faceMapper;
|
||||
@Autowired
|
||||
private OrderRepository orderRepository;
|
||||
|
||||
public PriceObj queryPrice(int goodsType, Long goodsId) {
|
||||
PriceObj priceObj = new PriceObj();
|
||||
switch (goodsType) {
|
||||
case 0: // video
|
||||
VideoRespVO video = videoMapper.getById(goodsId);
|
||||
if (video == null) {
|
||||
return null;
|
||||
}
|
||||
priceObj.setGoodsId(goodsId);
|
||||
priceObj.setGoodsType(goodsType);
|
||||
TemplateRespVO template = templateRepository.getTemplate(video.getTemplateId());
|
||||
if (template == null) {
|
||||
return priceObj;
|
||||
}
|
||||
priceObj.setPrice(template.getPrice());
|
||||
priceObj.setSlashPrice(template.getSlashPrice());
|
||||
priceObj.setScenicId(video.getScenicId());
|
||||
break;
|
||||
case 1: // source
|
||||
// goodsId 实际上是人脸ID
|
||||
FaceRespVO _faceRespVO = faceMapper.getById(goodsId);
|
||||
if (_faceRespVO == null || _faceRespVO.getScenicId() == null) {
|
||||
return null;
|
||||
}
|
||||
ScenicEntity _scenic = scenicRepository.getScenic(_faceRespVO.getScenicId());
|
||||
if (_scenic == null) {
|
||||
return null;
|
||||
}
|
||||
priceObj.setPrice(_scenic.getPrice());
|
||||
priceObj.setSlashPrice(_scenic.getPrice());
|
||||
break;
|
||||
case 2: // source
|
||||
// goodsId 实际上是人脸ID
|
||||
FaceRespVO __faceRespVO = faceMapper.getById(goodsId);
|
||||
if (__faceRespVO == null || __faceRespVO.getScenicId() == null) {
|
||||
return null;
|
||||
}
|
||||
ScenicEntity __scenic = scenicRepository.getScenic(__faceRespVO.getScenicId());
|
||||
if (__scenic == null) {
|
||||
return null;
|
||||
}
|
||||
priceObj.setPrice(__scenic.getPrice());
|
||||
priceObj.setSlashPrice(__scenic.getPrice());
|
||||
break;
|
||||
}
|
||||
return priceObj;
|
||||
}
|
||||
|
||||
public IsBuyRespVO isBuy(Long userId, int goodsType, Long goodsId) {
|
||||
IsBuyRespVO respVO = new IsBuyRespVO();
|
||||
boolean isBuy = orderRepository.checkUserBuyItem(userId, goodsType, goodsId);
|
||||
respVO.setBuy(isBuy);
|
||||
if (!isBuy) {
|
||||
PriceObj priceObj = queryPrice(goodsType, goodsId);
|
||||
if (priceObj == null) {
|
||||
return respVO;
|
||||
}
|
||||
respVO.setPrice(priceObj.getPrice());
|
||||
respVO.setSlashPrice(priceObj.getSlashPrice());
|
||||
}
|
||||
return respVO;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user