Skip to content

Commit

Permalink
提交xxpay4spring-boot版本
Browse files Browse the repository at this point in the history
  • Loading branch information
jmdhappy committed Oct 24, 2017
1 parent c454edf commit 20a5732
Show file tree
Hide file tree
Showing 39 changed files with 2,724 additions and 14 deletions.
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<module>xxpay-shop</module>
<module>xxpay4spring-cloud</module>
<module>xxpay4dubbo</module>
<module>xxpay4spring-boot</module>
</modules>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
*/
public interface IMchInfoService {

public Map selectMchInfo(String jsonParam);
Map selectMchInfo(String jsonParam);

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
*/
public interface IPayChannelService {

public Map selectPayChannel(String jsonParam);
Map selectPayChannel(String jsonParam);

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@
*/
public interface IPayOrderService {

public Map createPayOrder(String jsonParam);
Map createPayOrder(String jsonParam);

public Map selectPayOrder(String jsonParam);
Map selectPayOrder(String jsonParam);

public Map selectPayOrderByMchIdAndPayOrderId(String jsonParam);
Map selectPayOrderByMchIdAndPayOrderId(String jsonParam);

public Map selectPayOrderByMchIdAndMchOrderNo(String jsonParam);
Map selectPayOrderByMchIdAndMchOrderNo(String jsonParam);

public Map updateStatus4Ing(String jsonParam);
Map updateStatus4Ing(String jsonParam);

public Map updateStatus4Success(String jsonParam);
Map updateStatus4Success(String jsonParam);

public Map updateStatus4Complete(String jsonParam);
Map updateStatus4Complete(String jsonParam);

public Map updateNotify(String jsonParam);
Map updateNotify(String jsonParam);

}
4 changes: 4 additions & 0 deletions xxpay4dubbo/xxpay4dubbo-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-activemq</artifactId>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-pool</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.xxpay.dubbo.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.alibaba.fastjson.JSONObject;
import com.alipay.api.AlipayApiException;
import com.alipay.api.internal.util.AlipaySignature;
import com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse;
Expand All @@ -15,7 +14,10 @@
import org.xxpay.common.constant.PayConstant;
import org.xxpay.common.domain.BaseParam;
import org.xxpay.common.enumm.RetEnum;
import org.xxpay.common.util.*;
import org.xxpay.common.util.JsonUtil;
import org.xxpay.common.util.MyLog;
import org.xxpay.common.util.ObjectValidUtil;
import org.xxpay.common.util.RpcUtil;
import org.xxpay.dal.dao.model.PayChannel;
import org.xxpay.dal.dao.model.PayOrder;
import org.xxpay.dubbo.api.service.INotifyPayService;
Expand Down
95 changes: 95 additions & 0 deletions xxpay4spring-boot/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.xxpay</groupId>
<artifactId>xxpay4spring-boot</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>xxpay4spring-boot</name>
<description>xxpay4spring-boot</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<springboot.version>1.5.6.RELEASE</springboot.version>
<springboot.dubbo.version>1.0.0</springboot.dubbo.version>
</properties>

<dependencies>
<dependency>
<groupId>org.xxpay</groupId>
<artifactId>xxpay-dal</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-activemq</artifactId>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-pool</artifactId>
</dependency>
<!--wx_pay-->
<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-pay</artifactId>
<version>2.8.0</version>
</dependency>
<!--ali_pay-->
<dependency>
<groupId>com.alipay</groupId>
<artifactId>sdk</artifactId>
<version>1.5</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/alipay-sdk-java20170818173712.jar</systemPath>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<finalName>${project.name}</finalName>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.xxpay.boot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;

/**
*
*/
@SpringBootApplication
@ComponentScan(basePackages={"org.xxpay"})
public class XxPayBootAppliaction {
public static void main(String[] args) {
SpringApplication.run(XxPayBootAppliaction.class, args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package org.xxpay.boot.ctrl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.xxpay.boot.web.NotifyPayService;
import org.xxpay.common.constant.PayConstant;
import org.xxpay.common.util.MyLog;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

/**
* @Description: 接收处理支付宝通知
* @author dingzhiwei [email protected]
* @date 2017-07-05
* @version V1.0
* @Copyright: www.xxpay.org
*/
@RestController
public class Notify4AliPayController {

private static final MyLog _log = MyLog.getLog(Notify4AliPayController.class);

@Autowired
private NotifyPayService notifyPayService;

/**
* 支付宝移动支付后台通知响应
* @param request
* @return
* @throws ServletException
* @throws IOException
*/
@RequestMapping(value = "/notify/pay/aliPayNotifyRes.htm")
@ResponseBody
public String aliPayNotifyRes(HttpServletRequest request) throws ServletException, IOException {
_log.info("====== 开始接收支付宝支付回调通知 ======");
String notifyRes = doAliPayRes(request);
_log.info("响应给支付宝:{}", notifyRes);
_log.info("====== 完成接收支付宝支付回调通知 ======");
return notifyRes;
}

public String doAliPayRes(HttpServletRequest request) throws ServletException, IOException {
String logPrefix = "【支付宝支付回调通知】";
//获取支付宝POST过来反馈信息
Map<String,String> params = new HashMap<String,String>();
Map requestParams = request.getParameterMap();
for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext();) {
String name = (String) iter.next();
String[] values = (String[]) requestParams.get(name);
String valueStr = "";
for (int i = 0; i < values.length; i++) {
valueStr = (i == values.length - 1) ? valueStr + values[i]
: valueStr + values[i] + ",";
}
//乱码解决,这段代码在出现乱码时使用。如果mysign和sign不相等也可以使用这段代码转化
//valueStr = new String(valueStr.getBytes("ISO-8859-1"), "gbk");
params.put(name, valueStr);
}
_log.info("{}通知请求数据:reqStr={}", logPrefix, params);
if(params.isEmpty()) {
_log.error("{}请求参数为空", logPrefix);
return PayConstant.RETURN_ALIPAY_VALUE_FAIL;
}
return notifyPayService.doAliPayNotify(params);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package org.xxpay.boot.ctrl;

import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.xxpay.boot.web.NotifyPayService;
import org.xxpay.common.util.MyLog;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
* @Description: 接收处理微信通知
* @author dingzhiwei [email protected]
* @date 2017-07-05
* @version V1.0
* @Copyright: www.xxpay.org
*/
@RestController
public class Notify4WxPayController {

private static final MyLog _log = MyLog.getLog(Notify4WxPayController.class);

@Autowired
private NotifyPayService notifyPayService;

/**
* 微信支付(统一下单接口)后台通知响应
* @param request
* @return
* @throws ServletException
* @throws IOException
*/
@RequestMapping("/notify/pay/wxPayNotifyRes.htm")
@ResponseBody
public String wxPayNotifyRes(HttpServletRequest request) throws ServletException, IOException {
_log.info("====== 开始接收微信支付回调通知 ======");
String notifyRes = doWxPayRes(request);
_log.info("响应给微信:{}", notifyRes);
_log.info("====== 完成接收微信支付回调通知 ======");
return notifyRes;
}

public String doWxPayRes(HttpServletRequest request) throws ServletException, IOException {
String logPrefix = "【微信支付回调通知】";
String xmlResult = IOUtils.toString(request.getInputStream(), request.getCharacterEncoding());
_log.info("{}通知请求数据:reqStr={}", logPrefix, xmlResult);
return notifyPayService.doWxPayNotify(xmlResult);
}

}
Loading

0 comments on commit 20a5732

Please sign in to comment.