From 2249b805c56996259c9c426402f4ec1f5b32476a Mon Sep 17 00:00:00 2001 From: chenwenkai <1084072318@qq.com> Date: Mon, 17 Feb 2025 14:44:36 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=80=E8=B4=A7=E6=9B=B4=E6=94=B9=EF=BC=8Cte?= =?UTF-8?q?mu=E6=B4=BB=E5=8A=A8=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TradeManageNew/DataNew.cs | 13 ++ TradeManageNew/HuoWuServiceNew.asmx.cs | 108 ++++++++++++++++ .../SelfPickupOrderUsedSalePlatformInput.cs | 4 + .../OrderUsedSalePlatformPageDto.cs | 4 + .../OuterService/ShageService.ashx.cs | 117 +++++++++++++----- TradeUsedSale/Enums/UsedSalePlatformStatus.cs | 11 +- .../Models/DT_OrderUsedSalePlatform.cs | 5 + 7 files changed, 229 insertions(+), 33 deletions(-) diff --git a/TradeManageNew/DataNew.cs b/TradeManageNew/DataNew.cs index 56e9bb8..ca32513 100644 --- a/TradeManageNew/DataNew.cs +++ b/TradeManageNew/DataNew.cs @@ -28582,6 +28582,19 @@ end"; var dt = db.ExecuteDataTable(cmd); return dt.ToList(); } + + public static List GetTemuShopGoodActive(int shopid, string sku, string SKUID) + { + var sql = @" select * from TemuShopGoodActive where Shopid=@shopid and SKU=@sku and SPUID=@SKUID "; + + var db = DatabaseFactory.CreateDatabase(); + var cmd = db.GetSqlStringCommand(sql); + db.AddInParameter(cmd, "@shopid", DbType.Int32, shopid); + db.AddInParameter(cmd, "@SKU", DbType.String, sku); + db.AddInParameter(cmd, "@SKUID", DbType.String, SKUID); + var dt = db.ExecuteDataTable(cmd); + return dt.ToList(); + } public static TemuShopGoodPrice GetTemuShopGoodPriceOne(int shopid, string spuid) { var sql = @" select top 1 * from TemuShopGoodPrice where Shopid=@shopid and spuid=@spuid "; diff --git a/TradeManageNew/HuoWuServiceNew.asmx.cs b/TradeManageNew/HuoWuServiceNew.asmx.cs index 6e2df2f..e23b636 100644 --- a/TradeManageNew/HuoWuServiceNew.asmx.cs +++ b/TradeManageNew/HuoWuServiceNew.asmx.cs @@ -7385,6 +7385,114 @@ namespace TradeManageNew } } + //temu 活动导入 + [WebMethod(EnableSession = true)] + public APIReturnModel ImportTemuHuoDongPrices(string filePath) + { + PagesNew.Login(this.Session); + var userid = Convert.ToInt32(base.Session["UserId"]); + string ServerFileName = AppDomain.CurrentDomain.BaseDirectory + filePath; + var rmodel = new APIReturnModel(); + try + { + MicrosoftExcel excel = new MicrosoftExcel(); + DataTable tb = excel.ImportExcel(ServerFileName); + + string error = ""; + if (tb.Columns.Contains("店铺名") == false) { error = error + "导入模板的 店铺名 列不存在"; } + if (tb.Columns.Contains("SKU") == false) { error = error + "导入模板的 SKU 列不存在"; } + if (tb.Columns.Contains("SKUID") == false) { error = error + "导入模板的 SKUID 列不存在"; } + if (tb.Columns.Contains("价格") == false) { error = error + "导入模板的 价格 列不存在"; } + + if (string.IsNullOrEmpty(error) == false) + { + rmodel.Code = 0; + rmodel.Message = error; + } + var goods = new List(); + StringBuilder sb = new StringBuilder(); + + for (int i = 0; i < tb.Rows.Count; i++) + { + var shopName = tb.Rows[i]["店铺名"].ToString(); + if (string.IsNullOrEmpty(shopName)) + { + sb.Append("第" + (i + 1).ToString() + "行店铺名不能为空;"); + continue; + } + var shop = DataNew.GetShopByShopName(shopName); + if (shop == null) + { + sb.Append("第" + (i + 1).ToString() + "行店铺名:" + shopName + "不存在;"); + continue; + } + + var sku = tb.Rows[i]["SKU"].ToString(); + if (string.IsNullOrEmpty(sku)) + { + sb.Append("第" + (i + 1).ToString() + "行SKU不能为空;"); + continue; + } + + + var SKUID = tb.Rows[i]["SKUID"].ToString(); + if (string.IsNullOrEmpty(SKUID)) + { + sb.Append("第" + (i + 1).ToString() + "行SKUID不能为空;"); + continue; + } + + if (string.IsNullOrEmpty(tb.Rows[i]["价格"].ToString())) + { + sb.Append("第" + (i + 1).ToString() + "行价格不能为空;"); + continue; + } + + var data = DataNew.GetTemuShopGoodPrice(shop.ShopId.Value, sku, SKUID); + if (data != null) + { + sb.Append("第" + (i + 1).ToString() + "行已存在相同数据;"); + continue; + } + + var md = new TemuShopGoodActive() + { + Shopid = shop.ShopId.Value, + SPUID = SKUID, + SKU = sku, + BasePrice = Convert.ToDecimal(tb.Rows[i]["价格"]), + CreateUserId = userid, + }; + + goods.Add(md); + } + + if (sb.Length > 0) + { + rmodel.Code = 0; + rmodel.Message = sb.ToString(); + return rmodel; + } + + foreach (var md in goods) + { + DataNew.Save_TemuShopGoodActive(md); + } + + rmodel.Code = 1; + rmodel.Message = ""; + return rmodel; + } + catch (Exception ex) + { + rmodel.Code = 0; + rmodel.Message = ex.Message; + return rmodel; + } + } + + + [WebMethod(EnableSession = true)] public APIReturnModel DeleteTemuShopGoodPrice(int id) diff --git a/TradeManageNew/Models/Shage/SelfPickupOrderUsedSalePlatformInput.cs b/TradeManageNew/Models/Shage/SelfPickupOrderUsedSalePlatformInput.cs index f0de104..3d5fe08 100644 --- a/TradeManageNew/Models/Shage/SelfPickupOrderUsedSalePlatformInput.cs +++ b/TradeManageNew/Models/Shage/SelfPickupOrderUsedSalePlatformInput.cs @@ -7,5 +7,9 @@ namespace TradeManageNew.Models.Shage public List Ids { get; set; } public int UserId { get; set; } + + public int Status { get; set; } + + public string imgList { get; set; } } } \ No newline at end of file diff --git a/TradeManageNew/Models/ShopifyUsedSale/OrderUsedSalePlatformPageDto.cs b/TradeManageNew/Models/ShopifyUsedSale/OrderUsedSalePlatformPageDto.cs index ef0f3e5..113efa4 100644 --- a/TradeManageNew/Models/ShopifyUsedSale/OrderUsedSalePlatformPageDto.cs +++ b/TradeManageNew/Models/ShopifyUsedSale/OrderUsedSalePlatformPageDto.cs @@ -107,5 +107,9 @@ namespace TradeManageNew.Models.ShopifyUsedSale /// TrackingCode /// public string TrackingCode { get; set; } + /// + /// imgList + /// + public string imgList { get; set; } } } \ No newline at end of file diff --git a/TradeManageNew/OuterService/ShageService.ashx.cs b/TradeManageNew/OuterService/ShageService.ashx.cs index b2f134d..e499477 100644 --- a/TradeManageNew/OuterService/ShageService.ashx.cs +++ b/TradeManageNew/OuterService/ShageService.ashx.cs @@ -23,6 +23,7 @@ using System.Windows.Forms; using TradeData; using NetLibrary.Data; using NetLibrary.ReportPrint; +using TradeManageNew.APIClients.ShopifyAPI; namespace TradeManageNew.OuterService { @@ -1748,36 +1749,60 @@ namespace TradeManageNew.OuterService if (orderUsedSalePlatform is null) { - throw new Exception( - $"No barcode for {input.BarCode} to be shipped used sale item exists"); - } - - var product = db.HW_GoodsInfo.FirstOrDefault(x => x.GoodsId == orderUsedSalePlatform.ProductId); + //throw new Exception( + // $"No barcode for {input.BarCode} to be shipped used sale item exists"); + + + orderUsedSalePlatform= db.DT_OrderUsedSalePlatform.FirstOrDefault(x => + x.BarCode == input.BarCode); + var product = db.HW_GoodsInfo.FirstOrDefault(x => x.GoodsId == orderUsedSalePlatform.ProductId); - var result = new GetPickupOrderUsedSalePlatformDto + var result = new GetPickupOrderUsedSalePlatformDto + { + Id = orderUsedSalePlatform.Id, + + ProductDescription = product?.GoodsEnglisgName, + SkuId = orderUsedSalePlatform.SkuId, + SkuCode = orderUsedSalePlatform.SkuCode, + BarCode = orderUsedSalePlatform.BarCode, + + }; + + md.Code = "100"; + md.Result = "Success"; + md.Data = JsonConvert.SerializeObject(result); + } + else { - Id = orderUsedSalePlatform.Id, - ProductId = orderUsedSalePlatform.ProductId, - ProductCode = orderUsedSalePlatform.ProductCode, - ProductDescription = product?.GoodsEnglisgName, - SkuId = orderUsedSalePlatform.SkuId, - SkuCode = orderUsedSalePlatform.SkuCode, - BarCode = orderUsedSalePlatform.BarCode, - IsPrinted = orderUsedSalePlatform.IsPrinted, - Status = orderUsedSalePlatform.Status, - WarehouseLocation =orderUsedSalePlatform.WarehouseLocation, - WarehousePositionId = orderUsedSalePlatform.WarehousePositionId, - WarehousePositionCode = orderUsedSalePlatform.WarehousePositionCode, - ImageUrls = JsonConvert.DeserializeObject>(orderUsedSalePlatform.ImageUrls), - ShippingMethod = orderUsedSalePlatform.ShippingMethod, - IsNew = orderUsedSalePlatform.IsNew, - CreationTime = orderUsedSalePlatform.CreationTime, - CreatorId = orderUsedSalePlatform.CreatorId - }; + var product = db.HW_GoodsInfo.FirstOrDefault(x => x.GoodsId == orderUsedSalePlatform.ProductId); + + var result = new GetPickupOrderUsedSalePlatformDto + { + Id = orderUsedSalePlatform.Id, + ProductId = orderUsedSalePlatform.ProductId, + ProductCode = orderUsedSalePlatform.ProductCode, + ProductDescription = product?.GoodsEnglisgName, + SkuId = orderUsedSalePlatform.SkuId, + SkuCode = orderUsedSalePlatform.SkuCode, + BarCode = orderUsedSalePlatform.BarCode, + IsPrinted = orderUsedSalePlatform.IsPrinted, + Status = orderUsedSalePlatform.Status, + WarehouseLocation = orderUsedSalePlatform.WarehouseLocation, + WarehousePositionId = orderUsedSalePlatform.WarehousePositionId, + WarehousePositionCode = orderUsedSalePlatform.WarehousePositionCode, + ImageUrls = JsonConvert.DeserializeObject>(orderUsedSalePlatform.ImageUrls), + ShippingMethod = orderUsedSalePlatform.ShippingMethod, + IsNew = orderUsedSalePlatform.IsNew, + CreationTime = orderUsedSalePlatform.CreationTime, + CreatorId = orderUsedSalePlatform.CreatorId + }; + + md.Code = "100"; + md.Result = "Success"; + md.Data = JsonConvert.SerializeObject(result); + } - md.Code = "100"; - md.Result = "Success"; - md.Data = JsonConvert.SerializeObject(result); + } } } @@ -2008,23 +2033,51 @@ namespace TradeManageNew.OuterService if (Method == "SelfPickupOrderUsedSalePlatform") { var input = JsonConvert.DeserializeObject(ResponseContent); - + using (var db = new ErpDbContext()) { + var exPlatformList = db.DT_OrderUsedSalePlatform.Where(x => + input.Ids.Contains(x.Id)) + .ToList(); + //如果传入的状态不是4,并且之前的状态是2则需要删除变体 + foreach (var i in exPlatformList) + { + if (input.Status != 4 && (int)i.Status == 2) + { + var shopifyApiClient = new ShopifyAPIClient(); + var productVariantRes = shopifyApiClient.DeleteProductVariantAsync(new Body3 + { + ProductId = i.ProductId.ToString(), + Code = i.ProductCode, + }).ConfigureAwait(false) + .GetAwaiter() + .GetResult(); + + //if (productVariantRes.Success != true) + //{ + // throw new Exception($"删除Shopify条码[{item.ProductCode}]变体失败,{productVariantRes.Message}"); + //} + + } + + } + var orderUsedSalePlatformList = db.DT_OrderUsedSalePlatform.Where(x => input.Ids.Contains(x.Id) - && x.Status == UsedSalePlatformStatus.PendingPickup) + && x.Status == (UsedSalePlatformStatus)input.Status) .ToList(); - + + if (orderUsedSalePlatformList.Any()) { db.DT_OrderUsedSalePlatform.Where(x => input.Ids.Contains(x.Id) - && x.Status == UsedSalePlatformStatus.PendingPickup) + && x.Status == (UsedSalePlatformStatus)input.Status) .Set(x => x.ShippingMethod, ShippingMethod.SelfPickup) - .Set(x => x.Status, UsedSalePlatformStatus.Sold) + .Set(x => x.Status, (UsedSalePlatformStatus)input.Status) .Set(x => x.LastModifierId, input.UserId) .Set(x => x.LastModificationTime, DateTime.Now) + .Set(x => x.imgList, input.imgList) .Update(); } } diff --git a/TradeUsedSale/Enums/UsedSalePlatformStatus.cs b/TradeUsedSale/Enums/UsedSalePlatformStatus.cs index 717227a..22eb1f1 100644 --- a/TradeUsedSale/Enums/UsedSalePlatformStatus.cs +++ b/TradeUsedSale/Enums/UsedSalePlatformStatus.cs @@ -22,6 +22,15 @@ namespace TradeUsedSale.Enums /// /// 售卖完成 /// - [Description("售卖完成")] Sold + [Description("售卖完成")] Sold, + + /// + /// 使用配件 + /// + [Description("使用配件")] PeiJian , + /// + /// 现场出售 + /// + [Description("现场出售")] XcChuShou } } \ No newline at end of file diff --git a/TradeUsedSale/Repositories/Models/DT_OrderUsedSalePlatform.cs b/TradeUsedSale/Repositories/Models/DT_OrderUsedSalePlatform.cs index 9e3699f..8fd0c2c 100644 --- a/TradeUsedSale/Repositories/Models/DT_OrderUsedSalePlatform.cs +++ b/TradeUsedSale/Repositories/Models/DT_OrderUsedSalePlatform.cs @@ -117,5 +117,10 @@ namespace TradeUsedSale.Repositories.Models /// 运费 /// public decimal TotalNetCharge { get; set; } + + /// + /// 运费 + /// + public string imgList { get; set; } } } \ No newline at end of file