7
7
import com .egzosn .pay .common .http .UriVariables ;
8
8
import com .egzosn .pay .common .util .sign .SignUtils ;
9
9
import com .egzosn .pay .common .util .str .StringUtils ;
10
- import org .apache .commons .logging .Log ;
11
- import org .apache .commons .logging .LogFactory ;
12
-
13
10
import java .awt .image .BufferedImage ;
14
11
import java .io .InputStream ;
15
12
import java .math .BigDecimal ;
25
22
* </pre>
26
23
*/
27
24
public class FuiouPayService extends BasePayService <FuiouPayConfigStorage > {
28
- //日志
29
- protected final Log log = LogFactory .getLog (FuiouPayService .class );
30
- //正式域名
31
- public final static String URL_FuiouBaseDomain = "https://pay.fuiou.com/" ;
32
- //测试域名
33
- public final static String DEV_URL_FUIOUBASEDOMAIN = "http://www-1.fuiou.com:8888/wg1_run/" ;
34
-
35
- //B2C/B2B支付
36
- public final static String URL_FuiouSmpGate = "smpGate.do" ;
37
- //B2C/B2B支付(跨境支付)
38
- public final static String URL_FuiouNewSmpGate = "newSmpGate.do" ;
39
- //订单退款
40
- public final static String URL_FuiouSmpRefundGate = "newSmpRefundGate.do" ;
41
- //3.2 支付结果查询
42
- public final static String URL_FuiouSmpQueryGate = "smpQueryGate.do" ;
43
- //3.3 支付结果查询(直接返回)
44
- public final static String URL_FuiouSmpAQueryGate = "smpAQueryGate.do" ;
45
- //3.4订单退款
46
- public final static String URL_NewSmpRefundGate = "newSmpRefundGate.do" ;
25
+
26
+ /**
27
+ * 正式域名
28
+ */
29
+ public static final String URL_FuiouBaseDomain = "https://pay.fuiou.com/" ;
30
+ /**
31
+ * 测试域名
32
+ */
33
+ public static final String DEV_URL_FUIOUBASEDOMAIN = "http://www-1.fuiou.com:8888/wg1_run/" ;
34
+
35
+ /**
36
+ * B2C/B2B支付
37
+ */
38
+ public static final String URL_FuiouSmpGate = "smpGate.do" ;
39
+ /**
40
+ * B2C/B2B支付(跨境支付)
41
+ */
42
+ public static final String URL_FuiouNewSmpGate = "newSmpGate.do" ;
43
+ /**
44
+ * 订单退款
45
+ */
46
+ public static final String URL_FuiouSmpRefundGate = "newSmpRefundGate.do" ;
47
+ /**
48
+ * 3.2 支付结果查询
49
+ */
50
+ public static final String URL_FuiouSmpQueryGate = "smpQueryGate.do" ;
51
+ /**
52
+ * 3.3 支付结果查询(直接返回)
53
+ */
54
+ public static final String URL_FuiouSmpAQueryGate = "smpAQueryGate.do" ;
55
+ /**
56
+ * 3.4订单退款
57
+ */
58
+ public static final String URL_NewSmpRefundGate = "newSmpRefundGate.do" ;
59
+
47
60
48
61
/**
49
62
* 获取对应的请求地址
@@ -78,7 +91,7 @@ public FuiouPayService (FuiouPayConfigStorage payConfigStorage) {
78
91
@ Override
79
92
public boolean verify (Map <String , Object > params ) {
80
93
if (!"0000" .equals (params .get ("order_pay_code" ))) {
81
- log .debug (String .format ("富友支付异常:order_pay_code=%s,错误原因=%s,参数集=%s" , params .get ("order_pay_code" ), params .get ("order_pay_error" ), params ));
94
+ LOG .debug (String .format ("富友支付异常:order_pay_code=%s,错误原因=%s,参数集=%s" , params .get ("order_pay_code" ), params .get ("order_pay_error" ), params ));
82
95
return false ;
83
96
}
84
97
try {
@@ -145,24 +158,36 @@ public Map<String, Object> orderInfo(PayOrder order) {
145
158
*/
146
159
private LinkedHashMap <String , Object > getOrderInfo (PayOrder order ) {
147
160
LinkedHashMap <String , Object > parameters = new LinkedHashMap <String , Object >();
148
- parameters .put ("mchnt_cd" , payConfigStorage .getPid ());//商户代码
149
- parameters .put ("order_id" , order .getOutTradeNo ());//商户订单号
150
- parameters .put ("order_amt" , order .getPrice ().multiply (new BigDecimal (100 )).setScale ( 0 , BigDecimal .ROUND_HALF_UP ).intValue ());//交易金额
151
- // parameters.put("cur_type", null == order.getCurType() ? FuiouCurType.CNY:order.getCurType());//交易币种
152
- parameters .put ("order_pay_type" , order .getTransactionType ());//支付类型
153
- parameters .put ("page_notify_url" , payConfigStorage .getReturnUrl ());//商户接受支付结果通知地址
154
- parameters .put ("back_notify_url" , StringUtils .isBlank (payConfigStorage .getNotifyUrl ()) ? "" : payConfigStorage .getNotifyUrl ());//商户接受的支付结果后台通知地址 //非必填
161
+ //商户代码
162
+ parameters .put ("mchnt_cd" , payConfigStorage .getPid ());
163
+ //商户订单号
164
+ parameters .put ("order_id" , order .getOutTradeNo ());
165
+ //交易金额
166
+ parameters .put ("order_amt" , order .getPrice ().multiply (new BigDecimal (100 )).setScale ( 0 , BigDecimal .ROUND_HALF_UP ).intValue ());
167
+ //交易币种
168
+ // parameters.put("cur_type", null == order.getCurType() ? FuiouCurType.CNY:order.getCurType());
169
+ //支付类型
170
+ parameters .put ("order_pay_type" , order .getTransactionType ());
171
+ //商户接受支付结果通知地址
172
+ parameters .put ("page_notify_url" , payConfigStorage .getReturnUrl ());
173
+ //商户接受的支付结果后台通知地址 //非必填
174
+ parameters .put ("back_notify_url" , StringUtils .isBlank (payConfigStorage .getNotifyUrl ()) ? "" : payConfigStorage .getNotifyUrl ());
155
175
156
176
if (null != order .getExpirationTime ()){
157
177
parameters .put ("order_valid_time" , ((order .getExpirationTime ().getTime () - System .currentTimeMillis ())/1000 /60 + "m" ));
158
178
}else {
159
- parameters .put ("order_valid_time" , "30m" );//超时时间 1m-15天,m:分钟、h:小时、d天、1c当天有效,
179
+ //超时时间 1m-15天,m:分钟、h:小时、d天、1c当天有效,
180
+ parameters .put ("order_valid_time" , "30m" );
160
181
}
161
- parameters .put ("iss_ins_cd" , order .getBankType ());//银行代码
182
+ //银行代码
183
+ parameters .put ("iss_ins_cd" , order .getBankType ());
162
184
parameters .put ("goods_name" , order .getSubject ());
163
- parameters .put ("goods_display_url" , "" );//商品展示网址 //非必填
164
- parameters .put ("rem" , "" );//备注 //非必填
165
- parameters .put ("ver" , "1.0.1" );//版本号
185
+ //商品展示网址 //非必填
186
+ parameters .put ("goods_display_url" , "" );
187
+ //备注 //非必填
188
+ parameters .put ("rem" , "" );
189
+ //版本号
190
+ parameters .put ("ver" , "1.0.1" );
166
191
return parameters ;
167
192
}
168
193
@@ -287,9 +312,9 @@ private String getFormString(Map<String, Object> param, MethodType method,String
287
312
formHtml .append ( "<form name=\" pay\" method=\" " +method .name ().toLowerCase ()+"\" " );
288
313
formHtml .append ( "action=\" " +url +"\" id = \" form\" >" );
289
314
290
- for (String key : param .keySet ()) {
291
- Object o = param . get ( key );
292
- formHtml .append ("<input type=\" hidden\" value = '" + o + "' name=\" " + key + "\" />" );
315
+ for (Map . Entry entry : param .entrySet ()) {
316
+ Object o = entry . getValue ( );
317
+ formHtml .append ("<input type=\" hidden\" value = '" + o + "' name=\" " + entry . getKey () + "\" />" );
293
318
}
294
319
295
320
formHtml .append ("</form></body></html>" );
@@ -311,8 +336,6 @@ public Map<String, Object> query(String tradeNo, String outTradeNo) {
311
336
params .put ("order_id" , outTradeNo );
312
337
params .put ("md5" , createSign (SignUtils .parameters2MD5Str (params , "|" ), payConfigStorage .getInputCharset ()));
313
338
JSONObject resultJson = getHttpRequestTemplate ().postForObject (getReqUrl () + URL_FuiouSmpAQueryGate + "?" + UriVariables .getMapToParameters (params ), null , JSONObject .class );
314
-
315
-
316
339
return resultJson ;
317
340
}
318
341
@@ -326,11 +349,12 @@ public Map<String, Object> query(String tradeNo, String outTradeNo) {
326
349
*/
327
350
@ Override
328
351
public Map <String , Object > close (String tradeNo , String outTradeNo ) {
329
- return null ;
352
+ return Collections . EMPTY_MAP ;
330
353
}
331
354
332
355
333
356
357
+
334
358
/**
335
359
* 申请退款接口
336
360
*
@@ -355,17 +379,20 @@ public Map<String, Object> refund (String tradeNo, String outTradeNo, BigDecimal
355
379
* @return 退款返回结果集
356
380
*/
357
381
@ Override
358
- public Map <String , Object > refund (RefundOrder refundOrder ) {
359
- Map <String ,Object > params = new HashMap <>();
360
- params .put ("mchnt_cd" ,payConfigStorage .getPid ());//商户代码
361
- DateFormat df = new SimpleDateFormat ("yyyy-MM-dd" );
362
- df .setTimeZone (TimeZone .getTimeZone ("GMT+8" ));
363
- params .put ("origin_order_date" ,refundOrder .getOrderDate ());//原交易日期
364
- params .put ("origin_order_id" ,refundOrder .getTradeNo ());//原订单号
365
- params .put ("refund_amt" ,refundOrder .getRefundAmount ().multiply (new BigDecimal (100 )).setScale ( 0 , BigDecimal .ROUND_HALF_UP ).intValue ());//退款金额
366
- params .put ("rem" ,"" );//备注
367
- params .put ("md5" ,createSign (SignUtils .parameters2MD5Str (params ,"|" ),payConfigStorage .getInputCharset ()));
368
- JSONObject resultJson = getHttpRequestTemplate ().postForObject (getReqUrl () + URL_FuiouSmpRefundGate ,params ,JSONObject .class );
382
+ public Map <String , Object > refund (RefundOrder refundOrder ) {
383
+ Map <String , Object > params = new HashMap <>();
384
+ //商户代码
385
+ params .put ("mchnt_cd" , payConfigStorage .getPid ());
386
+ //原交易日期
387
+ params .put ("origin_order_date" , refundOrder .getOrderDate ());
388
+ //原订单号
389
+ params .put ("origin_order_id" , refundOrder .getTradeNo ());
390
+ //退款金额
391
+ params .put ("refund_amt" , refundOrder .getRefundAmount ().multiply (new BigDecimal (100 )).setScale (0 , BigDecimal .ROUND_HALF_UP ).intValue ());
392
+ //备注
393
+ params .put ("rem" , "" );
394
+ params .put ("md5" , createSign (SignUtils .parameters2MD5Str (params , "|" ), payConfigStorage .getInputCharset ()));
395
+ JSONObject resultJson = getHttpRequestTemplate ().postForObject (getReqUrl () + URL_FuiouSmpRefundGate , params , JSONObject .class );
369
396
return resultJson ;
370
397
}
371
398
0 commit comments