diff --git a/TradeManage/HuoWu/HW_GoodsAddForTM.aspx b/TradeManage/HuoWu/HW_GoodsAddForTM.aspx index 258aede..a0c9711 100644 --- a/TradeManage/HuoWu/HW_GoodsAddForTM.aspx +++ b/TradeManage/HuoWu/HW_GoodsAddForTM.aspx @@ -4852,6 +4852,19 @@ function selectE(p,c) { type="button" value="计算" /> + + + temu成本预估: + + + 进价: + +运费: + +货物税费: + +头程: + =预计价格:0$   + + + diff --git a/TradeManage/HuoWu/HW_GoodsDetailList2.aspx b/TradeManage/HuoWu/HW_GoodsDetailList2.aspx index 108329a..f9e3932 100644 --- a/TradeManage/HuoWu/HW_GoodsDetailList2.aspx +++ b/TradeManage/HuoWu/HW_GoodsDetailList2.aspx @@ -3005,6 +3005,7 @@ + diff --git a/TradeManage/HuoWuServiceNew.asmx.cs b/TradeManage/HuoWuServiceNew.asmx.cs index 2aea6a7..fbc2346 100644 --- a/TradeManage/HuoWuServiceNew.asmx.cs +++ b/TradeManage/HuoWuServiceNew.asmx.cs @@ -447,7 +447,15 @@ namespace TradeManage public JsonModel> GetGoodsDetailListNew22(int platid, int MUserId, int cpzt, int GNum, int TJ1, int IsYC, int IsJQ, int StoreId, int AQNum, int AQNum2, string Name, string Supplier, int TJ2, int SNum, int ENum, int cgjh,int kh, int PageIndex, int PageSize, string Sort) { HuoWuData data = new HuoWuData(); - int num = Convert.ToInt32(base.Session["CompanyId"]); + int num = 0; + if (base.Session["CompanyId"] != null) + { + num = Convert.ToInt32(base.Session["CompanyId"]); + } + else + { + num = 1; + } RefParameterCollection where = new RefParameterCollection(); if (IsYC == 0) { @@ -475,7 +483,8 @@ namespace TradeManage where.Add("b.guserid_wayfair", "=", MUserId, DbType.Int32); else if (MUserId != 0 && platid == 21) where.Add("b.guserid_sheIn", "=", MUserId, DbType.Int32); - + else if (MUserId != 0 && platid == 23) + where.Add("b.guserid_temu", "=", MUserId, DbType.Int32); if (AQNum == 1) { where.Add("isnull(a.WestNum,0)-isnull(a.GoodsHJNum12,0)", "<", 0, DbType.Int32); diff --git a/TradeManageNew/APIClients/ShopifyApi/ShopifyAPIClient.cs b/TradeManageNew/APIClients/ShopifyApi/ShopifyAPIClient.cs index b63349a..806ec12 100644 --- a/TradeManageNew/APIClients/ShopifyApi/ShopifyAPIClient.cs +++ b/TradeManageNew/APIClients/ShopifyApi/ShopifyAPIClient.cs @@ -1338,19 +1338,19 @@ namespace APIClients.ShopifyAPI /// 产品重量(g) /// [Newtonsoft.Json.JsonProperty("Weight", Required = Newtonsoft.Json.Required.Always)] - public double Weight { get; set; } + public decimal Weight { get; set; } /// /// 产品价格 /// [Newtonsoft.Json.JsonProperty("JYPrice", Required = Newtonsoft.Json.Required.Always)] - public double JYPrice { get; set; } + public decimal JYPrice { get; set; } /// /// 运费 /// [Newtonsoft.Json.JsonProperty("ShippingFee", Required = Newtonsoft.Json.Required.Always)] - public double ShippingFee { get; set; } + public decimal ShippingFee { get; set; } private System.Collections.Generic.IDictionary _additionalProperties; @@ -2196,7 +2196,7 @@ namespace APIClients.ShopifyAPI /// 产品ID /// [Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public double? Id { get; set; } + public string Id { get; set; } private System.Collections.Generic.IDictionary _additionalProperties; @@ -2216,7 +2216,7 @@ namespace APIClients.ShopifyAPI /// Shopify商品ID /// [Newtonsoft.Json.JsonProperty("shoifyGoodsId", Required = Newtonsoft.Json.Required.Always)] - public double ShoifyGoodsId { get; set; } + public string ShoifyGoodsId { get; set; } /// /// 产品SKU @@ -2254,19 +2254,19 @@ namespace APIClients.ShopifyAPI /// 产品重量(g) /// [Newtonsoft.Json.JsonProperty("Weight", Required = Newtonsoft.Json.Required.Always)] - public double Weight { get; set; } + public decimal Weight { get; set; } /// /// 产品价格 /// [Newtonsoft.Json.JsonProperty("JYPrice", Required = Newtonsoft.Json.Required.Always)] - public double JYPrice { get; set; } + public decimal JYPrice { get; set; } /// /// 运费 /// [Newtonsoft.Json.JsonProperty("ShippingFee", Required = Newtonsoft.Json.Required.Always)] - public double ShippingFee { get; set; } + public decimal ShippingFee { get; set; } private System.Collections.Generic.IDictionary _additionalProperties; diff --git a/TradeManageNew/DD_OrderServiceNew.asmx.cs b/TradeManageNew/DD_OrderServiceNew.asmx.cs index 239ac16..cadacad 100644 --- a/TradeManageNew/DD_OrderServiceNew.asmx.cs +++ b/TradeManageNew/DD_OrderServiceNew.asmx.cs @@ -33,6 +33,7 @@ using Newtonsoft.Json.Serialization; using NPOI.HSSF.Record.Formula.Functions; using static NPOI.HSSF.Util.HSSFColor; using System.Linq.Expressions; +using APIClients.ShopifyAPI; using LinqToDB; using Match = System.Text.RegularExpressions.Match; using TradeManageNew.APIClients.FedexApi.Tests; @@ -28727,18 +28728,247 @@ namespace TradeManageNew } [WebMethod(EnableSession = true)] - public int OrderUsedSalePlatformPrint(int Id) + public APIReturnModel OrderUsedSalePlatformPrint(List Ids) { // PagesNew.Login(base.Session); using (var db = new TradeUsedSale.Repositories.ErpDbContext()) { - var orderUsedSalePlatform = db.DT_OrderUsedSalePlatform - .Where(x => x.Id == Id) + db.DT_OrderUsedSalePlatform + .Where(x => Ids.Contains(x.Id)) .Set(x => x.IsPrinted, true) .Update(); - return orderUsedSalePlatform; + return new APIReturnModel + { + Code = 1, + Message = "Success", + Datas = null + }; + } + } + + [WebMethod(EnableSession = true)] + public APIReturnModel OrderUsedSalePlatformPublish(List Ids) + { + // PagesNew.Login(base.Session); + using (var db = new TradeUsedSale.Repositories.ErpDbContext()) + { + var orderUsedSalePlatformList = db.DT_OrderUsedSalePlatform.Where(x => Ids.Contains(x.Id)).ToList(); + + foreach (var orderUsedSalePlatform in orderUsedSalePlatformList) + { + if (orderUsedSalePlatform.Status != TradeUsedSale.Enums.UsedSalePlatformStatus.NotListed) + { + continue; + } + + //系统产品信息 + var product = db.HW_GoodsInfo.FirstOrDefault(x => x.GoodsId == orderUsedSalePlatform.ProductId); + if (product is null) + { + var message = $"系统中不存在编码为[{orderUsedSalePlatform.ProductCode}]的产品信息,无法推送至Shopify"; + db.DT_OrderUsedSalePlatform.Where(x => x.Id == orderUsedSalePlatform.Id) + .Set(x => x.PublishMessage, message) + .Update(); + + continue; + } + + //毛重 + if (product.Weight is null || product.Weight <= 0) + { + var message = $"产品[{product.GoodsCode}]无毛重信息,无法推送至Shopify"; + db.DT_OrderUsedSalePlatform.Where(x => x.Id == orderUsedSalePlatform.Id) + .Set(x => x.PublishMessage, message) + .Update(); + + continue; + } + + //建议售价 + if (product.JYPrice is null || product.JYPrice <= 0) + { + var message = $"产品[{product.GoodsCode}]无建议售价,无法推送至Shopify"; + db.DT_OrderUsedSalePlatform.Where(x => x.Id == orderUsedSalePlatform.Id) + .Set(x => x.PublishMessage, message) + .Update(); + + continue; + } + + //预估运费 + var postFee = db.HW_PostFee.FirstOrDefault(x => x.GoodsId == orderUsedSalePlatform.ProductId); + if (postFee is null) + { + db.DT_OrderUsedSalePlatform.Where(x => x.Id == orderUsedSalePlatform.Id) + .Set(x => x.PublishMessage, $"产品[{product.GoodsCode}]无预估运费,无法推送至Shopify") + .Update(); + + continue; + } + var fees = new List() + { + postFee.Fee1, + //postFee.Fee2, + postFee.Fee3, + postFee.Fee4, + postFee.Fee5, + //postFee.Fee6, + postFee.Fee7, + postFee.Fee8, + }.Where(x => x != null).ToList(); + var feeCost = fees.Any() ? fees.Min() : 0; + + if (feeCost <= 0) + { + db.DT_OrderUsedSalePlatform.Where(x => x.Id == orderUsedSalePlatform.Id) + .Set(x => x.PublishMessage, $"产品[{product.GoodsCode}]预估运费小于0,无法推送至Shopify") + .Update(); + + continue; + } + + string shopifyProductId; + + //判断时候在Shopify已创建过产品 + var shopifyProductGoodsMap = + db.DT_ShopifyProductGoodsMap.FirstOrDefault(x => x.SkuId == orderUsedSalePlatform.SkuId); + + //获取SKU的资料信息 + var shopifyProductProfile = + db.DT_ShopifyUsedSaleProduct.FirstOrDefault(x => x.Sku == orderUsedSalePlatform.SkuCode); + + //Shopify客户端 + var shopifyApiClient = new ShopifyAPIClient(); + + if (shopifyProductGoodsMap is null) + { + try + { + //在Shopify创建产品信息 + var createShopifyProductParameter = new Body2 + { + ProductBaseData = new ProductBaseData + { + SKU = shopifyProductProfile?.Sku ?? orderUsedSalePlatform.SkuCode, + Title = shopifyProductProfile?.Title ?? product.GoodsEnglisgName, + ImagePath = shopifyProductProfile?.ImagePath ?? product.FirstImgUrl, + ProductType = shopifyProductProfile?.Category, + Tags = shopifyProductProfile?.Tags, + Weight = product.Weight.Value, + JYPrice = product.JYPrice.Value, + ShippingFee = feeCost.Value, + } + }; + var shopifyProductRes = shopifyApiClient.CreateProductAsync(createShopifyProductParameter) + .ConfigureAwait(false) + .GetAwaiter() + .GetResult(); + + if (string.IsNullOrWhiteSpace(shopifyProductRes?.Data?.Id)) + { + var message = $"产品[{product.GoodsCode}]推送Shopify产品失败,原因:{shopifyProductRes.Message}"; + db.DT_OrderUsedSalePlatform.Where(x => x.Id == orderUsedSalePlatform.Id) + .Set(x => x.PublishMessage, message) + .Update(); + + continue; + } + + shopifyProductId = shopifyProductRes.Data.Id; + + var newMap = new TradeUsedSale.Repositories.Models.DT_ShopifyProductGoodsMap + { + ShopifyProductId = shopifyProductId, + SkuId = orderUsedSalePlatform.SkuId, + SkuCode = orderUsedSalePlatform.SkuCode, + CreationTime = DateTime.Now + }; + + db.InsertWithInt32Identity(newMap); + } + catch (Exception ex) + { + var message = $"产品[{product.GoodsCode}]推送Shopify产品失败,原因:{ex.Message}"; + + db.DT_OrderUsedSalePlatform.Where(x => x.Id == orderUsedSalePlatform.Id) + .Set(x => x.PublishMessage, message) + .Update(); + + continue; + } + } + else + { + shopifyProductId = shopifyProductGoodsMap.ShopifyProductId; + } + + + try + { + //在Shopify创建产品变体信息 + var createShopifyVariantParameter = new AddVariantRequest + { + ProductBaseData = new ProductBaseData2 + { + ShoifyGoodsId = shopifyProductId, + SKU = shopifyProductProfile?.Sku ?? orderUsedSalePlatform.SkuCode, + Title = shopifyProductProfile?.Title ?? product.GoodsEnglisgName, + ImagePath = shopifyProductProfile?.ImagePath ?? product.FirstImgUrl, + ProductType = shopifyProductProfile?.Category, + Tags = shopifyProductProfile?.Tags, + Weight = product.Weight.Value, + JYPrice = product.JYPrice.Value, + ShippingFee = feeCost.Value + }, + Variants = new Variants + { + Return_quantity = 1, + StoreName = orderUsedSalePlatform.WarehouseLocation.ToString(), + Code = orderUsedSalePlatform.BarCode, + }, + }; + + var productVariantRes = shopifyApiClient.AddProductVariantAsync(createShopifyVariantParameter).ConfigureAwait(false) + .GetAwaiter() + .GetResult(); + + if (productVariantRes.Success == false) + { + var message = $"产品[{product.GoodsCode}]推送Shopify变体失败,原因:{productVariantRes.Message}"; + db.DT_OrderUsedSalePlatform.Where(x => x.Id == orderUsedSalePlatform.Id) + .Set(x => x.PublishMessage, message) + .Update(); + + continue; + } + + //推送Shopify成功 + db.DT_OrderUsedSalePlatform.Where(x => x.Id == orderUsedSalePlatform.Id) + .Set(x => x.Status, TradeUsedSale.Enums.UsedSalePlatformStatus.Listed) + .Set(x => x.PublishMessage, "推送成功") + .Update(); + + } + catch (Exception ex) + { + var message = $"产品[{product.GoodsCode}]推送Shopify变体失败,原因:{ex.Message}"; + + db.DT_OrderUsedSalePlatform.Where(x => x.Id == orderUsedSalePlatform.Id) + .Set(x => x.PublishMessage, message) + .Update(); + + continue; + } + } } + + return new APIReturnModel + { + Code = 1, + Message = "Success", + Datas = null + }; } #endregion diff --git a/TradeManageNew/DataNew.cs b/TradeManageNew/DataNew.cs index 0dbaa67..1977aa0 100644 --- a/TradeManageNew/DataNew.cs +++ b/TradeManageNew/DataNew.cs @@ -30614,10 +30614,10 @@ select @id"; try { string tsql = @" -SELECT a.[ID],a.[GoodsId],c.GoodsCode,[JinJia],[YunFei],[TouCheng],[HuoWuShuiFei],[YuGuJiaGe],[CreateUserId],[CreateTime] - FROM [newerpbak_cwk].[dbo].[TemuChengBen] a +SELECT top 1 a.[ID],a.[GoodsId],c.GoodsCode,[JinJia],[YunFei],[TouCheng],[HuoWuShuiFei],[YuGuJiaGe],[CreateUserId],[CreateTime] + FROM [dbo].[TemuChengBen] a inner join HW_GoodsInfo c on a.GoodsId=c.GoodsId -where a.GoodsId = @GoodsId "; +where a.GoodsId = @GoodsId order by a.CreateTime desc"; Database db = DatabaseFactory.CreateDatabase(); DbCommand cmd = db.GetSqlStringCommand(tsql); db.AddInParameter(cmd, "@GoodsId", DbType.Int32, GoodsId); diff --git a/TradeManageNew/HuoWuServiceNew.asmx.cs b/TradeManageNew/HuoWuServiceNew.asmx.cs index ff88dda..3b2a81e 100644 --- a/TradeManageNew/HuoWuServiceNew.asmx.cs +++ b/TradeManageNew/HuoWuServiceNew.asmx.cs @@ -451,7 +451,18 @@ namespace TradeManageNew public JsonModel> GetGoodsDetailListNew22(int platid,int MUserId,int cpzt,int GNum, int TJ1, int IsYC, int IsJQ, int StoreId, int AQNum, int AQNum2, string Name, string Supplier, int TJ2, int SNum, int ENum, int cgjh, int kh, int PageIndex, int PageSize, string Sort) { HuoWuData data = new HuoWuData(); - int num = Convert.ToInt32(base.Session["CompanyId"]); + int num = 0; + if (base.Session["CompanyId"] != null) + { + num = Convert.ToInt32(base.Session["CompanyId"]); + } + else + { + num = 1; + } + + + RefParameterCollection where = new RefParameterCollection(); if (cpzt > 0) { @@ -497,6 +508,8 @@ namespace TradeManageNew where.Add("b.guserid_wayfair", "=", MUserId, DbType.Int32); else if (MUserId != 0 && platid == 21) where.Add("b.guserid_sheIn", "=", MUserId, DbType.Int32); + else if (MUserId != 0 && platid == 23) + where.Add("b.guserid_temu", "=", MUserId, DbType.Int32); if (AQNum == 1) { diff --git a/TradeUsedSale/Repositories/ErpDbContext.cs b/TradeUsedSale/Repositories/ErpDbContext.cs index 81117e0..f87e4c6 100644 --- a/TradeUsedSale/Repositories/ErpDbContext.cs +++ b/TradeUsedSale/Repositories/ErpDbContext.cs @@ -27,5 +27,8 @@ namespace TradeUsedSale.Repositories public ITable JC_Shop => this.GetTable(); public ITable JC_UserInfo => this.GetTable(); public ITable CK_StorePostion => this.GetTable(); + public ITable DT_ShopifyUsedSaleProduct => this.GetTable(); + public ITable DT_ShopifyProductGoodsMap => this.GetTable(); + public ITable HW_PostFee => this.GetTable(); } } diff --git a/TradeUsedSale/Repositories/Models/DT_OrderUsedSalePlatform.cs b/TradeUsedSale/Repositories/Models/DT_OrderUsedSalePlatform.cs index f4cba8a..cc1849f 100644 --- a/TradeUsedSale/Repositories/Models/DT_OrderUsedSalePlatform.cs +++ b/TradeUsedSale/Repositories/Models/DT_OrderUsedSalePlatform.cs @@ -92,5 +92,10 @@ namespace TradeUsedSale.Repositories.Models /// 修改人 /// public int? LastModifierId { get; set; } + + /// + /// 推送至平台信息 + /// + public string PublishMessage { get; set; } } } \ No newline at end of file diff --git a/TradeUsedSale/Repositories/Models/DT_ShopifyProductGoodsMap.cs b/TradeUsedSale/Repositories/Models/DT_ShopifyProductGoodsMap.cs new file mode 100644 index 0000000..804f137 --- /dev/null +++ b/TradeUsedSale/Repositories/Models/DT_ShopifyProductGoodsMap.cs @@ -0,0 +1,30 @@ +using System; +using LinqToDB.Mapping; + +namespace TradeUsedSale.Repositories.Models +{ + /// + /// Shopify产品与系统SKU映射 + /// + public class DT_ShopifyProductGoodsMap + { + [PrimaryKey, Identity] public int Id { get; set; } + + /// + /// Shopify产品Id + /// + public string ShopifyProductId { get; set; } + + /// + /// 系统SKU ID + /// + public int SkuId { get; set; } + + public string SkuCode { get; set; } + + /// + /// 创建时间 + /// + public DateTime CreationTime { get; set; } + } +} \ No newline at end of file diff --git a/TradeUsedSale/Repositories/Models/DT_ShopifyUsedSaleProduct.cs b/TradeUsedSale/Repositories/Models/DT_ShopifyUsedSaleProduct.cs new file mode 100644 index 0000000..b47b884 --- /dev/null +++ b/TradeUsedSale/Repositories/Models/DT_ShopifyUsedSaleProduct.cs @@ -0,0 +1,17 @@ +using LinqToDB.Mapping; + +namespace TradeUsedSale.Repositories.Models +{ + /// + /// Shopify产品资料 + /// + public class DT_ShopifyUsedSaleProduct + { + [PrimaryKey, Identity] public int Id { get; set; } + public string Sku { get; set; } + public string Title { get; set; } + public string ImagePath { get; set; } + public string Category { get; set; } + public string Tags { get; set; } + } +} \ No newline at end of file diff --git a/TradeUsedSale/Repositories/Models/HW_PostFee.cs b/TradeUsedSale/Repositories/Models/HW_PostFee.cs new file mode 100644 index 0000000..d01f36a --- /dev/null +++ b/TradeUsedSale/Repositories/Models/HW_PostFee.cs @@ -0,0 +1,19 @@ +using LinqToDB.Mapping; + +namespace TradeUsedSale.Repositories.Models +{ + public class HW_PostFee + { + [PrimaryKey, Identity] + public int Id { get; set; } + public int? GoodsId { get; set; } + public decimal? Fee1 { get; set; } + public decimal? Fee2 { get; set; } + public decimal? Fee3 { get; set; } + public decimal? Fee4 { get; set; } + public decimal? Fee5 { get; set; } + public decimal? Fee6 { get; set; } + public decimal? Fee7 { get; set; } + public decimal? Fee8 { get; set; } + } +} \ No newline at end of file diff --git a/TradeUsedSale/TradeUsedSale.csproj b/TradeUsedSale/TradeUsedSale.csproj index 5068fe5..66be4d3 100644 --- a/TradeUsedSale/TradeUsedSale.csproj +++ b/TradeUsedSale/TradeUsedSale.csproj @@ -56,8 +56,11 @@ + + +