示例#1
0
  @RequestMapping(value = "/index")
  public ModelAndView index(
      HttpServletRequest request, HttpServletResponse response, ModelAndView mv) {
    mv.addObject("currentTime", Tools.getLongTime());

    PageData pd = new PageData(request);
    HashMap<String, Object> borrowList = thisService.getBorrowList(pd, mv);
    mv.addObject("borrowList", borrowList);

    HashMap<String, Object> xborrow = thisService.getXBorrowList();
    mv.addObject("xborrow", xborrow.get("data"));
    // logger.info("s当是人城"+xborrow);

    HashMap<String, String> indexFlashAd = (HashMap<String, String>) Common.getCacheAd("51", false);
    if (!Common.isBlankInMap(indexFlashAd, "content"))
      mv.addObject(
          "indexAdImgs",
          (List<HashMap<String, String>>) JacksonUtil.listFromJson(indexFlashAd.get("content")));

    // 网站公告
    Map<String, Object> notice = categoryService.getCategoryArticle("427", 6);
    mv.addObject("notice", notice);
    // 公司动态
    Map<String, Object> trace = categoryService.getCategoryArticle("389", 3);
    mv.addObject("trace", trace);
    // 新闻动态
    Map<String, Object> news = categoryService.getCategoryArticle("377", 6);
    mv.addObject("news", news);
    // 图片新闻
    Map<String, Object> imgnews = categoryService.getCategoryArticleImg("539", 6);
    mv.addObject("imgnews", imgnews);

    WhereUtil mapUtil = new WhereUtil();
    mapUtil.getStringCondition("borrow_status", "2,4,6,7", "in");
    Map<String, String> summary =
        BaseService.getOne(
            "borrow_info",
            mapUtil.getParamConditionList(),
            "sum(repayment_interest) as repayment_interest,sum(borrow_money) as borrow_money");
    Map<String, String> userSum =
        BaseService.getOne("user", Tools.BuildWhereMap("id", "0", ">"), "count(id) as num");
    Tools.printData(summary);
    summary.put("user_count", userSum.get("num"));
    mv.addObject("summary", summary);

    return this.getTplView(request, response, tplPath, mv);
  }
  public ModelAndView index(
      HttpServletRequest request, HttpServletResponse response, ModelAndView mv) {
    Map<String, String> compareSignSelect = new LinkedHashMap<String, String>();
    compareSignSelect.put("gt", "大于");
    compareSignSelect.put("eq", "等于");
    compareSignSelect.put("lt", "小于");
    mv.addObject("compareSignSelect", compareSignSelect);

    Map<String, String> txSignSelect = new LinkedHashMap<String, String>();
    txSignSelect.put("gt", "大于");
    txSignSelect.put("eq", "等于");
    txSignSelect.put("lt", "小于");
    mv.addObject("tbjSignSelect", txSignSelect);

    PageData pd = new PageData(request);

    HashMap<String, Object> list = thisService.getCapital_borrow_repaymentList(pd, mv);

    mv.addObject("list", list);

    Map<String, Object> borrowType = ConfigCache.getCacheList("BorrowType");
    if (borrowType != null) {
      HashMap<String, Object> typeList = (HashMap<String, Object>) borrowType.get("type");
      HashMap<String, Object> borrowTypeData = new LinkedHashMap<>();
      HashMap<String, Object> borrowTypeDataX =
          Common.buildNewKVMap(typeList, "key", "borrow_name");
      borrowTypeData.put(" ", "选择产品类型");
      for (Entry<String, Object> entry : borrowTypeDataX.entrySet()) {
        String ekeyString = entry.getKey();
        String eValueString = entry.getValue() + "";
        borrowTypeData.put(ekeyString, eValueString);
      }

      mv.addObject("borrowType", borrowTypeData);
    }

    Map<String, String> istatus = new LinkedHashMap<String, String>();
    istatus.put("", "==回款状态==");
    istatus.put("0", "还未确认通过");
    istatus.put("1", "已回收");
    istatus.put("7", "待回收");
    mv.addObject("istatus", istatus);

    return this.getTplView(request, response, tplPath, mv);
  }
  public void toExcel(HttpServletRequest request, HttpServletResponse response, ModelAndView mv) {
    PageData pd = new PageData(request);

    HashMap<String, Object> list = thisService.getCapital_borrow_repaymentExcelList(pd, mv);
    String[] arr = {
      "id as ID",
      "borrow_id as 标号",
      "user_name as 投资人",
      "real_name as 真实姓名",
      "capital as 应收本金",
      "interest as 应收利息",
      "use_reward_money as 使用奖励",
      "will_receive_capital as 待收本金",
      "will_receive_interest as 待收利息",
      "interest_fee as 利息管理费",
      "sort_order as 当前期数",
      "total as 总期数",
      "borrow_name as 借款名",
      "borrow_type as 产品名称",
      "deadline as 应收时间",
      "repayment_time as 实收时间",
    };

    Map<String, Object> borrowType = ConfigCache.getCacheList("BorrowType");

    HashMap<String, Object> typeList = (HashMap<String, Object>) borrowType.get("type");
    HashMap<String, Object> borrowTypeDataX = Common.buildNewKVMap(typeList, "key", "borrow_name");
    List<Map<String, Object>> SSData = (List<Map<String, Object>>) list.get("data");
    for (Map<String, Object> thisdata : SSData) {
      thisdata.put(
          "will_receive_capital",
          DfMath.s2sub(thisdata.get("capital") + "", thisdata.get("receive_capital") + ""));
      thisdata.put(
          "will_receive_interest",
          DfMath.s2sub(thisdata.get("interest") + "", thisdata.get("receive_interest") + ""));
      thisdata.put("borrow_type", borrowTypeDataX.get(thisdata.get("borrow_type")) + "");
    }
    ExcelUtil.writeExcel(SSData, "会员待收明细", arr, response);
  }
  public String editBorrow(PageData pd, Map<String, String> thisBorrowInfo) {
    // 些标种相关信息
    Map<String, Object> borrowTypeConfig =
        (Map<String, Object>)
            ((Map<String, Object>)
                    borrowAndInvest.getBorrowTypeConfig(thisBorrowInfo.get("borrow_type")))
                .get("borrow");
    Connection conn = MySQL.getConnectionReadOnly(false);
    String[] onlycanEditField = {
      "id",
      "can_auto",
      "deposit_fee",
      "borrow_fee",
      "vouch_company_id",
      "mortgage_id",
      "collect_time",
      "collect_day",
      "borrow_pass",
      "borrow_max",
      "borrow_money",
      "borrow_status",
      "borrow_info",
      "borrow_use",
      "borrow_name",
      "deal_info",
      "start_time"
    };
    Map<String, Object> borrowInfoMap = pd.getFormHandlerCan("borrow_info", onlycanEditField);

    List<String> canEditStatus = Arrays.asList("1", "2", "10");
    List<String[]> validatorMap = new ArrayList();
    validatorMap.add(
        Tools.buildValidatorObject(
            "deal_info", "处理说明不能为空", !StringUtils.isBlank(pd.post("deal_info") + "")));
    validatorMap.add(
        Tools.buildValidatorObject(
            "borrow_status",
            "处理状态不正确",
            canEditStatus.contains(borrowInfoMap.get("borrow_status") + "")));
    List<String> fieldCheck = PageData.getError(validatorMap);

    if (fieldCheck.size() > 0) return fieldCheck.get(0);

    // 密码标
    String password = borrowInfoMap.get("borrow_pass").toString();
    if (StringUtils.isBlank(password)) borrowInfoMap.remove("borrow_pass");
    else borrowInfoMap.put("borrow_pass", borrowAndInvest.md5(password));

    // logger.info("############"+borrowInfoMap.get("start_time")+"");
    // 预约标开标时间
    if (!Common.isBlankInMap(borrowInfoMap, "start_time"))
      borrowInfoMap.put("start_time", Tools.strToTime(borrowInfoMap.get("start_time") + ""));
    // 初审通过或者预发布
    if ("2".equals(borrowInfoMap.get("borrow_status"))
        || "10".equals(borrowInfoMap.get("borrow_status"))) { // 初审通过
      borrowInfoMap.put("collect_time", Tools.strToTime(borrowInfoMap.get("collect_time") + ""));
      // 保证金
      Tools.printData(borrowTypeConfig);
      String depositFeeRateString =
          (borrowTypeConfig != null)
              ? (String) ((Map<String, Object>) borrowTypeConfig.get("borrowFee")).get("deposit")
              : "5";
      double depositFeeRate = DfMath.s2div(depositFeeRateString, "100", 9);
      double depositFee =
          DfMath.round(
              (DfMath.s2multi(depositFeeRate + "", borrowInfoMap.get("borrow_money") + "")));
      borrowInfoMap.put("deposit_fee", depositFee);
    }

    HashMap<String, String> AdminInfo = (HashMap<String, String>) Common.getSession("AdminInfo");
    // 初审记录
    HashMap<String, Object> verifyLogMap = new HashMap<>();
    verifyLogMap.put("borrow_id", borrowInfoMap.get("id"));
    verifyLogMap.put("deal_info", pd.post("deal_info"));
    verifyLogMap.put("deal_user", AdminInfo.get("id"));
    verifyLogMap.put("deal_time", Tools.getLongTime());
    verifyLogMap.put("deal_status", borrowInfoMap.get("borrow_status"));

    try {
      thisDao.eidtBorrowInfo(conn, borrowInfoMap);
      thisDao.addVerify(conn, verifyLogMap);
      MySQL.commit(conn);
    } catch (Exception e) {
      MySQL.rollback(conn);
      logger.error("borrow_check失败", e);
      return "数据修改失败";
    } finally {
      MySQL.closeConnection(conn);
    }
    return "success";
  }