-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3078 from mc7246/master
添加 查询购买资源包的用量情况
- Loading branch information
Showing
4 changed files
with
275 additions
and
0 deletions.
There are no files selected for viewing
90 changes: 90 additions & 0 deletions
90
...n.WxOpen/src/Senparc.Weixin.WxOpen/Senparc.Weixin.WxOpen/AdvancedAPIs/Charge/ChargeApi.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
using Senparc.NeuChar; | ||
using Senparc.Weixin.CommonAPIs; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Senparc.Weixin.WxOpen.AdvancedAPIs.Charge | ||
{ | ||
[NcApiBind(NeuChar.PlatformType.WeChat_MiniProgram, true)] | ||
public class ChargeApi | ||
{ | ||
#region 同步方法 | ||
/// <summary> | ||
/// 查询购买资源包的用量情况 | ||
/// </summary> | ||
/// <param name="accessTokenOrAppId"></param> | ||
/// <param name="spuId">商品SPU ID</param> | ||
/// <param name="offset">分页偏移量,从0开始</param> | ||
/// <param name="limit"每页个数,最大20></param> | ||
/// <param name="timeOut"></param> | ||
/// <returns></returns> | ||
public static UsageResultJson Usage(string accessTokenOrAppId, string spuId, int offset, int limit, int timeOut = Config.TIME_OUT) | ||
{ | ||
return WxOpenApiHandlerWapper.TryCommonApi(accessToken => | ||
{ | ||
var urlFormat = Config.ApiMpHost + "/wxa/charge/usage/get?access_token={0}&spuId=" + spuId + "&offset=" + offset+ "&limit=" + limit; | ||
return CommonJsonSend.Send<UsageResultJson>(accessToken, urlFormat, null, CommonJsonSendType.GET, timeOut: timeOut); | ||
|
||
}, accessTokenOrAppId); | ||
} | ||
|
||
/// <summary> | ||
/// 获取小程序某个付费能力的最近用量数据 | ||
/// </summary> | ||
/// <param name="accessTokenOrAppId"></param> | ||
/// <param name="spuId">商品SPU ID</param> | ||
/// <param name="timeOut"></param> | ||
/// <returns></returns> | ||
public static GetRecentAverageResultJson GetRecentAverage(string accessTokenOrAppId, string spuId, int timeOut = Config.TIME_OUT) | ||
{ | ||
return WxOpenApiHandlerWapper.TryCommonApi(accessToken => | ||
{ | ||
var urlFormat = Config.ApiMpHost + "/wxa/charge/usage/get_recent_average?access_token={0}&spuId=" + spuId; | ||
return CommonJsonSend.Send<GetRecentAverageResultJson>(accessToken, urlFormat, null, CommonJsonSendType.GET, timeOut: timeOut); | ||
|
||
}, accessTokenOrAppId); | ||
} | ||
#endregion | ||
|
||
#region 异步方法 | ||
/// <summary> | ||
/// 【异步方法】查询购买资源包的用量情况 | ||
/// </summary> | ||
/// <param name="accessTokenOrAppId"></param> | ||
/// <param name="spuId">商品SPU ID</param> | ||
/// <param name="offset">分页偏移量,从0开始</param> | ||
/// <param name="limit"每页个数,最大20></param> | ||
/// <param name="timeOut"></param> | ||
/// <returns></returns> | ||
public static async Task<UsageResultJson> UsageAsync(string accessTokenOrAppId, string spuId, int offset, int limit, int timeOut = Config.TIME_OUT) | ||
{ | ||
return await WxOpenApiHandlerWapper.TryCommonApiAsync(async accessToken => | ||
{ | ||
var urlFormat = Config.ApiMpHost + "/wxa/charge/usage/get?access_token={0}&spuId=" + spuId + "&offset=" + offset + "&limit=" + limit; | ||
return await CommonJsonSend.SendAsync<UsageResultJson>(accessToken, urlFormat, null, CommonJsonSendType.GET, timeOut: timeOut).ConfigureAwait(false); | ||
|
||
}, accessTokenOrAppId).ConfigureAwait(false); | ||
} | ||
|
||
/// <summary> | ||
/// 【异步方法】获取小程序某个付费能力的最近用量数据 | ||
/// </summary> | ||
/// <param name="accessTokenOrAppId"></param> | ||
/// <param name="spuId">商品SPU ID</param> | ||
/// <param name="timeOut"></param> | ||
/// <returns></returns> | ||
public static async Task<GetRecentAverageResultJson> GetRecentAverageAsync(string accessTokenOrAppId, string spuId, int timeOut = Config.TIME_OUT) | ||
{ | ||
return await WxOpenApiHandlerWapper.TryCommonApiAsync(async accessToken => | ||
{ | ||
var urlFormat = Config.ApiMpHost + "/wxa/charge/usage/get_recent_average?access_token={0}&spuId=" + spuId; | ||
return await CommonJsonSend.SendAsync<GetRecentAverageResultJson>(accessToken, urlFormat, null, CommonJsonSendType.GET, timeOut: timeOut).ConfigureAwait(false); | ||
|
||
}, accessTokenOrAppId).ConfigureAwait(false); | ||
} | ||
#endregion | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...WxOpen/Senparc.Weixin.WxOpen/AdvancedAPIs/Charge/ChargeJson/GetRecentAverageResultJson.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#region Apache License Version 2.0 | ||
/*---------------------------------------------------------------- | ||
Copyright 2024 Jeffrey Su & Suzhou Senparc Network Technology Co.,Ltd. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file | ||
except in compliance with the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software distributed under the | ||
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
either express or implied. See the License for the specific language governing permissions | ||
and limitations under the License. | ||
Detail: https://github.com/JeffreySu/WeiXinMPSDK/blob/master/license.md | ||
----------------------------------------------------------------*/ | ||
#endregion Apache License Version 2.0 | ||
|
||
/*---------------------------------------------------------------- | ||
Copyright (C) 2024 Senparc | ||
文件名:GetRecentAverageResultJson.cs | ||
文件功能描述:小程序 获取小程序某个付费能力的最近用量数据 返回结果 | ||
创建标识:mc7246 - 20240831 | ||
----------------------------------------------------------------*/ | ||
|
||
using Senparc.Weixin.Entities; | ||
|
||
namespace Senparc.Weixin.WxOpen.AdvancedAPIs.Charge | ||
{ | ||
/// <summary> | ||
/// 小程序 获取小程序某个付费能力的最近用量数据 返回结果 | ||
/// </summary> | ||
public class GetRecentAverageResultJson: WxJsonResult | ||
{ | ||
/// <summary> | ||
/// 最近月平均用量,经模糊化处理,非精确值 | ||
/// 当averageData返回值为50时,语义为小程序最近平均用量小于等于50次/月,并不是特指精确等于每月50次。 | ||
/// </summary> | ||
public int averageData { get; set; } | ||
} | ||
} |
126 changes: 126 additions & 0 deletions
126
...arc.Weixin.WxOpen/Senparc.Weixin.WxOpen/AdvancedAPIs/Charge/ChargeJson/UsageResultJson.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
#region Apache License Version 2.0 | ||
/*---------------------------------------------------------------- | ||
Copyright 2024 Jeffrey Su & Suzhou Senparc Network Technology Co.,Ltd. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file | ||
except in compliance with the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software distributed under the | ||
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
either express or implied. See the License for the specific language governing permissions | ||
and limitations under the License. | ||
Detail: https://github.com/JeffreySu/WeiXinMPSDK/blob/master/license.md | ||
----------------------------------------------------------------*/ | ||
#endregion Apache License Version 2.0 | ||
|
||
/*---------------------------------------------------------------- | ||
Copyright (C) 2024 Senparc | ||
文件名:UsageResultJson.cs | ||
文件功能描述:小程序 查询购买资源包的用量情况 返回结果 | ||
创建标识:mc7246 - 20240831 | ||
----------------------------------------------------------------*/ | ||
|
||
using Senparc.Weixin.Entities; | ||
using System.Collections.Generic; | ||
|
||
namespace Senparc.Weixin.WxOpen.AdvancedAPIs.Charge | ||
{ | ||
/// <summary> | ||
/// 小程序-查询购买资源包的用量情况 返回结果 | ||
/// </summary> | ||
public class UsageResultJson : WxJsonResult | ||
{ | ||
/// <summary> | ||
/// 资源可用总量(64位数字),用于资源包类商品 | ||
/// </summary> | ||
public string all { get; set; } | ||
|
||
/// <summary> | ||
/// 资源总量(64位数字),用于资源包类商品 | ||
/// </summary> | ||
public string effectiveAll { get; set; } | ||
|
||
/// <summary> | ||
/// 累计用量(64位数字),用于资源包类商品 | ||
/// </summary> | ||
public string effectiveUse { get; set; } | ||
|
||
/// <summary> | ||
/// 订阅开始时间戳(单位:秒),用于订阅类商品 | ||
/// </summary> | ||
public long startServiceTime { get; set; } | ||
|
||
/// <summary> | ||
/// 订阅结束时间戳(单位:秒),用于订阅类商品 | ||
/// </summary> | ||
public long endServiceTime { get; set; } | ||
|
||
/// <summary> | ||
/// 用量详情列表总数 | ||
/// </summary> | ||
public int total { get; set; } | ||
|
||
/// <summary> | ||
/// 用量详情列表 | ||
/// </summary> | ||
public List<UsageResultJson_DetailList> detailList { get; set; } | ||
} | ||
|
||
public class UsageResultJson_DetailList | ||
{ | ||
/// <summary> | ||
/// 资源包ID | ||
/// </summary> | ||
public string pkgId { get; set; } | ||
|
||
/// <summary> | ||
/// 资源包状态,1生效中,2未生效,3已失效 | ||
/// </summary> | ||
public int status { get; set; } | ||
|
||
/// <summary> | ||
/// 额度有效期开始时间戳(单位:秒) | ||
/// </summary> | ||
public long startTime { get; set; } | ||
|
||
/// <summary> | ||
/// 额度有效期至结束时间戳(单位:秒) | ||
/// </summary> | ||
public long endTime { get; set; } | ||
|
||
/// <summary> | ||
/// 使用额度(64位数字) | ||
/// </summary> | ||
public string used { get; set; } | ||
|
||
/// <summary> | ||
/// 额度容量(64位数字) | ||
/// </summary> | ||
public string all { get; set; } | ||
|
||
/// <summary> | ||
/// 额度来源的商品SPU ID(64位数字) | ||
/// </summary> | ||
public string spuId { get; set; } | ||
|
||
/// <summary> | ||
/// 额度来源的商品SKU ID(64位数字) | ||
/// </summary> | ||
public string skuId { get; set; } | ||
|
||
/// <summary> | ||
/// 额度来源,1体验额度,2付费购买,3服务商分配,4其他,5其他 | ||
/// </summary> | ||
public int source { get; set; } | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters