无关风月
2024-11-12 3ec572e2cb7adf7d33d2018b24c003d9ef18906a
xinquan-modules/xinquan-order/src/main/java/com/xinquan/order/service/impl/OrderServiceImpl.java
@@ -1,15 +1,18 @@
package com.xinquan.order.service.impl;
import com.alibaba.fastjson2.JSONObject;
import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.C;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xinquan.common.core.constant.Constants;
import com.xinquan.common.core.constant.SecurityConstants;
import com.xinquan.common.core.domain.R;
import com.xinquan.common.core.enums.ChargeTypeEnum;
import com.xinquan.common.core.enums.DisabledEnum;
import com.xinquan.common.core.enums.PaymentStatusEnum;
import com.xinquan.common.core.enums.PaymentTypeEnum;
import com.xinquan.common.core.exception.ServiceException;
import com.xinquan.common.core.utils.ip.IpUtils;
import com.xinquan.common.security.service.TokenService;
import com.xinquan.common.security.utils.SecurityUtils;
import com.xinquan.course.api.domain.Course;
import com.xinquan.course.api.feign.RemoteCourseService;
@@ -23,15 +26,20 @@
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.system.api.model.LoginUser;
import com.xinquan.user.api.domain.dto.AppUserDTO;
import com.xinquan.user.api.feign.RemoteAppUserService;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
/**
 * <p>
@@ -45,11 +53,16 @@
@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;
    @Autowired
    private TokenService tokenService;
    /**
     * 创建待支付订单
     *
@@ -63,10 +76,17 @@
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public ClientPlaceOrderVO placeOrder(Long targetId, Integer orderFrom, Long receiverId,
            Integer balanceFlag, Integer payType) throws Exception {
    public ClientPlaceOrderVO placeOrder(Long targetId, Integer orderFrom, Long receiverId, Long orderId,
            Integer balanceFlag, Integer payType,BigDecimal amount,Integer vipType) throws Exception {
        // 获取当前登录用户id
        Long userId = SecurityUtils.getUserId();
        LoginUser loginUser = tokenService.getLoginUser();
        if (loginUser==null){
            return new ClientPlaceOrderVO();
        }
        Long userId = loginUser.getUserid();
        if (amount!=null){
            amount = amount.setScale(2, RoundingMode.HALF_DOWN);
        }
        // 获取用户信息
        AppUser appUser = getAppUserById(userId);
        ClientPlaceOrderVO clientPlaceOrderVO = new ClientPlaceOrderVO();
@@ -80,71 +100,186 @@
            String wxOpenId = appUser.getWxOpenId();
            // 创建订单
            String orderNo = OrderUtil.getOrderNoForPrefix("MX");
            order.setOrderFrom(orderFrom);
            order.setBizOrderNo(orderNo);
            order.setBusinessId(meditation.getId());
            order.setAppUserId(userId);
            order.setTotalAmount(meditation.getGeneralPrice());
            this.save(order);
            Long orderId = order.getId();
            if (orderId==null){
                order.setPayType(payType);
                order.setOrderFrom(orderFrom);
                order.setBizOrderNo(orderNo);
                order.setBusinessId(meditation.getId());
                order.setAppUserId(userId);
                order.setRealPayAmount(meditation.getGeneralPrice());
                order.setPayType(payType);
                order.setBuyContent("购买疗愈【"+meditationTitle+"】");
                order.setTotalAmount(meditation.getGeneralPrice());
                order.setGiveUserId(receiverId);
                this.save(order);
            }else{
                 order = this.getById(orderId);
                order.setBuyContent("购买疗愈【"+meditationTitle+"】");
            }
            Long orderId9 = order.getId();
            clientPlaceOrderVO.setOrderNo(orderNo);
            clientPlaceOrderVO.setId(orderId);
            clientPlaceOrderVO.setId(orderId9);
            // 如果冥想音频价格设定为单独收费,且需要使用余额抵扣
            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);
                        orderId9);
                if (needPayAmount.compareTo(BigDecimal.ZERO) <= 0) {
                    clientPlaceOrderVO.setZeroFlag(DisabledEnum.YES.getCode());
                    // 抵扣后金额为0 为余额支付
                    order.setPayType(4);
                    order.setRealPayAmount(meditation.getGeneralPrice());
                    order.setBuyContent("购买疗愈【"+meditationTitle+"】");
                    this.updateById(order);
                    return clientPlaceOrderVO;
                }else{
                    // 余额抵扣不完
                    OrderPaymentRecord one = orderPaymentRecordService.lambdaQuery().eq(OrderPaymentRecord::getPaymentType, 4)
                            .eq(OrderPaymentRecord::getOrderId, orderId9).one();
                    if (one!=null){
                        one.setPayAmount(meditation.getGeneralPrice().subtract(needPayAmount));
                        orderPaymentRecordService.updateById(one);
                    }
                }
                if (payType==1){
                    // 微信+余额
                    order.setPayType(5);
                }else if (payType == 2){
                    // 支付宝+余额
                    order.setPayType(6);
                }
                order.setBuyContent("购买疗愈【"+meditationTitle+"】");
                this.updateById(order);
                // 创建支付订单
                createPayment(payType, orderNo, needPayAmount, meditationTitle, detailDescription,
                        wxOpenId, orderId, clientPlaceOrderVO);
                        wxOpenId, orderId9, clientPlaceOrderVO);
            } else {
                // 创建支付订单
                createPayment(payType, orderNo, meditation.getGeneralPrice(), meditationTitle,
                        detailDescription, wxOpenId, orderId, clientPlaceOrderVO);
                        detailDescription, wxOpenId, orderId9, clientPlaceOrderVO);
            }
        } else {
        }
        else if (orderFrom == 2){
            // 购买课程
            Course course = remoteCourseService.getCourseById(targetId,
                    SecurityConstants.INNER).getData();
            Course course = remoteCourseService.getCourseById(targetId).getData();
            String courseTitle = course.getCourseTitle();
            String wxOpenId = appUser.getWxOpenId();
            String description = course.getDescription();
            // 创建订单
            String orderNo = OrderUtil.getOrderNoForPrefix("KC");
            order.setOrderFrom(orderFrom);
            order.setBizOrderNo(orderNo);
            order.setBusinessId(course.getId());
            order.setAppUserId(userId);
            order.setTotalAmount(course.getGeneralPrice());
            this.save(order);
            Long orderId = order.getId();
            if (orderId==null){
                order.setOrderFrom(orderFrom);
                order.setBizOrderNo(orderNo);
                order.setGiveUserId(receiverId);
                order.setBusinessId(course.getId());
                order.setAppUserId(userId);
                order.setBuyContent("购买课程【"+courseTitle+"】");
                order.setRealPayAmount(course.getGeneralPrice());
                order.setTotalAmount(course.getGeneralPrice());
                this.save(order);
            }else{
                order = this.getById(orderId);
                order.setBuyContent("购买课程【"+courseTitle+"】");
            }
            Long orderId8 = order.getId();
            clientPlaceOrderVO.setOrderNo(orderNo);
            clientPlaceOrderVO.setId(orderId);
            clientPlaceOrderVO.setId(orderId8);
            if (balanceFlag.equals(1) && course.getChargeType()
                    .equals(ChargeTypeEnum.SEPARATE_CHARGE.getCode())) {
                BigDecimal needPayAmount = handleBalancePayment(appUser, course.getGeneralPrice(),
                        orderId);
                        orderId8);
                if (needPayAmount.compareTo(BigDecimal.ZERO) <= 0) {
                    clientPlaceOrderVO.setZeroFlag(DisabledEnum.YES.getCode());
                    // 抵扣后金额为0 为余额支付
                    order.setPayType(4);
                    order.setRealPayAmount(course.getGeneralPrice());
                    order.setBuyContent("购买课程【"+courseTitle+"】");
                    this.updateById(order);
                    return clientPlaceOrderVO;
                }else{
                    // 余额抵扣不完
                    OrderPaymentRecord one = orderPaymentRecordService.lambdaQuery().eq(OrderPaymentRecord::getPaymentType, 4)
                            .eq(OrderPaymentRecord::getOrderId, orderId8).one();
                    if (one!=null){
                        one.setPayAmount(course.getGeneralPrice().subtract(needPayAmount));
                        orderPaymentRecordService.updateById(one);
                    }
                }
                if (payType==1){
                    // 微信+余额
                    order.setPayType(5);
                }else if (payType == 2){
                    // 支付宝+余额
                    order.setPayType(6);
                }
                order.setBuyContent("购买课程【"+courseTitle+"】");
                this.updateById(order);
                // 创建支付订单
                createPayment(payType, orderNo, needPayAmount, courseTitle, description,
                        wxOpenId, orderId, clientPlaceOrderVO);
                        wxOpenId, orderId8, clientPlaceOrderVO);
            } else {
                // 创建支付订单
                createPayment(payType, orderNo, course.getGeneralPrice(), courseTitle,
                        description, wxOpenId, orderId, clientPlaceOrderVO);
                        description, wxOpenId, orderId8, clientPlaceOrderVO);
            }
        }
        else if (orderFrom == 3){
            String wxOpenId = appUser.getWxOpenId();
            // 创建订单
            String orderNo = OrderUtil.getOrderNoForPrefix("HY");
            order.setOrderFrom(orderFrom);
            order.setBizOrderNo(orderNo);
            order.setAppUserId(userId);
            order.setTotalAmount(amount);
            order.setPayType(payType);
            order.setRealPayAmount(amount);
            String vipType1 ="";
            switch (vipType){
                case 1:
                    vipType1="月会员";
                    break;
                case 2:
                    vipType1="季会员";
                    break;
                case 3:
                    vipType1="年会员";
                    break;
            }
            order.setBuyContent(vipType1);
            this.save(order);
            Long orderId7 = order.getId();
            clientPlaceOrderVO.setOrderNo(orderNo);
            clientPlaceOrderVO.setId(orderId7);
            // 创建支付订单
            createPayment(payType, orderNo, amount, "购买会员",
                    vipType1, wxOpenId, orderId7, clientPlaceOrderVO);
        }else {
            // 充值
            String wxOpenId = appUser.getWxOpenId();
            // 创建订单
            String orderNo = OrderUtil.getOrderNoForPrefix("CZ");
            order.setOrderFrom(orderFrom);
            order.setBizOrderNo(orderNo);
            order.setAppUserId(userId);
            order.setTotalAmount(amount);
            order.setRealPayAmount(amount);
            order.setPayType(payType);
            order.setBuyContent("充值");
            this.save(order);
            Long orderId6 = order.getId();
            clientPlaceOrderVO.setOrderNo(orderNo);
            clientPlaceOrderVO.setId(orderId6);
            // 创建支付订单
            createPayment(payType, orderNo, amount, "充值余额",
                    "充值余额", wxOpenId, orderId6, clientPlaceOrderVO);
        }
        return clientPlaceOrderVO;
    }
@@ -187,9 +322,7 @@
     * @return AppUser
     */
    private AppUser getAppUserById(Long userId) {
        return remoteAppUserService.getUserByCondition(
                AppUserDTO.builder().id(userId).build(),
                SecurityConstants.INNER).getData();
        return remoteAppUserService.getAppUserById(userId+"").getData();
    }
    /**
@@ -208,28 +341,54 @@
    private void createPayment(Integer payType, String orderNo, BigDecimal needPayAmount,
            String goodsTitle, String goodsDesc, String wxOpenId, Long orderId,
            ClientPlaceOrderVO clientPlaceOrderVO) throws Exception {
        // 截取前42个字符 商品描述信息,微信小程序和微信公众号该字段,最大长度 42 个字符
        goodsDesc = goodsDesc.substring(0, 42);
        // 调用第三方支付获取支付信息
        JSONObject payInfo = JuHeFuUtil.createPayment(orderNo, payType,
                needPayAmount.toString(), goodsTitle, goodsDesc,
                IpUtils.getIpAddr(), wxOpenId, Constants.PAYMENT_NOTIFY_URL);
        // 第三方支付记录
        OrderPaymentRecord paymentRecord = new OrderPaymentRecord();
        paymentRecord.setOrderId(orderId);
        if (payType == 1) {
            clientPlaceOrderVO.setPayInfo(payInfo.getString("pay_info"));
        if (payType == 1){
            // 微信托管支付
            // 截取前42个字符 商品描述信息,微信小程序和微信公众号该字段,最大长度 42 个字符
            // 调用第三方支付获取支付信息
            JSONObject payInfo = JuHeFuUtil.createPayment1(orderNo, payType,
                    needPayAmount.toString(), goodsTitle, goodsDesc,
                    IpUtils.getIpAddr(), wxOpenId,
                    //                "https://v7ro848ar5jx.ngrok.xiaomiqiu123.top/order/client/order/order/base/callback")
                    "https://xq.xqzhihui.com/api/order/client/order/order/base/callback");
            // 第三方支付记录
            OrderPaymentRecord paymentRecord = new OrderPaymentRecord();
            paymentRecord.setOrderId(orderId);
            Order byId = this.getById(orderId);
            this.updateById(byId);
            clientPlaceOrderVO.setPayAmt(payInfo.getString("pay_amt"));
            clientPlaceOrderVO.setPath(payInfo.getJSONObject("expend").getString("path"));
            clientPlaceOrderVO.setPayInfo(payInfo.getJSONObject("expend").getString("pay_info"));
            clientPlaceOrderVO.setOrgId(payInfo.getJSONObject("expend").getString("org_id"));
            clientPlaceOrderVO.setAppId(payInfo.getJSONObject("expend").getString("app_id"));
            paymentRecord.setPaymentType(PaymentTypeEnum.WECHAT_PAY.getCode());
        } else {
            paymentRecord.setPayOrderNo(payInfo.getString("id"));
            paymentRecord.setPaymentStatus(PaymentStatusEnum.TO_BE_PAID.getCode());
            paymentRecord.setPayAmount(needPayAmount);
            orderPaymentRecordService.save(paymentRecord);
            // 设置订单是否需要支付标识
            clientPlaceOrderVO.setZeroFlag(DisabledEnum.NO.getCode());
        }else{
            // 调用第三方支付获取支付信息
            JSONObject payInfo = JuHeFuUtil.createPayment(orderNo, payType,
                    needPayAmount.toString(), goodsTitle, goodsDesc,
                    IpUtils.getIpAddr(), wxOpenId,
                    //                "https://v7ro848ar5jx.ngrok.xiaomiqiu123.top/order/client/order/order/base/callback")
                    "https://xq.xqzhihui.com/api/order/client/order/order/base/callback");
            // 第三方支付记录
            OrderPaymentRecord paymentRecord = new OrderPaymentRecord();
            paymentRecord.setOrderId(orderId);
            paymentRecord.setPayAmount(needPayAmount);
            Order byId = this.getById(orderId);
            byId.setPayOrderNo(payInfo.getString("id"));
            this.updateById(byId);
            clientPlaceOrderVO.setQrcodeUrl(payInfo.getString("qrcode_url"));
            paymentRecord.setPaymentType(PaymentTypeEnum.ALI_PAY.getCode());
            paymentRecord.setPaymentStatus(PaymentStatusEnum.TO_BE_PAID.getCode());
            orderPaymentRecordService.save(paymentRecord);
            // 设置订单是否需要支付标识
            clientPlaceOrderVO.setZeroFlag(DisabledEnum.NO.getCode());
        }
        paymentRecord.setPaymentStatus(PaymentStatusEnum.TO_BE_PAID.getCode());
        orderPaymentRecordService.save(paymentRecord);
        // 设置订单是否需要支付标识
        clientPlaceOrderVO.setZeroFlag(DisabledEnum.NO.getCode());
    }
    /**
@@ -244,4 +403,193 @@
        return this.lambdaQuery().eq(Order::getAppUserId, userId).eq(Order::getOrderFrom, orderFrom)
                .eq(Order::getPaymentStatus, PaymentStatusEnum.COMPLETED.getCode()).list();
    }
    @Override
    public String placeOrderApple(Long targetId, Integer orderFrom,
                                  Long receiverId, Integer balanceFlag,
                                  BigDecimal amount, Integer vipType, String transactionIdentifier) {
        // 获取当前登录用户id
        Long userId = tokenService.getLoginUser().getUserid();
        // 获取用户信息
        AppUser appUser = getAppUserById(userId);
        ClientPlaceOrderVO clientPlaceOrderVO = new ClientPlaceOrderVO();
        Order order = new Order();
        // 购买冥想音频
        if (orderFrom == 1) {
            Meditation meditation = remoteMeditationService.getMeditationById(targetId,
                    SecurityConstants.INNER).getData();
            // 创建订单
            String orderNo = OrderUtil.getOrderNoForPrefix("MX");
            order.setOrderFrom(orderFrom);
            order.setBizOrderNo(orderNo);
            order.setBusinessId(meditation.getId());
            order.setAppUserId(userId);
            order.setTotalAmount(meditation.getIosPrice());
            order.setPayType(3);
            order.setBuyContent("购买疗愈");
            this.save(order);
            Long orderId = order.getId();
            clientPlaceOrderVO.setOrderNo(orderNo);
            clientPlaceOrderVO.setId(orderId);
            // 如果冥想音频价格设定为单独收费,且需要使用余额抵扣
            if (balanceFlag.equals(1) && meditation.getChargeType().equals(ChargeTypeEnum.SEPARATE_CHARGE.getCode())) {
                BigDecimal needPayAmount = handleBalancePayment(appUser,
                        meditation.getIosPrice(),
                        orderId);
                if (needPayAmount.compareTo(BigDecimal.ZERO) <= 0) {
                    clientPlaceOrderVO.setZeroFlag(DisabledEnum.YES.getCode());
                    // 抵扣后金额为0 为余额支付
                    order.setPayType(4);
                    order.setRealPayAmount(meditation.getIosPrice());
                    this.updateById(order);
                    return order.getId().toString();
                }else{
                    order.setPayType(7);
                    this.updateById(order);
                    // 创建支付订单
                    OrderPaymentRecord paymentRecord = new OrderPaymentRecord();
                    paymentRecord.setPayAmount(meditation.getIosPrice());
                    paymentRecord.setPayOrderNo(transactionIdentifier);
                    paymentRecord.setOrderId(orderId);
                    paymentRecord.setPaymentType(PaymentTypeEnum.IOS_PAY.getCode());
                    paymentRecord.setPaymentStatus(PaymentStatusEnum.TO_BE_PAID.getCode());
                    orderPaymentRecordService.save(paymentRecord);
                }
            } else {
                order.setPayType(3);
                this.updateById(order);
                // 纯内购支付
                OrderPaymentRecord paymentRecord = new OrderPaymentRecord();
                paymentRecord.setPayAmount(meditation.getIosPrice());
                paymentRecord.setPayOrderNo(transactionIdentifier);
                paymentRecord.setOrderId(orderId);
                paymentRecord.setPaymentType(PaymentTypeEnum.IOS_PAY.getCode());
                paymentRecord.setPaymentStatus(PaymentStatusEnum.TO_BE_PAID.getCode());
                orderPaymentRecordService.save(paymentRecord);
            }
        }
        else if (orderFrom == 2){
            // 购买课程
            Course course = remoteCourseService.getCourseById(targetId).getData();
            // 创建订单
            String orderNo = OrderUtil.getOrderNoForPrefix("KC");
            order.setOrderFrom(orderFrom);
            order.setBuyContent("购买课程");
            order.setBizOrderNo(orderNo);
            order.setPayOrderNo(transactionIdentifier);
            order.setGiveUserId(receiverId);
            order.setBusinessId(course.getId());
            order.setAppUserId(userId);
            order.setTotalAmount(course.getIosPrice());
            this.save(order);
            Long orderId = order.getId();
            clientPlaceOrderVO.setOrderNo(orderNo);
            clientPlaceOrderVO.setId(orderId);
            if (balanceFlag.equals(1) && course.getChargeType()
                    .equals(ChargeTypeEnum.SEPARATE_CHARGE.getCode())) {
                BigDecimal needPayAmount = handleBalancePayment(appUser, course.getGeneralPrice(),
                        orderId);
                if (needPayAmount.compareTo(BigDecimal.ZERO) <= 0) {
                    clientPlaceOrderVO.setZeroFlag(DisabledEnum.YES.getCode());
                    // 抵扣后金额为0 为余额支付
                    order.setPayType(4);
                    order.setRealPayAmount(course.getGeneralPrice());
                    this.updateById(order);
                    return order.getId()+"";
                }else{
                    order.setPayType(7);
                    this.updateById(order);
                    // 创建支付订单
                    OrderPaymentRecord paymentRecord = new OrderPaymentRecord();
                    paymentRecord.setPayAmount(course.getIosPrice());
                    paymentRecord.setPayOrderNo(transactionIdentifier);
                    paymentRecord.setOrderId(orderId);
                    paymentRecord.setPaymentType(PaymentTypeEnum.IOS_PAY.getCode());
                    paymentRecord.setPaymentStatus(PaymentStatusEnum.TO_BE_PAID.getCode());
                    orderPaymentRecordService.save(paymentRecord);
                }
            } else {
                order.setPayType(3);
                this.updateById(order);
                // 创建支付订单
                OrderPaymentRecord paymentRecord = new OrderPaymentRecord();
                paymentRecord.setPayAmount(course.getIosPrice());
                paymentRecord.setPayOrderNo(transactionIdentifier);
                paymentRecord.setOrderId(orderId);
                paymentRecord.setPaymentType(PaymentTypeEnum.IOS_PAY.getCode());
                paymentRecord.setPaymentStatus(PaymentStatusEnum.TO_BE_PAID.getCode());
                orderPaymentRecordService.save(paymentRecord);
            }
        }
        else if (orderFrom == 3){
            // 创建订单
            String orderNo = OrderUtil.getOrderNoForPrefix("HY");
            order.setOrderFrom(orderFrom);
            order.setBizOrderNo(orderNo);
            order.setAppUserId(userId);
            order.setTotalAmount(amount);
            String vipType1 ="";
            switch (vipType){
                case 1:
                    vipType1="月会员";
                    break;
                case 2:
                    vipType1="季会员";
                    break;
                case 3:
                    vipType1="年会员";
                    break;
            }
            order.setBuyContent(vipType1);
            this.save(order);
            Long orderId = order.getId();
            order.setPayType(3);
            this.updateById(order);
            // 创建支付订单
            OrderPaymentRecord paymentRecord = new OrderPaymentRecord();
            paymentRecord.setPayAmount(amount);
            paymentRecord.setPayOrderNo(transactionIdentifier);
            paymentRecord.setOrderId(orderId);
            paymentRecord.setPaymentType(PaymentTypeEnum.IOS_PAY.getCode());
            paymentRecord.setPaymentStatus(PaymentStatusEnum.TO_BE_PAID.getCode());
            orderPaymentRecordService.save(paymentRecord);
        }else {
            // 充值
            String wxOpenId = appUser.getWxOpenId();
            // 创建订单
            String orderNo = OrderUtil.getOrderNoForPrefix("CZ");
            order.setOrderFrom(orderFrom);
            order.setBizOrderNo(orderNo);
            order.setAppUserId(userId);
            order.setTotalAmount(amount);
            order.setBuyContent("充值");
            this.save(order);
            Long orderId = order.getId();
            order.setPayType(3);
            this.updateById(order);
            // 创建支付订单
            OrderPaymentRecord paymentRecord = new OrderPaymentRecord();
            paymentRecord.setPayAmount(amount);
            paymentRecord.setPayOrderNo(transactionIdentifier);
            paymentRecord.setOrderId(orderId);
            paymentRecord.setPaymentType(PaymentTypeEnum.IOS_PAY.getCode());
            paymentRecord.setPaymentStatus(PaymentStatusEnum.TO_BE_PAID.getCode());
            orderPaymentRecordService.save(paymentRecord);
        }
        return order.getId()+"";
    }
    @Override
    public String refund(Long uid) throws Exception {
        Order byId = this.getById(uid);
        OrderPaymentRecord one = orderPaymentRecordService.lambdaQuery()
                .eq(OrderPaymentRecord::getOrderId, uid)
                .ne(OrderPaymentRecord::getPaymentType, 3)
                .ne(OrderPaymentRecord::getPaymentType, 4).one();
        JuHeFuUtil.refund(one.getPayOrderNo(),byId.getBizOrderNo());
        return null;
    }
}