diff --git a/BBWYB.Client/APIServices/PurchaseProductAPIService.cs b/BBWYB.Client/APIServices/PurchaseProductAPIService.cs index 4ad8e49..17b0308 100644 --- a/BBWYB.Client/APIServices/PurchaseProductAPIService.cs +++ b/BBWYB.Client/APIServices/PurchaseProductAPIService.cs @@ -25,6 +25,10 @@ namespace BBWYB.Client.APIServices private IDictionary _1688ProductDetailRequestHeader; + private List _1688ColorPropertyFieldIdList; + private List locationIdList; + private List priceIdList; + public PurchaseProductAPIService(RestApiService restApiService, IMemoryCache memoryCache) { this.restApiService = restApiService; @@ -38,6 +42,10 @@ namespace BBWYB.Client.APIServices { "Accept-Language","zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6"} }; purchaseProductCacheTimeSpan = TimeSpan.FromDays(1); + + _1688ColorPropertyFieldIdList = new List() { 3216, 1627207, 1234, 3151, 7853, 446, 374, 404, 100019516, 3114, 2068 }; + locationIdList = new List() { "1081181309101", "16347413030323", "13772573013156" }; + priceIdList = new List() { "1081181309582", "1081181309582", "16347413030316", "13772573013151" }; } public (Purchaser purchaser, IList purchaseSchemeProductSkus)? GetProductInfo(Platform platform, string productId, string skuId, string purchaseProductId, PurchaseOrderMode priceMode, PurchaseProductAPIMode apiMode) @@ -186,31 +194,47 @@ namespace BBWYB.Client.APIServices var jsonStr = match.Groups[2].Value; var jobject = JObject.Parse(jsonStr); + var location = ""; + for (var i = 0; i < locationIdList.Count(); i++) + { + if (jobject["data"][locationIdList[i]] != null) + { + location = jobject["data"][locationIdList[i]]["data"]["location"].ToString(); + break; + } + } + //16347413030323 var purchaser = new Purchaser() { Id = jobject["globalData"]["tempModel"]["sellerUserId"].ToString(), Id2 = jobject["globalData"]["tempModel"]["sellerLoginId"]?.ToString(), Name = jobject["globalData"]["tempModel"]["companyName"].ToString(), - Location = jobject["data"]["1081181309101"] != null ? - jobject["data"]["1081181309101"]["data"]["location"].ToString() : - jobject["data"]["16347413030323"]["data"]["location"].ToString() + Location = location, + Platform = platform }; - var colorsProperty = jobject["globalData"]["skuModel"]["skuProps"].FirstOrDefault(j => j.Value("fid") == 3216 || - j.Value("fid") == 1627207 || - j.Value("fid") == 1234 || - j.Value("fid") == 3151)["value"] - .Children() - .Select(j => new - { - name = j.Value("name"), - imageUrl = j.Value("imageUrl") - }).ToList(); - - var firstPrice = jobject["data"]["1081181309582"] != null ? - jobject["data"]["1081181309582"]["data"]["priceModel"]["currentPrices"][0].Value("price") : - jobject["data"]["16347413030316"]["data"]["priceModel"]["currentPrices"][0].Value("price"); + var fidJToken = jobject["globalData"]["skuModel"]["skuProps"].FirstOrDefault(j => _1688ColorPropertyFieldIdList.Contains(j.Value("fid"))); + if (fidJToken == null) + fidJToken = jobject["globalData"]["skuModel"]["skuProps"].FirstOrDefault(j => j.Value("prop").Contains("颜色")); + if (fidJToken == null && jobject["globalData"]["skuModel"]["skuProps"].Children().Count() == 1) + fidJToken = jobject["globalData"]["skuModel"]["skuProps"].FirstOrDefault(); + var colorsProperty = fidJToken["value"].Children() + .Select(j => new + { + name = j.Value("name"), + imageUrl = j.Value("imageUrl") + }).ToList(); + + var firstPrice = 0.0M; + for (var i = 0; i < priceIdList.Count(); i++) + { + if (jobject["data"][priceIdList[i]] != null) + { + firstPrice = jobject["data"][priceIdList[i]]["data"]["priceModel"]["currentPrices"][0].Value("price"); + break; + } + } var purchaseSchemeProductSkus = new List(); diff --git a/BBWYB.Client/GlobalContext.cs b/BBWYB.Client/GlobalContext.cs index 02ac109..dcc7452 100644 --- a/BBWYB.Client/GlobalContext.cs +++ b/BBWYB.Client/GlobalContext.cs @@ -1,4 +1,5 @@ using BBWYB.Client.APIServices; +using BBWYB.Client.Helpers; using BBWYB.Client.Models; using BBWYB.Client.ViewModels; using BBWYB.Client.Views.PackPurchaseTaska; @@ -7,6 +8,7 @@ using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Messaging; using Microsoft.Extensions.DependencyInjection; using Newtonsoft.Json; +using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Windows; @@ -20,7 +22,7 @@ namespace BBWYB.Client { public GlobalContext() { - BBWYBApiVersion = "10029"; + BBWYBApiVersion = "10030"; } private User user; @@ -57,6 +59,25 @@ namespace BBWYB.Client return BBWYBApiVersion; } + public void CallALiWangWang(string sellerLoginId) + { + var url = $"aliim:sendmsg?siteid=cnalichn&portalId=&gid=&itemsId=&touid=cnalichn{sellerLoginId}&status=1"; + try + { + //Process.Start("explorer.exe", url); + ShellExecuteHelper.ShellExecute(IntPtr.Zero, "open", url, string.Empty, string.Empty, ShellExecuteHelper.ShowCommands.SW_SHOWNORMAL); + } + catch (Exception ex) + { + try + { + Clipboard.SetText(url); + } + catch { } + MessageBox.Show($"{ex.Message}\r\n唤醒旺旺失败,唤醒链接已复制到剪切板,请手动打开浏览器唤醒", "提示"); + } + } + /// /// 对web版提供的修改打包任务方法 /// diff --git a/BBWYB.Client/Resources/Images/bbwylogo.ico b/BBWYB.Client/Resources/Images/bbwylogo.ico index 5fb3f35..c743326 100644 Binary files a/BBWYB.Client/Resources/Images/bbwylogo.ico and b/BBWYB.Client/Resources/Images/bbwylogo.ico differ diff --git a/BBWYB.Client/ViewModels/MainViewModel.cs b/BBWYB.Client/ViewModels/MainViewModel.cs index dc308ca..41da673 100644 --- a/BBWYB.Client/ViewModels/MainViewModel.cs +++ b/BBWYB.Client/ViewModels/MainViewModel.cs @@ -1,13 +1,11 @@ using BBWYB.Client.APIServices; using BBWYB.Client.Models; -using BBWYB.Client.Views; using BBWYB.Client.Views.SelectShop; using BBWYB.Client.Views.WebB; using BBWYB.Common.Extensions; using BBWYB.Common.Models; using CommunityToolkit.Mvvm.Input; using CommunityToolkit.Mvvm.Messaging; -using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Collections.ObjectModel;