This commit is contained in:
wyn
2026-04-30 19:00:15 +08:00
parent a4edccc7de
commit 594c99b4dc
4 changed files with 22 additions and 8 deletions

View File

@@ -41,6 +41,7 @@ import com.peanut.modules.pay.weChatPay.service.WxpayService;
import com.peanut.modules.sys.entity.SysConfigEntity;
import com.peanut.modules.sys.service.SysConfigService;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpException;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
@@ -676,6 +677,7 @@ public class BuyOrderController {
}
//设置状态为已退款
buyOrder.setOrderStatus(Constants.ORDER_STATUS_REFUNDING);
buyOrderService.updateById(buyOrder);
BigDecimal refundFee = buyOrder.getRealMoney();
BigDecimal shippingMoney = buyOrder.getShippingMoney()==null?BigDecimal.ZERO:buyOrder.getShippingMoney();
@@ -742,7 +744,11 @@ public class BuyOrderController {
} else if (buyOrder.getCome()==4) {
weChatRefundInfo.setAppName("thyy");
}
wxpayService.refund(weChatRefundInfo);
try {
wxpayService.refund(weChatRefundInfo);
} catch (Exception e) {
System.out.println("msg=" + e.getMessage()); // 👈 关键
}
}
}
// else if (Constants.PAYMENT_METHOD_ALI_PAY.equals(buyOrder.getPaymentMethod())) {

View File

@@ -19,7 +19,9 @@ public class PayRefundOrder implements Serializable {
@TableId
private Integer refundId;
private Integer id;
private String refundId;
/**
* 支付方式 1微信2支付宝3虚拟币
@@ -29,8 +31,9 @@ public class PayRefundOrder implements Serializable {
/**
* BuyOrder
*/
private Integer orderId;
private String orderSn;
private Integer orderId;
/**
* 微信支付宝订单号
*/

View File

@@ -369,7 +369,7 @@ public class WxpayServiceImpl extends ServiceImpl<PayWechatOrderDao, PayWechatOr
// 这里 * 100微信支付单位为 ‘分’
BigDecimal hand = new BigDecimal("100");
Map<String, Object> amountMap = new HashMap<>();
amountMap.put("refund", refund.multiply(hand));
amountMap.put("refund", refund.multiply(hand).intValue());
amountMap.put("total", total.multiply(hand).intValue());
amountMap.put("currency", "CNY");
paramMap.put("amount", amountMap);
@@ -392,14 +392,18 @@ public class WxpayServiceImpl extends ServiceImpl<PayWechatOrderDao, PayWechatOr
appid = wechatPayConfig.getThyyappId();
}
// app id
paramMap.put("appid", appid);
// paramMap.put("appid", appid);
String notify_url = wechatPayConfig.getRefundNotifyUrl();
String mchName = "";
String mchid = wechatPayConfig.getMchId();
if ("trainingClass".equals(refundInfo.getOrderType())||"lsorder".equals(refundInfo.getOrderType())) {
mchName = "LS";
mchid = wechatPayConfig.getLsMchId();
notify_url = wechatPayConfig.getLsRefundNotifyUrl();
}
// paramMap.put("mchid", mchid);
paramMap.put("notify_url", notify_url);
JSONObject json = JSONObject.parseObject(JSON.toJSONString(paramMap));
@@ -470,9 +474,9 @@ public class WxpayServiceImpl extends ServiceImpl<PayWechatOrderDao, PayWechatOr
PayRefundOrder refund = new PayRefundOrder();
refund.setPayType("1");
refund.setOrderId(order.getOrderId());
refund.setRefundId(resourceMap.get("refund_id").toString());
refund.setTradeNo(resourceMap.get("transaction_id").toString());
refund.setOutTradeNo(resourceMap.get("out_trade_no").toString());
refund.setOrderSn(resourceMap.get("out_trade_no").toString());
refund.setRefundFee(((Map)resourceMap.get("amount")).get("refund").toString());
refundOrderService.save(refund);

View File

@@ -210,8 +210,9 @@
<!-- &lt;!&ndash; 4.2 生产环境:输出到文档&ndash;&gt;-->
<springProfile name="test,prod">
<logger name="com.peanut" level="ERROR" additivity="false">
<logger name="com.peanut" level="INFO" additivity="false">
<!-- <appender-ref ref="DEBUG_FILE"/>-->
<appender-ref ref="INFO_FILE"/>
<appender-ref ref="ERROR_FILE"/>
</logger>
<root level="info">