拼多多拍单关联闪退修复
This commit is contained in:
1 parent
b2d6d81e07
commit
ebccdbc28c
4 files changed
+140
-81
No files matched your search
@@ -38,6 +38,7 @@
|
|||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
<Reference Include="System.Drawing" />
|
<Reference Include="System.Drawing" />
|
||||||
|
<Reference Include="System.Management" />
|
||||||
<Reference Include="System.Net.Http" />
|
<Reference Include="System.Net.Http" />
|
||||||
<Reference Include="System.Windows.Forms" />
|
<Reference Include="System.Windows.Forms" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
|
|||||||
@@ -190,6 +190,41 @@ namespace _29WxOrderWpf.ViewModels
|
|||||||
CefWebBrowser = null;
|
CefWebBrowser = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int GetRenderProcessId()
|
||||||
|
{
|
||||||
|
int parentPid = Process.GetCurrentProcess().Id;
|
||||||
|
// 查找所有名为 CefSharp.BrowserSubprocess 且父进程为当前应用的进程
|
||||||
|
var subprocesses = Process.GetProcessesByName("CefSharp.BrowserSubprocess")
|
||||||
|
.Where(p =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return p.SessionId == Process.GetCurrentProcess().SessionId && GetParentProcessId(p.Id) == parentPid;
|
||||||
|
}
|
||||||
|
catch { return false; }
|
||||||
|
});
|
||||||
|
|
||||||
|
// 返回第一个匹配的 Render 进程 ID,实际可能有多个
|
||||||
|
return subprocesses.FirstOrDefault()?.Id ?? -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 辅助方法:获取父进程 ID (需引用 System.Management 或使用 P/Invoke)
|
||||||
|
private static int GetParentProcessId(int processId)
|
||||||
|
{
|
||||||
|
using (var query = new System.Management.ManagementObjectSearcher(
|
||||||
|
$"SELECT ParentProcessId FROM Win32_Process WHERE ProcessId = {processId}"))
|
||||||
|
{
|
||||||
|
using (var results = query.Get())
|
||||||
|
{
|
||||||
|
foreach (System.Management.ManagementObject obj in results)
|
||||||
|
{
|
||||||
|
return Convert.ToInt32(obj["ParentProcessId"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
public static void CleanupBrowserSubprocesses(List<Process> processes = null)
|
public static void CleanupBrowserSubprocesses(List<Process> processes = null)
|
||||||
{
|
{
|
||||||
// 有可能释放错误导致程序崩溃,废弃
|
// 有可能释放错误导致程序崩溃,废弃
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ XDYGZC ;广州仓 ;何外华 ;13826339849 ;广州市增城区朱村街
|
|||||||
XDYWHC ;武汉2仓 ;杨先生 ;13044121071 ;湖北省武汉市江汉区民族街道沿江大道轮渡龙王庙码头 ;13 ;180 ;1546 ;湖北省 ;武汉市 ;江汉区 ;民族街道 ;沿江大道轮渡龙王庙码头
|
XDYWHC ;武汉2仓 ;杨先生 ;13044121071 ;湖北省武汉市江汉区民族街道沿江大道轮渡龙王庙码头 ;13 ;180 ;1546 ;湖北省 ;武汉市 ;江汉区 ;民族街道 ;沿江大道轮渡龙王庙码头
|
||||||
XDYSHANDC ;山东2仓 ;鸿鹄小申 ;13044121239 ;山东省临沂市费县南外环东转盘往东200米顺通快递有限公司(仓库二楼) ;22 ;292 ;2415 ;山东省 ;临沂市 ;费县 ;费城街道 ;南外环东转盘往东200米顺通快递有限公司(仓库二楼)
|
XDYSHANDC ;山东2仓 ;鸿鹄小申 ;13044121239 ;山东省临沂市费县南外环东转盘往东200米顺通快递有限公司(仓库二楼) ;22 ;292 ;2415 ;山东省 ;临沂市 ;费县 ;费城街道 ;南外环东转盘往东200米顺通快递有限公司(仓库二楼)
|
||||||
XDYSHC ;上海新仓 ;纪先生 ;13044121150 ;上海市上海市普陀区真如镇街道真北路2653弄T区 ;25 ;321 ;2709 ;上海市 ;上海市 ;普陀区 ;真如镇街道 ;真北路2653弄T区
|
XDYSHC ;上海新仓 ;纪先生 ;13044121150 ;上海市上海市普陀区真如镇街道真北路2653弄T区 ;25 ;321 ;2709 ;上海市 ;上海市 ;普陀区 ;真如镇街道 ;真北路2653弄T区
|
||||||
XDYSZC ;深圳仓 ;峰峰 ;15343351331 ;广东省东莞市凤岗镇浸校塘东良巷逸乐轩E栋5号楼 ;6 ;79 ;732 ;广东省 ;东莞市 ;凤岗镇 ;凤岗街道 ;浸校塘东良巷逸乐轩E栋5号楼
|
XDYSZC ;深圳仓 ;峰峰 ;15343351331 ;广东省东莞市凤岗镇浸校塘东良巷逸乐轩E栋5号楼 ;6 ;79 ;732 ;广东省 ;东莞市 ;凤岗镇 ;凤岗街道 ;浸校塘东良巷逸乐轩E栋5号楼";
|
||||||
XDYYWC ;义乌仓 ;小田 ;19058117371 ;浙江省义乌市后宅街道金城高尔夫二期别墅区401栋 ;31 ;386 ;3409 ;浙江省 ;金华市 ;义乌市 ;后宅街道 ;金城高尔夫二期别墅区401栋";
|
//XDYYWC ;义乌仓 ;小田 ;19058117371 ;浙江省义乌市后宅街道金城高尔夫二期别墅区401栋 ;31 ;386 ;3409 ;浙江省 ;金华市 ;义乌市 ;后宅街道 ;金城高尔夫二期别墅区401栋
|
||||||
//XDYYWC ;义乌仓 ;小田 ;19058117371 ;浙江省金华市义乌市北苑街道西站大道妈妈商贸18号库39号楼誉达 ;31 ;386 ;3409 ;浙江省 ;金华市 ;义乌市 ;北苑街道 ;西站大道妈妈商贸18号库39号楼誉达
|
//XDYYWC ;义乌仓 ;小田 ;19058117371 ;浙江省金华市义乌市北苑街道西站大道妈妈商贸18号库39号楼誉达 ;31 ;386 ;3409 ;浙江省 ;金华市 ;义乌市 ;北苑街道 ;西站大道妈妈商贸18号库39号楼誉达
|
||||||
//XDYJJC ;晋江仓 ;安群 ;19905951984 ;福建省泉州市南安市霞美镇温山村431号鸿鹄大厦 ;4 ;58 ;569 ;福建省 ;泉州市
|
//XDYJJC ;晋江仓 ;安群 ;19905951984 ;福建省泉州市南安市霞美镇温山村431号鸿鹄大厦 ;4 ;58 ;569 ;福建省 ;泉州市
|
||||||
//XDYCDC ;成都仓 ;谢春虹 ;15828201479 ;四川省资阳市乐至县仙鹤大道桑都街15-19号仓库(不要放驿站,送到仓库) ;26 ;340 ;2898 ;四川省 ;资阳市
|
//XDYCDC ;成都仓 ;谢春虹 ;15828201479 ;四川省资阳市乐至县仙鹤大道桑都街15-19号仓库(不要放驿站,送到仓库) ;26 ;340 ;2898 ;四川省 ;资阳市
|
||||||
|
|||||||
@@ -1009,6 +1009,8 @@ namespace TemuKJD.ToolForms
|
|||||||
pddFrontGoodsLite.goodsId = BaseRegex.GetLongJson(ref data, "goodsId");
|
pddFrontGoodsLite.goodsId = BaseRegex.GetLongJson(ref data, "goodsId");
|
||||||
pddFrontGoodsLite.mallName = BaseRegex.GetStringJson(ref data, "mallName");
|
pddFrontGoodsLite.mallName = BaseRegex.GetStringJson(ref data, "mallName");
|
||||||
pddFrontGoodsLite.mallId = BaseRegex.GetLongJson(ref data, "mallId");
|
pddFrontGoodsLite.mallId = BaseRegex.GetLongJson(ref data, "mallId");
|
||||||
|
if (pddFrontGoodsLite.mallId == 0)
|
||||||
|
pddFrontGoodsLite.mallId = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ShopLoginForm_FormClosed(object sender, FormClosedEventArgs e)
|
private void ShopLoginForm_FormClosed(object sender, FormClosedEventArgs e)
|
||||||
@@ -1050,39 +1052,60 @@ namespace TemuKJD.ToolForms
|
|||||||
|
|
||||||
private async void btnManualUpdateTransitWarehouse_Click(object sender, EventArgs e)
|
private async void btnManualUpdateTransitWarehouse_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var sendProvince = txtSendProvince.Text.Trim();
|
try
|
||||||
if (transitWarehouse == null && !cmbTransitWarehouse.Text.Trim().IsNullOrEmpty())
|
{
|
||||||
{
|
await ManualUpdateTransitWarehouse();
|
||||||
transitWarehouse = TransitWarehouseData.TransitWarehouseList.FirstOrDefault(t => t.TransName + " " + t.TransFullAddress == cmbTransitWarehouse.Text.Trim().ParseToString());
|
}
|
||||||
}
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (transitWarehouse == null)
|
public async Task ManualUpdateTransitWarehouse()
|
||||||
{
|
{
|
||||||
BaseMsgForm.ShowError("仓库不能为空");
|
var sendProvince = txtSendProvince.Text.Trim();
|
||||||
return;
|
if (transitWarehouse == null && !cmbTransitWarehouse.Text.Trim().IsNullOrEmpty())
|
||||||
}
|
{
|
||||||
|
transitWarehouse = TransitWarehouseData.TransitWarehouseList.FirstOrDefault(t => t.TransName + " " + t.TransFullAddress == cmbTransitWarehouse.Text.Trim().ParseToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (transitWarehouse == null)
|
||||||
|
{
|
||||||
|
BaseMsgForm.ShowError("仓库不能为空");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ((this.pddFrontGoodsLite?.goodsId).IsNullOrZero() || (this.pddFrontGoodsLite?.mallId).IsNullOrZero())
|
if ((this.pddFrontGoodsLite?.goodsId).IsNullOrZero() || (this.pddFrontGoodsLite?.mallId).IsNullOrZero())
|
||||||
{
|
{
|
||||||
await Task.Run(() =>
|
StringBuilder sb = new StringBuilder();
|
||||||
{
|
sb.Append("(function(){\r\n");
|
||||||
var jsStr = "document.getElementById('orderGoodsBlock').getElementsByTagName('div')[0].click();";
|
sb.Append("var orderGoodsBlock = document.getElementById('orderGoodsBlock')\r\n");
|
||||||
|
sb.Append("if (orderGoodsBlock) {\r\n");
|
||||||
|
sb.Append(" orderGoodsBlock.getElementsByTagName('div')[0].click();\r\n");
|
||||||
|
sb.Append(" return 'success';\r\n");
|
||||||
|
sb.Append("}\r\n");
|
||||||
|
sb.Append("else\r\n");
|
||||||
|
sb.Append(" return 'failed';\r\n");
|
||||||
|
sb.Append("})();\r\n");
|
||||||
|
//var jsStr = "document.getElementById('orderGoodsBlock').getElementsByTagName('div')[0].click();";
|
||||||
|
var jsStr = sb.ToString();
|
||||||
|
|
||||||
var host = cefWebBrowser.GetBrowser().GetHost();
|
var host = cefWebBrowser.GetBrowser().GetHost();
|
||||||
var client = cefWebBrowser.GetDevToolsClient();
|
var client = cefWebBrowser.GetDevToolsClient();
|
||||||
var ts1 = client.Runtime.EvaluateAsync(jsStr, null, true, null, null, true, null, true);
|
var rst = await client.Runtime.EvaluateAsync(jsStr, null, true, null, null, true, null, true);
|
||||||
ts1.Wait(500);
|
for (int i = 0; i < 80; i++)
|
||||||
for (int i = 0; i < 80; i++)
|
{
|
||||||
{
|
if (rst.Result.Value.ParseToString() == "failed")
|
||||||
if (!(this.pddFrontGoodsLite?.mallId).IsNullOrZero())
|
break;
|
||||||
break;
|
if (!(this.pddFrontGoodsLite?.mallId).IsNullOrZero())
|
||||||
Thread.Sleep(100);
|
break;
|
||||||
}
|
await Task.Delay(100);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.Enabled = false;
|
this.Enabled = false;
|
||||||
if (!this.cefWebBrowser.Address.StartsWith("https://mobile.yangkeduo.com/order.html?order_sn=") && (this.pddFrontGoodsLite?.goodsId).ParseToString() == txtMapGoodsId.Text.Trim())
|
if (this.cefWebBrowser != null &&
|
||||||
|
!this.cefWebBrowser.Address.StartsWith("https://mobile.yangkeduo.com/order.html?order_sn=") && (this.pddFrontGoodsLite?.goodsId).ParseToString() == txtMapGoodsId.Text.Trim())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1091,14 +1114,14 @@ namespace TemuKJD.ToolForms
|
|||||||
string upSkuCode = txtSkuCode.Text.Trim();
|
string upSkuCode = txtSkuCode.Text.Trim();
|
||||||
// 保存sku及商品关联信息
|
// 保存sku及商品关联信息
|
||||||
var data = UserLogin.GetSignaturex()
|
var data = UserLogin.GetSignaturex()
|
||||||
+ "&spu_code=" + GetHtml.UrlEncodeUtf8(upSpuCode)
|
+ "&spu_code=" + GetHtml.UrlEncodeUtf8(upSpuCode)
|
||||||
+ "&sku_code=" + GetHtml.UrlEncodeUtf8(upSkuCode)
|
+ "&sku_code=" + GetHtml.UrlEncodeUtf8(upSkuCode)
|
||||||
+ "&main_user_name=" + BaseClass.MainUserName
|
+ "&main_user_name=" + BaseClass.MainUserName
|
||||||
+ "&map_goods_name=" + txtMapGoodsName.Text.Trim()
|
+ "&map_goods_name=" + txtMapGoodsName.Text.Trim()
|
||||||
+ "&map_spec_name=" + txtMapSkuName.Text.Trim()
|
+ "&map_spec_name=" + txtMapSkuName.Text.Trim()
|
||||||
+ "&map_goods_id=" + txtMapGoodsId.Text.Trim()
|
+ "&map_goods_id=" + txtMapGoodsId.Text.Trim()
|
||||||
+ "&map_sku_id=" + txtMapSkuId.Text.Trim()
|
+ "&map_sku_id=" + txtMapSkuId.Text.Trim()
|
||||||
+ "&map_send_address=" + sendProvince
|
+ "&map_send_address=" + sendProvince
|
||||||
+ "&transit_warehouse_id=" + transitWarehouse?.TransId;
|
+ "&transit_warehouse_id=" + transitWarehouse?.TransId;
|
||||||
if (!(this.pddFrontGoodsLite?.mallId).IsNullOrZero() && this.pddFrontGoodsLite.goodsId.ParseToString() == txtMapGoodsId.Text.Trim())
|
if (!(this.pddFrontGoodsLite?.mallId).IsNullOrZero() && this.pddFrontGoodsLite.goodsId.ParseToString() == txtMapGoodsId.Text.Trim())
|
||||||
{
|
{
|
||||||
@@ -1160,29 +1183,29 @@ namespace TemuKJD.ToolForms
|
|||||||
}
|
}
|
||||||
url = BaseClass.Build29WxObjString("order/wx_add_mdy_buy_prod_map");
|
url = BaseClass.Build29WxObjString("order/wx_add_mdy_buy_prod_map");
|
||||||
var result = await GetHtml.PostUtf8Async(url, data);
|
var result = await GetHtml.PostUtf8Async(url, data);
|
||||||
if (!result.Contains("\"code\":200"))
|
if (!result.Contains("\"code\":200"))
|
||||||
result = await GetHtml.PostUtf8Async(url, data);
|
result = await GetHtml.PostUtf8Async(url, data);
|
||||||
if (!result.Contains("\"code\":200"))
|
if (!result.Contains("\"code\":200"))
|
||||||
{
|
{
|
||||||
this.Enabled = true;
|
this.Enabled = true;
|
||||||
BaseMsgForm.ShowError("保存失败" + BaseRegex.GetStringJson(ref result, "msg") + ",请稍后重试");
|
BaseMsgForm.ShowError("保存失败" + BaseRegex.GetStringJson(ref result, "msg") + ",请稍后重试");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var urlMap = BaseClass.Build29WxObjString("order/wx_get_buy_prod_map");
|
var urlMap = BaseClass.Build29WxObjString("order/wx_get_buy_prod_map");
|
||||||
var dataMap = UserLogin.GetSignaturex()
|
var dataMap = UserLogin.GetSignaturex()
|
||||||
+ "&spu_codes=" + upSpuCode;
|
+ "&spu_codes=" + upSpuCode;
|
||||||
//dataMap += "&sku_codes=" + upSkuCode;
|
//dataMap += "&sku_codes=" + upSkuCode;
|
||||||
dataMap += "&main_user_name=" + BaseClass.MainUserName;
|
dataMap += "&main_user_name=" + BaseClass.MainUserName;
|
||||||
var resultMap = await GetHtml.PostUtf8Async(urlMap, dataMap);
|
var resultMap = await GetHtml.PostUtf8Async(urlMap, dataMap);
|
||||||
if (string.IsNullOrEmpty(resultMap) || !resultMap.Contains("\"code\":200"))
|
if (string.IsNullOrEmpty(resultMap) || !resultMap.Contains("\"code\":200"))
|
||||||
resultMap = await GetHtml.PostUtf8Async(urlMap, dataMap);
|
resultMap = await GetHtml.PostUtf8Async(urlMap, dataMap);
|
||||||
if (string.IsNullOrEmpty(resultMap) || !resultMap.Contains("\"code\":200"))
|
if (string.IsNullOrEmpty(resultMap) || !resultMap.Contains("\"code\":200"))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<WXBuyMapInfo> buyMapList = new List<WXBuyMapInfo>();
|
List<WXBuyMapInfo> buyMapList = new List<WXBuyMapInfo>();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
buyMapList = JsonHelper.DeserializeJsonToList<WXBuyMapInfo>(JObject.Parse(resultMap)["data"].ParseToString());
|
buyMapList = JsonHelper.DeserializeJsonToList<WXBuyMapInfo>(JObject.Parse(resultMap)["data"].ParseToString());
|
||||||
@@ -1193,38 +1216,38 @@ namespace TemuKJD.ToolForms
|
|||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
var pddBuyMap = buyMapList.FirstOrDefault(b => b.spu_code == upSpuCode && b.sku_code == upSkuCode && b.platform == "pdd");
|
var pddBuyMap = buyMapList.FirstOrDefault(b => b.spu_code == upSpuCode && b.sku_code == upSkuCode && b.platform == "pdd");
|
||||||
if (pddBuyMap != null)
|
if (pddBuyMap != null)
|
||||||
{
|
{
|
||||||
foreach (var order in GlobalConfig.lstOrder)
|
foreach (var order in GlobalConfig.lstOrder)
|
||||||
{
|
{
|
||||||
if (order.IsWaitBuy)
|
if (order.IsWaitBuy)
|
||||||
{
|
{
|
||||||
foreach (var item in order.orderItems)
|
foreach (var item in order.orderItems)
|
||||||
{
|
{
|
||||||
if ((item.out_product_id == pddBuyMap.spu_code && item.out_sku_id == pddBuyMap.sku_code) ||
|
if ((item.out_product_id == pddBuyMap.spu_code && item.out_sku_id == pddBuyMap.sku_code) ||
|
||||||
(item.out_product_id == pddBuyMap.spu_code && item.sku_attr_str == pddBuyMap.sku_code) ||
|
(item.out_product_id == pddBuyMap.spu_code && item.sku_attr_str == pddBuyMap.sku_code) ||
|
||||||
(item.product_id == pddBuyMap.spu_code && item.out_sku_id == pddBuyMap.sku_code) ||
|
(item.product_id == pddBuyMap.spu_code && item.out_sku_id == pddBuyMap.sku_code) ||
|
||||||
(item.product_id == pddBuyMap.spu_code && item.sku_attr_str == pddBuyMap.sku_code))
|
(item.product_id == pddBuyMap.spu_code && item.sku_attr_str == pddBuyMap.sku_code))
|
||||||
{
|
{
|
||||||
item.PddBuyMap = pddBuyMap;
|
item.PddBuyMap = pddBuyMap;
|
||||||
|
|
||||||
if (filterOrderAction != null)
|
if (filterOrderAction != null)
|
||||||
{
|
{
|
||||||
item.SetOrderItemTextProperty();
|
item.SetOrderItemTextProperty();
|
||||||
filterOrderAction(order, false);
|
filterOrderAction(order, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BaseMsgForm.ShowInfo("保存成功!");
|
BaseMsgForm.ShowInfo("保存成功!");
|
||||||
this.IsClose = true;
|
this.IsClose = true;
|
||||||
this.Close();
|
this.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void btnManualUpdateBuyOrder_Click(object sender, EventArgs e)
|
private async void btnManualUpdateBuyOrder_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user