| 
					
				 | 
			
			
				@@ -10,15 +10,21 @@ import com.platform.yijia.utils.weixinapp.WxPushUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.saobei.open.sdk.DefaultSaobeiApiClient; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.saobei.open.sdk.SaobeiApiClient; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.saobei.open.sdk.model.requst.trade.SaobeiMiniPayRequest; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.saobei.open.sdk.model.requst.trade.preauth.SaobeiPreAuthMiniPayRequest; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.saobei.open.sdk.model.response.trade.SaobeiMiniPayResponse; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.saobei.open.sdk.model.response.trade.preauth.SaobeiPreAuthMiniPayResponse; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import net.sf.json.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.slf4j.Logger; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.slf4j.LoggerFactory; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.beans.factory.annotation.Value; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.stereotype.Controller; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.transaction.annotation.Transactional; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.web.bind.annotation.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import javax.annotation.Resource; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.text.SimpleDateFormat; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.Date; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.Random; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 /* 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -69,12 +75,17 @@ public class SaoBeiPayController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 //    终端号:18237172 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 //    密钥:2ef428f4f76c414282e831baea9e4b0e 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public static final String PAY_VER = "110";//版本号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public static final String KEY = "";//机构秘钥 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public static final String ACCESS_TOKEN = "2ef428f4f76c414282e831baea9e4b0e";//支付秘钥 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public static final String INST_NO = "";//机构号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public static final String MERCHANT_NO = "852105942000011";//商户号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public static final String TERMINAL_ID = "18237172";//终端号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//    商户号码:845104816000034 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//    终端号:18241101 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//    密钥:23570b46a955484d92038f6a18d2b9d6 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public static final String PAY_VER = "110";         //版本号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public static final String KEY = "";                //机构秘钥 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public static final String ACCESS_TOKEN = "23570b46a955484d92038f6a18d2b9d6";       //支付秘钥 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public static final String INST_NO = "";            //机构号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public static final String MERCHANT_NO = "845104816000034";         //商户号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public static final String TERMINAL_ID = "18241101";                //终端号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /*** 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -88,36 +99,71 @@ public class SaoBeiPayController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public String payAmtInfo(@RequestBody PayInfoRequest payInfoRequest) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Gson gson =new Gson(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         ResultData resultData =null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //创建client 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        SaobeiApiClient<SaobeiMiniPayRequest, SaobeiMiniPayResponse> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        SaobeiApiClient<SaobeiPreAuthMiniPayRequest, SaobeiPreAuthMiniPayResponse> client = new DefaultSaobeiApiClient<>(ACCESS_TOKEN); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //创建requst 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        SaobeiMiniPayRequest requst = new SaobeiMiniPayRequest(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        SaobeiPreAuthMiniPayRequest requst = new SaobeiPreAuthMiniPayRequest(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         requst.setPay_ver(PAY_VER); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         requst.setPay_type("010"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         requst.setService_id("015"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         requst.setMerchant_no(MERCHANT_NO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         requst.setTerminal_id(TERMINAL_ID); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        requst.setTerminal_trace("202003252204310000");         //终端流水号,填写商户系统的订单号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        requst.setTerminal_time("20200325220431");              //交易时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Random random = new Random(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String result = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (int i = 0; i < 6; i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            result += random.nextInt(10); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String ordNo_1 = System.nanoTime() + result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //202003252204310000 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        requst.setTerminal_trace(ordNo_1);         //终端流水号,填写商户系统的订单号 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        requst.setTerminal_time(new SimpleDateFormat("yyyyMMddhhmmss").format(new Date()));      //交易时间 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         String amt = payInfoRequest.getAmt(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        requst.setTotal_fee("1");                               //订单金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        requst.setTotal_fee("0.01");                                                                    //订单金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         String openId = payInfoRequest.getOpenId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        requst.setOpen_id("obnG9jhDLvom5fGwuhYysmQTW4qQ");       //微信用户openId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //oRwjv4iHjSUgxNxOJOQ_60Ln7cno  obnG9jhDLvom5fGwuhYysmQTW4qQ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        requst.setOpen_id("oRwjv4iHjSUgxNxOJOQ_60Ln7cno");                                              //微信用户openId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         requst.setOrder_body("sdk测试"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         String notifyUrl = "https://"+domainName+"/"+globalPrefix+"/getSaobeiCallback"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         logger.info("扫呗调用回调地址:" + notifyUrl); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         requst.setNotify_url(notifyUrl); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        requst.setSub_appid("wxe568c727d466aef9"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //wxe568c727d466aef9 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //wxe1135cd390b38a54 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        requst.setSub_appid("wxe1135cd390b38a54"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //发送请求 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        System.out.println("小程序预支付请求报文:"+JSON.toJSONString(requst)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        SaobeiPreAuthMiniPayResponse response = client.execute(requst); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        System.out.println("小程序预支付权返回报文:"+JSON.toJSONString(response)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        System.out.println("========================================================================================="); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //创建client 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        SaobeiApiClient<SaobeiMiniPayRequest, SaobeiMiniPayResponse> clientMiniPay = new DefaultSaobeiApiClient<>(ACCESS_TOKEN); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //创建requst 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        SaobeiMiniPayRequest requstMiniPay = new SaobeiMiniPayRequest(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        requstMiniPay.setPay_ver(PAY_VER); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        requstMiniPay.setPay_type("010");                      //010 微信  020 支付宝 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        requstMiniPay.setService_id("015");                    //接口类型 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        requstMiniPay.setMerchant_no(response.getMerchant_no()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        requstMiniPay.setTerminal_id(response.getTerminal_id()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        requstMiniPay.setTerminal_trace(response.getTerminal_trace()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        requstMiniPay.setTerminal_time(response.getTerminal_time()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        requstMiniPay.setTotal_fee(response.getTotal_fee()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //requstMiniPay.setOpen_id(response.getOp); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //requstMiniPay.setOrder_body(response.get); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        requstMiniPay.setNotify_url(response.getFront_notify_url()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        requstMiniPay.setSub_appid(response.getAppId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //发送请求 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        System.out.println("请求报文:"+ JSON.toJSONString(requst)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        SaobeiMiniPayResponse response = client.execute(requst); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        System.out.println("返回报文:"+JSON.toJSONString(response)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        resultData = ResultData.success(response); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return gson.toJson(resultData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        System.out.println("请求报文:"+ JSON.toJSONString(requstMiniPay)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        SaobeiMiniPayResponse responseMiniPay = clientMiniPay.execute(requstMiniPay); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        System.out.println("返回报文:"+JSON.toJSONString(responseMiniPay)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        resultData = ResultData.success(responseMiniPay); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return gson.toJson(responseMiniPay); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /*** 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -127,9 +173,21 @@ public class SaoBeiPayController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @RequestMapping(value = "/getSaobeiCallback", consumes = "application/json", method = RequestMethod.POST) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @ResponseBody 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Transactional 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public JSONObject getSaobeiCallback(@RequestBody JSONObject jsonObject){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        JSONObject result = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        result.put("code", "success"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        JSONObject result = new JSONObject();       //返回给扫呗状态码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        System.out.println("扫呗调用回调接口返回参数:" + jsonObject); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(jsonObject.containsKey("result_code") && jsonObject.get("result_code").toString().equals("01")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //业务逻辑 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //返给扫呗状态码 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            result.put("return_code", "01"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            result.put("return_msg", "success"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            result.put("return_code", "02"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            result.put("return_msg", "fail"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 |