Kaynağa Gözat

feat:“增加定时汇付提现功能,减少财务工作量“

soobin 1 yıl önce
ebeveyn
işleme
bdffdfd805

+ 5 - 0
src/main/java/com/szwl/constant/HuifuConstant.java

@@ -74,6 +74,11 @@ public class HuifuConstant {
     public static final String TOKEN_NO = "10010356033";
 
     /**
+     *
+     */
+    public static final String SZ_TOKEN_NO = "10031470954";
+
+    /**
      * >>>>>>>>>>>>> 币种 >>>>>>>>>>>>>
      *
      */

+ 27 - 0
src/main/java/com/szwl/controller/ScheduledService.java

@@ -1,8 +1,10 @@
 package com.szwl.controller;
 
+import com.szwl.constant.HuifuConstant;
 import com.szwl.feign.bean.PayFeign;
 import com.szwl.mapper.TLocationCheckMapper;
 import com.szwl.model.entity.TLocationCheck;
+import com.szwl.model.utils.DateUtils;
 import com.szwl.service.*;
 import com.szwl.service.es.EsTCoinOrderService;
 import com.szwl.service.es.EsTOrderService;
@@ -17,6 +19,7 @@ import java.io.IOException;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.util.Calendar;
+import java.util.Date;
 import java.util.List;
 
 
@@ -51,6 +54,9 @@ public class ScheduledService {
     TWechatService wechatService;
 
     @Autowired
+    THuifuMchService huifuMchService;
+
+    @Autowired
     PayFeign payFeign;
 
     // 每周二上午8点10分去校验设备位置
@@ -181,4 +187,25 @@ public class ScheduledService {
             payFeign.resetSignIn();
         }
     }
+
+    /**
+     *  定时月末汇付提现申泽公账
+     */
+    @Scheduled(cron = "0 0 6 28-31 * *")
+    public void regularWithdrawal() {
+        if (isDo()) {
+            // 先判断是不是最后一天
+            if (DateUtils.isLastDayOfMonth(new Date())) {
+                // 先查询余额
+                try {
+                    String balance = huifuMchService.checkBalance(HuifuConstant.SZ_DIV_HUIFU_ID);
+                    if (!"0.00".equals(balance)) {
+                        huifuMchService.withdraw(balance, HuifuConstant.SZ_DIV_HUIFU_ID, "D1", HuifuConstant.SZ_TOKEN_NO);
+                    }
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
 }

+ 1 - 2
src/main/java/com/szwl/controller/THuifuMchController.java

@@ -15,7 +15,6 @@ import com.szwl.model.bo.ResponseModel;
 import com.szwl.model.bo.UserDetailBO;
 import com.szwl.model.entity.THuifuMch;
 import com.szwl.model.entity.THuifuMchCheck;
-import com.szwl.model.entity.TJoinpayMch;
 import com.szwl.model.param.UploadParms;
 import com.szwl.service.THuifuMchCheckService;
 import com.szwl.service.THuifuMchService;
@@ -427,7 +426,7 @@ public class THuifuMchController {
         LambdaQueryWrapper<THuifuMch> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.eq(THuifuMch::getAdminId,adminId);
         THuifuMch tHuifuMch = tHuifuMchService.getOne(queryWrapper);
-        String result = tHuifuMchService.checkBalance(tHuifuMch);
+        String result = tHuifuMchService.checkBalance(tHuifuMch.getHuifuId());
         return R.ok(result);
     }
 

+ 21 - 0
src/main/java/com/szwl/model/param/RemoteProParam.java

@@ -0,0 +1,21 @@
+package com.szwl.model.param;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+@Accessors(chain = true)
+@ApiModel(description = "远程制作参数")
+@Data
+public class RemoteProParam {
+
+    @ApiModelProperty("账号登录名")
+    private String username;
+
+    @ApiModelProperty("设备编号")
+    private String clientId;
+
+    @ApiModelProperty("商品名称")
+    private String productName;
+}

+ 241 - 239
src/main/java/com/szwl/model/utils/DateUtils.java

@@ -7,260 +7,262 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 
-public class DateUtils
-{
-  public static final String PATTERN_MMdd = "MMdd";
-  public static final String PATTERN_yyyyMMdd = "yyyyMMdd";
-  public static final String PATTERN_yyyyMMddHHmmss = "yyyyMMddHHmmss";
-  public static final String PATTERN_yyyyMMddHHmmssSSS = "yyyyMMddHHmmssSSS";
-  public static final String PATTERN_yyyy_MM_dd = "yyyy-MM-dd";
-  public static final String PATTERN_yyyy_M_d = "yyyy-M-d";
-  public static final String PATTERN_yyyy_MM_dd_HH_mm_ss = "yyyy-MM-dd HH:mm:ss";
-  public static final String PATTERN_yyyy_MM_dd_HH_mm = "yyyy-MM-dd HH:mm";
-  public static final String PATTERN_HH_mm_ss = "HH:mm:ss";
-  public static final String PATTERN_HHmmss = "HHmmss";
-  public static final String PATTERN_HH = "HH";
-  public static final String PATTERN_MMdd2 = "MM月dd";
-  public static final String PATTERN_MM = "MM";
-  public static final Map<String, String> mapChDate = new HashMap<String, String>();
-
-  public static Date getNextday(Date now)
-  {
-    Calendar calendar = Calendar.getInstance();
-    calendar.setTime(now);
-    calendar.add(5, 1);
-    return calendar.getTime();
-  }
-  
-  public static Date getPreday(Date now)
-  {
-    Calendar calendar = Calendar.getInstance();
-    calendar.setTime(now);
-    calendar.add(5, -1);
-    return calendar.getTime();
-  }
-
-  public static String formatDate_ch(Date date)
-  {
-    if(date==null){
-   	 throw new IllegalArgumentException("需要转换的对象为空");
+public class DateUtils {
+    public static final String PATTERN_MMdd = "MMdd";
+    public static final String PATTERN_yyyyMMdd = "yyyyMMdd";
+    public static final String PATTERN_yyyyMMddHHmmss = "yyyyMMddHHmmss";
+    public static final String PATTERN_yyyyMMddHHmmssSSS = "yyyyMMddHHmmssSSS";
+    public static final String PATTERN_yyyy_MM_dd = "yyyy-MM-dd";
+    public static final String PATTERN_yyyy_M_d = "yyyy-M-d";
+    public static final String PATTERN_yyyy_MM_dd_HH_mm_ss = "yyyy-MM-dd HH:mm:ss";
+    public static final String PATTERN_yyyy_MM_dd_HH_mm = "yyyy-MM-dd HH:mm";
+    public static final String PATTERN_HH_mm_ss = "HH:mm:ss";
+    public static final String PATTERN_HHmmss = "HHmmss";
+    public static final String PATTERN_HH = "HH";
+    public static final String PATTERN_MMdd2 = "MM月dd";
+    public static final String PATTERN_MM = "MM";
+    public static final Map<String, String> mapChDate = new HashMap<String, String>();
+
+    public static Date getNextday(Date now) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(now);
+        calendar.add(5, 1);
+        return calendar.getTime();
+    }
+
+    public static Date getPreday(Date now) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(now);
+        calendar.add(5, -1);
+        return calendar.getTime();
+    }
+
+    public static String formatDate_ch(Date date) {
+        if (date == null) {
+            throw new IllegalArgumentException("需要转换的对象为空");
+        }
+        String str = formatDate(date, "MMdd");
+        str = (String) mapChDate.get(str.substring(0, 2)) + str.substring(2);
+        return str;
+    }
+
+    public static String formatDate(Date date, String pattern) {
+        if (date == null) {
+            return "";
+        }
+        SimpleDateFormat sdf = null;
+        if (pattern == null)
+            sdf = new SimpleDateFormat();
+        else {
+            sdf = new SimpleDateFormat(pattern);
+        }
+        return sdf.format(date);
+    }
+
+    public static String formatDate(Date date) {
+        SimpleDateFormat sdf = new SimpleDateFormat();
+        return sdf.format(date);
+    }
+
+    public static Date parseDate(String source, String pattern) throws ParseException {
+        SimpleDateFormat sdf = null;
+        if (pattern == null)
+            sdf = new SimpleDateFormat();
+        else {
+            sdf = new SimpleDateFormat(pattern);
+        }
+        return sdf.parse(source);
+    }
+
+    public static Date parseDate(String source) throws ParseException {
+        SimpleDateFormat sdf = new SimpleDateFormat();
+        return sdf.parse(source);
+    }
+
+    public static Date parseDate(String source, Date defaultDate) {
+        try {
+            SimpleDateFormat sdf = new SimpleDateFormat();
+            return sdf.parse(source);
+        } catch (ParseException e) {
+        }
+        return defaultDate;
+    }
+
+    public static Date parseDate(String source, String pattern, Date defaultDate) {
+        try {
+            SimpleDateFormat sdf = null;
+            if (pattern == null)
+                sdf = new SimpleDateFormat();
+            else {
+                sdf = new SimpleDateFormat(pattern);
+            }
+            return sdf.parse(source);
+        } catch (ParseException e) {
+        }
+        return defaultDate;
+    }
+
+    public static boolean tryParse(String source) throws ParseException {
+        try {
+            Integer.parseInt(source);
+            return true;
+        } catch (NumberFormatException e) {
+        }
+        return false;
+    }
+
+    public static Date changeDate(Date date, TimeType timeType, int amount) {
+        if ((date == null) || (timeType == null) || (amount == 0)) {
+            return date;
+        }
+        Calendar c = Calendar.getInstance();
+        c.setTime(date);
+        c.add(timeType.getValue(), amount);
+        return c.getTime();
+    }
+
+    public static boolean isSameDay(Date date1, Date date2) {
+        if ((date1 == null) || (date2 == null)) {
+            throw new IllegalArgumentException("The date must not be null");
+        }
+        Calendar cal1 = Calendar.getInstance();
+        cal1.setTime(date1);
+        Calendar cal2 = Calendar.getInstance();
+        cal2.setTime(date2);
+        return isSameDay(cal1, cal2);
+    }
+
+    public static boolean isSameDay(Calendar cal1, Calendar cal2) {
+        if ((cal1 == null) || (cal2 == null)) {
+            throw new IllegalArgumentException("The date must not be null");
+        }
+        return (cal1.get(0) == cal2.get(0)) && (cal1.get(1) == cal2.get(1)) && (cal1.get(6) == cal2.get(6));
     }
-    String str = formatDate(date, "MMdd");
-    str = (String)mapChDate.get(str.substring(0, 2)) + str.substring(2);
-    return str;
-  }
-
-  public static String formatDate(Date date, String pattern)
-  {
-    if(date==null){
-        return "";
+
+    /**
+     * @deprecated
+     */
+    public static Date add(Date date, int calendarField, int amount) {
+        if (date == null) {
+            throw new IllegalArgumentException("The date must not be null");
+        }
+        Calendar c = Calendar.getInstance();
+        c.setTime(date);
+        c.add(calendarField, amount);
+        return c.getTime();
     }
-    SimpleDateFormat sdf = null;
-    if (pattern == null)
-      sdf = new SimpleDateFormat();
-    else {
-      sdf = new SimpleDateFormat(pattern);
+
+    public static Date addYears(Date date, int amount) {
+        return add(date, 1, amount);
     }
-    return sdf.format(date);
-  }
-
-  public static String formatDate(Date date) {
-    SimpleDateFormat sdf = new SimpleDateFormat();
-    return sdf.format(date);
-  }
-
-  public static Date parseDate(String source, String pattern) throws ParseException
-  {
-    SimpleDateFormat sdf = null;
-    if (pattern == null)
-      sdf = new SimpleDateFormat();
-    else {
-      sdf = new SimpleDateFormat(pattern);
+
+    public static Date addMonths(Date date, int amount) {
+        return add(date, 2, amount);
     }
-    return sdf.parse(source);
-  }
-
-  public static Date parseDate(String source) throws ParseException {
-    SimpleDateFormat sdf = new SimpleDateFormat();
-    return sdf.parse(source);
-  }
-
-  public static Date parseDate(String source, Date defaultDate) {
-    try {
-      SimpleDateFormat sdf = new SimpleDateFormat();
-      return sdf.parse(source);
+
+    public static Date addWeeks(Date date, int amount) {
+        return add(date, 3, amount);
     }
-    catch (ParseException e)
-    {
+
+    public static Date addDays(Date date, int amount) {
+        return add(date, 5, amount);
     }
-    return defaultDate;
-  }
-
-  public static Date parseDate(String source, String pattern, Date defaultDate) {
-    try {
-      SimpleDateFormat sdf = null;
-      if (pattern == null)
-        sdf = new SimpleDateFormat();
-      else {
-        sdf = new SimpleDateFormat(pattern);
-      }
-      return sdf.parse(source);
+
+    public static Date addHours(Date date, int amount) {
+        return add(date, 11, amount);
     }
-    catch (ParseException e) {
+
+    public static Date addMinutes(Date date, int amount) {
+        return add(date, 12, amount);
     }
-    return defaultDate;
-  }
-
-  public static boolean tryParse(String source) throws ParseException {
-    try {
-      Integer.parseInt(source);
-      return true;
-    } catch (NumberFormatException e) {
+
+    public static Date addSeconds(Date date, int amount) {
+        return add(date, 13, amount);
     }
-    return false;
-  }
 
-  public static Date changeDate(Date date, TimeType timeType, int amount)
-  {
-    if ((date == null) || (timeType == null) || (amount == 0)) {
-      return date;
+    public static Date addMilliseconds(Date date, int amount) {
+        return add(date, 14, amount);
     }
-    Calendar c = Calendar.getInstance();
-    c.setTime(date);
-    c.add(timeType.getValue(), amount);
-    return c.getTime();
-  }
-
-  public static boolean isSameDay(Date date1, Date date2)
-  {
-    if ((date1 == null) || (date2 == null)) {
-      throw new IllegalArgumentException("The date must not be null");
+
+    static {
+        mapChDate.put("01", "一月");
+        mapChDate.put("02", "二月");
+        mapChDate.put("03", "三月");
+        mapChDate.put("04", "四月");
+        mapChDate.put("05", "五月");
+        mapChDate.put("06", "六月");
+        mapChDate.put("07", "七月");
+        mapChDate.put("08", "八月");
+        mapChDate.put("09", "九月");
+        mapChDate.put("10", "十月");
+        mapChDate.put("11", "十一月");
+        mapChDate.put("12", "十二月");
     }
-    Calendar cal1 = Calendar.getInstance();
-    cal1.setTime(date1);
-    Calendar cal2 = Calendar.getInstance();
-    cal2.setTime(date2);
-    return isSameDay(cal1, cal2);
-  }
-
-  public static boolean isSameDay(Calendar cal1, Calendar cal2)
-  {
-    if ((cal1 == null) || (cal2 == null)) {
-      throw new IllegalArgumentException("The date must not be null");
+
+    public static enum TimeType {
+        SECOND(13), MINUTE(12), HOUR(10), DAY(5),
+        WEEK(4), MONTH(2),
+        YEAR(1);
+
+        private int value;
+
+        private TimeType(int value) {
+            this.value = value;
+        }
+
+        public int getValue() {
+            return this.value;
+        }
     }
-    return (cal1.get(0) == cal2.get(0)) && (cal1.get(1) == cal2.get(1)) && (cal1.get(6) == cal2.get(6));
-  }
-
-  /** @deprecated */
-  public static Date add(Date date, int calendarField, int amount)
-  {
-    if (date == null) {
-      throw new IllegalArgumentException("The date must not be null");
+
+    /**
+     * 毛龙飞
+     *
+     * @param d
+     * @param day
+     * @return
+     * @Description 获取日期的后几天
+     */
+    public static Date getDateAfter(Date d, int day) {
+        Calendar now = Calendar.getInstance();
+        now.setTime(d);
+        now.set(Calendar.DATE, now.get(Calendar.DATE) + day);
+        return now.getTime();
     }
-    Calendar c = Calendar.getInstance();
-    c.setTime(date);
-    c.add(calendarField, amount);
-    return c.getTime();
-  }
-
-  public static Date addYears(Date date, int amount)
-  {
-    return add(date, 1, amount);
-  }
-
-  public static Date addMonths(Date date, int amount)
-  {
-    return add(date, 2, amount);
-  }
-
-  public static Date addWeeks(Date date, int amount)
-  {
-    return add(date, 3, amount);
-  }
-
-  public static Date addDays(Date date, int amount)
-  {
-    return add(date, 5, amount);
-  }
-
-  public static Date addHours(Date date, int amount)
-  {
-    return add(date, 11, amount);
-  }
-
-  public static Date addMinutes(Date date, int amount)
-  {
-    return add(date, 12, amount);
-  }
-
-  public static Date addSeconds(Date date, int amount)
-  {
-    return add(date, 13, amount);
-  }
-
-  public static Date addMilliseconds(Date date, int amount)
-  {
-    return add(date, 14, amount);
-  }
-
-  static
-  {
-    mapChDate.put("01", "一月");
-    mapChDate.put("02", "二月");
-    mapChDate.put("03", "三月");
-    mapChDate.put("04", "四月");
-    mapChDate.put("05", "五月");
-    mapChDate.put("06", "六月");
-    mapChDate.put("07", "七月");
-    mapChDate.put("08", "八月");
-    mapChDate.put("09", "九月");
-    mapChDate.put("10", "十月");
-    mapChDate.put("11", "十一月");
-    mapChDate.put("12", "十二月");
-  }
-
-  public static enum TimeType
-  {
-    SECOND(13), MINUTE(12), HOUR(10), DAY(5), 
-    WEEK(4), MONTH(2), 
-    YEAR(1);
-
-    private int value;
-
-    private TimeType(int value) {
-      this.value = value;
+
+    /**
+     * 获取week 0是周日
+     *
+     * @param day
+     * @return
+     */
+    public static int getWeek(Date day) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(day);
+        int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
+        if (w < 0)
+            w = 0;
+        return w;
     }
 
-    public int getValue() {
-      return this.value;
+    /**
+     * 判断给定日期是否是当月的最后一天
+     *
+     * @param date
+     * @return
+     */
+    public static boolean isLastDayOfMonth(Date date) {
+        //1、创建日历类
+        Calendar calendar = Calendar.getInstance();
+        //2、设置当前传递的时间,不设就是当前系统日期
+        calendar.setTime(date);
+        //3、data的日期是N,那么N+1【假设当月是30天,30+1=31,如果当月只有30天,那么最终结果为1,也就是下月的1号】
+        calendar.set(Calendar.DATE, (calendar.get(Calendar.DATE) + 1));
+        //4、判断是否是当月最后一天【1==1那么就表明当天是当月的最后一天返回true】
+        if (calendar.get(Calendar.DAY_OF_MONTH) == 1) {
+            return true;
+        } else {
+            return false;
+        }
     }
-  }
-  /**
-   * 
-   * 毛龙飞
-   * @Description 获取日期的后几天
-   * @param d
-   * @param day
-   * @return
-   */
-  public static Date getDateAfter(Date d, int day) {  
-      Calendar now = Calendar.getInstance();  
-      now.setTime(d);  
-      now.set(Calendar.DATE, now.get(Calendar.DATE) + day);  
-      return now.getTime();  
-  }
-
-  /**
-   * 获取week 0是周日
-   * @param day
-   * @return
-   */
-  public static int getWeek(Date day) {
-    Calendar cal = Calendar.getInstance();
-    cal.setTime(day);
-    int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
-    if (w < 0)
-      w = 0;
-    return w;
-  }
 }

+ 13 - 4
src/main/java/com/szwl/service/THuifuMchService.java

@@ -1,13 +1,12 @@
 package com.szwl.service;
 
+import com.baomidou.mybatisplus.extension.service.IService;
 import com.huifu.bspay.sdk.opps.core.exception.BasePayException;
 import com.szwl.constant.HuifuConstant;
 import com.szwl.model.entity.THuifuMch;
-import com.baomidou.mybatisplus.extension.service.IService;
 import com.szwl.model.entity.THuifuMchCheck;
 import org.springframework.web.multipart.MultipartFile;
 
-import java.io.File;
 import java.math.BigDecimal;
 
 /**
@@ -101,8 +100,18 @@ public interface THuifuMchService extends IService<THuifuMch> {
 
     /**
      * 查询账户余额
-     * @param tHuifuMch
+     * @param huifuId
      * @return
      */
-    String checkBalance(THuifuMch tHuifuMch) throws Exception;
+    String checkBalance(String huifuId) throws Exception;
+
+    /**
+     * 提现
+     * @param cashAmt 取现金额
+     * @param huifuId 汇付商户号
+     * @param dateType 到账日期类型
+     * @param tokenNo 取现卡序列号
+     * @return 成功状态
+     */
+    String withdraw(String cashAmt, String huifuId, String dateType, String tokenNo) throws BasePayException;
 }

+ 56 - 12
src/main/java/com/szwl/service/impl/THuifuMchServiceImpl.java

@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.huifu.bspay.sdk.opps.core.exception.BasePayException;
@@ -15,15 +16,13 @@ import com.huifu.bspay.sdk.opps.core.utils.SequenceTools;
 import com.szwl.common.myAnnotation.HuifuBaseCommon;
 import com.szwl.config.OppsMerchantConfig;
 import com.szwl.constant.HuifuConstant;
-import com.szwl.model.bo.R;
+import com.szwl.mapper.THuifuMchMapper;
 import com.szwl.model.entity.TAdmin;
 import com.szwl.model.entity.THuifuMch;
-import com.szwl.mapper.THuifuMchMapper;
 import com.szwl.model.entity.THuifuMchCheck;
 import com.szwl.service.TAdminService;
 import com.szwl.service.THuifuMchCheckService;
 import com.szwl.service.THuifuMchService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.szwl.util.HuifuUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
@@ -46,7 +45,10 @@ import java.math.BigDecimal;
 import java.nio.charset.Charset;
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
-import java.util.*;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.TreeMap;
 
 import static com.szwl.util.HuifuUtils.base64ToTempImage;
 
@@ -1002,10 +1004,10 @@ public class THuifuMchServiceImpl extends ServiceImpl<THuifuMchMapper, THuifuMch
     }
 
     @Override
-    public String checkBalance(THuifuMch tHuifuMch) throws Exception {
+    public String checkBalance(String huifuId) throws Exception {
         // 请求接口
         String url = "https://api.huifu.com/v2/trade/acctpayment/balance/query";
-        HuifuBaseCommon.doInit(OppsMerchantConfig.getMerchantConfig());
+//        HuifuBaseCommon.doInit(OppsMerchantConfig.getMerchantConfig());
         // 请求参数:Data
         JSONObject request = new JSONObject();
         // 请求流水号
@@ -1013,15 +1015,15 @@ public class THuifuMchServiceImpl extends ServiceImpl<THuifuMchMapper, THuifuMch
         // 请求日期
         request.put("req_date", DateTools.getCurrentDateYYYYMMDD());
         // 汇付ID
-        request.put("huifu_id", tHuifuMch.getHuifuId());
+        request.put("huifu_id", huifuId);
 
         // 签名:sign
-        String s = JSON.toJSONString(request);
-        String s1 = JSON.toJSONString(JSONObject.parseObject(s, TreeMap.class));
-        String sign = HuifuUtils.sign(s1, HuifuConstant.RSA_PRIVATE_KEY);
+        String jsonString = JSON.toJSONString(JSONObject.parseObject(request.toString(), TreeMap.class));
+        String sign = HuifuUtils.sign(jsonString, HuifuConstant.RSA_PRIVATE_KEY);
+
 
         // 公共参数
-        System.out.println("请求参数:"+ request);
+        log.info("余额查询请求参数:{}", request);
         JSONObject requestData = new JSONObject();
         requestData.put("sys_id", HuifuConstant.SYS_ID);
         requestData.put("product_id", HuifuConstant.PRODUCT_ID);
@@ -1029,7 +1031,7 @@ public class THuifuMchServiceImpl extends ServiceImpl<THuifuMchMapper, THuifuMch
         requestData.put("data", request);
 
         String result = OkHttpClientTools.httpPost(url, requestData.toString(), HuifuConstant.PRODUCT_ID);
-        System.out.println("返回的数据:"+ result);
+        log.info("余额查询返回数据:{}", result);
         JSONObject jsonObject = JSONObject.parseObject(result);
         JSONObject dataObject = jsonObject.getJSONObject("data");
         String acctInfoList = dataObject.getString("acctInfo_list");
@@ -1043,4 +1045,46 @@ public class THuifuMchServiceImpl extends ServiceImpl<THuifuMchMapper, THuifuMch
         }
         return balanceAmt;
     }
+
+    @Override
+    public String withdraw(String cashAmt, String huifuId, String dateType, String tokenNo) throws BasePayException {
+        // 请求接口
+        String url = "https://api.huifu.com/v2/trade/settlement/enchashment";
+        // 请求参数:Data
+        JSONObject request = new JSONObject();
+        // 请求流水号
+        request.put("req_seq_id", SequenceTools.getReqSeqId32());
+        // 请求日期
+        request.put("req_date", DateTools.getCurrentDateYYYYMMDD());
+        // 取现金额
+        request.put("cash_amt", cashAmt);
+        // 汇付ID
+        request.put("huifu_id", huifuId);
+        // 到账日期类型
+        request.put("into_acct_date_type", dateType);
+        // 取现卡序列号
+        request.put("token_no", tokenNo);
+
+        // 签名:sign
+        String jsonString = JSON.toJSONString(JSONObject.parseObject(request.toString(), TreeMap.class));
+        String sign = HuifuUtils.sign(jsonString, HuifuConstant.RSA_PRIVATE_KEY);
+
+
+        // 公共参数
+        log.info("汇付提现请求参数:{}", request);
+        JSONObject requestData = new JSONObject();
+        requestData.put("sys_id", HuifuConstant.SYS_ID);
+        requestData.put("product_id", HuifuConstant.PRODUCT_ID);
+        requestData.put("sign", sign);
+        requestData.put("data", request);
+
+        String result = OkHttpClientTools.httpPost(url, requestData.toString(), HuifuConstant.PRODUCT_ID);
+        log.info("汇付提现返回数据:{}", result);
+        JSONObject jsonObject = JSONObject.parseObject(result);
+        JSONObject dataObject = jsonObject.getJSONObject("data");
+        if(dataObject.getString("resp_code").equals("00000000")) {
+            return jsonObject.getString("resp_desc");
+        }
+        return "";
+    }
 }