注销支付宝
parent
4ebcb60f17
commit
14576812ae
|
@ -1,303 +1,303 @@
|
||||||
package com.mcwl.web.controller.pay.AliPay;
|
//package com.mcwl.web.controller.pay.AliPay;
|
||||||
|
//
|
||||||
import cn.hutool.core.lang.UUID;
|
//import cn.hutool.core.lang.UUID;
|
||||||
import cn.hutool.extra.qrcode.QrCodeUtil;
|
//import cn.hutool.extra.qrcode.QrCodeUtil;
|
||||||
import com.alipay.api.domain.AlipayAccount;
|
//import com.alipay.api.domain.AlipayAccount;
|
||||||
import com.alipay.easysdk.factory.Factory;
|
//import com.alipay.easysdk.factory.Factory;
|
||||||
import com.mcwl.common.annotation.Anonymous;
|
//import com.mcwl.common.annotation.Anonymous;
|
||||||
import com.mcwl.common.constant.HttpStatus;
|
//import com.mcwl.common.constant.HttpStatus;
|
||||||
import com.mcwl.common.core.controller.BaseController;
|
//import com.mcwl.common.core.controller.BaseController;
|
||||||
import com.mcwl.common.core.domain.AjaxResult;
|
//import com.mcwl.common.core.domain.AjaxResult;
|
||||||
import com.mcwl.common.core.domain.R;
|
//import com.mcwl.common.core.domain.R;
|
||||||
import com.mcwl.common.core.redis.RedisCache;
|
//import com.mcwl.common.core.redis.RedisCache;
|
||||||
import com.mcwl.common.utils.SecurityUtils;
|
//import com.mcwl.common.utils.SecurityUtils;
|
||||||
import com.mcwl.common.utils.ShareCodeUtils;
|
//import com.mcwl.common.utils.ShareCodeUtils;
|
||||||
import com.mcwl.pay.config.AliConfig;
|
//import com.mcwl.pay.config.AliConfig;
|
||||||
import com.mcwl.pay.domain.OrderTrade;
|
//import com.mcwl.pay.domain.OrderTrade;
|
||||||
import com.mcwl.pay.domain.OrderTradeDto;
|
//import com.mcwl.pay.domain.OrderTradeDto;
|
||||||
import com.mcwl.pay.domain.vo.PayVo;
|
//import com.mcwl.pay.domain.vo.PayVo;
|
||||||
import com.mcwl.pay.service.AliPayService;
|
//import com.mcwl.pay.service.AliPayService;
|
||||||
import com.mcwl.pay.service.OrderTradeService;
|
//import com.mcwl.pay.service.OrderTradeService;
|
||||||
import com.mcwl.system.domain.SysUserPayAccount;
|
//import com.mcwl.system.domain.SysUserPayAccount;
|
||||||
import com.mcwl.system.service.ISysUserPayAccountService;
|
//import com.mcwl.system.service.ISysUserPayAccountService;
|
||||||
import io.swagger.annotations.Api;
|
//import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
//import io.swagger.annotations.ApiOperation;
|
||||||
import org.apache.ibatis.annotations.Param;
|
//import org.apache.ibatis.annotations.Param;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
//import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Controller;
|
//import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.validation.annotation.Validated;
|
//import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
//import org.springframework.web.bind.annotation.*;
|
||||||
|
//
|
||||||
import javax.servlet.http.HttpServletRequest;
|
//import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
//import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.validation.Valid;
|
//import javax.validation.Valid;
|
||||||
import javax.validation.constraints.Min;
|
//import javax.validation.constraints.Min;
|
||||||
import javax.validation.constraints.NotBlank;
|
//import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.NotNull;
|
//import javax.validation.constraints.NotNull;
|
||||||
import javax.validation.constraints.Pattern;
|
//import javax.validation.constraints.Pattern;
|
||||||
import java.io.FileNotFoundException;
|
//import java.io.FileNotFoundException;
|
||||||
import java.net.URLEncoder;
|
//import java.net.URLEncoder;
|
||||||
import java.util.HashMap;
|
//import java.util.HashMap;
|
||||||
import java.util.Map;
|
//import java.util.Map;
|
||||||
import java.util.Objects;
|
//import java.util.Objects;
|
||||||
import java.util.Optional;
|
//import java.util.Optional;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* @Author:ChenYan
|
// * @Author:ChenYan
|
||||||
* @Project:McWl
|
// * @Project:McWl
|
||||||
* @Package:com.mcwl.web.controller.pay
|
// * @Package:com.mcwl.web.controller.pay
|
||||||
* @Filename:OrderTradeController
|
// * @Filename:OrderTradeController
|
||||||
* @Description 支付模块
|
// * @Description 支付模块
|
||||||
* @Date:2025/1/3 14:46
|
// * @Date:2025/1/3 14:46
|
||||||
*/
|
// */
|
||||||
|
//
|
||||||
@Controller
|
//@Controller
|
||||||
@RequestMapping("/ali/pay")
|
//@RequestMapping("/ali/pay")
|
||||||
@Validated
|
//@Validated
|
||||||
@Api(tags = "支付模块")
|
//@Api(tags = "支付模块")
|
||||||
public class AliPayController extends BaseController {
|
//public class AliPayController extends BaseController {
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private OrderTradeService orderTradeService;
|
// private OrderTradeService orderTradeService;
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private ISysUserPayAccountService sysUserPayAccountService;
|
// private ISysUserPayAccountService sysUserPayAccountService;
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private AliPayService aliPayService;
|
// private AliPayService aliPayService;
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private AliConfig aliConfig;
|
// private AliConfig aliConfig;
|
||||||
|
//
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private RedisCache redisCache;
|
// private RedisCache redisCache;
|
||||||
|
//
|
||||||
@Value("${mall.mgt.aliPayConfig.bindUrl}")
|
// @Value("${mall.mgt.aliPayConfig.bindUrl}")
|
||||||
private String bindUrl;
|
// private String bindUrl;
|
||||||
|
//
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 授权二维码
|
// * 授权二维码
|
||||||
*
|
// *
|
||||||
* @param response 响应
|
// * @param response 响应
|
||||||
* @throws Exception 抛出异常
|
// * @throws Exception 抛出异常
|
||||||
*/
|
// */
|
||||||
@ApiOperation(value = "支付宝绑定")
|
// @ApiOperation(value = "支付宝绑定")
|
||||||
@GetMapping("/generateQrCode")
|
// @GetMapping("/generateQrCode")
|
||||||
@ResponseBody
|
// @ResponseBody
|
||||||
public R<String> generateQrCode(HttpServletResponse response) throws Exception {
|
// public R<String> generateQrCode(HttpServletResponse response) throws Exception {
|
||||||
String scope = "auth_user"; // 需要获取用户信息
|
// String scope = "auth_user"; // 需要获取用户信息
|
||||||
String appId = aliConfig.getAppId();
|
// String appId = aliConfig.getAppId();
|
||||||
String state = ShareCodeUtils.idToCode(SecurityUtils.getUserId()); // 防止CSRF攻击
|
// String state = ShareCodeUtils.idToCode(SecurityUtils.getUserId()); // 防止CSRF攻击
|
||||||
|
//
|
||||||
String encodedRedirectUri = URLEncoder.encode(bindUrl, "UTF-8");
|
// String encodedRedirectUri = URLEncoder.encode(bindUrl, "UTF-8");
|
||||||
// 线上
|
// // 线上
|
||||||
|
//// String authUrl = String.format(
|
||||||
|
//// "https://openauth.alipay.com/oauth2/publicAppAuthorize.htm?app_id=%s&scope=%s&redirect_uri=%s&state=%s",
|
||||||
|
//// appId, scope, encodedRedirectUri, state
|
||||||
|
//// );
|
||||||
|
// // 沙箱
|
||||||
// String authUrl = String.format(
|
// String authUrl = String.format(
|
||||||
// "https://openauth.alipay.com/oauth2/publicAppAuthorize.htm?app_id=%s&scope=%s&redirect_uri=%s&state=%s",
|
// "https://openauth-sandbox.dl.alipaydev.com/oauth2/publicAppAuthorize.htm?app_id=%s&scope=%s&redirect_uri=%s&state=%s",
|
||||||
// appId, scope, encodedRedirectUri, state
|
// appId, scope, encodedRedirectUri, state
|
||||||
// );
|
// );
|
||||||
// 沙箱
|
//
|
||||||
String authUrl = String.format(
|
//// QrCodeUtil.generate(authUrl, 300, 300, "png", response.getOutputStream());
|
||||||
"https://openauth-sandbox.dl.alipaydev.com/oauth2/publicAppAuthorize.htm?app_id=%s&scope=%s&redirect_uri=%s&state=%s",
|
// return R.ok(authUrl, "成功");
|
||||||
appId, scope, encodedRedirectUri, state
|
|
||||||
);
|
|
||||||
|
|
||||||
// QrCodeUtil.generate(authUrl, 300, 300, "png", response.getOutputStream());
|
|
||||||
return R.ok(authUrl, "成功");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 支付宝绑定状态查询
|
|
||||||
*/
|
|
||||||
@GetMapping("/queryBindStatus")
|
|
||||||
@ApiOperation(value = "支付宝绑定状态查询")
|
|
||||||
@ResponseBody
|
|
||||||
public R<Object> queryTradeStatus() throws Exception {
|
|
||||||
|
|
||||||
return aliPayService.queryBindStatus();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 授权回调
|
|
||||||
*
|
|
||||||
* @param authCode 授权码
|
|
||||||
*/
|
|
||||||
@GetMapping("/callback")
|
|
||||||
public String callback(@RequestParam("auth_code") String authCode, String state) throws FileNotFoundException {
|
|
||||||
|
|
||||||
System.out.println("authCode = " + authCode);
|
|
||||||
String result = aliPayService.bindingCallback(authCode, state);
|
|
||||||
if ("success".equals(result)) {
|
|
||||||
return "binding-success";
|
|
||||||
} else {
|
|
||||||
return "binding-fail";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * 账户余额查询
|
|
||||||
// */
|
|
||||||
// @GetMapping("/balance")
|
|
||||||
// @ResponseBody
|
|
||||||
// public AjaxResult balance() throws AlipayApiException {
|
|
||||||
// String balance = aliPayService.balance();
|
|
||||||
// return AjaxResult.success(balance);
|
|
||||||
// }
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
/**
|
// * 支付宝绑定状态查询
|
||||||
* 支付接口
|
// */
|
||||||
*
|
// @GetMapping("/queryBindStatus")
|
||||||
* @param orderTradeDto 订单实体
|
// @ApiOperation(value = "支付宝绑定状态查询")
|
||||||
* @param response 响应
|
// @ResponseBody
|
||||||
* @throws Exception
|
// public R<Object> queryTradeStatus() throws Exception {
|
||||||
*/
|
//
|
||||||
@Anonymous
|
// return aliPayService.queryBindStatus();
|
||||||
@PostMapping("/doPay")
|
// }
|
||||||
@ApiOperation(value = "支付宝支付")
|
//
|
||||||
@ResponseBody
|
// /**
|
||||||
public R<PayVo> doPay(@Valid
|
// * 授权回调
|
||||||
@RequestBody
|
// *
|
||||||
OrderTradeDto orderTradeDto,
|
// * @param authCode 授权码
|
||||||
HttpServletResponse response) throws Exception {
|
// */
|
||||||
PayVo payVo = null;
|
// @GetMapping("/callback")
|
||||||
|
// public String callback(@RequestParam("auth_code") String authCode, String state) throws FileNotFoundException {
|
||||||
String type = orderTradeDto.getType();
|
//
|
||||||
|
// System.out.println("authCode = " + authCode);
|
||||||
if ("member".equalsIgnoreCase(type)) {
|
// String result = aliPayService.bindingCallback(authCode, state);
|
||||||
if (!Optional.ofNullable(orderTradeDto.getProductId()).isPresent()) {
|
// if ("success".equals(result)) {
|
||||||
return R.fail(HttpStatus.SHOW_ERROR_MSG,"商品id不能为空");
|
// return "binding-success";
|
||||||
}
|
// } else {
|
||||||
payVo = aliPayService.memberPay(orderTradeDto);
|
// return "binding-fail";
|
||||||
// QrCodeUtil.generate(payVo.getUrl(), 300, 300, "png", response.getOutputStream());
|
// }
|
||||||
} else if ("points".equalsIgnoreCase(type)) {
|
// }
|
||||||
payVo = aliPayService.pointsPay(orderTradeDto.getAmount());
|
//
|
||||||
// QrCodeUtil.generate(payVo.getUrl(), 300, 300, "png", response.getOutputStream());
|
//// /**
|
||||||
} else if ("wallet".equalsIgnoreCase(type)) {
|
//// * 账户余额查询
|
||||||
// 充值金额只能是整数
|
//// */
|
||||||
if (orderTradeDto.getAmount() % 1 != 0) {
|
//// @GetMapping("/balance")
|
||||||
return R.fail(HttpStatus.SHOW_ERROR_MSG,"充值金额只能是整数");
|
//// @ResponseBody
|
||||||
}
|
//// public AjaxResult balance() throws AlipayApiException {
|
||||||
payVo = aliPayService.walletPay(orderTradeDto.getAmount());
|
//// String balance = aliPayService.balance();
|
||||||
// QrCodeUtil.generate(payVo.getUrl(), 300, 300, "png", response.getOutputStream());
|
//// return AjaxResult.success(balance);
|
||||||
} else {
|
//// }
|
||||||
return R.fail(HttpStatus.SHOW_ERROR_MSG,"订单类型错误");
|
//
|
||||||
}
|
//
|
||||||
|
// /**
|
||||||
return R.ok(payVo);
|
// * 支付接口
|
||||||
}
|
// *
|
||||||
|
// * @param orderTradeDto 订单实体
|
||||||
/**
|
// * @param response 响应
|
||||||
* 提现接口
|
// * @throws Exception
|
||||||
*/
|
// */
|
||||||
@Anonymous
|
// @Anonymous
|
||||||
@GetMapping("/fetch")
|
// @PostMapping("/doPay")
|
||||||
@ResponseBody
|
// @ApiOperation(value = "支付宝支付")
|
||||||
@ApiOperation(value = "提现")
|
// @ResponseBody
|
||||||
public R<String> fetch(@Valid
|
// public R<PayVo> doPay(@Valid
|
||||||
@NotNull(message = "提现金额不能为空")
|
// @RequestBody
|
||||||
@Pattern(regexp = "^(0|(?!0\\d)[1-9]\\d*)(\\.\\d{2})?$", message = "金额格式错误(必须保留两位小数)")
|
// OrderTradeDto orderTradeDto,
|
||||||
String amount) throws Exception {
|
// HttpServletResponse response) throws Exception {
|
||||||
|
// PayVo payVo = null;
|
||||||
SysUserPayAccount sysUserPayAccount = sysUserPayAccountService.lambdaQuery()
|
//
|
||||||
.eq(SysUserPayAccount::getUserId, SecurityUtils.getUserId())
|
// String type = orderTradeDto.getType();
|
||||||
.eq(SysUserPayAccount::getType, 0)
|
//
|
||||||
.one();
|
// if ("member".equalsIgnoreCase(type)) {
|
||||||
|
// if (!Optional.ofNullable(orderTradeDto.getProductId()).isPresent()) {
|
||||||
if (Objects.isNull(sysUserPayAccount)) {
|
// return R.fail(HttpStatus.SHOW_ERROR_MSG,"商品id不能为空");
|
||||||
return R.fail(HttpStatus.SHOW_ERROR_MSG,"请先绑定支付宝");
|
// }
|
||||||
}
|
// payVo = aliPayService.memberPay(orderTradeDto);
|
||||||
|
//// QrCodeUtil.generate(payVo.getUrl(), 300, 300, "png", response.getOutputStream());
|
||||||
|
// } else if ("points".equalsIgnoreCase(type)) {
|
||||||
if (Double.parseDouble(amount) < 0.1) {
|
// payVo = aliPayService.pointsPay(orderTradeDto.getAmount());
|
||||||
return R.fail(HttpStatus.SHOW_ERROR_MSG,"提现金额最小为0.1");
|
//// QrCodeUtil.generate(payVo.getUrl(), 300, 300, "png", response.getOutputStream());
|
||||||
}
|
// } else if ("wallet".equalsIgnoreCase(type)) {
|
||||||
|
// // 充值金额只能是整数
|
||||||
return aliPayService.fetch(amount.toString());
|
// if (orderTradeDto.getAmount() % 1 != 0) {
|
||||||
}
|
// return R.fail(HttpStatus.SHOW_ERROR_MSG,"充值金额只能是整数");
|
||||||
|
// }
|
||||||
|
// payVo = aliPayService.walletPay(orderTradeDto.getAmount());
|
||||||
/**
|
//// QrCodeUtil.generate(payVo.getUrl(), 300, 300, "png", response.getOutputStream());
|
||||||
* 支付回调接口
|
// } else {
|
||||||
*
|
// return R.fail(HttpStatus.SHOW_ERROR_MSG,"订单类型错误");
|
||||||
* @param request
|
// }
|
||||||
* @return
|
//
|
||||||
* @throws Exception
|
// return R.ok(payVo);
|
||||||
*/
|
// }
|
||||||
@Anonymous
|
//
|
||||||
@PostMapping("/notify") // 注意这里必须是POST接口
|
// /**
|
||||||
@ResponseBody
|
// * 提现接口
|
||||||
public String payNotify(HttpServletRequest request) throws Exception {
|
// */
|
||||||
|
// @Anonymous
|
||||||
|
// @GetMapping("/fetch")
|
||||||
if (request.getParameter("trade_status").equals("TRADE_SUCCESS")) {
|
// @ResponseBody
|
||||||
System.out.println("=========支付宝异步回调========");
|
// @ApiOperation(value = "提现")
|
||||||
|
// public R<String> fetch(@Valid
|
||||||
Map<String, String> params = new HashMap<>();
|
// @NotNull(message = "提现金额不能为空")
|
||||||
Map<String, String[]> requestParams = request.getParameterMap();
|
// @Pattern(regexp = "^(0|(?!0\\d)[1-9]\\d*)(\\.\\d{2})?$", message = "金额格式错误(必须保留两位小数)")
|
||||||
for (String name : requestParams.keySet()) {
|
// String amount) throws Exception {
|
||||||
params.put(name, request.getParameter(name));
|
//
|
||||||
// System.out.println(name + " = " + request.getParameter(name));
|
// SysUserPayAccount sysUserPayAccount = sysUserPayAccountService.lambdaQuery()
|
||||||
}
|
// .eq(SysUserPayAccount::getUserId, SecurityUtils.getUserId())
|
||||||
|
// .eq(SysUserPayAccount::getType, 0)
|
||||||
// 支付宝验签
|
// .one();
|
||||||
if (Factory.Payment.Common().verifyNotify(params)) {
|
//
|
||||||
// System.out.println("交易名称: " + params.get("subject"));
|
// if (Objects.isNull(sysUserPayAccount)) {
|
||||||
// System.out.println("交易状态: " + params.get("trade_status"));
|
// return R.fail(HttpStatus.SHOW_ERROR_MSG,"请先绑定支付宝");
|
||||||
// System.out.println("支付宝交易凭证号: " + params.get("trade_no"));
|
// }
|
||||||
// System.out.println("商户订单号: " + params.get("out_trade_no"));
|
//
|
||||||
// System.out.println("交易金额: " + params.get("total_amount"));
|
//
|
||||||
// System.out.println("买家在支付宝唯一id: " + params.get("buyer_id"));
|
// if (Double.parseDouble(amount) < 0.1) {
|
||||||
// System.out.println("买家付款时间: " + params.get("gmt_payment"));
|
// return R.fail(HttpStatus.SHOW_ERROR_MSG,"提现金额最小为0.1");
|
||||||
// System.out.println("买家付款金额: " + params.get("buyer_pay_amount"));
|
// }
|
||||||
// 验签通过
|
//
|
||||||
|
// return aliPayService.fetch(amount.toString());
|
||||||
String code = params.get("out_trade_no"); // 商户订单号
|
// }
|
||||||
OrderTrade orderTrade = orderTradeService.lambdaQuery()
|
//
|
||||||
.eq(OrderTrade::getCode, code)
|
//
|
||||||
.one();
|
// /**
|
||||||
if (Objects.isNull(orderTrade)) {
|
// * 支付回调接口
|
||||||
return "failure";
|
// *
|
||||||
}
|
// * @param request
|
||||||
// 获取订单后缀
|
// * @return
|
||||||
String suffix = code.substring(code.lastIndexOf("_") + 1);
|
// * @throws Exception
|
||||||
|
// */
|
||||||
orderTradeService.orderHandler(orderTrade, suffix, params);
|
// @Anonymous
|
||||||
|
// @PostMapping("/notify") // 注意这里必须是POST接口
|
||||||
// 更新订单状态
|
// @ResponseBody
|
||||||
// if (!StringUtils.isEmpty(orderTradeJson)) {
|
// public String payNotify(HttpServletRequest request) throws Exception {
|
||||||
// OrderTrade orderTrade = JSONUtil.toBean(orderTradeJson, OrderTrade.class);
|
//
|
||||||
// // 支付宝交易凭证号
|
//
|
||||||
// orderTrade.setPaymentMethod(params.get("trade_no"));
|
// if (request.getParameter("trade_status").equals("TRADE_SUCCESS")) {
|
||||||
// orderTrade.setTransactionId(1);
|
// System.out.println("=========支付宝异步回调========");
|
||||||
// orderTrade.setOrderTime(DateUtils.parseDate(params.get("gmt_payment")));
|
//
|
||||||
// orderTrade.setOrderStatus(3);
|
// Map<String, String> params = new HashMap<>();
|
||||||
// orderTrade.setPayStatus(2);
|
// Map<String, String[]> requestParams = request.getParameterMap();
|
||||||
// String totalAmountStr = params.get("total_amount");
|
// for (String name : requestParams.keySet()) {
|
||||||
// if (totalAmountStr != null && !totalAmountStr.isEmpty()) {
|
// params.put(name, request.getParameter(name));
|
||||||
// BigDecimal totalAmount = new BigDecimal(totalAmountStr);
|
// // System.out.println(name + " = " + request.getParameter(name));
|
||||||
// orderTrade.setTotalAmount(totalAmount.intValue());
|
// }
|
||||||
// }
|
//
|
||||||
// String buyerPayAmountStr = params.get("buyer_pay_amount");
|
// // 支付宝验签
|
||||||
// if (buyerPayAmountStr != null && !buyerPayAmountStr.isEmpty()) {
|
// if (Factory.Payment.Common().verifyNotify(params)) {
|
||||||
// BigDecimal buyerPayAmount = new BigDecimal(buyerPayAmountStr);
|
//// System.out.println("交易名称: " + params.get("subject"));
|
||||||
// orderTrade.setPaymentAmount(buyerPayAmount.intValue());
|
//// System.out.println("交易状态: " + params.get("trade_status"));
|
||||||
// }
|
//// System.out.println("支付宝交易凭证号: " + params.get("trade_no"));
|
||||||
// orderTradeService.save(orderTrade);
|
//// System.out.println("商户订单号: " + params.get("out_trade_no"));
|
||||||
|
//// System.out.println("交易金额: " + params.get("total_amount"));
|
||||||
|
//// System.out.println("买家在支付宝唯一id: " + params.get("buyer_id"));
|
||||||
|
//// System.out.println("买家付款时间: " + params.get("gmt_payment"));
|
||||||
|
//// System.out.println("买家付款金额: " + params.get("buyer_pay_amount"));
|
||||||
|
// // 验签通过
|
||||||
|
//
|
||||||
|
// String code = params.get("out_trade_no"); // 商户订单号
|
||||||
|
// OrderTrade orderTrade = orderTradeService.lambdaQuery()
|
||||||
|
// .eq(OrderTrade::getCode, code)
|
||||||
|
// .one();
|
||||||
|
// if (Objects.isNull(orderTrade)) {
|
||||||
|
// return "failure";
|
||||||
// }
|
// }
|
||||||
} else {
|
// // 获取订单后缀
|
||||||
// 验签失败
|
// String suffix = code.substring(code.lastIndexOf("_") + 1);
|
||||||
System.out.println("验签失败");
|
//
|
||||||
}
|
// orderTradeService.orderHandler(orderTrade, suffix, params);
|
||||||
} else {
|
//
|
||||||
// 验签失败
|
// // 更新订单状态
|
||||||
System.out.println("验签失败");
|
//// if (!StringUtils.isEmpty(orderTradeJson)) {
|
||||||
}
|
//// OrderTrade orderTrade = JSONUtil.toBean(orderTradeJson, OrderTrade.class);
|
||||||
|
//// // 支付宝交易凭证号
|
||||||
return "success";
|
//// orderTrade.setPaymentMethod(params.get("trade_no"));
|
||||||
}
|
//// orderTrade.setTransactionId(1);
|
||||||
|
//// orderTrade.setOrderTime(DateUtils.parseDate(params.get("gmt_payment")));
|
||||||
|
//// orderTrade.setOrderStatus(3);
|
||||||
}
|
//// orderTrade.setPayStatus(2);
|
||||||
|
//// String totalAmountStr = params.get("total_amount");
|
||||||
|
//// if (totalAmountStr != null && !totalAmountStr.isEmpty()) {
|
||||||
|
//// BigDecimal totalAmount = new BigDecimal(totalAmountStr);
|
||||||
|
//// orderTrade.setTotalAmount(totalAmount.intValue());
|
||||||
|
//// }
|
||||||
|
//// String buyerPayAmountStr = params.get("buyer_pay_amount");
|
||||||
|
//// if (buyerPayAmountStr != null && !buyerPayAmountStr.isEmpty()) {
|
||||||
|
//// BigDecimal buyerPayAmount = new BigDecimal(buyerPayAmountStr);
|
||||||
|
//// orderTrade.setPaymentAmount(buyerPayAmount.intValue());
|
||||||
|
//// }
|
||||||
|
//// orderTradeService.save(orderTrade);
|
||||||
|
//// }
|
||||||
|
// } else {
|
||||||
|
// // 验签失败
|
||||||
|
// System.out.println("验签失败");
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// // 验签失败
|
||||||
|
// System.out.println("验签失败");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return "success";
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
|
|
@ -1,163 +1,163 @@
|
||||||
package com.mcwl.web.controller.pay.AliPay;
|
//package com.mcwl.web.controller.pay.AliPay;
|
||||||
|
//
|
||||||
import com.alipay.easysdk.factory.Factory;
|
//import com.alipay.easysdk.factory.Factory;
|
||||||
import com.alipay.easysdk.kernel.Config;
|
//import com.alipay.easysdk.kernel.Config;
|
||||||
import com.alipay.easysdk.payment.common.models.AlipayTradeCancelResponse;
|
//import com.alipay.easysdk.payment.common.models.AlipayTradeCancelResponse;
|
||||||
import com.alipay.easysdk.payment.common.models.AlipayTradeCloseResponse;
|
//import com.alipay.easysdk.payment.common.models.AlipayTradeCloseResponse;
|
||||||
import com.alipay.easysdk.payment.common.models.AlipayTradeQueryResponse;
|
//import com.alipay.easysdk.payment.common.models.AlipayTradeQueryResponse;
|
||||||
import com.mcwl.common.JSONUtils;
|
//import com.mcwl.common.JSONUtils;
|
||||||
import com.mcwl.common.constant.HttpStatus;
|
//import com.mcwl.common.constant.HttpStatus;
|
||||||
import com.mcwl.common.core.controller.BaseController;
|
//import com.mcwl.common.core.controller.BaseController;
|
||||||
import com.mcwl.common.core.domain.AjaxResult;
|
//import com.mcwl.common.core.domain.AjaxResult;
|
||||||
import com.mcwl.common.core.domain.R;
|
//import com.mcwl.common.core.domain.R;
|
||||||
import com.mcwl.common.core.page.TableDataInfo;
|
//import com.mcwl.common.core.page.TableDataInfo;
|
||||||
import com.mcwl.common.core.redis.RedisCache;
|
//import com.mcwl.common.core.redis.RedisCache;
|
||||||
import com.mcwl.common.domain.IdsParam;
|
//import com.mcwl.common.domain.IdsParam;
|
||||||
import com.mcwl.common.utils.SecurityUtils;
|
//import com.mcwl.common.utils.SecurityUtils;
|
||||||
import com.mcwl.pay.domain.OrderTrade;
|
//import com.mcwl.pay.domain.OrderTrade;
|
||||||
import com.mcwl.pay.service.AliPayService;
|
//import com.mcwl.pay.service.AliPayService;
|
||||||
import com.mcwl.pay.service.OrderTradeService;
|
//import com.mcwl.pay.service.OrderTradeService;
|
||||||
import com.mcwl.resource.domain.dto.ProductRes;
|
//import com.mcwl.resource.domain.dto.ProductRes;
|
||||||
import io.swagger.annotations.Api;
|
//import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
//import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.validation.annotation.Validated;
|
//import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
//import org.springframework.web.bind.annotation.*;
|
||||||
|
//
|
||||||
import javax.validation.Valid;
|
//import javax.validation.Valid;
|
||||||
import javax.validation.constraints.NotBlank;
|
//import javax.validation.constraints.NotBlank;
|
||||||
import java.util.List;
|
//import java.util.List;
|
||||||
import java.util.Map;
|
//import java.util.Map;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* @Author:ChenYan
|
// * @Author:ChenYan
|
||||||
* @Project:McWl
|
// * @Project:McWl
|
||||||
* @Package:com.mcwl.web.controller.pay
|
// * @Package:com.mcwl.web.controller.pay
|
||||||
* @Filename:OrderTradeController
|
// * @Filename:OrderTradeController
|
||||||
* @Description 支付模块
|
// * @Description 支付模块
|
||||||
* @Date:2025/1/3 14:46
|
// * @Date:2025/1/3 14:46
|
||||||
*/
|
// */
|
||||||
|
//
|
||||||
@RestController
|
//@RestController
|
||||||
@RequestMapping("/order")
|
//@RequestMapping("/order")
|
||||||
@Validated
|
//@Validated
|
||||||
@Api(tags = "订单模块")
|
//@Api(tags = "订单模块")
|
||||||
public class OrderTradeController extends BaseController {
|
//public class OrderTradeController extends BaseController {
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private Config config;
|
// private Config config;
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private OrderTradeService orderTradeService;
|
// private OrderTradeService orderTradeService;
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private AliPayService aliPayService;
|
// private AliPayService aliPayService;
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
private RedisCache redisCache;
|
// private RedisCache redisCache;
|
||||||
|
//
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 购买产品
|
// * 购买产品
|
||||||
*/
|
// */
|
||||||
@PostMapping("/buy")
|
// @PostMapping("/buy")
|
||||||
@ApiOperation(value = "购买产品")
|
// @ApiOperation(value = "购买产品")
|
||||||
public R<Object> buy(@Valid @RequestBody ProductRes productRes) throws Exception {
|
// public R<Object> buy(@Valid @RequestBody ProductRes productRes) throws Exception {
|
||||||
orderTradeService.productHandler(productRes);
|
// orderTradeService.productHandler(productRes);
|
||||||
return R.ok();
|
// return R.ok();
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询列表
|
|
||||||
*/
|
|
||||||
@GetMapping("/list")
|
|
||||||
@ApiOperation(value = "查询订单列表")
|
|
||||||
public TableDataInfo list(OrderTrade orderTrade) {
|
|
||||||
startPage();
|
|
||||||
List<OrderTrade> list = orderTradeService.selectMallProductList(orderTrade);
|
|
||||||
return getDataTable(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增
|
|
||||||
*/
|
|
||||||
@PostMapping("/add")
|
|
||||||
@ApiOperation(value = "新增订单")
|
|
||||||
public R<Object> add(@RequestBody OrderTrade orderTrade) {
|
|
||||||
// 获取当前用户
|
|
||||||
Long userId = SecurityUtils.getUserId();
|
|
||||||
if (userId == null) {
|
|
||||||
return R.fail(HttpStatus.SHOW_ERROR_MSG,"用户未登录");
|
|
||||||
}
|
|
||||||
orderTrade.setUserId(userId);
|
|
||||||
return R.ok(orderTradeService.insertMallProduct(orderTrade));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改
|
|
||||||
*/
|
|
||||||
@PostMapping("/update")
|
|
||||||
@ApiOperation(value = "修改订单")
|
|
||||||
public R<Object> update(@RequestBody OrderTrade orderTrade) {
|
|
||||||
// 获取当前用户
|
|
||||||
Long userId = SecurityUtils.getUserId();
|
|
||||||
if (userId == null) {
|
|
||||||
return R.fail(HttpStatus.SHOW_ERROR_MSG,"用户未登录");
|
|
||||||
}
|
|
||||||
orderTrade.setUserId(userId);
|
|
||||||
orderTradeService.updateMallProduct(orderTrade);
|
|
||||||
return R.ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除
|
|
||||||
*/
|
|
||||||
@PostMapping
|
|
||||||
@ApiOperation(value = "删除订单")
|
|
||||||
public R<Object> remove(@RequestBody IdsParam ids) {
|
|
||||||
orderTradeService.deleteMallProductByIds(ids);
|
|
||||||
return R.ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询交易状态
|
|
||||||
*/
|
|
||||||
@GetMapping("/queryTradeStatus")
|
|
||||||
@ApiOperation(value = "查询交易状态")
|
|
||||||
public R<Object> queryTradeStatus(@Valid @NotBlank(message = "订单号不能为空") String outTradeNo) throws Exception {
|
|
||||||
return aliPayService.queryTradeStatus(outTradeNo);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 撤销交易
|
|
||||||
*/
|
|
||||||
// @GetMapping("/cancelTrade")
|
|
||||||
// public AjaxResult cancelTrade(String outTradeNo) throws Exception {
|
|
||||||
// // 关闭交易
|
|
||||||
// AlipayTradeCancelResponse cancel = Factory.Payment.Common().cancel(outTradeNo);
|
|
||||||
// if (cancel.getCode().equals("10000")) {
|
|
||||||
// return AjaxResult.success("关闭成功");
|
|
||||||
// }
|
|
||||||
// return AjaxResult.error("关闭失败");
|
|
||||||
// }
|
// }
|
||||||
|
//
|
||||||
/**
|
//
|
||||||
* 关闭交易
|
// /**
|
||||||
*/
|
// * 查询列表
|
||||||
// @GetMapping("/closeTrade")
|
// */
|
||||||
// public AjaxResult closeTrade(String outTradeNo) throws Exception {
|
// @GetMapping("/list")
|
||||||
// // 关闭交易
|
// @ApiOperation(value = "查询订单列表")
|
||||||
// AlipayTradeCloseResponse close = Factory.Payment.Common().close(outTradeNo);
|
// public TableDataInfo list(OrderTrade orderTrade) {
|
||||||
// if (close.getCode().equals("10000")) {
|
// startPage();
|
||||||
// return AjaxResult.success("关闭成功");
|
// List<OrderTrade> list = orderTradeService.selectMallProductList(orderTrade);
|
||||||
// }
|
// return getDataTable(list);
|
||||||
// return AjaxResult.error("关闭失败");
|
|
||||||
// }
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
}
|
// * 新增
|
||||||
|
// */
|
||||||
|
// @PostMapping("/add")
|
||||||
|
// @ApiOperation(value = "新增订单")
|
||||||
|
// public R<Object> add(@RequestBody OrderTrade orderTrade) {
|
||||||
|
// // 获取当前用户
|
||||||
|
// Long userId = SecurityUtils.getUserId();
|
||||||
|
// if (userId == null) {
|
||||||
|
// return R.fail(HttpStatus.SHOW_ERROR_MSG,"用户未登录");
|
||||||
|
// }
|
||||||
|
// orderTrade.setUserId(userId);
|
||||||
|
// return R.ok(orderTradeService.insertMallProduct(orderTrade));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 修改
|
||||||
|
// */
|
||||||
|
// @PostMapping("/update")
|
||||||
|
// @ApiOperation(value = "修改订单")
|
||||||
|
// public R<Object> update(@RequestBody OrderTrade orderTrade) {
|
||||||
|
// // 获取当前用户
|
||||||
|
// Long userId = SecurityUtils.getUserId();
|
||||||
|
// if (userId == null) {
|
||||||
|
// return R.fail(HttpStatus.SHOW_ERROR_MSG,"用户未登录");
|
||||||
|
// }
|
||||||
|
// orderTrade.setUserId(userId);
|
||||||
|
// orderTradeService.updateMallProduct(orderTrade);
|
||||||
|
// return R.ok();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 删除
|
||||||
|
// */
|
||||||
|
// @PostMapping
|
||||||
|
// @ApiOperation(value = "删除订单")
|
||||||
|
// public R<Object> remove(@RequestBody IdsParam ids) {
|
||||||
|
// orderTradeService.deleteMallProductByIds(ids);
|
||||||
|
// return R.ok();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 查询交易状态
|
||||||
|
// */
|
||||||
|
// @GetMapping("/queryTradeStatus")
|
||||||
|
// @ApiOperation(value = "查询交易状态")
|
||||||
|
// public R<Object> queryTradeStatus(@Valid @NotBlank(message = "订单号不能为空") String outTradeNo) throws Exception {
|
||||||
|
// return aliPayService.queryTradeStatus(outTradeNo);
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 撤销交易
|
||||||
|
// */
|
||||||
|
//// @GetMapping("/cancelTrade")
|
||||||
|
//// public AjaxResult cancelTrade(String outTradeNo) throws Exception {
|
||||||
|
//// // 关闭交易
|
||||||
|
//// AlipayTradeCancelResponse cancel = Factory.Payment.Common().cancel(outTradeNo);
|
||||||
|
//// if (cancel.getCode().equals("10000")) {
|
||||||
|
//// return AjaxResult.success("关闭成功");
|
||||||
|
//// }
|
||||||
|
//// return AjaxResult.error("关闭失败");
|
||||||
|
//// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 关闭交易
|
||||||
|
// */
|
||||||
|
//// @GetMapping("/closeTrade")
|
||||||
|
//// public AjaxResult closeTrade(String outTradeNo) throws Exception {
|
||||||
|
//// // 关闭交易
|
||||||
|
//// AlipayTradeCloseResponse close = Factory.Payment.Common().close(outTradeNo);
|
||||||
|
//// if (close.getCode().equals("10000")) {
|
||||||
|
//// return AjaxResult.success("关闭成功");
|
||||||
|
//// }
|
||||||
|
//// return AjaxResult.error("关闭失败");
|
||||||
|
//// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
|
|
@ -144,12 +144,12 @@ mall:
|
||||||
appId: 9021000135682614
|
appId: 9021000135682614
|
||||||
# 沙箱应用私钥
|
# 沙箱应用私钥
|
||||||
privateKey: MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCQxmQGcaiKjOhayWi+zNTvpp8B5YT8jFFkjLzrD+W+T2Dwf2GfFR4p95zsCJxYeoLWdghMPA6/GMFrLbuVFpaEjuTm4icqA9N8n5d3W0j7gh+wMjZoqyJclAIeb09ut7rY6mWzilA9kWmZnUG7MOWIU70RVRYrfJectCFw/odM9lG4XIVe13X2h+1ecTQyQzLWmnvKFCfo7dQjE7fIYiWfud1ZGUneNs3u73pNWMB6ThGTTCbs0atcgM3fYOg3q7fTxIu9VcaUCJiJ/kNbL9sVEyOrSyx2f2o6w06zdEaOiQFsuDeS8QPYGMg7pf42wAfqCO6hqxQiQT5vp1hvB0o1AgMBAAECggEAIhaEYLwMSispXo8D2cES9iaOU/z91hUX6Qv2Q4anuqqoEZh8nN91Db6etTjFz1NxURvTklelxTsH97t56n26DRY0MWTYgd0Kw9Iz8MeOpKGb4nnAM97vpUq4QQBGfLRIC2ENdzu+7vA5JBFR88hsky/cWaNmJ/EbJauIIDneE7GigMR2HF7kfzdZzOBN4ZEh/ef5NKeCnEieRJJhWRgrgNXVZ44Tqi67AM7ey9pyUtBe7fgzxXtrWXBN9yKaVxxSXm3KJXFQqA6mcilFVZaxMNlAySc4MPTW8lq0ozOCOCunoeIphNz/OVIxGu3/voXFXlBfOKqOkYMVZxMY6OrvtQKBgQD0nIlXK4VW72VaGpz9kxQkRNzJV/yqaqet1GOSlPM2l0RCRFOVVdnvbQdHGPe6+HxHL1dh5MP8T/aHoP+4UXkkQCc8moS2FZxJvFH2QTSZBcSSdGL7GMpROqs38J+XlJzrhNcB20lrW6D7yMeQa4YEcXwdbD8Er/YaIqODBWYYewKBgQCXg+16RLDArciwwhf0TBWZPor2iYFDdwU5UPu7CKOhU1MLfQhG85gGpXHjB6G8cMUi/ezxh/FEl+sWOZegpkPwL5/BQS9tNYWIaC4kipPF/a5Up4DMYUHVAuuPwNqqXpvgU+rGjCns0wtPRnjrkghLkc3oTSID7o7pzUwIk2whDwKBgAys3+EIfExY82OL5X6uVGjcuKQmTw11oWK8krxRw5iclgjpCXu/ix+BAtOIU634mlgF9/02oYE9k4TLrvSaJDDgsifNyfq1e/fGLmkYT+VuCxWbulVQn4s+AwlPCrYMGWWK6KlL9638fYcOjGjLaZJpXwkXRtyzUYlhKh/r87JpAoGBAIavRp2mi/xrPvgpQQPv0k9L8llfOCHRnjoqC+thrZsNp8eRmJcBmMVnskofEZ2iHQuS71pw/n58EQTLo0ayJbhPjVJL8K3CovXzrfjbmqqoa5xi3bJQTiXdF6rMw1QpD6Uk05E1LVuQ6v/IZFr7kBYlAQWb8z3NhQq+bPU+nyLvAoGAGpBbSM8gPzdWQqkHoos0icu3cj0GhN3MU7+1Eb/rsXyh/lk5wtZTEnHjwhdUOUtwVNjvrv7CzA7unhOoaM6YcE/Zpd4zt8pjqH1Mhds7UHf4Xg+A+J4G6meYnhSwfBpOub02ncsqfBlXE0qhFv6AvcMewWndyLb8EYaUUXTYkG0=
|
privateKey: MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCQxmQGcaiKjOhayWi+zNTvpp8B5YT8jFFkjLzrD+W+T2Dwf2GfFR4p95zsCJxYeoLWdghMPA6/GMFrLbuVFpaEjuTm4icqA9N8n5d3W0j7gh+wMjZoqyJclAIeb09ut7rY6mWzilA9kWmZnUG7MOWIU70RVRYrfJectCFw/odM9lG4XIVe13X2h+1ecTQyQzLWmnvKFCfo7dQjE7fIYiWfud1ZGUneNs3u73pNWMB6ThGTTCbs0atcgM3fYOg3q7fTxIu9VcaUCJiJ/kNbL9sVEyOrSyx2f2o6w06zdEaOiQFsuDeS8QPYGMg7pf42wAfqCO6hqxQiQT5vp1hvB0o1AgMBAAECggEAIhaEYLwMSispXo8D2cES9iaOU/z91hUX6Qv2Q4anuqqoEZh8nN91Db6etTjFz1NxURvTklelxTsH97t56n26DRY0MWTYgd0Kw9Iz8MeOpKGb4nnAM97vpUq4QQBGfLRIC2ENdzu+7vA5JBFR88hsky/cWaNmJ/EbJauIIDneE7GigMR2HF7kfzdZzOBN4ZEh/ef5NKeCnEieRJJhWRgrgNXVZ44Tqi67AM7ey9pyUtBe7fgzxXtrWXBN9yKaVxxSXm3KJXFQqA6mcilFVZaxMNlAySc4MPTW8lq0ozOCOCunoeIphNz/OVIxGu3/voXFXlBfOKqOkYMVZxMY6OrvtQKBgQD0nIlXK4VW72VaGpz9kxQkRNzJV/yqaqet1GOSlPM2l0RCRFOVVdnvbQdHGPe6+HxHL1dh5MP8T/aHoP+4UXkkQCc8moS2FZxJvFH2QTSZBcSSdGL7GMpROqs38J+XlJzrhNcB20lrW6D7yMeQa4YEcXwdbD8Er/YaIqODBWYYewKBgQCXg+16RLDArciwwhf0TBWZPor2iYFDdwU5UPu7CKOhU1MLfQhG85gGpXHjB6G8cMUi/ezxh/FEl+sWOZegpkPwL5/BQS9tNYWIaC4kipPF/a5Up4DMYUHVAuuPwNqqXpvgU+rGjCns0wtPRnjrkghLkc3oTSID7o7pzUwIk2whDwKBgAys3+EIfExY82OL5X6uVGjcuKQmTw11oWK8krxRw5iclgjpCXu/ix+BAtOIU634mlgF9/02oYE9k4TLrvSaJDDgsifNyfq1e/fGLmkYT+VuCxWbulVQn4s+AwlPCrYMGWWK6KlL9638fYcOjGjLaZJpXwkXRtyzUYlhKh/r87JpAoGBAIavRp2mi/xrPvgpQQPv0k9L8llfOCHRnjoqC+thrZsNp8eRmJcBmMVnskofEZ2iHQuS71pw/n58EQTLo0ayJbhPjVJL8K3CovXzrfjbmqqoa5xi3bJQTiXdF6rMw1QpD6Uk05E1LVuQ6v/IZFr7kBYlAQWb8z3NhQq+bPU+nyLvAoGAGpBbSM8gPzdWQqkHoos0icu3cj0GhN3MU7+1Eb/rsXyh/lk5wtZTEnHjwhdUOUtwVNjvrv7CzA7unhOoaM6YcE/Zpd4zt8pjqH1Mhds7UHf4Xg+A+J4G6meYnhSwfBpOub02ncsqfBlXE0qhFv6AvcMewWndyLb8EYaUUXTYkG0=
|
||||||
# 线上应用公钥证书
|
# # 线上应用公钥证书
|
||||||
appCertPath: /opt/cert/pro/appCertPublicKey_2021005119630093.crt
|
# appCertPath: /opt/cert/pro/appCertPublicKey_2021005119630093.crt
|
||||||
# 线上支付宝公钥证书路径
|
# # 线上支付宝公钥证书路径
|
||||||
alipayCertPath: /opt/cert/pro/alipayCertPublicKey_RSA2.crt
|
# alipayCertPath: /opt/cert/pro/alipayCertPublicKey_RSA2.crt
|
||||||
# 线上支付宝根证书路径
|
# # 线上支付宝根证书路径
|
||||||
alipayRootCertPath: /opt/cert/pro/alipayRootCert.crt
|
# alipayRootCertPath: /opt/cert/pro/alipayRootCert.crt
|
||||||
# # 沙箱应用公钥证书
|
# # 沙箱应用公钥证书
|
||||||
# appCertPath: D:\workspace\mochuang\mcwl-ai\mcwl-admin\src\main\resources\cert\dev\alipayPublicCert.crt
|
# appCertPath: D:\workspace\mochuang\mcwl-ai\mcwl-admin\src\main\resources\cert\dev\alipayPublicCert.crt
|
||||||
# # 沙箱支付宝公钥证书路径
|
# # 沙箱支付宝公钥证书路径
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
package com.mcwl;
|
|
||||||
|
|
||||||
|
|
||||||
import com.mcwl.resource.util.MqttTemplate;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
|
|
||||||
@SpringBootTest(classes = McWlApplication.class)
|
|
||||||
@RunWith(SpringRunner.class)
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class TestMQTT {
|
|
||||||
|
|
||||||
private final MqttTemplate mqttTemplate;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void publishTest() throws Exception {
|
|
||||||
mqttTemplate.publish("workFlow/1", "test");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,34 +1,34 @@
|
||||||
package com.mcwl.pay.config;
|
//package com.mcwl.pay.config;
|
||||||
|
//
|
||||||
|
//
|
||||||
import lombok.Data;
|
//import lombok.Data;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
//import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
//import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Configuration;
|
//import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.stereotype.Component;
|
//import org.springframework.stereotype.Component;
|
||||||
|
//
|
||||||
@Data
|
//@Data
|
||||||
@Configuration
|
//@Configuration
|
||||||
@Component
|
//@Component
|
||||||
public class AliConfig {
|
//public class AliConfig {
|
||||||
@Value("${mall.mgt.aliPayConfig.protocol}")
|
// @Value("${mall.mgt.aliPayConfig.protocol}")
|
||||||
private String protocol;
|
// private String protocol;
|
||||||
@Value("${mall.mgt.aliPayConfig.gatewayHost}")
|
// @Value("${mall.mgt.aliPayConfig.gatewayHost}")
|
||||||
private String gatewayHost;
|
// private String gatewayHost;
|
||||||
@Value("${mall.mgt.aliPayConfig.signType}")
|
// @Value("${mall.mgt.aliPayConfig.signType}")
|
||||||
private String signType;
|
// private String signType;
|
||||||
@Value("${mall.mgt.aliPayConfig.appId}")
|
// @Value("${mall.mgt.aliPayConfig.appId}")
|
||||||
private String appId;
|
// private String appId;
|
||||||
@Value("${mall.mgt.aliPayConfig.privateKey}")
|
// @Value("${mall.mgt.aliPayConfig.privateKey}")
|
||||||
private String privateKey;
|
// private String privateKey;
|
||||||
@Value("${mall.mgt.aliPayConfig.appCertPath}")
|
// @Value("${mall.mgt.aliPayConfig.appCertPath}")
|
||||||
private String appCertPath;
|
// private String appCertPath;
|
||||||
@Value("${mall.mgt.aliPayConfig.alipayCertPath}")
|
// @Value("${mall.mgt.aliPayConfig.alipayCertPath}")
|
||||||
private String alipayCertPath;
|
// private String alipayCertPath;
|
||||||
@Value("${mall.mgt.aliPayConfig.alipayRootCertPath}")
|
// @Value("${mall.mgt.aliPayConfig.alipayRootCertPath}")
|
||||||
private String alipayRootCertPath;
|
// private String alipayRootCertPath;
|
||||||
@Value("${mall.mgt.aliPayConfig.gatewayUrl}")
|
// @Value("${mall.mgt.aliPayConfig.gatewayUrl}")
|
||||||
private String gatewayUrl;
|
// private String gatewayUrl;
|
||||||
@Value("${mall.mgt.aliPayConfig.notifyUrl}")
|
// @Value("${mall.mgt.aliPayConfig.notifyUrl}")
|
||||||
private String notifyUrl;
|
// private String notifyUrl;
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,27 +1,27 @@
|
||||||
package com.mcwl.pay.service;
|
//package com.mcwl.pay.service;
|
||||||
|
//
|
||||||
import com.alipay.api.AlipayApiException;
|
//import com.alipay.api.AlipayApiException;
|
||||||
import com.mcwl.common.core.domain.AjaxResult;
|
//import com.mcwl.common.core.domain.AjaxResult;
|
||||||
import com.mcwl.common.core.domain.R;
|
//import com.mcwl.common.core.domain.R;
|
||||||
import com.mcwl.pay.domain.OrderTradeDto;
|
//import com.mcwl.pay.domain.OrderTradeDto;
|
||||||
import com.mcwl.pay.domain.vo.PayVo;
|
//import com.mcwl.pay.domain.vo.PayVo;
|
||||||
|
//
|
||||||
import javax.validation.constraints.NotNull;
|
//import javax.validation.constraints.NotNull;
|
||||||
import java.io.FileNotFoundException;
|
//import java.io.FileNotFoundException;
|
||||||
|
//
|
||||||
public interface AliPayService {
|
//public interface AliPayService {
|
||||||
String bindingCallback(String authCode, String state) throws FileNotFoundException;
|
// String bindingCallback(String authCode, String state) throws FileNotFoundException;
|
||||||
|
//
|
||||||
PayVo memberPay(OrderTradeDto orderTradeDto) throws Exception;
|
// PayVo memberPay(OrderTradeDto orderTradeDto) throws Exception;
|
||||||
|
//
|
||||||
PayVo pointsPay(Double paymentAmount) throws Exception;
|
// PayVo pointsPay(Double paymentAmount) throws Exception;
|
||||||
|
//
|
||||||
R<String> fetch(String amount) throws AlipayApiException, FileNotFoundException;
|
// R<String> fetch(String amount) throws AlipayApiException, FileNotFoundException;
|
||||||
|
//
|
||||||
// 查询订单状态
|
// // 查询订单状态
|
||||||
R<Object> queryTradeStatus(String outTradeNo) throws Exception;
|
// R<Object> queryTradeStatus(String outTradeNo) throws Exception;
|
||||||
|
//
|
||||||
PayVo walletPay(Double amount) throws Exception;
|
// PayVo walletPay(Double amount) throws Exception;
|
||||||
|
//
|
||||||
R<Object> queryBindStatus();
|
// R<Object> queryBindStatus();
|
||||||
}
|
//}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,45 +1,45 @@
|
||||||
package com.mcwl.pay.task;
|
//package com.mcwl.pay.task;
|
||||||
|
//
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.mcwl.common.constant.QueueConstants;
|
//import com.mcwl.common.constant.QueueConstants;
|
||||||
import com.mcwl.memberCenter.domain.Member;
|
//import com.mcwl.memberCenter.domain.Member;
|
||||||
import com.mcwl.pay.domain.OrderTrade;
|
//import com.mcwl.pay.domain.OrderTrade;
|
||||||
import com.mcwl.pay.service.AliPayService;
|
//import com.mcwl.pay.service.AliPayService;
|
||||||
import com.mcwl.pay.service.OrderTradeService;
|
//import com.mcwl.pay.service.OrderTradeService;
|
||||||
import lombok.RequiredArgsConstructor;
|
//import lombok.RequiredArgsConstructor;
|
||||||
import org.joda.time.LocalDateTime;
|
//import org.joda.time.LocalDateTime;
|
||||||
import org.springframework.stereotype.Component;
|
//import org.springframework.stereotype.Component;
|
||||||
|
//
|
||||||
import java.util.Date;
|
//import java.util.Date;
|
||||||
import java.util.List;
|
//import java.util.List;
|
||||||
import java.util.function.Consumer;
|
//import java.util.function.Consumer;
|
||||||
|
//
|
||||||
@Component("payTask")
|
//@Component("payTask")
|
||||||
@RequiredArgsConstructor
|
//@RequiredArgsConstructor
|
||||||
public class PayTask {
|
//public class PayTask {
|
||||||
|
//
|
||||||
private final OrderTradeService orderTradeService;
|
// private final OrderTradeService orderTradeService;
|
||||||
|
//
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 删除失效订单 间隔1h检查 0 0 0/1 * * ?
|
// * 删除失效订单 间隔1h检查 0 0 0/1 * * ?
|
||||||
*/
|
// */
|
||||||
public void deleteInvalidOrderTask() {
|
// public void deleteInvalidOrderTask() {
|
||||||
|
//
|
||||||
Date date = LocalDateTime.now().plusMinutes(-15).toDate();
|
// Date date = LocalDateTime.now().plusMinutes(-15).toDate();
|
||||||
|
//
|
||||||
List<OrderTrade> orderTradeList = orderTradeService.lambdaQuery()
|
// List<OrderTrade> orderTradeList = orderTradeService.lambdaQuery()
|
||||||
.le(OrderTrade::getCreateTime, date)
|
// .le(OrderTrade::getCreateTime, date)
|
||||||
.and(wrapper -> wrapper
|
// .and(wrapper -> wrapper
|
||||||
.eq(OrderTrade::getOrderStatus, 4)
|
// .eq(OrderTrade::getOrderStatus, 4)
|
||||||
.or()
|
// .or()
|
||||||
.eq(OrderTrade::getPayStatus, 1)
|
// .eq(OrderTrade::getPayStatus, 1)
|
||||||
)
|
// )
|
||||||
.list();
|
// .list();
|
||||||
|
//
|
||||||
orderTradeService.removeBatchByIds(orderTradeList);
|
// orderTradeService.removeBatchByIds(orderTradeList);
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|
Loading…
Reference in New Issue