Преглед изворни кода

添加商户退款富友订单

Yangzw пре 8 месеци
родитељ
комит
10efd85ad7
44 измењених фајлова са 2138 додато и 35 уклоњено
  1. 3 1
      feifan-framework/feifan-spring-boot-starter-biz-pay/src/main/java/cn/newfeifan/mall/framework/pay/core/client/impl/PayClientFactoryImpl.java
  2. 3 2
      feifan-framework/feifan-spring-boot-starter-biz-pay/src/main/java/cn/newfeifan/mall/framework/pay/core/enums/channel/PayChannelEnum.java
  3. 25 0
      feifan-module-pay/feifan-module-pay-api/src/main/java/cn/newfeifan/mall/module/pay/enums/DictTypeConstants.java
  4. 46 0
      feifan-module-pay/feifan-module-pay-api/src/main/java/cn/newfeifan/mall/module/pay/enums/fuyouorder/AfterSaleOrderTypeEnum.java
  5. 31 0
      feifan-module-pay/feifan-module-pay-api/src/main/java/cn/newfeifan/mall/module/pay/enums/fuyouorder/FuYouPayOrderTypeEnum.java
  6. 18 0
      feifan-module-pay/feifan-module-pay-biz/pom.xml
  7. 5 9
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/dal/dataobject/order/PayOrderDO.java
  8. 13 13
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/dal/dataobject/refund/PayRefundDO.java
  9. 43 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/client/CommonQueryClient.java
  10. 35 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/client/GetMchntKeyClient.java
  11. 49 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/client/MicroPayClient.java
  12. 56 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/client/PreCreateClient.java
  13. 34 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/client/QueryChnlPayAmtClient.java
  14. 32 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/client/QueryFeeAmtClient.java
  15. 31 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/client/QueryWithdrawAmtClient.java
  16. 46 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/client/RefundClient.java
  17. 59 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/client/WapPreCreateClient.java
  18. 33 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/client/WithdrawClient.java
  19. 60 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/client/WxPreCreateClient.java
  20. 27 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/reqdata/CommonQueryDataReq.java
  21. 18 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/reqdata/GetMchntKeyDataReq.java
  22. 13 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/reqdata/GetOpenIdReq.java
  23. 54 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/reqdata/MicroPayDataReq.java
  24. 78 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/reqdata/PreCreateDataReq.java
  25. 28 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/reqdata/QueryChnlPayAmtDataReq.java
  26. 18 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/reqdata/QueryFeeAmtDataReq.java
  27. 19 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/reqdata/QueryWithdrawAmtDataReq.java
  28. 34 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/reqdata/RefundDataReq.java
  29. 63 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/reqdata/WapPreCreateDataReq.java
  30. 26 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/reqdata/WebPreCreateDeviceInfo.java
  31. 26 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/reqdata/WithdrawDataReq.java
  32. 61 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/reqdata/WxPreCreateDataReq.java
  33. 28 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/reqvo/SubmitOrderRequestVO.java
  34. 42 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/respVO/FuYouPayOrderSubmitRespVO.java
  35. 88 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/respVO/FuYouPayRefundResponse.java
  36. 133 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/respVO/FuYouPaymentResponseVO.java
  37. 139 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/respVO/FuYouQueryPayOrderResponseVO.java
  38. 79 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/util/DateUtils.java
  39. 158 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/util/FuiouHttpPoster.java
  40. 85 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/util/MD5.java
  41. 113 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/util/MySSLSocketFactory.java
  42. 18 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/service/fuyouorder/FuYouPayOrderService.java
  43. 124 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/service/fuyouorder/FuYouPayOrderServiceImpl.java
  44. 44 10
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/service/refund/PayRefundServiceImpl.java

+ 3 - 1
feifan-framework/feifan-spring-boot-starter-biz-pay/src/main/java/cn/newfeifan/mall/framework/pay/core/client/impl/PayClientFactoryImpl.java

@@ -27,7 +27,6 @@ public class PayClientFactoryImpl implements PayClientFactory {
 
     /**
      * 支付客户端 Map
-     *
      * key:渠道编号
      */
     private final ConcurrentMap<Long, AbstractPayClient<?>> clients = new ConcurrentHashMap<>();
@@ -52,6 +51,9 @@ public class PayClientFactoryImpl implements PayClientFactory {
         clientClass.put(ALIPAY_BAR, AlipayBarPayClient.class);
         // Mock 支付客户端
         clientClass.put(MOCK, MockPayClient.class);
+
+        //富友支付
+        clientClass.put(JSAPI, WxPubPayClient.class);
     }
 
     @Override

+ 3 - 2
feifan-framework/feifan-spring-boot-starter-biz-pay/src/main/java/cn/newfeifan/mall/framework/pay/core/enums/channel/PayChannelEnum.java

@@ -30,11 +30,12 @@ public enum PayChannelEnum {
     ALIPAY_BAR("alipay_bar", "支付宝条码支付", AlipayPayClientConfig.class),
     MOCK("mock", "模拟支付", NonePayClientConfig.class),
 
-    WALLET("wallet", "钱包支付", NonePayClientConfig.class);
+    WALLET("wallet", "钱包支付", NonePayClientConfig.class),
+
+    JSAPI("JSAPI","富友微信公众号支付", NonePayClientConfig.class);
 
     /**
      * 编码
-     *
      * 参考 <a href="https://www.pingxx.com/api/支付渠道属性值.html">支付渠道属性值</a>
      */
     private final String code;

+ 25 - 0
feifan-module-pay/feifan-module-pay-api/src/main/java/cn/newfeifan/mall/module/pay/enums/DictTypeConstants.java

@@ -15,4 +15,29 @@ public interface DictTypeConstants {
 
     String NOTIFY_STATUS = "pay_notify_status"; // 回调状态
 
+    // 富友支付的商户私钥
+    String privateKey = "b58ef4203dbe11ef3effcedc419c26ae";
+
+    // 查询富友支付订单状态为支付成功
+    String transStatus = "SUCCESS";
+
+    // 查询富友支付订单响应码为支功
+    String resultCode = "000000";
+
+    // 富友支付的商户号
+    String mchnt_cd = "0006420F7357129";
+
+    String term_id = "88888888";
+
+    String version = "1.0";
+
+    String term_ip = "192.168.8.8";
+
+    String FUYOU_TRADE_ORDER_NO_PREFIX = "16103-";
+
+    String ORDER_NO_PREFIX = "P";
+
+
+    String TRADE_NO = "trade_no:";
+
 }

+ 46 - 0
feifan-module-pay/feifan-module-pay-api/src/main/java/cn/newfeifan/mall/module/pay/enums/fuyouorder/AfterSaleOrderTypeEnum.java

@@ -0,0 +1,46 @@
+package cn.newfeifan.mall.module.pay.enums.fuyouorder;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * 富友退款的订单类型
+ */
+
+@Getter
+@AllArgsConstructor
+public enum AfterSaleOrderTypeEnum {
+
+    ALIPAY("ALIPAY","(统一下单、条码支付、服务窗支付)"),
+    WECHAT("WECHAT","(统一下单、条码支付、公众号支付、小程序)"),
+    UNIONPAY("UNIONPAY","富友没有备注"),
+    WXAPP("WXAPP","(微信app)"),
+    ALIAPP("ALIAPP","(支付宝app)"),
+    WXH5("WXH5","(微信h5)"),
+    ALIH5("ALIH5","(支付宝h5)"),
+    WXBX("WXBX","(微信保险类)"),
+    ALBX("ALBX","(支付宝保险类)"),
+    WXXS("WXXS","(微信线上所有交易)(不支持线下类型)"),
+    ;
+
+
+    /**
+     * 类型
+     */
+    private final String type;
+
+    /**
+     * 描述
+     */
+    private final String describe;
+
+    public static String getType(String code){
+        for (AfterSaleOrderTypeEnum type : AfterSaleOrderTypeEnum.values()) {
+            if(code.equals(FuYouPayOrderTypeEnum.JSAPI.getCode()) && type.getType().equals(WECHAT.getType())){
+                return type.getType();
+            }
+        }
+        return null;
+    }
+
+}

+ 31 - 0
feifan-module-pay/feifan-module-pay-api/src/main/java/cn/newfeifan/mall/module/pay/enums/fuyouorder/FuYouPayOrderTypeEnum.java

@@ -0,0 +1,31 @@
+package cn.newfeifan.mall.module.pay.enums.fuyouorder;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * 富友支付订单的类型枚举
+ */
+
+@Getter
+@AllArgsConstructor
+public enum FuYouPayOrderTypeEnum {
+
+    JSAPI("JSAPI","公众号线下支付"),
+    APP("APP","app支付(暂不可用)"),
+    FWC("FWC","支付宝服务窗"),
+    LETPAY("LETPAY","小程序"),
+    WXBXJS("WXBXJS","(微信公众号保险类)"),
+    WXBXLET("WXBXLET","(微信小程序保险类)"),
+    WXBXAPP("WXBXAPP","(微信APP保险类)"),
+    ALBXJS("ALBXJS","(支付宝服务窗保险类)"),
+    APPLEPAY("APPLEPAY","相机扫码)"),
+    UNIONPAY("UNIONPAY","(云闪付扫码)"),
+    BESTPAY("BESTPAY","(翼支付js)"),
+    ;
+
+
+    private final String code;
+
+    private final String describe;
+}

+ 18 - 0
feifan-module-pay/feifan-module-pay-biz/pom.xml

@@ -90,6 +90,24 @@
             <artifactId>feifan-spring-boot-starter-biz-dict</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>commons-codec</groupId>
+            <artifactId>commons-codec</artifactId>
+            <version>1.2</version>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-httpclient</groupId>
+            <artifactId>commons-httpclient</artifactId>
+            <version>3.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+            <version>1.2</version>
+        </dependency>
+
     </dependencies>
 
 </project>

+ 5 - 9
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/dal/dataobject/order/PayOrderDO.java

@@ -32,19 +32,16 @@ public class PayOrderDO extends BaseDO {
     private Long id;
     /**
      * 应用编号
-     *
      * 关联 {@link PayAppDO#getId()}
      */
     private Long appId;
     /**
      * 渠道编号
-     *
      * 关联 {@link PayChannelDO#getId()}
      */
     private Long channelId;
     /**
      * 渠道编码
-     *
      * 枚举 {@link PayChannelEnum}
      */
     private String channelCode;
@@ -53,7 +50,6 @@ public class PayOrderDO extends BaseDO {
 
     /**
      * 商户订单编号
-     *
      * 例如说,内部系统 A 的订单号,需要保证每个 PayAppDO 唯一
      */
     private String merchantOrderId;
@@ -78,7 +74,6 @@ public class PayOrderDO extends BaseDO {
     private Integer price;
     /**
      * 渠道手续费,单位:百分比
-     *
      * 冗余 {@link PayChannelDO#getFeeRate()}
      */
     private Double channelFeeRate;
@@ -88,7 +83,6 @@ public class PayOrderDO extends BaseDO {
     private Integer channelFeePrice;
     /**
      * 支付状态
-     *
      * 枚举 {@link PayOrderStatusEnum}
      */
     private Integer status;
@@ -106,13 +100,11 @@ public class PayOrderDO extends BaseDO {
     private LocalDateTime successTime;
     /**
      * 支付成功的订单拓展单编号
-     *
      * 关联 {@link PayOrderExtensionDO#getId()}
      */
     private Long extensionId;
     /**
      * 支付成功的外部订单号
-     *
      * 关联 {@link PayOrderExtensionDO#getNo()}
      */
     private String no;
@@ -126,7 +118,6 @@ public class PayOrderDO extends BaseDO {
     // ========== 渠道相关字段 ==========
     /**
      * 渠道用户编号
-     *
      * 例如说,微信 openid、支付宝账号
      */
     private String channelUserId;
@@ -135,4 +126,9 @@ public class PayOrderDO extends BaseDO {
      */
     private String channelOrderNo;
 
+    /**
+     * 支付订单号
+     */
+    private String payOrderNo;
+
 }

+ 13 - 13
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/dal/dataobject/refund/PayRefundDO.java

@@ -17,7 +17,6 @@ import java.time.LocalDateTime;
 /**
  * 支付退款单 DO
  * 一个支付订单,可以拥有多个支付退款单
- *
  * 即 PayOrderDO : PayRefundDO = 1 : n
  *
  * @author 非繁源码
@@ -39,7 +38,6 @@ public class PayRefundDO extends BaseDO {
     private Long id;
     /**
      * 外部退款号,根据规则生成
-     *
      * 调用支付渠道时,使用该字段作为对接的退款号:
      * 1. 微信退款:对应 <a href="https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_4">申请退款</a> 的 out_refund_no 字段
      * 2. 支付宝退款:对应 <a href="https://opendocs.alipay.com/open/02e7go"统一收单交易退款接口></a> 的 out_request_no 字段
@@ -48,31 +46,26 @@ public class PayRefundDO extends BaseDO {
 
     /**
      * 应用编号
-     *
      * 关联 {@link PayAppDO#getId()}
      */
     private Long appId;
     /**
      * 渠道编号
-     *
      * 关联 {@link PayChannelDO#getId()}
      */
     private Long channelId;
     /**
      * 商户编码
-     *
      * 枚举 {@link PayChannelEnum}
      */
     private String channelCode;
     /**
      * 订单编号
-     *
      * 关联 {@link PayOrderDO#getId()}
      */
     private Long orderId;
     /**
      * 支付订单编号
-     *
      * 冗余 {@link PayOrderDO#getNo()}
      */
     private String orderNo;
@@ -80,13 +73,11 @@ public class PayRefundDO extends BaseDO {
     // ========== 商户相关字段 ==========
     /**
      * 商户订单编号
-     *
      * 例如说,内部系统 A 的订单号,需要保证每个 PayAppDO 唯一
      */
     private String merchantOrderId;
     /**
      * 商户退款订单号
-     *
      * 例如说,内部系统 A 的订单号,需要保证每个 PayAppDO 唯一
      */
     private String merchantRefundId;
@@ -98,7 +89,6 @@ public class PayRefundDO extends BaseDO {
     // ========== 退款相关字段 ==========
     /**
      * 退款状态
-     *
      * 枚举 {@link PayRefundStatusEnum}
      */
     private Integer status;
@@ -125,13 +115,11 @@ public class PayRefundDO extends BaseDO {
     // ========== 渠道相关字段 ==========
     /**
      * 渠道订单号
-     *
      * 冗余 {@link PayOrderDO#getChannelOrderNo()}
      */
     private String channelOrderNo;
     /**
      * 渠道退款单号
-     *
      * 1. 微信退款:对应 <a href="https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_4">申请退款</a> 的 refund_id 字段
      * 2. 支付宝退款:没有字段
      */
@@ -152,9 +140,21 @@ public class PayRefundDO extends BaseDO {
 
     /**
      * 支付渠道的同步/异步通知的内容
-     *
      * 对应 {@link PayRefundRespDTO#getRawData()}
      */
     private String channelNotifyData;
 
+    /**
+     * 退款渠道的请求体
+     */
+    private String channelRequest;
+    /**
+     * 退款渠道的响应体
+     */
+    private String channelResponse;
+    /**
+     * 支付订单号
+     */
+    private String payRefundNo;
+
 }

+ 43 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/client/CommonQueryClient.java

@@ -0,0 +1,43 @@
+package cn.newfeifan.mall.module.pay.fuiou.client;
+
+import cn.newfeifan.mall.module.pay.fuiou.respVO.FuYouQueryPayOrderResponseVO;
+import com.alibaba.fastjson.JSON;
+import cn.newfeifan.mall.module.pay.fuiou.reqdata.CommonQueryDataReq;
+import cn.newfeifan.mall.module.pay.fuiou.util.FuiouHttpPoster;
+import cn.newfeifan.mall.module.pay.fuiou.util.MD5;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import static cn.newfeifan.mall.module.pay.enums.DictTypeConstants.*;
+
+/**
+ * 2.3 订单查询接口
+ * @author user
+ *
+ */
+public class CommonQueryClient {
+	
+	public static void main(String[] args) throws Exception {
+		FuiouHttpPoster http = new FuiouHttpPoster();
+		http.setCharset("utf-8");
+		http.setUrl("https://aipay.fuioupay.com/aggregatePay/commonQuery");
+		CommonQueryDataReq req=new CommonQueryDataReq();
+		req.setVersion("1.0");
+		req.setMchnt_cd(mchnt_cd);
+		req.setRandom_str("201707041112123456");
+		req.setOrder_type("JSAPI");
+		req.setMchnt_order_no("16103-202407112111001");
+		req.setTerm_id("88888888");
+		String data = MD5.MD5Encode(req.getMchnt_cd() + "|" + req.getOrder_type() + "|" + 
+				req.getMchnt_order_no() + "|" + req.getTerm_id() + "|" + req.getRandom_str() + "|" + 
+				req.getVersion() + "|" + privateKey);
+		req.setSign(data);
+		String res = http.newPost(JSON.toJSONString(req));
+		System.out.println("====resp====\n");
+		System.out.println(res);
+
+		ObjectMapper mapper = new ObjectMapper();
+		FuYouQueryPayOrderResponseVO resp = mapper.readValue(res, FuYouQueryPayOrderResponseVO.class);
+		System.out.println(resp.getResult_code());
+	}
+
+}

+ 35 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/client/GetMchntKeyClient.java

@@ -0,0 +1,35 @@
+package cn.newfeifan.mall.module.pay.fuiou.client;
+
+
+import com.alibaba.fastjson.JSON;
+import cn.newfeifan.mall.module.pay.fuiou.reqdata.GetMchntKeyDataReq;
+import cn.newfeifan.mall.module.pay.fuiou.util.FuiouHttpPoster;
+import cn.newfeifan.mall.module.pay.fuiou.util.MD5;
+
+/**
+ * 
+ * 2.11 商户获取密钥
+ * @history 2017年7月17日  创建GetMchntKeyClient.java
+ * 
+ * @version 0.1.0
+ */
+public class GetMchntKeyClient {
+	
+	 private static String privateKey = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAJgAzD8fEvBHQTyxUEeK963mjziMWG7nxpi+pDMdtWiakc6xVhhbaipLaHo4wVI92A2wr3ptGQ1/YsASEHm3m2wGOpT2vrb2Ln/S7lz1ShjTKaT8U6rKgCdpQNHUuLhBQlpJer2mcYEzG/nGzcyalOCgXC/6CySiJCWJmPyR45bJAgMBAAECgYBHFfBvAKBBwIEQ2jeaDbKBIFcQcgoVa81jt5xgz178WXUg/awu3emLeBKXPh2i0YtN87hM/+J8fnt3KbuMwMItCsTD72XFXLM4FgzJ4555CUCXBf5/tcKpS2xT8qV8QDr8oLKA18sQxWp8BMPrNp0epmwun/gwgxoyQrJUB5YgZQJBAOiVXHiTnc3KwvIkdOEPmlfePFnkD4zzcv2UwTlHWgCyM/L8SCAFclXmSiJfKSZZS7o0kIeJJ6xe3Mf4/HSlhdMCQQCnTow+TnlEhDTPtWa+TUgzOys83Q/VLikqKmDzkWJ7I12+WX6AbxxEHLD+THn0JGrlvzTEIZyCe0sjQy4LzQNzAkEAr2SjfVJkuGJlrNENSwPHMugmvusbRwH3/38ET7udBdVdE6poga1Z0al+0njMwVypnNwy+eLWhkhrWmpLh3OjfQJAI3BV8JS6xzKh5SVtn/3Kv19XJ0tEIUnn2lCjvLQdAixZnQpj61ydxie1rggRBQ/5vLSlvq3H8zOelNeUF1fT1QJADNo+tkHVXLY9H2kdWFoYTvuLexHAgrsnHxONOlSA5hcVLd1B3p9utOt3QeDf6x2i1lqhTH2w8gzjvsnx13tWqg==";
+	
+	 public static void main(String[] args) throws Exception {
+		FuiouHttpPoster http = new FuiouHttpPoster();
+		http.setCharset("utf-8");
+		http.setUrl("http://192.168.8.45:45002/aggregatePay/getMchntKey");
+		GetMchntKeyDataReq  req = new GetMchntKeyDataReq();
+		req.setTerm_id("88888888");
+		req.setMchnt_cd("0002900F0370586");
+		StringBuilder sb = new StringBuilder();
+		sb.append(req.getMchnt_cd().trim()).append("|")
+		.append(req.getTerm_id()).append("|")
+		.append(privateKey);
+		req.setSign(MD5.MD5Encode(sb.toString()));
+		String res = http.newPost(JSON.toJSONString(req));
+		System.out.println(res);
+	}
+}

+ 49 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/client/MicroPayClient.java

@@ -0,0 +1,49 @@
+package cn.newfeifan.mall.module.pay.fuiou.client;
+
+import cn.newfeifan.mall.module.pay.fuiou.util.DateUtils;
+import com.alibaba.fastjson.JSON;
+import cn.newfeifan.mall.module.pay.fuiou.reqdata.MicroPayDataReq;
+import cn.newfeifan.mall.module.pay.fuiou.util.FuiouHttpPoster;
+import cn.newfeifan.mall.module.pay.fuiou.util.MD5;
+
+/**
+ * 类功能描述
+ * MicroPayClient.java
+ * 2.2 条码支付
+ * 
+ * @author user
+ * @version 0.1.0
+ */
+public class MicroPayClient {
+
+	public static String privateKey = "f00dac5077ea11e754e14c9541bc0170";
+	
+	public static void main(String[] args) throws Exception {
+		FuiouHttpPoster http = new FuiouHttpPoster();
+		http.setCharset("utf-8");
+		http.setUrl("http://192.168.8.45:45002/aggregatePay/micropay");
+		MicroPayDataReq req = new MicroPayDataReq();
+		req.setVersion("1.0");
+		req.setMchnt_cd("0002900F0313432");
+		req.setRandom_str("201707140000015");
+		req.setOrder_type("ALIPAY");
+		req.setOrder_amt("1");
+		req.setMchnt_order_no("200000000000006");//不能重复
+		req.setTxn_begin_ts(DateUtils.getCurrentDateTime());
+		req.setGoods_des("测试");
+		req.setTerm_id("88888888");
+		req.setTerm_ip("192.168.8.8");
+		req.setAuth_code("4545465465");
+		req.setAddn_inf("hyjfservice18217072673");
+		StringBuilder sb = new StringBuilder();
+		sb.append(req.getMchnt_cd()).append("|").append(req.getOrder_type()).append("|")
+                .append(req.getOrder_amt()).append("|").append(req.getMchnt_order_no()).append("|")
+                .append(req.getTxn_begin_ts()).append("|").append(req.getGoods_des()).append("|").append(req.getTerm_id())
+                .append("|").append(req.getTerm_ip()).append("|").append(req.getAuth_code()).append("|").append(req.getRandom_str())
+				.append("|").append(req.getVersion()).append("|").append(privateKey);
+		System.out.println("请求sign:" + sb);
+		req.setSign(MD5.MD5Encode(sb.toString(), "UTF-8"));
+		String res = http.newPost(JSON.toJSONString(req));
+		System.out.println(res);
+	}
+}

+ 56 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/client/PreCreateClient.java

@@ -0,0 +1,56 @@
+package cn.newfeifan.mall.module.pay.fuiou.client;
+
+
+import cn.newfeifan.mall.module.pay.fuiou.util.DateUtils;
+import com.alibaba.fastjson.JSON;
+import cn.newfeifan.mall.module.pay.fuiou.reqdata.PreCreateDataReq;
+import cn.newfeifan.mall.module.pay.fuiou.util.FuiouHttpPoster;
+import cn.newfeifan.mall.module.pay.fuiou.util.MD5;
+
+/**
+ * 
+ * 2.1 统一下单
+ * PreCreateClient.java
+ *
+ * @history 2017年7月17日  创建PreCreateClient.java
+ * 
+ * @version 0.1.0
+ */
+public class PreCreateClient {
+	
+    public static String privateKey = "4e092f20607e11e71d2214ad47a356fa";
+    
+	public static void main(String[] args) throws Exception {
+		FuiouHttpPoster http = new FuiouHttpPoster();
+		http.setCharset("utf-8");
+		http.setUrl("http://192.168.8.45:45002/aggregatePay/preCreate");
+		PreCreateDataReq  req = new PreCreateDataReq();
+		req.setTerm_id("88888888");
+		req.setTerm_ip("192.168.8.8");
+		req.setRandom_str("20170714000006");//随机字符串
+		req.setMchnt_cd("0002900F0370586");
+		req.setOrder_type("QQ");
+		req.setOrder_amt("1");
+		req.setGoods_des("测试订单1");
+		req.setMchnt_order_no("2017082910000000890003");//不能重复
+		req.setTxn_begin_ts(DateUtils.getCurrentDateTime());//交易开始时间
+		req.setNotify_url("wwww.baidu.com");
+		req.setVersion("1.0");
+        String sb = req.getMchnt_cd().trim() + "|" +
+                req.getOrder_type().trim() + "|" +
+                req.getOrder_amt().trim() + "|" +
+                req.getMchnt_order_no().trim() + "|" +
+                req.getTxn_begin_ts() + "|" +
+                req.getGoods_des() + "|" +
+                req.getTerm_id() + "|" +
+                req.getTerm_ip() + "|" +
+                req.getNotify_url() + "|" +
+                req.getRandom_str() + "|" +
+                req.getVersion() + "|" +
+                privateKey;
+		req.setSign(MD5.MD5Encode(sb));
+		String res = http.newPost(JSON.toJSONString(req));
+		System.out.println(res);
+		
+	}
+}

+ 34 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/client/QueryChnlPayAmtClient.java

@@ -0,0 +1,34 @@
+package cn.newfeifan.mall.module.pay.fuiou.client;
+
+import com.alibaba.fastjson.JSON;
+import cn.newfeifan.mall.module.pay.fuiou.reqdata.QueryChnlPayAmtDataReq;
+import cn.newfeifan.mall.module.pay.fuiou.util.FuiouHttpPoster;
+import cn.newfeifan.mall.module.pay.fuiou.util.MD5;
+
+/**
+ * 2.10 资金划拨查询
+ * @author user
+ *
+ */
+public class QueryChnlPayAmtClient {
+	
+	public static String mchnt_key = "4e092f20607e11e71d2214ad47a356fa";
+	public static void main(String[] args) throws Exception {
+		FuiouHttpPoster http = new FuiouHttpPoster();
+		http.setCharset("utf-8");
+		http.setUrl("http://192.168.8.45:45002/aggregatePay/queryChnlPayAmt");
+		QueryChnlPayAmtDataReq req=new QueryChnlPayAmtDataReq();
+		req.setMchnt_cd("0002900F0370586");
+		req.setStart_date("20170704");
+		req.setEnd_date("20170704");
+		req.setStart_index("1");
+		req.setEnd_index("2");
+		req.setRandom_str("201707041112123456");
+		String data =  MD5.MD5Encode(req.getMchnt_cd() + "|" + req.getStart_date() + "|" + req.getEnd_date() + "|" + 
+				req.getStart_index() + "|" + req.getEnd_index() + "|" + req.getRandom_str() + "|" + mchnt_key);
+		req.setSign(data);
+		String res = http.newPost(JSON.toJSONString(req));
+		System.out.println(res);
+	}
+
+}

+ 32 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/client/QueryFeeAmtClient.java

@@ -0,0 +1,32 @@
+package cn.newfeifan.mall.module.pay.fuiou.client;
+
+import cn.newfeifan.mall.module.pay.fuiou.util.FuiouHttpPoster;
+import cn.newfeifan.mall.module.pay.fuiou.util.MD5;
+import com.alibaba.fastjson.JSON;
+import cn.newfeifan.mall.module.pay.fuiou.reqdata.QueryFeeAmtDataReq;
+
+/**
+ * 类功能描述
+ * QueryFeeAmtClient.java
+ * 2.8 查询提现手续费
+ * 
+ * @author user
+ * @version 0.1.0
+ */
+public class QueryFeeAmtClient {
+
+	public static String privateKey = "4e092f20607e11e71d2214ad47a356fa";
+	
+	public static void main(String[] args) throws Exception {
+		FuiouHttpPoster http = new FuiouHttpPoster();
+		http.setCharset("utf-8");
+		http.setUrl("http://192.168.8.45:45002/aggregatePay/queryFeeAmt");
+		QueryFeeAmtDataReq req = new QueryFeeAmtDataReq();
+		req.setMchnt_cd("0002900F0370586");
+		req.setRandom_str("123456");
+		req.setAmt("200000");
+		req.setSign(MD5.MD5Encode(req.getMchnt_cd() + "|" + req.getAmt() + "|" + req.getRandom_str() + "|" + privateKey, "UTF-8"));
+		String res = http.newPost(JSON.toJSONString(req));
+		System.out.println(res);
+	}
+}

+ 31 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/client/QueryWithdrawAmtClient.java

@@ -0,0 +1,31 @@
+package cn.newfeifan.mall.module.pay.fuiou.client;
+
+import cn.newfeifan.mall.module.pay.fuiou.util.FuiouHttpPoster;
+import cn.newfeifan.mall.module.pay.fuiou.util.MD5;
+import com.alibaba.fastjson.JSON;
+import cn.newfeifan.mall.module.pay.fuiou.reqdata.QueryWithdrawAmtDataReq;
+
+/**
+ * 类功能描述
+ * QueryWithdrawAmtClient.java
+ * 2.7 查询可提现资金
+ * 
+ * @author user
+ * @version 0.1.0
+ */
+public class QueryWithdrawAmtClient {
+
+	public static String privateKey = "4e092f20607e11e71d2214ad47a356fa";
+	
+	public static void main(String[] args) throws Exception {
+		FuiouHttpPoster http = new FuiouHttpPoster();
+		http.setCharset("utf-8");
+		http.setUrl("http://192.168.8.45:45002/aggregatePay/queryWithdrawAmt");
+		QueryWithdrawAmtDataReq req = new QueryWithdrawAmtDataReq();
+		req.setMchnt_cd("0002900F0370586");
+		req.setRandom_str("123456");
+		req.setSign(MD5.MD5Encode(req.getMchnt_cd() + "|" + req.getRandom_str() + "|" + privateKey, "UTF-8"));
+		String res = http.newPost(JSON.toJSONString(req));
+		System.out.println(res);
+	}
+}

+ 46 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/client/RefundClient.java

@@ -0,0 +1,46 @@
+package cn.newfeifan.mall.module.pay.fuiou.client;
+
+import cn.newfeifan.mall.module.pay.fuiou.util.FuiouHttpPoster;
+import cn.newfeifan.mall.module.pay.fuiou.util.MD5;
+import com.alibaba.fastjson.JSON;
+import cn.newfeifan.mall.module.pay.fuiou.reqdata.RefundDataReq;
+
+import static cn.newfeifan.mall.module.pay.enums.DictTypeConstants.*;
+
+/**
+ * 类功能描述
+ * RefundClient.java
+ * 2.4 退款
+ * 
+ * @author user
+ * @version 0.1.0
+ */
+public class RefundClient {
+
+
+	public static void main(String[] args) throws Exception {
+		FuiouHttpPoster http = new FuiouHttpPoster();
+		http.setCharset("utf-8");
+		http.setUrl("https://aipay.fuioupay.com/aggregatePay/commonRefund");
+		RefundDataReq req = new RefundDataReq();
+		req.setVersion("1.0");
+		req.setMchnt_cd(mchnt_cd);
+		req.setTerm_id(term_id);
+		req.setRandom_str("20240713175056568974");
+		req.setMchnt_order_no("16103-202407112111001");
+		req.setRefund_order_no("16103-202407131750580");
+		req.setOrder_type("WECHAT");
+		req.setTotal_amt("100");
+		req.setRefund_amt("100");
+		StringBuilder sb = new StringBuilder();
+		sb.append(req.getMchnt_cd()).append("|").append(req.getOrder_type()).append("|")
+		.append(req.getMchnt_order_no()).append("|").append(req.getRefund_order_no())
+		.append("|").append(req.getTotal_amt()).append("|").append(req.getRefund_amt())
+		.append("|").append(req.getTerm_id()).append("|").append(req.getRandom_str())
+		.append("|").append(req.getVersion()).append("|").append(privateKey);
+		System.out.println("请求sign:"+ sb);
+		req.setSign(MD5.MD5Encode(sb.toString(), "UTF-8"));
+		String res = http.newPost(JSON.toJSONString(req));
+		System.out.println(res);
+	}
+}

+ 59 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/client/WapPreCreateClient.java

@@ -0,0 +1,59 @@
+package cn.newfeifan.mall.module.pay.fuiou.client;
+
+import cn.newfeifan.mall.module.pay.fuiou.util.DateUtils;
+import cn.newfeifan.mall.module.pay.fuiou.util.FuiouHttpPoster;
+import cn.newfeifan.mall.module.pay.fuiou.util.MD5;
+import com.alibaba.fastjson.JSON;
+import cn.newfeifan.mall.module.pay.fuiou.reqdata.WapPreCreateDataReq;
+import cn.newfeifan.mall.module.pay.fuiou.reqdata.WebPreCreateDeviceInfo;
+
+/**
+ * 类功能描述
+ * WapPreCreateClient.java
+ * 2.12 扫码wap/app下单
+ * 
+ * @author user
+ * @version 0.1.0
+ */
+public class WapPreCreateClient {
+
+	public static String privateKey = "4e092f20607e11e71d2214ad47a356fa";
+	
+	public static void main(String[] args) throws Exception {
+		FuiouHttpPoster http = new FuiouHttpPoster();
+		http.setCharset("utf-8");
+		http.setUrl("http://192.168.8.45:45002/aggregatePay/wapPreCreate");
+		WapPreCreateDataReq req = new WapPreCreateDataReq();
+		req.setVersion("1.0");
+		req.setMchnt_cd("0002900F0370586");
+		req.setRandom_str("123456");
+		req.setOrder_type("ALIPAY");
+		req.setMchnt_order_no("10000000014");//不能重复
+		req.setOrder_amt("1");
+		req.setTxn_begin_ts(DateUtils.getCurrentDateTime());
+		req.setGoods_des("测试");
+		req.setTerm_id("0a1b0000");
+		req.setTerm_ip("192");
+		req.setTrade_type("H5");
+		
+		// H5 支付场景信息必填!
+		WebPreCreateDeviceInfo info = new WebPreCreateDeviceInfo();
+		info.setType("Wap");
+		info.setApp_name("淘宝");
+		info.setApp_url("www.taobao.com");
+		req.setReserved_device_info(JSON.toJSONString(info));
+		
+		req.setNotify_url("http://www.baidu.com");
+		StringBuilder sb = new StringBuilder();
+		sb.append(req.getMchnt_cd()).append("|").append(req.getOrder_type()).append("|")
+                .append(req.getTrade_type()).append("|").append(req.getOrder_amt()).append("|")
+                .append(req.getMchnt_order_no()).append("|").append(req.getTxn_begin_ts())
+                .append("|").append(req.getGoods_des()).append("|").append(req.getTerm_id())
+                .append("|").append(req.getTerm_ip()).append("|").append(req.getNotify_url())
+                .append("|").append(req.getRandom_str()).append("|").append(req.getVersion()).append("|").append(privateKey);
+		System.out.println("请求sign:" + sb);
+		req.setSign(MD5.MD5Encode(sb.toString(), "UTF-8"));
+		String res = http.newPost(JSON.toJSONString(req));
+		System.out.println(res);
+	}
+}

+ 33 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/client/WithdrawClient.java

@@ -0,0 +1,33 @@
+package cn.newfeifan.mall.module.pay.fuiou.client;
+
+import cn.newfeifan.mall.module.pay.fuiou.reqdata.WithdrawDataReq;
+import cn.newfeifan.mall.module.pay.fuiou.util.FuiouHttpPoster;
+import cn.newfeifan.mall.module.pay.fuiou.util.MD5;
+import com.alibaba.fastjson.JSON;
+
+/**
+ * 2.9 发起提现
+ * @author user
+ *
+ */
+public class WithdrawClient {
+	
+	public static String mchnt_key = "4e092f20607e11e71d2214ad47a356fa";
+	public static void main(String[] args) throws Exception {
+		FuiouHttpPoster http = new FuiouHttpPoster();
+		http.setCharset("utf-8");
+		http.setUrl("http://192.168.8.45:45002/aggregatePay/withdraw");
+		WithdrawDataReq req=new WithdrawDataReq();
+		req.setMchnt_cd("0002900F0370586");
+		req.setAmt("100");
+		req.setFee_amt("1");
+		req.setTxn_type("2");
+		req.setRandom_str("201707041112123456");
+		String data = MD5.MD5Encode(req.getMchnt_cd() + "|" + req.getAmt() + "|" + req.getFee_amt() + "|" +
+				req.getTxn_type() + "|" + req.getRandom_str() + "|" + mchnt_key);
+		req.setSign(data);
+		String res = http.newPost(JSON.toJSONString(req));
+		System.out.println(res);
+	}
+
+}

+ 60 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/client/WxPreCreateClient.java

@@ -0,0 +1,60 @@
+package cn.newfeifan.mall.module.pay.fuiou.client;
+
+
+import cn.newfeifan.mall.module.pay.fuiou.reqdata.WxPreCreateDataReq;
+import cn.newfeifan.mall.module.pay.fuiou.util.DateUtils;
+import cn.newfeifan.mall.module.pay.fuiou.util.FuiouHttpPoster;
+import cn.newfeifan.mall.module.pay.fuiou.util.MD5;
+import com.alibaba.fastjson.JSON;
+
+/**
+ * 
+ *2.6 公众号或服务窗下单
+ * WxPreCreateClient.java
+ *
+ * @history 2017年7月17日  创建WxPreCreateClient.java
+ * 
+ * @version 0.1.0
+ */
+public class WxPreCreateClient {
+	
+//    public static String privateKey = "4e092f20607e11e71d2214ad47a356fa";
+    public static String privateKey = "b58ef4203dbe11ef3effcedc419c26ae";
+
+	public static void main(String[] args) throws Exception {
+		FuiouHttpPoster http = new FuiouHttpPoster();
+		http.setCharset("utf-8");
+		http.setUrl("http://192.168.8.45:45002/aggregatePay/wxPreCreate");
+		WxPreCreateDataReq req = new WxPreCreateDataReq();
+		req.setTerm_id("88888888");
+		req.setTerm_ip("192.168.8.8");
+		req.setRandom_str(DateUtils.getCurrentDate("yyyyMMddHHmmss")
+					+ "568974");
+		req.setMchnt_cd("0002900F0370586");
+		req.setTrade_type("FWC");
+		req.setOpenid("oDax96l0bZdXqRQ2uVfn_2LV-DxM");//微信支付此字段必填
+//		req.setSub_openid("221122121");//支付宝支付此字段必填
+		req.setOrder_amt("1");
+		req.setGoods_des("测试订单");
+		req.setMchnt_order_no("201707191000000000011");//不能重复
+		req.setTxn_begin_ts(DateUtils.getCurrentDate("yyyyMMddHHmmss"));
+		req.setNotify_url("wwww.baidu.com");
+		req.setVersion("1.0");
+        String sb = req.getMchnt_cd().trim() + "|" +
+                req.getTrade_type().trim() + "|" +
+                req.getOrder_amt().trim() + "|" +
+                req.getMchnt_order_no().trim() + "|" +
+                req.getTxn_begin_ts() + "|" +
+                req.getGoods_des() + "|" +
+                req.getTerm_id() + "|" +
+                req.getTerm_ip() + "|" +
+                req.getNotify_url() + "|" +
+                req.getRandom_str() + "|" +
+                req.getVersion() + "|" +
+                privateKey;
+		req.setSign(MD5.MD5Encode(sb));
+		String res = http.newPost(JSON.toJSONString(req));
+		System.out.println("=====resp=====");
+		System.out.println(res);
+	}
+}

+ 27 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/reqdata/CommonQueryDataReq.java

@@ -0,0 +1,27 @@
+package cn.newfeifan.mall.module.pay.fuiou.reqdata;
+
+import lombok.Getter;
+import lombok.Setter;
+
+@Setter
+@Getter
+public class CommonQueryDataReq {
+	
+    private String version;
+	
+    private String mchnt_cd;
+	
+	private String random_str;
+	
+    private String order_type;
+	
+    private String mchnt_order_no;
+	
+	private String term_id;
+	
+	private String sign;
+	
+    private String ins_cd;
+
+
+}

+ 18 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/reqdata/GetMchntKeyDataReq.java

@@ -0,0 +1,18 @@
+package cn.newfeifan.mall.module.pay.fuiou.reqdata;
+
+
+import lombok.Getter;
+import lombok.Setter;
+
+@Setter
+@Getter
+public class GetMchntKeyDataReq {
+	
+	private String mchnt_cd;
+	
+	private String term_id = "";
+	
+	private String sign;
+
+
+}

+ 13 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/reqdata/GetOpenIdReq.java

@@ -0,0 +1,13 @@
+package cn.newfeifan.mall.module.pay.fuiou.reqdata;
+
+import lombok.Data;
+
+@Data
+public class GetOpenIdReq {
+
+    private String mchnt_cd;
+
+    private String redirect_uri;
+
+    private String sign;
+}

+ 54 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/reqdata/MicroPayDataReq.java

@@ -0,0 +1,54 @@
+package cn.newfeifan.mall.module.pay.fuiou.reqdata;
+
+import lombok.Getter;
+import lombok.Setter;
+
+@Setter
+@Getter
+public class MicroPayDataReq {
+
+    private String version = "";
+	
+	private String mchnt_cd = "";
+	
+	private String random_str = "";
+	
+	private String order_type = "";
+	
+	private String order_amt = "";
+	
+	private String mchnt_order_no = "";
+	
+	private String txn_begin_ts = "";
+	
+	private String goods_des = "";
+	
+	private String goods_detail = "";
+	
+	private String goods_tag = "";
+	
+	private String term_id = "";
+	
+	private String term_ip = "";
+	
+	private String addn_inf = "";
+	
+	private String curr_type = "";
+	
+	private String auth_code = "";
+	
+	private String sence = "";
+	
+	private String sign;
+	
+	private String reserved_sub_appid;
+	
+	private String reserved_limit_pay;
+	
+	private String reserved_expire_minute = "0";
+	
+	private String reserved_fy_term_id;
+	
+	private String ins_cd = "";
+
+}

+ 78 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/reqdata/PreCreateDataReq.java

@@ -0,0 +1,78 @@
+package cn.newfeifan.mall.module.pay.fuiou.reqdata;
+
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+  *实体类
+  时间2017-05-24 10:36:46
+*/
+
+@Setter
+@Getter
+public class PreCreateDataReq {
+	
+	
+	private String addn_inf = "";
+
+	
+	private String curr_type = "CNY";
+	
+	
+	private String goods_des = "";
+	
+
+	private String goods_detail = "";
+	
+	
+	private String goods_tag = "";
+	
+	
+	
+	private String mchnt_cd = "";
+	
+	
+	private String mchnt_order_no;
+	
+
+	private String notify_url = "";
+	
+	
+	private String order_amt = "";
+	
+
+	private String order_type = "";
+	
+
+	private String random_str = "";
+	
+
+	private String reserved_expire_minute = "0";
+	
+	
+	private String reserved_fy_term_id = "";
+	
+
+	private String reserved_limit_pay = "";
+	
+
+	private String reserved_sub_appid = "";
+	
+	
+	private String sign = "";
+	
+
+	private String term_id = "";
+	
+
+	private String term_ip = "";
+	
+	
+	private String txn_begin_ts = "";
+	
+	
+    private String version = "";
+
+
+}

+ 28 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/reqdata/QueryChnlPayAmtDataReq.java

@@ -0,0 +1,28 @@
+package cn.newfeifan.mall.module.pay.fuiou.reqdata;
+
+
+import lombok.Getter;
+import lombok.Setter;
+
+@Setter
+@Getter
+public class QueryChnlPayAmtDataReq {
+	
+    private String mchnt_cd;
+	
+    private String Start_date;
+	
+    private String End_date;
+	
+	private String Start_index;
+	
+	private String End_index;
+	
+	private String random_str;
+	
+	private String sign;
+	
+    private String ins_cd;
+
+
+}

+ 18 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/reqdata/QueryFeeAmtDataReq.java

@@ -0,0 +1,18 @@
+package cn.newfeifan.mall.module.pay.fuiou.reqdata;
+
+import lombok.Data;
+
+@Data
+public class QueryFeeAmtDataReq {
+	
+	private String ins_cd = "";
+	
+	private String mchnt_cd = "";
+	
+	private String random_str = "";
+	
+	private String sign;
+	
+	private String amt = "";
+
+}

+ 19 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/reqdata/QueryWithdrawAmtDataReq.java

@@ -0,0 +1,19 @@
+package cn.newfeifan.mall.module.pay.fuiou.reqdata;
+
+import lombok.Getter;
+import lombok.Setter;
+
+@Setter
+@Getter
+public class QueryWithdrawAmtDataReq {
+
+
+	private String mchnt_cd = "";
+	
+	private String random_str = "";
+	
+	private String sign;
+	
+	private String ins_cd = "";
+
+}

+ 34 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/reqdata/RefundDataReq.java

@@ -0,0 +1,34 @@
+package cn.newfeifan.mall.module.pay.fuiou.reqdata;
+
+import lombok.Data;
+
+@Data
+public class RefundDataReq {
+
+    private String version = "";
+	
+	private String mchnt_cd = "";
+	
+	private String term_id = "";
+	
+	private String random_str = "";
+	
+	private String mchnt_order_no = "";
+	
+	private String refund_order_no = "";
+	
+	private String order_type = "";
+	
+	private String total_amt = "";
+	
+	private String refund_amt = "";
+	
+	private String operator_id = "";
+	
+	private String reserved_fy_term_id;
+	
+	private String sign;
+	
+	private String ins_cd = "";
+
+}

+ 63 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/reqdata/WapPreCreateDataReq.java

@@ -0,0 +1,63 @@
+package cn.newfeifan.mall.module.pay.fuiou.reqdata;
+
+import lombok.Getter;
+import lombok.Setter;
+
+@Setter
+@Getter
+public class WapPreCreateDataReq {
+
+	private String addn_inf = "";
+
+	private String curr_type = "";
+	
+	private String order_type;
+	
+	private String goods_des = "";
+	
+	private String goods_detail = "";
+	
+	private String goods_tag = "";
+	
+    private String ins_cd;
+	
+	private String limit_pay = "";
+	
+	private String mchnt_cd;
+	
+	private String mchnt_order_no;
+	
+	private String notify_url;
+	
+	private String order_amt;
+	
+	private String openid = "";
+	
+	private String product_id = "";
+	
+	private String random_str = "";
+	
+	private String sign;
+	
+	private String sub_openid = "";
+	
+	private String sub_appid = "";
+	
+	private String term_id = "";
+	
+	private String term_ip = "";
+	
+	private String txn_begin_ts;
+	
+	private String trade_type;
+	
+    private String version = "1.0";
+	
+	private String reserved_fy_term_id;
+	
+	private String reserved_expire_minute;
+	
+	private String reserved_device_info;
+
+
+}

+ 26 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/reqdata/WebPreCreateDeviceInfo.java

@@ -0,0 +1,26 @@
+package cn.newfeifan.mall.module.pay.fuiou.reqdata;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 类功能描述
+ * WEB/APP下单,支付场景信息
+ * BarCodePayDeviceInfo.java
+ *
+ * @history 2017年7月17日 廖灿 创建BarCodePayDeviceInfo.java
+ * 
+ * @author user
+ * @version 0.1.0
+ */
+@Setter
+@Getter
+public class WebPreCreateDeviceInfo {
+
+	private String type;
+	
+	private String app_name;
+	
+	private String app_url;
+
+}

+ 26 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/reqdata/WithdrawDataReq.java

@@ -0,0 +1,26 @@
+package cn.newfeifan.mall.module.pay.fuiou.reqdata;
+
+
+import lombok.Getter;
+import lombok.Setter;
+
+@Setter
+@Getter
+public class WithdrawDataReq {
+	
+    private String mchnt_cd;
+	
+    private String amt;
+	
+    private String fee_amt;
+	
+	private String txn_type;
+	
+	private String random_str;
+	
+	private String sign;
+	
+    private String ins_cd;
+
+
+}

+ 61 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/reqdata/WxPreCreateDataReq.java

@@ -0,0 +1,61 @@
+package cn.newfeifan.mall.module.pay.fuiou.reqdata;
+
+
+import lombok.Data;
+
+/**
+  *实体类
+  时间2017-05-24 10:36:46
+*/
+@Data
+public class WxPreCreateDataReq {
+	
+	private String addn_inf = "";
+
+	private String curr_type = "";
+	
+	private String order_type;
+	
+	private String goods_des = "";
+	
+	private String goods_detail = "";
+	
+	private String goods_tag = "";
+	
+	private String limit_pay = "";
+	
+	private String mchnt_cd;
+	
+	private String mchnt_order_no;
+	
+	private String notify_url;
+	
+	private String order_amt;
+	
+	private String openid = "";
+	
+	private String product_id = "";
+	
+	private String random_str = "";
+	
+	private String sign;
+	
+	private String sub_openid = "";
+	
+	private String sub_appid = "";
+	
+	private String term_id = "";
+	
+	private String term_ip = "";
+	
+	private String txn_begin_ts;
+	
+	private String trade_type;
+	
+    private String version = "1.0";
+	
+	private String reserved_fy_term_id;
+	
+	private String reserved_expire_minute;
+
+}

+ 28 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/reqvo/SubmitOrderRequestVO.java

@@ -0,0 +1,28 @@
+package cn.newfeifan.mall.module.pay.fuiou.reqvo;
+
+import cn.newfeifan.mall.module.pay.fuiou.reqdata.WxPreCreateDataReq;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+
+/**
+ * 提交订单请求
+ */
+
+@Data
+@Schema(description = "管理后台 - 支付订单提交 Request VO")
+public class SubmitOrderRequestVO {
+
+    @Schema(description = "支付单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
+    @NotNull(message = "支付单编号不能为空")
+    private Long id;
+
+    @Schema(description = "支付渠道", requiredMode = Schema.RequiredMode.REQUIRED, example = "wx_pub")
+    @NotEmpty(message = "支付渠道不能为空")
+    private String channelCode;
+
+    @Schema(description = "支付渠道的额外参数", requiredMode = Schema.RequiredMode.REQUIRED, example = "wx_pub")
+    private WxPreCreateDataReq req;
+}

+ 42 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/respVO/FuYouPayOrderSubmitRespVO.java

@@ -0,0 +1,42 @@
+package cn.newfeifan.mall.module.pay.fuiou.respVO;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Builder;
+import lombok.Data;
+
+@Schema(description = "管理后台 - 富友支付订单提交 Response")
+@Data
+@Builder
+public class FuYouPayOrderSubmitRespVO {
+
+    /**
+     * 公众号id
+     */
+    private String appId;
+
+    /**
+     * 时间戳,自1970年1月1日0点0分0秒以来的秒数
+     */
+    private String timeStamp;
+
+    /**
+     * 随机字符串,不长于32位。
+     */
+    private String nonceStr;
+
+    /**
+     * 订单性情扩展字符串
+     */
+    private String sdk_package;
+
+    /**
+     * 签名方式,trade_type为JSAPI、LETPAY时才返回
+     */
+    private String signType;
+
+    /**
+     * 签名,使用字段appId、timeStamp、nonceStr、package计算得出的签名值
+     */
+    private String paySign;
+
+}

+ 88 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/respVO/FuYouPayRefundResponse.java

@@ -0,0 +1,88 @@
+package cn.newfeifan.mall.module.pay.fuiou.respVO;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+@Schema(description = "管理后台 - 申请富友退款 Response")
+@Data
+public class FuYouPayRefundResponse {
+    /**
+     * 000000 成功,其他详细参见错误列表
+     */
+    private String result_code;
+
+    /**
+     * 代码描述
+     */
+    private String result_msg;
+
+    /**
+     * 富友分配的商户号
+     */
+    private String mchnt_cd;
+
+    /**
+     * 终端号,用于标识交易的终端设备
+     */
+    private String term_id;
+
+    /**
+     * 随机字符串,用于保证请求的唯一性
+     */
+    private String random_str;
+
+    /**
+     * 订单类型:
+     * ALIPAY (统一下单、条码支付、服务窗支付)
+     * WECHAT(统一下单、条码支付,公众号支付)
+     * UNIONPAY
+     * WXAPP(微信app)
+     * ALIAPP(支付宝app)
+     * WXH5(微信h5)
+     * ALIH5(支付宝h5)
+     * WXBX(微信保险类)
+     * ALBX(支付宝保险类)
+     * 【公众号相关的交易为空,其他都有】
+     */
+    private String order_type;
+
+    /**
+     * 渠道交易流水号
+     */
+    private String transaction_id;
+
+    /**
+     * 退款流水号
+     */
+    private String refund_id;
+
+    /**
+     * 商户订单号,由商户为交易生成的唯一标识
+     */
+    private String mchnt_order_no;
+
+    /**
+     * 商户退款号,由商户为退款生成的唯一标识
+     */
+    private String refund_order_no;
+
+    /**
+     * 富友清算日
+     */
+    private String reserved_fy_settle_dt;
+
+    /**
+     * 退款金额
+     */
+    private String reserved_refund_amt;
+
+    /**
+     * 富友追踪号
+     */
+    private String reserved_fy_trace_no;
+
+    /**
+     * 签名字段,用于验证数据的完整性和真实性
+     */
+    private String sign;
+}

+ 133 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/respVO/FuYouPaymentResponseVO.java

@@ -0,0 +1,133 @@
+package cn.newfeifan.mall.module.pay.fuiou.respVO;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+@Schema(description = "管理后台 - 富友支付订单提交 Response")
+@Data
+public class FuYouPaymentResponseVO {
+    /**
+     * 响应代码
+     */
+    private String result_code;
+
+    /**
+     * 代码描述
+     */
+    private String result_msg;
+
+    /**
+     * 商户号,富友分配的商户号
+     */
+    private String mchnt_cd;
+
+    /**
+     * 终端号
+     */
+    private String term_id;
+
+    /**
+     * 随机字符串
+     */
+    private String random_str	;
+
+    /**
+     * 支付通道对应的子商户识别码
+     */
+    private String sub_mer_id;
+
+    /**
+     * 会话标识,预支付交易会话标识,用于后续接口调用中使用
+     */
+    private String session_id;
+
+    /**
+     * 支付链接(直接重定向调起支付)
+     */
+    private String qr_code;
+
+    /**
+     * 子商户公众号id
+     */
+    private String sub_appid;
+
+    /**
+     * 子商户用户标识
+     */
+    private String sub_openid;
+
+    /**
+     * 微信sdk_appid
+     */
+    private String sdk_appid;
+
+    /**
+     * 微信sdk_timestamp 时间戳
+     */
+    private String sdk_timestamp;
+
+    /**
+     * 微信sdk_noncestr 随机字符串
+     */
+    private String sdk_noncestr;
+
+    /**
+     * 微信扩展订单信息扩展字符串
+     */
+    private String sdk_package;
+
+    /**
+     * 签名方式,trade_type为JSAPI、LETPAY时才返回
+     */
+    private String sdk_signtype;
+
+    /**
+     * 签名
+     */
+    private String sdk_paysign;
+
+    /**
+     * trade_type为APP时才返回
+     */
+    private String sdk_partnerid;
+
+    /**
+     * 富友生成的订单号,需要商户与商户订单号进行关联
+     */
+    private String reserved_fy_order_no;
+
+    /**
+     * 富友清算日
+     */
+    private String reserved_fy_settle_dt;
+
+    /**
+     * 交易流水号,trade_type为FWC时返回
+     */
+    private String reserved_transaction_id;
+
+    /**
+     * 支付追踪号
+     */
+    private String reserved_fy_trace_no;
+
+    /**
+     * 支付不确定参数
+     */
+    private String reserved_pay_info;
+
+    /**
+     * 银行交易号
+     */
+    private String reserved_channel_order_id;
+
+    /**
+     * 附加数据
+     */
+    private String reserved_addn_inf;
+
+    /**
+     * 签名
+     */
+    private String sign;
+}

+ 139 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/respVO/FuYouQueryPayOrderResponseVO.java

@@ -0,0 +1,139 @@
+package cn.newfeifan.mall.module.pay.fuiou.respVO;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+@Schema(description = "管理后台 - 查询富友支付订单 Response")
+@Data
+public class FuYouQueryPayOrderResponseVO {
+    /**
+     * 000000 成功,其他详细参见错误列表
+     */
+    private String result_code;
+
+    /**
+     * 代码描述
+     */
+    private String result_msg;
+
+    /**
+     * 富友分配的商户号
+     */
+    private String mchnt_cd;
+
+    /**
+     * 终端号
+     */
+    private String term_id;
+
+    /**
+     * 随机字符串,用于保证交易请求的唯一性。
+     */
+    private String random_str;
+
+    /**
+     * 订单类型,用于区分不同类型的订单。
+     */
+    private String order_type;
+
+    /**
+     * 订单金额,交易的总金额。
+     */
+    private String order_amt;
+
+    /**
+     * 买家在渠道账号
+     */
+    private String buyer_id;
+
+    /**
+     * 渠道交易流水号
+     */
+    private String transaction_id;
+
+    /**
+     * 额外信息,用于传递附加的业务数据。
+     */
+    private String addn_inf;
+
+    /**
+     * 富友清算日
+     */
+    private String reserved_fy_settle_dt;
+
+    /**
+     * 商户系统内部的订单号
+     */
+    private String mchnt_order_no;
+
+    /**
+     * 交易状态,表示交易的当前状态。
+     */
+    private String trans_stat;
+
+    /**
+     * 优惠金额
+     */
+    private String reserved_coupon_fee;
+
+    /**
+     * 买家在渠道登录账号
+     */
+    private String reserved_buyer_logon_id;
+
+    /**
+     * 支付宝交易资金渠道,详细渠道
+     */
+    private String reserved_fund_bill_list;
+
+    /**
+     * 富友系统内部追踪号
+     */
+    private String reserved_fy_trace_no;
+
+    /**
+     * 银行返回的交易号
+     */
+    private String reserved_channel_order_id;
+
+    /**
+     * 富友的POS终端号,如果不是用的富友的POS终端请忽略
+     */
+    private String reserved_fy_term_id;
+
+    /**
+     * 1:表示信用卡或者花呗
+     * 0:表示其他(非信用方式)
+     * 不填,表示未知
+     */
+    private String reserved_is_credit;
+
+    /**
+     * 付款方式
+     */
+    private String reserved_bank_type;
+
+    /**
+     * 支付完成时间
+     */
+    private String reserved_txn_fin_ts;
+
+    /**
+     * 以分为单位的整数
+     * 只有成功交易才会返回
+     * 如果使用了商户免充值优惠券,该值为订单金额-商户免充值
+     * 如果没有使用商户免充值,该值等于订单金额
+     */
+    private String reserved_settlement_amt;
+
+    /**
+     * 微信营销详情
+     */
+    private String reserved_promotion_detail;
+
+    /**
+     * 签名,用于验证交易请求或响应的完整性。
+     */
+    private String sign;
+
+}

+ 79 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/util/DateUtils.java

@@ -0,0 +1,79 @@
+package cn.newfeifan.mall.module.pay.fuiou.util;
+
+import java.text.ParsePosition;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+
+
+/**
+ * @description 日期处理工具类
+ * @version 1.0.0
+ *
+ */
+public class DateUtils {
+	/**
+	 * 没有分隔符的日期格式
+	 */
+	public static final String FULL_TIME_WITH_OUT_SEPARATOR = "yyyyMMddHHmmss";
+	/**
+	 * 最为常见的日期格式
+	 */
+	public static final String FULL_TIME_WITH_COMMON_SEPARATOR = "yyyy-MM-dd HH:mm:ss";
+
+	/**
+	 * @description 取得当前日期的String。
+	 * @return String 返回值为日期,格式自定义,需要符合标准,参考Java Doc “SimpleDateFormat”
+	 */
+	public static String getCurrentDate(String aFormat) {
+		String tDate = new SimpleDateFormat(aFormat).format(new java.util.Date(
+				System.currentTimeMillis()));
+		return tDate;
+	}
+
+	/**
+	 * 获得当前时间格式yyyyMMddHHmmss
+	 * @return
+	 */
+	public static String getCurrentDateTime() {
+		return DateUtils.getCurrentDate("yyyyMMddHHmmss");
+	}
+
+	
+
+
+
+
+	
+	/**
+	 * @description 获取当前系统时间
+	 * @return 当前系统时间
+	 */
+	public static Date getNowDate() {
+		Date currentTime = new Date();
+		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+		String dateString = formatter.format(currentTime);
+		ParsePosition pos = new ParsePosition(0);
+		Date currentTime_2 = formatter.parse(dateString, pos);
+		return currentTime_2;
+	}
+	
+	/**
+	 * @description 按指定格式获取指定时间字符串
+	 * @param date
+	 *            待转换日期
+	 * @param patterns
+	 *            时间格式 e.g yyyy-MM-dd HH:mm:ss
+	 * @return 返回指定格式指定时间字符串
+	 */
+	public static String getDateStr(Date date, String patterns) {
+		if (date == null) {
+			date = new Date();
+		}
+		SimpleDateFormat formatter = new SimpleDateFormat(patterns);
+		String dateString = formatter.format(date);
+		return dateString;
+	}
+	
+	
+}

+ 158 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/util/FuiouHttpPoster.java

@@ -0,0 +1,158 @@
+/**
+ * 
+ */
+package cn.newfeifan.mall.module.pay.fuiou.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.List;
+
+import cn.newfeifan.mall.framework.common.exception.ErrorCode;
+import lombok.Setter;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.StringRequestEntity;
+import org.apache.commons.httpclient.params.HttpMethodParams;
+import org.apache.commons.httpclient.protocol.Protocol;
+
+import static cn.newfeifan.mall.framework.common.exception.util.ServiceExceptionUtil.exception;
+
+
+/**
+ * @author Administrator
+ * 
+ */
+@Setter
+public class FuiouHttpPoster {
+
+	public FuiouHttpPoster() {
+	}
+
+	private String url;
+
+	private String charset;
+
+	public FuiouHttpPoster(String url, String charset) {
+		super();
+		this.url = url;
+		this.charset = charset;
+	}
+
+	public FuiouHttpPoster(String url) {
+		super();
+		this.url = url;
+		this.charset = Charset.defaultCharset().name();
+	}
+
+	
+	
+	public String newPost(final String body) throws Exception {
+		return post(new PostMethodCallback() {
+
+			@Override
+			public void doInPostMethod(PostMethod postMethod) {
+
+				try {
+					postMethod.setRequestEntity(new StringRequestEntity(body,"application/json","UTF-8"));
+				} catch (UnsupportedEncodingException e) {
+					ErrorCode err = new ErrorCode(1, e.getMessage());
+					throw exception(err);
+				}
+			}
+		});
+	}
+	
+	
+
+	/**
+	 * 使用http协议发送xmltext到url
+//	 *
+//	 * @param url
+//	 *            将要发送的地址
+//	 * @param xmltext
+//	 *            将要发送的内容
+//	 * @return http返回码
+//	 * @throws LoanException
+//	 * @throws Exception
+	 */
+	private String post(PostMethodCallback callback) throws Exception {
+		PostMethod xmlpost = null;
+		HttpClient httpclient = new HttpClient();
+		try {
+			// https设置
+			if (url.indexOf("https://") != -1) {
+				// 创建SSL连接
+				@SuppressWarnings("deprecation")
+				Protocol myhttps = new Protocol("https",
+						new MySSLSocketFactory(), 443);
+				Protocol.registerProtocol("https", myhttps);
+			}	
+			httpclient.getHttpConnectionManager().getParams().setConnectionTimeout(60 * 1000);
+			httpclient.getHttpConnectionManager().getParams().setSoTimeout(60 * 1000);
+			xmlpost = new PostMethod(url);
+			httpclient.getParams().setParameter(
+					HttpMethodParams.HTTP_CONTENT_CHARSET, charset);
+			httpclient.getParams().setContentCharset(charset);
+			// xmlpost.setRequestHeader("content-type", "text/xml; charset=" +
+			// charset);
+
+			// 内部回调,发送数据,设置参数用
+			callback.doInPostMethod(xmlpost);
+			// 执行请求
+			httpclient.executeMethod(xmlpost);
+
+			// 获取返回信息
+			InputStream ips = xmlpost.getResponseBodyAsStream();
+			List<Byte> byteList = new ArrayList<Byte>();
+
+			int is = 0;
+			while ((is = ips.read()) != -1)
+				byteList.add((byte) is);
+
+			byte[] allb = new byte[byteList.size()];
+			for (int j = 0; j < byteList.size(); j++)
+				allb[j] = byteList.get(j);
+			String responseString = new String(allb, charset);
+			// LogWriter.debug(this, "HTTP返回码=" + responseStatCode);
+			System.out.println("应答数据=" + responseString);
+
+			if (url.indexOf("https://") != -1)
+				Protocol.unregisterProtocol("https");
+			return responseString;
+		} catch (IOException ex2) {
+			ErrorCode err = new ErrorCode(1, ex2.getMessage());
+//			throw exception(err);
+//			System.out.println("报文发送到[" + url + "]失败:" + ex2.getMessage());
+//			throw new Exception("报文发送异常");
+		} catch (Exception ex) {
+			ErrorCode err = new ErrorCode(1, ex.getMessage());
+			throw exception(err);
+//			System.out.println("报文发送到[" + url + "]失败:" + ex.getMessage());
+//			throw new Exception("报文发送异常");
+		} finally {
+			try {
+				if(xmlpost != null)
+					xmlpost.releaseConnection();
+				if(httpclient != null)
+					httpclient.getHttpConnectionManager().closeIdleConnections(0);
+			} catch (Exception e) {
+				ErrorCode err = new ErrorCode(1, e.getMessage());
+				throw exception(err);
+			}
+		}
+
+		return null;
+	}
+
+	/**
+	 * PostMethod回调处理
+	 * 
+	 */
+	public interface PostMethodCallback {
+		public void doInPostMethod(PostMethod postMethod);
+	}
+
+}

+ 85 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/util/MD5.java

@@ -0,0 +1,85 @@
+package cn.newfeifan.mall.module.pay.fuiou.util;
+import java.security.MessageDigest;
+
+public class MD5 {
+	private final static String[] hexDigits = { "0", "1", "2", "3", "4", "5",
+			"6", "7", "8", "9", "a", "b", "c", "d", "e", "f" };
+
+	/**
+	 * 转换字节数组为16进制字串
+	 * 
+	 * @param b
+	 *            字节数组
+	 * @return 16进制字串
+	 */
+	public static String byteArrayToHexString(byte[] b) {
+		StringBuffer resultSb = new StringBuffer();
+		for (int i = 0; i < b.length; i++) {
+			resultSb.append(byteToHexString(b[i]));
+		}
+		return resultSb.toString();
+	}
+
+	/**
+	 * J 转换byte到16进制
+	 * 
+	 * @param b
+	 * @return
+	 */
+	private static String byteToHexString(byte b) {
+		int n = b;
+		if (n < 0) {
+			n = 256 + n;
+		}
+		int d1 = n / 16;
+		int d2 = n % 16;
+		return hexDigits[d1] + hexDigits[d2];
+	}
+
+	/**
+	 * J 编码
+	 * 
+	 * @param origin
+	 * @return
+	 */
+
+	// MessageDigest 为 JDK 提供的加密类
+	public static String MD5Encode(String origin) {
+		String resultString = null;
+		try {
+			resultString = new String(origin);
+			MessageDigest md = MessageDigest.getInstance("MD5");
+			resultString = byteArrayToHexString(md.digest(resultString
+					.getBytes("UTF-8")));
+		} catch (Exception ex) {
+		}
+		return resultString;
+	}
+	
+	// MessageDigest 为 JDK 提供的加密类
+	public static String MD5Encode(byte[] bytes) {
+		String resultString = null;
+		try {
+//			resultString = new String(origin);
+			MessageDigest md = MessageDigest.getInstance("MD5");
+			resultString = byteArrayToHexString(md.digest(bytes));
+		} catch (Exception ex) {
+			ex.printStackTrace();
+		}
+		return resultString;
+	}
+	
+	public static String MD5Encode(String origin,String charsetName) {
+		origin =origin.trim();
+		String resultString = null;
+		try {
+			resultString = new String(origin);
+			MessageDigest md = MessageDigest.getInstance("MD5");
+			resultString = byteArrayToHexString(md.digest(resultString
+					.getBytes(charsetName)));
+		} catch (Exception ex) {
+		}
+		return resultString;
+	}
+
+}

+ 113 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/fuiou/util/MySSLSocketFactory.java

@@ -0,0 +1,113 @@
+/**
+ * 
+ */
+package cn.newfeifan.mall.module.pay.fuiou.util;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import java.net.SocketAddress;
+import java.net.UnknownHostException;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+
+import javax.net.SocketFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+
+import org.apache.commons.httpclient.ConnectTimeoutException;
+import org.apache.commons.httpclient.params.HttpConnectionParams;
+import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory;
+
+/**
+ * @author Administrator
+ * 
+ */
+public class MySSLSocketFactory implements SecureProtocolSocketFactory {
+	static {
+		System.out.println(">>>>in MySSLSocketFactory>>");
+	}
+	private SSLContext sslcontext = null;
+
+	private SSLContext createSSLContext() {
+		SSLContext sslcontext = null;
+		try {
+			sslcontext = SSLContext.getInstance("SSL");
+			sslcontext.init(null,
+					new TrustManager[] { new TrustAnyTrustManager() },
+					new java.security.SecureRandom());
+		} catch (NoSuchAlgorithmException e) {
+			e.printStackTrace();
+		} catch (KeyManagementException e) {
+			e.printStackTrace();
+		}
+		return sslcontext;
+	}
+
+	private SSLContext getSSLContext() {
+		if (this.sslcontext == null) {
+			this.sslcontext = createSSLContext();
+		}
+		return this.sslcontext;
+	}
+
+	public Socket createSocket(Socket socket, String host, int port,
+			boolean autoClose) throws IOException, UnknownHostException {
+		return getSSLContext().getSocketFactory().createSocket(socket, host,
+				port, autoClose);
+	}
+
+	public Socket createSocket(String host, int port) throws IOException,
+			UnknownHostException {
+		return getSSLContext().getSocketFactory().createSocket(host, port);
+	}
+
+	public Socket createSocket(String host, int port, InetAddress clientHost,
+			int clientPort) throws IOException, UnknownHostException {
+		return getSSLContext().getSocketFactory().createSocket(host, port,
+				clientHost, clientPort);
+	}
+
+	public Socket createSocket(String host, int port, InetAddress localAddress,
+			int localPort, HttpConnectionParams params) throws IOException,
+			UnknownHostException, ConnectTimeoutException {
+		if (params == null) {
+			throw new IllegalArgumentException("Parameters may not be null");
+		}
+		int timeout = params.getConnectionTimeout();
+		SocketFactory socketfactory = getSSLContext().getSocketFactory();
+		if (timeout == 0) {
+			return socketfactory.createSocket(host, port, localAddress,
+					localPort);
+		} else {
+			Socket socket = socketfactory.createSocket();
+			SocketAddress localaddr = new InetSocketAddress(localAddress,
+					localPort);
+			SocketAddress remoteaddr = new InetSocketAddress(host, port);
+			socket.bind(localaddr);
+			socket.connect(remoteaddr, timeout);
+			return socket;
+		}
+	}
+
+	//
+	private static class TrustAnyTrustManager implements X509TrustManager {
+
+		public void checkClientTrusted(X509Certificate[] chain, String authType)
+				throws CertificateException {
+		}
+
+		public void checkServerTrusted(X509Certificate[] chain, String authType)
+				throws CertificateException {
+		}
+
+		public X509Certificate[] getAcceptedIssuers() {
+			return new X509Certificate[] {};
+		}
+	}
+
+}

+ 18 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/service/fuyouorder/FuYouPayOrderService.java

@@ -0,0 +1,18 @@
+package cn.newfeifan.mall.module.pay.service.fuyouorder;
+
+
+import cn.newfeifan.mall.framework.pay.core.client.PayClient;
+import cn.newfeifan.mall.module.pay.api.refund.dto.PayRefundCreateReqDTO;
+import cn.newfeifan.mall.module.pay.dal.dataobject.channel.PayChannelDO;
+import cn.newfeifan.mall.module.pay.dal.dataobject.order.PayOrderDO;
+import cn.newfeifan.mall.module.pay.dal.dataobject.refund.PayRefundDO;
+
+/**
+ * 富有支付订单 Service 接口
+ *
+ * @author aquan
+ */
+public interface FuYouPayOrderService {
+
+    void payRefund(PayRefundCreateReqDTO reqDTO, PayOrderDO order, PayRefundDO refund, PayChannelDO channel, PayClient client);
+}

+ 124 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/service/fuyouorder/FuYouPayOrderServiceImpl.java

@@ -0,0 +1,124 @@
+package cn.newfeifan.mall.module.pay.service.fuyouorder;
+
+import cn.newfeifan.mall.framework.common.exception.ErrorCode;
+import cn.newfeifan.mall.framework.pay.core.client.PayClient;
+import cn.newfeifan.mall.module.pay.api.refund.dto.PayRefundCreateReqDTO;
+import cn.newfeifan.mall.module.pay.dal.dataobject.channel.PayChannelDO;
+import cn.newfeifan.mall.module.pay.dal.dataobject.order.PayOrderDO;
+import cn.newfeifan.mall.module.pay.dal.dataobject.refund.PayRefundDO;
+import cn.newfeifan.mall.module.pay.dal.mysql.refund.PayRefundMapper;
+import cn.newfeifan.mall.module.pay.dal.redis.no.PayNoRedisDAO;
+import cn.newfeifan.mall.module.pay.enums.fuyouorder.AfterSaleOrderTypeEnum;
+import cn.newfeifan.mall.module.pay.enums.notify.PayNotifyTypeEnum;
+import cn.newfeifan.mall.module.pay.enums.refund.PayRefundStatusEnum;
+import cn.newfeifan.mall.module.pay.fuiou.reqdata.RefundDataReq;
+import cn.newfeifan.mall.module.pay.fuiou.respVO.FuYouPayRefundResponse;
+import cn.newfeifan.mall.module.pay.fuiou.util.DateUtils;
+import cn.newfeifan.mall.module.pay.fuiou.util.FuiouHttpPoster;
+import cn.newfeifan.mall.module.pay.fuiou.util.MD5;
+import cn.newfeifan.mall.module.pay.service.notify.PayNotifyService;
+import cn.newfeifan.mall.module.pay.service.order.PayOrderService;
+import com.alibaba.fastjson.JSON;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+import java.time.LocalDateTime;
+
+import static cn.newfeifan.mall.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.newfeifan.mall.module.pay.enums.DictTypeConstants.*;
+import static cn.newfeifan.mall.module.pay.enums.ErrorCodeConstants.REFUND_STATUS_IS_NOT_WAITING;
+
+@Slf4j
+@Service
+public class FuYouPayOrderServiceImpl implements FuYouPayOrderService {
+
+    @Resource
+    private PayNoRedisDAO noRedisDAO;
+
+    @Resource
+    private PayRefundMapper refundMapper;
+
+    @Resource
+    private PayOrderService orderService;
+
+    @Resource
+    private PayNotifyService notifyService;
+
+    @Override
+    public void payRefund(PayRefundCreateReqDTO reqDTO, PayOrderDO order, PayRefundDO refund, PayChannelDO channel, PayClient client) {
+        String no = noRedisDAO.generate(FUYOU_TRADE_ORDER_NO_PREFIX);
+
+        FuiouHttpPoster http = new FuiouHttpPoster();
+        http.setCharset("utf-8");
+        http.setUrl("https://aipay.fuioupay.com/aggregatePay/commonRefund");
+        RefundDataReq req = new RefundDataReq();
+        req.setVersion(version);
+        req.setMchnt_cd(mchnt_cd);
+        req.setTerm_id(term_id);
+        req.setRandom_str(DateUtils.getCurrentDate("yyyyMMddHHmmss")
+                + "568974");
+        req.setMchnt_order_no(order.getPayOrderNo());
+        req.setRefund_order_no(no);
+        req.setOrder_type(AfterSaleOrderTypeEnum.getType(order.getChannelCode()));
+        req.setTotal_amt(order.getPrice().toString());
+        req.setRefund_amt(refund.getRefundPrice().toString());
+        StringBuilder sb = new StringBuilder();
+        sb.append(req.getMchnt_cd()).append("|").append(req.getOrder_type()).append("|")
+                .append(req.getMchnt_order_no()).append("|").append(req.getRefund_order_no())
+                .append("|").append(req.getTotal_amt()).append("|").append(req.getRefund_amt())
+                .append("|").append(req.getTerm_id()).append("|").append(req.getRandom_str())
+                .append("|").append(req.getVersion()).append("|").append(privateKey);
+        System.out.println("请求sign:"+ sb);
+        req.setSign(MD5.MD5Encode(sb.toString(), "UTF-8"));
+        log.info("向富友发起退款请求 == 请求体:{}", JSON.toJSONString(req));
+        try {
+            String res = http.newPost(JSON.toJSONString(req));
+            log.info("向富友发起退款请求 == 响应体:{}", res);
+
+            // 解析返回结果,获取参数
+            ObjectMapper mapper = new ObjectMapper();
+            FuYouPayRefundResponse resp = mapper.readValue(res, FuYouPayRefundResponse.class);
+
+            // 创建退款单
+            PayRefundDO updateRefundObj = new PayRefundDO()
+                    .setChannelRequest(JSON.toJSONString(req))
+                    .setChannelResponse(res);
+
+            // 记录异常信息
+            if (!resultCode.equals(resp.getResult_code())) {
+                updateRefundObj.setChannelErrorCode(resp.getResult_code());
+                updateRefundObj.setChannelErrorMsg(resp.getResult_msg());
+                refundMapper.updateById(updateRefundObj);
+
+                ErrorCode ERROR = new ErrorCode(1_007_901_006, "请求退款失败");
+                throw exception(ERROR);
+            }
+
+            // 1 更新 PayRefundDO
+            updateRefundObj.setPayRefundNo(no)
+                    .setSuccessTime(LocalDateTime.now())
+                    .setChannelRefundNo(resp.getRefund_id())
+                    .setStatus(PayRefundStatusEnum.SUCCESS.getStatus());
+            int updateCounts = refundMapper.updateByIdAndStatus(refund.getId(), refund.getStatus(), updateRefundObj);
+            if (updateCounts == 0) { // 校验状态,必须是等待状态
+                throw exception(REFUND_STATUS_IS_NOT_WAITING);
+            }
+            log.info("[notifyRefundSuccess][退款订单({}) 更新为退款成功]", refund.getId());
+
+            // 2. 更新订单
+            orderService.updateOrderRefundPrice(refund.getOrderId(), refund.getRefundPrice());
+
+            // 3. 插入退款通知记录
+            notifyService.createPayNotifyTask(PayNotifyTypeEnum.REFUND.getType(),
+                    refund.getId());
+
+        } catch (Exception e) {
+            log.error("向富友发起退款请求 == 异常:{}", e.getMessage());
+            ErrorCode ERROR = new ErrorCode(1_007_901_006, "异常! 请求退款失败");
+            throw exception(ERROR);
+        }
+    }
+}

+ 44 - 10
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/service/refund/PayRefundServiceImpl.java

@@ -18,12 +18,14 @@ import cn.newfeifan.mall.module.pay.dal.dataobject.order.PayOrderDO;
 import cn.newfeifan.mall.module.pay.dal.dataobject.refund.PayRefundDO;
 import cn.newfeifan.mall.module.pay.dal.mysql.refund.PayRefundMapper;
 import cn.newfeifan.mall.module.pay.dal.redis.no.PayNoRedisDAO;
+import cn.newfeifan.mall.module.pay.enums.fuyouorder.FuYouPayOrderTypeEnum;
 import cn.newfeifan.mall.module.pay.enums.notify.PayNotifyTypeEnum;
 import cn.newfeifan.mall.module.pay.enums.order.PayOrderStatusEnum;
 import cn.newfeifan.mall.module.pay.enums.refund.PayRefundStatusEnum;
 import cn.newfeifan.mall.module.pay.framework.pay.config.PayProperties;
 import cn.newfeifan.mall.module.pay.service.app.PayAppService;
 import cn.newfeifan.mall.module.pay.service.channel.PayChannelService;
+import cn.newfeifan.mall.module.pay.service.fuyouorder.FuYouPayOrderService;
 import cn.newfeifan.mall.module.pay.service.notify.PayNotifyService;
 import cn.newfeifan.mall.module.pay.service.order.PayOrderService;
 import lombok.extern.slf4j.Slf4j;
@@ -65,6 +67,9 @@ public class PayRefundServiceImpl implements PayRefundService {
     @Resource
     private PayNotifyService notifyService;
 
+    @Resource
+    private FuYouPayOrderService fuYouPayOrderService;
+
     @Override
     public PayRefundDO getRefund(Long id) {
         return refundMapper.selectById(id);
@@ -98,11 +103,20 @@ public class PayRefundServiceImpl implements PayRefundService {
         PayOrderDO order = validatePayOrderCanRefund(reqDTO);
         // 1.3 校验支付渠道是否有效
         PayChannelDO channel = channelService.validPayChannel(order.getChannelId());
-        PayClient client = channelService.getPayClient(channel.getId());
-        if (client == null) {
-            log.error("[refund][渠道编号({}) 找不到对应的支付客户端]", channel.getId());
-            throw exception(CHANNEL_NOT_FOUND);
+        PayClient client = null;
+
+        /*
+         * 这里做一下调整,因为现在对接了两个支付方(富友,微信),所以退款的申请对象也不同
+         */
+        if (!channel.getCode().equals(FuYouPayOrderTypeEnum.JSAPI.getCode())) {
+            client = channelService.getPayClient(channel.getId());
+
+            if (client == null) {
+                log.error("[refund][渠道编号({}) 找不到对应的支付客户端]", channel.getId());
+                throw exception(CHANNEL_NOT_FOUND);
+            }
         }
+
         // 1.4 校验退款订单是否已经存在
         PayRefundDO refund = refundMapper.selectByAppIdAndMerchantRefundId(
                 app.getId(), reqDTO.getMerchantRefundId());
@@ -123,6 +137,28 @@ public class PayRefundServiceImpl implements PayRefundService {
                 .setStatus(PayRefundStatusEnum.WAITING.getStatus())
                 .setPayPrice(order.getPrice()).setRefundPrice(reqDTO.getPrice());
         refundMapper.insert(refund);
+
+        //选择不同的渠道退款
+        if (channel.getCode().equals(FuYouPayOrderTypeEnum.JSAPI.getCode())) {
+            fuYouPayOrderService.payRefund(reqDTO, order, refund, channel, client);
+        } else {
+            // 这里是原来芋道的,不去改动
+            selectChannelRefund(reqDTO, order, refund, channel, client);
+        }
+
+        // 返回退款编号
+        return refund.getId();
+    }
+
+    /**
+     * 原本芋道退款的方法
+     * @param reqDTO 退款信息
+     * @param order 订单信息
+     * @param refund 支付退款信息
+     * @param channel 通道
+     * @param client 支付客户端
+     */
+    private void selectChannelRefund(PayRefundCreateReqDTO reqDTO, PayOrderDO order, PayRefundDO refund, PayChannelDO channel, PayClient client) {
         try {
             // 2.2 向渠道发起退款申请
             PayRefundUnifiedReqDTO unifiedReqDTO = new PayRefundUnifiedReqDTO()
@@ -142,9 +178,6 @@ public class PayRefundServiceImpl implements PayRefundService {
             log.error("[createPayRefund][退款 id({}) requestDTO({}) 发生异常]",
                     refund.getId(), reqDTO, e);
         }
-
-        // 返回退款编号
-        return refund.getId();
     }
 
     /**
@@ -164,7 +197,7 @@ public class PayRefundServiceImpl implements PayRefundService {
         }
 
         // 校验金额,退款金额不能大于原定的金额
-        if (reqDTO.getPrice() + order.getRefundPrice() > order.getPrice()){
+        if (reqDTO.getPrice() + order.getRefundPrice() > order.getPrice()) {
             throw exception(REFUND_PRICE_EXCEED);
         }
         // 是否有退款中的订单
@@ -197,9 +230,10 @@ public class PayRefundServiceImpl implements PayRefundService {
      * 通知并更新订单的退款结果
      *
      * @param channel 支付渠道
-     * @param notify 通知
+     * @param notify  通知
      */
-    @Transactional(rollbackFor = Exception.class)  // 注意,如果是方法内调用该方法,需要通过 getSelf().notifyRefund(channel, notify) 调用,否则事务不生效
+    @Transactional(rollbackFor = Exception.class)
+    // 注意,如果是方法内调用该方法,需要通过 getSelf().notifyRefund(channel, notify) 调用,否则事务不生效
     public void notifyRefund(PayChannelDO channel, PayRefundRespDTO notify) {
         // 情况一:退款成功
         if (PayRefundStatusRespEnum.isSuccess(notify.getStatus())) {