|
@@ -2,9 +2,7 @@ package com.jpsoft.epay.modules.pay.alipay;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
-import cn.hutool.core.util.StrUtil;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
-import com.alipay.api.AlipayApiException;
|
|
|
|
import com.alipay.api.AlipayClient;
|
|
import com.alipay.api.AlipayClient;
|
|
import com.alipay.api.DefaultAlipayClient;
|
|
import com.alipay.api.DefaultAlipayClient;
|
|
import com.alipay.api.internal.util.AlipaySignature;
|
|
import com.alipay.api.internal.util.AlipaySignature;
|
|
@@ -13,7 +11,6 @@ import com.alipay.api.response.AlipayTradePrecreateResponse;
|
|
import com.ijpay.alipay.AliPayApi;
|
|
import com.ijpay.alipay.AliPayApi;
|
|
import com.jpsoft.epay.modules.base.entity.RechargeRecord;
|
|
import com.jpsoft.epay.modules.base.entity.RechargeRecord;
|
|
import com.jpsoft.epay.modules.base.service.RechargeRecordService;
|
|
import com.jpsoft.epay.modules.base.service.RechargeRecordService;
|
|
-import com.jpsoft.epay.modules.business.controller.DemoController;
|
|
|
|
import com.jpsoft.epay.modules.business.service.RechargeService;
|
|
import com.jpsoft.epay.modules.business.service.RechargeService;
|
|
import com.jpsoft.epay.modules.common.dto.MessageResult;
|
|
import com.jpsoft.epay.modules.common.dto.MessageResult;
|
|
import com.jpsoft.epay.modules.communication.server.protocol.MeterReceivePacket;
|
|
import com.jpsoft.epay.modules.communication.server.protocol.MeterReceivePacket;
|
|
@@ -45,7 +42,6 @@ public class AlipayController {
|
|
|
|
|
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
|
|
-
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private AliPayProperties aliPayProperties;
|
|
private AliPayProperties aliPayProperties;
|
|
|
|
|
|
@@ -55,20 +51,18 @@ public class AlipayController {
|
|
@Autowired
|
|
@Autowired
|
|
private RechargeService rechargeService;
|
|
private RechargeService rechargeService;
|
|
|
|
|
|
-
|
|
|
|
@ApiOperation(value = "支付宝扫码支付")
|
|
@ApiOperation(value = "支付宝扫码支付")
|
|
@GetMapping("/tradePrecreatePay")
|
|
@GetMapping("/tradePrecreatePay")
|
|
- public MessageResult tradePrecreatePay(@RequestParam("rechargeRecordId") String rechargeRecordId) {
|
|
|
|
|
|
+ public MessageResult tradePrecreatePay(String recordId) {
|
|
|
|
|
|
MessageResult result = new MessageResult();
|
|
MessageResult result = new MessageResult();
|
|
- try {
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
+ try {
|
|
AlipayClient alipayClient = new DefaultAlipayClient(aliPayProperties.getServiceUrl(), aliPayProperties.getAppId(), aliPayProperties.getPrivateKey(), "json", aliPayProperties.getInputCharset(), aliPayProperties.getZfbPublicKey(), aliPayProperties.getSignType());
|
|
AlipayClient alipayClient = new DefaultAlipayClient(aliPayProperties.getServiceUrl(), aliPayProperties.getAppId(), aliPayProperties.getPrivateKey(), "json", aliPayProperties.getInputCharset(), aliPayProperties.getZfbPublicKey(), aliPayProperties.getSignType());
|
|
AlipayTradePrecreateRequest request = new AlipayTradePrecreateRequest();
|
|
AlipayTradePrecreateRequest request = new AlipayTradePrecreateRequest();
|
|
request.setNotifyUrl(aliPayProperties.getNotifyUrl());
|
|
request.setNotifyUrl(aliPayProperties.getNotifyUrl());
|
|
|
|
|
|
- RechargeRecord rechargeRecord = rechargeRecordService.get(rechargeRecordId);
|
|
|
|
|
|
+ RechargeRecord rechargeRecord = rechargeRecordService.get(recordId);
|
|
|
|
|
|
if (rechargeRecord == null) {
|
|
if (rechargeRecord == null) {
|
|
throw new Exception("订单不存在");
|
|
throw new Exception("订单不存在");
|
|
@@ -93,7 +87,6 @@ public class AlipayController {
|
|
maps.put("extend_params", extendParams);
|
|
maps.put("extend_params", extendParams);
|
|
request.putOtherTextParam("app_auth_token", aliPayProperties.getAppAuthToken());*/
|
|
request.putOtherTextParam("app_auth_token", aliPayProperties.getAppAuthToken());*/
|
|
//把订单信息转换为json对象的字符串
|
|
//把订单信息转换为json对象的字符串
|
|
-
|
|
|
|
String postdata = JSONObject.toJSONString(maps);
|
|
String postdata = JSONObject.toJSONString(maps);
|
|
request.setBizContent(postdata);
|
|
request.setBizContent(postdata);
|
|
AlipayTradePrecreateResponse response = alipayClient.execute(request);
|
|
AlipayTradePrecreateResponse response = alipayClient.execute(request);
|
|
@@ -101,11 +94,15 @@ public class AlipayController {
|
|
JSONObject jsonObject = JSONObject.parseObject(body);
|
|
JSONObject jsonObject = JSONObject.parseObject(body);
|
|
String alipayTradePrecreateResponse = jsonObject.getString("alipay_trade_precreate_response");
|
|
String alipayTradePrecreateResponse = jsonObject.getString("alipay_trade_precreate_response");
|
|
JSONObject jsonResponse = JSONObject.parseObject(alipayTradePrecreateResponse);
|
|
JSONObject jsonResponse = JSONObject.parseObject(alipayTradePrecreateResponse);
|
|
|
|
+
|
|
if (!jsonResponse.getString("code").equals("10000")) {
|
|
if (!jsonResponse.getString("code").equals("10000")) {
|
|
throw new Exception(jsonResponse.getString("sub_msg"));
|
|
throw new Exception(jsonResponse.getString("sub_msg"));
|
|
}
|
|
}
|
|
|
|
+
|
|
String qr_code = jsonObject.getJSONObject("alipay_trade_precreate_response").getString("qr_code");
|
|
String qr_code = jsonObject.getJSONObject("alipay_trade_precreate_response").getString("qr_code");
|
|
result.setResult(true);
|
|
result.setResult(true);
|
|
|
|
+
|
|
|
|
+ log.warn("qr_code=" + qr_code);
|
|
result.setData(qr_code);
|
|
result.setData(qr_code);
|
|
|
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -118,9 +115,8 @@ public class AlipayController {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- @RequestMapping("/payNotify")
|
|
|
|
- @ResponseBody
|
|
|
|
- public String notifyUrl(HttpServletRequest request) {
|
|
|
|
|
|
+ @RequestMapping(value="/payNotify")
|
|
|
|
+ public String payNotify(HttpServletRequest request) {
|
|
try {
|
|
try {
|
|
// 获取支付宝POST过来反馈信息
|
|
// 获取支付宝POST过来反馈信息
|
|
Map<String, String> params = AliPayApi.toMap(request);
|
|
Map<String, String> params = AliPayApi.toMap(request);
|