Compare commits
4 Commits
14576812ae
...
8ca5ff3290
Author | SHA1 | Date |
---|---|---|
|
8ca5ff3290 | |
|
dc5ea06789 | |
|
2ab3f8a7c6 | |
|
c556b006b7 |
|
@ -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-sandbox.dl.alipaydev.com/oauth2/publicAppAuthorize.htm?app_id=%s&scope=%s&redirect_uri=%s&state=%s",
|
// "https://openauth.alipay.com/oauth2/publicAppAuthorize.htm?app_id=%s&scope=%s&redirect_uri=%s&state=%s",
|
||||||
// appId, scope, encodedRedirectUri, state
|
// appId, scope, encodedRedirectUri, state
|
||||||
// );
|
// );
|
||||||
//
|
// 沙箱
|
||||||
//// QrCodeUtil.generate(authUrl, 300, 300, "png", response.getOutputStream());
|
String authUrl = String.format(
|
||||||
// return R.ok(authUrl, "成功");
|
"https://openauth-sandbox.dl.alipaydev.com/oauth2/publicAppAuthorize.htm?app_id=%s&scope=%s&redirect_uri=%s&state=%s",
|
||||||
// }
|
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("/queryBindStatus")
|
// @GetMapping("/balance")
|
||||||
// @ApiOperation(value = "支付宝绑定状态查询")
|
|
||||||
// @ResponseBody
|
// @ResponseBody
|
||||||
// public R<Object> queryTradeStatus() throws Exception {
|
// public AjaxResult balance() throws AlipayApiException {
|
||||||
//
|
// String balance = aliPayService.balance();
|
||||||
// return aliPayService.queryBindStatus();
|
// return AjaxResult.success(balance);
|
||||||
// }
|
// }
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 授权回调
|
/**
|
||||||
// *
|
* 支付接口
|
||||||
// * @param authCode 授权码
|
*
|
||||||
// */
|
* @param orderTradeDto 订单实体
|
||||||
// @GetMapping("/callback")
|
* @param response 响应
|
||||||
// public String callback(@RequestParam("auth_code") String authCode, String state) throws FileNotFoundException {
|
* @throws Exception
|
||||||
//
|
*/
|
||||||
// System.out.println("authCode = " + authCode);
|
@Anonymous
|
||||||
// String result = aliPayService.bindingCallback(authCode, state);
|
@PostMapping("/doPay")
|
||||||
// if ("success".equals(result)) {
|
@ApiOperation(value = "支付宝支付")
|
||||||
// return "binding-success";
|
@ResponseBody
|
||||||
// } else {
|
public R<PayVo> doPay(@Valid
|
||||||
// return "binding-fail";
|
@RequestBody
|
||||||
// }
|
OrderTradeDto orderTradeDto,
|
||||||
// }
|
HttpServletResponse response) throws Exception {
|
||||||
//
|
PayVo payVo = null;
|
||||||
//// /**
|
|
||||||
//// * 账户余额查询
|
String type = orderTradeDto.getType();
|
||||||
//// */
|
|
||||||
//// @GetMapping("/balance")
|
if ("member".equalsIgnoreCase(type)) {
|
||||||
//// @ResponseBody
|
if (!Optional.ofNullable(orderTradeDto.getProductId()).isPresent()) {
|
||||||
//// public AjaxResult balance() throws AlipayApiException {
|
return R.fail(HttpStatus.SHOW_ERROR_MSG,"商品id不能为空");
|
||||||
//// String balance = aliPayService.balance();
|
}
|
||||||
//// return AjaxResult.success(balance);
|
payVo = aliPayService.memberPay(orderTradeDto);
|
||||||
//// }
|
// 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)) {
|
||||||
// *
|
// 充值金额只能是整数
|
||||||
// * @param orderTradeDto 订单实体
|
if (orderTradeDto.getAmount() % 1 != 0) {
|
||||||
// * @param response 响应
|
return R.fail(HttpStatus.SHOW_ERROR_MSG,"充值金额只能是整数");
|
||||||
// * @throws Exception
|
}
|
||||||
// */
|
payVo = aliPayService.walletPay(orderTradeDto.getAmount());
|
||||||
// @Anonymous
|
// QrCodeUtil.generate(payVo.getUrl(), 300, 300, "png", response.getOutputStream());
|
||||||
// @PostMapping("/doPay")
|
} else {
|
||||||
// @ApiOperation(value = "支付宝支付")
|
return R.fail(HttpStatus.SHOW_ERROR_MSG,"订单类型错误");
|
||||||
// @ResponseBody
|
}
|
||||||
// public R<PayVo> doPay(@Valid
|
|
||||||
// @RequestBody
|
return R.ok(payVo);
|
||||||
// OrderTradeDto orderTradeDto,
|
}
|
||||||
// HttpServletResponse response) throws Exception {
|
|
||||||
// PayVo payVo = null;
|
/**
|
||||||
//
|
* 提现接口
|
||||||
// String type = orderTradeDto.getType();
|
*/
|
||||||
//
|
@Anonymous
|
||||||
// if ("member".equalsIgnoreCase(type)) {
|
@GetMapping("/fetch")
|
||||||
// if (!Optional.ofNullable(orderTradeDto.getProductId()).isPresent()) {
|
@ResponseBody
|
||||||
// return R.fail(HttpStatus.SHOW_ERROR_MSG,"商品id不能为空");
|
@ApiOperation(value = "提现")
|
||||||
// }
|
public R<String> fetch(@Valid
|
||||||
// payVo = aliPayService.memberPay(orderTradeDto);
|
@NotNull(message = "提现金额不能为空")
|
||||||
//// QrCodeUtil.generate(payVo.getUrl(), 300, 300, "png", response.getOutputStream());
|
@Pattern(regexp = "^(0|(?!0\\d)[1-9]\\d*)(\\.\\d{2})?$", message = "金额格式错误(必须保留两位小数)")
|
||||||
// } else if ("points".equalsIgnoreCase(type)) {
|
String amount) throws Exception {
|
||||||
// payVo = aliPayService.pointsPay(orderTradeDto.getAmount());
|
|
||||||
//// QrCodeUtil.generate(payVo.getUrl(), 300, 300, "png", response.getOutputStream());
|
SysUserPayAccount sysUserPayAccount = sysUserPayAccountService.lambdaQuery()
|
||||||
// } else if ("wallet".equalsIgnoreCase(type)) {
|
.eq(SysUserPayAccount::getUserId, SecurityUtils.getUserId())
|
||||||
// // 充值金额只能是整数
|
.eq(SysUserPayAccount::getType, 0)
|
||||||
// if (orderTradeDto.getAmount() % 1 != 0) {
|
.one();
|
||||||
// return R.fail(HttpStatus.SHOW_ERROR_MSG,"充值金额只能是整数");
|
|
||||||
// }
|
if (Objects.isNull(sysUserPayAccount)) {
|
||||||
// payVo = aliPayService.walletPay(orderTradeDto.getAmount());
|
return R.fail(HttpStatus.SHOW_ERROR_MSG,"请先绑定支付宝");
|
||||||
//// QrCodeUtil.generate(payVo.getUrl(), 300, 300, "png", response.getOutputStream());
|
}
|
||||||
// } else {
|
|
||||||
// return R.fail(HttpStatus.SHOW_ERROR_MSG,"订单类型错误");
|
|
||||||
// }
|
if (Double.parseDouble(amount) < 0.1) {
|
||||||
//
|
return R.fail(HttpStatus.SHOW_ERROR_MSG,"提现金额最小为0.1");
|
||||||
// return R.ok(payVo);
|
}
|
||||||
// }
|
|
||||||
//
|
return aliPayService.fetch(amount.toString());
|
||||||
// /**
|
}
|
||||||
// * 提现接口
|
|
||||||
// */
|
|
||||||
// @Anonymous
|
/**
|
||||||
// @GetMapping("/fetch")
|
* 支付回调接口
|
||||||
// @ResponseBody
|
*
|
||||||
// @ApiOperation(value = "提现")
|
* @param request
|
||||||
// public R<String> fetch(@Valid
|
* @return
|
||||||
// @NotNull(message = "提现金额不能为空")
|
* @throws Exception
|
||||||
// @Pattern(regexp = "^(0|(?!0\\d)[1-9]\\d*)(\\.\\d{2})?$", message = "金额格式错误(必须保留两位小数)")
|
*/
|
||||||
// String amount) throws Exception {
|
@Anonymous
|
||||||
//
|
@PostMapping("/notify") // 注意这里必须是POST接口
|
||||||
// SysUserPayAccount sysUserPayAccount = sysUserPayAccountService.lambdaQuery()
|
@ResponseBody
|
||||||
// .eq(SysUserPayAccount::getUserId, SecurityUtils.getUserId())
|
public String payNotify(HttpServletRequest request) throws Exception {
|
||||||
// .eq(SysUserPayAccount::getType, 0)
|
|
||||||
// .one();
|
|
||||||
//
|
if (request.getParameter("trade_status").equals("TRADE_SUCCESS")) {
|
||||||
// if (Objects.isNull(sysUserPayAccount)) {
|
System.out.println("=========支付宝异步回调========");
|
||||||
// return R.fail(HttpStatus.SHOW_ERROR_MSG,"请先绑定支付宝");
|
|
||||||
// }
|
Map<String, String> params = new HashMap<>();
|
||||||
//
|
Map<String, String[]> requestParams = request.getParameterMap();
|
||||||
//
|
for (String name : requestParams.keySet()) {
|
||||||
// if (Double.parseDouble(amount) < 0.1) {
|
params.put(name, request.getParameter(name));
|
||||||
// return R.fail(HttpStatus.SHOW_ERROR_MSG,"提现金额最小为0.1");
|
// System.out.println(name + " = " + request.getParameter(name));
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// return aliPayService.fetch(amount.toString());
|
// 支付宝验签
|
||||||
// }
|
if (Factory.Payment.Common().verifyNotify(params)) {
|
||||||
//
|
// System.out.println("交易名称: " + params.get("subject"));
|
||||||
//
|
// System.out.println("交易状态: " + params.get("trade_status"));
|
||||||
// /**
|
// System.out.println("支付宝交易凭证号: " + params.get("trade_no"));
|
||||||
// * 支付回调接口
|
// System.out.println("商户订单号: " + params.get("out_trade_no"));
|
||||||
// *
|
// System.out.println("交易金额: " + params.get("total_amount"));
|
||||||
// * @param request
|
// System.out.println("买家在支付宝唯一id: " + params.get("buyer_id"));
|
||||||
// * @return
|
// System.out.println("买家付款时间: " + params.get("gmt_payment"));
|
||||||
// * @throws Exception
|
// System.out.println("买家付款金额: " + params.get("buyer_pay_amount"));
|
||||||
// */
|
// 验签通过
|
||||||
// @Anonymous
|
|
||||||
// @PostMapping("/notify") // 注意这里必须是POST接口
|
String code = params.get("out_trade_no"); // 商户订单号
|
||||||
// @ResponseBody
|
OrderTrade orderTrade = orderTradeService.lambdaQuery()
|
||||||
// public String payNotify(HttpServletRequest request) throws Exception {
|
.eq(OrderTrade::getCode, code)
|
||||||
//
|
.one();
|
||||||
//
|
if (Objects.isNull(orderTrade)) {
|
||||||
// if (request.getParameter("trade_status").equals("TRADE_SUCCESS")) {
|
return "failure";
|
||||||
// System.out.println("=========支付宝异步回调========");
|
}
|
||||||
//
|
// 获取订单后缀
|
||||||
// Map<String, String> params = new HashMap<>();
|
String suffix = code.substring(code.lastIndexOf("_") + 1);
|
||||||
// Map<String, String[]> requestParams = request.getParameterMap();
|
|
||||||
// for (String name : requestParams.keySet()) {
|
orderTradeService.orderHandler(orderTrade, suffix, params);
|
||||||
// params.put(name, request.getParameter(name));
|
|
||||||
// // System.out.println(name + " = " + request.getParameter(name));
|
// 更新订单状态
|
||||||
// }
|
// if (!StringUtils.isEmpty(orderTradeJson)) {
|
||||||
//
|
// OrderTrade orderTrade = JSONUtil.toBean(orderTradeJson, OrderTrade.class);
|
||||||
// // 支付宝验签
|
// // 支付宝交易凭证号
|
||||||
// if (Factory.Payment.Common().verifyNotify(params)) {
|
// orderTrade.setPaymentMethod(params.get("trade_no"));
|
||||||
//// System.out.println("交易名称: " + params.get("subject"));
|
// orderTrade.setTransactionId(1);
|
||||||
//// System.out.println("交易状态: " + params.get("trade_status"));
|
// orderTrade.setOrderTime(DateUtils.parseDate(params.get("gmt_payment")));
|
||||||
//// System.out.println("支付宝交易凭证号: " + params.get("trade_no"));
|
// orderTrade.setOrderStatus(3);
|
||||||
//// System.out.println("商户订单号: " + params.get("out_trade_no"));
|
// orderTrade.setPayStatus(2);
|
||||||
//// System.out.println("交易金额: " + params.get("total_amount"));
|
// String totalAmountStr = params.get("total_amount");
|
||||||
//// System.out.println("买家在支付宝唯一id: " + params.get("buyer_id"));
|
// if (totalAmountStr != null && !totalAmountStr.isEmpty()) {
|
||||||
//// System.out.println("买家付款时间: " + params.get("gmt_payment"));
|
// BigDecimal totalAmount = new BigDecimal(totalAmountStr);
|
||||||
//// System.out.println("买家付款金额: " + params.get("buyer_pay_amount"));
|
// orderTrade.setTotalAmount(totalAmount.intValue());
|
||||||
// // 验签通过
|
// }
|
||||||
//
|
// String buyerPayAmountStr = params.get("buyer_pay_amount");
|
||||||
// String code = params.get("out_trade_no"); // 商户订单号
|
// if (buyerPayAmountStr != null && !buyerPayAmountStr.isEmpty()) {
|
||||||
// OrderTrade orderTrade = orderTradeService.lambdaQuery()
|
// BigDecimal buyerPayAmount = new BigDecimal(buyerPayAmountStr);
|
||||||
// .eq(OrderTrade::getCode, code)
|
// orderTrade.setPaymentAmount(buyerPayAmount.intValue());
|
||||||
// .one();
|
// }
|
||||||
// if (Objects.isNull(orderTrade)) {
|
// orderTradeService.save(orderTrade);
|
||||||
// return "failure";
|
|
||||||
// }
|
// }
|
||||||
// // 获取订单后缀
|
} else {
|
||||||
// String suffix = code.substring(code.lastIndexOf("_") + 1);
|
// 验签失败
|
||||||
//
|
System.out.println("验签失败");
|
||||||
// orderTradeService.orderHandler(orderTrade, suffix, params);
|
}
|
||||||
//
|
} else {
|
||||||
// // 更新订单状态
|
// 验签失败
|
||||||
//// if (!StringUtils.isEmpty(orderTradeJson)) {
|
System.out.println("验签失败");
|
||||||
//// OrderTrade orderTrade = JSONUtil.toBean(orderTradeJson, OrderTrade.class);
|
}
|
||||||
//// // 支付宝交易凭证号
|
|
||||||
//// orderTrade.setPaymentMethod(params.get("trade_no"));
|
return "success";
|
||||||
//// 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,316 +0,0 @@
|
||||||
//package com.mcwl.web.controller.pay.AliPay;
|
|
||||||
//
|
|
||||||
//import cn.hutool.core.bean.BeanUtil;
|
|
||||||
//import cn.hutool.core.lang.UUID;
|
|
||||||
//import cn.hutool.json.JSONUtil;
|
|
||||||
//import com.alibaba.fastjson.JSONObject;
|
|
||||||
//import com.alipay.api.AlipayApiException;
|
|
||||||
//import com.alipay.api.AlipayClient;
|
|
||||||
//import com.alipay.api.AlipayConfig;
|
|
||||||
//import com.alipay.api.DefaultAlipayClient;
|
|
||||||
//import com.alipay.api.diagnosis.DiagnosisUtils;
|
|
||||||
//import com.alipay.api.domain.AlipayFundAccountQueryModel;
|
|
||||||
//import com.alipay.api.domain.AlipayFundTransUniTransferModel;
|
|
||||||
//import com.alipay.api.domain.Participant;
|
|
||||||
//import com.alipay.api.request.AlipayFundAccountQueryRequest;
|
|
||||||
//import com.alipay.api.request.AlipayFundTransUniTransferRequest;
|
|
||||||
//import com.alipay.api.request.AlipaySystemOauthTokenRequest;
|
|
||||||
//import com.alipay.api.request.AlipayUserInfoAuthRequest;
|
|
||||||
//import com.alipay.api.response.AlipayFundAccountQueryResponse;
|
|
||||||
//import com.alipay.api.response.AlipayFundTransUniTransferResponse;
|
|
||||||
//import com.alipay.easysdk.base.oauth.models.AlipaySystemOauthTokenResponse;
|
|
||||||
//import com.alipay.easysdk.factory.Factory;
|
|
||||||
//import com.alipay.easysdk.kernel.Config;
|
|
||||||
//import com.alipay.easysdk.payment.facetoface.models.AlipayTradePrecreateResponse;
|
|
||||||
//import com.mcwl.common.core.redis.RedisCache;
|
|
||||||
//import com.mcwl.common.exception.ServiceException;
|
|
||||||
//import com.mcwl.common.utils.SecurityUtils;
|
|
||||||
//import com.mcwl.memberCenter.domain.MemberLevel;
|
|
||||||
//import com.mcwl.memberCenter.service.MemberLevelService;
|
|
||||||
//import com.mcwl.pay.config.AliConfig;
|
|
||||||
//import com.mcwl.pay.domain.OrderTrade;
|
|
||||||
//import com.mcwl.pay.domain.OrderTradeDto;
|
|
||||||
//import lombok.extern.slf4j.Slf4j;
|
|
||||||
//import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
//import org.springframework.stereotype.Component;
|
|
||||||
//
|
|
||||||
//import java.util.Optional;
|
|
||||||
//import java.util.concurrent.TimeUnit;
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * 支付宝支付
|
|
||||||
// */
|
|
||||||
//@Component
|
|
||||||
//@Slf4j
|
|
||||||
//public class AliPayIntegration {
|
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
// private RedisCache redisCache;
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
// private MemberLevelService memberLevelService;
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
// private AliConfig aliConfig;
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// public AliPayIntegration(Config config) {
|
|
||||||
// Factory.setOptions(config);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 调用支付宝预下订单接口
|
|
||||||
// *
|
|
||||||
// * @param orderTradeDto 订单实体
|
|
||||||
// * @return 二维码url
|
|
||||||
// * @throws Exception
|
|
||||||
// */
|
|
||||||
//// public String orderPay(OrderTradeDto orderTradeDto) throws Exception {
|
|
||||||
//// Integer productId = orderTradeDto.getProductId();
|
|
||||||
//// if (!Optional.ofNullable(productId).isPresent()) {
|
|
||||||
//// throw new ServiceException("mallProductId不能为空");
|
|
||||||
//// }
|
|
||||||
////
|
|
||||||
//// MallProduct mallProduct = mallProductService.getById(productId);
|
|
||||||
//// if (!Optional.ofNullable(mallProduct).isPresent()) {
|
|
||||||
//// throw new ServiceException("mallProduct不存在");
|
|
||||||
//// }
|
|
||||||
////
|
|
||||||
//// // 设置orderTrade信息
|
|
||||||
//// OrderTrade tradeEntity = new OrderTrade();
|
|
||||||
//// BeanUtil.copyProperties(orderTradeDto, tradeEntity);
|
|
||||||
//// tradeEntity.setCode(UUID.randomUUID().toString(true).substring(0, 30));
|
|
||||||
//// tradeEntity.setUserId(SecurityUtils.getUserId());
|
|
||||||
//// tradeEntity.setUserName(SecurityUtils.getUsername());
|
|
||||||
//// tradeEntity.setProductName(mallProduct.getProductName());
|
|
||||||
////
|
|
||||||
//// //调用支付宝的接口
|
|
||||||
//// AlipayTradePrecreateResponse payResponse = Factory.Payment.FaceToFace()
|
|
||||||
//// .preCreate(mallProduct.getProductName(),
|
|
||||||
//// tradeEntity.getCode() + "_product",
|
|
||||||
//// orderTradeDto.getPaymentAmount().toString());
|
|
||||||
//// // 缓存到redis
|
|
||||||
//// redisCache.setCacheObject(tradeEntity.getCode() + "_product", JSONUtil.toJsonStr(tradeEntity), 3, TimeUnit.MINUTES);
|
|
||||||
////// AlipayTradePrecreateResponse payResponse = Factory.Payment.FaceToFace().preCreate("订单主题:Mac笔记本", "LS123qwe123", "19999");
|
|
||||||
//// //参照官方文档响应示例,解析返回结果
|
|
||||||
//// String httpBodyStr = payResponse.getHttpBody();
|
|
||||||
//// JSONObject jsonObject = JSONObject.parseObject(httpBodyStr);
|
|
||||||
//// return jsonObject.getJSONObject("alipay_trade_precreate_response").get("qr_code").toString();
|
|
||||||
//// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 调用支付宝预下订单接口
|
|
||||||
// *
|
|
||||||
// * @param orderTradeDto 订单实体
|
|
||||||
// * @return 二维码url
|
|
||||||
// * @throws Exception
|
|
||||||
// */
|
|
||||||
// public String memberPay(OrderTradeDto orderTradeDto) throws Exception {
|
|
||||||
//
|
|
||||||
// // 会员等级id
|
|
||||||
// Integer productId = orderTradeDto.getProductId();
|
|
||||||
//
|
|
||||||
// if (!Optional.ofNullable(productId).isPresent()) {
|
|
||||||
// throw new ServiceException("memberLevelId不能为空");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// MemberLevel memberLevel = memberLevelService.getById(productId);
|
|
||||||
//
|
|
||||||
// if (!Optional.ofNullable(memberLevel).isPresent()) {
|
|
||||||
// throw new ServiceException("memberLevel不存在");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // 设置orderTrade信息
|
|
||||||
// OrderTrade tradeEntity = new OrderTrade();
|
|
||||||
// BeanUtil.copyProperties(orderTradeDto, tradeEntity);
|
|
||||||
// tradeEntity.setCode(UUID.randomUUID().toString(true).substring(0, 30));
|
|
||||||
// tradeEntity.setUserId(SecurityUtils.getUserId());
|
|
||||||
// tradeEntity.setUserName(SecurityUtils.getUsername());
|
|
||||||
// tradeEntity.setProductName(memberLevel.getMemberName());
|
|
||||||
//
|
|
||||||
// //调用支付宝的接口
|
|
||||||
// AlipayTradePrecreateResponse payResponse = Factory.Payment.FaceToFace()
|
|
||||||
// // 设置过期时
|
|
||||||
// .preCreate(memberLevel.getMemberName(),
|
|
||||||
// tradeEntity.getCode() + "_member",
|
|
||||||
// orderTradeDto.getPaymentAmount().toString());
|
|
||||||
// // 缓存到redis
|
|
||||||
// redisCache.setCacheObject(tradeEntity.getCode() + "_member", JSONUtil.toJsonStr(tradeEntity), 3, TimeUnit.MINUTES);
|
|
||||||
// redisCache.setCacheObject(tradeEntity.getCode() + "_member" + "_promotionId", orderTradeDto.getPromotionId(), 3, TimeUnit.MINUTES);
|
|
||||||
//// AlipayTradePrecreateResponse payResponse = Factory.Payment.FaceToFace().preCreate("订单主题:Mac笔记本", "LS123qwe123", "19999");
|
|
||||||
// //参照官方文档响应示例,解析返回结果
|
|
||||||
// String httpBodyStr = payResponse.getHttpBody();
|
|
||||||
// JSONObject jsonObject = JSONObject.parseObject(httpBodyStr);
|
|
||||||
// return jsonObject.getJSONObject("alipay_trade_precreate_response").get("qr_code").toString();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 调用支付宝预下订单接口
|
|
||||||
// *
|
|
||||||
// * @param paymentAmount 充值金额
|
|
||||||
// * @return 二维码url
|
|
||||||
// * @throws Exception
|
|
||||||
// */
|
|
||||||
// public String pointsPay(Double paymentAmount) throws Exception {
|
|
||||||
// // 设置orderTrade信息
|
|
||||||
// OrderTrade tradeEntity = new OrderTrade();
|
|
||||||
// tradeEntity.setCode(UUID.randomUUID().toString(true).substring(0, 30));
|
|
||||||
// tradeEntity.setUserId(SecurityUtils.getUserId());
|
|
||||||
// tradeEntity.setProductId(-1);
|
|
||||||
// tradeEntity.setProductName("积分充值");
|
|
||||||
// tradeEntity.setUserName(SecurityUtils.getUsername());
|
|
||||||
// tradeEntity.setPaymentAmount(paymentAmount.intValue());
|
|
||||||
//
|
|
||||||
// //调用支付宝的接口
|
|
||||||
// AlipayTradePrecreateResponse payResponse = Factory.Payment.FaceToFace()
|
|
||||||
// .preCreate(tradeEntity.getProductName(),
|
|
||||||
// tradeEntity.getCode() + "_points",
|
|
||||||
// tradeEntity.getPaymentAmount().toString());
|
|
||||||
// // 缓存到redis
|
|
||||||
// redisCache.setCacheObject(tradeEntity.getCode() + "_points", JSONUtil.toJsonStr(tradeEntity), 3, TimeUnit.MINUTES);
|
|
||||||
// //参照官方文档响应示例,解析返回结果
|
|
||||||
// String httpBodyStr = payResponse.getHttpBody();
|
|
||||||
// JSONObject jsonObject = JSONObject.parseObject(httpBodyStr);
|
|
||||||
// return jsonObject.getJSONObject("alipay_trade_precreate_response").get("qr_code").toString();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 支付宝转账方法
|
|
||||||
// * @param outBizNo 外部业务单号
|
|
||||||
// * @param payerUserId 付款方用户ID
|
|
||||||
// * @param payeeUserId 收款方用户ID
|
|
||||||
// * @param amount 转账金额
|
|
||||||
// * @return 返回支付宝转账响应的内容
|
|
||||||
// */
|
|
||||||
// public String transfer(String outBizNo, String payerUserId, String payeeUserId, String amount) throws AlipayApiException {
|
|
||||||
//
|
|
||||||
// // 初始化SDK
|
|
||||||
// AlipayClient alipayClient = new DefaultAlipayClient(getAlipayConfig());
|
|
||||||
//
|
|
||||||
// // 构造请求参数以调用接口
|
|
||||||
// AlipayFundTransUniTransferRequest request = new AlipayFundTransUniTransferRequest();
|
|
||||||
// AlipayFundTransUniTransferModel model = new AlipayFundTransUniTransferModel();
|
|
||||||
//
|
|
||||||
// // 设置商家侧唯一订单号
|
|
||||||
// model.setOutBizNo(outBizNo);
|
|
||||||
//
|
|
||||||
// // 设置订单总金额
|
|
||||||
// model.setTransAmount(amount);
|
|
||||||
//
|
|
||||||
// // 设置描述特定的业务场景
|
|
||||||
// model.setBizScene("DIRECT_TRANSFER");
|
|
||||||
//
|
|
||||||
// // 设置业务产品码
|
|
||||||
// model.setProductCode("TRANS_ACCOUNT_NO_PWD");
|
|
||||||
//
|
|
||||||
// // 设置转账业务的标题
|
|
||||||
// model.setOrderTitle("测试");
|
|
||||||
//
|
|
||||||
// // 设置收款方信息
|
|
||||||
// Participant payeeInfo = new Participant();
|
|
||||||
// payeeInfo.setCertType("IDENTITY_CARD");
|
|
||||||
// payeeInfo.setCertNo("1201152******72917");
|
|
||||||
// payeeInfo.setIdentity("2088123412341234");
|
|
||||||
// payeeInfo.setName("黄龙国际有限公司");
|
|
||||||
// payeeInfo.setIdentityType("ALIPAY_USER_ID");
|
|
||||||
// model.setPayeeInfo(payeeInfo);
|
|
||||||
//
|
|
||||||
// // 设置业务备注
|
|
||||||
// model.setRemark("201905代发");
|
|
||||||
//
|
|
||||||
// // 设置转账业务请求的扩展参数
|
|
||||||
// model.setBusinessParams("{\"payer_show_name_use_alias\":\"true\"}");
|
|
||||||
//
|
|
||||||
// request.setBizModel(model);
|
|
||||||
// AlipayFundTransUniTransferResponse response = alipayClient.certificateExecute(request);
|
|
||||||
// System.out.println(response.getBody());
|
|
||||||
//
|
|
||||||
// if (response.isSuccess()) {
|
|
||||||
// System.out.println("调用成功");
|
|
||||||
// } else {
|
|
||||||
// System.out.println("调用失败");
|
|
||||||
// // sdk版本是"4.38.0.ALL"及以上,可以参考下面的示例获取诊断链接
|
|
||||||
// String diagnosisUrl = DiagnosisUtils.getDiagnosisUrl(response);
|
|
||||||
// System.out.println(diagnosisUrl);
|
|
||||||
// }
|
|
||||||
// return response.getBody();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 查看余额
|
|
||||||
// */
|
|
||||||
// public void balance() throws Exception {
|
|
||||||
//
|
|
||||||
// AlipaySystemOauthTokenResponse token = Factory.Base.OAuth().getToken("code");
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// // 初始化SDK
|
|
||||||
// AlipayClient alipayClient = new DefaultAlipayClient(getAlipayConfig());
|
|
||||||
//
|
|
||||||
// // 构造请求参数以调用接口
|
|
||||||
// AlipayFundAccountQueryRequest request = new AlipayFundAccountQueryRequest();
|
|
||||||
// AlipayFundAccountQueryModel model = new AlipayFundAccountQueryModel();
|
|
||||||
//
|
|
||||||
// // uid参数未来计划废弃,存量商户可继续使用,新商户请使用openid。请根据应用-开发配置-openid配置选择支持的字段。
|
|
||||||
// // model.setAlipayUserId("2088301409188095");
|
|
||||||
//
|
|
||||||
// // 设置支付宝openId
|
|
||||||
// model.setAlipayOpenId("061P6NAblcWDWJoDRxSVvOYz-ufp-3wQaA4E_szQyMFTXse");
|
|
||||||
//
|
|
||||||
// // 设置查询的账号类型
|
|
||||||
// model.setAccountType("ACCTRANS_ACCOUNT");
|
|
||||||
//
|
|
||||||
// request.setBizModel(model);
|
|
||||||
// AlipayFundAccountQueryResponse response = alipayClient.execute(request);
|
|
||||||
// System.out.println(response.getBody());
|
|
||||||
//
|
|
||||||
// if (response.isSuccess()) {
|
|
||||||
// System.out.println("调用成功");
|
|
||||||
// } else {
|
|
||||||
// System.out.println("调用失败");
|
|
||||||
// // sdk版本是"4.38.0.ALL"及以上,可以参考下面的示例获取诊断链接
|
|
||||||
// // String diagnosisUrl = DiagnosisUtils.getDiagnosisUrl(response);
|
|
||||||
// // System.out.println(diagnosisUrl);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private AlipayConfig getAlipayConfig() {
|
|
||||||
// String privateKey = aliConfig.getPrivateKey();
|
|
||||||
// String alipayPublicKey = aliConfig.getPublicKey();
|
|
||||||
// AlipayConfig alipayConfig = new AlipayConfig();
|
|
||||||
// alipayConfig.setServerUrl(aliConfig.getGatewayUrl());
|
|
||||||
// alipayConfig.setAppId(aliConfig.getAppId());
|
|
||||||
// alipayConfig.setPrivateKey(privateKey);
|
|
||||||
// alipayConfig.setFormat("json");
|
|
||||||
// alipayConfig.setAlipayPublicKey(alipayPublicKey);
|
|
||||||
// alipayConfig.setCharset("UTF-8");
|
|
||||||
// alipayConfig.setSignType("RSA2");
|
|
||||||
// return alipayConfig;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// //TODO 绑定回调,获取openId,保存到数据库
|
|
||||||
// public void bindingCallback(String authCode) {
|
|
||||||
// try {
|
|
||||||
// AlipayClient alipayClient = new DefaultAlipayClient(getAlipayConfig());
|
|
||||||
// AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest();
|
|
||||||
// request.setCode(authCode);
|
|
||||||
// request.setGrantType("authorization_code");
|
|
||||||
// com.alipay.api.response.AlipaySystemOauthTokenResponse response = alipayClient.execute(request);
|
|
||||||
// if (response.isSuccess()) {
|
|
||||||
// String openId = response.getOpenId(); // 支付宝用户唯一ID
|
|
||||||
// // 将openId与当前商城用户绑定(保存到数据库)
|
|
||||||
// System.out.println("绑定成功!openId:" + openId);
|
|
||||||
// } else {
|
|
||||||
// System.out.println("绑定失败:" + response.getSubMsg());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// } catch (AlipayApiException e) {
|
|
||||||
// throw new RuntimeException(e);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
|
@ -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")
|
@GetMapping("/list")
|
||||||
// @ApiOperation(value = "查询订单列表")
|
@ApiOperation(value = "查询订单列表")
|
||||||
// public TableDataInfo list(OrderTrade orderTrade) {
|
public TableDataInfo list(OrderTrade orderTrade) {
|
||||||
// startPage();
|
startPage();
|
||||||
// List<OrderTrade> list = orderTradeService.selectMallProductList(orderTrade);
|
List<OrderTrade> list = orderTradeService.selectMallProductList(orderTrade);
|
||||||
// return getDataTable(list);
|
return getDataTable(list);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// /**
|
/**
|
||||||
// * 新增
|
* 新增
|
||||||
// */
|
*/
|
||||||
// @PostMapping("/add")
|
@PostMapping("/add")
|
||||||
// @ApiOperation(value = "新增订单")
|
@ApiOperation(value = "新增订单")
|
||||||
// public R<Object> add(@RequestBody OrderTrade orderTrade) {
|
public R<Object> add(@RequestBody OrderTrade orderTrade) {
|
||||||
// // 获取当前用户
|
// 获取当前用户
|
||||||
// Long userId = SecurityUtils.getUserId();
|
Long userId = SecurityUtils.getUserId();
|
||||||
// if (userId == null) {
|
if (userId == null) {
|
||||||
// return R.fail(HttpStatus.SHOW_ERROR_MSG,"用户未登录");
|
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("关闭成功");
|
||||||
// }
|
// }
|
||||||
// orderTrade.setUserId(userId);
|
// return AjaxResult.error("关闭失败");
|
||||||
// return R.ok(orderTradeService.insertMallProduct(orderTrade));
|
|
||||||
// }
|
// }
|
||||||
//
|
|
||||||
// /**
|
/**
|
||||||
// * 修改
|
* 关闭交易
|
||||||
// */
|
*/
|
||||||
// @PostMapping("/update")
|
// @GetMapping("/closeTrade")
|
||||||
// @ApiOperation(value = "修改订单")
|
// public AjaxResult closeTrade(String outTradeNo) throws Exception {
|
||||||
// public R<Object> update(@RequestBody OrderTrade orderTrade) {
|
// // 关闭交易
|
||||||
// // 获取当前用户
|
// AlipayTradeCloseResponse close = Factory.Payment.Common().close(outTradeNo);
|
||||||
// Long userId = SecurityUtils.getUserId();
|
// if (close.getCode().equals("10000")) {
|
||||||
// if (userId == null) {
|
// return AjaxResult.success("关闭成功");
|
||||||
// return R.fail(HttpStatus.SHOW_ERROR_MSG,"用户未登录");
|
|
||||||
// }
|
// }
|
||||||
// orderTrade.setUserId(userId);
|
// return AjaxResult.error("关闭失败");
|
||||||
// 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/dev/appPublicCert.crt
|
||||||
# # 线上支付宝公钥证书路径
|
# 沙箱支付宝公钥证书路径
|
||||||
# alipayCertPath: /opt/cert/pro/alipayCertPublicKey_RSA2.crt
|
alipayCertPath: /opt/cert/dev/alipayPublicCert.crt
|
||||||
# # 线上支付宝根证书路径
|
# 沙箱支付宝根证书路径
|
||||||
# alipayRootCertPath: /opt/cert/pro/alipayRootCert.crt
|
alipayRootCertPath: /opt/cert/dev/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,34 +1,33 @@
|
||||||
//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.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,25 @@
|
||||||
//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.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 java.io.FileNotFoundException;
|
||||||
//import javax.validation.constraints.NotNull;
|
|
||||||
//import java.io.FileNotFoundException;
|
public interface AliPayService {
|
||||||
//
|
String bindingCallback(String authCode, String state) throws FileNotFoundException;
|
||||||
//public interface AliPayService {
|
|
||||||
// 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,40 @@
|
||||||
//package com.mcwl.pay.task;
|
package com.mcwl.pay.task;
|
||||||
//
|
|
||||||
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.mcwl.pay.domain.OrderTrade;
|
||||||
//import com.mcwl.common.constant.QueueConstants;
|
import com.mcwl.pay.service.OrderTradeService;
|
||||||
//import com.mcwl.memberCenter.domain.Member;
|
import lombok.RequiredArgsConstructor;
|
||||||
//import com.mcwl.pay.domain.OrderTrade;
|
import org.joda.time.LocalDateTime;
|
||||||
//import com.mcwl.pay.service.AliPayService;
|
import org.springframework.stereotype.Component;
|
||||||
//import com.mcwl.pay.service.OrderTradeService;
|
|
||||||
//import lombok.RequiredArgsConstructor;
|
import java.util.Date;
|
||||||
//import org.joda.time.LocalDateTime;
|
import java.util.List;
|
||||||
//import org.springframework.stereotype.Component;
|
|
||||||
//
|
@Component("payTask")
|
||||||
//import java.util.Date;
|
@RequiredArgsConstructor
|
||||||
//import java.util.List;
|
public class PayTask {
|
||||||
//import java.util.function.Consumer;
|
|
||||||
//
|
private final OrderTradeService orderTradeService;
|
||||||
//@Component("payTask")
|
|
||||||
//@RequiredArgsConstructor
|
|
||||||
//public class PayTask {
|
/**
|
||||||
//
|
* 删除失效订单 间隔1h检查 0 0 0/1 * * ?
|
||||||
// private final OrderTradeService orderTradeService;
|
*/
|
||||||
//
|
public void deleteInvalidOrderTask() {
|
||||||
//
|
|
||||||
// /**
|
Date date = LocalDateTime.now().plusMinutes(-15).toDate();
|
||||||
// * 删除失效订单 间隔1h检查 0 0 0/1 * * ?
|
|
||||||
// */
|
List<OrderTrade> orderTradeList = orderTradeService.lambdaQuery()
|
||||||
// public void deleteInvalidOrderTask() {
|
.le(OrderTrade::getCreateTime, date)
|
||||||
//
|
.and(wrapper -> wrapper
|
||||||
// Date date = LocalDateTime.now().plusMinutes(-15).toDate();
|
.eq(OrderTrade::getOrderStatus, 4)
|
||||||
//
|
.or()
|
||||||
// List<OrderTrade> orderTradeList = orderTradeService.lambdaQuery()
|
.eq(OrderTrade::getPayStatus, 1)
|
||||||
// .le(OrderTrade::getCreateTime, date)
|
)
|
||||||
// .and(wrapper -> wrapper
|
.list();
|
||||||
// .eq(OrderTrade::getOrderStatus, 4)
|
|
||||||
// .or()
|
orderTradeService.removeBatchByIds(orderTradeList);
|
||||||
// .eq(OrderTrade::getPayStatus, 1)
|
|
||||||
// )
|
}
|
||||||
// .list();
|
|
||||||
//
|
|
||||||
// orderTradeService.removeBatchByIds(orderTradeList);
|
}
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
|
|
Loading…
Reference in New Issue