Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复错误,并增加专栏投币功能与领取大会员经验的功能 #617

Merged
merged 15 commits into from
Dec 1, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
添加卡券状态查询相关api
Polaris-cn10086 committed Nov 26, 2023
commit bf70735bb3e62618a2c78936a856c209d6ff022a
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Collections.Generic;

namespace Ray.BiliBiliTool.Agent.BiliBiliAgent.Dtos.VipTask;

public class VouchersInfoResponse
{
public List<VouchersInfo> VouchersInfos { get; set; }
public bool IsShortVip { get; set; }
public bool IsFreightOpen { get; set; }
public int Level { get; set; }
public int CurExp { get; set; }
public int NextExp { get; set; }
public bool IsVip { get; set; }
public int IsSeniorMember { get; set; }
public int Format060102 { get; set; }
}


public class VouchersInfo
{
public int Type { get; set; }
public int State { get; set; }
public int ExpireTime { get; set; }
public int VipType { get; set; }
public int NextReceiveDays { get; set; }
public int PeriodEndUnix { get; set; }
}

Original file line number Diff line number Diff line change
@@ -31,5 +31,8 @@ public interface IVipBigPointApi

[HttpPost("/pgc/activity/deliver/task/complete")]
Task<BiliApiResponse> ViewComplete([FormContent] ViewRequest request);

[HttpGet("/x/vip/privilege/my")]
Task<BiliApiResponse<VouchersInfoResponse>> GetVouchersInfo();
}
}
3 changes: 3 additions & 0 deletions src/Ray.BiliBiliTool.Application/DailyTaskAppService.cs
Original file line number Diff line number Diff line change
@@ -95,6 +95,9 @@ public override async Task DoTaskAsync(CancellationToken cancellationToken)
await ReceiveVipPrivilege(userInfo);
await ReceiveMangaVipReward(userInfo);

//TODO 大会员领经验


await Charge(userInfo);
}

34 changes: 32 additions & 2 deletions src/Ray.BiliBiliTool.Application/VipBigPointAppService.cs
Original file line number Diff line number Diff line change
@@ -19,20 +19,50 @@ public class VipBigPointAppService : AppService, IVipBigPointAppService
private readonly IConfiguration _configuration;
private readonly IVipBigPointApi _vipApi;
private readonly IAccountDomainService _loginDomainService;
private readonly IVideoDomainService _videoDomainService;

public VipBigPointAppService(
IConfiguration configuration,
ILogger<VipBigPointAppService> logger,
IVipBigPointApi vipApi,
IAccountDomainService loginDomainService
)
IAccountDomainService loginDomainService,
IVideoDomainService videoDomainService)
{
_configuration = configuration;
_logger = logger;
_vipApi = vipApi;
_loginDomainService = loginDomainService;
_videoDomainService = videoDomainService;
}

// 临时测试函数
public async Task Info()
{
var re = await _vipApi.GetVouchersInfo();
if (re.Code == 0)
{
var state = re.Data.list.Find(x => x.Type == 9).State;

switch (state)
{
case 2:
_logger.LogInformation("未完成");
// 未观看视频,观看和分享视频为第一个执行的每日任务,如果认为观看,就直接抛弃此任务
break;
case 1:
_logger.LogInformation("已兑换");
break;
case 0:
_logger.LogInformation("未兑换");
// TODO 兑换api
break;
}

}

}


[TaskInterceptor("大会员大积分", TaskLevel.One)]
public override async Task DoTaskAsync(CancellationToken cancellationToken)
{
41 changes: 41 additions & 0 deletions test/BiliAgentTest/VipApiTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System.Threading.Tasks;
using Xunit;
using Microsoft.Extensions.DependencyInjection;
using Ray.BiliBiliTool.Agent;
using Ray.BiliBiliTool.Console;
using Ray.BiliBiliTool.Infrastructure;
using Ray.BiliBiliTool.Agent.BiliBiliAgent.Interfaces;
using Xunit.Abstractions;
namespace BiliAgentTest;

public class VipApiTest
{
private readonly ITestOutputHelper _output;
public VipApiTest(ITestOutputHelper output)
{
_output = output;
Program.CreateHost(new[] { "--ENVIRONMENT=Development" });
}

[Fact]
public async Task VipInfoTest()
{
using var scope = Global.ServiceProviderRoot.CreateScope();

var ck = scope.ServiceProvider.GetRequiredService<BiliCookie>();
var api = scope.ServiceProvider.GetRequiredService<IVipBigPointApi>();
var re = await api.GetVouchersInfo();
if (re.Code == 0)
{
var info = re.Data.list.Find(x => x.Type == 9);
if (info != null)
{
_output.WriteLine(info.State.ToString());
}
else
{
_output.WriteLine("error");
}
}
}
}