You've already forked FrameTour-BE
一口价查询
This commit is contained in:
@@ -360,4 +360,12 @@ public class OrderBiz {
|
||||
orderRepository.clearOrderCache(orderId); // 更新完了,清理下
|
||||
profitSharingBiz.revokeProfitSharing(order.getScenicId(), orderId, "订单已退款");
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查用户是否购买了指定商品
|
||||
* 提供给PriceBiz使用,避免循环调用
|
||||
*/
|
||||
public boolean checkUserBuyItem(Long userId, int goodsType, Long goodsId) {
|
||||
return orderRepository.checkUserBuyItem(userId, goodsType, goodsId);
|
||||
}
|
||||
}
|
||||
|
@@ -11,9 +11,11 @@ import com.ycwl.basic.model.pc.price.entity.PriceConfigEntity;
|
||||
import com.ycwl.basic.model.pc.price.resp.GoodsListRespVO;
|
||||
import com.ycwl.basic.model.pc.scenic.entity.ScenicConfigEntity;
|
||||
import com.ycwl.basic.model.pc.template.resp.TemplateRespVO;
|
||||
import com.ycwl.basic.model.pc.video.entity.MemberVideoEntity;
|
||||
import com.ycwl.basic.pricing.entity.PriceOnePriceConfig;
|
||||
import com.ycwl.basic.pricing.service.IOnePricePurchaseService;
|
||||
import com.ycwl.basic.repository.FaceRepository;
|
||||
import com.ycwl.basic.repository.MemberRelationRepository;
|
||||
import com.ycwl.basic.repository.PriceRepository;
|
||||
import com.ycwl.basic.repository.ScenicRepository;
|
||||
import com.ycwl.basic.repository.TemplateRepository;
|
||||
@@ -47,6 +49,8 @@ public class PriceBiz {
|
||||
private FaceService faceService;
|
||||
@Autowired
|
||||
private CouponBiz couponBiz;
|
||||
@Autowired
|
||||
private MemberRelationRepository memberRelationRepository;
|
||||
|
||||
public List<GoodsListRespVO> listGoodsByScenic(Long scenicId) {
|
||||
List<GoodsListRespVO> goodsList = new ArrayList<>();
|
||||
@@ -150,10 +154,48 @@ public class PriceBiz {
|
||||
}
|
||||
}
|
||||
if (type == -1 && !respVO.isBuy()) {
|
||||
// 查找所有内容是否购买。
|
||||
List<ContentPageVO> list = faceService.faceContentList(faceId);
|
||||
boolean notBuy = list.stream().anyMatch(item -> Integer.valueOf(0).equals(item.getIsBuy()));
|
||||
if (!notBuy) {
|
||||
// 直接查询用户购买状态,避免调用faceContentList造成循环调用
|
||||
boolean allContentsPurchased = true;
|
||||
|
||||
// 检查视频模板购买状态
|
||||
List<TemplateRespVO> templateList = templateRepository.getTemplateListByScenicId(scenicId);
|
||||
for (TemplateRespVO template : templateList) {
|
||||
// 使用OrderRepository直接检查是否购买了该模板下的内容
|
||||
List<MemberVideoEntity> videoEntities = memberRelationRepository.listRelationByFaceAndTemplate(faceId, template.getId());
|
||||
if (videoEntities == null || videoEntities.isEmpty()) {
|
||||
allContentsPurchased = false;
|
||||
break;
|
||||
}
|
||||
boolean hasPurchasedTemplate = orderBiz.checkUserBuyItem(userId, 0, videoEntities.getFirst().getVideoId());
|
||||
if (!hasPurchasedTemplate) {
|
||||
allContentsPurchased = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 检查源文件购买状态(录像集和照片集)
|
||||
if (allContentsPurchased) {
|
||||
if (scenicConfig != null) {
|
||||
// 检查录像集
|
||||
if (!Boolean.TRUE.equals(scenicConfig.getDisableSourceVideo())) {
|
||||
boolean hasPurchasedRecording = orderBiz.checkUserBuyItem(userId, 1, faceId);
|
||||
if (!hasPurchasedRecording) {
|
||||
allContentsPurchased = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 检查照片集
|
||||
if (allContentsPurchased && !Boolean.TRUE.equals(scenicConfig.getDisableSourceImage())) {
|
||||
boolean hasPurchasedPhoto = orderBiz.checkUserBuyItem(userId, 2, faceId);
|
||||
if (!hasPurchasedPhoto) {
|
||||
allContentsPurchased = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 如果所有内容都已购买,则认为已购买套餐
|
||||
if (allContentsPurchased) {
|
||||
respVO.setBuy(true);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user