无关风月
2024-10-14 039a33d1bfa6ef041161666bbd120c34086fe7c1
xinquan-modules/xinquan-order/src/main/java/com/xinquan/order/service/impl/OrderServiceImpl.java
@@ -23,7 +23,7 @@
import com.xinquan.order.service.OrderService;
import com.xinquan.order.utils.JuHeFuUtil;
import com.xinquan.order.utils.OrderUtil;
import com.xinquan.user.api.domain.AppUser;
import com.xinquan.system.api.domain.AppUser;
import com.xinquan.user.api.domain.dto.AppUserDTO;
import com.xinquan.user.api.feign.RemoteAppUserService;
import java.math.BigDecimal;
@@ -32,6 +32,8 @@
import org.jetbrains.annotations.NotNull;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
/**
 * <p>
@@ -45,10 +47,14 @@
@RequiredArgsConstructor
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements OrderService {
    private final RemoteMeditationService remoteMeditationService;
    private final RemoteCourseService remoteCourseService;
    private final RemoteAppUserService remoteAppUserService;
    private final OrderPaymentRecordService orderPaymentRecordService;
    @Resource
    private  RemoteMeditationService remoteMeditationService;
    @Resource
    private  RemoteCourseService remoteCourseService;
    @Resource
    private  RemoteAppUserService remoteAppUserService;
    @Resource
    private  OrderPaymentRecordService orderPaymentRecordService;
    /**
     * 创建待支付订单
@@ -90,16 +96,26 @@
            clientPlaceOrderVO.setOrderNo(orderNo);
            clientPlaceOrderVO.setId(orderId);
            // 如果冥想音频价格设定为单独收费,且需要使用余额抵扣
            if (balanceFlag.equals(1) && meditation.getChargeType()
                    .equals(ChargeTypeEnum.SEPARATE_CHARGE.getCode())) {
            if (balanceFlag.equals(1) && meditation.getChargeType().equals(ChargeTypeEnum.SEPARATE_CHARGE.getCode())) {
                BigDecimal needPayAmount = handleBalancePayment(appUser,
                        meditation.getGeneralPrice(),
                        orderId);
                if (needPayAmount.compareTo(BigDecimal.ZERO) <= 0) {
                    clientPlaceOrderVO.setZeroFlag(DisabledEnum.YES.getCode());
                    // 抵扣后金额为0 为余额支付
                    order.setPayType(3);
                    order.setRealPayAmount(meditation.getGeneralPrice());
                    this.updateById(order);
                    return clientPlaceOrderVO;
                }
                if (payType==1){
                    // 微信+余额
                    order.setPayType(5);
                }else{
                    // 支付宝+余额
                    order.setPayType(6);
                }
                this.updateById(order);
                // 创建支付订单
                createPayment(payType, orderNo, needPayAmount, meditationTitle, detailDescription,
                        wxOpenId, orderId, clientPlaceOrderVO);
@@ -108,7 +124,7 @@
                createPayment(payType, orderNo, meditation.getGeneralPrice(), meditationTitle,
                        detailDescription, wxOpenId, orderId, clientPlaceOrderVO);
            }
        } else {
        } else if (orderFrom == 2){
            // 购买课程
            Course course = remoteCourseService.getCourseById(targetId,
                    SecurityConstants.INNER).getData();
@@ -145,6 +161,10 @@
                createPayment(payType, orderNo, course.getGeneralPrice(), courseTitle,
                        description, wxOpenId, orderId, clientPlaceOrderVO);
            }
        }else if (orderFrom == 3){
            // 购买会员
        }else {
            // 充值
        }
        return clientPlaceOrderVO;
    }