using BBWY.Client.Models; using BBWY.Common.Http; using BBWY.Common.Models; using System; using System.Collections.Generic; using System.Linq; using System.Net.Http; namespace BBWY.Client.APIServices { public class OrderService : BaseApiService, IDenpendency { public OrderService(RestApiService restApiService, GlobalContext globalContext) : base(restApiService, globalContext) { } public ApiResponse GetOrderList(string orderId, DateTime startDate, DateTime endDate, OrderState? orderState, string sku, string productNo, string waybill, string contactName, int pageIndex, int pageSize, long shopId, bool onlyDF, bool excludeSD, bool excludeCanceled) { return SendRequest(globalContext.BBYWApiHost, "api/order/getOrderList", new { orderId, startDate, endDate, orderState, pageIndex, pageSize, shopId, sku, productNo, waybill, contactName, onlyDF, excludeSD, excludeCanceled }, null, HttpMethod.Post); } /// /// 获取订单详情 /// /// /// public ApiResponse GetOrderById(string orderId) { return SendRequest(globalContext.BBYWApiHost, $"api/order/GetOrderById/{orderId}", null, null, HttpMethod.Get); } /// /// 解密收货人信息 /// /// /// public ApiResponse DecodeConsignee(string orderId, string plaintextMobile) { return SendRequest(globalContext.BBYWApiHost, "Api/Order/DecryptConsignee", new { globalContext.User.Shop.Platform, globalContext.User.Shop.AppKey, globalContext.User.Shop.AppSecret, globalContext.User.Shop.AppToken, saveResponseLog = true, orderId, plaintextMobile, saveDb = true }, null, HttpMethod.Post); } /// /// 自动计算成本 /// /// /// 是否设置仓储类型 /// /// public ApiResponse AutoCalculationCost(string orderId, bool isSetStorageType, StorageType storageType, decimal platformCommissionRatio) { return SendRequest(globalContext.BBYWApiHost, "api/order/AutoCalculationCost", new { orderId, isSetStorageType, storageType, platformCommissionRatio }, null, HttpMethod.Post); } /// /// 手动计算成本 /// /// /// /// /// /// /// public ApiResponse ManualCalculationCost(string orderId, bool isSetStorageType, StorageType storageType, IList manualEditCostOrderSkuList, decimal platformCommissionRatio) { return SendRequest(globalContext.BBYWApiHost, "api/order/ManualCalculationCost", new { orderId, isSetStorageType, storageType, OrderCostDetailList = manualEditCostOrderSkuList.Select(osku => new { SkuId = osku.Id, osku.ConsumableAmount, osku.DeliveryExpressFreight, osku.FirstFreight, DeductionQuantity = osku.ItemTotal, osku.OperationAmount, osku.PurchaseFreight, osku.ProductId, osku.SkuAmount, osku.StorageAmount, osku.TotalCost, osku.UnitCost }), platformCommissionRatio }, null, HttpMethod.Post); } /// /// 设置刷单成本 /// /// /// /// /// /// /// /// /// public ApiResponse SDCalculationCost(string orderId, bool isSetStorageType, decimal sdCommissionAmount, decimal deliveryExpressFreight, SDType sdType, string sdKey, PayBillType? sdPayChannel, string sdPaybillNo, string sdOperator, string flag, string venderRemark, decimal platformCommissionRatio) { return SendRequest(globalContext.BBYWApiHost, "api/order/SDCalculationCost", new { orderId, isSetStorageType, flag, venderRemark, sdType, sdCommissionAmount, deliveryExpressFreight, platformCommissionRatio, sdKey, sdPayChannel, sdPaybillNo, sdOperator, Platform = globalContext.User.Shop.Platform, AppKey = globalContext.User.Shop.AppKey, AppSecret = globalContext.User.Shop.AppSecret, AppToken = globalContext.User.Shop.AppToken }, null, HttpMethod.Post); } /// /// 关联代发订单 /// /// /// /// public ApiResponse RelationPurchaseOrder(OrderDropShipping orderDropShipping, IList relationPurchaseOrderSkuList, decimal platformCommissionRatio) { return SendRequest(globalContext.BBYWApiHost, "api/order/RelationPurchaseOrder", new { orderDropShipping, relationPurchaseOrderSkuList, platformCommissionRatio }, null, HttpMethod.Post); } public ApiResponse OutStock(string orderId, string waybillNo, string logisticsId) { return SendRequest(globalContext.BBYWApiHost, "api/order/outstock", new { orderId, waybillNo, logisticsId, Platform = globalContext.User.Shop.Platform, AppKey = globalContext.User.Shop.AppKey, AppSecret = globalContext.User.Shop.AppSecret, AppToken = globalContext.User.Shop.AppToken }, null, HttpMethod.Post); } public ApiResponse SyncOrder(long shopId, DateTime startTime, DateTime endTime) { return SendRequest(globalContext.BBYWApiHost, "/Api/Order/SyncOrderByDate", new { shopId, startTime, endTime }, null, HttpMethod.Post); } /// /// 修改商家备注 /// /// /// /// /// public ApiResponse EditVenderRemark(string orderId, string venderRemark, string flag) { return SendRequest(globalContext.BBYWApiHost, "api/order/EditVenderRemark", new { orderId, venderRemark, flag, globalContext.User.Shop.Platform, globalContext.User.Shop.AppKey, globalContext.User.Shop.AppSecret, globalContext.User.Shop.AppToken }, null, HttpMethod.Post); } public ApiResponse> ExportOrderList(string orderId, DateTime startDate, DateTime endDate, OrderState? orderState, string sku, string productNo, string waybill, string contactName, int pageIndex, int pageSize, long shopId, bool onlyDF, bool excludeSD, bool excludeCanceled) { return SendRequest>(globalContext.BBYWApiHost, "api/order/ExportOrderList", new { orderId, startDate, endDate, orderState, pageIndex, pageSize, shopId, sku, productNo, waybill, contactName, onlyDF, excludeSD, excludeCanceled }, null, HttpMethod.Post); } } }