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 productId, string productNo, string waybill, string contactName, int pageIndex, int pageSize, long? shopId, bool onlyDF, bool excludeSD, bool excludeCanceled, bool includeExceptionOrder, string sdOperator) { return SendRequest(globalContext.BBYWApiHost, "api/order/getOrderList", new { orderId, startDate, endDate, orderState, pageIndex, pageSize, shopId, sku, productId, productNo, waybill, contactName, onlyDF, excludeSD, excludeCanceled, includeExceptionOrder, sdOperator }, 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.InStorageAmount, osku.OutStorageAmount, 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 sdOrderAmount, decimal deliveryExpressFreight, SDType sdType, string sdKey, PayBillType? sdPayChannel, string sdPaybillNo, string sdOperator, string flag, string venderRemark, Shop shop) { return SendRequest(globalContext.BBYWApiHost, "api/order/SDCalculationCost", new { orderId, isSetStorageType, flag, venderRemark, sdType, sdCommissionAmount, sdOrderAmount, deliveryExpressFreight, platformCommissionRatio = shop.PlatformCommissionRatio ?? 0.05M, sdKey, sdPayChannel, sdPaybillNo, sdOperator, Platform = shop.Platform, AppKey = shop.AppKey, AppSecret = shop.AppSecret, AppToken = shop.AppToken }, null, HttpMethod.Post); } public ApiResponse RelationPurchaseOrderV2(IList orderDropShippingList, decimal platformCommissionRatio) { return SendRequest(globalContext.BBYWApiHost, "api/order/RelationPurchaseOrderV2", new { orderDropShippingList, 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/OrderSync/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, string sdOperator) { return SendRequest>(globalContext.BBYWApiHost, "api/order/ExportOrderList", new { orderId, startDate, endDate, orderState, pageIndex, pageSize, shopId, sku, productNo, waybill, contactName, onlyDF, excludeSD, excludeCanceled, sdOperator }, null, HttpMethod.Post); } public ApiResponse SDGroupPullOrder(string orderId, Shop shop) { return SendRequest(globalContext.BBYWApiHost, "Api/Order/SDGroupPullOrder", new { orderId, shop.ShopId, shop.Platform, shop.AppKey, shop.AppSecret, shop.AppToken }, null, HttpMethod.Post); } } }