| 
														
															@@ -3,22 +3,128 @@ package com.platform.yijia.controller; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.alibaba.fastjson.JSON; 
														 | 
														
														 | 
														
															 import com.alibaba.fastjson.JSON; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.alibaba.fastjson.JSONObject; 
														 | 
														
														 | 
														
															 import com.alibaba.fastjson.JSONObject; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.alibaba.fastjson.parser.Feature; 
														 | 
														
														 | 
														
															 import com.alibaba.fastjson.parser.Feature; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import com.google.gson.Gson; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.platform.yijia.config.YiJiaRequest; 
														 | 
														
														 | 
														
															 import com.platform.yijia.config.YiJiaRequest; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.platform.yijia.param.request.PayInfoRequest; 
														 | 
														
														 | 
														
															 import com.platform.yijia.param.request.PayInfoRequest; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.platform.yijia.utils.HttpUtils; 
														 | 
														
														 | 
														
															 import com.platform.yijia.utils.HttpUtils; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.platform.yijia.utils.RSASignature; 
														 | 
														
														 | 
														
															 import com.platform.yijia.utils.RSASignature; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import com.platform.yijia.utils.ResultData; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.platform.yijia.utils.SXFPaySign; 
														 | 
														
														 | 
														
															 import com.platform.yijia.utils.SXFPaySign; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import org.slf4j.Logger; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import org.slf4j.LoggerFactory; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import org.springframework.beans.factory.annotation.Value; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import org.springframework.transaction.annotation.Transactional; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import org.springframework.web.bind.annotation.*; 
														 | 
														
														 | 
														
															 import org.springframework.web.bind.annotation.*; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import java.text.ParseException; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import java.util.HashMap; 
														 | 
														
														 | 
														
															 import java.util.HashMap; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import java.util.LinkedHashMap; 
														 | 
														
														 | 
														
															 import java.util.LinkedHashMap; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import java.util.Random; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+/*** 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ * demo随行付测试 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ */ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 @RestController 
														 | 
														
														 | 
														
															 @RestController 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 @YiJiaRequest() 
														 | 
														
														 | 
														
															 @YiJiaRequest() 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 @CrossOrigin 
														 | 
														
														 | 
														
															 @CrossOrigin 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 public class DemoFenZhang { 
														 | 
														
														 | 
														
															 public class DemoFenZhang { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    private static Logger logger =(Logger) LoggerFactory.getLogger(DemoFenZhang.class); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//    @Value("${yijia.path.global-prefix}") 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//    private String globalPrefix; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//    @Value("${yijia.domainName}") 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//    private String domainName; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    @RequestMapping(value = "/demoTradeRefund", consumes = "application/json", method = RequestMethod.POST) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    public String demoTradeRefund(@RequestBody PayInfoRequest payInfoRequest) throws Exception { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        Gson gson = new Gson(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        ResultData resultData = null; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        JSONObject reqData = new JSONObject(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        Random random = new Random(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        String r = ""; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        for (int i = 0; i < 6; i++) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            r += random.nextInt(10); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        String ordNo = System.nanoTime() + r; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        logger.info("生成的订单号:" + ordNo); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        //业务参数 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        reqData.put("ordNo", ordNo); //商户订单号 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        reqData.put("mno", "399210816375479"); //商户编号 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        //下面三个至少传一个 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        reqData.put("origOrderNo", "10012955127877835724009"); //原商户订单号 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+         //reqData.put("origUuid", "3357cfbe24bc4de1bcb7013dd129eba3"); //原交易科技公司订单号 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        //reqData.put("origSxfUuid", "83620210924554863049"); //正交易落单号 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        reqData.put("amt", "0.01"); //退款金额 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        //String notifyUrl = "https://"+domainName+"/"+globalPrefix+"/tradeRefund"; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        //reqData.put("notifyUrl", notifyUrl); //回调推送地址,用来接收科技公司的异步推送 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        reqData.put("refundReason", "退货"); //退货原因 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        reqData.put("extend", ""); //备用 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        String req= SXFPaySign.getSXFPay(reqData); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        ///logger.debug("参数信息:"+req); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        System.out.println("req:" + req); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        //此处不要改变reqData里面值的顺序用LinkedHashMap 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        HashMap reqMap = JSON.parseObject(req, LinkedHashMap.class, Feature.OrderedField); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        //组装加密串 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        String signContent = RSASignature.getOrderContent(reqMap); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        System.out.println("拼接后的参数:" + signContent); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        //logger.debug("拼接后的参数:"+signContent); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        //sign 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        String sign = RSASignature.encryptBASE64(RSASignature.sign(signContent, SXFPaySign.privateKey)); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        System.out.println("============签名:" + sign); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        reqMap.put("sign", sign); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        String reqStr = JSON.toJSONString(reqMap); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        System.out.println("请求参数:" + reqMap); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        System.out.println("请求参数:" + reqStr); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        //调用第三方接口地址 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        String url = "https://openapi.suixingpay.com/order/refund";//生产地址 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        String resultJson = HttpUtils.connectPostUrl(url, reqStr); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        System.out.println("返回信息:" + resultJson); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        //不要对reqData排序 所以用LinkedHashMap 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        HashMap<String, Object> result = JSON.parseObject(resultJson, LinkedHashMap.class, Feature.OrderedField); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        if ("0000".equals(result.get("code"))) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            //验签 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            String signResult = result.get("sign").toString(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            result.remove("sign"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            String resultStr = RSASignature.getOrderContent(result); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            System.out.println("resultStr: " + resultStr); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            //sign 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            String resultSign = RSASignature.encryptBASE64(RSASignature.sign(signContent, SXFPaySign.privateKey)); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            System.out.println("resultSign: " + resultSign); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            //组装加密串 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            if (RSASignature.doCheck(resultStr, signResult, SXFPaySign.sxfPublic)) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                System.out.println("===================验签成功=============="); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                resultData= ResultData.success(result); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                // 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                if(result.containsKey("reqData")){ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    //判断 bizCode bizCode =="0000" 则业务成功 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        return gson.toJson(resultData); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    /** 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+     * 异步回调通知 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+     */ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    @RequestMapping(value = "/tradeRefund", consumes = "application/json", method = RequestMethod.POST) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    @ResponseBody 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    @Transactional 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    public JSONObject tradeRefund(@RequestBody JSONObject request) throws ParseException { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        logger.info("-------------------------------回调开始----------------------------------------------"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        logger.info("回调返回过来的参数" + request); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        JSONObject req = new JSONObject(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        req.put("code","success"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        req.put("msg","成功"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        return req; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     @RequestMapping(value = "/demoFenZhang", consumes = "application/json", method = RequestMethod.POST) 
														 | 
														
														 | 
														
															     @RequestMapping(value = "/demoFenZhang", consumes = "application/json", method = RequestMethod.POST) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     public String demoFenZhang(@RequestBody PayInfoRequest payInfoRequest) throws Exception { 
														 | 
														
														 | 
														
															     public String demoFenZhang(@RequestBody PayInfoRequest payInfoRequest) throws Exception { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         String ss =""; 
														 | 
														
														 | 
														
															         String ss =""; 
														 |