98 lines
3.1 KiB
C#
98 lines
3.1 KiB
C#
using Newtonsoft.Json;
|
||
using System;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using System.Threading.Tasks;
|
||
using UnityEngine;
|
||
|
||
//5.2.5查询结算
|
||
public class queryKnightBetResult525 : MonoBehaviour
|
||
{
|
||
//返回的(解析后)
|
||
public KnightBetResult knightBetResult;//===========================================================================================
|
||
|
||
|
||
|
||
public async Task<KnightBetResult> queryKnightBetResult(int KnightId) //
|
||
{
|
||
// 准备请求的头部信息,包含授权令牌
|
||
Dictionary<string, string> head525 = new Dictionary<string, string>
|
||
{
|
||
{ "Authorization", Global.global.serverResponse.data.token }
|
||
};
|
||
|
||
// 请求体
|
||
QueryKnightRoomListBody queryKnightRoomListBody = new QueryKnightRoomListBody
|
||
{
|
||
userId = Global.global.serverResponse.data.userId,
|
||
knightId = KnightId
|
||
};
|
||
Debug.Log("525接收的=========================" + KnightId);
|
||
// 异步发送请求
|
||
//string response525 = await web.SendRequest(web.URL + "/snail/gameKnight/queryUserBetResult", "POST", JsonUtility.ToJson(queryKnightRoomListBody), head525);
|
||
string response525 = await web.SendRequest(web.URL + "/snail/gameKnight/queryUserBetResult", "POST", JsonConvert.SerializeObject(queryKnightRoomListBody), head525);
|
||
|
||
// 调试输出接收到的响应
|
||
Debug.Log("5.2.5查询骑士结算:======== " + response525);
|
||
|
||
// 将响应反序列化为 KnightRoomList 对象
|
||
try
|
||
{
|
||
knightBetResult = JsonConvert.DeserializeObject<KnightBetResult>(response525);
|
||
if (knightBetResult != null && knightBetResult.data != null)//==================================================访问之前先判空,未到或已过时间,data[]为空
|
||
{
|
||
Debug.Log(knightBetResult.data[0].updateTime + "=525=8=======D");
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
Debug.LogError("反序列化响应失败: " + ex.Message);
|
||
}
|
||
|
||
// 返回解析后的 对象
|
||
return knightBetResult;
|
||
}
|
||
}
|
||
//==========525====================================================
|
||
[Serializable]
|
||
public class KnightBetResult : Response
|
||
{
|
||
public List<KnightBetResultData> data;
|
||
|
||
[Serializable]
|
||
public class KnightBetResultData
|
||
{
|
||
public int id;
|
||
public string gameNo;
|
||
public int knightId;
|
||
public int userId;
|
||
public float bet;
|
||
public int horseNo;
|
||
public int outcome;
|
||
public float win;
|
||
public float beansCoin;
|
||
public float ichorCoin;
|
||
public string createTime;
|
||
public string updateTime;
|
||
}
|
||
}
|
||
//{
|
||
// "code": 200,
|
||
// "message": "请求成功",
|
||
// "data": [
|
||
// {
|
||
// "id": 2706972,
|
||
// "gameNo": "202412041130",
|
||
// "knightId": 54695,
|
||
// "userId": 112,
|
||
// "bet": 50,
|
||
// "horseNo": 1,
|
||
// "outcome": 2,
|
||
// "win": 1,
|
||
// "beansCoin": 0,
|
||
// "ichorCoin": 5,
|
||
// "createTime": null,
|
||
// "updateTime": "2024-12-04 11:31:49"
|
||
// }
|
||
// ]
|
||
//} |