140 lines
4.9 KiB
C#
140 lines
4.9 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.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 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"));
|
|
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");
|
|
}
|
|
}
|
|
public static async Task GetOemAmount(int type)
|
|
{
|
|
var url3 = BaseClass.Build29WxObjString("user/GetUserMarkups");
|
|
var data3 = UserLogin.GetSignaturex();
|
|
data3 += "&PaymentType=" + type;
|
|
var html = await GetHtml.PostUtf8Async(url3, data3);
|
|
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
|
html = await GetHtml.PostUtf8Async(url3, data3);
|
|
if (html.Contains("\"code\":200"))
|
|
{
|
|
try
|
|
{
|
|
var jArr = AllBase.JsonHelper.JObjectParse(html)["data"] as JArray;
|
|
foreach (var r in jArr)
|
|
{
|
|
if (type == 16)
|
|
{
|
|
if (jArr["level"].ParseToInt() == 1)
|
|
{
|
|
BaseClass.ParentOemId = jArr["oemId"].ParseToString();
|
|
BaseClass.ParentOemGiftAmount = jArr["markup"].ParseToInt() * 0.01m;
|
|
}
|
|
else if (jArr["level"].ParseToInt() == 2)
|
|
{
|
|
BaseClass.OemId = jArr["oemId"].ParseToString();
|
|
BaseClass.OemGiftAmount = jArr["markup"].ParseToInt() * 0.01m;
|
|
}
|
|
}
|
|
else if (type == 20)
|
|
{
|
|
if (jArr["level"].ParseToInt() == 1)
|
|
{
|
|
BaseClass.ParentOemId = jArr["oemId"].ParseToString();
|
|
BaseClass.ParentPostageOemAmount = jArr["markup"].ParseToInt() * 0.01m;
|
|
}
|
|
else if (jArr["level"].ParseToInt() == 2)
|
|
{
|
|
BaseClass.OemId = jArr["oemId"].ParseToString();
|
|
BaseClass.PostageOemAmount = jArr["markup"].ParseToInt() * 0.01m;
|
|
}
|
|
}
|
|
else if (type == 26)
|
|
{
|
|
if (jArr["level"].ParseToInt() == 1)
|
|
{
|
|
BaseClass.ParentOemId = jArr["oemId"].ParseToString();
|
|
BaseClass.ParentRefundPostageOemAmount = jArr["markup"].ParseToInt() * 0.01m;
|
|
}
|
|
else if (jArr["level"].ParseToInt() == 2)
|
|
{
|
|
BaseClass.OemId = jArr["oemId"].ParseToString();
|
|
BaseClass.RefundPostageOemAmount = jArr["markup"].ParseToInt() * 0.01m;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|