Commit a553f1ce by BruceLu

加入專案檔案。

parent 26682177

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32901.215
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CaliBetManagementSystem", "CaliBetManagementSystem\CaliBetManagementSystem.csproj", "{B7B81EE0-CEA9-4ED3-A01B-982F648A2AD4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B7B81EE0-CEA9-4ED3-A01B-982F648A2AD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B7B81EE0-CEA9-4ED3-A01B-982F648A2AD4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B7B81EE0-CEA9-4ED3-A01B-982F648A2AD4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B7B81EE0-CEA9-4ED3-A01B-982F648A2AD4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D3803A91-ACE0-4844-8364-B81270F1C37C}
EndGlobalSection
EndGlobal
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
</Project>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CaliBetManagementSystem
{
public static class MD5Extensions
{
public static string ToMD5(this string password,string username)
{
using (var cryptoMD5 = System.Security.Cryptography.MD5.Create())
{
var bytes = Encoding.UTF8.GetBytes(password + "{"+ username + "}");
var hash = cryptoMD5.ComputeHash(bytes);
var md5 = BitConverter.ToString(hash).Replace("-", String.Empty).ToLower();
return md5;
}
}
}
}
using System.Text;
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using CaliBetManagementSystem;
internal class Program
{
private static void Main(string[] args)
{
HtmlHandler htmlHandler = new HtmlHandler();
while (true)
{
Console.WriteLine("請輸入帳號:");
string account = Console.ReadLine();
Console.WriteLine("請輸入密碼:");
string password = Console.ReadLine();
if (htmlHandler.Login(account, password))
{
//依序輸入
//1.檢索開始時間
//2.檢索結束時間
//3.頁數
//4.每頁資料數量
htmlHandler.GetWinLoss(new DateTime(2023, 7, 1, 12, 0, 0), new DateTime(2023, 8, 1, 12, 0, 0), 1, 100);
Console.ReadLine();
}
}
}
public class HtmlHandler
{
private string? _accessToken;
private HttpClient _httpClient;
private string _username;
private string _password;
private string _agentID;
public HtmlHandler()
{
var handler = new HttpClientHandler();
handler.ClientCertificateOptions = ClientCertificateOption.Manual;
handler.ServerCertificateCustomValidationCallback =
(httpRequestMessage, cert, cetChain, policyErrors) =>
{
return true;
};
_httpClient = new HttpClient();
}
/// <summary>
/// 登入方法
/// </summary>
/// <param name="username">帳號</param>
/// <param name="password">密碼</param>
public bool Login(string username, string password)
{
JObject jObject = new JObject();
jObject["username"] = _username = username;
jObject["password"] = _password = password.ToMD5(username);
jObject["refer"] = "https://ams.cali9999.net/";
var res = _httpClient.PostAsync($"https://ams.cali9999.net/service/auth?t={DateTime.Now.Millisecond}", new StringContent(JsonConvert.SerializeObject(jObject), Encoding.UTF8, "application/json")).Result;
if (res.IsSuccessStatusCode)
{
var content = JsonConvert.DeserializeObject<JObject>(res.Content.ReadAsStringAsync().Result);
if (content is not null)
{
Console.WriteLine(content["messages"].ToString());
//登入成功
if (content["resultCode"] is not null && (int)content["resultCode"] == 0)
{
//設定accesstoken
_accessToken = content["data"]["token"].ToString();
_httpClient.DefaultRequestHeaders.Add("X-Token", $"{_accessToken}");
//獲取agentID
res = _httpClient.GetAsync($"https://ams.cali9999.net/service/operator?t={DateTime.Now.Millisecond}").Result;
content = JsonConvert.DeserializeObject<JObject>(res.Content.ReadAsStringAsync().Result);
if (content is not null)
{
_agentID = content["data"]["agentId"].ToString();
}
return true;
}
return false;
}
}
return false;
}
/// <summary>
/// 代理輸贏報表方法
/// </summary>
/// <param name="startTime">檢索的開始時間</param>
/// <param name="endTime">檢索的結束時間</param>
/// <param name="pageNum">頁數,與下面數值相關聯</param>
/// <param name="numPerPage">每頁多少資料,與上面數值相關聯</param>
public void GetWinLoss(DateTime startTime, DateTime endTime, int pageNum, int numPerPage)
{
//獲取總輸贏報表資訊
var res = _httpClient.GetAsync($"https://ams.cali9999.com/service/reports/profit/{_agentID}/summary?t={DateTime.Now.Millisecond}&agentId={_agentID}&startTime={((DateTimeOffset)startTime).ToUnixTimeMilliseconds()}&endTime={((DateTimeOffset)endTime).ToUnixTimeMilliseconds()}&page.numPerPage={numPerPage}&page.pageNum={pageNum}").Result;
if (res.IsSuccessStatusCode)
{
var totalContent = JsonConvert.DeserializeObject<JObject>(res.Content.ReadAsStringAsync().Result);
//判斷token有沒有過期
if (totalContent["resultCode"] is not null && (int)totalContent["resultCode"] != 0)
{
Login(_username, _password);
GetWinLoss(startTime, endTime, pageNum, numPerPage);
return;
}
var info = totalContent["data"]["total"].ToObject<WinLossSummary>();
Console.WriteLine($"投注金額:{info.BetAmount} 輸贏:{info.WinOrLossAmount} 有效投注:{info.RebateAmount} 洗碼佣金{info.RebateCommission} 總金額:{info.TotalAmount} 交上線:{info.ActualSettlement} 交上線有效投注:{info.RebateToSuperior}");
}
//獲取個別代理資訊
res = _httpClient.GetAsync($"https://ams.cali9999.net/service/v2/reports/profit/34961/subagents?t={DateTime.Now.Millisecond}&agentId={_agentID}&startTime={((DateTimeOffset)startTime).ToUnixTimeMilliseconds()}&endTime={((DateTimeOffset)endTime).ToUnixTimeMilliseconds()}&page.numPerPage={numPerPage}&page.pageNum={pageNum}").Result;
if (res.IsSuccessStatusCode)
{
var agentContent = JsonConvert.DeserializeObject<JObject>(res.Content.ReadAsStringAsync().Result);
//判斷token有沒有過期
if (agentContent["resultCode"] is not null && (int)agentContent["resultCode"] != 0)
{
Login(_username, _password);
GetWinLoss(startTime, endTime, pageNum, numPerPage);
return;
}
foreach (var item in agentContent["data"]["agentDetails"]["groups"])
{
//名稱詳見類別WinLossMember
var info = item["agents"][0]["total"].ToObject<WinLossAgent>();
Console.WriteLine($"名稱:{item["agents"][0]["agent"]["userName"].ToString()} 投注金額:{info.BetAmount} 輸贏:{info.TotalAmount} 有效投注:{info.RebateAmount} 洗碼佣金:{info.RebateCommission} 總金額:{info.TotalAmount} 交上線:{info.ActualSettlement} 交上線有效投注:{info.RebateToSuperior}");
}
}
}
}
}
\ No newline at end of file
using Newtonsoft.Json.Converters;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CaliBetManagementSystem
{
public class WinLossAgent
{
[JsonProperty("agentId")]
public object AgentId { get; set; }
[JsonProperty("detailType", NullValueHandling = NullValueHandling.Ignore)]
public long? DetailType { get; set; }
/// <summary>
/// 投注金額
/// </summary>
[JsonProperty("betAmount", NullValueHandling = NullValueHandling.Ignore)]
public long? BetAmount { get; set; }
/// <summary>
/// 輸贏
/// </summary>
[JsonProperty("winOrLossAmount", NullValueHandling = NullValueHandling.Ignore)]
public long? WinOrLossAmount { get; set; }
/// <summary>
/// 有效投注
/// </summary>
[JsonProperty("rebateAmount", NullValueHandling = NullValueHandling.Ignore)]
public long? RebateAmount { get; set; }
[JsonProperty("rebate")]
public object Rebate { get; set; }
/// <summary>
/// 洗碼佣金
/// </summary>
[JsonProperty("rebateCommission", NullValueHandling = NullValueHandling.Ignore)]
public long? RebateCommission { get; set; }
/// <summary>
/// 總金額
/// </summary>
[JsonProperty("totalAmount", NullValueHandling = NullValueHandling.Ignore)]
public long? TotalAmount { get; set; }
[JsonProperty("share")]
public object Share { get; set; }
/// <summary>
/// 交上線有效投注
/// </summary>
[JsonProperty("rebateToSuperior", NullValueHandling = NullValueHandling.Ignore)]
public long? RebateToSuperior { get; set; }
/// <summary>
/// 交上線
/// </summary>
[JsonProperty("actualSettlement", NullValueHandling = NullValueHandling.Ignore)]
public long? ActualSettlement { get; set; }
[JsonProperty("profit")]
public object Profit { get; set; }
[JsonProperty("exchangeRate")]
public object ExchangeRate { get; set; }
[JsonProperty("currencyUnit", NullValueHandling = NullValueHandling.Ignore)]
public string CurrencyUnit { get; set; }
}
}
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CaliBetManagementSystem
{
public class WinLossSummary
{
[JsonProperty("agentId")]
public object AgentId { get; set; }
[JsonProperty("detailType", NullValueHandling = NullValueHandling.Ignore)]
public long? DetailType { get; set; }
/// <summary>
/// 投注金額
/// </summary>
[JsonProperty("betAmount", NullValueHandling = NullValueHandling.Ignore)]
public long? BetAmount { get; set; }
/// <summary>
/// 輸贏
/// </summary>
[JsonProperty("winOrLossAmount", NullValueHandling = NullValueHandling.Ignore)]
public long? WinOrLossAmount { get; set; }
/// <summary>
/// 有效投注
/// </summary>
[JsonProperty("rebateAmount", NullValueHandling = NullValueHandling.Ignore)]
public long? RebateAmount { get; set; }
[JsonProperty("rebate")]
public decimal? Rebate { get; set; }
/// <summary>
/// 洗碼佣金
/// </summary>
[JsonProperty("rebateCommission", NullValueHandling = NullValueHandling.Ignore)]
public decimal? RebateCommission { get; set; }
/// <summary>
/// 總金額
/// </summary>
[JsonProperty("totalAmount", NullValueHandling = NullValueHandling.Ignore)]
public decimal? TotalAmount { get; set; }
[JsonProperty("share")]
public long? Share { get; set; }
/// <summary>
/// 交上線有效投注
/// </summary>
[JsonProperty("rebateToSuperior", NullValueHandling = NullValueHandling.Ignore)]
public long? RebateToSuperior { get; set; }
/// <summary>
/// 交上線
/// </summary>
[JsonProperty("actualSettlement", NullValueHandling = NullValueHandling.Ignore)]
public decimal? ActualSettlement { get; set; }
/// <summary>
/// 我的盈利
/// </summary>
[JsonProperty("profit")]
public decimal? Profit { get; set; }
[JsonProperty("exchangeRate")]
public decimal? ExchangeRate { get; set; }
[JsonProperty("currencyUnit")]
public string CurrencyUnit { get; set; }
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment