|
@@ -2,21 +2,16 @@ package com.haha.miniapp.controller;
|
|
|
|
|
|
|
|
import cn.dev33.satoken.annotation.SaIgnore;
|
|
import cn.dev33.satoken.annotation.SaIgnore;
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
|
-import com.alibaba.fastjson2.JSON;
|
|
|
|
|
import com.haha.common.constant.CallbackConstants;
|
|
import com.haha.common.constant.CallbackConstants;
|
|
|
-import com.haha.common.constant.ResponseEnum;
|
|
|
|
|
import com.haha.common.utils.RequestParseUtil;
|
|
import com.haha.common.utils.RequestParseUtil;
|
|
|
import com.haha.common.vo.Result;
|
|
import com.haha.common.vo.Result;
|
|
|
-import com.haha.service.payment.payscore.*;
|
|
|
|
|
-import com.haha.service.payment.payscore.PayScoreCreateRequest.PostPayment;
|
|
|
|
|
-import com.haha.service.payment.payscore.PayScoreCompleteRequest.PostDiscount;
|
|
|
|
|
|
|
+import com.haha.service.payment.payscore.PayScoreCallbackResult;
|
|
|
|
|
+import com.haha.service.payment.payscore.PayScoreService;
|
|
|
import jakarta.servlet.http.HttpServletRequest;
|
|
import jakarta.servlet.http.HttpServletRequest;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
-import java.math.BigDecimal;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -79,19 +74,13 @@ public class PayScoreController {
|
|
|
log.info("用户 {} 确认开通支付分", userId);
|
|
log.info("用户 {} 确认开通支付分", userId);
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- if (!params.containsKey("outOrderNo")) {
|
|
|
|
|
- return ResponseEnum.PARAM_REQUIRED.toResult("参数错误:outOrderNo 不能为空");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- String outOrderNo = params.get("outOrderNo").toString();
|
|
|
|
|
- Map<String, Object> data = payScoreService.confirmEnablePayscore(userId, outOrderNo);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ Map<String, Object> data = payScoreService.confirmUserPayScoreOrder(userId, params);
|
|
|
if (data != null) {
|
|
if (data != null) {
|
|
|
log.info("用户 {} 确认开通支付分成功", userId);
|
|
log.info("用户 {} 确认开通支付分成功", userId);
|
|
|
return Result.success("开通成功", data);
|
|
return Result.success("开通成功", data);
|
|
|
} else {
|
|
} else {
|
|
|
log.warn("用户 {} 开通支付分失败", userId);
|
|
log.warn("用户 {} 开通支付分失败", userId);
|
|
|
- return ResponseEnum.OPERATION_FAILED.toResult("开通失败,请重试");
|
|
|
|
|
|
|
+ return com.haha.common.constant.ResponseEnum.OPERATION_FAILED.toResult("开通失败,请重试");
|
|
|
}
|
|
}
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
log.error("确认开通支付分失败 - userId: {}", userId, e);
|
|
log.error("确认开通支付分失败 - userId: {}", userId, e);
|
|
@@ -108,39 +97,19 @@ public class PayScoreController {
|
|
|
Long userId = StpUtil.getLoginIdAsLong();
|
|
Long userId = StpUtil.getLoginIdAsLong();
|
|
|
log.info("用户 {} 请求创建支付分服务订单", userId);
|
|
log.info("用户 {} 请求创建支付分服务订单", userId);
|
|
|
|
|
|
|
|
- if (!params.containsKey("orderId")) {
|
|
|
|
|
- return ResponseEnum.PARAM_REQUIRED.toResult("参数错误:orderId 不能为空");
|
|
|
|
|
- }
|
|
|
|
|
- if (!params.containsKey("openId")) {
|
|
|
|
|
- return ResponseEnum.PARAM_REQUIRED.toResult("参数错误:openId 不能为空");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- Long orderId = Long.valueOf(params.get("orderId").toString());
|
|
|
|
|
- String openId = params.get("openId").toString();
|
|
|
|
|
-
|
|
|
|
|
- BigDecimal riskFundAmount = null;
|
|
|
|
|
- if (params.containsKey("riskFundAmount")) {
|
|
|
|
|
- riskFundAmount = new BigDecimal(params.get("riskFundAmount").toString());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- String riskFundName = null;
|
|
|
|
|
- if (params.containsKey("riskFundName")) {
|
|
|
|
|
- riskFundName = params.get("riskFundName").toString();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- Map<String, Object> data = payScoreService.createUserPayScoreOrder(userId, orderId, openId, riskFundAmount, riskFundName);
|
|
|
|
|
|
|
+ Map<String, Object> data = payScoreService.createUserPayScoreOrder(userId, params);
|
|
|
if (data != null) {
|
|
if (data != null) {
|
|
|
- log.info("创建支付分服务订单成功 - orderId: {}", orderId);
|
|
|
|
|
|
|
+ log.info("创建支付分服务订单成功 - orderId: {}", params.get("orderId"));
|
|
|
return Result.success("创建成功", data);
|
|
return Result.success("创建成功", data);
|
|
|
} else {
|
|
} else {
|
|
|
- return ResponseEnum.OPERATION_FAILED.toResult("创建支付分服务订单失败");
|
|
|
|
|
|
|
+ return com.haha.common.constant.ResponseEnum.OPERATION_FAILED.toResult("创建支付分服务订单失败");
|
|
|
}
|
|
}
|
|
|
} catch (NumberFormatException e) {
|
|
} catch (NumberFormatException e) {
|
|
|
log.error("参数格式错误", e);
|
|
log.error("参数格式错误", e);
|
|
|
- return ResponseEnum.PARAM_FORMAT_ERROR.toResult();
|
|
|
|
|
|
|
+ return com.haha.common.constant.ResponseEnum.PARAM_FORMAT_ERROR.toResult();
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
log.error("创建支付分服务订单失败", e);
|
|
log.error("创建支付分服务订单失败", e);
|
|
|
- return ResponseEnum.OPERATION_FAILED.toResult("创建失败:" + e.getMessage());
|
|
|
|
|
|
|
+ return com.haha.common.constant.ResponseEnum.OPERATION_FAILED.toResult("创建失败:" + e.getMessage());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -153,39 +122,19 @@ public class PayScoreController {
|
|
|
Long userId = StpUtil.getLoginIdAsLong();
|
|
Long userId = StpUtil.getLoginIdAsLong();
|
|
|
log.info("用户 {} 请求完结支付分服务订单", userId);
|
|
log.info("用户 {} 请求完结支付分服务订单", userId);
|
|
|
|
|
|
|
|
- if (!params.containsKey("orderId")) {
|
|
|
|
|
- return ResponseEnum.PARAM_REQUIRED.toResult("参数错误:orderId 不能为空");
|
|
|
|
|
- }
|
|
|
|
|
- if (!params.containsKey("totalAmount")) {
|
|
|
|
|
- return ResponseEnum.PARAM_REQUIRED.toResult("参数错误:totalAmount 不能为空");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- Long orderId = Long.valueOf(params.get("orderId").toString());
|
|
|
|
|
- BigDecimal totalAmount = new BigDecimal(params.get("totalAmount").toString());
|
|
|
|
|
-
|
|
|
|
|
- List<PostPayment> payments = null;
|
|
|
|
|
- if (params.containsKey("payments")) {
|
|
|
|
|
- payments = JSON.parseArray(params.get("payments").toString(), PostPayment.class);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- List<PostDiscount> discounts = null;
|
|
|
|
|
- if (params.containsKey("discounts")) {
|
|
|
|
|
- discounts = JSON.parseArray(params.get("discounts").toString(), PostDiscount.class);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- Map<String, Object> data = payScoreService.completeUserPayScoreOrder(userId, orderId, totalAmount, payments, discounts);
|
|
|
|
|
|
|
+ Map<String, Object> data = payScoreService.completeUserPayScoreOrder(userId, params);
|
|
|
if (data != null) {
|
|
if (data != null) {
|
|
|
- log.info("完结支付分服务订单成功 - orderId: {}", orderId);
|
|
|
|
|
|
|
+ log.info("完结支付分服务订单成功 - orderId: {}", params.get("orderId"));
|
|
|
return Result.success("完结成功", data);
|
|
return Result.success("完结成功", data);
|
|
|
} else {
|
|
} else {
|
|
|
- return ResponseEnum.OPERATION_FAILED.toResult("完结支付分服务订单失败");
|
|
|
|
|
|
|
+ return com.haha.common.constant.ResponseEnum.OPERATION_FAILED.toResult("完结支付分服务订单失败");
|
|
|
}
|
|
}
|
|
|
} catch (NumberFormatException e) {
|
|
} catch (NumberFormatException e) {
|
|
|
log.error("参数格式错误", e);
|
|
log.error("参数格式错误", e);
|
|
|
- return ResponseEnum.PARAM_FORMAT_ERROR.toResult();
|
|
|
|
|
|
|
+ return com.haha.common.constant.ResponseEnum.PARAM_FORMAT_ERROR.toResult();
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
log.error("完结支付分服务订单失败", e);
|
|
log.error("完结支付分服务订单失败", e);
|
|
|
- return ResponseEnum.OPERATION_FAILED.toResult("完结失败:" + e.getMessage());
|
|
|
|
|
|
|
+ return com.haha.common.constant.ResponseEnum.OPERATION_FAILED.toResult("完结失败:" + e.getMessage());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -198,26 +147,19 @@ public class PayScoreController {
|
|
|
Long userId = StpUtil.getLoginIdAsLong();
|
|
Long userId = StpUtil.getLoginIdAsLong();
|
|
|
log.info("用户 {} 请求取消支付分服务订单", userId);
|
|
log.info("用户 {} 请求取消支付分服务订单", userId);
|
|
|
|
|
|
|
|
- if (!params.containsKey("orderId")) {
|
|
|
|
|
- return ResponseEnum.PARAM_REQUIRED.toResult("参数错误:orderId 不能为空");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- Long orderId = Long.valueOf(params.get("orderId").toString());
|
|
|
|
|
- String reason = params.containsKey("reason") ? params.get("reason").toString() : "用户取消";
|
|
|
|
|
-
|
|
|
|
|
- Map<String, Object> data = payScoreService.cancelUserPayScoreOrder(userId, orderId, reason);
|
|
|
|
|
|
|
+ Map<String, Object> data = payScoreService.cancelUserPayScoreOrder(userId, params);
|
|
|
if (data != null) {
|
|
if (data != null) {
|
|
|
- log.info("取消支付分服务订单成功 - orderId: {}", orderId);
|
|
|
|
|
|
|
+ log.info("取消支付分服务订单成功 - orderId: {}", params.get("orderId"));
|
|
|
return Result.success("取消成功", data);
|
|
return Result.success("取消成功", data);
|
|
|
} else {
|
|
} else {
|
|
|
- return ResponseEnum.OPERATION_FAILED.toResult("取消支付分服务订单失败");
|
|
|
|
|
|
|
+ return com.haha.common.constant.ResponseEnum.OPERATION_FAILED.toResult("取消支付分服务订单失败");
|
|
|
}
|
|
}
|
|
|
} catch (NumberFormatException e) {
|
|
} catch (NumberFormatException e) {
|
|
|
log.error("参数格式错误", e);
|
|
log.error("参数格式错误", e);
|
|
|
- return ResponseEnum.PARAM_FORMAT_ERROR.toResult();
|
|
|
|
|
|
|
+ return com.haha.common.constant.ResponseEnum.PARAM_FORMAT_ERROR.toResult();
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
log.error("取消支付分服务订单失败", e);
|
|
log.error("取消支付分服务订单失败", e);
|
|
|
- return ResponseEnum.OPERATION_FAILED.toResult("取消失败:" + e.getMessage());
|
|
|
|
|
|
|
+ return com.haha.common.constant.ResponseEnum.OPERATION_FAILED.toResult("取消失败:" + e.getMessage());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -235,11 +177,11 @@ public class PayScoreController {
|
|
|
log.info("查询支付分服务订单成功 - orderId: {}", orderId);
|
|
log.info("查询支付分服务订单成功 - orderId: {}", orderId);
|
|
|
return Result.success("查询成功", data);
|
|
return Result.success("查询成功", data);
|
|
|
} else {
|
|
} else {
|
|
|
- return ResponseEnum.ORDER_NOT_FOUND.toResult("订单不存在或未创建支付分服务订单");
|
|
|
|
|
|
|
+ return com.haha.common.constant.ResponseEnum.ORDER_NOT_FOUND.toResult("订单不存在或未创建支付分服务订单");
|
|
|
}
|
|
}
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
log.error("查询支付分服务订单失败", e);
|
|
log.error("查询支付分服务订单失败", e);
|
|
|
- return ResponseEnum.OPERATION_FAILED.toResult("查询失败:" + e.getMessage());
|
|
|
|
|
|
|
+ return com.haha.common.constant.ResponseEnum.OPERATION_FAILED.toResult("查询失败:" + e.getMessage());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -257,11 +199,11 @@ public class PayScoreController {
|
|
|
log.info("同步支付分状态成功 - orderId: {}", orderId);
|
|
log.info("同步支付分状态成功 - orderId: {}", orderId);
|
|
|
return Result.success("同步成功", null);
|
|
return Result.success("同步成功", null);
|
|
|
} else {
|
|
} else {
|
|
|
- return ResponseEnum.OPERATION_FAILED.toResult("同步失败");
|
|
|
|
|
|
|
+ return com.haha.common.constant.ResponseEnum.OPERATION_FAILED.toResult("同步失败");
|
|
|
}
|
|
}
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
log.error("同步支付分状态失败", e);
|
|
log.error("同步支付分状态失败", e);
|
|
|
- return ResponseEnum.OPERATION_FAILED.toResult("同步失败:" + e.getMessage());
|
|
|
|
|
|
|
+ return com.haha.common.constant.ResponseEnum.OPERATION_FAILED.toResult("同步失败:" + e.getMessage());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|