diff --git a/29WxOrderWpf/MainWindow.xaml.cs b/29WxOrderWpf/MainWindow.xaml.cs index 1deb912..916d7e3 100644 --- a/29WxOrderWpf/MainWindow.xaml.cs +++ b/29WxOrderWpf/MainWindow.xaml.cs @@ -248,6 +248,12 @@ namespace _29WxOrderWpf e.Cancel = true; } + public void Exit() + { + _ticketMonitor.Dispose(); + Process.GetCurrentProcess().Kill(); + } + #region 读取微信店铺 public bool isReadShop { get; set; } = false; public bool hasReadShop { get; set; } = false; diff --git a/29WxOrderWpf/StartUp.cs b/29WxOrderWpf/StartUp.cs index 266a9a7..050d332 100644 --- a/29WxOrderWpf/StartUp.cs +++ b/29WxOrderWpf/StartUp.cs @@ -14,6 +14,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows; using Work; namespace _29WxOrderWpf @@ -53,36 +54,56 @@ namespace _29WxOrderWpf public static async Task UpdateBalance() { - var url3 = BaseClass.Build29WxObjString("user/get_all_user"); - var data3 = UserLogin.GetSignaturex(); - data3 += "&search_user_name=" + BaseClass.UserName; - var html = GetHtml.PostUtf8(url3, data3); - if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200")) - html = GetHtml.PostUtf8(url3, data3); - if (html.Contains("\"code\":200")) - { - BaseClass.Balance = BaseRegex.GetDecimalJson(ref html, "balance"); - MainWindow.Instance.Balance = BaseClass.Balance.ToString("0.00"); - - // 更新下每单扣费金额 - //BaseClass.PostagePerOrder = Math.Max(2.2m, BaseRegex.GetDecimalJson(ref html, "postage_per_order")); - //BaseClass.RefundPostagePerOrder = Math.Max(2.5m, BaseRegex.GetDecimalJson(ref html, "refund_postage_per_order")); - //BaseClass.OemGiftAmount = BaseRegex.GetDecimalJson(ref html, "gift_oem_amount_per_order"); - BaseClass.OemId = BaseRegex.GetStringJson(ref html, "oem_id"); - BaseClass.OemName = BaseRegex.GetStringJson(ref html, "oem_name"); - BaseClass.IsOemOwner = BaseRegex.GetBoolJson(ref html, "is_oem_owner"); - - try - { - await UserLogin.GetUserOemAmount(16); - await UserLogin.GetUserOemAmount(20); - await UserLogin.GetUserOemAmount(26); - } - catch (Exception ex) - { - BaseMsgWindow.ShowError("更新账户余额失败 " + ex.Message); - } + UserLogin ul = new UserLogin(); + ul.Mobile = BaseClass.UserName; + ul.Password = "******"; + string message = ""; + int weakPassword = 0; + int lockUserName = 0; + string messageInfo = ""; + bool ok = ul.Get(ref message, out lockUserName, out weakPassword, out messageInfo); + if (!ok) + { + BaseMsgWindow.ShowError("登录发生改变,请重新登录!"); + MainWindow.Instance.Exit(); } - } - } + MainWindow.Instance.Balance = BaseClass.Balance.ToString("0.00"); + + //var url3 = BaseClass.Build29WxObjString("user/get_all_user"); + //var data3 = UserLogin.GetSignaturex(); + //data3 += "&search_user_name=" + BaseClass.UserName; + //var html = GetHtml.PostUtf8(url3, data3); + //if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200")) + // html = GetHtml.PostUtf8(url3, data3); + //if (html.Contains("\"code\":200")) + //{ + // BaseClass.Balance = BaseRegex.GetDecimalJson(ref html, "balance"); + // MainWindow.Instance.Balance = BaseClass.Balance.ToString("0.00"); + // + // // 更新下每单扣费金额 + // //BaseClass.PostagePerOrder = Math.Max(2.2m, BaseRegex.GetDecimalJson(ref html, "postage_per_order")); + // //BaseClass.RefundPostagePerOrder = Math.Max(2.5m, BaseRegex.GetDecimalJson(ref html, "refund_postage_per_order")); + // //BaseClass.OemGiftAmount = BaseRegex.GetDecimalJson(ref html, "gift_oem_amount_per_order"); + // BaseClass.OemId = BaseRegex.GetStringJson(ref html, "oem_id"); + // BaseClass.OemName = BaseRegex.GetStringJson(ref html, "oem_name"); + // BaseClass.IsOemOwner = BaseRegex.GetBoolJson(ref html, "is_oem_owner"); + // + // //try + // //{ + // // //await UserLogin.GetUserOemAmount(16); + // // //await UserLogin.GetUserOemAmount(20); + // // //await UserLogin.GetUserOemAmount(26); + // //} + // //catch (Exception ex) + // //{ + // // BaseMsgWindow.ShowError("更新账户余额失败 " + ex.Message); + // //} + // + // //// 获取加价信息 + // //JObject jObj = AllBase.JsonHelper.JObjectParse(html); + // //var dicMarkUp = AllBase.JsonHelper.DeserializeJsonToObject>(AllBase.JsonHelper.SerializeObject(jObj["data"]["MakUpRule"])); + // //UserLogin.GetUserOemAmount(dicMarkUp); + //} + } + } } diff --git a/29WxOrderWpf/Windows/LoginWindows/LoginWindow.xaml.cs b/29WxOrderWpf/Windows/LoginWindows/LoginWindow.xaml.cs index 68ac08d..74ef812 100644 --- a/29WxOrderWpf/Windows/LoginWindows/LoginWindow.xaml.cs +++ b/29WxOrderWpf/Windows/LoginWindows/LoginWindow.xaml.cs @@ -131,9 +131,9 @@ namespace _29WxOrderWpf.Windows.LoginWindows } try { - await UserLogin.GetUserOemAmount(16); - await UserLogin.GetUserOemAmount(20); - await UserLogin.GetUserOemAmount(26); + //await UserLogin.GetUserOemAmount(16); + //await UserLogin.GetUserOemAmount(20); + //await UserLogin.GetUserOemAmount(26); } catch (Exception ex) { diff --git a/AllBase/BaseClass.cs b/AllBase/BaseClass.cs index faecfa8..83d75ad 100644 --- a/AllBase/BaseClass.cs +++ b/AllBase/BaseClass.cs @@ -222,16 +222,18 @@ namespace AllBase /// /// 发货每笔费用 /// - public static decimal PostagePerOrder { get; set; } = 2.2m; - static decimal? postageOemAmount = null; - public static decimal PostageOemAmount { set { postageOemAmount = value; } get { return postageOemAmount ?? Math.Max(0, PostagePerOrder - 2.2m); } } + //public static decimal PostagePerOrder { get; set; } = 2.2m; + //static decimal? postageOemAmount = null; + //public static decimal PostageOemAmount { set { postageOemAmount = value; } get { return postageOemAmount ?? Math.Max(0, PostagePerOrder - 2.2m); } } + public static decimal PostageOemAmount { get; set; } = 0m; public static decimal ParentPostageOemAmount { get; set; } = 0m; /// /// 退货每笔费用 /// - public static decimal RefundPostagePerOrder { get; set; } = 2.5m; - static decimal? refundPostageOemAmount = null; - public static decimal RefundPostageOemAmount { set { refundPostageOemAmount = value; } get { return refundPostageOemAmount ?? Math.Max(0, RefundPostagePerOrder - 2.5m); } } + //public static decimal RefundPostagePerOrder { get; set; } = 2.5m; + //static decimal? refundPostageOemAmount = null; + //public static decimal RefundPostageOemAmount { set { refundPostageOemAmount = value; } get { return refundPostageOemAmount ?? Math.Max(0, RefundPostagePerOrder - 2.5m); } } + public static decimal RefundPostageOemAmount { get; set; } = 0m; public static decimal ParentRefundPostageOemAmount { get; set; } = 0m; public static int AlimamaPageCount = 0; public static bool CloudTitle = false; diff --git a/Work/Initialization.cs b/Work/Initialization.cs index 7c22506..1e16621 100644 --- a/Work/Initialization.cs +++ b/Work/Initialization.cs @@ -51,7 +51,7 @@ namespace Work //new Thread(new JumpUpProductNew().Ini).Start(); new Thread(CheckFiles).Start(); //new Thread(UpdateTime).Start(); - //new Thread(GetMacCode).Start(); + new Thread(GetMacCode).Start(); //////new Thread(CheckUpdataFile).Start(); CheckHecker r = new CheckHecker(); diff --git a/Work/UserLogin.cs b/Work/UserLogin.cs index 8c2d069..9e6c5e3 100644 --- a/Work/UserLogin.cs +++ b/Work/UserLogin.cs @@ -9,6 +9,8 @@ using System.Security.Cryptography; using System.Text; using System.Threading; using System.Threading.Tasks; +using System.Windows.Forms; +using WxOrder.Framework; namespace Work { @@ -148,17 +150,29 @@ namespace Work //BaseClass.AuthorizedAmount = BaseRegex.GetNullableDecimalJson(ref html, "authorized_amount"); BaseClass.Points = BaseRegex.GetStringJson(ref html, "points").ParseToInt(); BaseClass.ShopPointsPerMonth = BaseRegex.GetStringJson(ref html, "shop_points_per_month").ParseToInt(); - BaseClass.Balance = BaseRegex.GetDecimalJson(ref html, "balance"); - BaseClass.PostagePerOrder = Math.Max(2.2m, BaseRegex.GetDecimalJson(ref html, "postage_per_order")); - BaseClass.RefundPostagePerOrder = Math.Max(2.5m, BaseRegex.GetDecimalJson(ref html, "refund_postage_per_order")); - BaseClass.RechargeAmountTotal = BaseRegex.GetDecimalJson(ref html, "recharge_amount_total"); - BaseClass.OemGiftAmount = BaseRegex.GetDecimalJson(ref html, "gift_oem_amount_per_order"); - BaseClass.ParentOemGiftAmount = BaseRegex.GetDecimalJson(ref html, "parent_gift_oem_amount_per_order"); + BaseClass.Balance = BaseRegex.GetDecimalJson(ref html, "balance"); /* 当前余额 */ + BaseClass.RechargeAmountTotal = BaseRegex.GetDecimalJson(ref html, "recharge_amount_total"); /* 充值总数 */ + //BaseClass.PostagePerOrder = Math.Max(2.2m, BaseRegex.GetDecimalJson(ref html, "postage_per_order")); + //BaseClass.RefundPostagePerOrder = Math.Max(2.5m, BaseRegex.GetDecimalJson(ref html, "refund_postage_per_order")); BaseClass.OemId = BaseRegex.GetStringJson(ref html, "oem_id"); BaseClass.OemName = BaseRegex.GetStringJson(ref html, "oem_name"); - BaseClass.ParentOemId = BaseRegex.GetStringJson(ref html, "parent_oem_id"); - BaseClass.ParentOemName = BaseRegex.GetStringJson(ref html, "parent_oem_name"); + //BaseClass.ParentOemId = BaseRegex.GetStringJson(ref html, "parent_oem_id"); + //BaseClass.ParentOemName = BaseRegex.GetStringJson(ref html, "parent_oem_name"); + + + BaseClass.ParentPostageOemAmount = 0; + BaseClass.PostageOemAmount = 0; + BaseClass.ParentRefundPostageOemAmount = 0; + BaseClass.RefundPostageOemAmount = 0; + BaseClass.OemGiftAmount = 0; // BaseRegex.GetDecimalJson(ref html, "gift_oem_amount_per_order"); + BaseClass.ParentOemGiftAmount = 0; // BaseRegex.GetDecimalJson(ref html, "parent_gift_oem_amount_per_order"); BaseClass.IsOemOwner = BaseRegex.GetBoolJson(ref html, "is_oem_owner"); + + // 获取加价信息 + JObject jObj = JsonHelper.JObjectParse(html); + var dicMarkUp = JsonHelper.DeserializeJsonToObject>(JsonHelper.SerializeObject(jObj["data"]["MakUpRule"])); + GetUserOemAmount(dicMarkUp); + #if DEBUG if (!string.IsNullOrEmpty(BaseRegex.GetStringJson(ref html, "order_api_url")) && !BaseClass.LoginApiUrl.Contains("localhost") && !BaseClass.LoginApiUrl.Contains("127.0.0.1")) { @@ -300,6 +314,70 @@ namespace Work } } + public static void GetUserOemAmount(Dictionary oemMarkUpDic) + { + try + { + if (!oemMarkUpDic.Keys.Contains("16") || !oemMarkUpDic.Keys.Contains("20") || !oemMarkUpDic.Keys.Contains("26")) + { + BaseClass.UserId = 0; + BaseClass.UserKey = 0; + throw new Exception("账户信息获取失败"); + } + + foreach (var key in oemMarkUpDic.Keys) + { + var jArr = JArray.Parse(oemMarkUpDic[key].ParseToString()); + foreach (var item in jArr) + { + if (key == "16") + { + if (item["Level"].ParseToInt() == 1) + { + BaseClass.ParentOemId = item["OemId"].ParseToString(); + BaseClass.ParentOemGiftAmount = item["Markup"].ParseToInt() * 0.01m; + } + else if (item["Level"].ParseToInt() == 2) + { + BaseClass.OemId = item["OemId"].ParseToString(); + BaseClass.OemGiftAmount = item["Markup"].ParseToInt() * 0.01m; + } + } + else if (key == "20") + { + if (item["Level"].ParseToInt() == 1) + { + BaseClass.ParentOemId = item["OemId"].ParseToString(); + BaseClass.ParentPostageOemAmount = item["Markup"].ParseToInt() * 0.01m; + } + else if (item["Level"].ParseToInt() == 2) + { + BaseClass.OemId = item["OemId"].ParseToString(); + BaseClass.PostageOemAmount = item["Markup"].ParseToInt() * 0.01m; + } + } + else if (key == "26") + { + if (item["Level"].ParseToInt() == 1) + { + BaseClass.ParentOemId = item["OemId"].ParseToString(); + BaseClass.ParentRefundPostageOemAmount = item["Markup"].ParseToInt() * 0.01m; + } + else if (item["Level"].ParseToInt() == 2) + { + BaseClass.OemId = item["OemId"].ParseToString(); + BaseClass.RefundPostageOemAmount = item["Markup"].ParseToInt() * 0.01m; + } + } + } + } + } + catch (Exception ex) + { + throw new Exception(ex.Message); + } + } + /// /// 注册账户