xucaiqin 1 рік тому
батько
коміт
a0697ea39e

+ 21 - 0
src/main/java/com/sckw/freight/model/dto/BusinessNo.java

@@ -0,0 +1,21 @@
+package com.sckw.freight.model.dto;
+
+import com.alibaba.fastjson2.annotation.JSONField;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * @author xucaiqin
+ * @date 2023-07-25 16:59:59
+ */
+@Getter
+@Setter
+public class BusinessNo implements Serializable {
+    @Serial
+    private static final long serialVersionUID = -8283758459410298302L;
+    @JSONField(name = "business_no")
+    private String businessNo;
+}

+ 17 - 0
src/main/java/com/sckw/freight/model/dto/Freeze.java

@@ -0,0 +1,17 @@
+package com.sckw.freight.model.dto;
+
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+@Data
+public class Freeze implements Serializable {
+    @Serial
+    private static final long serialVersionUID = 5111111815474400770L;
+    private String filter;
+    private int money;
+    private int balance;
+    private String businessNo;
+    private String channel;
+}

+ 40 - 0
src/main/java/com/sckw/freight/model/dto/MemberCreate.java

@@ -0,0 +1,40 @@
+package com.sckw.freight.model.dto;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * @author xucaiqin
+ * @date 2023-07-25 16:34:32
+ */
+@Data
+public class MemberCreate implements Serializable {
+    @Serial
+    private static final long serialVersionUID = -6655826243958219906L;
+    @JSONField(name = "company_name")
+    private String companyName;
+    @JSONField(name = "license")
+    private String license;
+    @JSONField(name = "legalName")
+    private String legalName;
+    @JSONField(name = "legalPhone")
+    private String legalPhone;
+    /**
+     * 法人身份证号
+     */
+    @JSONField(name = "legalIds")
+    private String legalIds;
+    @JSONField(name = "accountNo")
+    private String accountNo;
+    @JSONField(name = "parentBankName")
+    private String parentBankName;
+    @JSONField(name = "unionBank")
+    private String unionBank;
+    @JSONField(name = "bankName")
+    private String bankName;
+    @JSONField(name = "channel")
+    private String channel;
+}

+ 20 - 0
src/main/java/com/sckw/freight/model/dto/MemberRes.java

@@ -0,0 +1,20 @@
+package com.sckw.freight.model.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * @author xucaiqin
+ * @date 2023-07-25 16:42:36
+ */
+@Getter
+@Setter
+public class MemberRes implements Serializable {
+    @Serial
+    private static final long serialVersionUID = 5099179450696261534L;
+    private String uid;
+    private String url;
+}

+ 21 - 0
src/main/java/com/sckw/freight/model/dto/Order.java

@@ -0,0 +1,21 @@
+package com.sckw.freight.model.dto;
+
+import com.alibaba.fastjson2.annotation.JSONField;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * @author xucaiqin
+ * @date 2023-07-25 15:30:59
+ */
+@Getter
+@Setter
+public class Order implements Serializable {
+    @Serial
+    private static final long serialVersionUID = -3148504181066374194L;
+    @JSONField(name = "order_no")
+    private String orderNo;
+}

+ 30 - 0
src/main/java/com/sckw/freight/model/dto/PatchPay.java

@@ -0,0 +1,30 @@
+package com.sckw.freight.model.dto;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * @author xucaiqin
+ * @date 2023-07-25 17:09:42
+ */
+@Getter
+@Setter
+@AllArgsConstructor
+@NoArgsConstructor
+public class PatchPay implements Serializable {
+    @Serial
+    private static final long serialVersionUID = -719246443006291337L;
+
+    @JSONField(name = "uid")
+    private String uid;
+    @JSONField(name = "money")
+    private Long money;
+    @JSONField(name = "remark")
+    private String remark;
+}

+ 23 - 0
src/main/java/com/sckw/freight/model/dto/PayIndex.java

@@ -0,0 +1,23 @@
+package com.sckw.freight.model.dto;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+@Getter
+@Setter
+public class PayIndex implements Serializable {
+    @Serial
+    private static final long serialVersionUID = -114261812502553262L;
+    @JSONField(name = "order_no")
+    private String orderNo;
+
+    @JSONField(name = "uid")
+    private String uid;
+
+    @JSONField(name = "pay_url")
+    private String payUrl;
+}

+ 68 - 0
src/main/java/com/sckw/freight/model/dto/SplitDto.java

@@ -0,0 +1,68 @@
+package com.sckw.freight.model.dto;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+@Getter
+@Setter
+public class SplitDto implements Serializable {
+    @Serial
+    private static final long serialVersionUID = -2392867380336186963L;
+    /**
+     * 支付方UID
+     */
+    @JSONField(name = "uid")
+    private String uid;
+    /**
+     * 清分收款方UID
+     */
+    @JSONField(name = "recv_uid")
+    private String recvUid;
+
+    /**
+     * 清分金额
+     */
+    @JSONField(name = "money")
+    private int money;
+    /**
+     * 记录时间
+     */
+    @JSONField(name = "create_time")
+    private String createTime;
+    /**
+     * 业务号
+     */
+    @JSONField(name = "business_no")
+    private String businessNo;
+    /**
+     * 支付通道
+     */
+    @JSONField(name = "channel")
+    private String channel;
+
+    @JSONField(name = "ap_no")
+    private Object apNo;
+    /**
+     * 清分单号
+     */
+    @JSONField(name = "sub_no")
+    private String subNo;
+    /**
+     * 完成时间
+     */
+    @JSONField(name = "finish_time")
+    private String finishTime;
+    /**
+     * 1-成功 2-等待分账 3-分帐中
+     */
+    @JSONField(name = "status")
+    private int status;
+
+    @JSONField(name = "status_label")
+    private String statusLabel;
+
+}

+ 65 - 0
src/main/java/com/sckw/freight/model/dto/WalletDto.java

@@ -0,0 +1,65 @@
+package com.sckw.freight.model.dto;
+
+import com.alibaba.fastjson2.annotation.JSONField;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * 钱包清单
+ */
+@Data
+public class WalletDto implements Serializable {
+    /**
+     * 钱包名称
+     */
+    private String name;
+    /**
+     * uid对应的企业名称
+     */
+    @JSONField(name = "member_name")
+    private String memberName;
+
+    private String uid;
+    /**
+     * 渠道 huifu
+     */
+    private String channel;
+
+    @JSONField(name = "create_time")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private LocalDateTime createTime;
+
+    private String filter;
+    /**
+     * 冻结金额(分)
+     * note:冻结金额为预付金额
+     */
+    private Long freeze;
+    /**
+     * 预付金额(分)
+     */
+    @JSONField(name = "ap_money")
+    private Long apMoney;
+    /**
+     * 总金额(分)
+     */
+    @JSONField(name = "total_money")
+    private Long totalMoney;
+    /**
+     * 线上可用余额(分)
+     */
+    private Long money;
+    /**
+     * 充值中金额
+     */
+    @JSONField(name = "charging_money")
+    private Long chargingMoney;
+    /**
+     * 提现中金额
+     */
+    @JSONField(name = "withdrawing_money")
+    private Long withdrawingMoney;
+}

+ 116 - 0
src/main/java/com/sckw/freight/model/enums/ChannelEnum.java

@@ -0,0 +1,116 @@
+package com.sckw.freight.model.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import org.apache.commons.lang3.StringUtils;
+
+@Getter
+@AllArgsConstructor
+public enum ChannelEnum {
+//    HF("11", "1", "huifu", "汇付渠道"),
+//    XS("12", "2", "newpay", "新生渠道"),
+//    ZX("13", "3", "citic", "中信渠道"),
+    XW("14", "4", "xinwang", "新网银行"),
+    ;
+
+    /**
+     * 预付款+支付渠道
+     */
+    private final String code;
+
+    /**
+     * 渠道对应的字典值
+     */
+    private final String value;
+    private final String channel;
+    private final String desc;
+
+    /**
+     * 通过交易方式获取支付渠道
+     *
+     * @param trading 交易方式字典
+     * @return
+     */
+    public static ChannelEnum getByTrading(String trading) {
+        //长度为1 表示线下付款
+        if (StringUtils.isBlank(trading) || trading.length() <= 1) {
+            return null;
+        }
+        String channel = trading.substring(1, 2);
+        for (ChannelEnum channelEnum : ChannelEnum.values()) {
+            if (channelEnum.getValue().equals(channel)) {
+                return channelEnum;
+            }
+        }
+        return null;
+    }
+
+    public static ChannelEnum getByCode(String code) {
+        for (ChannelEnum channelEnum : ChannelEnum.values()) {
+            if (channelEnum.getCode().equals(code)) {
+                return channelEnum;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * 通过渠道获取
+     *
+     * @param channel 渠道
+     * @return
+     */
+    public static ChannelEnum getByChannel(String channel) {
+        for (ChannelEnum channelEnum : ChannelEnum.values()) {
+            if (channelEnum.getChannel().equals(channel)) {
+                return channelEnum;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * 通过渠道获取描述
+     *
+     * @param channel 渠道
+     * @return 渠道名称
+     */
+    public static String getDesc(String channel) {
+        for (ChannelEnum channelEnum : ChannelEnum.values()) {
+            if (channelEnum.getChannel().equals(channel)) {
+                return channelEnum.getDesc();
+            }
+        }
+        return "";
+    }
+
+    /**
+     * 通过渠道获取字典值
+     *
+     * @param channel
+     * @return
+     */
+    public static String getDict(String channel) {
+        for (ChannelEnum channelEnum : ChannelEnum.values()) {
+            if (channelEnum.getChannel().equals(channel)) {
+                return channelEnum.getValue();
+            }
+        }
+        return "";
+    }
+
+    /**
+     * 通过字典值获取
+     *
+     * @param value
+     * @return
+     */
+    public static ChannelEnum getByValue(String value) {
+        for (ChannelEnum channelEnum : ChannelEnum.values()) {
+            if (channelEnum.getValue().equals(value)) {
+                return channelEnum;
+            }
+        }
+        return null;
+    }
+}

+ 60 - 0
src/main/java/com/sckw/freight/model/enums/PayCenterEnum.java

@@ -0,0 +1,60 @@
+package com.sckw.freight.model.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * @author xucaiqin
+ * @date 2023-07-21 17:53:28
+ */
+@Getter
+@AllArgsConstructor
+public enum PayCenterEnum {
+    MEMBER_DETAIL("/v1/member/detail", "会员详情"),
+    MEMBER_WALLET("/v1/member/wallet", "钱包清单"),
+    MEMBER_WALLET_V2("/v2/member/wallet", "钱包清单v2"),
+    MEMBER_GENERAL("/v2/wallet/general", "总览信息"),
+    USER("/v2/member/user", "会员注册信息"),
+    WITHDRAW_DETAIL("/v2/wallet/withdraw/detail", "提现详情"),
+    //    WITHDRAW_DETAIL("/v1/wallet/withdraw/detail", "提现详情"), 原接口
+    //    WITHDRAW_INDEX("/v1/wallet/withdraw/index", "提现清单"), 原接口
+    WITHDRAW_INDEX("/v2/wallet/withdraw/index", "提现清单"),
+    WITHDRAW_CATEGORY("/v2/wallet/withdraw/categories", "提现清单分类"),
+    WITHDRAW_STATUS("/v1/wallet/withdraw/status", "订单状态"),
+    WITHDRAW_CANCEL("/v1/wallet/withdraw/cancel", "取消提现"),
+    WITHDRAW_TAKE("/v1/wallet/withdraw/take", "申请提现"),
+    TOTAL_INFO("/v1/wallet/totalInfo", "统计信息"),
+    OPERATE_DOWNLOAD("/v1/wallet/operate/download", "操作记录-下载"),
+    OPERATE_CATEGORY("/v1/wallet/operate/category", "操作记录-分类"),
+    OPERATE_INDEX("/v1/wallet/operate/index", "操作记录"),
+    LOG_CATEGORY("/v1/wallet/log/category", "钱包日志类型"),
+    RECORD("/v1/wallet/record", "获取钱包使用明细"),
+    TRANSFER("/v1/wallet/transfer", "余额转出"),
+    ADVANCE_PAY_DETAIL("/v1/wallet/advancepay/detail", "预付订单详情"),
+    ADVANCE_PAY_APPLY("/v1/wallet/advancepay/apply", "发起预付"),
+    ADVANCE_PAY_INDEX("/v1/wallet/advancepay/index", "预付订单清单"),
+    ADVANCE_PAY_INDEX2("/v2/wallet/advancepay/index", "预付订单清单"),
+    ADVANCE_PAY_WALLETS("/v2/advancepay/wallets", "钱包预付列表"),
+    ADVANCE_PAY_PAY_CHANNELS("/v2/advancepay/pay/channels", "钱包预付通道统计"),
+    ADVANCE_PAY_RECEIVE("/v2/advancepay/receives", "钱包预收列表"),
+    ADVANCE_PAY_LOGS("/v2/advancepay/operate/logs", "预付支出记录"),
+    ADVANCE_PAY_RECEIVE_CHANNELS("/v2/advancepay/receive/channels", "钱包预收通道统计"),
+    ADVANCE_PAY_STATUS("/v1/wallet/advancepay/statusCategory", "预付订单状态"),
+    INDEX("/v1/index/index", "获取通道清单"),
+    MEMBER_PAY_INDEX("/v1/member/pay/index", "订单记录"),
+    MEMBER_INDEX("/v1/member/index", "创建/更新账户"),
+    PAY_INDEX("/v1/pay/index", "在线充值"),
+    RECHARGE_ORDER("/v2/wallet/recharge/orders", "充值记录清单"),
+    WALLET_FREEZE("/v1/wallet/freeze", "冻结资金"),
+    WALLET_UNFREEZE("/v1/wallet/unfreeze", "解冻金额"),
+    PAY_AGENT_PAY("/v1/pay/agent_pay", "清分"),
+    PAY_AGENT_PAY_V2("/v2/pay/agent_pay", "清分"),
+    AGENT_PAY_QUERY("/v2/pay/status/query", "清分结果查询"),
+    WITHDRAW_TRANSFER("/v2/wallet/withdraw/transfer", "转出加提现"),
+    WALLET_INDEX("/v1/wallet/index", "创建钱包"),
+    REFUND_APPLY("/v1/pay/refund_apply", "充值订单退款"),
+    ;
+    private final String addr;
+    private final String desc;
+
+}

+ 461 - 0
src/main/java/com/sckw/freight/service/PayCenterService.java

@@ -0,0 +1,461 @@
+package com.sckw.freight.service;
+
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
+import com.alibaba.fastjson2.TypeReference;
+
+import com.sckw.freight.exception.BusinessException;
+import com.sckw.freight.model.dto.*;
+import com.sckw.freight.model.enums.ChannelEnum;
+import com.sckw.freight.model.enums.PayCenterEnum;
+import com.sckw.freight.util.OkHttpUtils;
+import com.sckw.freight.util.R;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotNull;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * 转发中台接口
+ *
+ * @author xucaiqin
+ * @date 2023-07-21 17:45:51
+ */
+@Service
+@Slf4j
+public class PayCenterService {
+    @Value("${payCenter.address}")
+    private String payCenterAddr;
+
+    private <T> R<List<T>> parseArray(String in, Class<T> t) {
+        R<String> res = JSONObject.parseObject(in, new TypeReference<R<String>>() {
+        });
+        String data = res.getData();
+        List<T> ts = JSONArray.parseArray(data, t);
+        R<List<T>> ok = R.ok(ts);
+        ok.setStatus(res.getStatus());
+        ok.setMsg(res.getMsg());
+        ok.setCode(res.getCode());
+        return ok;
+    }
+
+    private String getHttp(PayCenterEnum payCenterEnum, Map<String, Object> para) {
+        log.info("{}入参->{}", payCenterEnum.getDesc(), JSONObject.toJSONString(para));
+        OkHttpUtils okHttpUtils = OkHttpUtils.builder().url(payCenterAddr + payCenterEnum.getAddr());
+        if (!CollectionUtils.isEmpty(para)) {
+            for (Map.Entry<String, Object> p : para.entrySet()) {
+                //跳过非空参数
+                Object v = p.getValue();
+                String k = p.getKey();
+                if (Objects.isNull(v)) {
+                    continue;
+                }
+                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(k, v.toString());
+                }
+
+            }
+        }
+        String sync;
+        try {
+            sync = okHttpUtils.get().sync();
+        } catch (Exception e) {
+            log.error("中台服务异常", e.getCause());
+            throw new RuntimeException("支付服务异常!");
+        }
+        log.info("{}返回值->{}", payCenterEnum.getDesc(), sync);
+        return changeRes(sync);
+    }
+
+    private String postHttp(PayCenterEnum payCenterEnum, Map<String, Object> para) {
+        log.info("{}入参->{}", payCenterEnum.getDesc(), JSONObject.toJSONString(para));
+        OkHttpUtils okHttpUtils = OkHttpUtils.builder().url(payCenterAddr + payCenterEnum.getAddr());
+        if (!CollectionUtils.isEmpty(para)) {
+            for (Map.Entry<String, Object> p : para.entrySet()) {
+                //跳过非空参数
+                Object v = p.getValue();
+                String k = p.getKey();
+                if (Objects.isNull(v)) {
+                    continue;
+                }
+                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(k, JSONObject.toJSONString(v));
+                }
+            }
+        }
+        String sync;
+        try {
+            sync = okHttpUtils.post(true).sync();
+        } catch (Exception e) {
+            log.error("中台服务异常", e.getCause());
+            throw new RuntimeException("支付服务异常!");
+        }
+        log.info("{}返回值->{}", payCenterEnum.getDesc(), sync);
+        return changeRes(sync);
+    }
+
+    private String jsonHttp(PayCenterEnum payCenterEnum, Object object) {
+        String para = object instanceof JSONObject jsonObject ? jsonObject.toJSONString() : JSONObject.toJSONString(object);
+        log.info("{}入参->{}", payCenterEnum.getDesc(), para);
+        OkHttpUtils okHttpUtils = OkHttpUtils.builder().url(payCenterAddr + payCenterEnum.getAddr());
+        okHttpUtils.addBodyJsonStr(para);
+        String sync;
+        try {
+            sync = okHttpUtils.post(true).sync();
+        } catch (Exception e) {
+            log.error("中台服务异常", e.getCause());
+            throw new RuntimeException("支付服务异常!");
+        }
+        log.info("{}返回值->{}", payCenterEnum.getDesc(), sync);
+        return changeRes(sync);
+    }
+
+    private String changeRes(String sync) {
+        JSONObject jsonObject = JSONObject.parseObject(sync);
+        //我的泛型是对象 返回值有可能 是对象或数组 {} []
+        //data:[]->转换成 data:null 进入if
+        Object data = jsonObject.get("data");
+        if (Objects.nonNull(data) && data instanceof JSONArray d && d.isEmpty()) {
+            jsonObject.put("data", null);
+            sync = jsonObject.toJSONString();
+        }
+        return sync;
+    }
+
+
+
+
+
+
+    /**
+     * 会员注册信息
+     *
+     * @param uid
+     * @return
+     */
+    public R<JSONObject> user(String uid, ChannelEnum channelEnum) {
+        String sync = getHttp(PayCenterEnum.USER, new HashMap<>() {{
+            put("uid", uid);
+            put("channel", channelEnum);
+            put("channels", "xinwang");
+        }});
+        return JSONObject.parseObject(sync, new TypeReference<>() {
+        });
+    }
+
+
+
+
+
+
+
+    /**
+     * 订单状态
+     *
+     * @param type
+     * @return
+     */
+    public R<Map<String, String>> withdrawStatus(String type) {
+        if (StringUtils.isBlank(type)) {
+            type = "order";
+        }
+        String finalType = type;
+        String sync = getHttp(PayCenterEnum.WITHDRAW_STATUS, new HashMap<>() {{
+            put("type", finalType);
+            put("channels", "xinwang");
+        }});
+        return JSONObject.parseObject(sync, new TypeReference<>() {
+        });
+    }
+
+    /**
+     * 取消提现
+     *
+     * @param uid
+     * @param orderNo
+     * @return
+     */
+    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);
+        }});
+        return JSONObject.parseObject(sync, new TypeReference<>() {
+        });
+    }
+
+    /**
+     * 申请提现
+     *
+     * @param uid
+     * @param channel
+     * @param money
+     * @param remarks
+     * @return
+     */
+    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("提现金额不能为空");
+        }
+        String sync = postHttp(PayCenterEnum.WITHDRAW_TAKE, new HashMap<>() {{
+            put("uid", uid);
+            put("channel", channel);
+            put("money", money);
+            put("remarks", remarks);
+        }});
+        return JSONObject.parseObject(sync, new TypeReference<>() {
+        });
+    }
+
+
+
+
+    /**
+     * 操作记录-分类
+     *
+     * @return
+     */
+    public R<Map<String, String>> operateCategory() {
+        String sync = getHttp(PayCenterEnum.OPERATE_CATEGORY, new HashMap<>());
+        return JSONObject.parseObject(sync, new TypeReference<>() {
+        });
+    }
+
+
+
+
+
+    /**
+     * 发起预付
+     *
+     * @param uid     乙方uid
+     * @param channel 渠道
+     * @param filter  甲方uid
+     * @param money   金额,分
+     * @return
+     */
+    public R<Order> advancePayApply(String uid, ChannelEnum channel, String filter, Long money) {
+        String sync = postHttp(PayCenterEnum.ADVANCE_PAY_APPLY, new HashMap<>() {{
+            put("uid", uid);
+            put("channel", channel);
+            put("money", money);
+            put("filter", filter);
+        }});
+        return JSONObject.parseObject(sync, new TypeReference<>() {
+        });
+    }
+
+
+    /**
+     * 清分结果查询
+     *
+     * @param uid
+     * @param channel
+     * @param businessNo
+     * @return
+     */
+    public R<List<SplitDto>> agentPayQuery(String uid, ChannelEnum channel, String businessNo) {
+        String sync = getHttp(PayCenterEnum.AGENT_PAY_QUERY, new HashMap<>() {{
+            put("uid", uid);
+            put("channel", channel);
+            put("business_no", businessNo);
+            put("channels", "xinwang");
+        }});
+        return parseArray(sync, SplitDto.class);
+    }
+
+
+    /**
+     * 创建/更新账户
+     *
+     * @param memberCreate
+     * @return
+     */
+    public R<MemberRes> memberIndex(MemberCreate memberCreate) {
+
+        String sync = jsonHttp(PayCenterEnum.MEMBER_INDEX, memberCreate);
+        return JSONObject.parseObject(sync, new TypeReference<>() {
+        });
+    }
+
+    /**
+     * 在线充值
+     *
+     * @param buyUid  付款方/乙方/买货方 账户
+     * @param sellUid 收款方/甲方/供货方 账户
+     * @param channel 渠道方
+     * @param money   金额,单位分
+     * @return
+     */
+    public R<PayIndex> payIndex(String buyUid, String sellUid, ChannelEnum channel, Long money) {
+        String sync = postHttp(PayCenterEnum.PAY_INDEX, new HashMap<>() {{
+            put("buy_uid", buyUid);
+            put("sell_uid", sellUid);
+            put("channel", channel);
+            put("money", money);
+        }});
+
+        return JSONObject.parseObject(sync, new TypeReference<>() {
+        });
+    }
+
+
+
+    /**
+     * 冻结资金
+     * 中台逻辑:
+     * 先判断预付金额是否足够,足够就冻结预付金额。
+     * 不够则进行追加预付操作,在进行冻结
+     *
+     * @param uid        付款方uid
+     * @param channel    支付通道
+     * @param money      冻结金额,单位分
+     * @param filter     收款方uid
+     * @param businessNo 流水号
+     * @return
+     */
+    public R<Freeze> walletFreeze(String uid, ChannelEnum channel, String filter, Long money, String businessNo) {
+        String sync = postHttp(PayCenterEnum.WALLET_FREEZE, new HashMap<>() {{
+            put("uid", uid);
+            put("filter", filter);
+            put("channel", channel);
+            put("money", money);
+            put("business_no", businessNo);
+        }});
+        return JSONObject.parseObject(sync, new TypeReference<>() {
+        });
+    }
+
+    /**
+     * 解冻金额
+     *
+     * @param businessNo
+     * @return
+     */
+    public R<BusinessNo> walletUnFreeze(String businessNo) {
+        String sync = postHttp(PayCenterEnum.WALLET_UNFREEZE, new HashMap<>() {{
+            put("business_no", businessNo);
+        }});
+        return JSONObject.parseObject(sync, new TypeReference<>() {
+        });
+    }
+
+    /**
+     * 清分
+     * 中台逻辑:
+     * 先从预付金额中进行扣除,然后金额不够的情况下在调用三方接口进行清分,然后进行记账
+     * 因为预付业务实际就是真实的清分业务,所以先判断预付金额是否足够
+     *
+     * @param buyUid
+     * @param sellUid
+     * @param channel
+     * @param money
+     * @param batchPayList
+     * @param businessNo
+     * @return
+     */
+    public R<BusinessNo> payAgentPay(String buyUid, String sellUid, ChannelEnum channel, Long money, List<PatchPay> batchPayList, String businessNo) {
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("buy_uid", buyUid);
+        jsonObject.put("sell_uid", sellUid);
+        jsonObject.put("channel", channel.getChannel());
+        jsonObject.put("money", money);
+        jsonObject.put("batch_pay_list", batchPayList);
+        jsonObject.put("business_no", businessNo);
+        String sync = jsonHttp(PayCenterEnum.PAY_AGENT_PAY, jsonObject);
+        return JSONObject.parseObject(sync, new TypeReference<>() {
+        });
+    }
+
+    /**
+     * 清分
+     *
+     * @param buyUid       付款方uid
+     * @param sellUid      收款方
+     * @param channel      渠道
+     * @param money        总清分金额
+     * @param batchPayList 收款方集合
+     * @param businessNo   流水号
+     * @param payType      支付类型 0-默认 1-仅预付支付 2-仅余额支付
+     * @return
+     */
+    public R<BusinessNo> payAgentPayV2(String buyUid, String sellUid, ChannelEnum channel, Long money, List<PatchPay> batchPayList, String businessNo, String payType) {
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("buy_uid", buyUid);
+        jsonObject.put("sell_uid", sellUid);
+        jsonObject.put("channel", Objects.nonNull(channel) ? channel.getChannel() : "");
+        jsonObject.put("money", money);
+        jsonObject.put("batch_pay_list", batchPayList);
+        jsonObject.put("business_no", businessNo);
+        jsonObject.put("pay_type", payType);
+        String sync = jsonHttp(PayCenterEnum.PAY_AGENT_PAY_V2, jsonObject);
+        return JSONObject.parseObject(sync, new TypeReference<>() {
+        });
+    }
+
+    /**
+     * 创建钱包
+     *
+     * @param uid
+     * @param channel
+     * @param filter
+     * @param nickname
+     * @return
+     */
+    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);
+            put("filter", filter);
+            put("nickname", nickname);
+        }});
+        return JSONObject.parseObject(sync, new TypeReference<>() {
+        });
+    }
+
+
+}