123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265 |
- #region Apache License Version 2.0
- #endregion Apache License Version 2.0
- using System;
- using System.Threading.Tasks;
- using Senparc.CO2NET.Helpers;
- using Senparc.CO2NET.Helpers.Serializers;
- using Senparc.NeuChar;
- using Senparc.Weixin.CommonAPIs;
- using Senparc.Weixin.Entities;
- using Senparc.Weixin.Helpers;
- using Senparc.Weixin.MP.CommonAPIs;
- namespace Senparc.Weixin.MP.AdvancedAPIs.MerChant
- {
-
-
-
- public static class OrderApi
- {
- #region 同步方法
-
-
-
-
-
-
-
-
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "OrderApi.GetByIdOrder", true)]
- public static GetByIdOrderResult GetByIdOrder(string accessToken, string orderId)
- {
- var urlFormat = Config.ApiMpHost + "/merchant/order/getbyid?access_token={0}";
- var data = new
- {
- order_id = orderId
- };
- return CommonJsonSend.Send<GetByIdOrderResult>(accessToken, urlFormat, data);
- }
-
-
-
-
-
-
-
-
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "OrderApi.GetByFilterOrder", true)]
- public static GetByFilterResult GetByFilterOrder(string accessToken, int? status, DateTime? beginTime, DateTime? endTime)
- {
- var urlFormat = Config.ApiMpHost + "/merchant/order/getbyfilter?access_token={0}";
- var data = new
- {
- status = status,
- begintime = beginTime.HasValue ? DateTimeHelper.GetUnixDateTime(beginTime.Value) : (long?)null,
- endtime = endTime.HasValue ? DateTimeHelper.GetUnixDateTime(endTime.Value) : (long?)null
- };
- return CommonJsonSend.Send<GetByFilterResult>(accessToken, urlFormat, data,jsonSetting:new JsonSetting(true));
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "OrderApi.SetdeliveryOrder", true)]
- public static WxJsonResult SetdeliveryOrder(string accessToken, string orderId, string deliveryCompany, string deliveryTrackNo, int needDelivery = 1, int isOthers = 0)
- {
- var urlFormat = Config.ApiMpHost + "/merchant/order/setdelivery?access_token={0}";
- var data = new
- {
- order_id = orderId,
- delivery_company = deliveryCompany,
- delivery_track_no = deliveryTrackNo,
- need_delivery = needDelivery,
- is_others = isOthers
- };
- return CommonJsonSend.Send<WxJsonResult>(accessToken, urlFormat, data);
- }
-
-
-
-
-
-
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "OrderApi.CloseOrder", true)]
- public static WxJsonResult CloseOrder(string accessToken, string orderId)
- {
- var urlFormat = Config.ApiMpHost + "/merchant/order/close?access_token={0}";
- var data = new
- {
- order_id = orderId
- };
- return CommonJsonSend.Send<WxJsonResult>(accessToken, urlFormat, data);
- }
- #endregion
- #if !NET35 && !NET40
- #region 异步方法
-
-
-
-
-
-
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "OrderApi.GetByIdOrderAsync", true)]
- public static async Task<GetByIdOrderResult> GetByIdOrderAsync(string accessToken, string orderId)
- {
- var urlFormat = Config.ApiMpHost + "/merchant/order/getbyid?access_token={0}";
- var data = new
- {
- order_id = orderId
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<GetByIdOrderResult>(accessToken, urlFormat, data);
- }
-
-
-
-
-
-
-
-
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "OrderApi.GetByFilterOrderAsync", true)]
- public static async Task<GetByFilterResult> GetByFilterOrderAsync(string accessToken, int? status, DateTime? beginTime, DateTime? endTime)
- {
- var urlFormat = Config.ApiMpHost + "/merchant/order/getbyfilter?access_token={0}";
- var data = new
- {
- status = status,
- begintime = beginTime.HasValue ? DateTimeHelper.GetUnixDateTime(beginTime.Value) : (long?)null,
- endtime = endTime.HasValue ? DateTimeHelper.GetUnixDateTime(endTime.Value) : (long?)null
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<GetByFilterResult>(accessToken, urlFormat, data, jsonSetting: new JsonSetting(true));
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "OrderApi.SetdeliveryOrderAsync", true)]
- public static async Task<WxJsonResult> SetdeliveryOrderAsync(string accessToken, string orderId, string deliveryCompany, string deliveryTrackNo, int needDelivery = 1, int isOthers = 0)
- {
- var urlFormat = Config.ApiMpHost + "/merchant/order/setdelivery?access_token={0}";
- var data = new
- {
- order_id = orderId,
- delivery_company = deliveryCompany,
- delivery_track_no = deliveryTrackNo,
- need_delivery = needDelivery,
- is_others = isOthers
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(accessToken, urlFormat, data);
- }
-
-
-
-
-
-
- [ApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, "OrderApi.CloseOrderAsync", true)]
- public static async Task<WxJsonResult> CloseOrderAsync(string accessToken, string orderId)
- {
- var urlFormat = Config.ApiMpHost + "/merchant/order/close?access_token={0}";
- var data = new
- {
- order_id = orderId
- };
- return await Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync<WxJsonResult>(accessToken, urlFormat, data);
- }
- #endregion
- #endif
- }
- }
|