#region Apache License Version 2.0
/*----------------------------------------------------------------
Copyright 2018 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) 2018 Senparc
文件名:StoreApi.cs
文件功能描述:门店接口
创建标识:Senparc - 20180927
----------------------------------------------------------------*/
using Senparc.CO2NET.Extensions;
using Senparc.NeuChar;
using Senparc.Weixin.CommonAPIs;
using Senparc.Weixin.Entities;
using System.Threading.Tasks;
namespace Senparc.Weixin.MP.AdvancedAPIs
{
///
/// 门店接口
///
public static class StoreApi
{
#region 同步方法
///
/// 拉取门店小程序类目
///
///
///
///
[ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.GetMerchantCategory", true)]
public static GetMerchantCategoryResultJson GetMerchantCategory(string accessTokenOrAppId, int timeOut = Config.TIME_OUT)
{
return ApiHandlerWapper.TryCommonApi(accessToken =>
{
var urlFormat = string.Format(Config.ApiMpHost + "/wxa/get_merchant_category?access_token={0}", accessToken.AsUrlData());
return CommonJsonSend.Send(null, urlFormat, null, CommonJsonSendType.GET, timeOut: timeOut);
}, accessTokenOrAppId);
}
///
/// 创建门店小程序
///
///
///
///
///
[ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.ApplyMerchant", true)]
public static WxJsonResult ApplyMerchant(string accessTokenOrAppId, ApplyMerchantData data, int timeOut = Config.TIME_OUT)
{
return ApiHandlerWapper.TryCommonApi(accessToken =>
{
var urlFormat = string.Format(Config.ApiMpHost + "/wxa/apply_merchant?access_token={0}", accessToken.AsUrlData());
return CommonJsonSend.Send(null, urlFormat, data, timeOut: timeOut);
}, accessTokenOrAppId);
}
///
/// 查询门店小程序审核结果
///
///
///
///
[ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.GetMerchantAuditInfo", true)]
public static GetMerchantAuditInfoResultJson GetMerchantAuditInfo(string accessTokenOrAppId, int timeOut = Config.TIME_OUT)
{
return ApiHandlerWapper.TryCommonApi(accessToken =>
{
var urlFormat = string.Format(Config.ApiMpHost + "/wxa/get_merchant_audit_info?access_token={0}", accessToken.AsUrlData());
return CommonJsonSend.Send(null, urlFormat, null, CommonJsonSendType.GET, timeOut: timeOut);
}, accessTokenOrAppId);
}
///
/// 修改门店小程序信息
///
///
///
///
///
///
[ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.ModifyMerchant", true)]
public static WxJsonResult ModifyMerchant(string accessTokenOrAppId, string headingMediaid, string intro, int timeOut = Config.TIME_OUT)
{
return ApiHandlerWapper.TryCommonApi(accessToken =>
{
var urlFormat = string.Format(Config.ApiMpHost + "/wxa/modify_merchant?access_token={0}", accessToken.AsUrlData());
var data = new
{
headimg_mediaid = headingMediaid,
intro
};
return CommonJsonSend.Send(null, urlFormat, data, timeOut: timeOut);
}, accessTokenOrAppId);
}
///
/// 从腾讯地图拉取省市区信息
///
///
///
///
[ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.GetDistrict", true)]
public static GetDistrictResultJson GetDistrict(string accessTokenOrAppId, int timeOut = Config.TIME_OUT)
{
return ApiHandlerWapper.TryCommonApi(accessToken =>
{
var urlFormat = string.Format(Config.ApiMpHost + "/wxa/get_district?access_token={0}", accessToken.AsUrlData());
return CommonJsonSend.Send(null, urlFormat, null, CommonJsonSendType.GET, timeOut: timeOut);
}, accessTokenOrAppId);
}
///
/// 在腾讯地图中搜索门店
///
///
///
///
///
///
[ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.SearchMapPoi", true)]
public static SearchMapPoiResultJson SearchMapPoi(string accessTokenOrAppId, string districtId, string keyword, int timeOut = Config.TIME_OUT)
{
return ApiHandlerWapper.TryCommonApi(accessToken =>
{
var urlFormat = string.Format(Config.ApiMpHost + "/wxa/search_map_poi?access_token={0}", accessToken.AsUrlData());
var data = new
{
districtid = districtId,
keyword
};
return CommonJsonSend.Send(null, urlFormat, data, timeOut: timeOut);
}, accessTokenOrAppId);
}
///
/// 在腾讯地图中创建门店
///
///
///
///
///
[ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.CreateMapPoi", true)]
public static CreateMapPoiResultJson CreateMapPoi(string accessTokenOrAppId, CreateMapPoiData data, int timeOut = Config.TIME_OUT)
{
return ApiHandlerWapper.TryCommonApi(accessToken =>
{
var urlFormat = string.Format(Config.ApiMpHost + "/wxa/create_map_poi?access_token={0}", accessToken.AsUrlData());
return CommonJsonSend.Send(null, urlFormat, data, timeOut: timeOut);
}, accessTokenOrAppId);
}
///
/// 添加门店
///
///
///
///
///
[ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.AddStore", true)]
public static AddStoreResultJson AddStore(string accessTokenOrAppId, AddStoreData data, int timeOut = Config.TIME_OUT)
{
return ApiHandlerWapper.TryCommonApi(accessToken =>
{
var urlFormat = string.Format(Config.ApiMpHost + "/wxa/add_store?access_token={0}", accessToken.AsUrlData());
return CommonJsonSend.Send(null, urlFormat, data, timeOut: timeOut);
}, accessTokenOrAppId);
}
///
/// 更新门店信息
///
///
///
///
///
[ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.UpdateStore", true)]
public static UpdateStoreResultJson UpdateStore(string accessTokenOrAppId, UpdateStoreData data, int timeOut = Config.TIME_OUT)
{
return ApiHandlerWapper.TryCommonApi(accessToken =>
{
var urlFormat = string.Format(Config.ApiMpHost + "/wxa/update_store?access_token={0}", accessToken.AsUrlData());
return CommonJsonSend.Send(null, urlFormat, data, timeOut: timeOut);
}, accessTokenOrAppId);
}
///
/// 获取单个门店信息
///
///
///
///
///
[ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.GetStoreInfo", true)]
public static GetStoreInfoResultJson GetStoreInfo(string accessTokenOrAppId, string poiId, int timeOut = Config.TIME_OUT)
{
return ApiHandlerWapper.TryCommonApi(accessToken =>
{
var urlFormat = string.Format(Config.ApiMpHost + "/wxa/get_store_info?access_token={0}", accessToken.AsUrlData());
var data = new
{
poi_id = poiId
};
return CommonJsonSend.Send(null, urlFormat, data, timeOut: timeOut);
}, accessTokenOrAppId);
}
///
/// 获取门店信息列表
///
///
///
///
///
///
[ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.GetStoreList", true)]
public static GetStoreListResultJson GetStoreList(string accessTokenOrAppId, int offset, int limit, int timeOut = Config.TIME_OUT)
{
return ApiHandlerWapper.TryCommonApi(accessToken =>
{
var urlFormat = string.Format(Config.ApiMpHost + "/wxa/get_store_list?access_token={0}", accessToken.AsUrlData());
var data = new
{
offset = offset,
limit = limit
};
return CommonJsonSend.Send(null, urlFormat, data, timeOut: timeOut);
}, accessTokenOrAppId);
}
///
/// 删除门店
///
///
///
///
///
[ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.DelStore", true)]
public static WxJsonResult DelStore(string accessTokenOrAppId, string poiId, int timeOut = Config.TIME_OUT)
{
return ApiHandlerWapper.TryCommonApi(accessToken =>
{
var urlFormat = string.Format(Config.ApiMpHost + "/wxa/del_store?access_token={0}", accessToken.AsUrlData());
var data = new
{
poi_id = poiId
};
return CommonJsonSend.Send(null, urlFormat, data, timeOut: timeOut);
}, accessTokenOrAppId);
}
///
/// 获取门店小程序配置的卡券
///
///
///
///
///
[ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.GetStoreCard", true)]
public static GetStoreCardResultJson GetStoreCard(string accessTokenOrAppId, string poiId, int timeOut = Config.TIME_OUT)
{
return ApiHandlerWapper.TryCommonApi(accessToken =>
{
var urlFormat = string.Format(Config.ApiMpHost + "/card/storewxa/get?access_token={0}", accessToken.AsUrlData());
var data = new
{
poi_id = poiId
};
return CommonJsonSend.Send(null, urlFormat, data, timeOut: timeOut);
}, accessTokenOrAppId);
}
///
/// 设置门店小程序配置的卡券
///
///
///
///
///
///
[ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.SetStoreCard", true)]
public static WxJsonResult SetStoreCard(string accessTokenOrAppId, string poiId, string cardId, int timeOut = Config.TIME_OUT)
{
return ApiHandlerWapper.TryCommonApi(accessToken =>
{
var urlFormat = string.Format(Config.ApiMpHost + "/card/storewxa/set?access_token={0}", accessToken.AsUrlData());
var data = new
{
poi_id = poiId,
card_id = cardId
};
return CommonJsonSend.Send(null, urlFormat, data, timeOut: timeOut);
}, accessTokenOrAppId);
}
#endregion
#if !NET35 && !NET40
#region 异步方法
///
/// 【异步方法】拉取门店小程序类目
///
///
///
///
[ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.GetMerchantCategoryAsync", true)]
public static async Task GetMerchantCategoryAsync(string accessTokenOrAppId, int timeOut = Config.TIME_OUT)
{
return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
{
var urlFormat = string.Format(Config.ApiMpHost + "/wxa/get_merchant_category?access_token={0}", accessToken.AsUrlData());
return await CommonJsonSend.SendAsync(null, urlFormat, null, CommonJsonSendType.GET, timeOut: timeOut);
}, accessTokenOrAppId);
}
///
/// 【异步方法】创建门店小程序
///
///
///
///
///
[ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.ApplyMerchantAsync", true)]
public static async Task ApplyMerchantAsync(string accessTokenOrAppId, ApplyMerchantData data, int timeOut = Config.TIME_OUT)
{
return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
{
var urlFormat = string.Format(Config.ApiMpHost + "/wxa/apply_merchant?access_token={0}", accessToken.AsUrlData());
return await CommonJsonSend.SendAsync(null, urlFormat, data, timeOut: timeOut);
}, accessTokenOrAppId);
}
///
/// 【异步方法】查询门店小程序审核结果
///
///
///
///
[ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.GetMerchantAuditInfoAsync", true)]
public static async Task GetMerchantAuditInfoAsync(string accessTokenOrAppId, int timeOut = Config.TIME_OUT)
{
return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
{
var urlFormat = string.Format(Config.ApiMpHost + "/wxa/get_merchant_audit_info?access_token={0}", accessToken.AsUrlData());
return await CommonJsonSend.SendAsync(null, urlFormat, null, CommonJsonSendType.GET, timeOut: timeOut);
}, accessTokenOrAppId);
}
///
/// 【异步方法】修改门店小程序信息
///
///
///
///
///
///
[ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.ModifyMerchantAsync", true)]
public static async Task ModifyMerchantAsync(string accessTokenOrAppId, string headingMediaid, string intro, int timeOut = Config.TIME_OUT)
{
return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
{
var urlFormat = string.Format(Config.ApiMpHost + "/wxa/modify_merchant?access_token={0}", accessToken.AsUrlData());
var data = new
{
headimg_mediaid = headingMediaid,
intro
};
return await CommonJsonSend.SendAsync(null, urlFormat, data, timeOut: timeOut);
}, accessTokenOrAppId);
}
///
/// 【异步方法】从腾讯地图拉取省市区信息
///
///
///
///
[ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.GetDistrictAsync", true)]
public static async Task GetDistrictAsync(string accessTokenOrAppId, int timeOut = Config.TIME_OUT)
{
return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
{
var urlFormat = string.Format(Config.ApiMpHost + "/wxa/get_district?access_token={0}", accessToken.AsUrlData());
return await CommonJsonSend.SendAsync(null, urlFormat, null, CommonJsonSendType.GET, timeOut: timeOut);
}, accessTokenOrAppId);
}
///
/// 【异步方法】在腾讯地图中搜索门店
///
///
///
///
///
///
[ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.SearchMapPoiAsync", true)]
public static async Task SearchMapPoiAsync(string accessTokenOrAppId, string districtId, string keyword, int timeOut = Config.TIME_OUT)
{
return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
{
var urlFormat = string.Format(Config.ApiMpHost + "/wxa/search_map_poi?access_token={0}", accessToken.AsUrlData());
var data = new
{
districtid = districtId,
keyword
};
return await CommonJsonSend.SendAsync(null, urlFormat, data, timeOut: timeOut);
}, accessTokenOrAppId);
}
///
/// 【异步方法】在腾讯地图中创建门店
///
///
///
///
///
[ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.CreateMapPoiAsync", true)]
public static async Task CreateMapPoiAsync(string accessTokenOrAppId, CreateMapPoiData data, int timeOut = Config.TIME_OUT)
{
return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
{
var urlFormat = string.Format(Config.ApiMpHost + "/wxa/create_map_poi?access_token={0}", accessToken.AsUrlData());
return await CommonJsonSend.SendAsync(null, urlFormat, data, timeOut: timeOut);
}, accessTokenOrAppId);
}
///
/// 【异步方法】添加门店
///
///
///
///
///
[ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.AddStoreAsync", true)]
public static async Task AddStoreAsync(string accessTokenOrAppId, AddStoreData data, int timeOut = Config.TIME_OUT)
{
return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
{
var urlFormat = string.Format(Config.ApiMpHost + "/wxa/add_store?access_token={0}", accessToken.AsUrlData());
return await CommonJsonSend.SendAsync(null, urlFormat, data, timeOut: timeOut);
}, accessTokenOrAppId);
}
///
/// 【异步方法】更新门店信息
///
///
///
///
///
[ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.UpdateStoreAsync", true)]
public static async Task UpdateStoreAsync(string accessTokenOrAppId, UpdateStoreData data, int timeOut = Config.TIME_OUT)
{
return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
{
var urlFormat = string.Format(Config.ApiMpHost + "/wxa/update_store?access_token={0}", accessToken.AsUrlData());
return await CommonJsonSend.SendAsync(null, urlFormat, data, timeOut: timeOut);
}, accessTokenOrAppId);
}
///
/// 【异步方法】获取单个门店信息
///
///
///
///
///
[ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.GetStoreInfoAsync", true)]
public static async Task GetStoreInfoAsync(string accessTokenOrAppId, string poiId, int timeOut = Config.TIME_OUT)
{
return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
{
var urlFormat = string.Format(Config.ApiMpHost + "/wxa/get_store_info?access_token={0}", accessToken.AsUrlData());
var data = new
{
poi_id = poiId
};
return await CommonJsonSend.SendAsync(null, urlFormat, data, timeOut: timeOut);
}, accessTokenOrAppId);
}
///
/// 【异步方法】获取门店信息列表
///
///
///
///
///
///
[ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.GetStoreListAsync", true)]
public static async Task GetStoreListAsync(string accessTokenOrAppId, int offset, int limit, int timeOut = Config.TIME_OUT)
{
return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
{
var urlFormat = string.Format(Config.ApiMpHost + "/wxa/get_store_list?access_token={0}", accessToken.AsUrlData());
var data = new
{
offset = offset,
limit = limit
};
return await CommonJsonSend.SendAsync(null, urlFormat, data, timeOut: timeOut);
}, accessTokenOrAppId);
}
///
/// 【异步方法】删除门店
///
///
///
///
///
[ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.DelStoreAsync", true)]
public static async Task DelStoreAsync(string accessTokenOrAppId, string poiId, int timeOut = Config.TIME_OUT)
{
return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
{
var urlFormat = string.Format(Config.ApiMpHost + "/wxa/del_store?access_token={0}", accessToken.AsUrlData());
var data = new
{
poi_id = poiId
};
return await CommonJsonSend.SendAsync(null, urlFormat, data, timeOut: timeOut);
}, accessTokenOrAppId);
}
///
/// 【异步方法】获取门店小程序配置的卡券
///
///
///
///
///
[ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.GetStoreCardAsync", true)]
public static async Task GetStoreCardAsync(string accessTokenOrAppId, string poiId, int timeOut = Config.TIME_OUT)
{
return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
{
var urlFormat = string.Format(Config.ApiMpHost + "/card/storewxa/get?access_token={0}", accessToken.AsUrlData());
var data = new
{
poi_id = poiId
};
return await CommonJsonSend.SendAsync(null, urlFormat, data, timeOut: timeOut);
}, accessTokenOrAppId);
}
///
/// 设置门店小程序配置的卡券
///
///
///
///
///
///
[ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "StoreApi.SetStoreCardAsync", true)]
public static async Task SetStoreCardAsync(string accessTokenOrAppId, string poiId, string cardId, int timeOut = Config.TIME_OUT)
{
return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
{
var urlFormat = string.Format(Config.ApiMpHost + "/card/storewxa/set?access_token={0}", accessToken.AsUrlData());
var data = new
{
poi_id = poiId,
card_id = cardId
};
return await CommonJsonSend.SendAsync(null, urlFormat, data, timeOut: timeOut);
}, accessTokenOrAppId);
}
#endregion
#endif
}
}