feat: 对接银行模块接口,即将上线功能
This commit is contained in:
@@ -0,0 +1,45 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Volo.Abp.Application.Dtos;
|
||||||
|
using Yi.Framework.Bbs.Domain.Shared.Enums;
|
||||||
|
|
||||||
|
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Bank
|
||||||
|
{
|
||||||
|
public class BankCardDto:EntityDto<Guid>
|
||||||
|
{
|
||||||
|
|
||||||
|
public DateTime? LastDepositTime { get; set; }
|
||||||
|
public DateTime CreationTime { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用户id
|
||||||
|
/// </summary>
|
||||||
|
public Guid UserId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 当前存储的钱
|
||||||
|
/// </summary>
|
||||||
|
public decimal StorageMoney { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 最大可存储的钱钱
|
||||||
|
/// </summary>
|
||||||
|
public decimal MaxStorageMoney { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 满期限时间,可空
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? Fullterm { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 银行卡状态
|
||||||
|
/// </summary>
|
||||||
|
public BankCardStateEnum BankCardState { get; set; } = BankCardStateEnum.Unused;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Volo.Abp.Application.Dtos;
|
||||||
|
|
||||||
|
namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Bank
|
||||||
|
{
|
||||||
|
public class InterestRecordsDto : EntityDto<Guid>
|
||||||
|
{
|
||||||
|
public DateTime CreationTime { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 当前汇率值
|
||||||
|
/// </summary>
|
||||||
|
public decimal Value { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否波动期
|
||||||
|
/// </summary>
|
||||||
|
public bool IsFluctuate { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,20 +1,51 @@
|
|||||||
using System;
|
using Mapster;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Volo.Abp.Application.Services;
|
using Volo.Abp.Application.Services;
|
||||||
|
using Yi.Framework.Bbs.Application.Contracts.Dtos.Bank;
|
||||||
|
using Yi.Framework.Bbs.Domain.Entities.Bank;
|
||||||
using Yi.Framework.Bbs.Domain.Managers;
|
using Yi.Framework.Bbs.Domain.Managers;
|
||||||
|
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||||
|
|
||||||
namespace Yi.Framework.Bbs.Application.Services.Bank
|
namespace Yi.Framework.Bbs.Application.Services.Bank
|
||||||
{
|
{
|
||||||
public class BankService : ApplicationService
|
public class BankService : ApplicationService
|
||||||
{
|
{
|
||||||
private BankManager _bankManager;
|
private BankManager _bankManager;
|
||||||
public BankService(BankManager bankManager)
|
private BbsUserManager _bbsUserManager;
|
||||||
|
private ISqlSugarRepository<BankCardEntity, Guid> _repository;
|
||||||
|
private ISqlSugarRepository<InterestRecordsEntity, Guid> _interestRepository;
|
||||||
|
public BankService(BankManager bankManager, BbsUserManager userManager, ISqlSugarRepository<BankCardEntity, Guid> repository, ISqlSugarRepository<InterestRecordsEntity, Guid> interestRepository)
|
||||||
{
|
{
|
||||||
_bankManager = bankManager;
|
_bankManager = bankManager;
|
||||||
|
_bbsUserManager = userManager;
|
||||||
|
_repository = repository;
|
||||||
|
_interestRepository = interestRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取最近24小时汇率记录
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("bank/interest")]
|
||||||
|
public async Task<List<InterestRecordsDto>> GetInterestRecordsAsync()
|
||||||
|
{
|
||||||
|
var entities = await _interestRepository._DbQueryable.OrderByDescending(x => x.CreationTime).ToPageListAsync(1, 24);
|
||||||
|
var output = entities.Adapt<List<InterestRecordsDto>>();
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取登录用户全部银行卡信息
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[Authorize]
|
||||||
|
[HttpGet("bank")]
|
||||||
|
public async Task<List<BankCardDto>> GetBankCardListAsync()
|
||||||
|
{
|
||||||
|
var entities = await _repository.GetListAsync(x => x.UserId == CurrentUser.Id);
|
||||||
|
var output = entities.Adapt<List<BankCardDto>>();
|
||||||
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -22,9 +53,21 @@ namespace Yi.Framework.Bbs.Application.Services.Bank
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public Task ApplyingBankCardAsync()
|
[HttpPost("bank/applying")]
|
||||||
|
public async Task ApplyingBankCardAsync()
|
||||||
{
|
{
|
||||||
return _bankManager.ApplyingBankCardAsync(CurrentUser.Id.Value);
|
var userInfo = await _bbsUserManager.GetBbsUserInfoAsync(CurrentUser.Id!.Value);
|
||||||
|
var banCardNum = await _repository.CountAsync(x => x.UserId == CurrentUser.Id!.Value);
|
||||||
|
|
||||||
|
var diffNum = userInfo.Level - banCardNum;
|
||||||
|
if (diffNum <= 0)
|
||||||
|
{
|
||||||
|
throw new UserFriendlyException($"申请失败,当前等级-【{userInfo.Level}】,最多可申领-【{userInfo.Level}】张银行卡,目前已拥有-【{banCardNum}】,请提升你的等级信誉,行长会考虑的");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await _bankManager.ApplyingBankCardAsync(CurrentUser.Id.Value, diffNum);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -33,6 +76,7 @@ namespace Yi.Framework.Bbs.Application.Services.Bank
|
|||||||
/// <param name="cardId"></param>
|
/// <param name="cardId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[Authorize]
|
[Authorize]
|
||||||
|
[HttpPut("bank/draw/{cardId}")]
|
||||||
public Task DrawMoneyAsync(Guid cardId)
|
public Task DrawMoneyAsync(Guid cardId)
|
||||||
{
|
{
|
||||||
return _bankManager.DrawMoneyAsync(cardId);
|
return _bankManager.DrawMoneyAsync(cardId);
|
||||||
@@ -40,12 +84,24 @@ namespace Yi.Framework.Bbs.Application.Services.Bank
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 给银行卡存款
|
/// 给银行卡存款
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="CardId"></param>
|
/// <param name="cardId"></param>
|
||||||
/// <param name="moneyNum"></param>
|
/// <param name="moneyNum"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Task DepositAsync(Guid CardId, decimal moneyNum)
|
[Authorize]
|
||||||
|
[HttpPut("bank/deposit/{cardId}/{moneyNum}")]
|
||||||
|
public async Task DepositAsync(Guid cardId, decimal moneyNum)
|
||||||
{
|
{
|
||||||
return _bankManager.DepositAsync(CardId, moneyNum);
|
if (moneyNum < 50)
|
||||||
|
{
|
||||||
|
throw new UserFriendlyException("存款金额不能小于50");
|
||||||
|
}
|
||||||
|
var userInfo = await _bbsUserManager.GetBbsUserInfoAsync(CurrentUser.Id!.Value);
|
||||||
|
if (userInfo.Money < moneyNum)
|
||||||
|
{
|
||||||
|
throw new UserFriendlyException("存钱失败!你的钱钱不足,再存进去,就负数啦~");
|
||||||
|
}
|
||||||
|
|
||||||
|
await _bankManager.DepositAsync(cardId, moneyNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ namespace Yi.Framework.Bbs.Domain.Shared.Etos
|
|||||||
{
|
{
|
||||||
public class MoneyChangeEventArgs
|
public class MoneyChangeEventArgs
|
||||||
{
|
{
|
||||||
|
public MoneyChangeEventArgs() { }
|
||||||
|
public MoneyChangeEventArgs(Guid userId, decimal changeNumber) { UserId = userId; Number = changeNumber; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 用户id
|
/// 用户id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -16,10 +16,28 @@ namespace Yi.Framework.Bbs.Domain.Entities.Bank
|
|||||||
[SugarTable("BankCard")]
|
[SugarTable("BankCard")]
|
||||||
public class BankCardEntity : Entity<Guid>, IHasCreationTime
|
public class BankCardEntity : Entity<Guid>, IHasCreationTime
|
||||||
{
|
{
|
||||||
|
public BankCardEntity()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public BankCardEntity(Guid userId)
|
||||||
|
{
|
||||||
|
this.UserId = userId;
|
||||||
|
}
|
||||||
[SugarColumn(ColumnName = "Id", IsPrimaryKey = true)]
|
[SugarColumn(ColumnName = "Id", IsPrimaryKey = true)]
|
||||||
public override Guid Id { get; protected set; }
|
public override Guid Id { get; protected set; }
|
||||||
public DateTime CreationTime { get; set; }
|
public DateTime CreationTime { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 上一次存款日期
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? LastDepositTime { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 上一次取款日期
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? LastDrawTime { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 用户id
|
/// 用户id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -40,16 +58,44 @@ namespace Yi.Framework.Bbs.Domain.Entities.Bank
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 满期限时间,可空
|
/// 满期限时间,可空
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime? Fullterm { get; set; }
|
public DateTime? FulltermTime { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 银行卡状态
|
/// 银行卡状态
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BankCardStateEnum BankCardState { get; set; } = BankCardStateEnum.Unused;
|
public BankCardStateEnum BankCardState { get; set; } = BankCardStateEnum.Unused;
|
||||||
|
|
||||||
|
public bool IsStorageFull()
|
||||||
|
{
|
||||||
|
if (FulltermTime is null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return DateTime.Now >= FulltermTime;
|
||||||
|
}
|
||||||
|
public void SetDrawMoney()
|
||||||
|
{
|
||||||
|
this.BankCardState = BankCardStateEnum.Unused;
|
||||||
|
|
||||||
|
LastDrawTime = DateTime.Now;
|
||||||
|
this.FulltermTime = null;
|
||||||
|
this.StorageMoney = 0;
|
||||||
|
}
|
||||||
|
public void SetStorageMoney(decimal storageMoney)
|
||||||
|
{
|
||||||
|
if (storageMoney > MaxStorageMoney)
|
||||||
|
{
|
||||||
|
throw new UserFriendlyException($"存款数不能大于该卡的上限-【{MaxStorageMoney}】钱钱");
|
||||||
|
}
|
||||||
|
|
||||||
|
StorageMoney = storageMoney;
|
||||||
|
|
||||||
|
LastDepositTime = DateTime.Now;
|
||||||
|
FulltermTime = LastDepositTime + TimeSpan.FromDays(3);
|
||||||
|
this.BankCardState = BankCardStateEnum.Wait;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ namespace Yi.Framework.Bbs.Domain.Entities.Bank
|
|||||||
public InterestRecordsEntity(decimal inputValue, bool isFluctuate, decimal oldValue = 0)
|
public InterestRecordsEntity(decimal inputValue, bool isFluctuate, decimal oldValue = 0)
|
||||||
{
|
{
|
||||||
//这里写好根据数据的值,以及是否要波动期,进行得出真是利息
|
//这里写好根据数据的值,以及是否要波动期,进行得出真是利息
|
||||||
|
//有了老值和新值,我们可以根据这个变化程度去做一个涨幅或跌幅,Todo
|
||||||
|
Value=inputValue;
|
||||||
}
|
}
|
||||||
[SugarColumn(ColumnName = "Id", IsPrimaryKey = true)]
|
[SugarColumn(ColumnName = "Id", IsPrimaryKey = true)]
|
||||||
public override Guid Id { get; protected set; }
|
public override Guid Id { get; protected set; }
|
||||||
|
|||||||
@@ -1,13 +1,31 @@
|
|||||||
using Volo.Abp.Domain.Services;
|
using Volo.Abp.Domain.Services;
|
||||||
|
using Volo.Abp.EventBus.Local;
|
||||||
using Yi.Framework.Bbs.Domain.Entities.Bank;
|
using Yi.Framework.Bbs.Domain.Entities.Bank;
|
||||||
|
using Yi.Framework.Bbs.Domain.Shared.Enums;
|
||||||
|
using Yi.Framework.Bbs.Domain.Shared.Etos;
|
||||||
|
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||||
|
|
||||||
namespace Yi.Framework.Bbs.Domain.Managers
|
namespace Yi.Framework.Bbs.Domain.Managers
|
||||||
{
|
{
|
||||||
public class BankManager : DomainService
|
public class BankManager : DomainService
|
||||||
{
|
{
|
||||||
|
private ISqlSugarRepository<BankCardEntity> _repository;
|
||||||
|
private ILocalEventBus _localEventBus;
|
||||||
|
private ISqlSugarRepository<InterestRecordsEntity> _interestRepository;
|
||||||
|
public BankManager(ISqlSugarRepository<BankCardEntity> repository, ILocalEventBus localEventBus, ISqlSugarRepository<InterestRecordsEntity> interestRepository)
|
||||||
|
{
|
||||||
|
_repository = repository;
|
||||||
|
_localEventBus = localEventBus;
|
||||||
|
_interestRepository = interestRepository;
|
||||||
|
}
|
||||||
|
|
||||||
public BankManager() { }
|
public decimal CurrentInterestRate => GetCurrentInterestRate();
|
||||||
|
private decimal GetCurrentInterestRate()
|
||||||
|
{
|
||||||
|
//先判断时间是否与当前时间差1小时,小于1小时直接返回即可,可以由一个单例类提供
|
||||||
|
GetThirdPartyValue();
|
||||||
|
return 1.30m;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取第三方的值
|
/// 获取第三方的值
|
||||||
@@ -22,39 +40,96 @@ namespace Yi.Framework.Bbs.Domain.Managers
|
|||||||
/// 创建一个记录
|
/// 创建一个记录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public InterestRecordsEntity CreateInterestRecords()
|
public async Task<InterestRecordsEntity> CreateInterestRecordsAsync()
|
||||||
{
|
{
|
||||||
return new InterestRecordsEntity();
|
//获取最新的实体
|
||||||
|
var newEntity = await _interestRepository._DbQueryable.OrderByDescending(x => x.CreationTime).FirstAsync();
|
||||||
|
decimal oldValue = 1.3m;
|
||||||
|
if (newEntity is not null)
|
||||||
|
{
|
||||||
|
oldValue = newEntity.Value;
|
||||||
|
}
|
||||||
|
var currentValue = GetThirdPartyValue();
|
||||||
|
var entity = new InterestRecordsEntity(currentValue, false, oldValue);
|
||||||
|
var output = await _interestRepository.InsertReturnEntityAsync(entity);
|
||||||
|
|
||||||
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 给用户申请银行卡
|
/// 给用户申请银行卡
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Task ApplyingBankCardAsync(Guid userId)
|
public async Task ApplyingBankCardAsync(Guid userId, int cardNumber)
|
||||||
{
|
{
|
||||||
return Task.CompletedTask;
|
var entities = Enumerable.Range(1, cardNumber).Select(x => new BankCardEntity(userId)).ToList();
|
||||||
|
await _repository.InsertManyAsync(entities);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 给银行卡提款
|
/// 进行银行卡提款
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="CardId"></param>
|
/// <param name="cardId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Task DrawMoneyAsync(Guid CardId)
|
public async Task DrawMoneyAsync(Guid cardId)
|
||||||
{
|
{
|
||||||
return Task.CompletedTask;
|
var entity = await _repository.GetByIdAsync(cardId);
|
||||||
|
if (entity.BankCardState == BankCardStateEnum.Unused)
|
||||||
|
{
|
||||||
|
throw new UserFriendlyException("当前银行卡状态不能提款");
|
||||||
|
}
|
||||||
|
|
||||||
|
//这里其实不存在这个状态,只有等待状态,不需要去主动触发,前端判断即可
|
||||||
|
if (entity.BankCardState == BankCardStateEnum.Full)
|
||||||
|
{
|
||||||
|
throw new UserFriendlyException("当前银行卡状态不能存款");
|
||||||
|
}
|
||||||
|
|
||||||
|
//可以提款
|
||||||
|
if (entity.BankCardState == BankCardStateEnum.Wait)
|
||||||
|
{
|
||||||
|
decimal changeMoney = 0;
|
||||||
|
//判断是否存满时间
|
||||||
|
if (entity.IsStorageFull())
|
||||||
|
{
|
||||||
|
changeMoney = this.CurrentInterestRate * entity.StorageMoney;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
changeMoney = entity.StorageMoney;
|
||||||
|
}
|
||||||
|
|
||||||
|
//提款
|
||||||
|
entity.SetDrawMoney();
|
||||||
|
await _repository.UpdateAsync(entity);
|
||||||
|
|
||||||
|
//打钱,该卡状态钱更新,并提款加到用户钱钱里
|
||||||
|
await _localEventBus.PublishAsync(new MoneyChangeEventArgs(entity.UserId, changeMoney));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 给银行卡存款
|
/// 给银行卡存款
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="CardId"></param>
|
/// <param name="cardId"></param>
|
||||||
/// <param name="moneyNum"></param>
|
/// <param name="moneyNum"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Task DepositAsync(Guid CardId, decimal moneyNum)
|
public async Task DepositAsync(Guid cardId, decimal moneyNum)
|
||||||
{
|
{
|
||||||
return Task.CompletedTask;
|
var entity = await _repository.GetByIdAsync(cardId);
|
||||||
|
if (entity.BankCardState != BankCardStateEnum.Unused)
|
||||||
|
{
|
||||||
|
throw new UserFriendlyException("当前银行卡状态不能存款");
|
||||||
|
}
|
||||||
|
//存款
|
||||||
|
entity.SetStorageMoney(moneyNum);
|
||||||
|
|
||||||
|
await _repository.UpdateAsync(entity);
|
||||||
|
await _localEventBus.PublishAsync(new MoneyChangeEventArgs(entity.UserId, -moneyNum));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
43
Yi.Bbs.Vue3/src/apis/bankApi.js
Normal file
43
Yi.Bbs.Vue3/src/apis/bankApi.js
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
import request from "@/config/axios/service";
|
||||||
|
|
||||||
|
//得到利息趋势
|
||||||
|
export function getInterestList() {
|
||||||
|
return request({
|
||||||
|
url: "/bank/interest",
|
||||||
|
method: "get"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 获取用户的银行卡
|
||||||
|
export function getBankCardList() {
|
||||||
|
return request({
|
||||||
|
url: "/bank",
|
||||||
|
method: "get",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 申请银行卡
|
||||||
|
export function applyingBankCard() {
|
||||||
|
return request({
|
||||||
|
url: "/bank/applying",
|
||||||
|
method: "post"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 提款
|
||||||
|
export function drawMoney(cardId) {
|
||||||
|
return request({
|
||||||
|
url: `/bank/draw/${cardId}`,
|
||||||
|
method: "put",
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 存款
|
||||||
|
export function delUser(cardId,moneyNum) {
|
||||||
|
return request({
|
||||||
|
url: `/bank/deposit/${cardId}/${moneyNum}`,
|
||||||
|
method: "put"
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -8,8 +8,7 @@ import piniaPluginPersistedstate from "pinia-plugin-persistedstate";
|
|||||||
import "element-plus/dist/index.css";
|
import "element-plus/dist/index.css";
|
||||||
import "./assets/main.css";
|
import "./assets/main.css";
|
||||||
import "@/assets/styles/index.scss"; // global css
|
import "@/assets/styles/index.scss"; // global css
|
||||||
import '@/assets/atom-one-dark.css'
|
|
||||||
import '@/assets/github-markdown.css'
|
|
||||||
|
|
||||||
import * as ElementPlusIconsVue from "@element-plus/icons-vue";
|
import * as ElementPlusIconsVue from "@element-plus/icons-vue";
|
||||||
import directive from "./directive"; // directive
|
import directive from "./directive"; // directive
|
||||||
|
|||||||
@@ -1,61 +1,90 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="bank-body">
|
<div class="bank-body">
|
||||||
<h2>小心谨慎选择银行机构,确保资金安全</h2>
|
<h2>小心谨慎选择银行机构,确保资金安全</h2>
|
||||||
<div>
|
<div>
|
||||||
<ExchangeRate :option="statisOptions" />
|
<ExchangeRate :option="statisOptions" />
|
||||||
<div class="div-show">
|
<div class="div-show">
|
||||||
<p class="p-rate">当前实时利息:<span>110%</span>(可获取投入的百分之110%的本金)</p>
|
<p class="p-rate">当前实时利息:<span>110%</span>(可获取投入的百分之110%的本金)</p>
|
||||||
<el-button type="primary"><el-icon><AddLocation /></el-icon>申领银行卡</el-button>
|
<el-button type="primary" @click="applying()"><el-icon>
|
||||||
</div>
|
<AddLocation />
|
||||||
</div>
|
</el-icon>申领银行卡</el-button>
|
||||||
<el-divider />
|
</div>
|
||||||
<div>
|
|
||||||
<el-row :gutter="20">
|
|
||||||
<el-col :span=8 v-for="i in 6">
|
|
||||||
<BankCard></BankCard>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<el-divider />
|
||||||
|
<div>
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<el-col :span=8 v-for="item in bankCardList">
|
||||||
|
<BankCard></BankCard>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import BankCard from "./components/BankCard.vue"
|
import BankCard from "./components/BankCard.vue"
|
||||||
import ExchangeRate from "./components/ExchangeRateChart.vue"
|
import ExchangeRate from "./components/ExchangeRateChart.vue"
|
||||||
import {computed, ref} from "vue";
|
import { getBankCardList, applyingBankCard, getInterestList } from '@/apis/bankApi'
|
||||||
const weekList=ref([]);
|
import useAuths from '@/hooks/useAuths.js';
|
||||||
const statisOptions = computed(() => {
|
import { computed, ref,onMounted } from "vue";
|
||||||
|
|
||||||
|
const { isLogin } = useAuths();
|
||||||
|
const bankCardList = ref([]);
|
||||||
|
|
||||||
|
const interestList=ref([]);
|
||||||
|
const refreshData = async () => {
|
||||||
|
|
||||||
|
if (isLogin) {
|
||||||
|
const {data} = await getBankCardList();
|
||||||
|
bankCardList.value=data;
|
||||||
|
}
|
||||||
|
|
||||||
|
const {data2:data} = await getInterestList();
|
||||||
|
interestList.value =data;
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
await refreshData();
|
||||||
|
})
|
||||||
|
const applying = async () => {
|
||||||
|
// await applyingBankCard();
|
||||||
|
//刷新一下
|
||||||
|
await refreshData();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const statisOptions = computed( () => {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
xAxis: {
|
xAxis: {
|
||||||
data: ['1时', '2时', '3时', '4时', '5时', '6时', '7时','1时', '2时', '3时', '4时', '5时', '6时', '7时','5时', '6时', '7时','1时', '2时', '3时', '4时', '5时', '6时', '7时']
|
data: ['1时', '2时', '3时', '4时', '5时', '6时', '7时', '1时', '2时', '3时', '4时', '5时', '6时', '7时', '5时', '6时', '7时', '1时', '2时', '3时', '4时', '5时', '6时', '7时']
|
||||||
},
|
},
|
||||||
series: {
|
series: {
|
||||||
data:[10, 6, 13, 11, 12, 12, 9,10, 11, 13, 11, 8, 14, 9,12, 12, 9,10, 11, 13, 11, 8, 14, 9]
|
data: [10, 6, 13, 11, 12, 12, 9, 10, 11, 13, 11, 8, 14, 9, 12, 12, 9, 10, 11, 13, 11, 8, 14, 9]
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.bank-body {
|
.bank-body {
|
||||||
padding: 20px 30px;
|
padding: 20px 30px;
|
||||||
}
|
}
|
||||||
|
|
||||||
h2 {
|
h2 {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
||||||
}
|
}
|
||||||
.div-show
|
|
||||||
{
|
.div-show {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
.p-rate
|
|
||||||
{
|
.p-rate {
|
||||||
span{
|
span {
|
||||||
font-weight:600;
|
font-weight: 600;
|
||||||
font-size: larger;
|
font-size: larger;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
Reference in New Issue
Block a user