2
0

feat: payment modules support alipay and credit card pay api

This commit is contained in:
zhangsz
2024-12-30 20:30:19 +08:00
parent 0207122187
commit d0dee7f7a4
45 changed files with 490 additions and 2212 deletions

View File

@@ -6,10 +6,10 @@
<groupId>org.wfc</groupId>
<artifactId>wfc</artifactId>
<version>1.0.2</version>
<version>${wfc.version}</version>
<name>wfc</name>
<description>WANFi Control and Billing System</description>
<description>WANFi Control and Billing Management System</description>
<properties>
<wfc.version>1.0.2</wfc.version>

View File

@@ -89,6 +89,13 @@
<version>4.6.0</version>
</dependency>
<!-- for Ali Pay -->
<dependency>
<groupId>com.alipay.sdk</groupId>
<artifactId>alipay-sdk-java</artifactId>
<version>4.11.0.ALL</version>
</dependency>
<!-- Swagger 依赖项 -->
<!-- <dependency>
<groupId>io.springfox</groupId>

View File

@@ -0,0 +1,25 @@
package org.wfc.payment.alipay.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Data
@Configuration
@ConfigurationProperties(prefix = "alipay")
public class AlipayConfig {
private String appId;
private String privateKey;
private String publicKey;
private String notifyUrl;
private String returnUrl;
private String signType;
private String charset;
private String gatewayUrl;
private String logPath;
private int maxQueryRetry;
private int queryDuration;
private int maxCancelRetry;
private int cancelDuration;
private int heartbeatDelay;
}

View File

@@ -0,0 +1,80 @@
package org.wfc.payment.alipay.controller;
import com.alipay.api.AlipayApiException;
import com.alipay.api.response.AlipayTradeQueryResponse;
import com.alipay.api.response.AlipayTradeCloseResponse;
import com.alipay.api.response.AlipayTradeRefundResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.wfc.payment.alipay.service.IAlipayPaymentService;
import org.wfc.payment.alipay.service.IAlipayQueryOrderService;
import org.wfc.payment.alipay.service.IAlipayTradeCloseService;
import org.wfc.payment.alipay.service.IAlipayRefundService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
@Tag(name = "Ali Pay")
@RestController
@RequestMapping("/alipay")
@AllArgsConstructor
public class AlipayController {
@Autowired
private final IAlipayPaymentService alipayPaymentService;
@Autowired
private final IAlipayQueryOrderService alipayQueryService;
@Autowired
private final IAlipayTradeCloseService alipayCloseService;
@Autowired
private final IAlipayRefundService alipayRefundService;
@Operation(summary = "Create Alipay order")
@GetMapping("/pay")
public String pay(@RequestParam String outTradeNo, @RequestParam String totalAmount, @RequestParam String subject,
@RequestParam String body) {
try {
return alipayPaymentService.createPayment(outTradeNo, totalAmount, subject, body);
} catch (AlipayApiException e) {
e.printStackTrace();
return "Error occurred while processing payment";
}
}
@Operation(summary = "Query Alipay order")
@GetMapping("/query")
public AlipayTradeQueryResponse query(@RequestParam String outTradeNo) {
try {
return alipayQueryService.queryOrder(outTradeNo);
} catch (AlipayApiException e) {
e.printStackTrace();
return null;
}
}
@Operation(summary = "Close Alipay order")
@GetMapping("/close")
public AlipayTradeCloseResponse close(@RequestParam String outTradeNo) {
try {
return alipayCloseService.closeOrder(outTradeNo);
} catch (AlipayApiException e) {
e.printStackTrace();
return null;
}
}
@Operation(summary = "Refund Alipay order")
@GetMapping("/refund")
public AlipayTradeRefundResponse refund(@RequestParam String outTradeNo, @RequestParam String refundAmount,
@RequestParam String refundReason) {
try {
return alipayRefundService.refundOrder(outTradeNo, refundAmount, refundReason);
} catch (AlipayApiException e) {
e.printStackTrace();
return null;
}
}
}

View File

@@ -0,0 +1,7 @@
package org.wfc.payment.alipay.service;
import com.alipay.api.AlipayApiException;
public interface IAlipayPaymentService {
String createPayment(String outTradeNo, String totalAmount, String subject, String body) throws AlipayApiException;
}

View File

@@ -0,0 +1,8 @@
package org.wfc.payment.alipay.service;
import com.alipay.api.AlipayApiException;
import com.alipay.api.response.AlipayTradeQueryResponse;
public interface IAlipayQueryOrderService {
AlipayTradeQueryResponse queryOrder(String outTradeNo) throws AlipayApiException;
}

View File

@@ -0,0 +1,9 @@
package org.wfc.payment.alipay.service;
import com.alipay.api.AlipayApiException;
import com.alipay.api.response.AlipayTradeRefundResponse;
public interface IAlipayRefundService {
AlipayTradeRefundResponse refundOrder(String outTradeNo, String refundAmount, String refundReason)
throws AlipayApiException;
}

View File

@@ -0,0 +1,8 @@
package org.wfc.payment.alipay.service;
import com.alipay.api.AlipayApiException;
import com.alipay.api.response.AlipayTradeCloseResponse;
public interface IAlipayTradeCloseService {
AlipayTradeCloseResponse closeOrder(String outTradeNo) throws AlipayApiException;
}

View File

@@ -0,0 +1,44 @@
package org.wfc.payment.alipay.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.request.AlipayTradePagePayRequest;
import org.wfc.payment.alipay.config.AlipayConfig;
import org.wfc.payment.alipay.service.IAlipayPaymentService;
@Service
public class AlipayPaymentServiceImpl implements IAlipayPaymentService {
@Autowired
private AlipayConfig alipayConfig;
@Override
public String createPayment(String outTradeNo, String totalAmount, String subject, String body)
throws AlipayApiException {
AlipayClient alipayClient = new DefaultAlipayClient(
alipayConfig.getGatewayUrl(),
alipayConfig.getAppId(),
alipayConfig.getPrivateKey(),
"json",
alipayConfig.getCharset(),
alipayConfig.getPublicKey(),
alipayConfig.getSignType());
AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();
request.setReturnUrl(alipayConfig.getReturnUrl());
request.setNotifyUrl(alipayConfig.getNotifyUrl());
request.setBizContent("{" +
"\"out_trade_no\":\"" + outTradeNo + "\"," +
"\"total_amount\":\"" + totalAmount + "\"," +
"\"subject\":\"" + subject + "\"," +
"\"body\":\"" + body + "\"," +
"\"product_code\":\"FAST_INSTANT_TRADE_PAY\"" +
"}");
return alipayClient.pageExecute(request).getBody();
}
}

View File

@@ -0,0 +1,37 @@
package org.wfc.payment.alipay.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.request.AlipayTradeQueryRequest;
import com.alipay.api.response.AlipayTradeQueryResponse;
import org.wfc.payment.alipay.config.AlipayConfig;
import org.wfc.payment.alipay.service.IAlipayQueryOrderService;
@Service
public class AlipayQueryOrderServiceImpl implements IAlipayQueryOrderService {
@Autowired
private AlipayConfig alipayConfig;
@Override
public AlipayTradeQueryResponse queryOrder(String outTradeNo) throws AlipayApiException {
AlipayClient alipayClient = new DefaultAlipayClient(
alipayConfig.getGatewayUrl(),
alipayConfig.getAppId(),
alipayConfig.getPrivateKey(),
"json",
alipayConfig.getCharset(),
alipayConfig.getPublicKey(),
alipayConfig.getSignType());
AlipayTradeQueryRequest request = new AlipayTradeQueryRequest();
request.setBizContent("{" +
"\"out_trade_no\":\"" + outTradeNo + "\"" +
"}");
return alipayClient.execute(request);
}
}

View File

@@ -0,0 +1,40 @@
package org.wfc.payment.alipay.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.request.AlipayTradeRefundRequest;
import com.alipay.api.response.AlipayTradeRefundResponse;
import org.wfc.payment.alipay.config.AlipayConfig;
import org.wfc.payment.alipay.service.IAlipayRefundService;
@Service
public class AlipayRefundServiceImpl implements IAlipayRefundService {
@Autowired
private AlipayConfig alipayConfig;
@Override
public AlipayTradeRefundResponse refundOrder(String outTradeNo, String refundAmount, String refundReason)
throws AlipayApiException {
AlipayClient alipayClient = new DefaultAlipayClient(
alipayConfig.getGatewayUrl(),
alipayConfig.getAppId(),
alipayConfig.getPrivateKey(),
"json",
alipayConfig.getCharset(),
alipayConfig.getPublicKey(),
alipayConfig.getSignType());
AlipayTradeRefundRequest request = new AlipayTradeRefundRequest();
request.setBizContent("{" +
"\"out_trade_no\":\"" + outTradeNo + "\"," +
"\"refund_amount\":\"" + refundAmount + "\"," +
"\"refund_reason\":\"" + refundReason + "\"" +
"}");
return alipayClient.execute(request);
}
}

View File

@@ -0,0 +1,37 @@
package org.wfc.payment.alipay.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.request.AlipayTradeCloseRequest;
import com.alipay.api.response.AlipayTradeCloseResponse;
import org.wfc.payment.alipay.config.AlipayConfig;
import org.wfc.payment.alipay.service.IAlipayTradeCloseService;
@Service
public class AlipayTradeCloseServiceImpl implements IAlipayTradeCloseService {
@Autowired
private AlipayConfig alipayConfig;
@Override
public AlipayTradeCloseResponse closeOrder(String outTradeNo) throws AlipayApiException {
AlipayClient alipayClient = new DefaultAlipayClient(
alipayConfig.getGatewayUrl(),
alipayConfig.getAppId(),
alipayConfig.getPrivateKey(),
"json",
alipayConfig.getCharset(),
alipayConfig.getPublicKey(),
alipayConfig.getSignType());
AlipayTradeCloseRequest request = new AlipayTradeCloseRequest();
request.setBizContent("{" +
"\"out_trade_no\":\"" + outTradeNo + "\"" +
"}");
return alipayClient.execute(request);
}
}

View File

@@ -0,0 +1,17 @@
package org.wfc.payment.ccpay.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Data
@Configuration
@ConfigurationProperties(prefix = "ccpay")
public class CcpayConfig {
private String url;
private String apiKey;
private String merchantId;
private String currency;
private int timeout;
private String callbackUrl;
}

View File

@@ -0,0 +1,32 @@
package org.wfc.payment.ccpay.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.wfc.payment.ccpay.model.PaymentRequest;
import org.wfc.payment.ccpay.model.PaymentResponse;
import org.wfc.payment.ccpay.service.ICcpayPaymentService;
import org.wfc.common.core.constant.HttpStatus;
/**
* Credit card pay controller
*
*/
@RestController
@RequestMapping("/ccpay")
public class CcpayController {
@Autowired
private ICcpayPaymentService ccpayService;
@PostMapping("/payOrder")
public ResponseEntity<String> processPayment(@RequestBody PaymentRequest paymentRequest) {
// 调用支付服务处理支付请求
PaymentResponse paymentResult = ccpayService.processPayment(paymentRequest);
if (paymentResult.isSuccess()) {
return ResponseEntity.ok("Payment successful");
} else {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Payment failed");
}
}
}

View File

@@ -0,0 +1,12 @@
package org.wfc.payment.ccpay.model;
import lombok.Data;
@Data
public class PaymentRequest {
private String cardNumber;
private String cardHolderName;
private String expirationDate;
private String cvv;
private double amount;
}

View File

@@ -0,0 +1,10 @@
package org.wfc.payment.ccpay.model;
import lombok.Data;
@Data
public class PaymentResponse {
private boolean success;
private String message;
private String transactionId;
}

View File

@@ -0,0 +1,8 @@
package org.wfc.payment.ccpay.service;
import org.wfc.payment.ccpay.model.PaymentRequest;
import org.wfc.payment.ccpay.model.PaymentResponse;
public interface ICcpayPaymentService {
PaymentResponse processPayment(PaymentRequest paymentRequest);
}

View File

@@ -0,0 +1,61 @@
package org.wfc.payment.ccpay.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import org.wfc.payment.ccpay.config.CcpayConfig;
import org.wfc.payment.ccpay.model.PaymentRequest;
import org.wfc.payment.ccpay.model.PaymentResponse;
import org.wfc.payment.ccpay.service.ICcpayPaymentService;
import java.util.HashMap;
import java.util.Map;
@Service
public class CcpayPaymentServiceImpl implements ICcpayPaymentService {
@Autowired
private CcpayConfig ccpayConfig;
@Override
public PaymentResponse processPayment(PaymentRequest paymentRequest) {
RestTemplate restTemplate = new RestTemplate();
PaymentResponse paymentResponse = new PaymentResponse();
try {
// 设置请求头
Map<String, String> headers = new HashMap<>();
headers.put("Authorization", "Bearer " + ccpayConfig.getApiKey());
headers.put("Content-Type", "application/json");
// 设置请求体
Map<String, Object> requestBody = new HashMap<>();
requestBody.put("merchantId", ccpayConfig.getMerchantId());
requestBody.put("currency", ccpayConfig.getCurrency());
requestBody.put("amount", paymentRequest.getAmount());
requestBody.put("cardNumber", paymentRequest.getCardNumber());
requestBody.put("cardHolderName", paymentRequest.getCardHolderName());
requestBody.put("expirationDate", paymentRequest.getExpirationDate());
requestBody.put("cvv", paymentRequest.getCvv());
requestBody.put("callbackUrl", ccpayConfig.getCallbackUrl());
// 调用第三方支付网关的 API 进行支付处理
PaymentResponse response = restTemplate.postForObject(ccpayConfig.getUrl(), requestBody,
PaymentResponse.class);
if (response != null && response.isSuccess()) {
paymentResponse.setSuccess(true);
paymentResponse.setMessage("Payment successful");
paymentResponse.setTransactionId(response.getTransactionId());
} else {
paymentResponse.setSuccess(false);
paymentResponse.setMessage("Payment failed");
}
} catch (Exception e) {
paymentResponse.setSuccess(false);
paymentResponse.setMessage("Error occurred while processing payment: " + e.getMessage());
}
return paymentResponse;
}
}

View File

@@ -1,73 +0,0 @@
package org.wfc.payment.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.wfc.common.core.web.controller.BaseController;
import org.wfc.common.core.web.domain.AjaxResult;
import org.wfc.common.log.annotation.Log;
import org.wfc.common.log.enums.BusinessType;
import org.wfc.common.security.annotation.RequiresPermissions;
import org.wfc.payment.domain.AliPay;
import org.wfc.payment.service.IAliPayService;
/**
* Paypal controller
*
* @author wfc
*/
@RestController
@RequestMapping("/alipay")
public class AliPayController extends BaseController
{
@Autowired
private IAliPayService alipayService;
/**
* AliPay
*/
@RequiresPermissions("payment:alipayInfo:query")
@Log(title = "alipay info management", businessType = BusinessType.OTHER)
@GetMapping("/{userId}")
public AjaxResult query(@PathVariable Long userId) {
return success(alipayService.selectAliPayInfoByUserId(userId));
}
/**
* AliPay
*/
@RequiresPermissions("payment:alipayInfo:add")
@Log(title = "alipay info management", businessType = BusinessType.INSERT)
@PostMapping("/{alipay}")
public AjaxResult add(@PathVariable AliPay alipay)
{
return toAjax(alipayService.insertAliPayInfo(alipay));
}
/**
* AliPay
*/
@RequiresPermissions("payment:alipayInfo:edit")
@Log(title = "alipay info management", businessType = BusinessType.UPDATE)
@PutMapping("/{id}")
public AjaxResult edit(@PathVariable Long id) {
return toAjax(alipayService.updateAliPayInfoById(id));
}
/**
* AliPay
*/
@RequiresPermissions("payment:alipayInfo:remove")
@Log(title = "alipay info management", businessType = BusinessType.DELETE)
@DeleteMapping("/{id}")
public AjaxResult remove(@PathVariable Long id) {
alipayService.deleteAliPayInfoById(id);
return success();
}
}

View File

@@ -1,89 +0,0 @@
package org.wfc.payment.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
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.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.wfc.common.core.web.controller.BaseController;
import org.wfc.common.core.web.domain.AjaxResult;
import org.wfc.common.log.annotation.Log;
import org.wfc.common.log.enums.BusinessType;
import org.wfc.common.security.annotation.RequiresPermissions;
import org.wfc.payment.domain.CreditCard;
import org.wfc.payment.domain.PaymentRequest;
import org.wfc.payment.service.ICreditCardService;
import org.springframework.http.ResponseEntity;
import org.wfc.common.core.constant.HttpStatus;
/**
* Credit card pay controller
*
* @author simon
*/
@RestController
@RequestMapping("/payment")
public class CreditCardController extends BaseController
{
@Autowired
private ICreditCardService ccPayService;
@PostMapping("/creditCard")
public ResponseEntity<String> processPayment(@RequestBody PaymentRequest paymentRequest) {
// 调用支付服务处理支付请求
boolean paymentResult = ccPayService.processPayment(paymentRequest);
if (paymentResult) {
return ResponseEntity.ok("Payment successful");
} else {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Payment failed");
}
}
/**
* 根据参数编号获取详细信息
*/
@GetMapping(value = "/{userId}")
public AjaxResult getInfo(@PathVariable Long userId)
{
return success(ccPayService.selectCreditCardInfoByUserId(userId));
}
/**
* 新增参数配置
*/
@RequiresPermissions("payment:creditCard:add")
@Log(title = "参数管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody CreditCard creditCardInfo)
{
return toAjax(ccPayService.insertCreditCardInfo(creditCardInfo));
}
/**
* 修改参数配置
*/
@RequiresPermissions("pay:creditCard:edit")
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody CreditCard creditCardInfo)
{
return toAjax(ccPayService.updateCreditCardInfo(creditCardInfo));
}
/**
* 删除参数配置
*/
@RequiresPermissions("pay:creditCard:remove")
@Log(title = "参数管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{id}")
public AjaxResult remove(@PathVariable Long id)
{
ccPayService.deleteCreditCardInfoById(id);
return success();
}
}

View File

@@ -1,73 +0,0 @@
package org.wfc.payment.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.wfc.common.core.web.controller.BaseController;
import org.wfc.common.core.web.domain.AjaxResult;
import org.wfc.common.log.annotation.Log;
import org.wfc.common.log.enums.BusinessType;
import org.wfc.common.security.annotation.RequiresPermissions;
import org.wfc.payment.domain.PayPal;
import org.wfc.payment.service.IPayPalService;
/**
* Paypal controller
*
* @author wfc
*/
@RestController
@RequestMapping("/paypal")
public class PayPalController extends BaseController
{
@Autowired
private IPayPalService paypalService;
/**
* PayPal
*/
@RequiresPermissions("payment:paypalInfo:query")
@Log(title = "paypal info management", businessType = BusinessType.OTHER)
@GetMapping("/{userId}")
public AjaxResult query(@PathVariable Long userId) {
return success(paypalService.selectPayPalInfoByUserId(userId));
}
/**
* PayPal
*/
@RequiresPermissions("payment:paypalInfo:add")
@Log(title = "paypal info management", businessType = BusinessType.INSERT)
@PostMapping("/{paypal}")
public AjaxResult add(@PathVariable PayPal paypal)
{
return toAjax(paypalService.insertPayPalInfo(paypal));
}
/**
* PayPal
*/
@RequiresPermissions("payment:paypalInfo:edit")
@Log(title = "paypal info management", businessType = BusinessType.UPDATE)
@PutMapping("/{id}")
public AjaxResult edit(@PathVariable Long id) {
return toAjax(paypalService.updatePayPalInfoById(id));
}
/**
* PayPal
*/
@RequiresPermissions("payment:paypalInfo:remove")
@Log(title = "paypal info management", businessType = BusinessType.DELETE)
@DeleteMapping("/{id}")
public AjaxResult remove(@PathVariable Long id) {
paypalService.deletePayPalInfoById(id);
return success();
}
}

View File

@@ -1,37 +0,0 @@
package org.wfc.payment.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.wfc.common.core.web.controller.BaseController;
import org.wfc.common.core.web.domain.AjaxResult;
import org.wfc.common.log.annotation.Log;
import org.wfc.common.log.enums.BusinessType;
import org.wfc.common.security.annotation.RequiresPermissions;
import org.wfc.payment.domain.WxPay;
import org.wfc.payment.service.IWxPayService;
import org.wfc.payment.service.impl.WWxPayServiceImpl;
import org.springframework.web.bind.annotation.RequestBody;
import com.github.binarywang.wxpay.exception.WxPayException;
// import com.github.binarywang.wxpay.service.WxPayService;
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
import com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse;
@RestController
@RequestMapping("/wxpay")
public class WxPayController extends BaseController {
@Autowired
private IWxPayService wxPayService;
@PostMapping("/notify")
public String payNotify(@RequestBody String xmlData) throws WxPayException {
WxPayOrderNotifyResult result = wxPayService.parseOrderNotifyResult(xmlData);
// 处理支付结果
return WxPayNotifyResponse.success("WeChat pay successfully");
}
}

View File

@@ -1,256 +0,0 @@
package org.wfc.payment.domain;
import org.wfc.common.core.web.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
/**
* 菜单权限表 sys_menu
*
* @author wfc
*/
public class AliPay extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 菜单ID */
private Long menuId;
/** 菜单名称 */
private String menuName;
/** 父菜单名称 */
private String parentName;
/** 父菜单ID */
private Long parentId;
/** 显示顺序 */
private Integer orderNum;
/** 路由地址 */
private String path;
/** 组件路径 */
private String component;
/** 路由参数 */
private String query;
/** 是否为外链0是 1否 */
private String isFrame;
/** 是否缓存0缓存 1不缓存 */
private String isCache;
/** 类型M目录 C菜单 F按钮 */
private String menuType;
/** 显示状态0显示 1隐藏 */
private String visible;
/** 菜单状态0正常 1停用 */
private String status;
/** 权限字符串 */
private String perms;
/** 菜单图标 */
private String icon;
/** 菜单key */
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Long getMenuId()
{
return menuId;
}
public void setMenuId(Long menuId)
{
this.menuId = menuId;
}
@NotBlank(message = "菜单名称不能为空")
@Size(min = 0, max = 50, message = "菜单名称长度不能超过50个字符")
public String getMenuName()
{
return menuName;
}
public void setMenuName(String menuName)
{
this.menuName = menuName;
}
public String getParentName()
{
return parentName;
}
public void setParentName(String parentName)
{
this.parentName = parentName;
}
public Long getParentId()
{
return parentId;
}
public void setParentId(Long parentId)
{
this.parentId = parentId;
}
@NotNull(message = "显示顺序不能为空")
public Integer getOrderNum()
{
return orderNum;
}
public void setOrderNum(Integer orderNum)
{
this.orderNum = orderNum;
}
@Size(min = 0, max = 200, message = "路由地址不能超过200个字符")
public String getPath()
{
return path;
}
public void setPath(String path)
{
this.path = path;
}
@Size(min = 0, max = 200, message = "组件路径不能超过255个字符")
public String getComponent()
{
return component;
}
public void setComponent(String component)
{
this.component = component;
}
public String getQuery()
{
return query;
}
public void setQuery(String query)
{
this.query = query;
}
public String getIsFrame()
{
return isFrame;
}
public void setIsFrame(String isFrame)
{
this.isFrame = isFrame;
}
public String getIsCache()
{
return isCache;
}
public void setIsCache(String isCache)
{
this.isCache = isCache;
}
@NotBlank(message = "菜单类型不能为空")
public String getMenuType()
{
return menuType;
}
public void setMenuType(String menuType)
{
this.menuType = menuType;
}
public String getVisible()
{
return visible;
}
public void setVisible(String visible)
{
this.visible = visible;
}
public String getStatus()
{
return status;
}
public void setStatus(String status)
{
this.status = status;
}
@Size(min = 0, max = 100, message = "权限标识长度不能超过100个字符")
public String getPerms()
{
return perms;
}
public void setPerms(String perms)
{
this.perms = perms;
}
public String getIcon()
{
return icon;
}
public void setIcon(String icon)
{
this.icon = icon;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("menuId", getMenuId())
.append("menuName", getMenuName())
.append("parentId", getParentId())
.append("orderNum", getOrderNum())
.append("path", getPath())
.append("component", getComponent())
.append("isFrame", getIsFrame())
.append("IsCache", getIsCache())
.append("menuType", getMenuType())
.append("visible", getVisible())
.append("status ", getStatus())
.append("perms", getPerms())
.append("icon", getIcon())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.append("name", getName())
.toString();
}
}

View File

@@ -1,111 +0,0 @@
package org.wfc.payment.domain;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.wfc.common.core.annotation.Excel;
import org.wfc.common.core.annotation.Excel.ColumnType;
import org.wfc.common.core.web.domain.BaseEntity;
/**
* 参数配置表 sys_config
*
* @author wfc
*/
public class CreditCard extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 参数主键 */
@Excel(name = "参数主键", cellType = ColumnType.NUMERIC)
private Long configId;
/** 参数名称 */
@Excel(name = "参数名称")
private String configName;
/** 参数键名 */
@Excel(name = "参数键名")
private String configKey;
/** 参数键值 */
@Excel(name = "参数键值")
private String configValue;
/** 系统内置Y是 N否 */
@Excel(name = "系统内置", readConverterExp = "Y=是,N=否")
private String configType;
public Long getConfigId()
{
return configId;
}
public void setConfigId(Long configId)
{
this.configId = configId;
}
@NotBlank(message = "参数名称不能为空")
@Size(min = 0, max = 100, message = "参数名称不能超过100个字符")
public String getConfigName()
{
return configName;
}
public void setConfigName(String configName)
{
this.configName = configName;
}
@NotBlank(message = "参数键名长度不能为空")
@Size(min = 0, max = 100, message = "参数键名长度不能超过100个字符")
public String getConfigKey()
{
return configKey;
}
public void setConfigKey(String configKey)
{
this.configKey = configKey;
}
@NotBlank(message = "参数键值不能为空")
@Size(min = 0, max = 500, message = "参数键值长度不能超过500个字符")
public String getConfigValue()
{
return configValue;
}
public void setConfigValue(String configValue)
{
this.configValue = configValue;
}
public String getConfigType()
{
return configType;
}
public void setConfigType(String configType)
{
this.configType = configType;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("configId", getConfigId())
.append("configName", getConfigName())
.append("configKey", getConfigKey())
.append("configValue", getConfigValue())
.append("configType", getConfigType())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.toString();
}
}

View File

@@ -1,256 +0,0 @@
package org.wfc.payment.domain;
import org.wfc.common.core.web.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
/**
* 菜单权限表 sys_menu
*
* @author wfc
*/
public class PayPal extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 菜单ID */
private Long menuId;
/** 菜单名称 */
private String menuName;
/** 父菜单名称 */
private String parentName;
/** 父菜单ID */
private Long parentId;
/** 显示顺序 */
private Integer orderNum;
/** 路由地址 */
private String path;
/** 组件路径 */
private String component;
/** 路由参数 */
private String query;
/** 是否为外链0是 1否 */
private String isFrame;
/** 是否缓存0缓存 1不缓存 */
private String isCache;
/** 类型M目录 C菜单 F按钮 */
private String menuType;
/** 显示状态0显示 1隐藏 */
private String visible;
/** 菜单状态0正常 1停用 */
private String status;
/** 权限字符串 */
private String perms;
/** 菜单图标 */
private String icon;
/** 菜单key */
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Long getMenuId()
{
return menuId;
}
public void setMenuId(Long menuId)
{
this.menuId = menuId;
}
@NotBlank(message = "菜单名称不能为空")
@Size(min = 0, max = 50, message = "菜单名称长度不能超过50个字符")
public String getMenuName()
{
return menuName;
}
public void setMenuName(String menuName)
{
this.menuName = menuName;
}
public String getParentName()
{
return parentName;
}
public void setParentName(String parentName)
{
this.parentName = parentName;
}
public Long getParentId()
{
return parentId;
}
public void setParentId(Long parentId)
{
this.parentId = parentId;
}
@NotNull(message = "显示顺序不能为空")
public Integer getOrderNum()
{
return orderNum;
}
public void setOrderNum(Integer orderNum)
{
this.orderNum = orderNum;
}
@Size(min = 0, max = 200, message = "路由地址不能超过200个字符")
public String getPath()
{
return path;
}
public void setPath(String path)
{
this.path = path;
}
@Size(min = 0, max = 200, message = "组件路径不能超过255个字符")
public String getComponent()
{
return component;
}
public void setComponent(String component)
{
this.component = component;
}
public String getQuery()
{
return query;
}
public void setQuery(String query)
{
this.query = query;
}
public String getIsFrame()
{
return isFrame;
}
public void setIsFrame(String isFrame)
{
this.isFrame = isFrame;
}
public String getIsCache()
{
return isCache;
}
public void setIsCache(String isCache)
{
this.isCache = isCache;
}
@NotBlank(message = "菜单类型不能为空")
public String getMenuType()
{
return menuType;
}
public void setMenuType(String menuType)
{
this.menuType = menuType;
}
public String getVisible()
{
return visible;
}
public void setVisible(String visible)
{
this.visible = visible;
}
public String getStatus()
{
return status;
}
public void setStatus(String status)
{
this.status = status;
}
@Size(min = 0, max = 100, message = "权限标识长度不能超过100个字符")
public String getPerms()
{
return perms;
}
public void setPerms(String perms)
{
this.perms = perms;
}
public String getIcon()
{
return icon;
}
public void setIcon(String icon)
{
this.icon = icon;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("menuId", getMenuId())
.append("menuName", getMenuName())
.append("parentId", getParentId())
.append("orderNum", getOrderNum())
.append("path", getPath())
.append("component", getComponent())
.append("isFrame", getIsFrame())
.append("IsCache", getIsCache())
.append("menuType", getMenuType())
.append("visible", getVisible())
.append("status ", getStatus())
.append("perms", getPerms())
.append("icon", getIcon())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.append("name", getName())
.toString();
}
}

View File

@@ -1,65 +0,0 @@
package org.wfc.payment.domain;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.wfc.common.core.annotation.Excel;
import org.wfc.common.core.annotation.Excel.ColumnType;
import org.wfc.common.core.web.domain.BaseEntity;
/**
* 参数配置表 sys_config
*
* @author wfc
*/
public class PaymentRequest extends BaseEntity {
private String cardNumber;
private String cardHolderName;
private String expirationDate;
private String cvv;
private int amount; // 以分为单位
// Getters and Setters
public String getCardNumber() {
return cardNumber;
}
public void setCardNumber(String cardNumber) {
this.cardNumber = cardNumber;
}
public String getCardHolderName() {
return cardHolderName;
}
public void setCardHolderName(String cardHolderName) {
this.cardHolderName = cardHolderName;
}
public String getExpirationDate() {
return expirationDate;
}
public void setExpirationDate(String expirationDate) {
this.expirationDate = expirationDate;
}
public String getCvv() {
return cvv;
}
public void setCvv(String cvv) {
this.cvv = cvv;
}
public int getAmount() {
return amount;
}
public void setAmount(int amount) {
this.amount = amount;
}
}

View File

@@ -1,256 +0,0 @@
package org.wfc.payment.domain;
import org.wfc.common.core.web.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
/**
* 菜单权限表 sys_menu
*
* @author wfc
*/
public class WxPay extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 菜单ID */
private Long menuId;
/** 菜单名称 */
private String menuName;
/** 父菜单名称 */
private String parentName;
/** 父菜单ID */
private Long parentId;
/** 显示顺序 */
private Integer orderNum;
/** 路由地址 */
private String path;
/** 组件路径 */
private String component;
/** 路由参数 */
private String query;
/** 是否为外链0是 1否 */
private String isFrame;
/** 是否缓存0缓存 1不缓存 */
private String isCache;
/** 类型M目录 C菜单 F按钮 */
private String menuType;
/** 显示状态0显示 1隐藏 */
private String visible;
/** 菜单状态0正常 1停用 */
private String status;
/** 权限字符串 */
private String perms;
/** 菜单图标 */
private String icon;
/** 菜单key */
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Long getMenuId()
{
return menuId;
}
public void setMenuId(Long menuId)
{
this.menuId = menuId;
}
@NotBlank(message = "菜单名称不能为空")
@Size(min = 0, max = 50, message = "菜单名称长度不能超过50个字符")
public String getMenuName()
{
return menuName;
}
public void setMenuName(String menuName)
{
this.menuName = menuName;
}
public String getParentName()
{
return parentName;
}
public void setParentName(String parentName)
{
this.parentName = parentName;
}
public Long getParentId()
{
return parentId;
}
public void setParentId(Long parentId)
{
this.parentId = parentId;
}
@NotNull(message = "显示顺序不能为空")
public Integer getOrderNum()
{
return orderNum;
}
public void setOrderNum(Integer orderNum)
{
this.orderNum = orderNum;
}
@Size(min = 0, max = 200, message = "路由地址不能超过200个字符")
public String getPath()
{
return path;
}
public void setPath(String path)
{
this.path = path;
}
@Size(min = 0, max = 200, message = "组件路径不能超过255个字符")
public String getComponent()
{
return component;
}
public void setComponent(String component)
{
this.component = component;
}
public String getQuery()
{
return query;
}
public void setQuery(String query)
{
this.query = query;
}
public String getIsFrame()
{
return isFrame;
}
public void setIsFrame(String isFrame)
{
this.isFrame = isFrame;
}
public String getIsCache()
{
return isCache;
}
public void setIsCache(String isCache)
{
this.isCache = isCache;
}
@NotBlank(message = "菜单类型不能为空")
public String getMenuType()
{
return menuType;
}
public void setMenuType(String menuType)
{
this.menuType = menuType;
}
public String getVisible()
{
return visible;
}
public void setVisible(String visible)
{
this.visible = visible;
}
public String getStatus()
{
return status;
}
public void setStatus(String status)
{
this.status = status;
}
@Size(min = 0, max = 100, message = "权限标识长度不能超过100个字符")
public String getPerms()
{
return perms;
}
public void setPerms(String perms)
{
this.perms = perms;
}
public String getIcon()
{
return icon;
}
public void setIcon(String icon)
{
this.icon = icon;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("menuId", getMenuId())
.append("menuName", getMenuName())
.append("parentId", getParentId())
.append("orderNum", getOrderNum())
.append("path", getPath())
.append("component", getComponent())
.append("isFrame", getIsFrame())
.append("IsCache", getIsCache())
.append("menuType", getMenuType())
.append("visible", getVisible())
.append("status ", getStatus())
.append("perms", getPerms())
.append("icon", getIcon())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.append("name", getName())
.toString();
}
}

View File

@@ -1,106 +0,0 @@
package org.wfc.payment.domain.vo;
import org.wfc.common.core.utils.StringUtils;
/**
* 路由显示信息
*
* @author wfc
*/
public class MetaVo
{
/**
* 设置该路由在侧边栏和面包屑中展示的名字
*/
private String title;
/**
* 设置该路由的图标对应路径src/assets/icons/sv
*/
private String icon;
/**
* 设置为true则不会被 <keep-alive>缓存
*/
private boolean noCache;
/**
* 内链地址http(s)://开头)
*/
private String link;
public MetaVo()
{
}
public MetaVo(String title, String icon)
{
this.title = title;
this.icon = icon;
}
public MetaVo(String title, String icon, boolean noCache)
{
this.title = title;
this.icon = icon;
this.noCache = noCache;
}
public MetaVo(String title, String icon, String link)
{
this.title = title;
this.icon = icon;
this.link = link;
}
public MetaVo(String title, String icon, boolean noCache, String link)
{
this.title = title;
this.icon = icon;
this.noCache = noCache;
if (StringUtils.ishttp(link))
{
this.link = link;
}
}
public boolean isNoCache()
{
return noCache;
}
public void setNoCache(boolean noCache)
{
this.noCache = noCache;
}
public String getTitle()
{
return title;
}
public void setTitle(String title)
{
this.title = title;
}
public String getIcon()
{
return icon;
}
public void setIcon(String icon)
{
this.icon = icon;
}
public String getLink()
{
return link;
}
public void setLink(String link)
{
this.link = link;
}
}

View File

@@ -1,148 +0,0 @@
package org.wfc.payment.domain.vo;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.List;
/**
* 路由配置信息
*
* @author wfc
*/
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class RouterVo
{
/**
* 路由名字
*/
private String name;
/**
* 路由地址
*/
private String path;
/**
* 是否隐藏路由,当设置 true 的时候该路由不会再侧边栏出现
*/
private boolean hideInMenu;
/**
* 重定向地址,当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
*/
private String redirect;
/**
* 组件地址
*/
private String component;
/**
* 路由参数:如 {"id": 1, "name": "ry"}
*/
private String query;
/**
* 当你一个路由下面的 children 声明的路由大于1个时自动会变成嵌套的模式--如组件页面
*/
private Boolean alwaysShow;
/**
* 其他元素
*/
private MetaVo meta;
/**
* 子路由
*/
private List<RouterVo> children;
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public String getPath()
{
return path;
}
public void setPath(String path)
{
this.path = path;
}
public boolean getHideInMenu()
{
return hideInMenu;
}
public void setHideInMenu(boolean hideInMenu)
{
this.hideInMenu = hideInMenu;
}
public String getRedirect()
{
return redirect;
}
public void setRedirect(String redirect)
{
this.redirect = redirect;
}
public String getComponent()
{
return component;
}
public void setComponent(String component)
{
this.component = component;
}
public String getQuery()
{
return query;
}
public void setQuery(String query)
{
this.query = query;
}
public Boolean getAlwaysShow()
{
return alwaysShow;
}
public void setAlwaysShow(Boolean alwaysShow)
{
this.alwaysShow = alwaysShow;
}
public MetaVo getMeta()
{
return meta;
}
public void setMeta(MetaVo meta)
{
this.meta = meta;
}
public List<RouterVo> getChildren()
{
return children;
}
public void setChildren(List<RouterVo> children)
{
this.children = children;
}
}

View File

@@ -1,60 +0,0 @@
package org.wfc.payment.domain.vo;
import java.io.Serializable;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonInclude;
/**
* Treeselect树结构实体类
*
* @author wfc
*/
public class TreeSelect implements Serializable
{
private static final long serialVersionUID = 1L;
/** 节点ID */
private Long id;
/** 节点名称 */
private String label;
/** 子节点 */
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<TreeSelect> children;
public TreeSelect()
{
}
public Long getId()
{
return id;
}
public void setId(Long id)
{
this.id = id;
}
public String getLabel()
{
return label;
}
public void setLabel(String label)
{
this.label = label;
}
public List<TreeSelect> getChildren()
{
return children;
}
public void setChildren(List<TreeSelect> children)
{
this.children = children;
}
}

View File

@@ -1,43 +0,0 @@
package org.wfc.payment.mapper;
import org.wfc.payment.domain.AliPay;
/**
* Paypal mapper
*
* @author wfc
*/
public interface AliPayMapper
{
/**
* select alipay info by user id
*
* @param userId user id
* @return alipay information
*/
public AliPay selectAliPayInfoByUserId(Long userId);
/**
* select AliPay pay information by user ID
*
* @param userId user ID
* @return AliPay pay information
*/
public int insertAliPayInfo(AliPay alipay);
/**
* select AliPay pay information by user ID
*
* @param userId user ID
* @return AliPay pay information
*/
public int updateAliPayInfoById(Long id);
/**
* select AliPay pay information by user ID
*
* @param userId user ID
* @return AliPay pay information
*/
public void deleteAliPayInfoById(Long id);
}

View File

@@ -1,44 +0,0 @@
package org.wfc.payment.mapper;
import java.util.List;
import org.wfc.payment.domain.CreditCard;
/**
* 参数配置 数据层
*
* @author simon
*/
public interface CreditCardMapper
{
/**
* 通过ID查询配置
*
* @param id 参数ID
* @return 参数配置信息
*/
public CreditCard selectCreditCardInfoByUserId(Long id);
/**
* 新增参数配置
*
* @param creditCard 参数配置信息
* @return 结果
*/
public int insertCreditCardInfo(CreditCard creditCard);
/**
* 修改参数配置
*
* @param creditCard 参数配置信息
* @return 结果
*/
public int updateCreditCardInfo(CreditCard creditCard);
/**
* 删除参数配置
*
* @param id 参数ID
* @return 结果
*/
public void deleteCreditCardInfoById(Long id);
}

View File

@@ -1,43 +0,0 @@
package org.wfc.payment.mapper;
import org.wfc.payment.domain.PayPal;
/**
* Paypal mapper
*
* @author wfc
*/
public interface PayPalMapper
{
/**
* select paypal info by user id
*
* @param userId user id
* @return paypal information
*/
public PayPal selectPayPalInfoByUserId(Long userId);
/**
* select PayPal pay information by user ID
*
* @param userId user ID
* @return PayPal pay information
*/
public int insertPayPalInfo(PayPal paypal);
/**
* select PayPal pay information by user ID
*
* @param userId user ID
* @return PayPal pay information
*/
public int updatePayPalInfoById(Long id);
/**
* select PayPal pay information by user ID
*
* @param userId user ID
* @return PayPal pay information
*/
public void deletePayPalInfoById(Long id);
}

View File

@@ -1,43 +0,0 @@
package org.wfc.payment.mapper;
import org.wfc.payment.domain.WxPay;
/**
* Paypal mapper
*
* @author wfc
*/
public interface WxPayMapper
{
/**
* select wxpay info by user id
*
* @param userId user id
* @return wxpay information
*/
public WxPay selectWxPayInfoByUserId(Long userId);
/**
* select WxPay pay information by user ID
*
* @param userId user ID
* @return WxPay pay information
*/
public int insertWxPayInfo(WxPay wxpay);
/**
* select WxPay pay information by user ID
*
* @param userId user ID
* @return WxPay pay information
*/
public int updateWxPayInfoById(Long id);
/**
* select WxPay pay information by user ID
*
* @param userId user ID
* @return WxPay pay information
*/
public void deleteWxPayInfoById(Long id);
}

View File

@@ -1,43 +0,0 @@
package org.wfc.payment.service;
import org.wfc.payment.domain.AliPay;
/**
* Paypal pay service layer
*
* @author wfc
*/
public interface IAliPayService
{
/**
* select AliPay pay information by user ID
*
* @param userId user ID
* @return AliPay pay information
*/
public AliPay selectAliPayInfoByUserId(Long userId);
/**
* select AliPay pay information by user ID
*
* @param userId user ID
* @return AliPay pay information
*/
public int insertAliPayInfo(AliPay alipay);
/**
* select AliPay pay information by user ID
*
* @param userId user ID
* @return AliPay pay information
*/
public int updateAliPayInfoById(Long id);
/**
* select AliPay pay information by user ID
*
* @param userId user ID
* @return AliPay pay information
*/
public void deleteAliPayInfoById(Long id);
}

View File

@@ -1,46 +0,0 @@
package org.wfc.payment.service;
import org.wfc.payment.domain.CreditCard;
import org.wfc.payment.domain.PaymentRequest;
/**
* Credit card pay service layer
*
* @author wfc
*/
public interface ICreditCardService
{
public boolean processPayment(PaymentRequest paymentRequest);
/**
* select credit card information
*
* @param userId User ID
* @return Credit card info
*/
public CreditCard selectCreditCardInfoByUserId(Long userId);
/**
* insert credit card
*
* @param creditCard User ID
* @return Credit card info
*/
public int insertCreditCardInfo(CreditCard creditCard);
/**
* update credit card
*
* @param creditCard User ID
* @return Credit card info
*/
public int updateCreditCardInfo(CreditCard creditCard);
/**
* update credit card
*
* @param creditCard User ID
* @return void
*/
public void deleteCreditCardInfoById(Long id);
}

View File

@@ -1,43 +0,0 @@
package org.wfc.payment.service;
import org.wfc.payment.domain.PayPal;
/**
* Paypal pay service layer
*
* @author wfc
*/
public interface IPayPalService
{
/**
* select PayPal pay information by user ID
*
* @param userId user ID
* @return PayPal pay information
*/
public PayPal selectPayPalInfoByUserId(Long userId);
/**
* select PayPal pay information by user ID
*
* @param userId user ID
* @return PayPal pay information
*/
public int insertPayPalInfo(PayPal paypal);
/**
* select PayPal pay information by user ID
*
* @param userId user ID
* @return PayPal pay information
*/
public int updatePayPalInfoById(Long id);
/**
* select PayPal pay information by user ID
*
* @param userId user ID
* @return PayPal pay information
*/
public void deletePayPalInfoById(Long id);
}

View File

@@ -1,11 +0,0 @@
package org.wfc.payment.service;
import java.math.BigDecimal;
import org.wfc.payment.domain.WxPay;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.bean.result.WxPayUnifiedOrderResult;
import com.github.binarywang.wxpay.service.WxPayService;
public interface IWxPayService extends WxPayService {
public WxPayUnifiedOrderResult createOrder(String orderId, BigDecimal amount) throws WxPayException;
}

View File

@@ -1,63 +0,0 @@
package org.wfc.payment.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.wfc.payment.mapper.AliPayMapper;
import org.wfc.payment.service.IAliPayService;
import org.wfc.payment.domain.AliPay;
/**
* AliPay service implementation
*
* @author wfc
*/
@Service
public class AliPayServiceImpl implements IAliPayService
{
@Autowired
private AliPayMapper alipayMapper;
/**
* Select Paypal information by user ID
*
* @param userId user ID
* @return 结果
*/
@Override
public AliPay selectAliPayInfoByUserId(Long userId) {
return alipayMapper.selectAliPayInfoByUserId(userId);
}
/**
* Select Paypal information by user ID
*
* @param userId user ID
* @return 结果
*/
@Override
public int insertAliPayInfo(AliPay alipay) {
return alipayMapper.insertAliPayInfo(alipay);
}
/**
* Select Paypal information by user ID
*
* @param userId user ID
* @return 结果
*/
@Override
public int updateAliPayInfoById(Long id) {
return alipayMapper.updateAliPayInfoById(id);
}
/**
* update credit card
*
* @param creditCard User ID
* @return void
*/
@Override
public void deleteAliPayInfoById(Long id) {
alipayMapper.deleteAliPayInfoById(id);
}
}

View File

@@ -1,103 +0,0 @@
package org.wfc.payment.service.impl;
import java.util.Collection;
import java.util.List;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.wfc.common.core.constant.CacheConstants;
import org.wfc.common.core.constant.UserConstants;
import org.wfc.common.core.exception.ServiceException;
import org.wfc.common.core.text.Convert;
import org.wfc.common.core.utils.StringUtils;
import org.wfc.common.redis.service.RedisService;
import org.wfc.payment.domain.CreditCard;
import org.wfc.payment.domain.PaymentRequest;
import org.wfc.payment.mapper.CreditCardMapper;
import org.wfc.payment.service.ICreditCardService;
import java.util.HashMap;
import java.util.Map;
import com.stripe.Stripe;
import com.stripe.model.Charge;
import com.stripe.exception.StripeException;
import com.stripe.param.ChargeCreateParams;
import org.springframework.beans.factory.annotation.Autowired;
/**
* 参数配置 服务层实现
*
* @author wfc
*/
@Service
public class CreditCardServiceImpl implements ICreditCardService
{
@Autowired
private CreditCardMapper creditCardMapper;
public void SetStripeApiKey(String apiKey) {
Stripe.apiKey = apiKey;
}
@Override
public boolean processPayment(PaymentRequest paymentRequest) {
ChargeCreateParams params = ChargeCreateParams.builder()
.setAmount((long) paymentRequest.getAmount())
.setCurrency("usd")
.setSource(paymentRequest.getCardNumber()) // 这里假设前端传递的是支付令牌
.setDescription("Charge for " + paymentRequest.getCardHolderName())
.build();
try {
Charge charge = Charge.create(params);
return charge.getPaid();
} catch (StripeException e) {
e.printStackTrace();
return false;
}
}
/**
* 查询参数置信息
*
* @param creditCardId 参数配置ID
* @return 参数配置信息
*/
public CreditCard selectCreditCardInfoByUserId(Long userId)
{
//CreditCard creditCardInfo = new CreditCard();
return creditCardMapper.selectCreditCardInfoByUserId(userId);
}
/**
* 新增参数配置
*
* @param creditCard 参数配置信息
* @return 结果
*/
public int insertCreditCardInfo(CreditCard creditCard)
{
int row = creditCardMapper.insertCreditCardInfo(creditCard);
return row;
}
/**
* 修改参数配置
*
* @param creditCard 参数配置信息
* @return 结果
*/
public int updateCreditCardInfo(CreditCard creditCard)
{
int row = creditCardMapper.updateCreditCardInfo(creditCard);
return row;
}
/**
* 删除参数信息
*
* @param id 需要删除的参数ID
*/
public void deleteCreditCardInfoById(Long id)
{
creditCardMapper.deleteCreditCardInfoById(id);
}
}

View File

@@ -1,63 +0,0 @@
package org.wfc.payment.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.wfc.payment.mapper.PayPalMapper;
import org.wfc.payment.service.IPayPalService;
import org.wfc.payment.domain.PayPal;
/**
* PayPal service implementation
*
* @author wfc
*/
@Service
public class PayPalServiceImpl implements IPayPalService
{
@Autowired
private PayPalMapper paypalMapper;
/**
* Select Paypal information by user ID
*
* @param userId user ID
* @return 结果
*/
@Override
public PayPal selectPayPalInfoByUserId(Long userId) {
return paypalMapper.selectPayPalInfoByUserId(userId);
}
/**
* Select Paypal information by user ID
*
* @param userId user ID
* @return 结果
*/
@Override
public int insertPayPalInfo(PayPal paypal) {
return paypalMapper.insertPayPalInfo(paypal);
}
/**
* Select Paypal information by user ID
*
* @param userId user ID
* @return 结果
*/
@Override
public int updatePayPalInfoById(Long id) {
return paypalMapper.updatePayPalInfoById(id);
}
/**
* update credit card
*
* @param creditCard User ID
* @return void
*/
@Override
public void deletePayPalInfoById(Long id) {
paypalMapper.deletePayPalInfoById(id);
}
}

View File

@@ -1,95 +0,0 @@
package org.wfc.payment.service.impl;
import java.math.BigDecimal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.wfc.payment.config.WWxPayConfig;
import org.wfc.payment.service.IWxPayService;
import com.github.binarywang.wxpay.bean.request.BaseWxPayRequest;
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
import com.github.binarywang.wxpay.bean.result.WxPayUnifiedOrderResult;
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
import com.github.binarywang.wxpay.bean.notify.ComplaintNotifyResult;
import com.github.binarywang.wxpay.bean.notify.SignatureHeader;
import com.github.binarywang.wxpay.bean.result.WxPayQueryExchangeRateResult;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.service.PartnerPayScoreSignPlanService;
import com.github.binarywang.wxpay.service.PartnerPayScoreService;
import com.github.binarywang.wxpay.service.TransferService;
import com.github.binarywang.wxpay.service.WxPayService;
import com.github.binarywang.wxpay.service.BankService;
import com.github.binarywang.wxpay.service.ComplaintService;
@Service
public class WWxPayServiceImpl implements WxPayService {
@Autowired
private WWxPayConfig config;
private WxPayService wxPayService;
@Autowired
public WWxPayServiceImpl(WWxPayConfig config, WxPayService wxPayService) {
this.config = config;
this.wxPayService = wxPayService;
}
public WxPayUnifiedOrderResult createOrder(String orderId, BigDecimal amount) throws WxPayException {
WxPayUnifiedOrderRequest request = new WxPayUnifiedOrderRequest();
request.setOutTradeNo(orderId);
request.setTotalFee(BaseWxPayRequest.yuanToFen(amount.toString()));
request.setBody("Order Payment");
request.setTradeType("JSAPI");
request.setNotifyUrl("https://wfc-modules-payment:/wxpay/notify");
return wxPayService.unifiedOrder(request);
}
@Override
public WxPayOrderNotifyResult parseOrderNotifyResult(String xmlData) throws WxPayException {
// Implement the method logic here
return null;
}
@Override
public PartnerPayScoreSignPlanService getPartnerPayScoreSignPlanService() {
// Implement the method logic here
return null;
}
@Override
public PartnerPayScoreService getPartnerPayScoreService() {
// Implement the method logic here
return null;
}
@Override
public TransferService getTransferService() {
// Implement the method logic here
return null;
}
@Override
public BankService getBankService() {
// Implement the method logic here
return null;
}
@Override
public ComplaintService getComplaintsService() {
// Implement the method logic here
return null;
}
@Override
public ComplaintNotifyResult parseComplaintNotifyResult(String xmlData, SignatureHeader header) throws WxPayException {
// Implement the method logic here
return null;
}
@Override
public WxPayQueryExchangeRateResult queryExchangeRate(String fromCurrency, String toCurrency) throws WxPayException {
// Implement the method logic here
return null;
}
// Implement other methods from WxPayService interface as needed
}

View File

@@ -9,7 +9,10 @@ import org.springframework.core.env.Environment;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import org.springdoc.core.GroupedOpenApi;
@Configuration
@@ -33,47 +36,11 @@ public class SwaggerConfig extends WebMvcConfigurationSupport implements Environ
super.addResourceHandlers(registry);
}
// @Bean
// public Docket docket() {
// //最重要的就是这里,定义了/test/.*开头的rest接口都分在了test分组里可以通过/v2/api-docs?group=test得到定义的json
// log.info("Starting Swagger");
// StopWatch watch = new StopWatch();
// watch.start();
// Docket docket = new Docket(DocumentationType.SWAGGER_2)
// .groupName("pay")
// .apiInfo(this.apiInfo())
// .select()
// .apis(RequestHandlerSelectors.any())
// .paths(regex("/payment/wxpay/.*"))
// .build();
// watch.stop();
// log.info("Started Swagger in {} ms", watch.getTotalTimeMillis());
// return docket;
// }
// @Bean
// public Docket api() {
// return new Docket(DocumentationType.SWAGGER_2)
// .select()
// .apis(RequestHandlerSelectors.any())
// .paths(PathSelectors.any())
// .build()
// .apiInfo(apiInfo());
// }
// private ApiInfo apiInfo() {
// return new ApiInfoBuilder()
// .title("WeChat Pay API")
// .description("WeChat Pay API for Java")
// .version("1.0.0")
// .build();
// }
@Bean
public GroupedOpenApi publicApi() {
return GroupedOpenApi.builder()
.group("public")
.pathsToMatch("/api/payment/**")
.pathsToMatch("/payment/**")
.packagesToScan("org.wfc.payment.wxpay.controller")
.build();
}
@@ -81,9 +48,13 @@ public class SwaggerConfig extends WebMvcConfigurationSupport implements Environ
@Bean
public OpenAPI customOpenAPI() {
return new OpenAPI()
.openapi("3.0.0")
.info(new Info()
.title("WeChat Pay API")
.version("1.0.0")
.description("WeChat Pay API for Java"));
.description("WeChat Pay API for Java")
.termsOfService("http://swagger.io/terms/")
.contact(new Contact().name("API Support").url("http://www.wfc.vip/support").email("support@wfc.com"))
.license(new License().name("wfc 1.0").url("http://springdoc.org")));
}
}

View File

@@ -9,7 +9,6 @@ import com.github.binarywang.wxpay.bean.request.*;
import com.github.binarywang.wxpay.bean.result.*;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.service.WxPayService;
import org.springdoc.api.annotations.ParameterObject;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
@@ -23,7 +22,7 @@ import java.util.Date;
@Tag(name = "WeChat Pay")
@RestController
@RequestMapping("/payment/wxpay")
@RequestMapping("/wxpay")
@AllArgsConstructor
public class WxPayController {
@Autowired

View File

@@ -1,5 +1,12 @@
# spring配置
spring:
application:
name: wfc-payment
cloud:
nacos:
discovery:
server-addr: ${NACOS_SERVER_ADDR:wfc-nacos}:${NACOS_SERVER_PORT:8848}
namespace: ${NACOS_NAMESPACE:wfc-prod}
main:
allow-bean-definition-overriding: true
@@ -87,3 +94,32 @@ wxpay:
subMchId: #服务商模式下的子商户号
keyPath: /opt/wfc/config/payment/wxpay_key.pem
useSandboxEnv: false
alipay:
appId: 121412414112
privateKey: 1131412414
publicKey: 1525342aa
notifyUrl: http://wfc-gateway:${GATEWAY_SERVER_PORT:8080}/alipay/notify
returnUrl: http://wfc-gateway:${GATEWAY_SERVER_PORT:8080}/alipay/return
signType: RSA2
charset: utf-8
gatewayUrl: https://openapi.alipaydev.com/gateway.do
logPath: /opt/wfc/config/payment/alipay_log.txt
maxQueryRetry: 5
queryDuration: 5
maxCancelRetry: 3
cancelDuration: 2
heartbeatDelay: 5
heartbeatDuration: 5
storeId:
storeName:
supportEmail:
supportPhone:
ccpay:
url: https://api.paymentgateway.com/v1/payments
apiKey: your-api-key
merchantId: your-merchant-id
currency: USD
timeout: 30
callbackUrl: https://yourdomain.com/payment/callback