【7.0.4】整理支付代码

pull/22/head
fengshuonan 2021-06-01 22:29:04 +08:00
parent 1f3a58c356
commit 2b8ec525b6
12 changed files with 41 additions and 61 deletions

View File

@ -11,10 +11,4 @@
<artifactId>pay-api</artifactId> <artifactId>pay-api</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
</project> </project>

View File

@ -38,36 +38,34 @@ public interface PayApi {
/** /**
* PC * PC
* *
* @param orderName * @param orderName
* @param outTradeNo * @param outTradeNo
* @param total * @param total
* @param returnUrl * @param returnUrl
* @return * @return
* @author huziyang * @author huziyang
* @date 2021/04/20 20:43 * @date 2021/04/20 20:43
*/ */
String page(String orderName, String outTradeNo, String total, String returnUrl); String page(String orderName, String outTradeNo, String total, String returnUrl);
/** /**
* *
* *
* @param orderName * @param orderName
* @param outTradeNo * @param outTradeNo
* @param total * @param total
* @param quitUrl 退 * @param quitUrl 退
* @param returnUrl * @param returnUrl
* @return * @return
* @author huziyang * @author huziyang
* @date 2021/04/20 20:43 * @date 2021/04/20 20:43
*/ */
String wap(String orderName, String outTradeNo, String total, String quitUrl, String returnUrl); String wap(String orderName, String outTradeNo, String total, String quitUrl, String returnUrl);
/** /**
* 退 * 退
* *
* @param outTradeNo * @param outTradeNo
* @param refundAmount 退 * @param refundAmount 退
* @return 退 * @return 退
* @author huziyang * @author huziyang
@ -75,5 +73,4 @@ public interface PayApi {
*/ */
TradeRefundResponse refund(String outTradeNo, String refundAmount); TradeRefundResponse refund(String outTradeNo, String refundAmount);
} }

View File

@ -42,7 +42,6 @@ public interface PayConstants {
*/ */
String PAY_EXCEPTION_STEP_CODE = "80"; String PAY_EXCEPTION_STEP_CODE = "80";
/** /**
* 退 * 退
*/ */

View File

@ -25,7 +25,10 @@
package cn.stylefeng.roses.kernel.pay.api.pojo; package cn.stylefeng.roses.kernel.pay.api.pojo;
import cn.stylefeng.roses.kernel.pay.api.constants.PayConstants; import cn.stylefeng.roses.kernel.pay.api.constants.PayConstants;
import lombok.*; import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/** /**
* 退 * 退
@ -37,7 +40,7 @@ import lombok.*;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@Builder @Builder
public class TradeRefundResponse{ public class TradeRefundResponse {
/** /**
* 退 * 退
@ -88,12 +91,12 @@ public class TradeRefundResponse{
* TradeRefundResponse * TradeRefundResponse
* *
* @param code * @param code
* @param msg * @param msg
* @param data * @param data
* @author huziyang * @author huziyang
* @date 2021/04/20 20:43 * @date 2021/04/20 20:43
*/ */
public TradeRefundResponse(String code, String msg, Object data){ public TradeRefundResponse(String code, String msg, Object data) {
this.code = code; this.code = code;
this.msg = msg; this.msg = msg;
this.data = data; this.data = data;
@ -102,17 +105,16 @@ public class TradeRefundResponse{
/** /**
* *
* *
* @param msg * @param msg
* @param data * @param data
* @return TradeRefundResponse * @return TradeRefundResponse
* @author huziyang * @author huziyang
* @date 2021/04/20 20:43 * @date 2021/04/20 20:43
*/ */
public static TradeRefundResponse error(String msg, Object data){ public static TradeRefundResponse error(String msg, Object data) {
return new TradeRefundResponse(PayConstants.REFUND_ERROR_CODE,msg,data); return new TradeRefundResponse(PayConstants.REFUND_ERROR_CODE, msg, data);
} }
/** /**
* *
* *
@ -121,9 +123,8 @@ public class TradeRefundResponse{
* @author huziyang * @author huziyang
* @date 2021/04/20 20:43 * @date 2021/04/20 20:43
*/ */
public static TradeRefundResponse error(String msg){ public static TradeRefundResponse error(String msg) {
return error(msg,null); return error(msg, null);
} }
} }

View File

@ -11,25 +11,20 @@
<artifactId>pay-sdk-alipay</artifactId> <artifactId>pay-sdk-alipay</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies> <dependencies>
<!--支付模块的api--> <!--支付模块的api-->
<dependency> <dependency>
<groupId>cn.stylefeng.roses</groupId> <groupId>cn.stylefeng.roses</groupId>
<artifactId>pay-api</artifactId> <artifactId>pay-api</artifactId>
<version>7.0.4</version> <version>${roses.version}</version>
</dependency> </dependency>
<!--阿里支付sdk--> <!--阿里支付sdk-->
<dependency> <dependency>
<groupId>com.alipay.sdk</groupId> <groupId>com.alipay.sdk</groupId>
<artifactId>alipay-easysdk</artifactId> <artifactId>alipay-easysdk</artifactId>
<version>2.2.0</version> <version>${alipay.version}</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -48,7 +48,7 @@ public class AlipayConfig implements ApplicationRunner {
/** /**
* *
*/ */
@Value("${alipay.merchantPrivateKey}") @Value("${alipay.merchantPrivateKey}")
private String merchantPrivateKey; private String merchantPrivateKey;
@ -132,5 +132,4 @@ public class AlipayConfig implements ApplicationRunner {
return config; return config;
} }
} }

View File

@ -33,4 +33,5 @@ package cn.stylefeng.roses.kernel.pay.alipay.constants;
public interface AlipayConstants { public interface AlipayConstants {
String ALIPAY_REFUND_SUCCESS_CODE = "10000"; String ALIPAY_REFUND_SUCCESS_CODE = "10000";
} }

View File

@ -38,36 +38,34 @@ public interface AlipayService {
/** /**
* PC * PC
* *
* @param orderName * @param orderName
* @param outTradeNo * @param outTradeNo
* @param total * @param total
* @param returnUrl * @param returnUrl
* @return * @return
* @author huziyang * @author huziyang
* @date 2021/04/20 20:43 * @date 2021/04/20 20:43
*/ */
String page(String orderName, String outTradeNo, String total, String returnUrl); String page(String orderName, String outTradeNo, String total, String returnUrl);
/** /**
* *
* *
* @param orderName * @param orderName
* @param outTradeNo * @param outTradeNo
* @param total * @param total
* @param quitUrl 退 * @param quitUrl 退
* @param returnUrl * @param returnUrl
* @return * @return
* @author huziyang * @author huziyang
* @date 2021/04/20 20:43 * @date 2021/04/20 20:43
*/ */
String wap(String orderName, String outTradeNo, String total, String quitUrl, String returnUrl); String wap(String orderName, String outTradeNo, String total, String quitUrl, String returnUrl);
/** /**
* 退 * 退
* *
* @param outTradeNo * @param outTradeNo
* @param refundAmount 退 * @param refundAmount 退
* @return 退 * @return 退
* @author huziyang * @author huziyang
@ -75,5 +73,4 @@ public interface AlipayService {
*/ */
TradeRefundResponse refund(String outTradeNo, String refundAmount); TradeRefundResponse refund(String outTradeNo, String refundAmount);
} }

View File

@ -44,7 +44,6 @@ import org.springframework.stereotype.Service;
@Slf4j @Slf4j
public class AlipayServiceImpl implements AlipayService, PayApi { public class AlipayServiceImpl implements AlipayService, PayApi {
@Override @Override
public String page(String orderName, String outTradeNo, String total, String returnUrl) { public String page(String orderName, String outTradeNo, String total, String returnUrl) {
try { try {
@ -58,7 +57,7 @@ public class AlipayServiceImpl implements AlipayService, PayApi {
@Override @Override
public String wap(String orderName, String outTradeNo, String total, String quitUrl, String returnUrl) { public String wap(String orderName, String outTradeNo, String total, String quitUrl, String returnUrl) {
try { try {
return Factory.Payment.Wap().pay(orderName, outTradeNo, total, quitUrl, returnUrl).body; return Factory.Payment.Wap().pay(orderName, outTradeNo, total, quitUrl, returnUrl).body;
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage()); log.error(e.getMessage());
return e.getMessage(); return e.getMessage();
@ -69,7 +68,7 @@ public class AlipayServiceImpl implements AlipayService, PayApi {
public TradeRefundResponse refund(String outTradeNo, String refundAmount) { public TradeRefundResponse refund(String outTradeNo, String refundAmount) {
try { try {
AlipayTradeRefundResponse response = Factory.Payment.Common().refund(outTradeNo, refundAmount); AlipayTradeRefundResponse response = Factory.Payment.Common().refund(outTradeNo, refundAmount);
if (AlipayConstants.ALIPAY_REFUND_SUCCESS_CODE.equals(response.getCode())){ if (AlipayConstants.ALIPAY_REFUND_SUCCESS_CODE.equals(response.getCode())) {
return TradeRefundResponse.builder() return TradeRefundResponse.builder()
.code(PayConstants.REFUND_SUCCESS_CODE) .code(PayConstants.REFUND_SUCCESS_CODE)
.msg(response.getMsg()) .msg(response.getMsg())
@ -82,10 +81,11 @@ public class AlipayServiceImpl implements AlipayService, PayApi {
.data(response) .data(response)
.build(); .build();
} }
return TradeRefundResponse.error(response.msg,response); return TradeRefundResponse.error(response.msg, response);
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage()); log.error(e.getMessage());
return TradeRefundResponse.error(e.getMessage()); return TradeRefundResponse.error(e.getMessage());
} }
} }
} }

View File

@ -11,18 +11,15 @@
<artifactId>pay-spring-boot-starter</artifactId> <artifactId>pay-spring-boot-starter</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies> <dependencies>
<!--alipay api模块的sdk--> <!--alipay api模块的sdk-->
<dependency> <dependency>
<groupId>cn.stylefeng.roses</groupId> <groupId>cn.stylefeng.roses</groupId>
<artifactId>pay-sdk-alipay</artifactId> <artifactId>pay-sdk-alipay</artifactId>
<version>7.0.4</version> <version>${roses.version}</version>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -49,6 +49,5 @@ public class GunsPayAutoConfiguration {
return new AlipayServiceImpl(); return new AlipayServiceImpl();
} }
} }

View File

@ -20,6 +20,7 @@
<properties> <properties>
<maven.compiler.source>8</maven.compiler.source> <maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target> <maven.compiler.target>8</maven.compiler.target>
<alipay.version>2.2.0</alipay.version>
</properties> </properties>
<dependencies> <dependencies>
@ -28,7 +29,7 @@
<dependency> <dependency>
<groupId>cn.stylefeng.roses</groupId> <groupId>cn.stylefeng.roses</groupId>
<artifactId>kernel-a-rule</artifactId> <artifactId>kernel-a-rule</artifactId>
<version>7.0.4</version> <version>${roses.version}</version>
</dependency> </dependency>
</dependencies> </dependencies>