·¢²¼Ê±¼ä:2022-11-29 15:32:04 ÎÄÕÂÀ´Ô´:»¥ÁªÍø
΢²© ΢ÐÅ QQ¿Õ¼ä

ÈÏÇåÏÖʵ£¬·ÅÆú»ÃÏ룬׼±¸¶·ÕùÒ»¡¢ºó¶ËʵÏÖ

ÈÏÇåÏÖʵ£¬·ÅÆú»ÃÏ룬׼±¸¶·ÕùÒ»¡¢ºó¶ËʵÏÖ

ÈÏÇåÏÖʵ£¬·ÅÏ»ÃÏ룬׼±¸Õ½¶·

Ò»¡¢ºó¶ËʵÏÖ 1¡¢ÊµÏÖ˼·

½è¿îÈËÌá½»´û¿îʱ£¬±ØÐëÅжϽè¿îÈËÕË»§°ó¶¨×´Ì¬ºÍ½è¿îÈËÐÅÏ¢ÉóÅú״̬¡£Ö»ÓÐÕâÁ½¸öÉí·Ý¶¼È·Á¢ÁË£¬Ëû²ÅÄܽèÇ®¡£ÕâÁ½ÖÖ״̬¶¼ÁÐÔÚ³ÉÔ±×ʸñ±íÖС£

Ä¿±ê£º½«Óû§ÔÚ´û¿îÉêÇë±íÖÐÌîдµÄÊý¾Ý±£´æÔÚborrow_infoÊý¾Ý¿â±íÖÐ

2.ö¾Ù

½èÓÃÐÅϢ״̬ö¾Ù

NO_AUTH(0, "δÌá½»"),

CHECK_RUN(1, "¼ì²éÖÐ"),

CHECK_OK(2, "Åú×¼"),

CHECK_FAIL(-1, "Ñé֤ʧ°Ü"),

;

״̬£¨0£ºÎ´Ìá½»£¬1£ºÉóºËÖнè¿î·þÎñÉêÇë±í£¬2£ºÍ¨¹ý½è¿î·þÎñÉêÇë±í£¬-1£ºÎ´Í¨¹ý£©

3.¿ØÖÆÆ÷

½èÓÃÐÅÏ¢¿ØÖÆÆ÷

@ApiOperation("Ìá½»½è¿îÉêÇë")
@PostMapping("/auth/save")
public R save(@RequestBody BorrowInfo borrowInfo, HttpServletRequest request) {
    String token = request.getHeader("token");
    Long userId = JwtUtils.getUserId(token);
    borrowInfoService.saveBorrowInfo(borrowInfo, userId);
    return R.ok().message("Ìá½»³É¹¦");
}

4.·þÎñ

½Ó¿Ú£ºBorrowInfoService

void saveBorrowInfo(BorrowInfo borrowInfo, Long userId);

ʵÏÖ£ºBorrowInfoServiceImpl

@Override
public void saveBorrowInfo(BorrowInfo borrowInfo, Long userId) {
    //»ñÈ¡userInfoµÄÓû§Êý¾Ý
    UserInfo userInfo = userInfoMapper.selectById(userId);
    //ÅжÏÓû§°ó¶¨×´Ì¬
    Assert.isTrue(
        userInfo.getBindStatus().intValue() == UserBindEnum.BIND_OK.getStatus().intValue(),
        ResponseEnum.USER_NO_BIND_ERROR);
    //ÅжÏÓû§ÐÅÏ¢ÊÇ·ñÉóÅúͨ¹ý
    Assert.isTrue(
        userInfo.getBorrowAuthStatus().intValue() == BorrowerStatusEnum.AUTH_OK.getStatus().intValue(),
        ResponseEnum.USER_NO_AMOUNT_ERROR);
    //ÅжϽè¿î¶î¶ÈÊÇ·ñ×ã¹»
    BigDecimal borrowAmount = this.getBorrowAmount(userId);
    Assert.isTrue(
        borrowInfo.getAmount().doubleValue() <= borrowAmount.doubleValue(),
        ResponseEnum.USER_AMOUNT_LESS_ERROR);
    //´æ´¢Êý¾Ý
    borrowInfo.setUserId(userId);
    //°Ù·Ö±Èת³ÉСÊý
    borrowInfo.setBorrowYearRate( borrowInfo.getBorrowYearRate().divide(new BigDecimal(100)));
    borrowInfo.setStatus(BorrowInfoStatusEnum.CHECK_RUN.getStatus());
    baseMapper.insert(borrowInfo);
}

2.Ç°¶ËÌá½»´û¿îÉêÇë

Ò³Ãæ/Óû§/apply.vue

    //Ìá½»½è¿îÉêÇë
    save() {
      // this.submitBtnDisabled = true
      this.$$axios
        .$$post('/api/core/borrowInfo/auth/save', this.borrowInfo)
        .then((response) => {
          this.active = 1
        })
    },

ÁíÒ»ÊÓ½Ç

»»Ò»»»