|
|
@@ -3,6 +3,7 @@ package com.sckw.payment.service;
|
|
|
import com.alibaba.fastjson2.JSONArray;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.alibaba.fastjson2.TypeReference;
|
|
|
+import com.sckw.core.exception.BusinessException;
|
|
|
import com.sckw.core.utils.CollectionUtils;
|
|
|
import com.sckw.core.utils.OkHttpUtils;
|
|
|
import com.sckw.payment.api.model.constant.ChannelEnum;
|
|
|
@@ -20,9 +21,11 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
-import java.util.*;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
/**
|
|
|
* 转发中台接口
|
|
|
@@ -33,7 +36,6 @@ import java.util.*;
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
@RefreshScope
|
|
|
-@Validated
|
|
|
public class PayCenterService {
|
|
|
@Value("${payCenter.address}")
|
|
|
private String payCenterAddr;
|
|
|
@@ -56,14 +58,27 @@ public class PayCenterService {
|
|
|
if (!CollectionUtils.isEmpty(para)) {
|
|
|
for (Map.Entry<String, Object> p : para.entrySet()) {
|
|
|
//跳过非空参数
|
|
|
- if (Objects.isNull(p.getValue())) {
|
|
|
+ Object v = p.getValue();
|
|
|
+ String k = p.getKey();
|
|
|
+ if (Objects.isNull(v)) {
|
|
|
continue;
|
|
|
}
|
|
|
- if (p.getValue() instanceof ChannelEnum channelEnum) {
|
|
|
- okHttpUtils.addPara(p.getKey(), channelEnum.getChannel());
|
|
|
+ if (v instanceof ChannelEnum channelEnum) {
|
|
|
+ okHttpUtils.addPara(k, channelEnum.getChannel());
|
|
|
+ } else if (v instanceof Integer i) {
|
|
|
+ okHttpUtils.addPara(k, String.valueOf(i));
|
|
|
+ } else if (v instanceof Long i) {
|
|
|
+ okHttpUtils.addPara(k, String.valueOf(i));
|
|
|
+ } else if (v instanceof String i) {
|
|
|
+ okHttpUtils.addPara(k, i);
|
|
|
+ } else if ((v.getClass().isArray()) && v instanceof String[] l) {
|
|
|
+ for (int i = 0; i < l.length; i++) {
|
|
|
+ okHttpUtils.addPara(k + "[" + i + "]", l[i]);
|
|
|
+ }
|
|
|
} else {
|
|
|
- okHttpUtils.addPara(p.getKey(), (String) p.getValue());
|
|
|
+ okHttpUtils.addPara(k, v.toString());
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
String sync;
|
|
|
@@ -83,13 +98,25 @@ public class PayCenterService {
|
|
|
if (!CollectionUtils.isEmpty(para)) {
|
|
|
for (Map.Entry<String, Object> p : para.entrySet()) {
|
|
|
//跳过非空参数
|
|
|
- if (Objects.isNull(p.getValue())) {
|
|
|
+ Object v = p.getValue();
|
|
|
+ String k = p.getKey();
|
|
|
+ if (Objects.isNull(v)) {
|
|
|
continue;
|
|
|
}
|
|
|
- if (p.getValue() instanceof ChannelEnum channelEnum) {
|
|
|
- okHttpUtils.addBodyPara(p.getKey(), channelEnum.getChannel());
|
|
|
+ if (v instanceof ChannelEnum channelEnum) {
|
|
|
+ okHttpUtils.addBodyPara(k, channelEnum.getChannel());
|
|
|
+ } else if (v instanceof Integer i) {
|
|
|
+ okHttpUtils.addBodyPara(k, String.valueOf(i));
|
|
|
+ } else if (v instanceof Long i) {
|
|
|
+ okHttpUtils.addBodyPara(k, String.valueOf(i));
|
|
|
+ } else if (v instanceof String i) {
|
|
|
+ okHttpUtils.addBodyPara(k, i);
|
|
|
+ } else if ((v.getClass().isArray()) && v instanceof String[] l) {
|
|
|
+ for (int i = 0; i < l.length; i++) {
|
|
|
+ okHttpUtils.addPara(k + "[" + i + "]", l[i]);
|
|
|
+ }
|
|
|
} else {
|
|
|
- okHttpUtils.addBodyPara(p.getKey(), (String) p.getValue());
|
|
|
+ okHttpUtils.addBodyPara(k, v.toString());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -141,6 +168,9 @@ public class PayCenterService {
|
|
|
* @return
|
|
|
*/
|
|
|
public R<List<WalletDto>> wallet(@NotNull String uid, ChannelEnum channel, String filter) {
|
|
|
+ if (StringUtils.isBlank(uid)) {
|
|
|
+ throw new BusinessException("提现用户不能为空");
|
|
|
+ }
|
|
|
String sync = getHttp(PayCenterEnum.MEMBER_WALLET, new HashMap<>() {{
|
|
|
put("uid", uid);
|
|
|
put("channel", channel);
|
|
|
@@ -157,7 +187,13 @@ public class PayCenterService {
|
|
|
* @param orderNo
|
|
|
* @return
|
|
|
*/
|
|
|
- public R<CashDetail> withdrawDetail(@NotBlank(message = "提现用户不能为空") String uid, @NotBlank(message = "") String view, @NotBlank(message = "订单编号不能为空") String orderNo) {
|
|
|
+ public R<CashDetail> withdrawDetail(String uid, String view, String orderNo) {
|
|
|
+ if (StringUtils.isBlank(uid)) {
|
|
|
+ throw new BusinessException("提现用户不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(orderNo)) {
|
|
|
+ throw new BusinessException("订单编号不能为空");
|
|
|
+ }
|
|
|
String sync = getHttp(PayCenterEnum.WITHDRAW_DETAIL, new HashMap<>() {{
|
|
|
put("uid", uid);
|
|
|
put("view", view);
|
|
|
@@ -176,12 +212,26 @@ public class PayCenterService {
|
|
|
* @param pageSize
|
|
|
* @return
|
|
|
*/
|
|
|
- public R<CashPage> withdrawIndex(@NotBlank(message = "提现用户不能为空") String uid, @NotNull(message = "支付渠道不能为空") ChannelEnum channel, @NotNull(message = "分页参数不能为空") Integer page, @NotNull(message = "分页大小参数不能为空") Integer pageSize) {
|
|
|
+ public R<CashPage> withdrawIndex(String uid, ChannelEnum channel, Integer page, Integer pageSize) {
|
|
|
+ if (StringUtils.isBlank(uid)) {
|
|
|
+ throw new BusinessException("用户不能为空");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(channel)) {
|
|
|
+ throw new BusinessException("支付渠道不能为空");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(page)) {
|
|
|
+ page = 1;
|
|
|
+ }
|
|
|
+ if (Objects.isNull(pageSize)) {
|
|
|
+ pageSize = 5;
|
|
|
+ }
|
|
|
+ Integer finalPage = page;
|
|
|
+ Integer finalPageSize = pageSize;
|
|
|
String sync = getHttp(PayCenterEnum.WITHDRAW_INDEX, new HashMap<>() {{
|
|
|
put("uid", uid);
|
|
|
put("channel", channel);
|
|
|
- put("page", page);
|
|
|
- put("pageSize", pageSize);
|
|
|
+ put("page", finalPage);
|
|
|
+ put("pageSize", finalPageSize);
|
|
|
}});
|
|
|
return JSONObject.parseObject(sync, new TypeReference<>() {
|
|
|
});
|
|
|
@@ -212,7 +262,13 @@ public class PayCenterService {
|
|
|
* @param orderNo
|
|
|
* @return
|
|
|
*/
|
|
|
- public R<Object> withdrawCancel(@NotBlank(message = "提现用户不能为空") String uid, @NotBlank(message = "体现订单号不能为空") String orderNo) {
|
|
|
+ public R<Object> withdrawCancel(String uid, String orderNo) {
|
|
|
+ if (StringUtils.isBlank(uid)) {
|
|
|
+ throw new BusinessException("用户不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(orderNo)) {
|
|
|
+ throw new BusinessException("提现订单不能为空");
|
|
|
+ }
|
|
|
String sync = postHttp(PayCenterEnum.WITHDRAW_CANCEL, new HashMap<>() {{
|
|
|
put("uid", uid);
|
|
|
put("order_no", orderNo);
|
|
|
@@ -230,7 +286,19 @@ public class PayCenterService {
|
|
|
* @param remarks
|
|
|
* @return
|
|
|
*/
|
|
|
- public R<Order> withdrawTake(@NotBlank(message = "提现用户不能为空") String uid, @NotBlank(message = "渠道不能为空") ChannelEnum channel, @NotBlank(message = "金额(分)不能为空") Long money, @NotBlank(message = "备注不能为空") String remarks) {
|
|
|
+ public R<Order> withdrawTake(String uid, @NotBlank(message = "渠道不能为空") ChannelEnum channel, Long money, String remarks) {
|
|
|
+ if (StringUtils.isBlank(uid)) {
|
|
|
+ throw new BusinessException("提现用户不能为空");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(channel)) {
|
|
|
+ throw new BusinessException("提现渠道不能为空");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(money)) {
|
|
|
+ throw new BusinessException("提现金额不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(remarks)) {
|
|
|
+ throw new BusinessException("备注不能为空");
|
|
|
+ }
|
|
|
String sync = postHttp(PayCenterEnum.WITHDRAW_TAKE, new HashMap<>() {{
|
|
|
put("uid", uid);
|
|
|
put("channel", channel);
|
|
|
@@ -249,7 +317,16 @@ public class PayCenterService {
|
|
|
* @param filter
|
|
|
* @return
|
|
|
*/
|
|
|
- public R<WalletInfo> totalInfo(@NotBlank(message = "用户不能为空") String uid, @NotBlank(message = "渠道不能为空") ChannelEnum channel, @NotBlank(message = "乙方用户不能为空") String filter) {
|
|
|
+ public R<WalletInfo> totalInfo(String uid, ChannelEnum channel, String filter) {
|
|
|
+ if (StringUtils.isBlank(uid)) {
|
|
|
+ throw new BusinessException("提现用户不能为空");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(channel)) {
|
|
|
+ throw new BusinessException("提现渠道不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(filter)) {
|
|
|
+ throw new BusinessException("乙方用户不能为空");
|
|
|
+ }
|
|
|
String sync = getHttp(PayCenterEnum.TOTAL_INFO, new HashMap<>() {{
|
|
|
put("uid", uid);
|
|
|
put("channel", channel);
|
|
|
@@ -268,6 +345,15 @@ public class PayCenterService {
|
|
|
* @return
|
|
|
*/
|
|
|
public R<OperateDown> operateDownload(String uid, ChannelEnum channel, String filter) {
|
|
|
+ if (StringUtils.isBlank(uid)) {
|
|
|
+ throw new BusinessException("提现用户不能为空");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(channel)) {
|
|
|
+ throw new BusinessException("提现渠道不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(filter)) {
|
|
|
+ throw new BusinessException("乙方用户不能为空");
|
|
|
+ }
|
|
|
String sync = getHttp(PayCenterEnum.OPERATE_DOWNLOAD, new HashMap<>() {{
|
|
|
put("uid", uid);
|
|
|
put("channel", channel);
|
|
|
@@ -297,12 +383,28 @@ public class PayCenterService {
|
|
|
* @param pageSize
|
|
|
* @return
|
|
|
*/
|
|
|
- public R<Operate> operateIndex(String uid, ChannelEnum channel, Integer page, Integer pageSize) {
|
|
|
+ public R<Operate> operateIndex(String uid, ChannelEnum channel, Integer page, Integer pageSize, String[] createTime, String[] money) {
|
|
|
+ if (StringUtils.isBlank(uid)) {
|
|
|
+ throw new BusinessException("用户不能为空");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(channel)) {
|
|
|
+ throw new BusinessException("支付渠道不能为空");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(page)) {
|
|
|
+ page = 1;
|
|
|
+ }
|
|
|
+ if (Objects.isNull(pageSize)) {
|
|
|
+ pageSize = 5;
|
|
|
+ }
|
|
|
+ Integer finalPage = page;
|
|
|
+ Integer finalPageSize = pageSize;
|
|
|
String sync = getHttp(PayCenterEnum.OPERATE_INDEX, new HashMap<>() {{
|
|
|
put("uid", uid);
|
|
|
put("channel", channel);
|
|
|
- put("page", page);
|
|
|
- put("pageSize", pageSize);
|
|
|
+ put("page", finalPage);
|
|
|
+ put("pageSize", finalPageSize);
|
|
|
+ put("createTime", createTime);
|
|
|
+ put("money", money);
|
|
|
}});
|
|
|
return JSONObject.parseObject(sync, new TypeReference<>() {
|
|
|
});
|
|
|
@@ -561,9 +663,7 @@ public class PayCenterService {
|
|
|
* @param nickname
|
|
|
* @return
|
|
|
*/
|
|
|
- public R<Object> walletIndex(@NotBlank(message = "uid不能为空") String uid,
|
|
|
- @NotNull(message = "支付渠道不能为空") ChannelEnum channel,
|
|
|
- @NotBlank(message = "filter不能为空") String filter, String nickname) {
|
|
|
+ public R<Object> walletIndex(@NotBlank(message = "uid不能为空") String uid, @NotNull(message = "支付渠道不能为空") ChannelEnum channel, @NotBlank(message = "filter不能为空") String filter, String nickname) {
|
|
|
String sync = postHttp(PayCenterEnum.WALLET_INDEX, new HashMap<>() {{
|
|
|
put("uid", uid);
|
|
|
put("channel", channel);
|