FundBiz.java 26 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680
package com.cjs.site.biz.user.fund;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

import com.cjs.site.dao.pub.SysConfigDao;
import com.cjs.site.dao.user.fund.FundRealDao;
import com.cjs.site.dao.user.fund.OtcEntrustUsefulDao;
import com.cjs.site.dao.user.fund.UserKitingDao;
import com.cjs.site.dao.user.ration.RationNewFundDao;
import com.cjs.site.model.pub.SysConfigInfo;
import com.cjs.site.model.user.account.UserInfo;
import com.cjs.site.model.user.ration.RationNewFundInfo;
import com.cjs.site.util.lang.DateEnum;
import com.cjs.site.util.lang.DateUtil;
import com.cjs.site.util.lang.JsonUtil;
import com.cjs.site.util.lang.StringUtil;
import com.cjs.site.util.t2.T2Result;
import com.cjs.site.util.t2.T2Util;
import com.cjs.site.util.web.ActionUtil;

/**
 * 用户资金管理
 * 
 * @author tongyufu
 *
 */
@Service
public class FundBiz {

    Logger                      log = LogManager.getLogger(FundBiz.class);
    @Autowired
    private SysConfigDao        sysConfigDao;
    @Autowired
    private RationNewFundDao    rationNewFundDao;
    @Autowired
    private OtcEntrustUsefulDao usefulDao;
    @Autowired
    private FundRealDao fundRealDao;

    /**
     * 余额查询
     */
    public Map<String, Object> balance(String userId) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("entrust", "7");//委托请求
        params.put("request_num", "2000");//请求行数
        params.put("fund_account", userId);//资金账号
        params.put("client_id", userId);//客户号

        T2Result result = T2Util.request(params, "619014");
        log.info("用户[" + userId + "]资金余额:" + result);
        return result.getData().get(0);
    }
    
    /**
     * 余额查询
     */
    public Map<String, Double> balanceSelf(String userId) {
        return fundRealDao.getUserBalance(userId);
    }

    /**
     * 冻结用户资金
     * 
     * @param fundAccount 会员号
     * @param occurBalance 冻结金额
     * @param endDate 发生日期 yyyyMMdd
     * @param joinInfo 辅助信息
     * @param remark 备注
     */
    public T2Result freezeFund(String businessId, String businessType, String fundAccount,
                               Double occurBalance, Date endDate, String joinInfo, String remark) {
        Assert.notNull("会员号不能为空", fundAccount);
        Assert.state(occurBalance > 0.0, "冻结金额不能小于0");

        Map<String, Object> params = new HashMap<String, Object>();
        params.put("op_branch_no", "11"); //操作分支机构
        params.put("operator_no", "2001"); //操作员
        params.put("user_type", "1");
        params.put("op_password", "");
        params.put("op_station", ""); //站点地址
        params.put("op_entrust_way", "7"); //申请方式(7:网络)
        params.put("menu_id", "200501");
        params.put("function_id", "201031");
        params.put("branch_no", "11"); //分支机构
        params.put("audit_action", "0");
        params.put("action_in", "3");
        params.put("fund_account", fundAccount);
        params.put("money_type", "0");
        params.put("frozen_reason", "0"); //冻结原因(0:普通冻结)
        params.put("occur_balance", occurBalance);
        params.put("valid_date", DateUtil.parseDate(endDate, DateEnum.UNSIGNED_DATE)); //截止日期
        params.put("join_info", joinInfo);
        params.put("remark", remark);

        T2Result result = null;
        try {
            result = T2Util.request(params, "201031");
        } finally {
            RationNewFundInfo fund = new RationNewFundInfo();
            fund.setBusinessId(businessId);
            fund.setBusinessType(businessType);
            fund.setUserId(fundAccount);
            fund.setFund(occurBalance);
            fund.setFundType("addbank");
            if (result == null || result.getCode() != 0) {
                fund.setFundStatus("0");
            } else {
                fund.setFundStatus("1");
            }
            fund.setRemark(remark);
            fund.setServiceId("201031");
            fund.setRequest(JsonUtil.toJson(params));
            fund.setResponse(JsonUtil.toJson(result));
            fund.setCreateBy(" ");
            rationNewFundDao.save(fund);
        }
        log.info("冻结客户资金:" + result);
        return result;
    }

    /**
     * 解冻用户资金
     * @param fundAccount 会员号
     * @param serialNo 冻结资金流水号
     * @param freezeDate 冻结日期
     * @return
     */
    public T2Result unfreezeFund(String businessId, String businessType, String fundAccount,
                                 String serialNo, Date freezeDate) {
        Assert.notNull("会员号不能为空", fundAccount);
        Assert.notNull("冻结资金流水号不能为空", serialNo);
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("op_branch_no", "11"); //操作分支机构
        params.put("operator_no", "2001"); //操作员
        params.put("user_type", "1");
        params.put("op_password", "");
        params.put("op_station", ""); //站点地址
        params.put("op_entrust_way", "7"); //申请方式(7:网络)
        params.put("menu_id", "200502");
        params.put("function_id", "201033");
        params.put("branch_no", "11"); //分支机构
        params.put("audit_action", "0");
        params.put("action_in", "0");
        params.put("fund_account", fundAccount);
        params.put("serial_no", serialNo);
        params.put("jour_date", DateUtil.parseDate(freezeDate, DateEnum.UNSIGNED_DATE));
        params.put("join_info", "");
        params.put("remark", "");
        T2Result result = null;
        try {
            result = T2Util.request(params, "201033");
        } finally {
            RationNewFundInfo fund = new RationNewFundInfo();
            fund.setBusinessId(businessId);
            fund.setBusinessType(businessType);
            fund.setUserId(fundAccount);
            fund.setFund(0d);
            fund.setFundType("addbank");
            if (result == null || result.getCode() != 0) {
                fund.setFundStatus("0");
            } else {
                fund.setFundStatus("1");
            }
            fund.setRemark("");
            fund.setServiceId("201033");
            fund.setRequest(JsonUtil.toJson(params));
            fund.setResponse(JsonUtil.toJson(result));
            fund.setCreateBy(" ");
            rationNewFundDao.save(fund);
        }
        log.info("解冻用户资金:" + result);
        return result;
    }

    /**
     * 查询用户冻结资金记录
     * 
     * @param fundAccount 会员号
     * @param startDate 起始日期
     * @param endDate 结束日期
     * @return
     * <pre>
     * serial_no 流水号
     * init_date 发生日期
     * client_id 会员号
     * fund_account 会员号
     * curr_date 发生日期
     * curr_time 发生时间
     * occur_balance 冻结金额
     * post_balance 后置资金
     * treat_status 冻结状态(0:资金冻结;1:冻结取消)
     * valid_date 截止日期
     * frozen_status 冻结原因(0:普通冻结)
     * remark 备注
     * </pre>
     */
    public T2Result freezeRecord(String fundAccount, Date startDate, Date endDate) {
        Assert.notNull("会员号不能为空", fundAccount);
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("op_branch_no", "11"); //操作分支机构
        params.put("operator_no", "2001"); //操作员
        params.put("user_type", "1");
        params.put("op_password", "");
        params.put("op_station", ""); //站点地址
        params.put("op_entrust_way", "7"); //申请方式(7:网络)
        params.put("menu_id", "200502");
        params.put("function_id", "201037");
        params.put("branch_no", "11"); //分支机构
        params.put("audit_action", "0");
        params.put("action_in", "0");
        params.put("fund_account", fundAccount);
        params.put("start_date", DateUtil.parseDate(startDate, DateEnum.UNSIGNED_DATE));
        params.put("end_date", DateUtil.parseDate(endDate, DateEnum.UNSIGNED_DATE));
        params.put("serial_no", "0");
        params.put("en_business_flag", "2301");
        params.put("en_money_type", "0");
        params.put("en_operator_no", "2001");
        params.put("position_str", "");
        params.put("request_num", "0");
        T2Result result = T2Util.request(params, "201037");
        log.info("查询用户冻结资金记录:" + result);
        return result;
    }

    /**托管资金流水*/
    public List<Map<String, Object>> fundRecord(Map<String, Object> params, UserInfo userInfo) {
        String startDate = StringUtil.castString(params.get("start_date"));
        String endDate = StringUtil.castString(params.get("end_date"));
        String currentDate = DateUtil.parseDate(new Date(), DateEnum.UNSIGNED_DATE);

        if (StringUtils.isBlank(startDate)) {
            startDate = DateUtil.parseDate(new Date(), DateEnum.UNSIGNED_DATE);
        } else {
            startDate = startDate.replace("-", "");
        }
        params.put("start_date", startDate);
        if (StringUtils.isBlank(endDate)) {
            endDate = DateUtil.parseDate(new Date(), DateEnum.UNSIGNED_DATE);
        } else {
            endDate = endDate.replace("-", "");
        }

        params.put("end_date", endDate);
        params.put("op_branch_no", "11");
        params.put("operator_no", "2001");
        params.put("user_type", "1");
        params.put("op_entrust_way", "4");
        params.put("menu_id", "4200");
        params.put("branch_no", "11");
        //params.put("en_business_flag", "35950");
        params.put("client_id", userInfo.getClient_id());
        params.put("fund_account", userInfo.getFund_account());
        params.put("position_str", "0");
        params.put("request_num", "200");
        params.put("sort_direction", "1"); //0:正序;1:倒序
        log.info("用户资金流水params:" + params);

        List<Map<String, Object>> funds = new ArrayList<Map<String, Object>>();
        // 当天资金流水
        if (currentDate.equals(endDate)) {
            T2Result result = T2Util.request(params, "380504");
            log.info("用户当天资金流水:" + result);
            funds.addAll(this.processFund(result.getData()));
        }
        //历史资金流水
        if (DateUtil.parseDate(startDate, DateEnum.UNSIGNED_DATE)
            .before(DateUtil.parseDate(currentDate, DateEnum.UNSIGNED_DATE))) {
            T2Result result = T2Util.request(params, "390504");
            log.info("用户历史资金流水:" + result);
            funds.addAll(this.processFund(result.getData()));
        }
        //
        startDate = DateUtil.parseDate(DateUtil.parseDate(startDate, DateEnum.UNSIGNED_DATE),
            DateEnum.DATE);
        endDate = DateUtil.parseDate(DateUtil.parseDate(endDate, DateEnum.UNSIGNED_DATE),
            DateEnum.DATE);
        params.put("start_date", startDate);
        params.put("end_date", endDate);
        return funds;
    }
    
    
    public List<Map<String, Object>> fundRecordNew(Map<String, Object> params, UserInfo userInfo)
    {
      String startDate = StringUtil.castString(params.get("start_date"));
      String endDate = StringUtil.castString(params.get("end_date"));
      if (StringUtils.isBlank(startDate))
        startDate = DateUtil.parseDate(new Date(), DateEnum.UNSIGNED_DATE);
      else {
        startDate = startDate.replace("-", "");
      }
      params.put("start_date", startDate);
      if (StringUtils.isBlank(endDate))
        endDate = DateUtil.parseDate(new Date(), DateEnum.UNSIGNED_DATE);
      else {
        endDate = endDate.replace("-", "");
      }
      params.put("end_date", endDate);

      int businessFlag = 0;
      if (!StringUtil.isBlank(params.get("en_business_flag"))) {
        businessFlag = Integer.parseInt(params.get("en_business_flag").toString());
        switch (businessFlag) {
        case 1:
          params.put("remark", "客户提现");
          params.put("en_business_flag", "2516");
          break;
        case 2:
          params.put("remark", "入金调增");
          params.put("en_business_flag", "2515");
          break;
        default:
          businessFlag = 0;
        }

      }

      params.put("fundAccount", ActionUtil.getUser().getFund_account());
      List<Map<String, Object>> funds = this.fundRealDao.queryFundRecord(params);
      params.put("_total", Integer.valueOf(this.fundRealDao.queryFundRecordTotal(params)));

      for (Map map : funds) {
        map.put("PARENT_CODE", "2000");
        SysConfigInfo sysConfigInfo = this.sysConfigDao.queryByCondition(map);
        map.put("BUSINESS_FLAG", sysConfigInfo.getSysValue());
        if ("存管资金红冲".equals(map.get("BUSINESS_FLAG").toString())) {
          if (map.get("REMARK").toString().indexOf("客户提现") >= 0)
            map.put("BUSINESS_FLAG", "客户提现");
        }
        else if (("存管资金蓝补".equals(map.get("BUSINESS_FLAG").toString())) && 
          (map.get("REMARK").toString().indexOf("入金调增") >= 0)) {
          map.put("BUSINESS_FLAG", "客户入金");
        }

        String initDate = DateUtil.parseDate(
          DateUtil.parseDate(map.get("INIT_DATE").toString(), DateEnum.UNSIGNED_DATE), 
          DateEnum.DATE);

        map.put("CURR_DATE_TIME", initDate);
      }

      if (businessFlag != 0) {
        params.put("en_business_flag", Integer.valueOf(businessFlag));
      }

      startDate = DateUtil.parseDate(DateUtil.parseDate(startDate, DateEnum.UNSIGNED_DATE), 
        DateEnum.DATE);
      endDate = DateUtil.parseDate(DateUtil.parseDate(endDate, DateEnum.UNSIGNED_DATE), 
        DateEnum.DATE);
      params.put("start_date", startDate);
      params.put("end_date", endDate);
      return funds;
    }
    
    

    private List<Map<String, Object>> processFund(List<Map<String, Object>> funds) {
        List<SysConfigInfo> configs = sysConfigDao.queryByParentCode("2000");
        for (Map<String, Object> fund : funds) {
            String business_flag = StringUtil.castString(fund.get("business_flag"));
            String date = fund.get("init_date").toString();
            String time = fund.get("curr_time").toString();
            Date datetime = null;
            for (SysConfigInfo config : configs) {
                if (StringUtils.equals(business_flag, config.getSysKey())) {
                    fund.put("business_flag", config.getSysValue());
                }
            }
            if ("0".equals(time)) {
                datetime = DateUtil.parseDate(date, DateEnum.UNSIGNED_DATE);
            } else {
                if (time.length() < 6) {
                    time = "0" + time;
                }
                datetime = DateUtil.parseDate(date + time, DateEnum.UNSIGNED_DATE_TIME);
            }
            fund.put("curr_date_time", DateUtil.parseDate(datetime, DateEnum.DATETIME));
        }
        return funds;
    }

    /**
     * 支付
     * @param businessId 对应的业务记录主键
     * @param businessType 业务类型,在com.cjs.cms.model.pub.ConstInfo中定义
     * @param payer 付款人
     * @param payee 收款人
     * @param money 金额
     * @param remark 备注
     * @return 接口结果信息集合,全部成功集合size为4;失败则只有当前的失败信息
     */
    public List<T2Result> pay(String businessId, String businessType, String payer, String payee,
                              Double money, String remark) {
        List<T2Result> results = new ArrayList<T2Result>();
        T2Result result;
        result = this.subtractSysFund(businessId, businessType, payer, money, remark);
        results.add(result);
        if (result.getCode() != 0) {
            return Arrays.asList(result);
        }
        result = this.subtractBankFund(businessId, businessType, payer, money, remark);
        results.add(result);
        if (result.getCode() != 0) {
            return Arrays.asList(result);
        }
        result = this.addSysFund(businessId, businessType, payee, money, remark);
        results.add(result);
        if (result.getCode() != 0) {
            return Arrays.asList(result);
        }
        result = this.addBankFund(businessId, businessType, payee, money, remark);
        results.add(result);
        if (result.getCode() != 0) {
            return Arrays.asList(result);
        }
        return results;
    }

    /**
     * 银行业务_三方存管内部资金蓝补
     * @param businessId 相关业务主键
     * @param userId 会员号
     * @param money 蓝补金额
     * @param remark 备注
     */
    public T2Result addSysFund(String businessId, String businessType, String userId, Double money,
                               String remark) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("op_branch_no", "11");
        params.put("operator_no", "2001");
        params.put("user_type", "");
        params.put("op_password", "111111");
        params.put("op_station", "");
        params.put("op_entrust_way", "7");
        params.put("menu_id", "");
        params.put("function_id", "");
        params.put("branch_no", "11");
        params.put("audit_action", "1");
        params.put("action_in", "");
        params.put("fund_account", userId);
        params.put("money_type", "0");
        params.put("occur_date", DateUtil.getNow(DateEnum.UNSIGNED_DATE));
        params.put("occur_balance", money);
        params.put("bank_no", "");
        //params.put("join_info", "存管内部附加信息");
        params.put("remark", remark);
        T2Result result = null;
        try {
            result = T2Util.request(params, "202102");
        } finally {
            RationNewFundInfo fund = new RationNewFundInfo();
            fund.setBusinessId(businessId);
            fund.setBusinessType(businessType);
            fund.setUserId(userId);
            fund.setFund(money);
            fund.setFundType("addsys");
            if (result == null || result.getCode() != 0) {
                fund.setFundStatus("0");
            } else {
                fund.setFundStatus("1");
            }
            fund.setRemark(remark);
            fund.setServiceId("202102");
            fund.setRequest(JsonUtil.toJson(params));
            fund.setResponse(JsonUtil.toJson(result));
            fund.setCreateBy(" ");
            rationNewFundDao.save(fund);
        }
        log.info("银行业务_三方存管内部资金蓝补调用结果:" + result);
        return result;
    }

    /**
     * 银行业务_三方存管银行单边资金调增
     * @param userId 会员号
     * @param money 蓝补金额
     * @param remark 备注
     */
    public T2Result addBankFund(String businessId, String businessType, String userId, Double money,
                                String remark) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("op_branch_no", "11");
        params.put("operator_no", "2001");
        params.put("user_type", "");
        params.put("op_password", "111111");
        params.put("op_station", "");
        params.put("op_entrust_way", "7");
        params.put("menu_id", "");
        params.put("function_id", "");
        params.put("branch_no", "11");
        params.put("audit_action", "1");
        params.put("action_in", "");
        params.put("fund_account", userId);
        params.put("money_type", "0");
        params.put("occur_date", DateUtil.getNow(DateEnum.UNSIGNED_DATE));
        params.put("occur_balance", money);
        params.put("bank_no", "");
        //params.put("join_info", "存管内部附加信息");
        params.put("remark", remark);
        T2Result result = null;
        try {
            result = T2Util.request(params, "202110");
        } finally {
            RationNewFundInfo fund = new RationNewFundInfo();
            fund.setBusinessId(businessId);
            fund.setBusinessType(businessType);
            fund.setUserId(userId);
            fund.setFund(money);
            fund.setFundType("addbank");
            if (result == null || result.getCode() != 0) {
                fund.setFundStatus("0");
            } else {
                fund.setFundStatus("1");
            }
            fund.setRemark(remark);
            fund.setServiceId("202110");
            fund.setRequest(JsonUtil.toJson(params));
            fund.setResponse(JsonUtil.toJson(result));
            fund.setCreateBy(" ");
            rationNewFundDao.save(fund);
        }
        log.info("银行业务_三方存管银行单边资金调增调用结果:" + result);
        return result;
    }

    /**
     * 银行业务_三方存管内部资金红冲
     * @param userId 会员号
     * @param money 红冲金额,需为负数
     * @param remark 备注
     */
    public T2Result subtractSysFund(String businessId, String businessType, String userId,
                                    Double money, String remark) {
        Map<String, Object> params = new HashMap<String, Object>();
        if (money > 0) {
            money *= -1;
        }
        params.put("op_branch_no", "11");
        params.put("operator_no", "2001");
        params.put("user_type", "");
        params.put("op_password", "111111");
        params.put("op_station", "");
        params.put("op_entrust_way", "7");
        params.put("menu_id", "");
        params.put("function_id", "");
        params.put("branch_no", "11");
        params.put("audit_action", "1");
        params.put("action_in", "");
        params.put("fund_account", userId);
        params.put("money_type", "0");
        params.put("occur_date", DateUtil.getNow(DateEnum.UNSIGNED_DATE));
        params.put("occur_balance", money);
        params.put("bank_no", "");
        //params.put("join_info", "存管内部附加信息");
        params.put("remark", remark);
        T2Result result = null;
        try {
            result = T2Util.request(params, "202101");
        } finally {
            RationNewFundInfo fund = new RationNewFundInfo();
            fund.setBusinessId(businessId);
            fund.setBusinessType(businessType);
            fund.setUserId(userId);
            fund.setFund(money);
            fund.setFundType("subsys");
            if (result == null || result.getCode() != 0) {
                fund.setFundStatus("0");
            } else {
                fund.setFundStatus("1");
            }
            fund.setRemark(remark);
            fund.setServiceId("202101");
            fund.setRequest(JsonUtil.toJson(params));
            fund.setResponse(JsonUtil.toJson(result));
            fund.setCreateBy(" ");
            rationNewFundDao.save(fund);
        }
        log.info("银行业务_三方存管内部资金红冲调用结果:" + result);
        return result;
    }

    /**
     * 银行业务_三方存管银行单边资金红冲
     * @param userId 会员号
     * @param money 红冲金额,需为负数
     * @param remark 备注
     */
    public T2Result subtractBankFund(String businessId, String businessType, String userId,
                                     Double money, String remark) {
        Map<String, Object> params = new HashMap<String, Object>();
        if (money > 0) {
            money *= -1;
        }
        params.put("op_branch_no", "11");
        params.put("operator_no", "2001");
        params.put("user_type", "");
        params.put("op_password", "111111");
        params.put("op_station", "");
        params.put("op_entrust_way", "7");
        params.put("menu_id", "");
        params.put("function_id", "");
        params.put("branch_no", "11");
        params.put("audit_action", "1");
        params.put("action_in", "");
        params.put("fund_account", userId);
        params.put("money_type", "0");
        params.put("occur_date", DateUtil.getNow(DateEnum.UNSIGNED_DATE));
        params.put("occur_balance", money);
        params.put("bank_no", "");
        //params.put("join_info", "存管内部附加信息");
        params.put("remark", remark);
        T2Result result = null;
        try {
            result = T2Util.request(params, "202109");
        } finally {
            RationNewFundInfo fund = new RationNewFundInfo();
            fund.setBusinessId(businessId);
            fund.setBusinessType(businessType);
            fund.setUserId(userId);
            fund.setFund(money);
            fund.setFundType("subbank");
            if (result == null || result.getCode() != 0) {
                fund.setFundStatus("0");
            } else {
                fund.setFundStatus("1");
            }
            fund.setRemark(remark);
            fund.setServiceId("202109");
            fund.setRequest(JsonUtil.toJson(params));
            fund.setResponse(JsonUtil.toJson(result));
            fund.setCreateBy(" ");
            rationNewFundDao.save(fund);
        }
        log.info("银行业务_三方存管银行单边资金红冲调用结果:" + result);
        return result;
    }

    /**
     * 修改用户委托方式
     * @param useful
     * @return
     */
    public String usefulOperate(String useful) {
        UserInfo userInfo = ActionUtil.getUser();
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("fundAccount", userInfo.getFund_account());
        params.put("useful", useful);
        if (usefulDao.queryCountByAccount(userInfo.getFund_account()) == 0) {
            usefulDao.save(params);
        } else {
            usefulDao.updateUseful(params);
        }
        return JsonUtil.toJson("resultMsg", "委托有效期修改成功,如需修改请前往会员中心-我的账户进行修改");
    }

    /**
     * 查询用户委托方式的状态
     * @return
     */
    public String checkEntrustUseful() {
        if (usefulDao.queryCountByAccount(ActionUtil.getUser().getFund_account()) > 0) {
            return "1";
        } else {
            return "0";
        }
    }
}