|
package org.jeecg;
|
|
|
|
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
|
|
import org.jeecg.modules.pay.MpWxPayService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.boot.SpringApplication;
|
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
import org.springframework.context.ConfigurableApplicationContext;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
@RestController
|
|
@SpringBootApplication
|
|
public class PayDemoApplication {
|
|
|
|
public static void main(String[] args) {
|
|
ConfigurableApplicationContext app = SpringApplication.run(PayDemoApplication.class, args);
|
|
|
|
// 用法说明 @Autowired MpWxPayService mpWxPayService
|
|
MpWxPayService bean = app.getBean(MpWxPayService.class);
|
|
//Object callback = bean.createAppOrder("产品名", "127.0.0.1", "89", 1, "20219092", "{}","");
|
|
//System.err.println(callback.toString());
|
|
Object webOrder = bean.createWebOrder("产品名", "117.61.97.157", "89", 1, "20219092", "{}", "");
|
|
System.err.println(webOrder.toString());
|
|
|
|
//缓存该数据用于与异步通知对比处理
|
|
//WxPayAppOrderResult(sign=6E404CB2E71FD391BB0FE2C2B12F5264, prepayId=wx17011430290850d50f73c68d61e80a0000, partnerId=1560997691, appId=wx7081b3f6277c100d, packageValue=Sign=WXPay, timeStamp=1637082870, nonceStr=1637082870392)
|
|
//取以上数据交由前端调起支付
|
|
}
|
|
|
|
//部署该地址至外网接受异步通知
|
|
@RequestMapping("/notify")
|
|
public Object notify(@RequestBody String requestBody, @Autowired MpWxPayService mpWxPayService){
|
|
WxPayOrderNotifyResult notify = mpWxPayService.notify(requestBody);
|
|
String outTradeNo = notify.getOutTradeNo();
|
|
System.err.println(outTradeNo);
|
|
//对比outTradeNo进行业务处理
|
|
if (notify == null){
|
|
//会继续通知
|
|
return "FAIL";
|
|
}
|
|
//不再通知该结果
|
|
return "SUCCESS";
|
|
}
|
|
|
|
}
|