72 lines
2.6 KiB
C#
72 lines
2.6 KiB
C#
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.Helper;
|
|
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
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 void 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"));
|
|
}
|
|
}
|
|
}
|
|
}
|