Parcourir la source

修改支付宝

杨杰 il y a 1 an
Parent
commit
be0c14bc8b

+ 2 - 2
pom.xml

@@ -39,9 +39,9 @@
 		<dependency><!-- 支付宝 -->
 			<groupId>com.alipay.sdk</groupId>
 			<artifactId>alipay-sdk-java</artifactId>
-			<version>3.1.0</version>
+			<version>4.34.0.ALL</version>
 		</dependency>
-		<dependency><!-- 微信支付 -->
+		<dependency><!-- 微信支付 V3-->
 		  <groupId>com.github.wechatpay-apiv3</groupId>
 		  <artifactId>wechatpay-java</artifactId>
 		  <version>0.2.12</version>

+ 77 - 0
src/main/java/com/llisoft/pay/controller/AliPayController.java

@@ -0,0 +1,77 @@
+package com.llisoft.pay.controller;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import com.llisoft.pay.service.PayAliService;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+@Api(tags="支付宝回调")
+@Controller
+@RequestMapping("/alipay")
+@Deprecated
+public class AliPayController {
+	
+	private Logger logger = LoggerFactory.getLogger(AliPayController.class);
+	
+	@Autowired
+	private PayAliService aliPayService;
+	
+	
+	@ApiOperation(value="同步回调")
+	@GetMapping("/return")
+	public String returns(HttpServletRequest request) throws Exception {
+		Map<String, String> resultMap = this.getParamMap(request);
+		logger.debug("收到支付宝同步回调: {}", resultMap);
+		return "redirect:" + aliPayService.doReturn(resultMap);
+	}
+	
+	@ApiOperation(value="异步通知")
+	@PostMapping(value="/notify")
+	public @ResponseBody String notify(HttpServletRequest request) throws Exception {
+		Map<String, String> resultMap = this.getParamMap(request);
+		logger.debug("收到支付宝异步通知: {}", resultMap);
+		try {
+			if (aliPayService.doNotify(resultMap)) {
+				logger.debug("支付宝异步通知处理成功!");
+				return "success";
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		logger.error("支付宝异步通知处理失败!");
+		return null;
+	}
+	
+	
+	/**
+	 * 获取参数Map<String, String>
+	 * @param request
+	 * @return
+	 */
+	private Map<String, String> getParamMap(HttpServletRequest request){
+		Map<String, String> returnMap = new HashMap<String, String>();
+		Map<String, String[]> paramMap = request.getParameterMap();
+		for (String key: paramMap.keySet()) {
+			String[] values = paramMap.get(key);
+			if (values!=null && values.length>0) {
+				returnMap.put(key, values[0]);
+			}
+		}
+		return returnMap;
+	}
+
+}

+ 13 - 7
src/main/java/com/llisoft/pay/controller/ApiController.java

@@ -31,23 +31,29 @@ public class ApiController{
 	
 	
 	@ApiOperation(value="青题库 微信支付 APP")
-	@PostMapping("/qingtiku/wxpay/info")
-	public ApiInfoResponseVo qingtikuWxpayInfo(@Valid @RequestBody ApiInfoRequestVo requestVo) throws Exception{
-		return apiService.wxInfoQinggu(requestVo.getPid());
-	}
-	
-	@ApiOperation(value="青题库 微信支付 APP")
 	@PostMapping("/qingtiku/wxpay/app")
 	public ApiPayWxAppResponseVo qingtikuWxpayApp(@Valid @RequestBody ApiPayRequestVo requestVo) throws Exception{
 		String appid = "wxfb2da083f9dfe038";
 		return apiService.wxAppQinggu(appid, requestVo.getMoney(), requestVo.getTitle());
 	}
 	
+	@ApiOperation(value="青题库 微信支付详情")
+	@PostMapping("/qingtiku/wxpay/info")
+	public ApiInfoResponseVo qingtikuWxpayInfo(@Valid @RequestBody ApiInfoRequestVo requestVo) throws Exception{
+		return apiService.wxInfoQinggu(requestVo.getPid());
+	}
+	
 	
 	@ApiOperation(value="青题库 支付宝 APP")
 	@PostMapping("/qingtiku/alipay/app")
 	public ApiPayAliAppResponseVo qingtikuAlipayApp(@Valid @RequestBody ApiPayRequestVo requestVo) throws Exception{
-		return null;
+		return apiService.aliAppQinggu(requestVo.getMoney(), requestVo.getTitle());
+	}
+	
+	@ApiOperation(value="青题库 支付宝详情")
+	@PostMapping("/qingtiku/alipay/info")
+	public ApiInfoResponseVo qingtikuAlipayInfo(@Valid @RequestBody ApiInfoRequestVo requestVo) throws Exception{
+		return apiService.aliInfoDongke(requestVo.getPid());
 	}
 	
 }

+ 13 - 29
src/main/java/com/llisoft/pay/controller/CallbackAliPayController.java

@@ -8,52 +8,35 @@ import javax.servlet.http.HttpServletRequest;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.ResponseBody;
 
-import com.llisoft.pay.service.PayAliService;
+import com.llisoft.pay.service.ApiService;
 
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 
 @Api(tags="支付宝回调")
 @Controller
-//@RequestMapping("/callback/alipay")
-@RequestMapping("/alipay") // 兼容旧旧接口,找机会替换成上面路径
+@RequestMapping("/callback/alipay")
 public class CallbackAliPayController {
 	
 	private Logger logger = LoggerFactory.getLogger(CallbackAliPayController.class);
-	
+
 	@Autowired
-	private PayAliService aliPayService;
+	private ApiService apiService;
 	
 	
-	@ApiOperation(value="同步回调")
-	@GetMapping("/return")
-	public String returns(HttpServletRequest request) throws Exception {
-		Map<String, String> resultMap = this.getParamMap(request);
-		logger.debug("收到支付宝同步回调: {}", resultMap);
-		return "redirect:" + aliPayService.doReturn(resultMap);
-	}
-	
-	@ApiOperation(value="异步通知")
-	@PostMapping(value="/notify")
-	public @ResponseBody String notify(HttpServletRequest request) throws Exception {
-		Map<String, String> resultMap = this.getParamMap(request);
-		logger.debug("收到支付宝异步通知: {}", resultMap);
-		try {
-			if (aliPayService.doNotify(resultMap)) {
-				logger.debug("支付宝异步通知处理成功!");
-				return "success";
-			}
-		} catch (Exception e) {
-			e.printStackTrace();
+	@ApiOperation("异步通知")
+	@PostMapping("/notify/{pid}")
+	public ResponseEntity<String> notify(@PathVariable String pid, HttpServletRequest request) throws Exception {
+		if(apiService.aliNotify(pid, this.getParamMap(request))) {
+			return ResponseEntity.ok().build();
 		}
-		logger.error("支付宝异步通知处理失败!");
-		return null;
+		return ResponseEntity.badRequest().build();
 	}
 	
 	
@@ -71,6 +54,7 @@ public class CallbackAliPayController {
 				returnMap.put(key, values[0]);
 			}
 		}
+		logger.debug("收到支付宝异步通知: {}", returnMap);
 		return returnMap;
 	}
 

+ 4 - 4
src/main/java/com/llisoft/pay/controller/CallbackWxPayController.java

@@ -32,8 +32,8 @@ public class CallbackWxPayController {
 	private ApiService apiService;
 	
 	
-	@ApiOperation(value="异步通知 栋科")
-	@PostMapping(value="/dongke/{pid}")
+	@ApiOperation("异步通知 栋科")
+	@PostMapping("/dongke/{pid}")
 	public ResponseEntity<String> dongke(@PathVariable String pid, HttpServletRequest request) throws Exception {
 		if(apiService.wxNotifyDongke(pid, this.notify(request))) {
 			return ResponseEntity.ok().build();
@@ -41,8 +41,8 @@ public class CallbackWxPayController {
 		return ResponseEntity.badRequest().build();
 	}
 	
-	@ApiOperation(value="异步通知 青谷")
-	@PostMapping(value="/qinggu/{pid}")
+	@ApiOperation("异步通知 青谷")
+	@PostMapping("/qinggu/{pid}")
 	public ResponseEntity<String> qinggu(@PathVariable String pid, HttpServletRequest request) throws Exception {
 		if(apiService.wxNotifyQinggu(pid, this.notify(request))) {
 			return ResponseEntity.ok().build();

+ 88 - 5
src/main/java/com/llisoft/pay/service/ApiService.java

@@ -1,5 +1,6 @@
 package com.llisoft.pay.service;
 
+import java.util.Map;
 import java.util.Objects;
 
 import org.slf4j.Logger;
@@ -14,6 +15,7 @@ import com.llisoft.pay.entity.Pay;
 import com.llisoft.pay.util.CodeUtil;
 import com.llisoft.pay.util.JsonUtil;
 import com.llisoft.pay.vo.ApiInfoResponseVo;
+import com.llisoft.pay.vo.ApiPayAliAppResponseVo;
 import com.llisoft.pay.vo.ApiPayWxAppResponseVo;
 import com.wechat.pay.java.core.notification.RequestParam;
 
@@ -27,6 +29,8 @@ public class ApiService {
 	private PayDao payDao;
 	@Autowired
 	private PayWxV3Service payWxV3Service;
+	@Autowired
+	private PayAliNewService payAliNewService;
 
 	
 	/**
@@ -35,7 +39,7 @@ public class ApiService {
 	 * @throws Exception 
 	 */
 	public ApiPayWxAppResponseVo wxAppDongke(String appid, int money, String title) throws Exception {
-		Pay pay = this.add(appid, money, title);
+		Pay pay = this.add(money, title);
 		logger.debug("添加支付记录:{}", JsonUtil.toJson(pay));
 		return payWxV3Service.appDongke(appid, pay.getPid(), money, title);
 	}
@@ -46,7 +50,8 @@ public class ApiService {
 	 * @throws Exception 
 	 */
 	public ApiPayWxAppResponseVo wxAppQinggu(String appid, int money, String title) throws Exception {
-		Pay pay = this.add(appid, money, title);
+		Pay pay = this.add(money, title);
+		logger.debug("添加支付记录:{}", JsonUtil.toJson(pay));
 		return payWxV3Service.appQinggu(appid, pay.getPid(), money, title);
 	}
 	
@@ -64,7 +69,7 @@ public class ApiService {
 				payed = true;
 			}
 		}
-		return ApiInfoResponseVo.Build(pid, payed);
+		return ApiInfoResponseVo.build(pid, payed);
 	}
 	
 	/**
@@ -80,7 +85,7 @@ public class ApiService {
 				payed = true;
 			}
 		}
-		return ApiInfoResponseVo.Build(pid, payed);
+		return ApiInfoResponseVo.build(pid, payed);
 	}
 	
 	/**
@@ -110,6 +115,84 @@ public class ApiService {
 		}
 		return false;
 	}
+
+	
+	/**
+	 * 支付宝 APP 栋科
+	 * @return
+	 * @throws Exception 
+	 */
+	public ApiPayAliAppResponseVo aliAppDongke(int money, String title) throws Exception {
+		Pay pay = this.add(money, title);
+		logger.debug("添加支付记录:{}", JsonUtil.toJson(pay));
+		String text = payAliNewService.appDongke(pay.getPid(), money, title);
+		ApiPayAliAppResponseVo responseVo = new ApiPayAliAppResponseVo();
+		responseVo.setPid(pay.getPid());
+		responseVo.setText(text);
+		return responseVo;
+	}
+	
+	/**
+	 * 支付宝 APP 青谷
+	 * @return
+	 * @throws Exception 
+	 */
+	public ApiPayAliAppResponseVo aliAppQinggu(int money, String title) throws Exception {
+		Pay pay = this.add(money, title);
+		logger.debug("添加支付记录:{}", JsonUtil.toJson(pay));
+		String text = payAliNewService.appQinggu( pay.getPid(), money, title);
+		ApiPayAliAppResponseVo responseVo = new ApiPayAliAppResponseVo();
+		responseVo.setPid(pay.getPid());
+		responseVo.setText(text);
+		return responseVo;
+	}
+	
+	
+	/**
+	 * 支付宝查询 栋科
+	 * @return
+	 * @throws Exception 
+	 */
+	public ApiInfoResponseVo aliInfoDongke(String pid) throws Exception {
+		boolean payed = this.payed(pid);
+		if(!payed) { // 待支付订单通过接口查询并更新支付状态
+			if(payAliNewService.queryDongke(pid)) { // 接口查询已支付
+				payDao.update(pid, Constant.STATUS_PAYED, Constant.FLAG_QUERY);
+				payed = true;
+			}
+		}
+		return ApiInfoResponseVo.build(pid, payed);
+	}
+	
+	/**
+	 * 支付宝查询 青谷
+	 * @return
+	 * @throws Exception 
+	 */
+	public ApiInfoResponseVo aliInfoQinggu(String pid) throws Exception {
+		boolean payed = this.payed(pid);
+		if(!payed) { // 待支付订单通过接口查询并更新支付状态
+			if(payAliNewService.queryQinggu(pid)) { // 接口查询已支付
+				payDao.update(pid, Constant.STATUS_PAYED, Constant.FLAG_QUERY);
+				payed = true;
+			}
+		}
+		return ApiInfoResponseVo.build(pid, payed);
+	}
+	
+	/**
+	 * 支付宝通知
+	 * @param pid
+	 * @param requestParam
+	 * @return
+	 * @throws Exception
+	 */
+	public boolean aliNotify(String pid, Map<String, String> paramMap) throws Exception {
+		if(!this.payed(pid) && payAliNewService.notify(paramMap)) {
+			return payDao.update(pid, Constant.STATUS_PAYED, Constant.FLAG_NOTIFY);
+		}
+		return false;
+	}
 	
 
 	/**
@@ -117,7 +200,7 @@ public class ApiService {
 	 * @return
 	 * @throws Exception 
 	 */
-	private Pay add(String appid, int money, String title) throws Exception {
+	private Pay add(int money, String title) throws Exception {
 		Pay pay = new Pay();
 		pay.setMoney(money);
 		pay.setTitle(title);

+ 270 - 0
src/main/java/com/llisoft/pay/service/PayAliNewService.java

@@ -0,0 +1,270 @@
+package com.llisoft.pay.service;
+
+import java.util.Map;
+import java.util.Objects;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import com.alipay.api.AlipayClient;
+import com.alipay.api.DefaultAlipayClient;
+import com.alipay.api.domain.AlipayTradeAppPayModel;
+import com.alipay.api.domain.AlipayTradePagePayModel;
+import com.alipay.api.domain.AlipayTradeQueryModel;
+import com.alipay.api.domain.AlipayTradeWapPayModel;
+import com.alipay.api.internal.util.AlipaySignature;
+import com.alipay.api.request.AlipayTradeAppPayRequest;
+import com.alipay.api.request.AlipayTradePagePayRequest;
+import com.alipay.api.request.AlipayTradeQueryRequest;
+import com.alipay.api.request.AlipayTradeWapPayRequest;
+import com.alipay.api.response.AlipayTradeAppPayResponse;
+import com.alipay.api.response.AlipayTradePagePayResponse;
+import com.alipay.api.response.AlipayTradeQueryResponse;
+import com.alipay.api.response.AlipayTradeWapPayResponse;
+import com.llisoft.pay.util.DecimalUtil;
+import com.llisoft.pay.util.JsonUtil;
+
+/**
+ * 支付宝支付
+ */
+@Service
+public class PayAliNewService {
+	
+	private Logger logger = LoggerFactory.getLogger(PayAliNewService.class);
+	
+	@Value("${mta.domain}")
+	private String domain;
+	
+	private String serverUrl = "https://openapi.alipay.com/gateway.do";
+	private String appidDongke = "2017020505526927";
+	private String appidQinggu = "2021004131649155";
+	private String privateKeyDongke = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCJDDaWPOLc5n7D2wNrPSou+Yi+C/cw7x2105ANs8vXlGSCJyHfmKR3b2+1/fiKYDvjboeKbL5wbpbUrWt10VW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8pCaZ91bn6A4Rpr7AqklDuSTsArvC9LrSNQa2Nz3+huYoMGDh0c+DeNkRSmheB2UGkY+F3dpPxyWZrlgzIreMLb7mCoioITz0QKBgQDAAeu3TkCzofhFN10t5p6q4kMErbVYGdZ8khgEXFkgZr/l/vXlVZqc+yMaC0RQB8n4l5kKxOfKrnTFy8GPQ2Oe2EmQ3Rr672xD1UPpgc0J3dxQqkAfFnFpaHryrxVZ0ntYuJ8mvMZ37cIpSvMjwLPI7RLT1lLsu7/ZahHWSSi5lQKBgQCzYj/cY08THB6gDUotD//HFooIRKs6VBoKolR+faGC/oKHV0iugKJGnbh4jSHunk2z3SkFcCPkNV+/Im6k18yV1jXrVnsLSUl0RpozwVwQjK4rPE96WhwCgItY7Lrao8mtE/gDiXqto12xkGr5q6jIYstwjzPP++DaWC7MBzkiZQKBgQCXa+xc71WPVJja3UKaxFk1IqL/uY5eIGJKc1yFc97F8sI7u8poRg5c5qFUFLaW9s2NQuDq4UZ7TQHCS2ImfVq/FotNt1FjvBWBmVqpeDgfI9xvsRRIcAaYvlDXusP3xkqIOXEpt449Xj/VGMqO05X1SyGh9lAHajluWHwgpil70QKBgEjuWBJtWdfmJdlirda2W4KA+mu0J32WdeP+7aVjxIeynDUUWpt/9voI49g3YSVXvTW0ZBou5pjAzoWyJRPmHOqKZe+hgHMtP60Di2whYCHmYGV5psKS4jJuOrlTvgBoePViWgJuIa947P3lPmj1zrBx4k6IGkOkH14GXjhbc3I1AoGAV5BLnPrAaxedyDJdystReDEnOV4urfhcg0EGsgDe1wMe8brPXD+pvKaIzhHNLHL1zz0LSvrgHqpuX4P2I7MWAoWVLjNuKYw8tBuUPATxdPDES5IekHFfC09hrTsX7iyd1FWUtP6ENrnJn/B8yQuHmFin2BaPNLtIHDkev4hKWMA=";
+	private String signType = "RSA2";
+	
+	private AlipayClient alipayClientDongke = DefaultAlipayClient.builder(serverUrl, appidDongke, privateKeyDongke).signType(signType).build();
+	private AlipayClient alipayClientQinggu = DefaultAlipayClient.builder(serverUrl, appidQinggu, privateKeyQinggu).signType(signType).build();
+	
+	
+	/**
+	 * PC 栋科
+	 * @param pid
+	 * @param money
+	 * @param subject
+	 * @return
+	 */
+	public String pcDongke(String pid, int money, String subject) {
+		return this.pc(alipayClientDongke, pid, money, subject);
+	}
+	
+	/**
+	 * PC 青谷
+	 * @param pid
+	 * @param money
+	 * @param subject
+	 * @return
+	 */
+	public String pcQinggu(String pid, int money, String subject) {
+		return this.pc(alipayClientQinggu, pid, money, subject);
+	}
+	
+	/**
+	 * PC
+	 * @param alipayClient
+	 * @param pid
+	 * @param money
+	 * @param subject
+	 * @return 该结果用于跳转到支付宝页面,返回到用户浏览器渲染或重定向跳转到支付宝页面
+	 * https://opendocs.alipay.com/open/59da99d0_alipay.trade.page.pay
+	 */
+	public String pc(AlipayClient alipayClient, String pid, int money, String subject) {
+		AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();
+		request.setReturnUrl(domain+"/alipay/return");
+		request.setNotifyUrl(domain+"/alipay/notify");
+		AlipayTradePagePayModel model = new AlipayTradePagePayModel();
+		model.setOutTradeNo(pid); // Y 商户订单号,64个字符以内、可包含字母、数字、下划线;需保证在商户端不重复
+		model.setTotalAmount(DecimalUtil.toString(money)); // Y 订单总金额,单位为元,精确到小数点后两位,取值范围[0.01,100000000]
+		model.setSubject(subject); // Y 订单标题
+		model.setProductCode("FAST_INSTANT_TRADE_PAY"); // Y 销售产品码,与支付宝签约的产品码名称。 注:目前仅支持FAST_INSTANT_TRADE_PAY
+		request.setBizModel(model);
+		try {
+			logger.debug("支付宝支付接口(PC)请求:{}", JsonUtil.toJson(request));
+			AlipayTradePagePayResponse response = alipayClient.pageExecute(request);
+			logger.debug("支付宝支付接口(pc)返回:{}", JsonUtil.toJson(response));
+			return response.getBody();
+		} catch (Exception exception) {
+			logger.error("支付宝支付接口(pc)异常", exception);
+		}
+		return null;
+	}
+	
+	
+	/**
+	 * WAP 栋科
+	 * @param pid
+	 * @param money
+	 * @param subject
+	 * @return
+	 */
+	public String wapDongke(String pid, int money, String subject) {
+		return this.wap(alipayClientDongke, pid, money, subject);
+	}
+	
+	/**
+	 * WAP 青谷
+	 * @param pid
+	 * @param money
+	 * @param subject
+	 * @return
+	 */
+	public String wapQinggu(String pid, int money, String subject) {
+		return this.wap(alipayClientQinggu, pid, money, subject);
+	}
+	
+	/**
+	 * 支付 移动端
+	 * @param alipayClient
+	 * @param pid
+	 * @param money
+	 * @param subject
+	 * @return
+	 * https://docs.open.alipay.com/270/alipay.trade.page.pay
+	 */
+	public String wap(AlipayClient alipayClient, String pid, int money, String subject) {
+		AlipayTradeWapPayRequest request = new AlipayTradeWapPayRequest();
+		request.setReturnUrl(domain+"/alipay/return");
+		request.setNotifyUrl(domain+"/alipay/notify");
+		AlipayTradeWapPayModel model = new AlipayTradeWapPayModel();
+		model.setOutTradeNo(pid); // Y 商户订单号,64个字符以内、可包含字母、数字、下划线;需保证在商户端不重复
+		model.setTotalAmount(DecimalUtil.toString(money)); // Y 订单总金额,单位为元,精确到小数点后两位,取值范围[0.01,100000000]
+		model.setSubject(subject); // Y 订单标题
+		request.setBizModel(model);
+		try {
+			logger.debug("支付宝支付接口(WAP)请求:{}", JsonUtil.toJson(request));
+			AlipayTradeWapPayResponse response = alipayClient.pageExecute(request);
+			logger.debug("支付宝支付接口(WAP)返回:{}", JsonUtil.toJson(response));
+			return response.getBody();
+		} catch (Exception exception) {
+			logger.error("支付宝支付接口(WAP)异常", exception);
+		}
+		return null;
+	}
+	
+	
+	/**
+	 * WAP 栋科
+	 * @param pid
+	 * @param money
+	 * @param subject
+	 * @return
+	 */
+	public String appDongke(String pid, int money, String subject) {
+		return this.app(alipayClientDongke, pid, money, subject);
+	}
+	
+	/**
+	 * WAP 青谷
+	 * @param pid
+	 * @param money
+	 * @param subject
+	 * @return
+	 */
+	public String appQinggu(String pid, int money, String subject) {
+		return this.app(alipayClientQinggu, pid, money, subject);
+	}
+	
+	/**
+	 * 支付 移动端
+	 * @param alipayClient
+	 * @param pid
+	 * @param money
+	 * @param subject
+	 * @return
+	 * https://opendocs.alipay.com/open/29ae8cb6_alipay.trade.wap.pay
+	 */
+	public String app(AlipayClient alipayClient, String pid, int money, String subject) {
+		AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
+		request.setReturnUrl(domain+"/alipay/return");
+		request.setNotifyUrl(domain+"/alipay/notify");
+		AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
+		model.setOutTradeNo(pid); // Y 商户订单号,64个字符以内、可包含字母、数字、下划线;需保证在商户端不重复
+		model.setTotalAmount(DecimalUtil.toString(money)); // Y 订单总金额,单位为元,精确到小数点后两位,取值范围[0.01,100000000]
+		model.setSubject(subject); // Y 订单标题
+		request.setBizModel(model);
+		try {
+			logger.debug("支付宝支付接口(APP)请求:{}", JsonUtil.toJson(request));
+			AlipayTradeAppPayResponse response = alipayClient.pageExecute(request);
+			logger.debug("支付宝支付接口(APP)返回:{}", JsonUtil.toJson(response));
+			return response.getBody();
+		} catch (Exception exception) {
+			logger.error("支付宝支付接口(APP)异常", exception);
+		}
+		return null;
+	}
+	
+	
+	/**
+	 * 查询 栋科
+	 * @return
+	 * @throws Exception 
+	 */
+	public boolean queryDongke(String pid) throws Exception {
+		return this.query(alipayClientDongke, pid);
+	}
+	
+	/**
+	 * 查询 青谷
+	 * @return
+	 * @throws Exception 
+	 */
+	public boolean queryQinggu(String pid) throws Exception {
+		return this.query(alipayClientQinggu, pid);
+	}
+	
+	/**
+	 * 查询
+	 * @param pid
+	 * @return
+	 * https://docs.open.alipay.com/api_1/alipay.trade.query
+	 */
+	public boolean query(AlipayClient alipayClient, String pid) {
+		AlipayTradeQueryRequest request = new AlipayTradeQueryRequest();
+		AlipayTradeQueryModel model = new AlipayTradeQueryModel();
+		model.setOutTradeNo(pid); // 商户订单号
+		request.setBizModel(model);
+		try {
+			logger.debug("支付宝查询接口请求:{}", JsonUtil.toJson(request));
+			AlipayTradeQueryResponse response = alipayClient.execute(request);
+			logger.debug("支付宝查询接口返回:{}", JsonUtil.toJson(response));
+			// {"alipay_trade_query_response":{"code":"10000","msg":"Success","buyer_logon_id":"ipb***@sandbox.com","buyer_pay_amount":"0.00","buyer_user_id":"2088102170394382","buyer_user_type":"PRIVATE","invoice_amount":"0.00","out_trade_no":"1529637131201603","point_amount":"0.00","receipt_amount":"0.00","send_pay_date":"2018-06-22 11:12:23","total_amount":"12.00","trade_no":"2018062221001004380200826678","trade_status":"TRADE_SUCCESS"},"sign":"gnWtxKDDhkRmoWnfwLVs2RGtt4GbiY+xaVs5+G47D5e9SnQHqGnElKme4jlDdnqhAroX3aqyJLVexohBjzA+DlpRzDhIu5EZLXnDr/B2FZEVjyiU66ImVH6vSyWyOVEjbGIgmVhUslhXqXYK5KxAx3QAdLrJLQeMO/gUdjs0qWcGO9yTU/suDy0YcdLSLlFyUutwD2MBz4Ri0tBk+uHjpxXoTZeb9/lQ7e4BixwCy+wB3hcESWN1b/m77YLKztmbLy67auhxzP9TRwQQ+6WRrTdMe/9rouIt6AW9T+6XSFd/LwL73Qo+1MfQa+iEUx2Iq+AYekhSgVyLJMRgz/qoZA=="}
+			String body = response.getBody();
+			if(Objects.nonNull(body) && !body.trim().isEmpty()) {
+				Map<String, Object> bodyMap = JsonUtil.toObject(body, Map.class, String.class, Object.class);
+				Map<String, Object> tradeMap = JsonUtil.toObject(JsonUtil.toJson(bodyMap.get("alipay_trade_query_response")), Map.class, String.class, Object.class);
+				return "10000".equals(tradeMap.get("code")) && ("TRADE_SUCCESS".equals(tradeMap.get("trade_status")) || "TRADE_FINISHED".equals(tradeMap.get("trade_status")));
+			}
+		} catch (Exception exception) {
+			logger.error("支付宝查询接口异常", exception);
+		}
+		return false;
+	}
+
+	// 支付宝公钥
+	String publicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0ZsJ44iDOtJ2vJnoIL970l3a9xJXiRtLWJWlUyhFz8zIlkNb0A/oMSWWpkUs7B2ryUTKmItmRqg8em4diQTcE5b0fpYIFntg+ThLN4Jbt3+CK05tCKIKfuCkDSaIkr8PP+vCZyHlpw5MBdBpX4sG9lDsPh3E48qXeh9vvLUeqF2n+Pok9FHHzEUcrCtVWp5eHL34a/HnJbTzb4t25b9FqQmhYK/vI2CUN3aI+rmthzqJFrmxsTFkR5rTvcMyVzOze6EoDgzBFShJnrfVD4efbqhc1+afmrKj+VAp8Uxpj8HCzTvuBDuB2yg/rgTt2y3u9HZT67NM18Butk/XgmIUlQIDAQAB";
+	public boolean notify(Map<String, String> map) throws Exception {
+		// 验证签名
+		if(!AlipaySignature.rsaCheckV1(map, publicKey, "UTF-8", signType)) {
+			logger.error("支付宝异步通知: 签名验证失败: {}", map);
+			return false;
+		}
+		// 验证支付宝交易状态
+		String tradeStatus = map.get("trade_status"); // 支付宝交易状态 https://docs.open.alipay.com/#s1
+		if(Objects.nonNull(tradeStatus) && ("TRADE_SUCCESS".equals(tradeStatus) || "TRADE_FINISHED".equals(tradeStatus))) {
+			return true;
+		}
+		return false;
+	}
+	
+}

+ 1 - 1
src/main/java/com/llisoft/pay/vo/ApiInfoResponseVo.java

@@ -12,7 +12,7 @@ public class ApiInfoResponseVo {
 	@ApiModelProperty("是否已支付")
 	private boolean payed;
 	
-	public static ApiInfoResponseVo Build(String pid, boolean payed) {
+	public static ApiInfoResponseVo build(String pid, boolean payed) {
 		ApiInfoResponseVo responseVo = new ApiInfoResponseVo();
 		responseVo.setPid(pid);
 		responseVo.setPayed(payed);

+ 11 - 0
src/main/java/com/llisoft/pay/vo/ApiPayAliAppResponseVo.java

@@ -9,6 +9,9 @@ public class ApiPayAliAppResponseVo {
 	@ApiModelProperty("支付号")
     private String pid;
 	
+	@ApiModelProperty("文本")
+	private String text;
+	
 	public String getPid() {
 		return pid;
 	}
@@ -16,5 +19,13 @@ public class ApiPayAliAppResponseVo {
 	public void setPid(String pid) {
 		this.pid = pid;
 	}
+
+	public String getText() {
+		return text;
+	}
+
+	public void setText(String text) {
+		this.text = text;
+	}
   
 }

+ 3 - 3
src/test/java/com/llisoft/pay/ServiceTest.java

@@ -6,7 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
-import com.llisoft.pay.service.PayWxService;
+import com.llisoft.pay.service.PayAliNewService;
 import com.llisoft.pay.util.CodeUtil;
 
 @SpringBootTest
@@ -14,12 +14,12 @@ import com.llisoft.pay.util.CodeUtil;
 public class ServiceTest {
 	
 	@Autowired
-	PayWxService wxPayService;
+	PayAliNewService service;
 	
 	@Test
 	public void test() throws Exception{
 		long begin = System.currentTimeMillis();
-		System.out.println(wxPayService.pay(CodeUtil.time(), 1, "测试"));
+		System.out.println(service.pcDongke(CodeUtil.time(), 1, "测试"));
 		System.out.println("耗时:"+ (System.currentTimeMillis() - begin));
 	}