public async Task <BbExpressResponse> AddExpress(BbExpressRequest request) { try { using (HttpClient hc = new HttpClient()) { Dictionary <string, string> dict = new Dictionary <string, string>(); dict.Add("method", "beibei.outer.trade.logistics.ship"); dict.Add("app_id", appId); dict.Add("session", session); dict.Add("timestamp", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); dict.Add("oid", request.Oid); dict.Add("company", request.Company); dict.Add("out_sid", request.Out_sid); if (request.Order_items != null) { dict.Add("order_items", request.Order_items); } string sing = CommonHelper.BbOpera(dict, secret); dict.Add("sign", sing); FormUrlEncodedContent content = new FormUrlEncodedContent(dict); HttpResponseMessage msg = await hc.PostAsync(gateway, content); string res = await msg.Content.ReadAsStringAsync(); return(CommonHelper.DeJson <BbExpressResponse>(res)); } } catch (Exception e) { throw e; } }
/// <summary> /// 获取贝贝网店订单 /// </summary> /// <param name="request"></param> /// <returns></returns> public async Task <BbOrderResponse> GetOrder(BbOrderRequest request) { try { string method = "beibei.outer.trade.order.get"; using (HttpClient hc = new HttpClient()) { Dictionary <string, string> dict = new Dictionary <string, string>(); dict.Add("method", method); dict.Add("app_id", appId); dict.Add("session", session); dict.Add("timestamp", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); dict.Add("time_range", request.TimeRange); dict.Add("start_time", request.StartTime.ToString("yyyy-MM-dd HH:mm:ss")); dict.Add("end_time", request.EndTime.ToString("yyyy-MM-dd HH:mm:ss")); //待发货 dict.Add("status", request.Status.ToString()); dict.Add("page_no", request.PageNo.ToString()); dict.Add("page_size", request.PageSize.ToString()); string sing = CommonHelper.BbOpera(dict, secret); dict.Add("sign", sing); FormUrlEncodedContent content = new FormUrlEncodedContent(dict); HttpResponseMessage msg = await hc.PostAsync(gateway, content); string res = await msg.Content.ReadAsStringAsync(); var resOrders = CommonHelper.DeJson <BbOrderResponse>(res); return(resOrders); } } catch (Exception e) { throw e; } }
public async Task <BbItemResponse> GetItemResponse(int pageNo, int pageSize) { try { string method = "beibei.outer.item.onsale.get"; using (HttpClient hc = new HttpClient()) { Dictionary <string, string> dict = new Dictionary <string, string>(); dict.Add("method", method); dict.Add("app_id", appId); dict.Add("secret", secret); dict.Add("session", session); dict.Add("timestamp", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); dict.Add("version", "1.0"); dict.Add("page_no", pageNo.ToString()); dict.Add("page_size", pageSize.ToString()); string sing = CommonHelper.BbOpera(dict, secret); dict.Add("sign", sing); FormUrlEncodedContent content = new FormUrlEncodedContent(dict); HttpResponseMessage msg = await hc.PostAsync(gateway, content); string res = await msg.Content.ReadAsStringAsync(); var resItems = CommonHelper.DeJson <BbItemResponse>(res); return(resItems); } } catch (Exception e) { throw e; } }
/// <summary> /// 获取所有的物流信息 /// </summary> /// <returns></returns> public async Task <BbCompany[]> GetExpress() { try { using (HttpClient hc = new HttpClient()) { Dictionary <string, string> dict = new Dictionary <string, string>(); dict.Add("method", "beibei.outer.logistics.company.get"); dict.Add("app_id", appId); dict.Add("session", session); dict.Add("timestamp", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); dict.Add("version", "1.0"); string sing = CommonHelper.BbOpera(dict, secret); dict.Add("sign", sing); FormUrlEncodedContent content = new FormUrlEncodedContent(dict); HttpResponseMessage msg = await hc.PostAsync(gateway, content); string res = await msg.Content.ReadAsStringAsync(); var companys = CommonHelper.DeJson <BbCompanyResponse>(res); if (companys.Success) { return(companys.Data); } return(null); } } catch (Exception e) { throw e; } }
public async Task <bool> UpdateItemQty(BbGood good) { try { string method = "beibei.outer.item.qty.update"; using (HttpClient hc = new HttpClient()) { Dictionary <string, string> dict = new Dictionary <string, string>(); dict.Add("method", method); dict.Add("app_id", appId); dict.Add("secret", secret); dict.Add("session", session); dict.Add("timestamp", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); dict.Add("version", "1.0"); dict.Add("iid", good.Iid); dict.Add("sku_id", good.Sku_Id); dict.Add("outer_id", good.Outer_Id); dict.Add("qty", good.Qty); string sing = CommonHelper.BbOpera(dict, secret); dict.Add("sign", sing); FormUrlEncodedContent content = new FormUrlEncodedContent(dict); HttpResponseMessage msg = await hc.PostAsync(gateway, content); string res = await msg.Content.ReadAsStringAsync(); var resQty = CommonHelper.DeJson <BbQtyUpdateResponse>(res); if (resQty != null) { log.Debug("id" + resQty.Data.Iid + "qty" + resQty.Data.Sale_Qty + " " + resQty.Success); return(resQty.Success); } } } catch (Exception e) { throw e; } return(false); }