10.*蜗牛矿场接口

This commit is contained in:
HuangZiBo 2024-12-02 17:51:28 +08:00
parent 210edf9a4d
commit ce9392a015
19 changed files with 609 additions and 0 deletions

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 42fa19d4f4852ea47975d89b06e107d8
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,40 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class KuangChangTest : MonoBehaviour
{
queryMiningContractList101 queryMiningContractList = new queryMiningContractList101();//10.110.1,查询可购买的挖矿合约
queryMiningContracDetail102 queryMiningContracDetail = new queryMiningContracDetail102();//10.2
MiningContracDetail miningContracDetail = new MiningContracDetail();
buyMiningContract103 buyMiningContract = new buyMiningContract103();//10.3
queryUserMiningSlot104 queryUserMiningSlot = new queryUserMiningSlot104();//10.4
openSlot105 openSlot5 = new openSlot105();//10.5
queryMyPureContract106 queryMyPureContract = new queryMyPureContract106();//10.6
bindSlot107 bindSlot = new bindSlot107();
queryUserVoluteCoin108 queryUserVoluteCoin = new queryUserVoluteCoin108();
async void Start()
{
queryMiningContractList.QueryMiningContract();
miningContracDetail = await queryMiningContracDetail.QueryMiningContracDetail(2L);
//Debug.Log("====bbb======" + miningContracDetail.data.createTime);
bool isBuySucceed = await buyMiningContract.BuyMiningContract(1);
//Debug.Log("====购买===" + isBuySucceed);
//Debug.Log(buyMiningContract.BuyMiningContract(2) + "==========买");
//Debug.Log(openSlot5.OpenSlot() + "===============开卡槽");
queryMyPureContract.QueryMyPureContract();
queryUserMiningSlot.QueryUserMiningSlot();
bool isSucceed = await bindSlot.BindSlot(1, 1);
//Debug.Log(isSucceed + "========绑定卡槽");
QueryUserVoluteCoinResponse queryUserVoluteCoinResponse = await queryUserVoluteCoin.QueryUserVoluteCoin();
//Debug.Log(queryUserVoluteCoinResponse.data + "============================");
}
// Update is called once per frame
void Update()
{
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ee3458e7da434c4419e107eb11b1e6c4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,44 @@
using Newtonsoft.Json;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
//10.7,绑定卡槽
public class bindSlot107 : MonoBehaviour
{
public async Task<bool> BindSlot(long miningUserId,long slotId)
{
// 准备请求的头部信息,包含授权令牌
Dictionary<string, string> head = new Dictionary<string, string>
{
{ "Authorization", Global.global.serverResponse.data.token }
};
BindSlotBody107 body = new BindSlotBody107();
body.slotId = slotId;
body.miningUserId = miningUserId;
// 异步发送请求以获取最新的蜗牛骑士信息
string response0107 = await web.SendRequest(web.URL + "/snail/mining/bindSlot", "POST", JsonConvert.SerializeObject(body), head);
// 调试输出接收到的响应
Debug.Log("10.7绑定卡槽" + response0107);
BindSlotResponse bindSlotResponse = JsonConvert.DeserializeObject<BindSlotResponse>(response0107);
bool isSucceed;
if (bindSlotResponse.code == 200) { isSucceed = true; }else{ isSucceed = false; }
return isSucceed;
}
}
//======请求体==========================
public class BindSlotBody107
{
public long miningUserId;
public long slotId;
}
//请求参数headerAuthorization1.2接口返回的token
//         bodyminingUserIdLong用户合约id
//               slotIdLong, 卡槽id
//===========返回===============================
public class BindSlotResponse : Response
{
public string data;
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4a2290ed1af6fbf4d9a46ed338f4c485
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,51 @@
using Newtonsoft.Json;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
//10.3,购买合约
public class buyMiningContract103 : MonoBehaviour
{
public async Task<bool> BuyMiningContract(long contractId) // 9.1
{
// 准备请求的头部信息,包含授权令牌
Dictionary<string, string> head = new Dictionary<string, string>
{
{ "Authorization", Global.global.serverResponse.data.token }
};
queryPlayerInfo queryPlayerInfo = new queryPlayerInfo();
RealPlayerInfo realPlayerInfo = await queryPlayerInfo.QueryPlayerInfoPro();
BuyMiningContractBody body = new BuyMiningContractBody();
body.userId = realPlayerInfo.data.userId;
body.contractId = contractId;
//Debug.Log(JsonConvert.SerializeObject(body)+"=====================================");
// 异步发送请求以获取最新的蜗牛骑士信息
string response0103 = await web.SendRequest(web.URL + "/snail/mining/buyMiningContract" , "POST", JsonConvert.SerializeObject(body), head);
// 调试输出接收到的响应
Debug.Log("10.3购买合约" + response0103);
// 将响应反序列化为对象
BuyMiningResponse buyMiningResponse = JsonConvert.DeserializeObject<BuyMiningResponse>(response0103);
bool isSucceed;
if (buyMiningResponse.code == 200) { isSucceed = true; } else { isSucceed = false; }
// 返回解析后的对象
return isSucceed;
}
}
//==========请求体===========================
public class BuyMiningContractBody
{
public long contractId;
public long userId;
}
//==========返回值===========================
public class BuyMiningResponse : Response
{
public string data;
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 547a1a8c0d4f9484a9ce192f84a2334c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,39 @@
using Newtonsoft.Json;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
//10.5开启卡槽
public class openSlot105 : MonoBehaviour
{
public async Task<bool> OpenSlot()
{
// 准备请求的头部信息,包含授权令牌
Dictionary<string, string> head = new Dictionary<string, string>
{
{ "Authorization", Global.global.serverResponse.data.token }
};
// 异步发送请求以获取最新的蜗牛骑士信息
string response0105 = await web.SendRequest(web.URL + "/snail/mining/openSlot", "POST", "{}", head);
// 调试输出接收到的响应
Debug.Log("10.5开启卡槽" + response0105);
// 将响应反序列化为对象
OpenSlot openSlot = JsonConvert.DeserializeObject<OpenSlot>(response0105);
bool isSucceed;
if (openSlot.code == 200) { isSucceed = true; } else { isSucceed = false; }
// 返回解析后的对象
return isSucceed;
}
}
//===========返回==================================
public class OpenSlot:Response
{
public string data;
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2652070c59330a04181bcc871e591093
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,58 @@
using Newtonsoft.Json;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
//10.2查询合约详情
public class queryMiningContracDetail102 : MonoBehaviour
{
public async Task<MiningContracDetail> QueryMiningContracDetail(long contractId)
{
// 准备请求的头部信息,包含授权令牌
Dictionary<string, string> head = new Dictionary<string, string>
{
{ "Authorization", Global.global.serverResponse.data.token }
};
// 异步发送请求以获取最新的蜗牛骑士信息
string response0102 = await web.SendRequest(web.URL + "/snail/mining/queryMiningContractInfo?contractId=" + contractId, "GET","{}", head);
// 调试输出接收到的响应
Debug.Log("10.2,查询合约详情" + response0102);
// 将响应反序列化为对象
MiningContracDetail miningContracDetail = JsonConvert.DeserializeObject<MiningContracDetail>(response0102);
// 返回解析后的对象
return miningContracDetail;
}
}
//================返回==============================
public class MiningContracDetail : Response
{
public MiningDetailData data;
}
public class MiningDetailData
{
public long id;
public string name;
public int status;
public double voluteCoinBuy;
public int miningDays;
public double voluteCoinReward;
public double eachSecondsReward;
public string createTime;
public string updateTime;
}
//返回参数code200成功
//        message成功提示语
//        data合约详情
//             idLong合约id
//             nameString合约名称
//             voluteCoinBuyDecimal购买合约的蜗壳
//             voluteCoinRewardDecimal合约的回报蜗壳
//             miningDaysInteger挖矿天数

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4df814f1e75b83145ae57163b0e3cddb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,63 @@
using Newtonsoft.Json;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
//10.1,查询可购买的挖矿合约
public class queryMiningContractList101 : MonoBehaviour
{
public async Task<MiningContractList> QueryMiningContract()
{
// 准备请求的头部信息,包含授权令牌
Dictionary<string, string> head = new Dictionary<string, string>
{
{ "Authorization", Global.global.serverResponse.data.token }
};
// 异步发送请求以获取最新的蜗牛骑士信息
string response0101 = await web.SendRequest(web.URL + "/snail/mining/queryMiningContractList", "POST", "{}", head);
// 调试输出接收到的响应
Debug.Log("10.1,查询可购买的挖矿合约" + response0101);
// 将响应反序列化为对象
MiningContractList miningContractList = JsonConvert.DeserializeObject<MiningContractList>(response0101);
//// 遍历 miningContractList.data 列表中的每个 MiningContract 对象
//foreach (var contract in miningContractList.data)
//{
// Debug.Log($"合约ID: {contract.id}");
// Debug.Log($"合约名称: {contract.name}");
// Debug.Log($"状态: {contract.status}");
// Debug.Log($"上架状态: {contract.onShelves}");
// Debug.Log($"购买所需 VoluteCoin: {contract.voluteCoinBuy}");
// Debug.Log($"挖矿天数: {contract.miningDays}");
// Debug.Log($"挖矿奖励 VoluteCoin: {contract.voluteCoinReward}");
// Debug.Log($"每秒奖励: {contract.eachSecondsReward}");
// Debug.Log($"创建时间: {contract.createTime}");
// Debug.Log($"更新时间: {contract.updateTime}");
//}
// 返回解析后的对象
return miningContractList;
}
}
//=====返回================================================================
public class MiningContractList:Response
{
public List<MiningContract> data { get; set; }
}
public class MiningContract
{
public long id { get; set; }
public string name { get; set; }
public int status { get; set; }
public int onShelves { get; set; }
public double voluteCoinBuy { get; set; }
public int miningDays { get; set; }
public double voluteCoinReward { get; set; }
public double eachSecondsReward { get; set; }
public string createTime { get; set; }
public string updateTime { get; set; }
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0af9ad2dd63b0794bbc29fdafce5621c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,75 @@
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
//10.6查询寻未激活的条约
public class queryMyPureContract106 : MonoBehaviour
{
public async Task QueryMyPureContract()
{
// 准备请求的头部信息,包含授权令牌
Dictionary<string, string> head = new Dictionary<string, string>
{
{ "Authorization", Global.global.serverResponse.data.token }
};
// 异步发送请求以获取未激活的合约信息
string response0106 = await web.SendRequest(web.URL + "/snail/mining/queryMyPureContract", "POST", "{}", head);
// 调试输出接收到的响应
Debug.Log("10.6 查询未激活的合约: " + response0106);
// 将响应反序列化为对象
MyPureContractResponse contractResponse = JsonConvert.DeserializeObject<MyPureContractResponse>(response0106);
// 检查返回的数据
if (contractResponse != null && contractResponse.data != null)
{
//foreach (var contract in contractResponse.data)
//{
// // 访问合约字段
// Debug.Log($"合约 ID: {contract.id}");
// Debug.Log($"合约名称: {contract.contractName}");
// Debug.Log($"每秒奖励: {contract.eachSecondsReward}");
// Debug.Log($"合约创建时间: {contract.createTime}");
// Debug.Log($"合约更新时间: {contract.updateTime}");
// // 这里可以根据需要进行其他处理
//}
}
else
{
Debug.LogError("未能获取到合约数据!");
}
}
}
//==============返回值===================================
public class MyPureContractResponse:Response
{
public List<MyPureContract> data { get; set; }
}
public class MyPureContract
{
public long id { get; set; }
public long userId { get; set; }
public long contractId { get; set; }
public string contractName { get; set; }
public long slotId { get; set; }
public string miningBegin { get; set; }
public string miningEnd { get; set; }
public string miningNow { get; set; }
public double eachSecondsReward { get; set; }
public int status { get; set; }
public string createTime { get; set; }
public string updateTime { get; set; }
}
//code200成功
//        message成功提示语
//        data合约列表
//            idLong, 用户合约id
//            userIdLong, 用户id
//            contractIdLong合约id
//            contractNameString合约名称

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 52d5a0e68db288146b6bf48a0d4c05a8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,100 @@
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
//10.4查询矿场卡槽分页
public class queryUserMiningSlot104 : MonoBehaviour
{
public async Task<UserMiningSlotResponse> QueryUserMiningSlot()
{
// 准备请求的头部信息,包含授权令牌
Dictionary<string, string> head = new Dictionary<string, string>
{
{ "Authorization", Global.global.serverResponse.data.token }
};
queryPlayerInfo queryPlayerInfo = new queryPlayerInfo();
RealPlayerInfo realPlayerInfo = await queryPlayerInfo.QueryPlayerInfoPro();
UserMiningSlotBody body = new UserMiningSlotBody();
body.userId = realPlayerInfo.data.userId;
// 异步发送请求以获取最新的蜗牛骑士信息
string response0104 = await web.SendRequest(web.URL + "/snail/mining/queryUserMiningSlot", "POST", JsonConvert.SerializeObject(body), head);
// 调试输出接收到的响应
Debug.Log("10.4查询矿场卡槽分页" + response0104);
// 将响应反序列化为对象
UserMiningSlotResponse userMiningSlotResponse = JsonConvert.DeserializeObject<UserMiningSlotResponse>(response0104);
//Debug.Log("===========88============="+ userMiningSlotResponse.data.dataList[0].userId);
// 返回解析后的对象
return userMiningSlotResponse;
}
}
//======请求体==================================
public class UserMiningSlotBody
{
public long userId;
}
//===========返回值==============================
public class UserMiningSlotResponse:Response
{
public UserMiningSlotData data { get; set; }
}
public class UserMiningSlotData
{
public int pageNo { get; set; }
public int pageSize { get; set; }
public int totalCount { get; set; }
public List<UserMiningSlot> dataList { get; set; }
}
public class UserMiningSlot
{
public long id { get; set; }
public long userId { get; set; }
public long snailId { get; set; }
public long contractId { get; set; }
public long contractUserId { get; set; }
public string bindTime { get; set; }
public int source { get; set; }
public int useType { get; set; }
public int status { get; set; }
public string createTime { get; set; }
public string miningBegin { get; set; }
public string miningEnd { get; set; }
public int carry { get; set; }
public string contractName { get; set; }
}
//{
// "code": 200,
// "message": "请求成功",
// "data": {
// "pageNo": 1,
// "pageSize": 20,
// "totalCount": 1,
// "dataList": [
// {
// "id": 13,
// "userId": 106,
// "snailId": 0,
// "contractId": 0,
// "contractUserId": 0,
// "bindTime": null,
// "source": 0,
// "useType": 2,
// "status": 0,
// "createTime": null,
// "miningBegin": null,
// "miningEnd": null,
// "carry": 0,
// "contractName": null
// }
// ]
// }
//}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: adf0d750fe73e4d49853f565e07de4f4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,32 @@
using Newtonsoft.Json;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
//10.8,矿厂主页刷新蜗壳值
public class queryUserVoluteCoin108 : MonoBehaviour
{
public async Task<QueryUserVoluteCoinResponse> QueryUserVoluteCoin()
{
// 准备请求的头部信息,包含授权令牌
Dictionary<string, string> head = new Dictionary<string, string>
{
{ "Authorization", Global.global.serverResponse.data.token }
};
// 异步发送请求
string response0108 = await web.SendRequest(web.URL + "/snail/mining/queryUserVoluteCoin", "POST","{}", head);
// 调试输出接收到的响应
Debug.Log("10.8,矿厂主页刷新蜗壳值" + response0108);
QueryUserVoluteCoinResponse queryUserVoluteCoinResponse = JsonConvert.DeserializeObject<QueryUserVoluteCoinResponse>(response0108);
return queryUserVoluteCoinResponse;
}
}
//============返回值======================================
public class QueryUserVoluteCoinResponse:Response
{
public double data;
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b49f6a4966f47f84b803332f4eea8b7e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: