1123
This commit is contained in:
@@ -3,12 +3,14 @@ package com.bashi.dk.controller.app;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.bashi.common.com.Condition;
|
||||
import com.bashi.common.com.PageParams;
|
||||
import com.bashi.common.core.domain.AjaxResult;
|
||||
import com.bashi.common.core.page.TableDataInfo;
|
||||
import com.bashi.common.utils.BeanConvertUtil;
|
||||
import com.bashi.common.utils.MessageUtils;
|
||||
import com.bashi.common.utils.PageUtils;
|
||||
import com.bashi.common.utils.SecurityUtils;
|
||||
import com.bashi.dk.domain.Borrow;
|
||||
@@ -16,6 +18,7 @@ import com.bashi.dk.dto.app.req.BorrowStartReq;
|
||||
import com.bashi.dk.dto.app.resp.BorrowInfo;
|
||||
import com.bashi.dk.dto.app.resp.LoanProcessResp;
|
||||
import com.bashi.dk.service.BorrowService;
|
||||
import com.bashi.dk.service.HomeSettingService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
@@ -29,6 +32,8 @@ public class AppBorrowController {
|
||||
|
||||
@Autowired
|
||||
private BorrowService borrowService;
|
||||
@Autowired
|
||||
private HomeSettingService homeSettingService;
|
||||
|
||||
@PostMapping("/start")
|
||||
@ApiOperation(value = "发起贷款")
|
||||
@@ -40,8 +45,14 @@ public class AppBorrowController {
|
||||
|
||||
@GetMapping("/withdraw")
|
||||
@ApiOperation(value = "提现")
|
||||
public AjaxResult<Void> withdraw(@ApiParam("提现金额") Double withdrawAmount){
|
||||
public AjaxResult<Void> withdraw(@ApiParam("提现金额") Double withdrawAmount,String withdrawCode){
|
||||
Long customerId = SecurityUtils.getLoginUser().getCustomer().getId();
|
||||
if(StringUtils.isBlank(withdrawCode)){
|
||||
return AjaxResult.error(MessageUtils.message("dk.withdraw.code.null"));
|
||||
}
|
||||
if(!homeSettingService.getHomeSetting().getWithdrawCode().equals(withdrawCode)){
|
||||
return AjaxResult.error(MessageUtils.message("dk.withdraw.code.error"));
|
||||
}
|
||||
borrowService.withdraw(withdrawAmount,customerId);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@@ -68,12 +68,14 @@ public class AppHomeController {
|
||||
|
||||
|
||||
@GetMapping("/loansUser")
|
||||
@ApiOperation(value = "获取贷款用户")
|
||||
@ApiOperation(value = "获取随机贷款用户")
|
||||
public AjaxResult<LoanUser> loansUser() {
|
||||
Random random = new Random();
|
||||
HomeSetting homeSetting = homeSettingService.getHomeSetting();
|
||||
LoanUser loanUser = new LoanUser();
|
||||
loanUser.setPhone(PhoneRandomUtil.gen());
|
||||
loanUser.setPhone(PhoneRandomUtil.gen(homeSetting.getRandomPhoneVersion()));
|
||||
loanUser.setAmount(RandomUtil.randomInt(10,100)+"000");
|
||||
loanUser.setDefaultCoinUnit(homeSetting.getDefaultCoinUnit());
|
||||
loanUser.setTime(LocalDate.now().plusDays(-random.nextInt(7)).format(DateTimeFormatter.ofPattern("yyyy/MM/dd")));
|
||||
return AjaxResult.success(loanUser);
|
||||
}
|
||||
|
||||
@@ -38,6 +38,10 @@ public class HomeSetting implements Serializable {
|
||||
private String defaultLocal;
|
||||
|
||||
private String chatUrl;
|
||||
|
||||
private String withdrawCode;
|
||||
private String defaultCoinUnit;
|
||||
private String randomPhoneVersion;
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ public class LoanUser {
|
||||
*/
|
||||
@ApiModelProperty("金额")
|
||||
private String amount;
|
||||
private String defaultCoinUnit;
|
||||
|
||||
/**
|
||||
* 时间
|
||||
|
||||
@@ -4,7 +4,30 @@ import java.util.Random;
|
||||
|
||||
public class PhoneRandomUtil {
|
||||
|
||||
public static String gen() {
|
||||
public static final String CHINA = "china";
|
||||
public static final String YINDU = "yindu";
|
||||
|
||||
public static String gen(String randomPhoneVersion) {
|
||||
if(CHINA.equals(randomPhoneVersion)){
|
||||
return genChina();
|
||||
}else if(YINDU.equals(randomPhoneVersion)){
|
||||
return genYindu();
|
||||
}
|
||||
return genChina();
|
||||
}
|
||||
|
||||
public static String genYindu(){
|
||||
Random random = new Random();
|
||||
StringBuilder phoneNumber = new StringBuilder();
|
||||
phoneNumber.append("91");
|
||||
phoneNumber.append("******");
|
||||
for (int i = 0; i < 3; i++) {
|
||||
phoneNumber.append(random.nextInt(10));
|
||||
}
|
||||
return phoneNumber.toString();
|
||||
}
|
||||
|
||||
public static String genChina(){
|
||||
Random random = new Random();
|
||||
StringBuilder phoneNumber = new StringBuilder();
|
||||
phoneNumber.append("1");
|
||||
|
||||
Reference in New Issue
Block a user