|
@@ -1,5 +1,6 @@
|
|
|
package com.payment.platform.module.payment.har.service;
|
|
package com.payment.platform.module.payment.har.service;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.MybatisConfiguration;
|
|
import com.baomidou.mybatisplus.core.MybatisConfiguration;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
@@ -640,6 +641,44 @@ class HarOrderServiceTest {
|
|
|
return d;
|
|
return d;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 上游**线上要求**退款的 biz 带非空 reason —— 2026-09-24 真机实测:
|
|
|
|
|
+ * 不带就回「详细参数校验异常,退款原因(reason)不能为空!」。
|
|
|
|
|
+ *
|
|
|
|
|
+ * 这一格**不在任何规范里**:上游表 8 的 biz 只有 order_no / third_order_no 两行,
|
|
|
|
|
+ * demo 没有退款示例,两版 docx 转写件全文也搜不到 reason。所以本用例钉的是
|
|
|
|
|
+ * **线上行为**,不是规范文本 —— 规范哪天补上,这里也不用改。
|
|
|
|
|
+ */
|
|
|
|
|
+ @Test
|
|
|
|
|
+ void openRefund_sendsNonBlankReason_upstreamRejectsEmpty() {
|
|
|
|
|
+ when(orderMapper.selectOne(any())).thenReturn(paidOrder());
|
|
|
|
|
+ when(orderMapper.update(any(), any())).thenReturn(1);
|
|
|
|
|
+ when(harClient.refund(any())).thenReturn(response("10000", null));
|
|
|
|
|
+
|
|
|
|
|
+ service.openRefund(refundDto());
|
|
|
|
|
+
|
|
|
|
|
+ ArgumentCaptor<HarRefundRequest> req = ArgumentCaptor.forClass(HarRefundRequest.class);
|
|
|
|
|
+ verify(harClient).refund(req.capture());
|
|
|
|
|
+ assertTrue(StrUtil.isNotBlank(req.getValue().getReason()),
|
|
|
|
|
+ "调用方没填时必须给默认值,否则整笔退款被上游拒。实测 reason=" + req.getValue().getReason());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /** 调用方填了就按他填的走 —— 退款原因会进商户的账务记录,不该被默认值盖掉 */
|
|
|
|
|
+ @Test
|
|
|
|
|
+ void openRefund_callerReasonWins() {
|
|
|
|
|
+ when(orderMapper.selectOne(any())).thenReturn(paidOrder());
|
|
|
|
|
+ when(orderMapper.update(any(), any())).thenReturn(1);
|
|
|
|
|
+ when(harClient.refund(any())).thenReturn(response("10000", null));
|
|
|
|
|
+ HarOpenRefundDTO dto = refundDto();
|
|
|
|
|
+ dto.setReason("用户申请退款");
|
|
|
|
|
+
|
|
|
|
|
+ service.openRefund(dto);
|
|
|
|
|
+
|
|
|
|
|
+ ArgumentCaptor<HarRefundRequest> req = ArgumentCaptor.forClass(HarRefundRequest.class);
|
|
|
|
|
+ verify(harClient).refund(req.capture());
|
|
|
|
|
+ assertEquals("用户申请退款", req.getValue().getReason());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/** 只取 WHERE 段引用到的绑定值,不倒 `paramNameValuePairs` 全集 —— 后者会把 SET 的绑定值也算进来 */
|
|
/** 只取 WHERE 段引用到的绑定值,不倒 `paramNameValuePairs` 全集 —— 后者会把 SET 的绑定值也算进来 */
|
|
|
private static Set<Object> whereBoundValues(UpdateWrapper<?> w) {
|
|
private static Set<Object> whereBoundValues(UpdateWrapper<?> w) {
|
|
|
Matcher m = Pattern.compile("paramNameValuePairs\\.([A-Za-z0-9_]+)")
|
|
Matcher m = Pattern.compile("paramNameValuePairs\\.([A-Za-z0-9_]+)")
|