110 lines
4.1 KiB
C#
110 lines
4.1 KiB
C#
using _29WxOrderWpf.BaseWindows;
|
|
using _29WxOrderWpf.ViewModels;
|
|
using AllBase;
|
|
using AllBase.DouYinModel.Param.ConfigManage;
|
|
using AllBase.Helper;
|
|
using AllBase.Model.Config;
|
|
using AllBase.Model.DBModel;
|
|
using NaiBa.Util;
|
|
using NaiBa.Util.Extension;
|
|
using NaiBa.Util.Helper;
|
|
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using Work;
|
|
|
|
namespace _29WxOrderWpf
|
|
{
|
|
public class StartUp
|
|
{
|
|
public static void Init()
|
|
{
|
|
GlobalConfig.BuyConfig = ConfigHelper.LoadConfig<BuyConfig>("buy_config_260708");
|
|
if (GlobalConfig.BuyConfig == null)
|
|
GlobalConfig.BuyConfig = new BuyConfig();
|
|
GlobalConfig.BuyConfig.IsSyncDirectBuyOrderWaybill = false;
|
|
|
|
GlobalConfig.lstWXShopTokenInfo = ConfigHelper.LoadConfig<ConcurrentList<WXShopTokenInfo>>("wx_shop_token_list");
|
|
if (GlobalConfig.lstWXShopTokenInfo == null)
|
|
GlobalConfig.lstWXShopTokenInfo = new ConcurrentList<WXShopTokenInfo>();
|
|
|
|
// 自动拍单支付宝密码
|
|
var alipayPassword = ConfigHelper.LoadConfig<List<string>>("ali_pay_password")?.FirstOrDefault() ?? "";
|
|
|
|
GlobalConfig.AutoBuyConfig = ConfigHelper.LoadConfig<AutoBuyConfig>("auto_buy_config");
|
|
if (GlobalConfig.AutoBuyConfig == null)
|
|
GlobalConfig.AutoBuyConfig = new AutoBuyConfig() { AlipayPassword = alipayPassword, IsLimitMinProfit = false, MinProfit = 0 };
|
|
|
|
|
|
BaseClass.Setting = NaiBa.Util.Helper.ConfigHelper.LoadConfig<SettingConfig>(SettingViewModel.SettingFileName);
|
|
if (BaseClass.Setting == null) BaseClass.Setting = new SettingConfig();
|
|
BaseClass.Setting.AutoSwitchGiftType = true;
|
|
|
|
new WxOrder.Framework.Startup();
|
|
}
|
|
|
|
public static void SaveBuyConfig()
|
|
{
|
|
ConfigHelper.SaveConfig("buy_config_260708", GlobalConfig.BuyConfig);
|
|
}
|
|
|
|
public static async Task UpdateBalance()
|
|
{
|
|
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<Dictionary<string, object>>(AllBase.JsonHelper.SerializeObject(jObj["data"]["MakUpRule"]));
|
|
// //UserLogin.GetUserOemAmount(dicMarkUp);
|
|
//}
|
|
}
|
|
}
|
|
}
|