151 lines
4.9 KiB
C#
151 lines
4.9 KiB
C#
using DontConfuse;
|
|
using SGModule.Common.Helper;
|
|
using UnityEngine.Events;
|
|
|
|
namespace SGModule.NetKit {
|
|
public static class NetApi {
|
|
#region 玩家数据
|
|
|
|
public static void RequestPlayerData(UnityAction<bool, string> onCompleted) {
|
|
NetKit.Instance.Post<string>("user/userData", onCompleted: response => {
|
|
onCompleted?.Invoke(response.IsSuccess, response.Data);
|
|
});
|
|
}
|
|
|
|
/// <summary>
|
|
/// 立即发送请求更新用户数据
|
|
/// </summary>
|
|
/// <param name="version"></param>
|
|
/// <param name="data"></param>
|
|
public static void UploadPlayerDataUpdate(long version, string data) {
|
|
var requestSavePlayData = new RequestSavePlayData {
|
|
Version = version,
|
|
Data = data
|
|
};
|
|
NetKit.Instance.Post("user/updateData", requestSavePlayData, useCoroutine: false);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 启动协程更新用户数据
|
|
/// </summary>
|
|
/// <param name="version"></param>
|
|
/// <param name="data"></param>
|
|
/// <param name="onCompleted"></param>
|
|
public static void UploadPlayerDataUpdate(long version, string data, UnityAction<bool> onCompleted) {
|
|
var requestSavePlayData = new RequestSavePlayData {
|
|
Version = version,
|
|
Data = data
|
|
};
|
|
NetKit.Instance.Post<object>("user/updateData", requestSavePlayData,
|
|
response => {
|
|
onCompleted?.Invoke(response.IsSuccess);
|
|
});
|
|
}
|
|
|
|
public static void DeltaUpdateData(long version, string data, UnityAction<bool> onCompleted) {
|
|
var requestSavePlayData = new RequestSavePlayData {
|
|
Version = version,
|
|
Data = data
|
|
};
|
|
NetKit.Instance.Post<object>("user/deltaUpdateData", requestSavePlayData,
|
|
response => {
|
|
onCompleted?.Invoke(response.IsSuccess);
|
|
});
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
#region Pay
|
|
|
|
public static void PixPayIn<T>(string account, string phone, string email, int amount,
|
|
UnityAction<bool, T> onCompleted = null) {
|
|
var data = new PayerData {
|
|
Name = account,
|
|
Tel = phone,
|
|
Email = email,
|
|
Amount = amount
|
|
};
|
|
|
|
NetKit.Instance.Post<T>("shop/pixPayIn", data,
|
|
response => {
|
|
onCompleted?.Invoke(response.IsSuccess, response.Data);
|
|
});
|
|
}
|
|
|
|
public static void PixPayOrderQuery<T>(string orderID, UnityAction<bool, T> onCompleted = null) {
|
|
var data = new OrderData {
|
|
OrderID = orderID
|
|
};
|
|
|
|
NetKit.Instance.Post<T>("shop/pixPayOrderQuery", data,
|
|
response => {
|
|
onCompleted?.Invoke(response.IsSuccess, response.Data);
|
|
});
|
|
}
|
|
|
|
public static void PayOutUserInfo<T>(string email, string firstName, string lastName,
|
|
UnityAction<bool, T> onCompleted = null) {
|
|
var data = new PayOutUserInfoData {
|
|
Email = email,
|
|
FirstName = firstName,
|
|
LastName = lastName
|
|
};
|
|
|
|
NetKit.Instance.Post<T>("shop/payOutUserInfo", data,
|
|
response => {
|
|
onCompleted?.Invoke(response.IsSuccess, response.Data);
|
|
});
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
#region H5
|
|
|
|
public static void H5RefreshTimes<T>(string link, string type, UnityAction<bool, T> onCompleted = null) {
|
|
var info = new H5SendClass {
|
|
Link = link,
|
|
Type = type
|
|
};
|
|
NetKit.Instance.Post<T>("event/h5Impressions", info,
|
|
response => {
|
|
onCompleted?.Invoke(response.IsSuccess, response.Data);
|
|
});
|
|
}
|
|
|
|
public static void SetClickAdEvent<T>(string link, string type, UnityAction<bool, T> onCompleted = null)
|
|
{
|
|
var info = new H5sendClass
|
|
{
|
|
link = link,
|
|
type = type
|
|
};
|
|
NetKit.Instance.Post<T>("event/h5Clicks", info,
|
|
response => {
|
|
onCompleted?.Invoke(response.IsSuccess, response.Data);
|
|
});
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
#region 结算上传
|
|
|
|
public static void SettleUp(int gameType, RequestStageData stageData, UnityAction<bool> onCompleted = null) {
|
|
var requestJson = SerializeHelper.ToJsonIndented(stageData);
|
|
var reqData = new RequestResultData {
|
|
Type = gameType,
|
|
Result = requestJson
|
|
};
|
|
|
|
NetKit.Instance.Post<object>("game/settleUp", reqData, response => {
|
|
onCompleted?.Invoke(response.IsSuccess);
|
|
});
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|