437 lines
19 KiB
C#
437 lines
19 KiB
C#
using AllBase;
|
|
using AllBase.Extension;
|
|
using AllBase.Helper;
|
|
using AllBase.Model.Param.CollectManage;
|
|
using AllBase.Model.Param.ProductManage;
|
|
using AllBase.Model.Param.ShopManage;
|
|
using AllBase.Model.Result;
|
|
using TemuKJD.BaseForms;
|
|
using TemuKJD.KJDForms.ProductForms;
|
|
using NaiBa.Util;
|
|
using NaiBa.Util.Extension;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using Work;
|
|
using AllBase.Model.Param.TemuProductManage;
|
|
using TemuKJD.KJDForms.ShopForms;
|
|
using TemuKJD.KJDForms.AdminForms;
|
|
|
|
namespace TemuKJD
|
|
{
|
|
public class StartUp
|
|
{
|
|
public static bool IsShopInit = false;
|
|
public static void Init()
|
|
{
|
|
InitOem();
|
|
|
|
InitProxy();
|
|
|
|
#region 抖音相关 -作废
|
|
#region 抖音账号登录信息
|
|
//try { GlobalConfig.DouUserCookies = NaiBa.Util.Helper.FileHelper.ReadAllText("data\\config\\dou_user_cookies")?.Trim('\"'); } catch { }
|
|
//if (GlobalConfig.DouUserCookies == null)
|
|
// GlobalConfig.DouUserCookies = "";
|
|
|
|
//try { GlobalConfig.DouBuyinCookies = NaiBa.Util.Helper.FileHelper.ReadAllText("data\\config\\dou_buyin_cookies")?.Trim('\"'); } catch { }
|
|
//if (GlobalConfig.DouBuyinCookies == null)
|
|
// GlobalConfig.DouBuyinCookies = "";
|
|
|
|
//GlobalConfig.dicLocalStorage = NaiBa.Util.Helper.ConfigHelper.LoadConfig<IDictionary<string, object>>("dou_local_Storage");
|
|
//if (GlobalConfig.dicLocalStorage == null)
|
|
// GlobalConfig.dicLocalStorage = new Dictionary<string, object>();
|
|
#endregion
|
|
|
|
#region 抖音获取类目
|
|
//DyCategoryParam.DyCategorys = Properties.Resources.DyCategorys;
|
|
#endregion
|
|
|
|
#region 抖音读取上传违规词
|
|
//FilterForm.LoadFilterWord();
|
|
#endregion
|
|
|
|
#region 抖音数据净化参数
|
|
//GlobalConfig.FissionSettingParam = NaiBa.Util.Helper.ConfigHelper.LoadConfig<FissionSettingParam>("fission_setting_param");
|
|
//if (GlobalConfig.FissionSettingParam == null)
|
|
//{
|
|
// GlobalConfig.FissionSettingParam = new FissionSettingParam();
|
|
//}
|
|
#endregion
|
|
|
|
#region 抖音读取违规规则列表
|
|
//var violateRuleNameSelectList = NaiBa.Util.Helper.ConfigHelper.LoadConfig<List<string>>("violate_rule_name_select");
|
|
//if (violateRuleNameSelectList != null)
|
|
// ViolateRuleParam.LstViolateRuleNameSelect = violateRuleNameSelectList;
|
|
#endregion
|
|
|
|
#region 抖音旧店铺商品数据本地缓存 供重复铺货检测使用
|
|
//GlobalConfig.SameProductCheckParamList = NaiBa.Util.Helper.ConfigHelper.LoadConfig<List<SameProductCheckParam>>("same_product_check_list");
|
|
//if (GlobalConfig.SameProductCheckParamList == null)
|
|
// GlobalConfig.SameProductCheckParamList = new List<SameProductCheckParam>();
|
|
#endregion
|
|
#endregion
|
|
|
|
#region Temu店铺登录信息
|
|
Task.Run((Action)(() =>
|
|
{
|
|
while (!BaseClass.IsLoginSuccess)
|
|
Thread.Sleep(200);
|
|
|
|
ShopListForm.UpdateShop();
|
|
IsShopInit = true;
|
|
}));
|
|
#endregion
|
|
|
|
#region Temu店铺登录设置参数
|
|
GlobalConfig.TemuShopSettingParam = NaiBa.Util.Helper.ConfigHelper.LoadConfig<TemuShopSettingParam>("temu_shop_setting_param");
|
|
if (GlobalConfig.TemuShopSettingParam == null)
|
|
{
|
|
GlobalConfig.TemuShopSettingParam = new TemuShopSettingParam
|
|
{
|
|
IsAutoDragLogin = false,
|
|
};
|
|
}
|
|
#endregion
|
|
|
|
#region Temu读取上传标题头尾词
|
|
GlobalConfig.ProductWords = NaiBa.Util.Helper.ConfigHelper.LoadConfig<TemuProductWords>("product_words");
|
|
if (GlobalConfig.ProductWords == null)
|
|
GlobalConfig.ProductWords = new TemuProductWords();
|
|
#endregion
|
|
|
|
#region Temu读取退货库存信息
|
|
Task.Run(() =>
|
|
{
|
|
while (!IsShopInit)
|
|
{
|
|
Thread.Sleep(1000);
|
|
}
|
|
|
|
if (BaseClass.MainPath != "kuajingda") // 跨境达才读取库存
|
|
return;
|
|
|
|
ReturnPackageDetailForm retrunPackageForm = new ReturnPackageDetailForm(null);
|
|
retrunPackageForm.Show();
|
|
retrunPackageForm.Hide();
|
|
Dictionary<string, string> dicGetReturnPackDate = NaiBa.Util.Helper.ConfigHelper.LoadConfig<Dictionary<string, string>>("get_return_package_date");
|
|
if (dicGetReturnPackDate == null)
|
|
dicGetReturnPackDate = new Dictionary<string, string>();
|
|
|
|
while (true)
|
|
{
|
|
//Thread.Sleep(20000);
|
|
|
|
//#if DEBUG
|
|
//#else
|
|
var url = BaseClass.BuildObjString("user/is_get_return_package");
|
|
var data = Work.UserLogin.GetSignaturex();
|
|
|
|
int r2 = DateTime.Now.Millisecond;
|
|
data += "&r2=" + r2;
|
|
data += "&c2=" + Work.UserLogin.Encryption(r2);
|
|
string rstHtml = GetHtml.PostUtf8(url, data);
|
|
var isGet = BaseRegex.GetStringJson(ref rstHtml, "is_get") != "false";
|
|
|
|
foreach (var shop in GlobalConfig.ShopLoginList)
|
|
//foreach (var shop in AdminShopListForm.lstAdminShopInfo)
|
|
{
|
|
if (!isGet)
|
|
break;
|
|
|
|
//var index = AdminShopListForm.lstAdminShopInfo.IndexOf(shop);
|
|
if (string.IsNullOrEmpty(shop.ShopId))
|
|
continue;
|
|
|
|
if (dicGetReturnPackDate.Keys.Contains(shop.ShopId) && dicGetReturnPackDate[shop.ShopId] == DateTime.Now.ToString("yyyyMMdd")) //今日已获取过,则只读今日
|
|
{
|
|
//retrunPackageForm.GetReturnPackage(shop, true, DateTime.Now.Date, DateTime.Now.Date.AddDays(1)); // 后台读取今日退货信息
|
|
continue;
|
|
}
|
|
|
|
try
|
|
{
|
|
var rst = retrunPackageForm.GetReturnPackage(shop, true); // 后台读取退货信息
|
|
if (rst == false && shop.LoginStatus == "登录成功" && shop.LoginStatus2 == "国际版在线")
|
|
{
|
|
dicGetReturnPackDate[shop.ShopId] = DateTime.Now.ToString("yyyyMMdd");
|
|
NaiBa.Util.Helper.ConfigHelper.SaveConfig<Dictionary<string, string>>("get_return_package_date", dicGetReturnPackDate);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
}
|
|
}
|
|
//#endif
|
|
for (int i = 0; i < 360; i++)
|
|
{
|
|
Thread.Sleep(10000);
|
|
}
|
|
for (int i = 0; i < 180; i++)
|
|
{
|
|
Thread.Sleep(10000);
|
|
}
|
|
}
|
|
});
|
|
#endregion
|
|
}
|
|
|
|
public static void InitProxy()
|
|
{
|
|
GetProxyHtml.txtUrl = GetProxyHtml.orderId = "";
|
|
if (FileBase.Exists("temp/proxy.txt"))
|
|
{
|
|
string sAgentIpKey = FileBase.ReadAllText("temp/proxy.txt").Trim();
|
|
KJDForms.ToolForms.ProxyForm.InitProxyIp(sAgentIpKey, false);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 贴牌管理
|
|
/// </summary>
|
|
public static void InitOem()
|
|
{
|
|
#region 代理版本获取代理码,暂时作废
|
|
if (FileBase.Exists("locales/ig.pak"))
|
|
{
|
|
BaseClass.AgentCode = FileBase.ReadAllText("locales/ig.pak");
|
|
|
|
string agTxt = "";
|
|
string agVersion = "";
|
|
if (FileBase.Exists("locales/igx.pak"))
|
|
{
|
|
var agTxtArr = FileBase.ReadAllText("locales/igx.pak").Split(new string[] { "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries);
|
|
agTxt = BaseEncrypt.EncryptDecode(agTxtArr[0], "asdf1357", "vbnm2468");
|
|
if (agTxtArr.Length >= 2)
|
|
agVersion = BaseEncrypt.EncryptDecode(agTxtArr[1], "asdf1357", "vbnm2468");
|
|
}
|
|
|
|
if (!agTxt.Contains("oem_title")
|
|
|| !agTxt.Contains("oem_register")
|
|
|| !agTxt.Contains("oem_reset")
|
|
|| !agTxt.Contains("oem_notice")
|
|
|| !agTxt.Contains("oem_video")
|
|
|| !agTxt.Contains("oem_logo_link")
|
|
|| !agTxt.Contains("oem_icon_link"))
|
|
{
|
|
agTxt = "";
|
|
agVersion = "";
|
|
}
|
|
|
|
// 获取贴牌版本号
|
|
string url = BaseClass.BuildObjString("oem_config&act=get_version");
|
|
string data = UserLogin.GetSignaturex("", "") + "&agent_code=" + BaseClass.AgentCode;
|
|
string html = GetHtml.PostUtf8(url, data);
|
|
if (!string.IsNullOrEmpty(html) && html != agVersion)
|
|
{
|
|
agTxt = "";
|
|
agVersion = html;
|
|
}
|
|
if (!html.Contains("\"code\":200"))
|
|
{
|
|
var msg = BaseRegex.GetStringJson(ref html, "msg");
|
|
//BaseMsgForm.ShowError("获取版本信息失败,请检查电脑时间!");
|
|
BaseMsgForm.ShowError(msg);
|
|
Process.GetCurrentProcess().Kill();
|
|
return;
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(agTxt))
|
|
{
|
|
// 根据代理码给贴牌信息赋值
|
|
url = BaseClass.BuildObjString("oem_config&act=get_config_info");
|
|
data = UserLogin.GetSignaturex("", "") + "&agent_code=" + BaseClass.AgentCode;
|
|
agTxt = GetHtml.PostUtf8(url, data);
|
|
if (!agTxt.Contains("\"code\":200"))
|
|
{
|
|
var msg = BaseRegex.GetStringJson(ref html, "msg");
|
|
BaseMsgForm.ShowError(msg);
|
|
Process.GetCurrentProcess().Kill();
|
|
return;
|
|
}
|
|
|
|
File.WriteAllText("locales/igx.pak",
|
|
BaseEncrypt.EncryptEncode(agTxt, "asdf1357", "vbnm2468") + "\r\n" + BaseEncrypt.EncryptEncode(agVersion, "asdf1357", "vbnm2468"));
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(agTxt) && agTxt.Contains("获取配置信息成功"))
|
|
{
|
|
var oem_title = BaseRegex.GetStringJson(ref agTxt, "oem_title");
|
|
var oem_register = BaseRegex.GetStringJson(ref agTxt, "oem_register");
|
|
var oem_reset = BaseRegex.GetStringJson(ref agTxt, "oem_reset");
|
|
var oem_notice = BaseRegex.GetStringJson(ref agTxt, "oem_notice");
|
|
var oem_video = BaseRegex.GetStringJson(ref agTxt, "oem_video");
|
|
var oem_pay = BaseRegex.GetStringJson(ref agTxt, "oem_pay");
|
|
var oem_pay_ip = BaseRegex.GetStringJson(ref agTxt, "oem_pay_ip");
|
|
var oem_logo_link = BaseRegex.GetStringJson(ref agTxt, "oem_logo_link");
|
|
var oem_icon_link = BaseRegex.GetStringJson(ref agTxt, "oem_icon_link");
|
|
var oem_mobile = BaseRegex.GetStringJson(ref agTxt, "oem_mobile");
|
|
var oem_open = BaseRegex.GetStringJson(ref agTxt, "oem_open");
|
|
var oem_header_name = BaseRegex.GetStringJson(ref agTxt, "oem_header_name");
|
|
var oem_qq = BaseRegex.GetStringJson(ref agTxt, "oem_qq");
|
|
|
|
// 软件标题
|
|
if (!string.IsNullOrEmpty(oem_title))
|
|
{
|
|
BaseClass.ToolName = oem_title;
|
|
}
|
|
// 开放注册
|
|
if (!string.IsNullOrEmpty(oem_register))
|
|
{
|
|
BaseClass.IsShowRegister = oem_register == "1";
|
|
}
|
|
// 开户续费
|
|
if (!string.IsNullOrEmpty(oem_open))
|
|
{
|
|
BaseClass.IsShowOpenAccount = oem_open == "1";
|
|
}
|
|
//// 找回密码
|
|
//if (!string.IsNullOrEmpty(oem_reset))
|
|
//{
|
|
// BaseClass.IsShowForgetPwd = oem_reset == "1";
|
|
//}
|
|
//// 公告显示
|
|
//if (!string.IsNullOrEmpty(oem_notice))
|
|
//{
|
|
// BaseClass.IsHideAnnounce = oem_notice == "0";
|
|
//}
|
|
//// 视频显示
|
|
//if (!string.IsNullOrEmpty(oem_video))
|
|
//{
|
|
// BaseClass.IsShowGuidance = oem_video == "1";
|
|
//}
|
|
//// 充值元宝
|
|
//if (!string.IsNullOrEmpty(oem_pay))
|
|
//{
|
|
// BaseClass.IsShowRecharge = oem_pay == "1";
|
|
//}
|
|
//// 代理ip
|
|
//if (!string.IsNullOrEmpty(oem_pay_ip))
|
|
//{
|
|
// BaseClass.IsShowBuyProxyIp = oem_pay_ip == "1";
|
|
//}
|
|
// logo图片地址
|
|
if (!string.IsNullOrEmpty(oem_logo_link))
|
|
{
|
|
try
|
|
{
|
|
var bitmapBG = (Bitmap)Properties.Resources.ResourceManager.GetObject("login_bg_agent");
|
|
var img = GetHtml.LoadImage(oem_logo_link);
|
|
Graphics g = Graphics.FromImage(bitmapBG);
|
|
g.DrawImage(img, new Rectangle(bitmapBG.Width / 2 - img.Width / 2, bitmapBG.Height / 2 - img.Height / 2, img.Width, img.Height));
|
|
var imgBytes = ImageBuild.BitmapToBytes(bitmapBG);
|
|
img.Dispose();
|
|
g.Dispose();
|
|
GetHtml.LoadImage(oem_logo_link);
|
|
|
|
// 登录窗口图标
|
|
BaseClass.LoginImage = ImageBuild.BytesToImage(imgBytes);
|
|
|
|
// 主窗体图标
|
|
BaseClass.LogoImage = GetHtml.LoadImage(oem_logo_link);
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
if (BaseClass.LoginImage == null || BaseClass.LogoImage == null)
|
|
{
|
|
BaseMsgForm.ShowError("获取版本信息失败,请检查电脑联网状态或电脑时间!");
|
|
Process.GetCurrentProcess().Kill();
|
|
return;
|
|
}
|
|
}
|
|
// icon图片地址
|
|
if (!string.IsNullOrEmpty(oem_icon_link))
|
|
{
|
|
BaseClass.Ico = GetHtml.LoadIcon(oem_icon_link);
|
|
if (BaseClass.Ico == null)
|
|
{
|
|
BaseMsgForm.ShowError("获取版本信息失败,请检查电脑联网状态或电脑时间!");
|
|
Process.GetCurrentProcess().Kill();
|
|
return;
|
|
}
|
|
}
|
|
// 客服QQ(或电话)
|
|
if (!string.IsNullOrEmpty(oem_qq))
|
|
{
|
|
BaseClass.ServiceQQ = oem_qq;
|
|
}
|
|
//if (!string.IsNullOrEmpty(oem_header_name))
|
|
//{
|
|
// BaseClass.oem_header = oem_header_name;
|
|
//}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
public static void SaveLocalShopLoginInfo()
|
|
{
|
|
//ConcurrentList<ShopLoginInfo> shopLoginListCopy =
|
|
// JsonHelper.DeserializeJsonToObject<ConcurrentList<ShopLoginInfo>>(JsonHelper.SerializeObject(GlobalConfig.ShopLoginList));
|
|
//shopLoginListCopy.AddRange(GlobalConfig.DouShopLoginOtherUserShopList);
|
|
//// 替换掉密码,cookie等敏感参数
|
|
//foreach (var shop in shopLoginListCopy)
|
|
//{
|
|
// shop.Password = "";
|
|
// shop.Cookies = "";
|
|
//}
|
|
//NaiBa.Util.Helper.ConfigHelper.SaveConfig("dou_shop_login", shopLoginListCopy);
|
|
}
|
|
|
|
public static void SaveTemuShopSettingParam()
|
|
{
|
|
NaiBa.Util.Helper.ConfigHelper.SaveConfig("temu_shop_setting_param", GlobalConfig.TemuShopSettingParam);
|
|
}
|
|
|
|
public static void SaveProductWords()
|
|
{
|
|
NaiBa.Util.Helper.ConfigHelper.SaveConfig("product_words", GlobalConfig.ProductWords);
|
|
}
|
|
|
|
#region 暂时作废的函数
|
|
//public static void SaveFissionSettingParam()
|
|
//{
|
|
// NaiBa.Util.Helper.ConfigHelper.SaveConfig("fission_setting_param", GlobalConfig.FissionSettingParam);
|
|
//}
|
|
|
|
///// <summary>
|
|
///// 保存抖音采集用户cookie
|
|
///// </summary>
|
|
//public static void SaveDouUserCookies()
|
|
//{
|
|
// NaiBa.Util.Helper.ConfigHelper.SaveConfig("dou_user_cookies", GlobalConfig.DouUserCookies);
|
|
//}
|
|
|
|
//public static void SaveDouBuyinCookies()
|
|
//{
|
|
// NaiBa.Util.Helper.ConfigHelper.SaveConfig("dou_buyin_cookies", GlobalConfig.DouBuyinCookies);
|
|
//}
|
|
|
|
//public static void SaveDouLocalStorage()
|
|
//{
|
|
// if (GlobalConfig.dicLocalStorage != null)
|
|
// NaiBa.Util.Helper.ConfigHelper.SaveConfig<IDictionary<string, object>>("dou_local_Storage", GlobalConfig.dicLocalStorage);
|
|
//}
|
|
|
|
//public static void SaveDouLocalDetailStorage()
|
|
//{
|
|
// if (GlobalConfig.dicLocalDetailStorage != null)
|
|
// NaiBa.Util.Helper.ConfigHelper.SaveConfig<IDictionary<string, object>>("dou_local_detail_Storage", GlobalConfig.dicLocalDetailStorage);
|
|
//}
|
|
|
|
//public static void SaveViolateRuleNameSelectList()
|
|
//{
|
|
// if (ViolateRuleParam.LstViolateRuleNameSelect != null)
|
|
// NaiBa.Util.Helper.ConfigHelper.SaveConfig<List<string>>("violate_rule_name_select", ViolateRuleParam.LstViolateRuleNameSelect);
|
|
//}
|
|
#endregion
|
|
}
|
|
}
|