Merge branch 'preview' into feature/admin
# Conflicts: # mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ToActivityServiceImpl.javamaster
commit
74c13643a8
|
@ -135,6 +135,11 @@
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.aliyun</groupId>
|
<groupId>com.aliyun</groupId>
|
||||||
<artifactId>aliyun-java-sdk-core</artifactId>
|
<artifactId>aliyun-java-sdk-core</artifactId>
|
||||||
|
|
|
@ -146,7 +146,7 @@ public class OssUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getOssFilePath(String filePath){
|
public static String getOssFilePath(String filePath){
|
||||||
String fileSuf = filePath.substring(filePath.indexOf(".") + 1);
|
String fileSuf = filePath.substring(filePath.lastIndexOf(".") + 1);
|
||||||
return getOssDefaultPath() + UUID.randomUUID().toString() + "." + fileSuf;
|
return getOssDefaultPath() + UUID.randomUUID().toString() + "." + fileSuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,224 @@
|
||||||
|
package com.mcwl.web.controller.pay.AliPay;
|
||||||
|
|
||||||
|
import cn.hutool.core.lang.UUID;
|
||||||
|
import cn.hutool.extra.qrcode.QrCodeUtil;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.alipay.easysdk.factory.Factory;
|
||||||
|
import com.mcwl.common.annotation.Anonymous;
|
||||||
|
import com.mcwl.common.core.controller.BaseController;
|
||||||
|
import com.mcwl.common.core.domain.AjaxResult;
|
||||||
|
import com.mcwl.common.core.redis.RedisCache;
|
||||||
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
|
import com.mcwl.common.utils.ShareCodeUtils;
|
||||||
|
import com.mcwl.pay.domain.OrderTrade;
|
||||||
|
import com.mcwl.pay.domain.OrderTradeDto;
|
||||||
|
import com.mcwl.pay.service.AliPayService;
|
||||||
|
import com.mcwl.pay.service.OrderTradeService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.checkerframework.checker.units.qual.min;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import javax.validation.constraints.Min;
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:ChenYan
|
||||||
|
* @Project:McWl
|
||||||
|
* @Package:com.mcwl.web.controller.pay
|
||||||
|
* @Filename:OrderTradeController
|
||||||
|
* @Description 支付模块
|
||||||
|
* @Date:2025/1/3 14:46
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/ali/pay")
|
||||||
|
@Validated
|
||||||
|
@Api(tags = "支付模块")
|
||||||
|
public class AliPayController extends BaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OrderTradeService orderTradeService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AliPayService aliPayService;
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisCache redisCache;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 授权二维码
|
||||||
|
*
|
||||||
|
* @param response 响应
|
||||||
|
* @throws Exception 抛出异常
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "支付宝绑定")
|
||||||
|
@GetMapping("/generateQrCode")
|
||||||
|
public void generateQrCode(HttpServletResponse response) throws Exception {
|
||||||
|
String scope = "auth_user"; // 需要获取用户信息
|
||||||
|
String appId = "2021005114616085";
|
||||||
|
String state = ShareCodeUtils.idToCode(SecurityUtils.getUserId()); // 防止CSRF攻击
|
||||||
|
|
||||||
|
String encodedRedirectUri = URLEncoder.encode("https://3195d9a3.r27.cpolar.top/ali/pay/callback", "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
|
||||||
|
);
|
||||||
|
|
||||||
|
QrCodeUtil.generate(authUrl, 300, 300, "png", response.getOutputStream());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 授权回调
|
||||||
|
*
|
||||||
|
* @param authCode 授权码
|
||||||
|
*/
|
||||||
|
@GetMapping("/callback")
|
||||||
|
public String callback(@RequestParam("auth_code") String authCode, String state) {
|
||||||
|
|
||||||
|
System.out.println("authCode = " + authCode);
|
||||||
|
String result = aliPayService.bindingCallback(authCode, state);
|
||||||
|
if ("success".equals(result)) {
|
||||||
|
return "binding-success";
|
||||||
|
} else {
|
||||||
|
return "binding-fail";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付接口
|
||||||
|
*
|
||||||
|
* @param orderTradeDto 订单实体
|
||||||
|
* @param response 响应
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Anonymous
|
||||||
|
@PostMapping("/doPay")
|
||||||
|
@ApiOperation(value = "支付宝支付")
|
||||||
|
public void doPay(@Valid
|
||||||
|
@RequestBody
|
||||||
|
OrderTradeDto orderTradeDto,
|
||||||
|
HttpServletResponse response) throws Exception {
|
||||||
|
String qrUrl = null;
|
||||||
|
|
||||||
|
String type = orderTradeDto.getType();
|
||||||
|
|
||||||
|
if ("member".equalsIgnoreCase(type)) {
|
||||||
|
qrUrl = aliPayService.memberPay(orderTradeDto);
|
||||||
|
} else if ("points".equalsIgnoreCase(type)) {
|
||||||
|
qrUrl = aliPayService.pointsPay(orderTradeDto.getPaymentAmount());
|
||||||
|
}
|
||||||
|
|
||||||
|
QrCodeUtil.generate(qrUrl, 300, 300, "png", response.getOutputStream());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提现接口
|
||||||
|
*/
|
||||||
|
@Anonymous
|
||||||
|
@PostMapping("/fetch")
|
||||||
|
@ResponseBody
|
||||||
|
@ApiOperation(value = "提现")
|
||||||
|
public AjaxResult fetch(@Valid
|
||||||
|
@NotNull(message = "提现金额不能为空")
|
||||||
|
Double amount) throws Exception {
|
||||||
|
if (amount < 0.01) {
|
||||||
|
return AjaxResult.error("提现金额最小为0.01");
|
||||||
|
}
|
||||||
|
String outBizNo = UUID.fastUUID().toString(true);
|
||||||
|
|
||||||
|
return aliPayService.fetch(outBizNo, amount.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付回调接口
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Anonymous
|
||||||
|
@PostMapping("/notify") // 注意这里必须是POST接口
|
||||||
|
@ResponseBody
|
||||||
|
public String payNotify(HttpServletRequest request) throws Exception {
|
||||||
|
|
||||||
|
|
||||||
|
if (request.getParameter("trade_status").equals("TRADE_SUCCESS")) {
|
||||||
|
System.out.println("=========支付宝异步回调========");
|
||||||
|
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
Map<String, String[]> requestParams = request.getParameterMap();
|
||||||
|
for (String name : requestParams.keySet()) {
|
||||||
|
params.put(name, request.getParameter(name));
|
||||||
|
// System.out.println(name + " = " + request.getParameter(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 支付宝验签
|
||||||
|
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"));
|
||||||
|
// 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"); // 商户订单号
|
||||||
|
// 获取订单后缀
|
||||||
|
String suffix = code.substring(code.lastIndexOf("_") + 1);
|
||||||
|
String orderTradeJson = redisCache.getCacheObject(code);
|
||||||
|
OrderTrade orderTrade = JSONUtil.toBean(orderTradeJson, OrderTrade.class);
|
||||||
|
|
||||||
|
orderTradeService.orderHandler(orderTrade, suffix, params);
|
||||||
|
|
||||||
|
// 更新订单状态
|
||||||
|
// if (!StringUtils.isEmpty(orderTradeJson)) {
|
||||||
|
// OrderTrade orderTrade = JSONUtil.toBean(orderTradeJson, OrderTrade.class);
|
||||||
|
// // 支付宝交易凭证号
|
||||||
|
// 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,80 +1,127 @@
|
||||||
package com.mcwl.web.controller.pay.AliPay;
|
//package com.mcwl.web.controller.pay.AliPay;
|
||||||
|
//
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
//import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.lang.UUID;
|
//import cn.hutool.core.lang.UUID;
|
||||||
import cn.hutool.json.JSONUtil;
|
//import cn.hutool.json.JSONUtil;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
//import com.alibaba.fastjson.JSONObject;
|
||||||
import com.alipay.api.AlipayApiException;
|
//import com.alipay.api.AlipayApiException;
|
||||||
import com.alipay.api.AlipayClient;
|
//import com.alipay.api.AlipayClient;
|
||||||
import com.alipay.api.AlipayConfig;
|
//import com.alipay.api.AlipayConfig;
|
||||||
import com.alipay.api.DefaultAlipayClient;
|
//import com.alipay.api.DefaultAlipayClient;
|
||||||
import com.alipay.api.diagnosis.DiagnosisUtils;
|
//import com.alipay.api.diagnosis.DiagnosisUtils;
|
||||||
import com.alipay.api.domain.AlipayFundAccountQueryModel;
|
//import com.alipay.api.domain.AlipayFundAccountQueryModel;
|
||||||
import com.alipay.api.domain.AlipayFundTransUniTransferModel;
|
//import com.alipay.api.domain.AlipayFundTransUniTransferModel;
|
||||||
import com.alipay.api.domain.Participant;
|
//import com.alipay.api.domain.Participant;
|
||||||
import com.alipay.api.request.AlipayFundAccountQueryRequest;
|
//import com.alipay.api.request.AlipayFundAccountQueryRequest;
|
||||||
import com.alipay.api.request.AlipayFundTransUniTransferRequest;
|
//import com.alipay.api.request.AlipayFundTransUniTransferRequest;
|
||||||
import com.alipay.api.response.AlipayFundAccountQueryResponse;
|
//import com.alipay.api.request.AlipaySystemOauthTokenRequest;
|
||||||
import com.alipay.api.response.AlipayFundTransUniTransferResponse;
|
//import com.alipay.api.request.AlipayUserInfoAuthRequest;
|
||||||
import com.alipay.easysdk.base.oauth.models.AlipaySystemOauthTokenResponse;
|
//import com.alipay.api.response.AlipayFundAccountQueryResponse;
|
||||||
import com.alipay.easysdk.factory.Factory;
|
//import com.alipay.api.response.AlipayFundTransUniTransferResponse;
|
||||||
import com.alipay.easysdk.kernel.Config;
|
//import com.alipay.easysdk.base.oauth.models.AlipaySystemOauthTokenResponse;
|
||||||
import com.alipay.easysdk.payment.facetoface.models.AlipayTradePrecreateResponse;
|
//import com.alipay.easysdk.factory.Factory;
|
||||||
import com.mcwl.common.core.redis.RedisCache;
|
//import com.alipay.easysdk.kernel.Config;
|
||||||
import com.mcwl.common.exception.ServiceException;
|
//import com.alipay.easysdk.payment.facetoface.models.AlipayTradePrecreateResponse;
|
||||||
import com.mcwl.common.utils.SecurityUtils;
|
//import com.mcwl.common.core.redis.RedisCache;
|
||||||
import com.mcwl.memberCenter.domain.MemberLevel;
|
//import com.mcwl.common.exception.ServiceException;
|
||||||
import com.mcwl.memberCenter.service.MemberLevelService;
|
//import com.mcwl.common.utils.SecurityUtils;
|
||||||
import com.mcwl.pay.config.AliConfig;
|
//import com.mcwl.memberCenter.domain.MemberLevel;
|
||||||
import com.mcwl.pay.domain.OrderTrade;
|
//import com.mcwl.memberCenter.service.MemberLevelService;
|
||||||
import com.mcwl.pay.domain.OrderTradeDto;
|
//import com.mcwl.pay.config.AliConfig;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
//import com.mcwl.pay.domain.OrderTrade;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import com.mcwl.pay.domain.OrderTradeDto;
|
||||||
import org.springframework.stereotype.Component;
|
//import lombok.extern.slf4j.Slf4j;
|
||||||
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import java.util.Optional;
|
//import org.springframework.stereotype.Component;
|
||||||
import java.util.concurrent.TimeUnit;
|
//
|
||||||
|
//import java.util.Optional;
|
||||||
/**
|
//import java.util.concurrent.TimeUnit;
|
||||||
* 支付宝支付
|
//
|
||||||
*/
|
///**
|
||||||
@Component
|
// * 支付宝支付
|
||||||
@Slf4j
|
// */
|
||||||
public class AliPayIntegration {
|
//@Component
|
||||||
|
//@Slf4j
|
||||||
@Autowired
|
//public class AliPayIntegration {
|
||||||
private RedisCache redisCache;
|
//
|
||||||
|
// @Autowired
|
||||||
|
// private RedisCache redisCache;
|
||||||
@Autowired
|
//
|
||||||
private MemberLevelService memberLevelService;
|
//
|
||||||
|
// @Autowired
|
||||||
|
// private MemberLevelService memberLevelService;
|
||||||
@Autowired
|
//
|
||||||
private AliConfig aliConfig;
|
//
|
||||||
|
// @Autowired
|
||||||
|
// private AliConfig aliConfig;
|
||||||
public AliPayIntegration(Config config) {
|
//
|
||||||
Factory.setOptions(config);
|
//
|
||||||
}
|
// 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不存在");
|
// * 调用支付宝预下订单接口
|
||||||
|
// *
|
||||||
|
// * @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信息
|
||||||
|
@ -83,211 +130,187 @@ public class AliPayIntegration {
|
||||||
// tradeEntity.setCode(UUID.randomUUID().toString(true).substring(0, 30));
|
// tradeEntity.setCode(UUID.randomUUID().toString(true).substring(0, 30));
|
||||||
// tradeEntity.setUserId(SecurityUtils.getUserId());
|
// tradeEntity.setUserId(SecurityUtils.getUserId());
|
||||||
// tradeEntity.setUserName(SecurityUtils.getUsername());
|
// tradeEntity.setUserName(SecurityUtils.getUsername());
|
||||||
// tradeEntity.setProductName(mallProduct.getProductName());
|
// tradeEntity.setProductName(memberLevel.getMemberName());
|
||||||
//
|
//
|
||||||
// //调用支付宝的接口
|
// //调用支付宝的接口
|
||||||
// AlipayTradePrecreateResponse payResponse = Factory.Payment.FaceToFace()
|
// AlipayTradePrecreateResponse payResponse = Factory.Payment.FaceToFace()
|
||||||
// .preCreate(mallProduct.getProductName(),
|
// // 设置过期时
|
||||||
// tradeEntity.getCode() + "_product",
|
// .preCreate(memberLevel.getMemberName(),
|
||||||
|
// tradeEntity.getCode() + "_member",
|
||||||
// orderTradeDto.getPaymentAmount().toString());
|
// orderTradeDto.getPaymentAmount().toString());
|
||||||
// // 缓存到redis
|
// // 缓存到redis
|
||||||
// redisCache.setCacheObject(tradeEntity.getCode() + "_product", JSONUtil.toJsonStr(tradeEntity), 3, TimeUnit.MINUTES);
|
// 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");
|
//// AlipayTradePrecreateResponse payResponse = Factory.Payment.FaceToFace().preCreate("订单主题:Mac笔记本", "LS123qwe123", "19999");
|
||||||
// //参照官方文档响应示例,解析返回结果
|
// //参照官方文档响应示例,解析返回结果
|
||||||
// String httpBodyStr = payResponse.getHttpBody();
|
// String httpBodyStr = payResponse.getHttpBody();
|
||||||
// JSONObject jsonObject = JSONObject.parseObject(httpBodyStr);
|
// JSONObject jsonObject = JSONObject.parseObject(httpBodyStr);
|
||||||
// return jsonObject.getJSONObject("alipay_trade_precreate_response").get("qr_code").toString();
|
// return jsonObject.getJSONObject("alipay_trade_precreate_response").get("qr_code").toString();
|
||||||
// }
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 调用支付宝预下订单接口
|
// * 调用支付宝预下订单接口
|
||||||
*
|
// *
|
||||||
* @param orderTradeDto 订单实体
|
// * @param paymentAmount 充值金额
|
||||||
* @return 二维码url
|
// * @return 二维码url
|
||||||
* @throws Exception
|
// * @throws Exception
|
||||||
*/
|
// */
|
||||||
public String memberPay(OrderTradeDto orderTradeDto) throws Exception {
|
// public String pointsPay(Double paymentAmount) throws Exception {
|
||||||
|
// // 设置orderTrade信息
|
||||||
// 会员等级id
|
// OrderTrade tradeEntity = new OrderTrade();
|
||||||
Integer productId = orderTradeDto.getProductId();
|
// tradeEntity.setCode(UUID.randomUUID().toString(true).substring(0, 30));
|
||||||
|
// tradeEntity.setUserId(SecurityUtils.getUserId());
|
||||||
if (!Optional.ofNullable(productId).isPresent()) {
|
// tradeEntity.setProductId(-1);
|
||||||
throw new ServiceException("memberLevelId不能为空");
|
// tradeEntity.setProductName("积分充值");
|
||||||
}
|
// tradeEntity.setUserName(SecurityUtils.getUsername());
|
||||||
|
// tradeEntity.setPaymentAmount(paymentAmount.intValue());
|
||||||
MemberLevel memberLevel = memberLevelService.getById(productId);
|
//
|
||||||
|
// //调用支付宝的接口
|
||||||
if (!Optional.ofNullable(memberLevel).isPresent()) {
|
// AlipayTradePrecreateResponse payResponse = Factory.Payment.FaceToFace()
|
||||||
throw new ServiceException("memberLevel不存在");
|
// .preCreate(tradeEntity.getProductName(),
|
||||||
}
|
// tradeEntity.getCode() + "_points",
|
||||||
|
// tradeEntity.getPaymentAmount().toString());
|
||||||
// 设置orderTrade信息
|
// // 缓存到redis
|
||||||
OrderTrade tradeEntity = new OrderTrade();
|
// redisCache.setCacheObject(tradeEntity.getCode() + "_points", JSONUtil.toJsonStr(tradeEntity), 3, TimeUnit.MINUTES);
|
||||||
BeanUtil.copyProperties(orderTradeDto, tradeEntity);
|
// //参照官方文档响应示例,解析返回结果
|
||||||
tradeEntity.setCode(UUID.randomUUID().toString(true).substring(0, 30));
|
// String httpBodyStr = payResponse.getHttpBody();
|
||||||
tradeEntity.setUserId(SecurityUtils.getUserId());
|
// JSONObject jsonObject = JSONObject.parseObject(httpBodyStr);
|
||||||
tradeEntity.setUserName(SecurityUtils.getUsername());
|
// return jsonObject.getJSONObject("alipay_trade_precreate_response").get("qr_code").toString();
|
||||||
tradeEntity.setProductName(memberLevel.getMemberName());
|
// }
|
||||||
|
//
|
||||||
//调用支付宝的接口
|
// /**
|
||||||
AlipayTradePrecreateResponse payResponse = Factory.Payment.FaceToFace()
|
// * 支付宝转账方法
|
||||||
// 设置过期时
|
// * @param outBizNo 外部业务单号
|
||||||
.preCreate(memberLevel.getMemberName(),
|
// * @param payerUserId 付款方用户ID
|
||||||
tradeEntity.getCode() + "_member",
|
// * @param payeeUserId 收款方用户ID
|
||||||
orderTradeDto.getPaymentAmount().toString());
|
// * @param amount 转账金额
|
||||||
// 缓存到redis
|
// * @return 返回支付宝转账响应的内容
|
||||||
redisCache.setCacheObject(tradeEntity.getCode() + "_member", JSONUtil.toJsonStr(tradeEntity), 3, TimeUnit.MINUTES);
|
// */
|
||||||
redisCache.setCacheObject(tradeEntity.getCode() + "_member" + "_promotionId", orderTradeDto.getPromotionId(), 3, TimeUnit.MINUTES);
|
// public String transfer(String outBizNo, String payerUserId, String payeeUserId, String amount) throws AlipayApiException {
|
||||||
// AlipayTradePrecreateResponse payResponse = Factory.Payment.FaceToFace().preCreate("订单主题:Mac笔记本", "LS123qwe123", "19999");
|
//
|
||||||
//参照官方文档响应示例,解析返回结果
|
// // 初始化SDK
|
||||||
String httpBodyStr = payResponse.getHttpBody();
|
// AlipayClient alipayClient = new DefaultAlipayClient(getAlipayConfig());
|
||||||
JSONObject jsonObject = JSONObject.parseObject(httpBodyStr);
|
//
|
||||||
return jsonObject.getJSONObject("alipay_trade_precreate_response").get("qr_code").toString();
|
// // 构造请求参数以调用接口
|
||||||
}
|
// AlipayFundTransUniTransferRequest request = new AlipayFundTransUniTransferRequest();
|
||||||
|
// AlipayFundTransUniTransferModel model = new AlipayFundTransUniTransferModel();
|
||||||
|
//
|
||||||
/**
|
// // 设置商家侧唯一订单号
|
||||||
* 调用支付宝预下订单接口
|
// model.setOutBizNo(outBizNo);
|
||||||
*
|
//
|
||||||
* @param paymentAmount 充值金额
|
// // 设置订单总金额
|
||||||
* @return 二维码url
|
// model.setTransAmount(amount);
|
||||||
* @throws Exception
|
//
|
||||||
*/
|
// // 设置描述特定的业务场景
|
||||||
public String pointsPay(Double paymentAmount) throws Exception {
|
// model.setBizScene("DIRECT_TRANSFER");
|
||||||
// 设置orderTrade信息
|
//
|
||||||
OrderTrade tradeEntity = new OrderTrade();
|
// // 设置业务产品码
|
||||||
tradeEntity.setCode(UUID.randomUUID().toString(true).substring(0, 30));
|
// model.setProductCode("TRANS_ACCOUNT_NO_PWD");
|
||||||
tradeEntity.setUserId(SecurityUtils.getUserId());
|
//
|
||||||
tradeEntity.setProductId(-1);
|
// // 设置转账业务的标题
|
||||||
tradeEntity.setProductName("积分充值");
|
// model.setOrderTitle("测试");
|
||||||
tradeEntity.setUserName(SecurityUtils.getUsername());
|
//
|
||||||
tradeEntity.setPaymentAmount(paymentAmount.intValue());
|
// // 设置收款方信息
|
||||||
|
// Participant payeeInfo = new Participant();
|
||||||
//调用支付宝的接口
|
// payeeInfo.setCertType("IDENTITY_CARD");
|
||||||
AlipayTradePrecreateResponse payResponse = Factory.Payment.FaceToFace()
|
// payeeInfo.setCertNo("1201152******72917");
|
||||||
.preCreate(tradeEntity.getProductName(),
|
// payeeInfo.setIdentity("2088123412341234");
|
||||||
tradeEntity.getCode() + "_points",
|
// payeeInfo.setName("黄龙国际有限公司");
|
||||||
tradeEntity.getPaymentAmount().toString());
|
// payeeInfo.setIdentityType("ALIPAY_USER_ID");
|
||||||
// 缓存到redis
|
// model.setPayeeInfo(payeeInfo);
|
||||||
redisCache.setCacheObject(tradeEntity.getCode() + "_points", JSONUtil.toJsonStr(tradeEntity), 3, TimeUnit.MINUTES);
|
//
|
||||||
//参照官方文档响应示例,解析返回结果
|
// // 设置业务备注
|
||||||
String httpBodyStr = payResponse.getHttpBody();
|
// model.setRemark("201905代发");
|
||||||
JSONObject jsonObject = JSONObject.parseObject(httpBodyStr);
|
//
|
||||||
return jsonObject.getJSONObject("alipay_trade_precreate_response").get("qr_code").toString();
|
// // 设置转账业务请求的扩展参数
|
||||||
}
|
// model.setBusinessParams("{\"payer_show_name_use_alias\":\"true\"}");
|
||||||
|
//
|
||||||
/**
|
// request.setBizModel(model);
|
||||||
* 支付宝转账方法
|
// AlipayFundTransUniTransferResponse response = alipayClient.certificateExecute(request);
|
||||||
* @param outBizNo 外部业务单号
|
// System.out.println(response.getBody());
|
||||||
* @param payerUserId 付款方用户ID
|
//
|
||||||
* @param payeeUserId 收款方用户ID
|
// if (response.isSuccess()) {
|
||||||
* @param amount 转账金额
|
// System.out.println("调用成功");
|
||||||
* @return 返回支付宝转账响应的内容
|
// } else {
|
||||||
*/
|
// System.out.println("调用失败");
|
||||||
public String transfer(String outBizNo, String payerUserId, String payeeUserId, String amount) throws AlipayApiException {
|
// // sdk版本是"4.38.0.ALL"及以上,可以参考下面的示例获取诊断链接
|
||||||
|
// String diagnosisUrl = DiagnosisUtils.getDiagnosisUrl(response);
|
||||||
// 初始化SDK
|
// System.out.println(diagnosisUrl);
|
||||||
AlipayClient alipayClient = new DefaultAlipayClient(getAlipayConfig());
|
// }
|
||||||
|
// return response.getBody();
|
||||||
// 构造请求参数以调用接口
|
// }
|
||||||
AlipayFundTransUniTransferRequest request = new AlipayFundTransUniTransferRequest();
|
//
|
||||||
AlipayFundTransUniTransferModel model = new AlipayFundTransUniTransferModel();
|
// /**
|
||||||
|
// * 查看余额
|
||||||
// 设置商家侧唯一订单号
|
// */
|
||||||
model.setOutBizNo(outBizNo);
|
// public void balance() throws Exception {
|
||||||
|
//
|
||||||
// 设置订单总金额
|
// AlipaySystemOauthTokenResponse token = Factory.Base.OAuth().getToken("code");
|
||||||
model.setTransAmount(amount);
|
//
|
||||||
|
//
|
||||||
// 设置描述特定的业务场景
|
// // 初始化SDK
|
||||||
model.setBizScene("DIRECT_TRANSFER");
|
// AlipayClient alipayClient = new DefaultAlipayClient(getAlipayConfig());
|
||||||
|
//
|
||||||
// 设置业务产品码
|
// // 构造请求参数以调用接口
|
||||||
model.setProductCode("TRANS_ACCOUNT_NO_PWD");
|
// AlipayFundAccountQueryRequest request = new AlipayFundAccountQueryRequest();
|
||||||
|
// AlipayFundAccountQueryModel model = new AlipayFundAccountQueryModel();
|
||||||
// 设置转账业务的标题
|
//
|
||||||
model.setOrderTitle("测试");
|
// // uid参数未来计划废弃,存量商户可继续使用,新商户请使用openid。请根据应用-开发配置-openid配置选择支持的字段。
|
||||||
|
// // model.setAlipayUserId("2088301409188095");
|
||||||
// 设置收款方信息
|
//
|
||||||
Participant payeeInfo = new Participant();
|
// // 设置支付宝openId
|
||||||
payeeInfo.setCertType("IDENTITY_CARD");
|
// model.setAlipayOpenId("061P6NAblcWDWJoDRxSVvOYz-ufp-3wQaA4E_szQyMFTXse");
|
||||||
payeeInfo.setCertNo("1201152******72917");
|
//
|
||||||
payeeInfo.setIdentity("2088123412341234");
|
// // 设置查询的账号类型
|
||||||
payeeInfo.setName("黄龙国际有限公司");
|
// model.setAccountType("ACCTRANS_ACCOUNT");
|
||||||
payeeInfo.setIdentityType("ALIPAY_USER_ID");
|
//
|
||||||
model.setPayeeInfo(payeeInfo);
|
// request.setBizModel(model);
|
||||||
|
// AlipayFundAccountQueryResponse response = alipayClient.execute(request);
|
||||||
// 设置业务备注
|
// System.out.println(response.getBody());
|
||||||
model.setRemark("201905代发");
|
//
|
||||||
|
// if (response.isSuccess()) {
|
||||||
// 设置转账业务请求的扩展参数
|
// System.out.println("调用成功");
|
||||||
model.setBusinessParams("{\"payer_show_name_use_alias\":\"true\"}");
|
// } else {
|
||||||
|
// System.out.println("调用失败");
|
||||||
request.setBizModel(model);
|
// // sdk版本是"4.38.0.ALL"及以上,可以参考下面的示例获取诊断链接
|
||||||
AlipayFundTransUniTransferResponse response = alipayClient.certificateExecute(request);
|
// // String diagnosisUrl = DiagnosisUtils.getDiagnosisUrl(response);
|
||||||
System.out.println(response.getBody());
|
// // System.out.println(diagnosisUrl);
|
||||||
|
// }
|
||||||
if (response.isSuccess()) {
|
// }
|
||||||
System.out.println("调用成功");
|
//
|
||||||
} else {
|
// private AlipayConfig getAlipayConfig() {
|
||||||
System.out.println("调用失败");
|
// String privateKey = aliConfig.getPrivateKey();
|
||||||
// sdk版本是"4.38.0.ALL"及以上,可以参考下面的示例获取诊断链接
|
// String alipayPublicKey = aliConfig.getPublicKey();
|
||||||
String diagnosisUrl = DiagnosisUtils.getDiagnosisUrl(response);
|
// AlipayConfig alipayConfig = new AlipayConfig();
|
||||||
System.out.println(diagnosisUrl);
|
// alipayConfig.setServerUrl(aliConfig.getGatewayUrl());
|
||||||
}
|
// alipayConfig.setAppId(aliConfig.getAppId());
|
||||||
return response.getBody();
|
// alipayConfig.setPrivateKey(privateKey);
|
||||||
}
|
// alipayConfig.setFormat("json");
|
||||||
|
// alipayConfig.setAlipayPublicKey(alipayPublicKey);
|
||||||
/**
|
// alipayConfig.setCharset("UTF-8");
|
||||||
* 查看余额
|
// alipayConfig.setSignType("RSA2");
|
||||||
*/
|
// return alipayConfig;
|
||||||
public void balance() throws Exception {
|
// }
|
||||||
|
//
|
||||||
AlipaySystemOauthTokenResponse token = Factory.Base.OAuth().getToken("code");
|
// //TODO 绑定回调,获取openId,保存到数据库
|
||||||
|
// public void bindingCallback(String authCode) {
|
||||||
|
// try {
|
||||||
// 初始化SDK
|
// AlipayClient alipayClient = new DefaultAlipayClient(getAlipayConfig());
|
||||||
AlipayClient alipayClient = new DefaultAlipayClient(getAlipayConfig());
|
// AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest();
|
||||||
|
// request.setCode(authCode);
|
||||||
// 构造请求参数以调用接口
|
// request.setGrantType("authorization_code");
|
||||||
AlipayFundAccountQueryRequest request = new AlipayFundAccountQueryRequest();
|
// com.alipay.api.response.AlipaySystemOauthTokenResponse response = alipayClient.execute(request);
|
||||||
AlipayFundAccountQueryModel model = new AlipayFundAccountQueryModel();
|
// if (response.isSuccess()) {
|
||||||
|
// String openId = response.getOpenId(); // 支付宝用户唯一ID
|
||||||
// uid参数未来计划废弃,存量商户可继续使用,新商户请使用openid。请根据应用-开发配置-openid配置选择支持的字段。
|
// // 将openId与当前商城用户绑定(保存到数据库)
|
||||||
// model.setAlipayUserId("2088301409188095");
|
// System.out.println("绑定成功!openId:" + openId);
|
||||||
|
// } else {
|
||||||
// 设置支付宝openId
|
// System.out.println("绑定失败:" + response.getSubMsg());
|
||||||
model.setAlipayOpenId("061P6NAblcWDWJoDRxSVvOYz-ufp-3wQaA4E_szQyMFTXse");
|
// }
|
||||||
|
//
|
||||||
// 设置查询的账号类型
|
// } catch (AlipayApiException e) {
|
||||||
model.setAccountType("ACCTRANS_ACCOUNT");
|
// throw new RuntimeException(e);
|
||||||
|
// }
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
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.core.util.RandomUtil;
|
||||||
import cn.hutool.extra.qrcode.QrCodeUtil;
|
import cn.hutool.extra.qrcode.QrCodeUtil;
|
||||||
|
import cn.hutool.json.JSON;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.alipay.api.AlipayApiException;
|
||||||
|
import com.alipay.api.request.AlipaySystemOauthTokenRequest;
|
||||||
|
import com.alipay.easysdk.base.oauth.models.AlipaySystemOauthTokenResponse;
|
||||||
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.AlipayTradeQueryResponse;
|
import com.alipay.easysdk.payment.common.models.AlipayTradeQueryResponse;
|
||||||
|
@ -16,6 +21,7 @@ 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.domain.OrderTradeDto;
|
import com.mcwl.pay.domain.OrderTradeDto;
|
||||||
|
import com.mcwl.pay.service.AliPayService;
|
||||||
import com.mcwl.pay.service.OrderTradeService;
|
import com.mcwl.pay.service.OrderTradeService;
|
||||||
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;
|
||||||
|
@ -23,9 +29,13 @@ 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 java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author:ChenYan
|
* @Author:ChenYan
|
||||||
|
@ -47,13 +57,6 @@ public class OrderTradeController extends BaseController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private OrderTradeService orderTradeService;
|
private OrderTradeService orderTradeService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private AliPayIntegration aliPayIntegration;
|
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RedisCache redisCache;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询列表
|
* 查询列表
|
||||||
*/
|
*/
|
||||||
|
@ -104,30 +107,6 @@ public class OrderTradeController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 支付接口
|
|
||||||
*
|
|
||||||
* @param orderTradeDto 订单实体
|
|
||||||
* @param response 响应
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
@Anonymous
|
|
||||||
@PostMapping("/doPay")
|
|
||||||
public void doPay(@RequestBody OrderTradeDto orderTradeDto, HttpServletResponse response) throws Exception {
|
|
||||||
String qrUrl = null;
|
|
||||||
|
|
||||||
String type = orderTradeDto.getType();
|
|
||||||
|
|
||||||
if ("member".equalsIgnoreCase(type)) {
|
|
||||||
qrUrl = aliPayIntegration.memberPay(orderTradeDto);
|
|
||||||
} else if ("points".equalsIgnoreCase(type)) {
|
|
||||||
qrUrl = aliPayIntegration.pointsPay(orderTradeDto.getPaymentAmount());
|
|
||||||
}
|
|
||||||
|
|
||||||
QrCodeUtil.generate(qrUrl, 300, 300, "png", response.getOutputStream());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/queryTradeStatus")
|
@GetMapping("/queryTradeStatus")
|
||||||
public Object queryTradeStatus(@RequestParam String outTradeNo) throws Exception {
|
public Object queryTradeStatus(@RequestParam String outTradeNo) throws Exception {
|
||||||
Factory.setOptions(config);
|
Factory.setOptions(config);
|
||||||
|
@ -144,102 +123,5 @@ public class OrderTradeController extends BaseController {
|
||||||
return map.get("alipay_trade_query_response");
|
return map.get("alipay_trade_query_response");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 查看余额
|
|
||||||
*/
|
|
||||||
@GetMapping("/balance")
|
|
||||||
public void balance() throws Exception {
|
|
||||||
aliPayIntegration.balance();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 提现接口
|
|
||||||
*/
|
|
||||||
@Anonymous
|
|
||||||
@PostMapping("/withdraw")
|
|
||||||
public void withdraw(@RequestBody OrderTradeDto orderTradeDto, HttpServletResponse response) throws Exception {
|
|
||||||
String outBizNo = UUID.fastUUID().toString(true);
|
|
||||||
String payerUserId = "2088102167258880";
|
|
||||||
String payeeUserId = "2088102167258880";
|
|
||||||
String amount = "100";
|
|
||||||
aliPayIntegration.transfer(outBizNo, payerUserId, payeeUserId, amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 支付回调接口
|
|
||||||
*
|
|
||||||
* @param request
|
|
||||||
* @return
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
@Anonymous
|
|
||||||
@PostMapping("/notify") // 注意这里必须是POST接口
|
|
||||||
public String payNotify(HttpServletRequest request) throws Exception {
|
|
||||||
|
|
||||||
|
|
||||||
if (request.getParameter("trade_status").equals("TRADE_SUCCESS")) {
|
|
||||||
System.out.println("=========支付宝异步回调========");
|
|
||||||
|
|
||||||
Map<String, String> params = new HashMap<>();
|
|
||||||
Map<String, String[]> requestParams = request.getParameterMap();
|
|
||||||
for (String name : requestParams.keySet()) {
|
|
||||||
params.put(name, request.getParameter(name));
|
|
||||||
// System.out.println(name + " = " + request.getParameter(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 支付宝验签
|
|
||||||
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"));
|
|
||||||
// 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"); // 商户订单号
|
|
||||||
// 获取订单后缀
|
|
||||||
String suffix = code.substring(code.lastIndexOf("_") + 1);
|
|
||||||
String orderTradeJson = redisCache.getCacheObject(code);
|
|
||||||
OrderTrade orderTrade = JSONUtil.toBean(orderTradeJson, OrderTrade.class);
|
|
||||||
|
|
||||||
orderTradeService.orderHandler(orderTrade, suffix, params);
|
|
||||||
|
|
||||||
// 更新订单状态
|
|
||||||
// if (!StringUtils.isEmpty(orderTradeJson)) {
|
|
||||||
// OrderTrade orderTrade = JSONUtil.toBean(orderTradeJson, OrderTrade.class);
|
|
||||||
// // 支付宝交易凭证号
|
|
||||||
// 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";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ 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.page.PageDomain;
|
import com.mcwl.common.core.page.PageDomain;
|
||||||
import com.mcwl.common.core.page.TableDataInfo;
|
import com.mcwl.common.core.page.TableDataInfo;
|
||||||
|
import com.mcwl.common.domain.IdsParam;
|
||||||
import com.mcwl.common.utils.SecurityUtils;
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
import com.mcwl.resource.domain.ModelProduct;
|
import com.mcwl.resource.domain.ModelProduct;
|
||||||
import com.mcwl.resource.domain.dto.ModelImagePageRes;
|
import com.mcwl.resource.domain.dto.ModelImagePageRes;
|
||||||
|
@ -19,7 +20,11 @@ import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -69,7 +74,11 @@ public class MallProductController extends BaseController {
|
||||||
public AjaxResult Malifile(@RequestParam MultipartFile file) {
|
public AjaxResult Malifile(@RequestParam MultipartFile file) {
|
||||||
|
|
||||||
String s = OssUtil.uploadMultipartFile(file);
|
String s = OssUtil.uploadMultipartFile(file);
|
||||||
return AjaxResult.success(s);
|
String fileName = file.getOriginalFilename();
|
||||||
|
Map<String, String> map = new HashMap<>();
|
||||||
|
map.put("fileName", fileName);
|
||||||
|
map.put("url", s);
|
||||||
|
return AjaxResult.success(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -145,9 +154,9 @@ public class MallProductController extends BaseController {
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "删除模型")
|
@ApiOperation(value = "删除模型")
|
||||||
@PostMapping("delete")
|
@GetMapping("delete")
|
||||||
public AjaxResult delete(@RequestBody ModelProduct modelVersion) {
|
public AjaxResult delete(@Valid @NotNull(message = "模型id不能为空") Long id) {
|
||||||
modelService.removeById(modelVersion.getId());
|
modelService.removeById(id);
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -42,7 +43,9 @@ public class ModelImageController {
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "图片列表")
|
@ApiOperation(value = "图片列表")
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
public TableDataInfo list(@RequestBody PageDomain pageDomain) {
|
public TableDataInfo list(@RequestBody
|
||||||
|
@Valid
|
||||||
|
PageDomain pageDomain) {
|
||||||
ModelImagePageRes imagePageRes = new ModelImagePageRes();
|
ModelImagePageRes imagePageRes = new ModelImagePageRes();
|
||||||
BeanUtil.copyProperties(pageDomain, imagePageRes);
|
BeanUtil.copyProperties(pageDomain, imagePageRes);
|
||||||
return modelImageService.listByPage(imagePageRes);
|
return modelImageService.listByPage(imagePageRes);
|
||||||
|
@ -52,9 +55,9 @@ public class ModelImageController {
|
||||||
* 图片详情
|
* 图片详情
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "图片详情")
|
@ApiOperation(value = "图片详情")
|
||||||
@GetMapping("/detail/{imageId}")
|
@GetMapping("/detail")
|
||||||
public AjaxResult detail(@PathVariable @NotNull(message = "图片id不能为空") Long imageId) {
|
public AjaxResult detail(@Valid @NotNull(message = "图片id不能为空") Long id) {
|
||||||
ModelImageVo modelImageVo = modelImageService.getDetail(imageId);
|
ModelImageVo modelImageVo = modelImageService.getDetail(id);
|
||||||
return AjaxResult.success(modelImageVo);
|
return AjaxResult.success(modelImageVo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,9 +65,9 @@ public class ModelImageController {
|
||||||
* 图片删除
|
* 图片删除
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "图片删除")
|
@ApiOperation(value = "图片删除")
|
||||||
@GetMapping("/delete/{imageId}")
|
@GetMapping("/delete")
|
||||||
public AjaxResult delete(@PathVariable @NotNull(message = "图片id不能为空") Long imageId) {
|
public AjaxResult delete(@Valid @NotNull(message = "图片id不能为空") Long id) {
|
||||||
modelImageService.removeById(imageId);
|
modelImageService.removeById(id);
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +76,7 @@ public class ModelImageController {
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "图片修改")
|
@ApiOperation(value = "图片修改")
|
||||||
@PostMapping("/update")
|
@PostMapping("/update")
|
||||||
public AjaxResult update(@RequestBody ModelImageRes modelImageRes) {
|
public AjaxResult update(@Valid @RequestBody ModelImageRes modelImageRes) {
|
||||||
modelImageService.updateById(modelImageRes);
|
modelImageService.updateById(modelImageRes);
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
@ -84,7 +87,7 @@ public class ModelImageController {
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "图片发布")
|
@ApiOperation(value = "图片发布")
|
||||||
@PostMapping("/publish")
|
@PostMapping("/publish")
|
||||||
public AjaxResult publish(@RequestBody ModelImageRes modelImageRes) {
|
public AjaxResult publish(@Valid @RequestBody ModelImageRes modelImageRes) {
|
||||||
modelImageService.publish(modelImageRes);
|
modelImageService.publish(modelImageRes);
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
@ -94,9 +97,9 @@ public class ModelImageController {
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "图片点赞/取消")
|
@ApiOperation(value = "图片点赞/取消")
|
||||||
@RepeatSubmit
|
@RepeatSubmit
|
||||||
@GetMapping("/imageLike/{imageId}")
|
@GetMapping("/imageLike")
|
||||||
public AjaxResult like(@PathVariable @NotNull(message = "图片id不能为空") Long imageId) {
|
public AjaxResult like(@Valid @NotNull(message = "图片id不能为空") Long id) {
|
||||||
modelImageLikeService.like(imageId);
|
modelImageLikeService.like(id);
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class ToActivityController extends BaseController {
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
public TableDataInfo list(@RequestBody ToActivity toActivity)
|
public TableDataInfo list(@RequestBody ToActivity toActivity)
|
||||||
{
|
{
|
||||||
startPage();
|
// startPage();
|
||||||
List<ToActivity> list = toActivityService.selectToActivityList(toActivity);
|
List<ToActivity> list = toActivityService.selectToActivityList(toActivity);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
# 发件人(必须正确,否则发送失败)
|
||||||
|
from = 2119157836@qq.com
|
||||||
|
# 密码(注意,某些邮箱需要为SMTP服务单独设置授权码)
|
||||||
|
pass = wetaiadftmidejab
|
||||||
|
# 使用SSL安全连接
|
||||||
|
sslEnable = true
|
|
@ -0,0 +1,11 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh-CN">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>绑定失败</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>支付宝账号绑定失败!</h1>
|
||||||
|
<p>请检查您的网络或稍后重试。</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,11 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh-CN">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>绑定成功</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>支付宝账号绑定成功!</h1>
|
||||||
|
<p>您可以返回用户中心继续操作。</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -1,18 +1,6 @@
|
||||||
package com.mcwl.memberCenter;
|
package com.mcwl.memberCenter;
|
||||||
|
|
||||||
import com.mcwl.McWlApplication;
|
|
||||||
import com.mcwl.common.core.domain.AjaxResult;
|
|
||||||
import com.mcwl.memberCenter.consumer.EmptyPointsRemindConsumer;
|
|
||||||
import com.mcwl.memberCenter.service.MemberLevelService;
|
|
||||||
import com.mcwl.memberCenter.service.MemberService;
|
|
||||||
import com.mcwl.memberCenter.task.UserMemberTask;
|
|
||||||
import com.mcwl.web.controller.memberCenter.MemberController;
|
|
||||||
import com.mcwl.web.controller.memberCenter.MemberLevelController;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
|
|
||||||
|
|
||||||
public class MemberCenterTest {
|
public class MemberCenterTest {
|
||||||
|
|
|
@ -30,6 +30,12 @@
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.sun.mail</groupId>
|
||||||
|
<artifactId>javax.mail</artifactId>
|
||||||
|
<version>1.6.2</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- Jackson -->
|
<!-- Jackson -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
package com.mcwl.common.domain;
|
package com.mcwl.common.domain;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
@ApiModel(description = "id集合")
|
||||||
public class IdsParam {
|
public class IdsParam {
|
||||||
|
@ApiModelProperty(value = "id集合")
|
||||||
private List<Long> ids;
|
private List<Long> ids;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,9 +20,17 @@ public class MyMetaObjectHandler implements MetaObjectHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void insertFill(MetaObject metaObject) {
|
public void insertFill(MetaObject metaObject) {
|
||||||
|
try {
|
||||||
this.strictInsertFill(metaObject, "createBy", String.class, SecurityUtils.getUsername());
|
this.strictInsertFill(metaObject, "createBy", String.class, SecurityUtils.getUsername());
|
||||||
|
} catch (Exception e) {
|
||||||
|
this.strictInsertFill(metaObject, "createBy", String.class, "");
|
||||||
|
}
|
||||||
this.strictInsertFill(metaObject, "createTime", Date.class, new Date());
|
this.strictInsertFill(metaObject, "createTime", Date.class, new Date());
|
||||||
|
try {
|
||||||
this.strictInsertFill(metaObject, "tenantId", Long.class, SecurityUtils.getUserId());
|
this.strictInsertFill(metaObject, "tenantId", Long.class, SecurityUtils.getUserId());
|
||||||
|
} catch (Exception e) {
|
||||||
|
this.strictInsertFill(metaObject, "tenantId", Long.class, -1L);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -129,11 +129,11 @@ public class SecurityConfig
|
||||||
.authorizeHttpRequests((requests) -> {
|
.authorizeHttpRequests((requests) -> {
|
||||||
permitAllUrl.getUrls().forEach(url -> requests.antMatchers(url).permitAll());
|
permitAllUrl.getUrls().forEach(url -> requests.antMatchers(url).permitAll());
|
||||||
// 对于登录login 注册register 验证码captchaImage 允许匿名访问
|
// 对于登录login 注册register 验证码captchaImage 允许匿名访问
|
||||||
requests.antMatchers("/login", "/register", "/captchaImage","/web/pay/doPay","/web/pay/notify").permitAll()
|
requests.antMatchers("/login", "/register", "/captchaImage","/ali/pay/doPay","/ali/pay/notify",
|
||||||
|
"/ali/pay/callback").permitAll()
|
||||||
// 静态资源,可匿名访问
|
// 静态资源,可匿名访问
|
||||||
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
|
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
|
||||||
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
|
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
|
||||||
.antMatchers("/web/pay/notify").permitAll()
|
|
||||||
// 除上面外的所有请求全部需要鉴权认证
|
// 除上面外的所有请求全部需要鉴权认证
|
||||||
.anyRequest().authenticated();
|
.anyRequest().authenticated();
|
||||||
})
|
})
|
||||||
|
|
|
@ -55,5 +55,18 @@
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alipay.sdk</groupId>
|
||||||
|
<artifactId>alipay-sdk-java</artifactId>
|
||||||
|
<version>4.40.30.ALL</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alipay.sdk</groupId>
|
||||||
|
<artifactId>alipay-easysdk</artifactId>
|
||||||
|
<version>2.2.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -1,27 +1,39 @@
|
||||||
package com.mcwl.pay.domain;
|
package com.mcwl.pay.domain;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
@ApiModel(description = "订单交易信息")
|
||||||
public class OrderTradeDto {
|
public class OrderTradeDto {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品ID
|
* 商品ID
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "商品ID", required = true)
|
||||||
|
@NotNull(message = "商品ID不能为空")
|
||||||
private Integer productId;
|
private Integer productId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付金额
|
* 支付金额
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "支付金额", required = true)
|
||||||
|
@NotNull(message = "支付金额不能为空")
|
||||||
private Double paymentAmount;
|
private Double paymentAmount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单类型 会员member 积分points
|
* 订单类型 会员member 积分points
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "订单类型 会员member 积分points", required = true)
|
||||||
|
@NotNull(message = "订单类型不能为空")
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 活动id
|
* 活动id
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty(value = "活动id")
|
||||||
private Long promotionId;
|
private Long promotionId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.mcwl.pay.service;
|
||||||
|
|
||||||
|
import com.alipay.api.AlipayApiException;
|
||||||
|
import com.mcwl.common.core.domain.AjaxResult;
|
||||||
|
import com.mcwl.pay.domain.OrderTradeDto;
|
||||||
|
|
||||||
|
public interface AliPayService {
|
||||||
|
String bindingCallback(String authCode, String state);
|
||||||
|
|
||||||
|
String memberPay(OrderTradeDto orderTradeDto) throws Exception;
|
||||||
|
|
||||||
|
String pointsPay(Double paymentAmount) throws Exception;
|
||||||
|
|
||||||
|
AjaxResult fetch(String outBizNo, String amount) throws AlipayApiException;
|
||||||
|
}
|
|
@ -0,0 +1,355 @@
|
||||||
|
package com.mcwl.pay.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.lang.UUID;
|
||||||
|
import cn.hutool.extra.mail.MailUtil;
|
||||||
|
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.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.domain.AjaxResult;
|
||||||
|
import com.mcwl.common.core.domain.entity.SysUser;
|
||||||
|
import com.mcwl.common.core.redis.RedisCache;
|
||||||
|
import com.mcwl.common.exception.BusinessException;
|
||||||
|
import com.mcwl.common.exception.ServiceException;
|
||||||
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
|
import com.mcwl.common.utils.ShareCodeUtils;
|
||||||
|
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 com.mcwl.pay.service.AliPayService;
|
||||||
|
import com.mcwl.system.domain.SysUserPayAccount;
|
||||||
|
import com.mcwl.system.domain.SysUserPayAccountLog;
|
||||||
|
import com.mcwl.system.service.ISysUserPayAccountLogService;
|
||||||
|
import com.mcwl.system.service.ISysUserPayAccountService;
|
||||||
|
import com.mcwl.system.service.ISysUserService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付宝支付
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class AliPayServiceImpl implements AliPayService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisCache redisCache;
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MemberLevelService memberLevelService;
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AliConfig aliConfig;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysUserPayAccountService sysUserPayAccountService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysUserService sysUserService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysUserPayAccountLogService sysUserPayAccountLogService;
|
||||||
|
|
||||||
|
|
||||||
|
public AliPayServiceImpl(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
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
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 amount 转账金额
|
||||||
|
* @return 返回支付宝转账响应的内容
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public AjaxResult fetch(String outBizNo, String amount) throws AlipayApiException {
|
||||||
|
Long userId = SecurityUtils.getUserId();
|
||||||
|
SysUser sysUser = sysUserService.selectUserById(userId);
|
||||||
|
if (sysUser.getWallet() < Double.parseDouble(amount)) {
|
||||||
|
return AjaxResult.error("钱包余额不足");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化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("提现");
|
||||||
|
|
||||||
|
// 查询用户支付宝账户
|
||||||
|
SysUserPayAccount sysUserPayAccount = sysUserPayAccountService
|
||||||
|
.lambdaQuery()
|
||||||
|
.eq(SysUserPayAccount::getUserId, userId)
|
||||||
|
.eq(SysUserPayAccount::getType, 0)
|
||||||
|
.one();
|
||||||
|
if (Objects.isNull(sysUserPayAccount)) {
|
||||||
|
return AjaxResult.error("请先绑定支付宝账号");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 收款方信息
|
||||||
|
Participant payeeInfo = new Participant();
|
||||||
|
payeeInfo.setIdentity(sysUserPayAccount.getOpenId());
|
||||||
|
payeeInfo.setIdentityType("ALIPAY_USER_ID");
|
||||||
|
model.setPayeeInfo(payeeInfo);
|
||||||
|
|
||||||
|
request.setBizModel(model);
|
||||||
|
AlipayFundTransUniTransferResponse response = alipayClient.certificateExecute(request);
|
||||||
|
System.out.println(response.getBody());
|
||||||
|
|
||||||
|
if (response.getSubCode().equals("PAYER_BALANCE_NOT_ENOUGH")) {
|
||||||
|
// 账户余额不足,发送邮件通知
|
||||||
|
ArrayList<String> tos = CollUtil.newArrayList("2119157836@qq.com");
|
||||||
|
|
||||||
|
String content = String.format("账户余额不足:用户%s提现%s", sysUser.getUserName(), amount);
|
||||||
|
MailUtil.send(tos, "上海辰风互娱", content, false);
|
||||||
|
return AjaxResult.error("系统繁忙,请稍后重试");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (response.isSuccess()) {
|
||||||
|
System.out.println("调用成功");
|
||||||
|
BigDecimal wallet = new BigDecimal(sysUser.getWallet().toString());
|
||||||
|
BigDecimal amountBigDecimal = new BigDecimal(amount);
|
||||||
|
sysUser.setWallet(wallet.subtract(amountBigDecimal).doubleValue());
|
||||||
|
sysUserService.updateUser(sysUser);
|
||||||
|
|
||||||
|
// 添加记录
|
||||||
|
SysUserPayAccountLog sysUserPayAccountLog = new SysUserPayAccountLog();
|
||||||
|
sysUserPayAccountLog.setUserId(userId);
|
||||||
|
sysUserPayAccountLog.setAmount(Double.valueOf(amount));
|
||||||
|
sysUserPayAccountLog.setAccount("支付宝");
|
||||||
|
sysUserPayAccountLogService.save(sysUserPayAccountLog);
|
||||||
|
// response.getBody()
|
||||||
|
return AjaxResult.success("转账成功");
|
||||||
|
} else {
|
||||||
|
System.out.println("调用失败");
|
||||||
|
// sdk版本是"4.38.0.ALL"及以上,可以参考下面的示例获取诊断链接
|
||||||
|
String diagnosisUrl = DiagnosisUtils.getDiagnosisUrl(response);
|
||||||
|
System.out.println(diagnosisUrl);
|
||||||
|
return AjaxResult.error("转账失败:" + response.getMsg());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String bindingCallback(String authCode, String state) {
|
||||||
|
try {
|
||||||
|
Long userId = ShareCodeUtils.codeToId(state);
|
||||||
|
if (Objects.isNull(userId)) {
|
||||||
|
return "fail";
|
||||||
|
}
|
||||||
|
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()) {
|
||||||
|
// 支付宝用户唯一ID
|
||||||
|
String openId = response.getOpenId();
|
||||||
|
// 判断是否已经绑定过
|
||||||
|
SysUserPayAccount sysUserPayAccount = sysUserPayAccountService.lambdaQuery()
|
||||||
|
.eq(SysUserPayAccount::getUserId, userId)
|
||||||
|
.eq(SysUserPayAccount::getType, 0)
|
||||||
|
.one();
|
||||||
|
if (Objects.nonNull(sysUserPayAccount)) {
|
||||||
|
// 已经绑定过,直接返回
|
||||||
|
return "success";
|
||||||
|
}
|
||||||
|
System.out.println("绑定成功!openId:" + openId);
|
||||||
|
// 将openId与当前商城用户绑定(保存到数据库)
|
||||||
|
SysUserPayAccount userPayAccount = new SysUserPayAccount();
|
||||||
|
userPayAccount.setUserId(userId);
|
||||||
|
userPayAccount.setOpenId(openId);
|
||||||
|
userPayAccount.setType(0);
|
||||||
|
sysUserPayAccountService.save(userPayAccount);
|
||||||
|
return "success";
|
||||||
|
} else {
|
||||||
|
System.out.println("绑定失败:" + response.getSubMsg());
|
||||||
|
return "fail";
|
||||||
|
}
|
||||||
|
} catch (AlipayApiException e) {
|
||||||
|
return "fail";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -47,10 +47,10 @@ public class ModelProduct extends BaseEntity {
|
||||||
@ApiModelProperty(value = "用户id")
|
@ApiModelProperty(value = "用户id")
|
||||||
private Long userId;
|
private Long userId;
|
||||||
/**
|
/**
|
||||||
* 模型类型ID
|
* 模型类型
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "模型类型ID")
|
@ApiModelProperty(value = "模型类型")
|
||||||
private Long modelTypeId;
|
private Long modelType;
|
||||||
/**
|
/**
|
||||||
* 垂类
|
* 垂类
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -54,6 +54,11 @@ public class ModelVersion extends BaseEntity {
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "文件地址")
|
@ApiModelProperty(value = "文件地址")
|
||||||
private String filePath;
|
private String filePath;
|
||||||
|
/**
|
||||||
|
* 文件名
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "文件名")
|
||||||
|
private String fileName;
|
||||||
/**
|
/**
|
||||||
* 版本介绍(富文本编辑)
|
* 版本介绍(富文本编辑)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -10,38 +10,38 @@ public class ModelLikeVo {
|
||||||
/**
|
/**
|
||||||
* id
|
* id
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "id", required = true)
|
@ApiModelProperty(value = "id")
|
||||||
private Long id;
|
private Long id;
|
||||||
/**
|
/**
|
||||||
* 用户ID
|
* 用户ID
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "用户id", required = true)
|
@ApiModelProperty(value = "用户id")
|
||||||
private Long userId;
|
private Long userId;
|
||||||
/**
|
/**
|
||||||
* 用户名称
|
* 用户名称
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "用户名称", required = true)
|
@ApiModelProperty(value = "用户名称")
|
||||||
private String userName;
|
private String userName;
|
||||||
/**
|
/**
|
||||||
* 用户头像
|
* 用户头像
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "用户头像", required = true)
|
@ApiModelProperty(value = "用户头像")
|
||||||
private String userAvatar;
|
private String userAvatar;
|
||||||
/**
|
/**
|
||||||
* 模型id
|
* 模型id
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "模型id", required = true)
|
@ApiModelProperty(value = "模型id")
|
||||||
private Long modelId;
|
private Long modelId;
|
||||||
|
/**
|
||||||
|
* 模型名称
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "模型名称")
|
||||||
|
private String modelName;
|
||||||
/**
|
/**
|
||||||
* 封面图
|
* 封面图
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "封面图")
|
@ApiModelProperty(value = "封面图")
|
||||||
private String surfaceUrl;
|
private String surfaceUrl;
|
||||||
/**
|
|
||||||
* 点赞数
|
|
||||||
*/
|
|
||||||
@ApiModelProperty(value = "点赞数")
|
|
||||||
private Integer likeNum;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,13 +10,18 @@ public class ModelVo {
|
||||||
/**
|
/**
|
||||||
* 模型id
|
* 模型id
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "模型id", required = true)
|
@ApiModelProperty(value = "模型id")
|
||||||
private Long id;
|
private Long id;
|
||||||
/**
|
/**
|
||||||
* 模型名称
|
* 模型名称
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "模型名称", required = true)
|
@ApiModelProperty(value = "模型名称")
|
||||||
private String modelName;
|
private String modelName;
|
||||||
|
/**
|
||||||
|
* 模型类型
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "模型类型")
|
||||||
|
private String modelType;
|
||||||
/**
|
/**
|
||||||
* 封面图
|
* 封面图
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -116,11 +116,19 @@ public class ModelImageLikeServiceImpl extends ServiceImpl<ModelImageLikeMapper,
|
||||||
|
|
||||||
// 获取用户信息
|
// 获取用户信息
|
||||||
SysUser sysUser = sysUserService.selectUserById(modelImageLike.getUserId());
|
SysUser sysUser = sysUserService.selectUserById(modelImageLike.getUserId());
|
||||||
|
if (Objects.isNull(sysUser)) {
|
||||||
|
page.setTotal(page.getTotal() - 1);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
modelImageLikeVo.setUserName(sysUser.getUserName());
|
modelImageLikeVo.setUserName(sysUser.getUserName());
|
||||||
modelImageLikeVo.setUserAvatar(sysUser.getAvatar());
|
modelImageLikeVo.setUserAvatar(sysUser.getAvatar());
|
||||||
|
|
||||||
// 获取图片信息
|
// 获取图片信息
|
||||||
ModelImage modelImage = modelImageMapper.selectById(modelImageLike.getModelImageId());
|
ModelImage modelImage = modelImageMapper.selectById(modelImageLike.getModelImageId());
|
||||||
|
if (Objects.isNull(modelImage)) {
|
||||||
|
page.setTotal(page.getTotal() - 1);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
modelImageLikeVo.setImagePaths(modelImage.getImagePaths());
|
modelImageLikeVo.setImagePaths(modelImage.getImagePaths());
|
||||||
modelImageLikeVo.setLikeNum(modelImage.getLikeNum());
|
modelImageLikeVo.setLikeNum(modelImage.getLikeNum());
|
||||||
|
|
||||||
|
|
|
@ -201,6 +201,10 @@ public class ModelImageServiceImpl extends ServiceImpl<ModelImageMapper, ModelIm
|
||||||
BeanUtil.copyProperties(modelImage, modelImageVo);
|
BeanUtil.copyProperties(modelImage, modelImageVo);
|
||||||
// 获取用户信息
|
// 获取用户信息
|
||||||
SysUser sysUser = sysUserService.selectUserById(modelImage.getUserId());
|
SysUser sysUser = sysUserService.selectUserById(modelImage.getUserId());
|
||||||
|
if (Objects.isNull(sysUser)) {
|
||||||
|
page.setTotal(page.getTotal() - 1);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
modelImageVo.setUserId(sysUser.getUserId());
|
modelImageVo.setUserId(sysUser.getUserId());
|
||||||
modelImageVo.setUserName(sysUser.getUserName());
|
modelImageVo.setUserName(sysUser.getUserName());
|
||||||
modelImageVo.setUserAvatar(sysUser.getAvatar());
|
modelImageVo.setUserAvatar(sysUser.getAvatar());
|
||||||
|
|
|
@ -93,13 +93,21 @@ public class ModelLikeServiceImpl extends ServiceImpl<ModelLikeMapper, ModelLike
|
||||||
|
|
||||||
// 获取用户信息
|
// 获取用户信息
|
||||||
SysUser sysUser = sysUserService.selectUserById(modelLike.getUserId());
|
SysUser sysUser = sysUserService.selectUserById(modelLike.getUserId());
|
||||||
|
if (Objects.isNull(sysUser)) {
|
||||||
|
page.setTotal(page.getTotal() - 1);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
modelLikeVo.setUserName(sysUser.getUserName());
|
modelLikeVo.setUserName(sysUser.getUserName());
|
||||||
modelLikeVo.setUserAvatar(sysUser.getAvatar());
|
modelLikeVo.setUserAvatar(sysUser.getAvatar());
|
||||||
|
|
||||||
// 获取模型信息
|
// 获取模型信息
|
||||||
ModelProduct modelProduct = modelMapper.selectById(modelLike.getModelId());
|
ModelProduct modelProduct = modelMapper.selectById(modelLike.getModelId());
|
||||||
|
if (Objects.isNull(modelProduct)) {
|
||||||
|
page.setTotal(page.getTotal() - 1);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
modelLikeVo.setSurfaceUrl(modelProduct.getSurfaceUrl());
|
modelLikeVo.setSurfaceUrl(modelProduct.getSurfaceUrl());
|
||||||
modelLikeVo.setLikeNum(modelProduct.getLikeNum());
|
modelLikeVo.setModelName(modelProduct.getModelName());
|
||||||
|
|
||||||
modelLikeVoList.add(modelLikeVo);
|
modelLikeVoList.add(modelLikeVo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,8 +155,19 @@ public class ModelServiceImpl extends ServiceImpl<ModelMapper,ModelProduct> impl
|
||||||
for (ModelProduct modelImage : modelImageList) {
|
for (ModelProduct modelImage : modelImageList) {
|
||||||
ModelVo modelVo = new ModelVo();
|
ModelVo modelVo = new ModelVo();
|
||||||
BeanUtil.copyProperties(modelImage, modelVo);
|
BeanUtil.copyProperties(modelImage, modelVo);
|
||||||
|
|
||||||
|
// 设置模型类型
|
||||||
|
if (Objects.nonNull(modelImage.getModelType())) {
|
||||||
|
String modelTypeName = DictInit.getDictValue(DictConstants.MODEL_CATEGORY, modelImage.getModelType().toString());
|
||||||
|
modelVo.setModelType(modelTypeName);
|
||||||
|
}
|
||||||
|
|
||||||
// 获取用户信息
|
// 获取用户信息
|
||||||
SysUser sysUser = sysUserService.selectUserById(modelImage.getUserId());
|
SysUser sysUser = sysUserService.selectUserById(modelImage.getUserId());
|
||||||
|
if (Objects.isNull(sysUser)) {
|
||||||
|
page.setTotal(page.getTotal() - 1);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
modelVo.setUserId(sysUser.getUserId());
|
modelVo.setUserId(sysUser.getUserId());
|
||||||
modelVo.setUserName(sysUser.getUserName());
|
modelVo.setUserName(sysUser.getUserName());
|
||||||
modelVo.setUserAvatar(sysUser.getAvatar());
|
modelVo.setUserAvatar(sysUser.getAvatar());
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package com.mcwl.resource.service.impl;
|
package com.mcwl.resource.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.mcwl.common.utils.StringUtils;
|
||||||
|
import com.mcwl.resource.domain.ModelProduct;
|
||||||
import com.mcwl.resource.domain.ToActivity;
|
import com.mcwl.resource.domain.ToActivity;
|
||||||
import com.mcwl.resource.mapper.ToActivityMapper;
|
import com.mcwl.resource.mapper.ToActivityMapper;
|
||||||
import com.mcwl.resource.service.ToActivityService;
|
import com.mcwl.resource.service.ToActivityService;
|
||||||
|
@ -31,9 +32,7 @@ public class ToActivityServiceImpl extends ServiceImpl<ToActivityMapper, ToActiv
|
||||||
@Override
|
@Override
|
||||||
public List<ToActivity> selectToActivityList(ToActivity toActivity) {
|
public List<ToActivity> selectToActivityList(ToActivity toActivity) {
|
||||||
LambdaQueryWrapper<ToActivity> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<ToActivity> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
if (StrUtil.isNotBlank(toActivity.getActivityName())){
|
queryWrapper.eq(StringUtils.isNotBlank(toActivity.getActivityName()),ToActivity::getActivityName, toActivity.getActivityName());
|
||||||
queryWrapper.eq(ToActivity::getActivityName, toActivity.getActivityName());
|
|
||||||
}
|
|
||||||
return toActivityMapper.selectList(queryWrapper);
|
return toActivityMapper.selectList(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ import org.springframework.stereotype.Service;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 工作流 业务实现层
|
* 工作流 业务实现层
|
||||||
|
@ -356,6 +357,10 @@ public class WorkFlowServiceImpl extends ServiceImpl<WorkFlowMapper, WorkFlow> i
|
||||||
BeanUtil.copyProperties(workFlow, workFlowVo);
|
BeanUtil.copyProperties(workFlow, workFlowVo);
|
||||||
// 获取用户信息
|
// 获取用户信息
|
||||||
SysUser sysUser = sysUserService.selectUserById(workFlow.getUserId());
|
SysUser sysUser = sysUserService.selectUserById(workFlow.getUserId());
|
||||||
|
if (Objects.isNull(sysUser)) {
|
||||||
|
page.setTotal(page.getTotal() - 1);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
workFlowVo.setUserId(sysUser.getUserId());
|
workFlowVo.setUserId(sysUser.getUserId());
|
||||||
workFlowVo.setUserName(sysUser.getUserName());
|
workFlowVo.setUserName(sysUser.getUserName());
|
||||||
workFlowVo.setUserAvatar(sysUser.getAvatar());
|
workFlowVo.setUserAvatar(sysUser.getAvatar());
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.mcwl.system.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.mcwl.common.core.domain.BaseEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户支付账户
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("sys_user_pay_account")
|
||||||
|
public class SysUserPayAccount extends BaseEntity {
|
||||||
|
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户id
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
/**
|
||||||
|
* 账号唯一标识
|
||||||
|
*/
|
||||||
|
private String openId;
|
||||||
|
/**
|
||||||
|
* 账号类型 0 支付宝 1 微信 2 QQ
|
||||||
|
*/
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.mcwl.system.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.mcwl.common.core.domain.BaseEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户提现日志
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName("sys_user_pay_account_log")
|
||||||
|
public class SysUserPayAccountLog extends BaseEntity {
|
||||||
|
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 提现用户
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
/**
|
||||||
|
* 提现金额
|
||||||
|
*/
|
||||||
|
private Double amount;
|
||||||
|
/**
|
||||||
|
* 提现账户
|
||||||
|
*/
|
||||||
|
private String account;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.mcwl.system.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.mcwl.system.domain.SysUserPayAccount;
|
||||||
|
import com.mcwl.system.domain.SysUserPayAccountLog;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户提现
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface SysUserPayAccountLogMapper extends BaseMapper<SysUserPayAccountLog> {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.mcwl.system.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.mcwl.system.domain.SysUserPayAccount;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户支付账户
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface SysUserPayAccountMapper extends BaseMapper<SysUserPayAccount> {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.mcwl.system.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.mcwl.system.domain.SysUserPayAccount;
|
||||||
|
import com.mcwl.system.domain.SysUserPayAccountLog;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户提现 服务层
|
||||||
|
*
|
||||||
|
* @author mcwl
|
||||||
|
*/
|
||||||
|
public interface ISysUserPayAccountLogService extends IService<SysUserPayAccountLog> {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.mcwl.system.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.mcwl.system.domain.SysUserPayAccount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户支付账户 服务层
|
||||||
|
*
|
||||||
|
* @author mcwl
|
||||||
|
*/
|
||||||
|
public interface ISysUserPayAccountService extends IService<SysUserPayAccount> {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.mcwl.system.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.mcwl.system.domain.SysUserPayAccount;
|
||||||
|
import com.mcwl.system.domain.SysUserPayAccountLog;
|
||||||
|
import com.mcwl.system.mapper.SysUserPayAccountLogMapper;
|
||||||
|
import com.mcwl.system.mapper.SysUserPayAccountMapper;
|
||||||
|
import com.mcwl.system.service.ISysUserPayAccountLogService;
|
||||||
|
import com.mcwl.system.service.ISysUserPayAccountService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户提现
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class SysUserPayAccountLogServiceImpl extends ServiceImpl<SysUserPayAccountLogMapper, SysUserPayAccountLog> implements ISysUserPayAccountLogService {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.mcwl.system.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.mcwl.system.domain.SysUserPayAccount;
|
||||||
|
import com.mcwl.system.mapper.SysUserPayAccountMapper;
|
||||||
|
import com.mcwl.system.service.ISysUserPayAccountService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户支付账户 业务层处理
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class SysUserPayAccountServiceImpl extends ServiceImpl<SysUserPayAccountMapper, SysUserPayAccount> implements ISysUserPayAccountService {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue