无关风月
2025-04-03 b01f752252eaadd1fa31eda6a9ad43146660b721
xinquan-modules/xinquan-order/src/main/java/com/xinquan/order/service/impl/OrderServiceImpl.java
@@ -21,6 +21,7 @@
import com.xinquan.order.service.OrderPaymentRecordService;
import com.xinquan.order.service.OrderService;
import com.xinquan.common.core.utils.JuHeFuUtil;
import com.xinquan.order.utils.MD5Generator;
import com.xinquan.order.utils.OrderUtil;
import com.xinquan.system.api.domain.AppUser;
import com.xinquan.system.api.domain.AppUserWalletRecord;
@@ -99,7 +100,7 @@
            Meditation meditation = remoteMeditationService.getMeditationById(targetId,
                    SecurityConstants.INNER).getData();
            String meditationTitle = meditation.getMeditationTitle();
            String detailDescription = meditation.getDetailDescription();
            String detailDescription = "购买疗愈音频";
            String wxOpenId = appUser.getWxOpenId();
            // 创建订单
            String orderNo = OrderUtil.getOrderNoForPrefix("MX");
@@ -117,7 +118,9 @@
                this.save(order);
            }else{
                 order = this.getById(orderId);
                 order.setBizOrderNo(orderNo);
                 order.setBuyContent("购买疗愈【"+meditationTitle+"】");
                 this.updateById(order);
            }
            Long orderId9 = order.getId();
@@ -147,12 +150,12 @@
                order.setBuyContent("购买疗愈【"+meditationTitle+"】");
                this.updateById(order);
                // 创建支付订单
                createPayment(payType, orderNo, needPayAmount, meditationTitle, detailDescription,
                createPayment(payType, orderNo, needPayAmount, meditationTitle, "购买疗愈",
                        wxOpenId, orderId9, clientPlaceOrderVO);
            } else {
                // 创建支付订单
                createPayment(payType, orderNo, type==null?order.getRealPayAmount():order.getRealPayAmount(), meditationTitle,
                        detailDescription, wxOpenId, orderId9, clientPlaceOrderVO);
                        "购买疗愈", wxOpenId, orderId9, clientPlaceOrderVO);
            }
        }
        else if (orderFrom == 2){
@@ -160,7 +163,7 @@
            Course course = remoteCourseService.getCourseById(targetId).getData();
            String courseTitle = course.getCourseTitle();
            String wxOpenId = appUser.getWxOpenId();
            String description = course.getDescription();
            String description = "购买课程";
            // 创建订单
            String orderNo = OrderUtil.getOrderNoForPrefix("KC");
@@ -178,6 +181,8 @@
            }else{
                order = this.getById(orderId);
                order.setBuyContent("购买课程【"+courseTitle+"】");
                order.setBizOrderNo(orderNo);
                this.updateById(order);
            }
            Long orderId8 = order.getId();
@@ -209,12 +214,12 @@
                this.updateById(order);
                // 创建支付订单
                createPayment(payType, orderNo, needPayAmount, courseTitle, description,
                createPayment(payType, orderNo, needPayAmount, courseTitle, "购买课程",
                        wxOpenId, orderId8, clientPlaceOrderVO);
            } else {
                // 创建支付订单
                createPayment(payType, orderNo, order.getRealPayAmount(), courseTitle,
                        description, wxOpenId, orderId8, clientPlaceOrderVO);
                        "购买课程", wxOpenId, orderId8, clientPlaceOrderVO);
            }
        }
        else if (orderFrom == 3){
@@ -299,7 +304,12 @@
            balancePaymentRecord.setPayAmount(one.getRealPayAmount());
            balancePaymentRecord.setPaymentType(PaymentTypeEnum.BALANCE_PAY.getCode());
            balancePaymentRecord.setPaymentStatus(PaymentStatusEnum.COMPLETED.getCode());
            orderPaymentRecordService.save(balancePaymentRecord);
            List<OrderPaymentRecord> list = orderPaymentRecordService.lambdaQuery().eq(OrderPaymentRecord::getOrderId, orderId)
                    .eq(OrderPaymentRecord::getPaymentType, 4).list();
            if (list.isEmpty()){
                orderPaymentRecordService.save(balancePaymentRecord);
            }
            return new BigDecimal("0");
        }else {
            // 更新用户余额
@@ -313,7 +323,11 @@
            balancePaymentRecord.setPaymentType(PaymentTypeEnum.BALANCE_PAY.getCode());
            balancePaymentRecord.setPaymentStatus(PaymentStatusEnum.COMPLETED.getCode());
            balancePaymentRecord.setPayAmount(appUser.getBalance());
            orderPaymentRecordService.save(balancePaymentRecord);
            List<OrderPaymentRecord> list = orderPaymentRecordService.lambdaQuery().eq(OrderPaymentRecord::getOrderId, orderId)
                    .eq(OrderPaymentRecord::getPaymentType, 4).list();
            if (list.isEmpty()){
                orderPaymentRecordService.save(balancePaymentRecord);
            }
            // 计算除去余额还需支付的金额
            return one.getRealPayAmount()
                    .subtract(appUser.getBalance());
@@ -372,7 +386,14 @@
            clientPlaceOrderVO.setOrderId(payInfo.getString("id"));
            paymentRecord.setPaymentStatus(PaymentStatusEnum.TO_BE_PAID.getCode());
            paymentRecord.setPayAmount(needPayAmount);
            orderPaymentRecordService.save(paymentRecord);
            OrderPaymentRecord list = orderPaymentRecordService.lambdaQuery().eq(OrderPaymentRecord::getOrderId, orderId)
                    .ne(OrderPaymentRecord::getPaymentType, 4).one();
            if (list==null){
                orderPaymentRecordService.save(paymentRecord);
            }else{
                list.setPayOrderNo(payInfo.getString("id"));
                orderPaymentRecordService.updateById(list);
            }
            // 设置订单是否需要支付标识
            clientPlaceOrderVO.setZeroFlag(DisabledEnum.NO.getCode());
        }else{
@@ -396,7 +417,14 @@
            paymentRecord.setPaymentType(PaymentTypeEnum.ALI_PAY.getCode());
            paymentRecord.setPaymentStatus(PaymentStatusEnum.TO_BE_PAID.getCode());
            paymentRecord.setPayOrderNo(payInfo.getString("id"));
            orderPaymentRecordService.save(paymentRecord);
            OrderPaymentRecord list = orderPaymentRecordService.lambdaQuery().eq(OrderPaymentRecord::getOrderId, orderId)
                    .ne(OrderPaymentRecord::getPaymentType, 4).one();
            if (list==null){
                orderPaymentRecordService.save(paymentRecord);
            }else{
                list.setPayOrderNo(payInfo.getString("id"));
                orderPaymentRecordService.updateById(list);
            }
            clientPlaceOrderVO.setPayAmt(payInfo.getString("pay_amt"));
            clientPlaceOrderVO.setOrderId(payInfo.getString("id"));
            // 设置订单是否需要支付标识
@@ -421,7 +449,10 @@
    @Override
    public String placeOrderApple(Long targetId, Integer orderFrom,
                                  Long receiverId, Integer balanceFlag,
                                  BigDecimal amount, Integer vipType, String transactionIdentifier) {
                                  BigDecimal amount, Integer vipType, String transactionIdentifier
    ,String originTransactionIdentifier,String receipt) {
//        String s = MD5Generator.generateMD5(receipt);
        // 获取当前登录用户id
        Long userId = tokenService.getLoginUser().getUserid();
        // 获取用户信息
@@ -467,6 +498,7 @@
                    paymentRecord.setOrderId(orderId);
                    paymentRecord.setPaymentType(PaymentTypeEnum.IOS_PAY.getCode());
                    paymentRecord.setPaymentStatus(PaymentStatusEnum.TO_BE_PAID.getCode());
//                    paymentRecord.setReceipt(s);
                    orderPaymentRecordService.save(paymentRecord);
                }
@@ -480,6 +512,8 @@
                paymentRecord.setOrderId(orderId);
                paymentRecord.setPaymentType(PaymentTypeEnum.IOS_PAY.getCode());
                paymentRecord.setPaymentStatus(PaymentStatusEnum.TO_BE_PAID.getCode());
//                paymentRecord.setReceipt(s);
                orderPaymentRecordService.save(paymentRecord);
            }
        }
@@ -521,6 +555,8 @@
                    paymentRecord.setOrderId(orderId);
                    paymentRecord.setPaymentType(PaymentTypeEnum.IOS_PAY.getCode());
                    paymentRecord.setPaymentStatus(PaymentStatusEnum.TO_BE_PAID.getCode());
//                    paymentRecord.setReceipt(s);
                    orderPaymentRecordService.save(paymentRecord);
                }
            } else {
@@ -533,6 +569,8 @@
                paymentRecord.setOrderId(orderId);
                paymentRecord.setPaymentType(PaymentTypeEnum.IOS_PAY.getCode());
                paymentRecord.setPaymentStatus(PaymentStatusEnum.TO_BE_PAID.getCode());
//                paymentRecord.setReceipt(s);
                orderPaymentRecordService.save(paymentRecord);
            }
        }
@@ -559,7 +597,6 @@
            order.setBuyContent(vipType1);
            this.save(order);
            Long orderId = order.getId();
            order.setPayType(3);
            this.updateById(order);
            // 创建支付订单
@@ -569,6 +606,8 @@
            paymentRecord.setOrderId(orderId);
            paymentRecord.setPaymentType(PaymentTypeEnum.IOS_PAY.getCode());
            paymentRecord.setPaymentStatus(PaymentStatusEnum.TO_BE_PAID.getCode());
//            paymentRecord.setReceipt(s);
            orderPaymentRecordService.save(paymentRecord);
        }else {
            // 充值
@@ -580,7 +619,6 @@
            order.setAppUserId(userId);
            order.setTotalAmount(amount);
            order.setRealPayAmount(amount);
            order.setBuyContent("充值");
            this.save(order);
            Long orderId = order.getId();
@@ -593,6 +631,7 @@
            paymentRecord.setOrderId(orderId);
            paymentRecord.setPaymentType(PaymentTypeEnum.IOS_PAY.getCode());
            paymentRecord.setPaymentStatus(PaymentStatusEnum.TO_BE_PAID.getCode());
//            paymentRecord.setReceipt(s);
            orderPaymentRecordService.save(paymentRecord);
        }
        return order.getId()+"";
@@ -622,7 +661,9 @@
            byId.setRefundRemark("后台退款");
            byId.setRefundTime(LocalDateTime.now());
            byId.setPaymentStatus(3);
            byId.setCancelTime(LocalDateTime.now());
            two.setPaymentStatus(3);
            this.updateById(byId);
            orderPaymentRecordService.updateById(two);
            switch (byId.getOrderFrom()){
@@ -668,6 +709,7 @@
            byId.setRefundRemark("后台退款");
            byId.setRefundTime(LocalDateTime.now());
            byId.setPaymentStatus(3);
            byId.setCancelTime(LocalDateTime.now());
            two.setPaymentStatus(3);
            this.updateById(byId);
            orderPaymentRecordService.updateById(two);
@@ -703,6 +745,7 @@
            return refund.getString("error_msg");
        }
        one.setPaymentStatus(3);
        orderPaymentRecordService.updateById(one);
        String string = refund.getString("payment_id");
        if (string!=null){