优化了微店商品上传 优化pdd买手读单
This commit is contained in:
1 parent
6c4f16b897
commit
f360688c43
62 files changed
+5620
-1432
No files matched your search
@@ -20,6 +20,8 @@ using TemuKJD.Extension;
|
||||
using AllBase.Model.Result;
|
||||
using TemuKJD.BLL.VDian;
|
||||
using TemuKJD;
|
||||
using TemuKJD.VDianForms;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace KJD.VDianForms
|
||||
{
|
||||
@@ -53,7 +55,7 @@ namespace KJD.VDianForms
|
||||
RefreshDataGridView();
|
||||
}
|
||||
|
||||
private void ProductMappingVDianLoginForm_SaveComplete(object obj)
|
||||
private void VDianLoginForm_SaveComplete(object obj)
|
||||
{
|
||||
VDianShopLoginInfo vDianShopLoginInfo = obj as VDianShopLoginInfo;
|
||||
if (vDianShopLoginInfo == null)
|
||||
@@ -80,106 +82,91 @@ namespace KJD.VDianForms
|
||||
|
||||
if (vDianShopLoginInfo.LoginStatus == 1)
|
||||
{
|
||||
// cookie保存到服务端
|
||||
var url = BaseClass.BuildObjString("api/weidian&act=add_weidian_login_cookie").Replace("littlecow/api/weidian", "api/weidian");
|
||||
//保存cookie到服务器
|
||||
var url = BaseClass.BuildPDDObjString("shop/mdy_weidian_shop_cookie");
|
||||
var data = UserLogin.GetSignaturex() +
|
||||
"&shop_id=" + vDianShopLoginInfo.ShopId +
|
||||
"&shop_name=" + vDianShopLoginInfo.ShopName +
|
||||
"&cookie=" + GetHtml.UrlEncodeUtf8(vDianShopLoginInfo.Cookies.Replace(" ", ""));
|
||||
"&wd_token=" + vDianShopLoginInfo.Wdtoken +
|
||||
"&cookie=" + GetHtml.UrlEncodeUtf8(vDianShopLoginInfo.Cookies.Replace(" ", "")) +
|
||||
"&login_status=在线";
|
||||
var html = GetHtml.PostUtf8(url, data);
|
||||
|
||||
// 测试获取cookie
|
||||
//url = BaseClass.BuildObjString("api/weidian&act=get_weidian_login_cookie").Replace("littlecow/api/weidian", "api/weidian");
|
||||
//data = UserLogin.GetSignaturex() + "&cid=6";
|
||||
//html = GetHtml.PostUtf8(url, data);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读取服务端的微店
|
||||
/// </summary>
|
||||
public static List<VDianShopLoginInfo> GetServerVDian()
|
||||
public static void GetServerVDian()
|
||||
{
|
||||
// 读取已有店铺
|
||||
List<VDianShopLoginInfo> list = new List<VDianShopLoginInfo>();
|
||||
string url = BaseClass.BuildObjString("shop&act=auto_login_shop_v1");
|
||||
string url = BaseClass.BuildObjString("shop/get_weidian_shop");
|
||||
string data = UserLogin.GetSignaturex();
|
||||
data += "&siteid=5";
|
||||
string html = GetHtml.PostUtf8(url, data);
|
||||
if (html == "Ok" || string.IsNullOrEmpty(html))
|
||||
if (!html.Contains("\"code\":200"))
|
||||
html = GetHtml.PostUtf8(url, data);
|
||||
if (!html.Contains("\"code\":200"))
|
||||
return;
|
||||
var jArr = JsonHelper.JObjectParse(html)["data"] as JArray;
|
||||
foreach(JObject o in jArr)
|
||||
{
|
||||
return list;
|
||||
}
|
||||
var m = BaseRegex.GetMatchRegex(ref html, "<shop([^>]+?)>");
|
||||
for (int i = 0; m != null && i < m.Count; i++)
|
||||
{
|
||||
string shopStr = m[i].Groups[0].Value;
|
||||
string shopStr = JsonHelper.SerializeObject(o);
|
||||
VDianShopLoginInfo vsp = new VDianShopLoginInfo();
|
||||
vsp.ShopId = BaseRegex.GetStringJson(ref shopStr, "id");
|
||||
vsp.ShopId = BaseRegex.GetStringJson(ref shopStr, "shop_id");
|
||||
if (vsp.ShopId == null)
|
||||
continue;
|
||||
vsp.Phone = BaseRegex.GetStringJson(ref shopStr, "user_name");
|
||||
vsp.ShopName = BaseRegex.GetStringJson(ref shopStr, "name");
|
||||
vsp.Password = BaseRegex.GetStringJson(ref shopStr, "password");
|
||||
vsp.Phone = BaseRegex.GetStringJson(ref shopStr, "login_name");
|
||||
vsp.ShopName = BaseRegex.GetStringJson(ref shopStr, "shop_account");
|
||||
vsp.Password = BaseRegex.GetStringJson(ref shopStr, "login_pass");
|
||||
vsp.Cookies = BaseRegex.GetStringJson(ref shopStr, "cookie");
|
||||
vsp.LoginStatus = BaseRegex.GetStringJson(ref shopStr, "login_status") == "在线" ? 1 : 2;
|
||||
vsp.Wdtoken = BaseRegex.GetStringJson(ref shopStr, "wd_token");
|
||||
if (!string.IsNullOrEmpty(vsp.Password))
|
||||
vsp.Password = DataOpenSSL.DecryptString(vsp.Password);
|
||||
vsp.ShopId = BaseRegex.GetStringJson(ref shopStr, "shop_id");
|
||||
|
||||
if (list.Any(l => l.Phone == vsp.Phone))
|
||||
continue;
|
||||
list.Add(vsp);
|
||||
}
|
||||
return list;
|
||||
GlobalConfig.VDianShopLoginList.RemoveAll(vDian => !list.Any(v => v.ShopId == vDian.ShopId));
|
||||
foreach (var v in list)
|
||||
{
|
||||
var vDian = GlobalConfig.VDianShopLoginList.FirstOrDefault(vo => vo.ShopId == v.ShopId);
|
||||
if (vDian == null)
|
||||
GlobalConfig.VDianShopLoginList.Add(v);
|
||||
else
|
||||
{
|
||||
vDian.Api2Auth = v.Api2Auth;
|
||||
vDian.ApiAuth = v.ApiAuth;
|
||||
vDian.Cookies = v.Cookies;
|
||||
vDian.LoginStatus = v.LoginStatus;
|
||||
vDian.LstWdApiToken = v.LstWdApiToken;
|
||||
vDian.MainAuth = v.MainAuth;
|
||||
vDian.MultiAttrApiToken = v.MultiAttrApiToken;
|
||||
vDian.MultiImgApiToken = v.MultiImgApiToken;
|
||||
vDian.MultiProductApiToken = v.MultiProductApiToken;
|
||||
vDian.Password = v.Password;
|
||||
vDian.Phone = v.Phone;
|
||||
vDian.ShopId = v.ShopId;
|
||||
vDian.ShopName = v.ShopName;
|
||||
vDian.UpGoodAuth = v.UpGoodAuth;
|
||||
vDian.user_name = v.user_name;
|
||||
vDian.WdApi2RefreshToken = v.WdApi2RefreshToken;
|
||||
vDian.WdApi2Token = v.WdApi2Token;
|
||||
vDian.Wdtoken = v.Wdtoken;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新增微店店铺列表
|
||||
/// </summary>
|
||||
/// <param name="vDianList"></param>
|
||||
/// <param name="isUpdateContainsShop">是否更新服务端已存在的店铺</param>
|
||||
public void SaveVDianToServer(List<VDianShopLoginInfo> vDianList, bool isUpdateContainsShop = false)
|
||||
public void SaveVDianToServer(List<VDianShopLoginInfo> vDianList)
|
||||
{
|
||||
var shops = vDianList;
|
||||
if (!isUpdateContainsShop)
|
||||
for (int i = 0; i < vDianList.Count; i++)
|
||||
{
|
||||
/// <summary>
|
||||
/// 读取店铺列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
List<VDianShopLoginInfo> list = new List<VDianShopLoginInfo>();
|
||||
string url = BaseClass.BuildObjString("shop&act=auto_login_shop_v1");
|
||||
string data = UserLogin.GetSignaturex();
|
||||
data += "&siteid=5";
|
||||
string html = GetHtml.PostUtf8(url, data);
|
||||
if (!string.IsNullOrEmpty(html))
|
||||
{
|
||||
var m = BaseRegex.GetMatchRegex(ref html, "<shop([^>]+?)>");
|
||||
for (int i = 0; m != null && i < m.Count; i++)
|
||||
{
|
||||
string shopStr = m[i].Groups[0].Value;
|
||||
VDianShopLoginInfo vsp = new VDianShopLoginInfo();
|
||||
vsp.ShopId = BaseRegex.GetStringJson(ref shopStr, "id");
|
||||
if (vsp.ShopId == null)
|
||||
continue;
|
||||
vsp.Phone = BaseRegex.GetStringJson(ref shopStr, "user_name");
|
||||
vsp.ShopName = BaseRegex.GetStringJson(ref shopStr, "name");
|
||||
vsp.Password = BaseRegex.GetStringJson(ref shopStr, "password");
|
||||
if (!string.IsNullOrEmpty(vsp.Password))
|
||||
vsp.Password = DataOpenSSL.DecryptString(vsp.Password);
|
||||
vsp.ShopId = BaseRegex.GetStringJson(ref shopStr, "shop_id");
|
||||
|
||||
if (list.Any(l => l.Phone == vsp.Phone))
|
||||
continue;
|
||||
list.Add(vsp);
|
||||
}
|
||||
}
|
||||
|
||||
// 写入服务端没有的店铺
|
||||
shops = GlobalConfig.VDianShopLoginList.Where(s => !list.Any(l => l.ShopId == s.ShopId)).ToList();
|
||||
}
|
||||
for (int i = 0; i < shops.Count; i++)
|
||||
{
|
||||
var vShop = shops[i];
|
||||
var vShop = vDianList[i];
|
||||
SaveVDianToServer(vShop);
|
||||
}
|
||||
}
|
||||
@@ -193,29 +180,21 @@ namespace KJD.VDianForms
|
||||
string sPassword = vShop.Password;
|
||||
string sShopName = vShop.ShopName;
|
||||
string sShopId = vShop.ShopId;
|
||||
//string sGroup = "";
|
||||
|
||||
//var x = "123 +/";
|
||||
//var r = GetHtml.UrlEncodeUtf8(DataOpenSSL.EncryptString(x));
|
||||
//var rr = DataOpenSSL.DecryptString(GetHtml.UrlDecode(r));
|
||||
|
||||
var url = BaseClass.BuildObjString("shop&act=add_shop_vd_v1");
|
||||
var data = UserLogin.GetSignaturex() + "&user_name=" + sShopPhone
|
||||
+ "&password=" + GetHtml.UrlEncodeUtf8(DataOpenSSL.EncryptString(sPassword)) + "&name=" + sShopName
|
||||
+ "&shop_id=" + sShopId //+ "&cat_name=" + sGroup
|
||||
+ "&service=&buyer=&login_user=&upload_user="
|
||||
+ "&collect_user=" + BaseClass.NickName + "&sub_account_name=&sub_account_password=";
|
||||
data += "&site_id=5"; // 5为微店
|
||||
var url = BaseClass.BuildPDDObjString("shop/add_weidian_shop");
|
||||
var data = UserLogin.GetSignaturex()
|
||||
+ "&login_name=" + sShopPhone
|
||||
+ "&login_pass=" + GetHtml.UrlEncodeUtf8(DataOpenSSL.EncryptString(sPassword))
|
||||
+ "&shop_id=" + sShopId
|
||||
+ "&shop_account=" + sShopName;
|
||||
data += "&login_status=" + (vShop.LoginStatus == 1 ? "在线" : "掉线");
|
||||
var html = GetHtml.PostUtf8(url, data);
|
||||
if (!string.IsNullOrEmpty(html) && html.Equals("Full Shop Count"))
|
||||
if (!html.Contains("\"code\":200"))
|
||||
{
|
||||
BaseMsgForm.ShowInfo("当前版本支持的最大店铺数已满,请升级版本或另外购买一个账户");
|
||||
}
|
||||
if (string.IsNullOrEmpty(html))
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
html = GetHtml.PostUtf8(url, data);
|
||||
}
|
||||
if (!html.Contains("\"code\":200"))
|
||||
BaseMsgForm.ShowError("店铺保存失败");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -223,11 +202,10 @@ namespace KJD.VDianForms
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public string DelServerVDianShop(string name)
|
||||
public string DelServerVDianShop(string shopId)
|
||||
{
|
||||
string url = BaseClass.BuildObjString("shop&act=delete");
|
||||
string data = UserLogin.GetSignaturex() + "&name=" + name;
|
||||
data += "&site_id=5";
|
||||
string url = BaseClass.BuildPDDObjString("shop/del_weidian_shop");
|
||||
string data = UserLogin.GetSignaturex() + "&shop_id=" + shopId;
|
||||
string html = GetHtml.PostUtf8(url, data);
|
||||
return html;
|
||||
}
|
||||
@@ -249,9 +227,8 @@ namespace KJD.VDianForms
|
||||
case "删除":
|
||||
if (BaseMsgForm.ShowConfirm("确定删除店铺吗?").DialogResult == DialogResult.Cancel)
|
||||
return;
|
||||
DelServerVDianShop(shopId);
|
||||
DeleteVDianShop(e.RowIndex);
|
||||
DelServerVDianShop(shopName);
|
||||
//StartUp.SaveVDianShopLogin();
|
||||
break;
|
||||
|
||||
case "编辑":
|
||||
@@ -262,19 +239,35 @@ namespace KJD.VDianForms
|
||||
break;
|
||||
|
||||
case "重登":
|
||||
//ProductMappingVDianLoginForm.IsRun = true;
|
||||
//var vDian = GlobalConfig.VDianShopLoginList.FirstOrDefault(v => v.ShopId == shopId);
|
||||
//var phone = "";
|
||||
//var password = "";
|
||||
//if (vDian != null)
|
||||
//{
|
||||
// phone = vDian.Phone;
|
||||
// password = vDian.Password;
|
||||
//}
|
||||
//ProductMappingVDianLoginForm productMappingVDianLoginForm = new ProductMappingVDianLoginForm(phone, password);
|
||||
//productMappingVDianLoginForm.SaveComplete += ProductMappingVDianLoginForm_SaveComplete;
|
||||
//productMappingVDianLoginForm.ShowDialog();
|
||||
//ProductMappingVDianLoginForm.IsRun = false;
|
||||
{
|
||||
VDianLoginForm.IsRun = true;
|
||||
var vDian = GlobalConfig.VDianShopLoginList.FirstOrDefault(v => v.ShopId == shopId);
|
||||
var phone = "";
|
||||
var password = "";
|
||||
if (vDian != null)
|
||||
{
|
||||
phone = vDian.Phone;
|
||||
password = vDian.Password;
|
||||
}
|
||||
VDianLoginForm vDianLoginForm = new VDianLoginForm(phone, password);
|
||||
vDianLoginForm.SaveComplete += VDianLoginForm_SaveComplete;
|
||||
vDianLoginForm.ShowDialog();
|
||||
VDianLoginForm.IsRun = false;
|
||||
}
|
||||
break;
|
||||
|
||||
case "进店":
|
||||
{
|
||||
VDianLoginForm.IsRun = true;
|
||||
var vDian = GlobalConfig.VDianShopLoginList.FirstOrDefault(v => v.ShopId == shopId);
|
||||
if (vDian != null)
|
||||
{
|
||||
VDianLoginForm vDianLoginForm = new VDianLoginForm(vDian, "manage");
|
||||
vDianLoginForm.WindowState = FormWindowState.Maximized;
|
||||
vDianLoginForm.ShowDialog();
|
||||
}
|
||||
VDianLoginForm.IsRun = false;
|
||||
}
|
||||
break;
|
||||
|
||||
case "上货认证":
|
||||
@@ -364,7 +357,7 @@ namespace KJD.VDianForms
|
||||
// string url = "https://d.weidian.com/weidian-pc/pc-vue-index/index.html"; // 微店商家后台
|
||||
var result = new VDianUpProdMappingBLL().request_vdian_sell_com(vDian.Wdtoken, vDian.Cookies);
|
||||
Thread.Sleep(200);
|
||||
if (result.Contains("LOGIN ERROR"))
|
||||
if (result.ToUpper().Contains("LOGIN ERROR"))
|
||||
{
|
||||
vDian.LoginStatus = 2;
|
||||
}
|
||||
@@ -372,6 +365,14 @@ namespace KJD.VDianForms
|
||||
{
|
||||
vDian.LoginStatus = 1;
|
||||
}
|
||||
var url = BaseClass.BuildPDDObjString("shop/mdy_weidian_shop_cookie");
|
||||
var data = UserLogin.GetSignaturex() +
|
||||
"&shop_id=" + vDian.ShopId +
|
||||
"&cookie=" + vDian.Cookies +
|
||||
"&wd_token=" + vDian.Wdtoken +
|
||||
"&login_status=" + (vDian.LoginStatus == 1 ? "在线" : "掉线");
|
||||
var html = GetHtml.PostUtf8(url, data);
|
||||
|
||||
|
||||
// 获取店铺token列表
|
||||
vDian.ApiAuth = "未授权";
|
||||
@@ -556,7 +557,8 @@ namespace KJD.VDianForms
|
||||
param.ShopName,
|
||||
param.Phone,
|
||||
param.Cookies,
|
||||
param.LoginStatus == 1 ? "正常" : "未登录",
|
||||
param.LoginStatus == 1 ? "在线" : "掉线",
|
||||
"进店",
|
||||
"检测",
|
||||
"重登",
|
||||
param.UpGoodAuth,
|
||||
@@ -577,7 +579,7 @@ namespace KJD.VDianForms
|
||||
{
|
||||
if (dgvr == null || param == null)
|
||||
return;
|
||||
dgvr.Cells["colLoginStatus"].Value = (param.LoginStatus == 1 ? "正常" : "未登录");
|
||||
dgvr.Cells["colLoginStatus"].Value = (param.LoginStatus == 1 ? "在线" : "掉线");
|
||||
dgvr.Cells["colCookie"].Value = param.Cookies;
|
||||
dgvr.Cells["colUpGoodAuth"].Value = param.UpGoodAuth;
|
||||
dgvr.Cells["colApiAuth"].Value = param.ApiAuth;
|
||||
@@ -663,7 +665,7 @@ namespace KJD.VDianForms
|
||||
// 批量导入店铺
|
||||
private void btnImport_Click(object sender, EventArgs e)
|
||||
{
|
||||
// ProductMappingVDianLoginForm.IsRun = true;
|
||||
VDianLoginForm.IsRun = true;
|
||||
ImportShop();
|
||||
}
|
||||
|
||||
@@ -684,28 +686,28 @@ namespace KJD.VDianForms
|
||||
var strArr = importStr.Replace("\r", "").Split('\n');
|
||||
for (int i = 0; i < strArr.Length; i++)
|
||||
{
|
||||
//if (ProductMappingVDianLoginForm.IsRun == false)
|
||||
// break;
|
||||
//try
|
||||
//{
|
||||
// // 通用格式
|
||||
// if (strArr[i].Contains("-----"))
|
||||
// {
|
||||
// var productArr = strArr[i].Split(new string[] { "-----" }, StringSplitOptions.RemoveEmptyEntries);
|
||||
// if (productArr.Length >= 2)
|
||||
// {
|
||||
// var phone = productArr[0];
|
||||
// var password = productArr[1];
|
||||
if (VDianLoginForm.IsRun == false)
|
||||
break;
|
||||
try
|
||||
{
|
||||
// 通用格式
|
||||
if (strArr[i].Contains("-----"))
|
||||
{
|
||||
var productArr = strArr[i].Split(new string[] { "-----" }, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (productArr.Length >= 2)
|
||||
{
|
||||
var phone = productArr[0];
|
||||
var password = productArr[1];
|
||||
|
||||
// ProductMappingVDianLoginForm productMappingVDianLoginForm = new ProductMappingVDianLoginForm(phone, password);
|
||||
// productMappingVDianLoginForm.SaveComplete += ProductMappingVDianLoginForm_SaveComplete;
|
||||
// productMappingVDianLoginForm.ShowDialog();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//catch (Exception ex)
|
||||
//{
|
||||
//}
|
||||
VDianLoginForm vDianLoginForm = new VDianLoginForm(phone, password);
|
||||
vDianLoginForm.SaveComplete += VDianLoginForm_SaveComplete;
|
||||
vDianLoginForm.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
this.btnImport.Enabled = true;
|
||||
@@ -821,7 +823,7 @@ namespace KJD.VDianForms
|
||||
|
||||
private void btnLoginSelect_Click(object sender, EventArgs e)
|
||||
{
|
||||
//ProductMappingVDianLoginForm.IsRun = true;
|
||||
VDianLoginForm.IsRun = true;
|
||||
if (this.btnLoginSelect.Text == "登录选中")
|
||||
{
|
||||
List<string> shopIdList = GetCheckedTokenList();
|
||||
@@ -833,15 +835,15 @@ namespace KJD.VDianForms
|
||||
|
||||
foreach (var shopId in shopIdList)
|
||||
{
|
||||
//if (ProductMappingVDianLoginForm.IsRun == false)
|
||||
// break;
|
||||
if (VDianLoginForm.IsRun == false)
|
||||
break;
|
||||
|
||||
var vDian = GlobalConfig.VDianShopLoginList.FirstOrDefault(v => v.ShopId == shopId);
|
||||
if (vDian != null && !string.IsNullOrEmpty(vDian.Phone)/* && !string.IsNullOrEmpty(vDian.Password)*/)
|
||||
{
|
||||
//ProductMappingVDianLoginForm productMappingVDianLoginForm = new ProductMappingVDianLoginForm(vDian.Phone, vDian.Password);
|
||||
//productMappingVDianLoginForm.SaveComplete += ProductMappingVDianLoginForm_SaveComplete;
|
||||
//productMappingVDianLoginForm.ShowDialog();
|
||||
VDianLoginForm vDianLoginForm = new VDianLoginForm(vDian.Phone, vDian.Password);
|
||||
vDianLoginForm.SaveComplete += VDianLoginForm_SaveComplete;
|
||||
vDianLoginForm.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user