From fbf430ea78304dc7ae60271090d082f05b21239b Mon Sep 17 00:00:00 2001
From: luodangjia <luodangjia>
Date: 星期四, 05 九月 2024 17:11:56 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java |   75 +++++++++++++++++++++++++++++++++++--
 1 files changed, 71 insertions(+), 4 deletions(-)

diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java
index b672bec..21ce3ea 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java
@@ -440,6 +440,7 @@
 					chargingOrder.setVipDiscountAmount(discountAmount);
 				}
 			}
+			
 		}
 		this.save(chargingOrder);
 
@@ -1325,10 +1326,10 @@
 		return chargingOrderTimeVO;
 	}
 
-	@Override
-	public R payRefund(PayOrderRefundDto payOrderQueryDto) {
-		return null;
-	}
+//	@Override
+//	public R payRefund(PayOrderRefundDto payOrderQueryDto) {
+//		return null;
+//	}
 
 	@Override
 	public ChargingOrderListInfoVO chargingInfo(String uid) {
@@ -1380,6 +1381,7 @@
 		chargingOrderListInfoVO.setList1(list);
 		return chargingOrderListInfoVO;
 	}
+
 
 	/**
 	 * 处理充电订单实时监控数据相关的业务逻辑
@@ -1548,4 +1550,69 @@
 	public void excelEndCharge(String orderCode) {
 		endCharge(orderCode, 0);
 	}
+
+
+
+	@Override
+	public R payRefund(PayOrderRefundDto payOrderQueryDto) {
+			if (payOrderQueryDto.getType()==1){
+				TChargingOrder tChargingOrder = this.baseMapper.selectById(payOrderQueryDto.getOrderId());
+				TChargingOrderRefund chargingOrderRefund = new TChargingOrderRefund();
+				chargingOrderRefund.setChargingOrderId(tChargingOrder.getId());
+				chargingOrderRefund.setRefundAmount(payOrderQueryDto.getRefundAmount());
+				chargingOrderRefund.setRefundStatus(1);
+				chargingOrderRefund.setPayType(tChargingOrder.getRechargePaymentType());
+				chargingOrderRefund.setRefundTime(LocalDateTime.now());
+				chargingOrderRefund.setCode(tChargingOrder.getCode());
+				SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
+				chargingOrderRefund.setRefundCode("GDF" + sdf.format(new Date()) + (Math.random() * 1000));
+				chargingOrderRefund.setRefundTitle("后台退款");
+				chargingOrderRefund.setRefundContent("后台退款");
+				chargingOrderRefund.setRefundReason("后台退款");
+				chargingOrderRefund.setRefundRemark("后台退款");
+				chargingOrderRefund.setRefundTotalAmount(tChargingOrder.getRefundAmount().add(payOrderQueryDto.getRefundAmount()));
+				chargingOrderRefund.setPayAmount(tChargingOrder.getPaymentAmount());
+
+				if(1 == tChargingOrder.getRechargePaymentType()){
+					WxPaymentRefundModel model = new WxPaymentRefundModel();
+					model.setOut_trade_no(tChargingOrder.getCode());
+					model.setOut_refund_no(chargingOrderRefund.getRefundCode());
+					model.setTransaction_id(tChargingOrder.getRechargeSerialNumber());
+					model.setReason("取消订单");
+					model.setNotify_url("http://127.0.0.1:9000/order/t-shopping-order/cancelShoppingOrderWxRefund");
+					WxPaymentRefundModel.RefundAmount amount = new WxPaymentRefundModel.RefundAmount();
+					amount.setRefund(payOrderQueryDto.getRefundAmount().multiply(new BigDecimal(100)).intValue());
+					amount.setTotal(tChargingOrder.getPaymentAmount().multiply(new BigDecimal(100)).intValue());
+					amount.setCurrency("CNY");
+					model.setAmount(amount);
+					R<String> orderR = wxPaymentClient.refundOrderR(model);
+					if(200 == orderR.getCode()){
+						chargingOrderRefundService.save(chargingOrderRefund);
+					}
+				}
+
+				if(2 == tChargingOrder.getRechargePaymentType()){
+					RefundReq dto = new RefundReq();
+					dto.setOutTradeNo(tChargingOrder.getCode());
+					dto.setOutRequestNo(tChargingOrder.getCode());
+					dto.setRefundAmount(payOrderQueryDto.getRefundAmount().toString());
+					dto.setRefundReason("取消订单");
+					RefundResp resp = aliPaymentClient.refund(dto).getData();
+					if(null != resp){
+						SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-DDTHH:mm:ss+TIMEZONE");
+							chargingOrderRefundService.save(chargingOrderRefund);
+
+					}
+				}
+
+
+
+
+
+			}
+
+
+
+		return null;
+	}
 }

--
Gitblit v1.7.1