|
@@ -4,7 +4,9 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.google.gson.Gson;
|
|
|
import com.platform.yijia.config.YiJiaRequest;
|
|
|
import com.platform.yijia.param.request.PayInfoRequest;
|
|
|
+import com.platform.yijia.pojo.PayOrder;
|
|
|
import com.platform.yijia.service.*;
|
|
|
+import com.platform.yijia.utils.CodeMsg;
|
|
|
import com.platform.yijia.utils.ResultData;
|
|
|
import com.platform.yijia.utils.weixinapp.WxPushUtil;
|
|
|
import com.saobei.open.sdk.DefaultSaobeiApiClient;
|
|
@@ -26,6 +28,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.Date;
|
|
|
+import java.util.Map;
|
|
|
import java.util.Random;
|
|
|
|
|
|
|
|
@@ -106,35 +109,49 @@ public class SaoBeiPayController {
|
|
|
// 密钥:23570b46a955484d92038f6a18d2b9d6
|
|
|
Gson gson = new Gson();
|
|
|
ResultData resultData = null;
|
|
|
- //创建client
|
|
|
- SaobeiApiClient<SaobeiJsPayRequest, SaobeiJsPayResponse> client = new DefaultSaobeiApiClient<>("23570b46a955484d92038f6a18d2b9d6");
|
|
|
- //创建requst
|
|
|
- SaobeiJsPayRequest requst = new SaobeiJsPayRequest();
|
|
|
- requst.setPay_ver("110");
|
|
|
- requst.setPay_type("010");
|
|
|
- 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++) {
|
|
|
- result += random.nextInt(10);
|
|
|
+
|
|
|
+ //根据订单号查询订单信息
|
|
|
+ String ordNo = payInfoRequest.getOrdNo();
|
|
|
+ PayOrder payOrder=payOrderService.selectOrderInfoByOrdNo(ordNo);
|
|
|
+ if(payOrder !=null){
|
|
|
+ if(payOrder.getStatus().equals("0")){
|
|
|
+ //String stationId = payInfoRequest.getStationId();
|
|
|
+ Map<String, String> staPayChannelInfo = stationService.getStationAppIdAndAppSecret(Integer.valueOf(payInfoRequest.getStationId()));
|
|
|
+ if(staPayChannelInfo !=null && staPayChannelInfo.containsKey("merchantNo") && staPayChannelInfo.containsKey("terminalId")
|
|
|
+ && staPayChannelInfo.containsKey("yunKey") && staPayChannelInfo.containsKey("gzhAppId")){
|
|
|
+ //创建client
|
|
|
+ SaobeiApiClient<SaobeiJsPayRequest, SaobeiJsPayResponse> client = new DefaultSaobeiApiClient<>(staPayChannelInfo.get("yunKey"));
|
|
|
+ //创建requst
|
|
|
+ SaobeiJsPayRequest requst = new SaobeiJsPayRequest();
|
|
|
+ requst.setPay_ver("110");
|
|
|
+ requst.setPay_type("010");
|
|
|
+ requst.setService_id("012");
|
|
|
+ requst.setMerchant_no(staPayChannelInfo.get("merchantNo")); //商户号
|
|
|
+ requst.setTerminal_id(staPayChannelInfo.get("terminalId")); //终端号
|
|
|
+ requst.setTerminal_trace(payOrder.getOrderNo()); //订单号
|
|
|
+ requst.setTerminal_time(new SimpleDateFormat("yyyyMMddhhmmss").format(new Date()));
|
|
|
+ requst.setTotal_fee(payOrder.getAmt().toString());
|
|
|
+ requst.setSub_appid(staPayChannelInfo.get("gzhAppId"));
|
|
|
+ requst.setOpen_id(payInfoRequest.getOpenId()); //oJR5R6r4EJhaORFcPap70r_mtFZo //oRwjv4iHjSUgxNxOJOQ_60Ln7cno
|
|
|
+ String orderBody = payOrder.getOilName() + " - " +payOrder.getStationName();
|
|
|
+ requst.setOrder_body(orderBody);
|
|
|
+ String notifyUrl = "https://" + this.domainName + "/" + this.globalPrefix + "/getYunPayGzhCallback";
|
|
|
+ //logger.info("回调地址:"+ notifyUrl);
|
|
|
+ requst.setNotify_url(notifyUrl);
|
|
|
+ //发送请求
|
|
|
+ System.out.println("请求报文:"+JSON.toJSONString(requst));
|
|
|
+ SaobeiJsPayResponse response = client.execute(requst);
|
|
|
+ System.out.println("返回报文:"+JSON.toJSONString(response));
|
|
|
+ resultData = ResultData.success(response);
|
|
|
+ }else {
|
|
|
+ resultData = ResultData.error(CodeMsg.STATION_NULL_INFO);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ resultData = ResultData.error(CodeMsg.ALREADY_PAY);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ resultData = ResultData.error(CodeMsg.NO_ORDER);
|
|
|
}
|
|
|
- String ordNo_1 = System.nanoTime() + result;
|
|
|
- requst.setTerminal_trace(ordNo_1); //202003252204310000
|
|
|
- requst.setTerminal_time(new SimpleDateFormat("yyyyMMddhhmmss").format(new Date()));
|
|
|
- requst.setTotal_fee("1");
|
|
|
- requst.setSub_appid("wxc8189d3b3a7283e0");
|
|
|
- requst.setOpen_id("oJR5R6r4EJhaORFcPap70r_mtFZo"); //oJR5R6r4EJhaORFcPap70r_mtFZo //oRwjv4iHjSUgxNxOJOQ_60Ln7cno
|
|
|
- requst.setOrder_body("sdk测试");
|
|
|
- String notifyUrl = "https://" + this.domainName + "/" + this.globalPrefix + "/getYunPayGzhCallback";
|
|
|
- logger.info("回调地址:"+ notifyUrl);
|
|
|
- requst.setNotify_url(notifyUrl);
|
|
|
- //发送请求
|
|
|
- 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);
|
|
|
}
|
|
|
|
|
@@ -179,6 +196,105 @@ public class SaoBeiPayController {
|
|
|
// 密钥:23570b46a955484d92038f6a18d2b9d6
|
|
|
Gson gson = new Gson();
|
|
|
ResultData resultData = null;
|
|
|
+ //根据订单号查询订单信息
|
|
|
+ String ordNo = payInfoRequest.getOrdNo();
|
|
|
+ PayOrder payOrder=payOrderService.selectOrderInfoByOrdNo(ordNo);
|
|
|
+ if(payOrder !=null){
|
|
|
+ if(payOrder.getStatus().equals("0")) {
|
|
|
+ //String stationId = payInfoRequest.getStationId();
|
|
|
+ Map<String, String> staPayChannelInfo = stationService.getStationAppIdAndAppSecret(Integer.valueOf(payInfoRequest.getStationId()));
|
|
|
+ if(staPayChannelInfo !=null && staPayChannelInfo.containsKey("merchantNo") && staPayChannelInfo.containsKey("terminalId")
|
|
|
+ && staPayChannelInfo.containsKey("yunKey") && staPayChannelInfo.containsKey("appId")) {
|
|
|
+ //秘钥
|
|
|
+ String yunKey = staPayChannelInfo.get("yunKey"); //23570b46a955484d92038f6a18d2b9d6
|
|
|
+ DefaultSaobeiApiClient defaultSaobeiApiClient = new DefaultSaobeiApiClient(yunKey); //2ef428f4f76c414282e831baea9e4b0e
|
|
|
+ SaobeiMiniPayRequest requst = new SaobeiMiniPayRequest();
|
|
|
+ requst.setPay_ver("100");
|
|
|
+ requst.setPay_type("010");
|
|
|
+ requst.setService_id("015");
|
|
|
+ requst.setMerchant_no(staPayChannelInfo.get("merchantNo")); //商户号 845104816000034
|
|
|
+ requst.setTerminal_id(staPayChannelInfo.get("terminalId")); //终端号 18241101
|
|
|
+ requst.setTerminal_trace(payOrder.getOrderNo()); //订单号 202003252204310000 6683315853083916109905
|
|
|
+ requst.setTerminal_time(new SimpleDateFormat("yyyyMMddhhmmss").format(new Date())); //"20200325220431"
|
|
|
+
|
|
|
+ //requst.setTotal_fee(String.valueOf(payOrder.getAmt()));
|
|
|
+ Double amt = payOrder.getAmt();
|
|
|
+// String amtStr = amt + "";
|
|
|
+// requst.setTotal_fee(amtStr);
|
|
|
+// requst.setTotal_fee(amt.toString());
|
|
|
+ requst.setTotal_fee(payInfoRequest.getAmt());
|
|
|
+ String openId = payInfoRequest.getOpenId();
|
|
|
+ requst.setOpen_id(openId); // oRwjv4iHjSUgxNxOJOQ_60Ln7cno obnG9jhDLvom5fGwuhYysmQTW4qQ
|
|
|
+
|
|
|
+ //订单内容
|
|
|
+ String orderBody = payOrder.getOilName() + "-" +payOrder.getStationName();
|
|
|
+ requst.setOrder_body(orderBody);
|
|
|
+ //回调地址
|
|
|
+ String notifyUrl = "https://" + this.domainName + "/" + this.globalPrefix + "/getYunPayCallback";
|
|
|
+ logger.info("回调地址" + notifyUrl);
|
|
|
+ requst.setNotify_url(notifyUrl);
|
|
|
+ //小程序appId
|
|
|
+ requst.setSub_appid(staPayChannelInfo.get("appId")); // 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);
|
|
|
+ }else {
|
|
|
+ resultData = ResultData.error(CodeMsg.STATION_NULL_INFO);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ resultData = ResultData.error(CodeMsg.ALREADY_PAY);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ resultData = ResultData.error(CodeMsg.NO_ORDER);
|
|
|
+ }
|
|
|
+ return gson.toJson(resultData);
|
|
|
+ }
|
|
|
+
|
|
|
+ /***
|
|
|
+ * 小程序云闪付扫呗回调
|
|
|
+ * @param jsonObject
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/getYunPayCallback", consumes = "application/json", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ @Transactional
|
|
|
+ public JSONObject getYunPayCallback(@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 = {"/yunPayTest"}, consumes = {"application/json"}, method = {RequestMethod.POST})
|
|
|
+ @ResponseBody
|
|
|
+ public String yunPayTest(@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();
|
|
|
requst.setPay_ver("110");
|
|
@@ -197,14 +313,14 @@ public class SaoBeiPayController {
|
|
|
|
|
|
requst.setTerminal_time(new SimpleDateFormat("yyyyMMddhhmmss").format(new Date())); //"20200325220431"
|
|
|
String amt = payInfoRequest.getAmt();
|
|
|
- requst.setTotal_fee("1");
|
|
|
+ requst.setTotal_fee("0.01");
|
|
|
String openId = payInfoRequest.getOpenId();
|
|
|
- requst.setOpen_id("oJR5R6r4EJhaORFcPap70r_mtFZo"); // oRwjv4iHjSUgxNxOJOQ_60Ln7cno obnG9jhDLvom5fGwuhYysmQTW4qQ
|
|
|
+ requst.setOpen_id("oRwjv4iHjSUgxNxOJOQ_60Ln7cno"); // oRwjv4iHjSUgxNxOJOQ_60Ln7cno obnG9jhDLvom5fGwuhYysmQTW4qQ
|
|
|
requst.setOrder_body("sdk测试");
|
|
|
String notifyUrl = "https://" + this.domainName + "/" + this.globalPrefix + "/getYunPayCallback";
|
|
|
logger.info("回调地址"+ notifyUrl);
|
|
|
requst.setNotify_url(notifyUrl);
|
|
|
- requst.setSub_appid("wxc8189d3b3a7283e0"); // wxe1135cd390b38a54 wxe568c727d466aef9 智慧易加公众号:wxc8189d3b3a7283e0
|
|
|
+ requst.setSub_appid("wxe1135cd390b38a54"); // 智慧易加小程序: wxe1135cd390b38a54 wxe568c727d466aef9 智慧易加公众号:wxc8189d3b3a7283e0
|
|
|
System.out.println("请求报文"+ JSON.toJSONString(requst));
|
|
|
SaobeiMiniPayResponse response = (SaobeiMiniPayResponse)defaultSaobeiApiClient.execute(requst);
|
|
|
System.out.println("返回报文"+ JSON.toJSONString(response));
|
|
@@ -212,29 +328,54 @@ public class SaoBeiPayController {
|
|
|
return gson.toJson(resultData);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/***
|
|
|
- * 小程序云闪付扫呗回调
|
|
|
- * @param jsonObject
|
|
|
+ * 测试
|
|
|
+ * 公众号云闪付拉起支付
|
|
|
+ * @param payInfoRequest
|
|
|
* @return
|
|
|
+ * @throws Exception
|
|
|
*/
|
|
|
- @RequestMapping(value = "/getYunPayCallback", consumes = "application/json", method = RequestMethod.POST)
|
|
|
+ @RequestMapping(value = {"/yunPayGzhTest"}, consumes = {"application/json"}, method = {RequestMethod.POST})
|
|
|
@ResponseBody
|
|
|
- @Transactional
|
|
|
- public JSONObject getYunPayCallback(@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");
|
|
|
+ public String yunPayGzhTest(@RequestBody PayInfoRequest payInfoRequest) throws Exception {
|
|
|
+ //智慧易加
|
|
|
+// 商户号码:845104816000034
|
|
|
+// 终端号:18241101
|
|
|
+// 密钥:23570b46a955484d92038f6a18d2b9d6
|
|
|
+ Gson gson = new Gson();
|
|
|
+ ResultData resultData = null;
|
|
|
+ //创建client
|
|
|
+ SaobeiApiClient<SaobeiJsPayRequest, SaobeiJsPayResponse> client = new DefaultSaobeiApiClient<>("23570b46a955484d92038f6a18d2b9d6");
|
|
|
+ //创建requst
|
|
|
+ SaobeiJsPayRequest requst = new SaobeiJsPayRequest();
|
|
|
+ requst.setPay_ver("110");
|
|
|
+ requst.setPay_type("010");
|
|
|
+ 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++) {
|
|
|
+ result += random.nextInt(10);
|
|
|
}
|
|
|
- return result;
|
|
|
+ String ordNo_1 = System.nanoTime() + result;
|
|
|
+ requst.setTerminal_trace(ordNo_1); //202003252204310000
|
|
|
+ requst.setTerminal_time(new SimpleDateFormat("yyyyMMddhhmmss").format(new Date()));
|
|
|
+ requst.setTotal_fee("1");
|
|
|
+ requst.setSub_appid("wxc8189d3b3a7283e0");
|
|
|
+ requst.setOpen_id("oJR5R6r4EJhaORFcPap70r_mtFZo"); //oJR5R6r4EJhaORFcPap70r_mtFZo //oRwjv4iHjSUgxNxOJOQ_60Ln7cno
|
|
|
+ requst.setOrder_body("sdk测试");
|
|
|
+ String notifyUrl = "https://" + this.domainName + "/" + this.globalPrefix + "/getYunPayGzhCallback";
|
|
|
+ logger.info("回调地址:"+ notifyUrl);
|
|
|
+ requst.setNotify_url(notifyUrl);
|
|
|
+ //发送请求
|
|
|
+ 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);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
}
|