diff --git a/BBWY.sln b/BBWY.sln index 04d4230b..c551a7e9 100644 --- a/BBWY.sln +++ b/BBWY.sln @@ -34,7 +34,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BBWY.1688SDK", "BBWY.1688SD EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BBWY.Test", "BBWY.Test\BBWY.Test.csproj", "{FCD5E03E-DA48-406B-9AA8-F72F21F62BDB}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JD.API", "JD.API\JD.API.csproj", "{3D37A8D3-0364-4539-B3E9-A6610F4659A8}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JD.API", "JD.API\JD.API.csproj", "{3D37A8D3-0364-4539-B3E9-A6610F4659A8}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PJZS", "PJZS\PJZS.csproj", "{FB4BF1A9-DA81-446F-903C-89D3F905B7B8}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -86,6 +88,10 @@ Global {3D37A8D3-0364-4539-B3E9-A6610F4659A8}.Debug|Any CPU.Build.0 = Debug|Any CPU {3D37A8D3-0364-4539-B3E9-A6610F4659A8}.Release|Any CPU.ActiveCfg = Release|Any CPU {3D37A8D3-0364-4539-B3E9-A6610F4659A8}.Release|Any CPU.Build.0 = Release|Any CPU + {FB4BF1A9-DA81-446F-903C-89D3F905B7B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FB4BF1A9-DA81-446F-903C-89D3F905B7B8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FB4BF1A9-DA81-446F-903C-89D3F905B7B8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FB4BF1A9-DA81-446F-903C-89D3F905B7B8}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -101,6 +107,7 @@ Global {1A7EB438-5DEF-4940-8CB2-C58141C75524} = {B131026A-2025-4A74-ABF1-644059FADF78} {FCD5E03E-DA48-406B-9AA8-F72F21F62BDB} = {B545F3FA-E6A7-4CB1-B92D-801C66357CF5} {3D37A8D3-0364-4539-B3E9-A6610F4659A8} = {B545F3FA-E6A7-4CB1-B92D-801C66357CF5} + {FB4BF1A9-DA81-446F-903C-89D3F905B7B8} = {D097AEA5-A7B1-414D-B82D-F70F177D0D8D} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {CC045257-4D86-45FD-A1F0-2715C024F1B5} diff --git a/PJZS/App.xaml b/PJZS/App.xaml new file mode 100644 index 00000000..e349b1c7 --- /dev/null +++ b/PJZS/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/PJZS/App.xaml.cs b/PJZS/App.xaml.cs new file mode 100644 index 00000000..c2ea46cd --- /dev/null +++ b/PJZS/App.xaml.cs @@ -0,0 +1,37 @@ +using System.Windows; + +namespace PJZS +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + protected override void OnStartup(StartupEventArgs e) + { + var gl = new GlobalContext(); + string userToken = string.Empty; +#if DEBUG + //齐越山鸡 + userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxNTM1MzMwMzI4ODkyMTQ5NzYwIiwidGVhbUlkIjoiMTUxNjk3NDI1MDU0MjUwMTg4OCIsInNvblRlYW1JZHMiOiIxNDM2Mjg4NTAwMjM1MjQzNTIwIiwiZXhwIjoxNjk0NjY5NjkxfQ.cSwro-7bGwOu92YejH9JhMenTai7Mvf99i2paQCmxIw"; +#else + var uid = e.Args.Count() > 0 ? e.Args.LastOrDefault(args => args.StartsWith("uid:")) : string.Empty; + if (string.IsNullOrEmpty(uid)) + { + MessageBox.Show("缺少启动参数", "提示"); + Environment.Exit(0); + } + var tokenResult = ReadMMF(uid); + if (tokenResult.isOk) + userToken = tokenResult.content; + else + { + MessageBox.Show($"读取内存数据失败\r\n{tokenResult.content}", "提示"); + Environment.Exit(0); + } +#endif + gl.UserToken = userToken; + base.OnStartup(e); + } + } +} diff --git a/PJZS/AssemblyInfo.cs b/PJZS/AssemblyInfo.cs new file mode 100644 index 00000000..8b5504ec --- /dev/null +++ b/PJZS/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/PJZS/GlobalContext.cs b/PJZS/GlobalContext.cs new file mode 100644 index 00000000..ea254d69 --- /dev/null +++ b/PJZS/GlobalContext.cs @@ -0,0 +1,22 @@ +namespace PJZS +{ + public class GlobalContext : NotifyObject + { + private User user; + + public User User { get => user; set { Set(ref user, value); } } + + public string UserToken { get; set; } + + + #region APIHost + public string BBYWApiHost { get; set; } + + public string MDSApiHost { get; set; } + + public string JOSApiHost { get; set; } + + public string _1688ApiHost { get; set; } + #endregion + } +} \ No newline at end of file diff --git a/PJZS/MainWindow.xaml b/PJZS/MainWindow.xaml new file mode 100644 index 00000000..fcd1e515 --- /dev/null +++ b/PJZS/MainWindow.xaml @@ -0,0 +1,12 @@ + + + + + diff --git a/PJZS/MainWindow.xaml.cs b/PJZS/MainWindow.xaml.cs new file mode 100644 index 00000000..e49658f9 --- /dev/null +++ b/PJZS/MainWindow.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace PJZS +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + public MainWindow() + { + InitializeComponent(); + } + } +} diff --git a/PJZS/Models/Enums.cs b/PJZS/Models/Enums.cs new file mode 100644 index 00000000..36a3f2bd --- /dev/null +++ b/PJZS/Models/Enums.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace PJZS.Models +{ + /// + /// 电商平台 + /// + public enum Platform + { + 淘宝 = 0, + 京东 = 1, + 阿里巴巴 = 2, + 拼多多 = 3, + 微信 = 4 + } +} diff --git a/PJZS/Models/NotifyObject.cs b/PJZS/Models/NotifyObject.cs new file mode 100644 index 00000000..dd276290 --- /dev/null +++ b/PJZS/Models/NotifyObject.cs @@ -0,0 +1,23 @@ +using System.ComponentModel; +using System.Runtime.CompilerServices; + +namespace PJZS +{ + public class NotifyObject : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + protected void OnPropertyChanged([CallerMemberName]string propertyName = "") + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + + protected bool Set(ref T oldValue, T newValue, [CallerMemberName]string propertyName = "") + { + if (Equals(oldValue, newValue)) + return false; + oldValue = newValue; + OnPropertyChanged(propertyName); + return true; + } + } +} diff --git a/PJZS/Models/Shop/Department.cs b/PJZS/Models/Shop/Department.cs new file mode 100644 index 00000000..aa2990c5 --- /dev/null +++ b/PJZS/Models/Shop/Department.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; + +namespace PJZS +{ + public class Department : NotifyObject + { + private bool isSelected; + + public string Id { get; set; } + + public string Name { get; set; } + + public IList ShopList { get; set; } + public bool IsSelected + { + get => isSelected; + set + { + if (Set(ref isSelected, value)) + OnIsSelectedChanged?.Invoke(); + } + } + + public Department() + { + ShopList = new List(); + } + + public Action OnIsSelectedChanged { get; set; } + + public override string ToString() + { + return this.Name; + } + } +} diff --git a/PJZS/Models/Shop/PurchaseAccount.cs b/PJZS/Models/Shop/PurchaseAccount.cs new file mode 100644 index 00000000..4ecefdc8 --- /dev/null +++ b/PJZS/Models/Shop/PurchaseAccount.cs @@ -0,0 +1,28 @@ +using PJZS.Models; +using System; + +namespace PJZS +{ + public class PurchaseAccount : NotifyObject,ICloneable + { + private string accountName; + private Platform purchasePlatformId; + private string appKey; + private string appSecret; + private string appToken; + + public long Id { get; set; } + + public long ShopId { get; set; } + public string AccountName { get => accountName; set { Set(ref accountName, value); } } + public Platform PurchasePlatformId { get => purchasePlatformId; set { Set(ref purchasePlatformId, value); } } + public string AppKey { get => appKey; set { Set(ref appKey, value); } } + public string AppSecret { get => appSecret; set { Set(ref appSecret, value); } } + public string AppToken { get => appToken; set { Set(ref appToken, value); } } + + public object Clone() + { + return this.MemberwiseClone(); + } + } +} diff --git a/PJZS/Models/Shop/Shop.cs b/PJZS/Models/Shop/Shop.cs new file mode 100644 index 00000000..b7f408f9 --- /dev/null +++ b/PJZS/Models/Shop/Shop.cs @@ -0,0 +1,79 @@ +using PJZS.Models; +using System.Collections.Generic; + +namespace PJZS +{ + public class Shop : NotifyObject + { + private bool isSelected; + private string shopName; + + public bool IsSelected { get => isSelected; set { Set(ref isSelected, value); } } + /// + /// 店铺Id + /// + public long ShopId { get; set; } + + /// + /// 商家类型 + /// + public string VenderType { get; set; } + + /// + /// 店铺平台 + /// + public Platform Platform { get; set; } + + public string AppKey { get; set; } + + public string AppSecret { get; set; } + + public string AppToken { get; set; } + + public string AppKey2 { get; set; } + + public string AppSecret2 { get; set; } + + public string AppToken2 { get; set; } + + public string ShopName { get => shopName; set { Set(ref shopName, value); } } + + public IList PurchaseAccountList { get; set; } + + public string ManagePwd { get; set; } + /// + /// 店铺扣点 + /// + public decimal? PlatformCommissionRatio { get; set; } + + public string TeamId { get; set; } + + public string TeamName { get; set; } + + public string DingDingWebHook { get; set; } + + public string DingDingKey { get; set; } + + public int SkuSafeTurnoverDays { get; set; } + + /// + /// 司南策略等级 + /// + public int SiNanPolicyLevel { get; set; } + + /// + /// 司南钉钉WebHook地址 + /// + public string SiNanDingDingWebHook { get; set; } + + /// + /// 司南钉钉密钥 + /// + public string SiNanDingDingKey { get; set; } + + public override string ToString() + { + return ShopName; + } + } +} diff --git a/PJZS/Models/User/User.cs b/PJZS/Models/User/User.cs new file mode 100644 index 00000000..0beb46a9 --- /dev/null +++ b/PJZS/Models/User/User.cs @@ -0,0 +1,31 @@ +using System.Collections.Generic; + +namespace PJZS +{ + public class User : NotifyObject + { + //private string name; + + private Shop shop; + + public long Id { get; set; } + + public string Name { get; set; } + + public string TeamId { get; set; } + + public string TeamName { get; set; } + + public string SonDepartmentNames { get; set; } + + public Shop Shop { get => shop; set { Set(ref shop, value); } } + + public IList DepartmentList { get; set; } + + /// + /// 店铺列表 (暂时只有刷单组才需要) + /// + public IList ShopList { get; set; } + + } +} diff --git a/PJZS/PJZS.csproj b/PJZS/PJZS.csproj new file mode 100644 index 00000000..0158e690 --- /dev/null +++ b/PJZS/PJZS.csproj @@ -0,0 +1,28 @@ + + + + WinExe + netcoreapp3.1 + true + + + + + + + + + + + + + + + + + + + + + + diff --git a/PJZS/WebView2Manager.cs b/PJZS/WebView2Manager.cs new file mode 100644 index 00000000..223dd844 --- /dev/null +++ b/PJZS/WebView2Manager.cs @@ -0,0 +1,69 @@ +using BBWY.Common.Models; +using Microsoft.Web.WebView2.Core; +using Microsoft.Web.WebView2.Wpf; +using System; +using io = System.IO; + +namespace PJZS +{ + public class WebView2Manager : IDenpendency + { + public WebView2 wb2 { get; private set; } + //public WebView2Manager() + //{ + // Init(); + //} + public void Init() + { + if (wb2 == null) + { + wb2 = new WebView2(); + var wb2Setting = CoreWebView2Environment.CreateAsync(userDataFolder: io.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "WebView2UserData")).Result; + wb2.EnsureCoreWebView2Async(wb2Setting); + wb2.CoreWebView2InitializationCompleted += Wb2_CoreWebView2InitializationCompleted; + wb2.NavigationCompleted += Wb2_NavigationCompleted; + wb2.WebMessageReceived += Wb2_WebMessageReceived; + } + } + + public Action OnWebMessageReceived; + public Action OnNavigationCompleted; + public Action CoreWebView2InitializationCompleted; + public bool IsInitializationCompleted { get ; private set; } + + private void Wb2_WebMessageReceived(object sender, CoreWebView2WebMessageReceivedEventArgs e) + { + OnWebMessageReceived?.Invoke(e); + } + + private void Wb2_NavigationCompleted(object sender, CoreWebView2NavigationCompletedEventArgs e) + { + OnNavigationCompleted?.Invoke(e); + } + + private void Wb2_CoreWebView2InitializationCompleted(object sender, CoreWebView2InitializationCompletedEventArgs e) + { + CoreWebView2InitializationCompleted?.Invoke(e); + IsInitializationCompleted = true; + } + + public void Close() + { + if (wb2 != null && wb2.CoreWebView2 != null) + { + IsInitializationCompleted = false; + wb2.CoreWebView2InitializationCompleted -= Wb2_CoreWebView2InitializationCompleted; + wb2.NavigationCompleted -= Wb2_NavigationCompleted; + wb2.WebMessageReceived -= Wb2_WebMessageReceived; + var udf = wb2.CoreWebView2.Environment.UserDataFolder; + wb2.Dispose(); + wb2 = null; + try + { + io.Directory.Delete(udf, true); + } + catch { } + } + } + } +}