|
@@ -9,8 +9,10 @@ import com.platform.yijia.utils.ResultData;
|
|
|
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.SaobeiJsPayRequest;
|
|
|
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.SaobeiJsPayResponse;
|
|
|
import com.saobei.open.sdk.model.response.trade.SaobeiMiniPayResponse;
|
|
|
import com.saobei.open.sdk.model.response.trade.preauth.SaobeiPreAuthMiniPayResponse;
|
|
|
import net.sf.json.JSONObject;
|
|
@@ -89,24 +91,30 @@ public class SaoBeiPayController {
|
|
|
public static final String TERMINAL_ID = "18237172"; //终端号
|
|
|
|
|
|
|
|
|
- @RequestMapping(value = {"/payAmtInfoOld"}, consumes = {"application/json"}, method = {RequestMethod.POST})
|
|
|
+ /***
|
|
|
+ * 公众号云闪付拉起支付
|
|
|
+ * @param payInfoRequest
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @RequestMapping(value = {"/payAmtInfoGzhOld"}, consumes = {"application/json"}, method = {RequestMethod.POST})
|
|
|
@ResponseBody
|
|
|
- public String payAmtInfoOld(@RequestBody PayInfoRequest payInfoRequest) throws Exception {
|
|
|
-
|
|
|
+ public String payAmtInfoGzh(@RequestBody PayInfoRequest payInfoRequest) throws Exception {
|
|
|
//智慧易加
|
|
|
// 商户号码:845104816000034
|
|
|
// 终端号:18241101
|
|
|
// 密钥:23570b46a955484d92038f6a18d2b9d6
|
|
|
Gson gson = new Gson();
|
|
|
ResultData resultData = null;
|
|
|
- DefaultSaobeiApiClient defaultSaobeiApiClient = new DefaultSaobeiApiClient("23570b46a955484d92038f6a18d2b9d6"); //2ef428f4f76c414282e831baea9e4b0e
|
|
|
- SaobeiMiniPayRequest requst = new SaobeiMiniPayRequest();
|
|
|
+ //创建client
|
|
|
+ SaobeiApiClient<SaobeiJsPayRequest, SaobeiJsPayResponse> client = new DefaultSaobeiApiClient<>("23570b46a955484d92038f6a18d2b9d6");
|
|
|
+ //创建requst
|
|
|
+ SaobeiJsPayRequest requst = new SaobeiJsPayRequest();
|
|
|
requst.setPay_ver("110");
|
|
|
requst.setPay_type("010");
|
|
|
- requst.setService_id("015");
|
|
|
- requst.setMerchant_no("845104816000034"); //852105942000011
|
|
|
- requst.setTerminal_id("18241101"); //18237172
|
|
|
-
|
|
|
+ requst.setService_id("012");
|
|
|
+ requst.setMerchant_no("845104816000034");
|
|
|
+ requst.setTerminal_id("18241101");
|
|
|
Random random = new Random();
|
|
|
String result = "";
|
|
|
for (int i = 0; i < 6; i++) {
|
|
@@ -114,110 +122,98 @@ public class SaoBeiPayController {
|
|
|
}
|
|
|
String ordNo_1 = System.nanoTime() + result;
|
|
|
requst.setTerminal_trace(ordNo_1); //202003252204310000
|
|
|
-
|
|
|
- requst.setTerminal_time(new SimpleDateFormat("yyyyMMddhhmmss").format(new Date())); //"20200325220431"
|
|
|
- String amt = payInfoRequest.getAmt();
|
|
|
+ requst.setTerminal_time(new SimpleDateFormat("yyyyMMddhhmmss").format(new Date()));
|
|
|
requst.setTotal_fee("1");
|
|
|
- String openId = payInfoRequest.getOpenId();
|
|
|
- requst.setOpen_id("oRwjv4iHjSUgxNxOJOQ_60Ln7cno"); // oRwjv4iHjSUgxNxOJOQ_60Ln7cno obnG9jhDLvom5fGwuhYysmQTW4qQ
|
|
|
+ requst.setSub_appid("wxc8189d3b3a7283e0");
|
|
|
+ requst.setOpen_id("oJR5R6r4EJhaORFcPap70r_mtFZo"); //oJR5R6r4EJhaORFcPap70r_mtFZo //oRwjv4iHjSUgxNxOJOQ_60Ln7cno
|
|
|
requst.setOrder_body("sdk测试");
|
|
|
- String notifyUrl = "https://" + this.domainName + "/" + this.globalPrefix + "/getSaobeiCallback";
|
|
|
- logger.info("回调地址"+ notifyUrl);
|
|
|
+ String notifyUrl = "https://" + this.domainName + "/" + this.globalPrefix + "/getSaobeiGzhCallback";
|
|
|
+ logger.info("回调地址:"+ notifyUrl);
|
|
|
requst.setNotify_url(notifyUrl);
|
|
|
- requst.setSub_appid("wxe1135cd390b38a54"); // wxe1135cd390b38a54 wxe568c727d466aef9
|
|
|
- System.out.println("请求报文"+ JSON.toJSONString(requst));
|
|
|
- SaobeiMiniPayResponse response = (SaobeiMiniPayResponse)defaultSaobeiApiClient.execute(requst);
|
|
|
- System.out.println("返回报文"+ JSON.toJSONString(response));
|
|
|
+ //发送请求
|
|
|
+ System.out.println("请求报文:"+JSON.toJSONString(requst));
|
|
|
+ SaobeiJsPayResponse response = client.execute(requst);
|
|
|
+ System.out.println("返回报文:"+JSON.toJSONString(response));
|
|
|
resultData = ResultData.success(response);
|
|
|
return gson.toJson(resultData);
|
|
|
}
|
|
|
|
|
|
/***
|
|
|
- * 支付接口,前台上传支付信息,支付数据落地生产订单,调用第三方扫呗支付
|
|
|
- * 小程序支付接口
|
|
|
+ * 公众号扫呗支付回调
|
|
|
+ * @param jsonObject
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/getSaobeiGzhCallback", consumes = "application/json", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ @Transactional
|
|
|
+ public JSONObject getSaobeiGzhCallback(@RequestBody JSONObject jsonObject){
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
+ /***
|
|
|
+ * 小程序云闪付拉起支付
|
|
|
* @param payInfoRequest
|
|
|
* @return
|
|
|
+ * @throws Exception
|
|
|
*/
|
|
|
- @RequestMapping(value = "/payAmtInfo", consumes = "application/json", method = RequestMethod.POST)
|
|
|
+ @RequestMapping(value = {"/payAmtInfoOld"}, consumes = {"application/json"}, method = {RequestMethod.POST})
|
|
|
@ResponseBody
|
|
|
public String payAmtInfo(@RequestBody PayInfoRequest payInfoRequest) throws Exception {
|
|
|
- Gson gson =new Gson();
|
|
|
- ResultData resultData =null;
|
|
|
|
|
|
//智慧易加
|
|
|
// 商户号码:845104816000034
|
|
|
// 终端号:18241101
|
|
|
// 密钥:23570b46a955484d92038f6a18d2b9d6
|
|
|
- //创建client
|
|
|
- SaobeiApiClient<SaobeiPreAuthMiniPayRequest, SaobeiPreAuthMiniPayResponse> client = new DefaultSaobeiApiClient<>("23570b46a955484d92038f6a18d2b9d6");
|
|
|
- //创建requst
|
|
|
- SaobeiPreAuthMiniPayRequest requst = new SaobeiPreAuthMiniPayRequest();
|
|
|
+ Gson gson = new Gson();
|
|
|
+ ResultData resultData = null;
|
|
|
+ DefaultSaobeiApiClient defaultSaobeiApiClient = new DefaultSaobeiApiClient("23570b46a955484d92038f6a18d2b9d6"); //2ef428f4f76c414282e831baea9e4b0e
|
|
|
+ SaobeiMiniPayRequest requst = new SaobeiMiniPayRequest();
|
|
|
requst.setPay_ver("110");
|
|
|
requst.setPay_type("010");
|
|
|
requst.setService_id("015");
|
|
|
- requst.setMerchant_no("845104816000034");
|
|
|
- requst.setTerminal_id("18241101");
|
|
|
+ requst.setMerchant_no("845104816000034"); //852105942000011
|
|
|
+ requst.setTerminal_id("18241101"); //18237172
|
|
|
+
|
|
|
Random random = new Random();
|
|
|
String result = "";
|
|
|
for (int i = 0; i < 6; i++) {
|
|
|
result += random.nextInt(10);
|
|
|
}
|
|
|
String ordNo_1 = System.nanoTime() + result;
|
|
|
+ requst.setTerminal_trace(ordNo_1); //202003252204310000
|
|
|
|
|
|
- //202003252204310000
|
|
|
- requst.setTerminal_trace(ordNo_1); //终端流水号,填写商户系统的订单号
|
|
|
- // new SimpleDateFormat("yyyyMMddhhmmss").format(new Date())
|
|
|
- requst.setTerminal_time(new SimpleDateFormat("yyyyMMddhhmmss").format(new Date())); //交易时间
|
|
|
+ requst.setTerminal_time(new SimpleDateFormat("yyyyMMddhhmmss").format(new Date())); //"20200325220431"
|
|
|
String amt = payInfoRequest.getAmt();
|
|
|
- requst.setTotal_fee("0.01"); //订单金额
|
|
|
+ requst.setTotal_fee("1");
|
|
|
String openId = payInfoRequest.getOpenId();
|
|
|
-
|
|
|
- //oRwjv4iHjSUgxNxOJOQ_60Ln7cno obnG9jhDLvom5fGwuhYysmQTW4qQ
|
|
|
- requst.setOpen_id("oRwjv4iHjSUgxNxOJOQ_60Ln7cno"); //微信用户openId
|
|
|
+ requst.setOpen_id("oJR5R6r4EJhaORFcPap70r_mtFZo"); // oRwjv4iHjSUgxNxOJOQ_60Ln7cno obnG9jhDLvom5fGwuhYysmQTW4qQ
|
|
|
requst.setOrder_body("sdk测试");
|
|
|
-
|
|
|
- String notifyUrl = "https://"+domainName+"/"+globalPrefix+"/getSaobeiCallback";
|
|
|
- logger.info("扫呗调用回调地址:" + notifyUrl);
|
|
|
+ String notifyUrl = "https://" + this.domainName + "/" + this.globalPrefix + "/getSaobeiCallback";
|
|
|
+ logger.info("回调地址"+ notifyUrl);
|
|
|
requst.setNotify_url(notifyUrl);
|
|
|
-
|
|
|
- //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(requstMiniPay));
|
|
|
- SaobeiMiniPayResponse responseMiniPay = clientMiniPay.execute(requstMiniPay);
|
|
|
- System.out.println("返回报文:"+JSON.toJSONString(responseMiniPay));
|
|
|
- resultData = ResultData.success(responseMiniPay);
|
|
|
+ requst.setSub_appid("wxc8189d3b3a7283e0"); // wxe1135cd390b38a54 wxe568c727d466aef9 智慧易加公众号:wxc8189d3b3a7283e0
|
|
|
+ System.out.println("请求报文"+ JSON.toJSONString(requst));
|
|
|
+ SaobeiMiniPayResponse response = (SaobeiMiniPayResponse)defaultSaobeiApiClient.execute(requst);
|
|
|
+ System.out.println("返回报文"+ JSON.toJSONString(response));
|
|
|
+ resultData = ResultData.success(response);
|
|
|
return gson.toJson(resultData);
|
|
|
}
|
|
|
|
|
|
/***
|
|
|
- * 扫呗回调
|
|
|
+ * 小程序云闪付扫呗回调
|
|
|
* @param jsonObject
|
|
|
* @return
|
|
|
*/
|