@@ -12,9 +12,9 @@ spring:
|
||||
# 主库数据源
|
||||
master:
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://localhost:4306/dk?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true
|
||||
username: dk
|
||||
password: dk123.com
|
||||
url: jdbc:mysql://124.222.254.188:4306/dk?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true
|
||||
username: root
|
||||
password: 383200134
|
||||
# 从库数据源
|
||||
slave:
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
@@ -66,13 +66,13 @@ spring:
|
||||
# redis 配置
|
||||
redis:
|
||||
# 地址
|
||||
host: localhost
|
||||
host: 124.222.254.188
|
||||
# 端口,默认为 6379
|
||||
port: 6379
|
||||
port: 9379
|
||||
# 数据库索引
|
||||
database: 1
|
||||
database: 3
|
||||
# 密码
|
||||
password:
|
||||
password: 383200134
|
||||
# 连接超时时间
|
||||
timeout: 10s
|
||||
# 是否开启ssl
|
||||
|
||||
@@ -99,6 +99,9 @@ public class Customer implements Serializable {
|
||||
@ApiModelProperty("最后登陆IP")
|
||||
private String lastLoginIp;
|
||||
|
||||
@ApiModelProperty("当前登录时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
|
||||
@JsonSerialize(using = LocalDateTimeSerializer.class)
|
||||
@JsonFormat(pattern = DateConstant.PATTERN_DATETIME)
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.bashi.dk.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.bashi.common.core.domain.AjaxResult;
|
||||
import com.bashi.common.core.domain.entity.Customer;
|
||||
import com.bashi.dk.domain.Borrow;
|
||||
import com.bashi.dk.service.BorrowService;
|
||||
import com.bashi.dk.service.CustomerService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/dk/home")
|
||||
public class HomeController {
|
||||
|
||||
@Autowired
|
||||
private CustomerService customerService;
|
||||
@Autowired
|
||||
private BorrowService borrowService;
|
||||
|
||||
@GetMapping("/index")
|
||||
public AjaxResult<Map<String,Long>> index() {
|
||||
Map<String,Long> map = new HashMap<>();
|
||||
LocalDate now = LocalDate.now();
|
||||
// 今日注册, 总注册
|
||||
long todayRegister = customerService.count(Wrappers.lambdaQuery(Customer.class).between(Customer::getCreateTime,
|
||||
now.atTime(LocalTime.MIN), now.atTime(LocalTime.MAX)));
|
||||
long totalRegister = customerService.count();
|
||||
// 今日订单, 总订单
|
||||
long todayBorrow = borrowService.count(Wrappers.lambdaQuery(Borrow.class).between(Borrow::getCreateTime,
|
||||
now.atTime(LocalTime.MIN), now.atTime(LocalTime.MAX)));
|
||||
long totalBorrow = borrowService.count();
|
||||
map.put("todayRegister",todayRegister);
|
||||
map.put("totalRegister",totalRegister);
|
||||
map.put("todayBorrow",todayBorrow);
|
||||
map.put("totalBorrow",totalBorrow);
|
||||
return AjaxResult.success(map);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.bashi.common.constant.DateConstant;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
@@ -34,7 +36,6 @@ public class Borrow implements Serializable {
|
||||
@TableId(value = "id")
|
||||
@ApiModelProperty("ID")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("用途说明")
|
||||
private String noteRemark;
|
||||
|
||||
@@ -92,6 +93,10 @@ public class Borrow implements Serializable {
|
||||
@ApiModelProperty("借款状态")
|
||||
private String borrowName;
|
||||
|
||||
/** 借款状态编码 **/
|
||||
@ApiModelProperty("借款状态ID")
|
||||
private Long borrowStatusId;
|
||||
|
||||
@ApiModelProperty("借款状态样式")
|
||||
private String borrowNameStyle;
|
||||
|
||||
@@ -201,6 +206,7 @@ public class Borrow implements Serializable {
|
||||
|
||||
/** 创建时间 */
|
||||
@ApiModelProperty("创建时间")
|
||||
@JsonFormat(pattern = DateConstant.PATTERN_DATETIME)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/** 修改时间 */
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
package com.bashi.dk.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 借款状态对象 dk_borrow_status
|
||||
@@ -35,6 +38,12 @@ public class BorrowStatus implements Serializable {
|
||||
@ApiModelProperty("是否可以打款")
|
||||
private Integer usedRemit;
|
||||
|
||||
@ApiModelProperty("借款状态编码")
|
||||
private String borrowCode;
|
||||
|
||||
@ApiModelProperty("是否允许提现")
|
||||
private Boolean withdrawFlag;
|
||||
|
||||
/** 借款状态 */
|
||||
@ApiModelProperty("借款状态")
|
||||
private String borrowName;
|
||||
|
||||
@@ -7,6 +7,7 @@ public class BorrowUpdateStatusReq {
|
||||
private Long id;
|
||||
private Integer usedRemit;
|
||||
private String borrowName;
|
||||
private Long borrowStatusId;
|
||||
private String borrowRemark;
|
||||
private String borrowNameStyle;
|
||||
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
package com.bashi.dk.dto.admin.resp;
|
||||
|
||||
import com.bashi.dk.domain.Borrow;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class BorrowResp extends Borrow {
|
||||
|
||||
private String customerLoginName;
|
||||
|
||||
@ApiModelProperty("是否允许提现")
|
||||
private Boolean withdrawFlag;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ public interface BorrowService extends IService<Borrow> {
|
||||
|
||||
void withdraw(Double withdrawAmount, Long customerId);
|
||||
|
||||
Borrow getByCustomerId(Long customerId);
|
||||
|
||||
LoanProcessResp getStepBorrow(Long customerId);
|
||||
|
||||
LoanProcessResp parseStepBorrow(Borrow one);
|
||||
|
||||
@@ -4,4 +4,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bashi.dk.domain.BorrowStatus;
|
||||
|
||||
public interface BorrowStatusService extends IService<BorrowStatus> {
|
||||
BorrowStatus getByCode(String borrowStatusCode);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.bashi.dk.service.impl;
|
||||
|
||||
import cn.hutool.core.annotation.MirroredAnnotationAttribute;
|
||||
import com.aliyun.oss.ServiceException;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
@@ -12,10 +12,7 @@ import com.bashi.common.exception.CustomException;
|
||||
import com.bashi.common.utils.BeanConvertUtil;
|
||||
import com.bashi.common.utils.JsonUtils;
|
||||
import com.bashi.common.utils.MessageUtils;
|
||||
import com.bashi.dk.domain.AgreementSetting;
|
||||
import com.bashi.dk.domain.Borrow;
|
||||
import com.bashi.dk.domain.CustomerInfo;
|
||||
import com.bashi.dk.domain.LoansSetting;
|
||||
import com.bashi.dk.domain.*;
|
||||
import com.bashi.dk.dto.admin.req.BorrowUpdateStatusReq;
|
||||
import com.bashi.dk.dto.admin.resp.BorrowResp;
|
||||
import com.bashi.dk.dto.app.req.BorrowStartReq;
|
||||
@@ -37,7 +34,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
@@ -59,6 +55,10 @@ public class BorrowServiceImpl extends ServiceImpl<BorrowMapper, Borrow> impleme
|
||||
private LoansSettingService loansSettingService;
|
||||
@Autowired
|
||||
private RedissonClient redissonClient;
|
||||
@Autowired
|
||||
private AgreementSettingService agreementSettingService;
|
||||
@Autowired
|
||||
private BorrowStatusService borrowStatusService;
|
||||
|
||||
@Override
|
||||
public Borrow borrow(BorrowStartReq req) {
|
||||
@@ -161,6 +161,7 @@ public class BorrowServiceImpl extends ServiceImpl<BorrowMapper, Borrow> impleme
|
||||
if(remit){
|
||||
update.setRemitFlag(1);
|
||||
}
|
||||
update.setBorrowStatusId(bo.getBorrowStatusId());
|
||||
boolean bool = this.updateById(update);
|
||||
if(bool && remit){
|
||||
customerService.borrowAmount(borrow.getCustomerId(), borrow.getTotalLoanMoney(),borrow.getTotalRepayment());
|
||||
@@ -191,6 +192,18 @@ public class BorrowServiceImpl extends ServiceImpl<BorrowMapper, Borrow> impleme
|
||||
|
||||
@Override
|
||||
public void withdraw(Double withdrawAmount, Long customerId) {
|
||||
Borrow borrow = this.getByCustomerId(customerId);
|
||||
if(borrow == null){
|
||||
throw new CustomException(MessageUtils.message("dk.withdraw.account.error"));
|
||||
}
|
||||
if(borrow.getBorrowStatusId() != null){
|
||||
BorrowStatus borrowStatus = borrowStatusService.getById(borrow.getBorrowStatusId());
|
||||
if(borrowStatus != null){
|
||||
if(BooleanUtils.isFalse(borrowStatus.getWithdrawFlag())){
|
||||
throw new CustomException(MessageUtils.message("dk.withdraw.account.error"));
|
||||
}
|
||||
}
|
||||
}
|
||||
Customer customer = customerService.getById(customerId);
|
||||
if(BooleanUtils.isNotTrue(customer.getAllowWithdrawFlag())){
|
||||
throw new CustomException(MessageUtils.message("dk.withdraw.account.error"));
|
||||
@@ -214,6 +227,12 @@ public class BorrowServiceImpl extends ServiceImpl<BorrowMapper, Borrow> impleme
|
||||
this.updateById(update);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Borrow getByCustomerId(Long customerId) {
|
||||
return this.getOne(Wrappers.lambdaQuery(Borrow.class).eq(Borrow::getCustomerId, customerId)
|
||||
.last("limit 1"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoanProcessResp getStepBorrow(Long customerId){
|
||||
Borrow one = this.getOne(Wrappers.lambdaQuery(Borrow.class).eq(Borrow::getCustomerId,customerId));
|
||||
@@ -252,9 +271,6 @@ public class BorrowServiceImpl extends ServiceImpl<BorrowMapper, Borrow> impleme
|
||||
return baseMapper.pageAdmin(Condition.getPage(pageParams),bo);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private AgreementSettingService agreementSettingService;
|
||||
|
||||
@Override
|
||||
public String getContract(String tradeNo) {
|
||||
Borrow borrow = this.getByTradeNo(tradeNo);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.bashi.dk.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bashi.dk.domain.BorrowStatus;
|
||||
import com.bashi.dk.mapper.BorrowStatusMapper;
|
||||
@@ -8,4 +9,9 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class BorrowStatusServiceImpl extends ServiceImpl<BorrowStatusMapper, BorrowStatus> implements BorrowStatusService {
|
||||
@Override
|
||||
public BorrowStatus getByCode(String borrowStatusCode) {
|
||||
return this.getOne(Wrappers.lambdaQuery(BorrowStatus.class).eq(BorrowStatus::getBorrowCode, borrowStatusCode)
|
||||
.last("limit 1"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.bashi.dk.mapper.BorrowMapper">
|
||||
<select id="pageAdmin" resultType="com.bashi.dk.dto.admin.resp.BorrowResp">
|
||||
select t1.*,t2.phone_number as customer_login_name
|
||||
select t1.*,t2.phone_number as customer_login_name,
|
||||
ifnull(t3.withdraw_flag,1) as withdraw_flag
|
||||
from dk_borrow t1
|
||||
left join dk_customer t2 on t1.customer_id = t2.id
|
||||
left join dk_borrow_status t3 on t1.borrow_status_id = t3.id
|
||||
<where>
|
||||
<if test="bo.tradeNo != null and bo.tradeNo != ''">
|
||||
and t1.trade_no = #{bo.tradeNo}
|
||||
|
||||
9
doc/v2.0/v2.0.sql
Normal file
9
doc/v2.0/v2.0.sql
Normal file
@@ -0,0 +1,9 @@
|
||||
ALTER TABLE `dk_borrow`
|
||||
ADD COLUMN `borrow_status_id` bigint(20) NULL COMMENT '借款编码' AFTER `borrow_name`;
|
||||
|
||||
ALTER TABLE `dk_borrow_status`
|
||||
ADD COLUMN `borrow_code` varchar(60) NULL COMMENT '借款编码' AFTER `used_remit`,
|
||||
ADD COLUMN `withdraw_flag` tinyint(1) NOT NULL DEFAULT 1 COMMENT '是否允许提现' AFTER `borrow_code`;
|
||||
|
||||
ALTER TABLE `dk_customer`
|
||||
ADD COLUMN `create_time` datetime NOT NULL DEFAULT now() COMMENT '新增时间' AFTER `update_time`;
|
||||
Reference in New Issue
Block a user