全免费、0元购模式

This commit is contained in:
Jerry Yan 2025-01-05 17:19:08 +08:00
parent 294f9b6690
commit 8f41a4f66d
8 changed files with 26 additions and 17 deletions

View File

@ -5,6 +5,7 @@ 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.ScenicConfigEntity;
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;
@ -14,6 +15,8 @@ import com.ycwl.basic.repository.TemplateRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
@Component
public class OrderBiz {
@ -28,10 +31,20 @@ public class OrderBiz {
@Autowired
private OrderRepository orderRepository;
public PriceObj queryPrice(int goodsType, Long goodsId) {
public PriceObj queryPrice(Long scenicId, int goodsType, Long goodsId) {
PriceObj priceObj = new PriceObj();
priceObj.setGoodsType(goodsType);
priceObj.setGoodsId(goodsId);
ScenicConfigEntity scenicConfig = scenicRepository.getScenicConfig(scenicId);
if (scenicConfig != null) {
if (0 != scenicConfig.getAllFree()) {
// 景区全免
priceObj.setFree(true);
priceObj.setPrice(BigDecimal.ZERO);
priceObj.setSlashPrice(BigDecimal.ZERO);
return priceObj;
}
}
switch (goodsType) {
case 0: // video
VideoRespVO video = videoMapper.getById(goodsId);
@ -76,12 +89,12 @@ public class OrderBiz {
return priceObj;
}
public IsBuyRespVO isBuy(Long userId, int goodsType, Long goodsId) {
public IsBuyRespVO isBuy(Long userId, Long scenicId, 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);
PriceObj priceObj = queryPrice(scenicId, goodsType, goodsId);
if (priceObj == null) {
return respVO;
}

View File

@ -77,6 +77,6 @@ public class AppOrderController {
@GetMapping("/scenic/{scenicId}/query")
public ApiResponse<IsBuyRespVO> isBuy(@PathVariable("scenicId") Long scenicId, @RequestParam("type") Integer type, @RequestParam("goodsId") Long goodsId) {
Long userId = Long.parseLong(BaseContextHandler.getUserId());
return ApiResponse.success(orderBiz.isBuy(userId, type, goodsId));
return ApiResponse.success(orderBiz.isBuy(userId, scenicId, type, goodsId));
}
}

View File

@ -6,6 +6,7 @@ import java.math.BigDecimal;
@Data
public class PriceObj {
private boolean free;
private Long scenicId;
private int goodsType;
private Long goodsId;

View File

@ -33,6 +33,7 @@ public class ScenicConfigEntity {
* 是否为默认
*/
private Integer isDefault;
private Integer allFree;
/**
* 创建时间
*/

View File

@ -8,9 +8,6 @@ import com.ycwl.basic.constant.NumberConstant;
import com.ycwl.basic.enums.*;
import com.ycwl.basic.exception.AppException;
import com.ycwl.basic.mapper.*;
import com.ycwl.basic.model.jwt.JwtInfo;
import com.ycwl.basic.model.mobile.goods.GoodsDetailVO;
import com.ycwl.basic.model.mobile.goods.GoodsPriceQueryReq;
import com.ycwl.basic.model.mobile.order.OrderAppPageReq;
import com.ycwl.basic.model.mobile.order.PriceObj;
import com.ycwl.basic.model.mobile.order.RefundOrderReq;
@ -20,7 +17,6 @@ import com.ycwl.basic.model.pc.order.entity.OrderEntity;
import com.ycwl.basic.model.pc.order.entity.OrderItemEntity;
import com.ycwl.basic.model.pc.order.req.CreateOrderReqVO;
import com.ycwl.basic.model.pc.order.req.OrderUpdateReq;
import com.ycwl.basic.model.pc.order.req.OrderAddReq;
import com.ycwl.basic.model.pc.order.req.OrderReqQuery;
import com.ycwl.basic.model.pc.order.resp.OrderAppRespVO;
import com.ycwl.basic.model.pc.order.resp.OrderItemVO;
@ -35,7 +31,6 @@ import com.ycwl.basic.service.mobile.WxPayService;
import com.ycwl.basic.service.pc.OrderService;
import com.ycwl.basic.utils.ApiResponse;
import com.ycwl.basic.utils.BigDecimalUtil;
import com.ycwl.basic.utils.JwtTokenUtil;
import com.ycwl.basic.utils.SnowFlakeUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ -68,8 +63,6 @@ public class OrderServiceImpl implements OrderService {
@Autowired
private MemberMapper memberMapper;
@Autowired
private GoodsService goodsService;
@Autowired
private OrderOperationMapper orderOperationMapper;
@Autowired
private StatisticsMapper statisticsMapper;
@ -287,7 +280,7 @@ public class OrderServiceImpl implements OrderService {
orderItem.setGoodsType(createOrderReqVO.getGoodsType());
orderItem.setOrderId(orderId);
orderItems.add(orderItem);
PriceObj priceObj = orderBiz.queryPrice(createOrderReqVO.getGoodsType(), createOrderReqVO.getGoodsId());
PriceObj priceObj = orderBiz.queryPrice(order.getScenicId(), createOrderReqVO.getGoodsType(), createOrderReqVO.getGoodsId());
order.setPrice(priceObj.getPrice());
// promo code
// coupon

View File

@ -20,7 +20,6 @@ import com.ycwl.basic.model.pc.task.entity.TaskEntity;
import com.ycwl.basic.model.pc.task.req.TaskReqQuery;
import com.ycwl.basic.model.pc.task.resp.TaskRespVO;
import com.ycwl.basic.model.pc.template.entity.TemplateConfigEntity;
import com.ycwl.basic.model.pc.template.entity.TemplateEntity;
import com.ycwl.basic.model.pc.template.resp.TemplateRespVO;
import com.ycwl.basic.model.pc.video.entity.MemberVideoEntity;
import com.ycwl.basic.model.pc.video.entity.VideoEntity;
@ -280,8 +279,8 @@ public class TaskTaskServiceImpl implements TaskService {
memberVideoEntity.setTaskId(list.get(0).getId());
VideoEntity video = videoMapper.findByTaskId(list.get(0).getId());
if (video != null) {
PriceObj priceObj = orderBiz.queryPrice(0, video.getId());
if (priceObj.getPrice().equals(BigDecimal.ZERO)) {
PriceObj priceObj = orderBiz.queryPrice(list.get(0).getScenicId(), 0, video.getId());
if (priceObj.isFree()) {
memberVideoEntity.setIsBuy(1);
}
memberVideoEntity.setVideoId(video.getId());
@ -324,8 +323,8 @@ public class TaskTaskServiceImpl implements TaskService {
videoMapper.add(video);
}
int isBuy = 0;
PriceObj priceObj = orderBiz.queryPrice(0, video.getId());
if (priceObj.getPrice().equals(BigDecimal.ZERO)) {
PriceObj priceObj = orderBiz.queryPrice(task.getScenicId(), 0, video.getId());
if (priceObj.isFree()) {
isBuy = 1;
}
videoMapper.updateRelationWhenTaskSuccess(taskId, video.getId(), isBuy);

View File

@ -158,6 +158,7 @@ aliFace:
accessKeySecret: "ZCIP8aKx1jwX1wkeYIPQEDZ8fPtN1c"
region: "cn-shanghai"
# 通知到人
notify:
defaultUse: "developer"
configs:

View File

@ -79,6 +79,7 @@
<if test="isDefault!=null">
is_default=#{isDefault},
</if>
all_free=#{allFree},
book_routine=#{bookRoutine},
sample_store_day=#{sampleStoreDay},
video_store_day=#{videoStoreDay},