1优化订单列表展示 2拍单逻辑优化调整 3自动拍单
This commit is contained in:
1 parent
b2d91563ed
commit
b03753e0cf
10 files changed
+309
-95
No files matched your search
@@ -47,9 +47,10 @@ namespace TemuKJD.ToolForms
|
||||
public oms_wei_external_procurement_log_info AbnormalTransitWarehouseOrderInfo { get; set; } = null;
|
||||
public pddFrontGoods3Lite pddFrontGoodsLite = new pddFrontGoods3Lite();
|
||||
|
||||
public bool IsAutoBuy { get; set; } = true;
|
||||
public bool IsFormLoad { get; set; } = false;
|
||||
public bool IsAutoBuy { get; set; } = false;
|
||||
public bool IsFormLoad { get; set; } = false;
|
||||
public bool ShowBuyMask { get; set; } = false;
|
||||
public string BuyErrMsg { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 直发direct 中转transit
|
||||
@@ -174,7 +175,7 @@ namespace TemuKJD.ToolForms
|
||||
}
|
||||
else if (orderItem.BuyMapSkus != null && orderItem.BuyMapSkus.Count > 0 && AbnormalTransitWarehouseOrderInfo == null) // 不能是异常重拍
|
||||
{
|
||||
panel2.Visible = true;
|
||||
//panel2.Visible = true;
|
||||
cmbMapSkusProd.Items.Clear();
|
||||
cmbMapSkusProd.Items.Add("");
|
||||
foreach (var mapSku in orderItem.BuyMapSkus)
|
||||
@@ -559,16 +560,21 @@ namespace TemuKJD.ToolForms
|
||||
}
|
||||
}
|
||||
// 自动下单
|
||||
if (IsAutoBuy)
|
||||
if (IsAutoBuy && HasChangeAddress && url.StartsWith("https://mobile.yangkeduo.com/order_checkout.html?sku_id="))
|
||||
{
|
||||
if (!IsSoldOut)
|
||||
{
|
||||
if (HasChangeAddress == true)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
await AutoBuy();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.BuyErrMsg = ex.Message;
|
||||
}
|
||||
Invoke(() => { this.Close(); });
|
||||
});
|
||||
}
|
||||
}));
|
||||
}
|
||||
});
|
||||
@@ -612,6 +618,137 @@ namespace TemuKJD.ToolForms
|
||||
}
|
||||
}
|
||||
|
||||
public async Task AutoBuy()
|
||||
{
|
||||
if (IsSoldOut)
|
||||
throw new Exception("商品已售罄");
|
||||
|
||||
//for (int i = 0; i < 50; i++)
|
||||
//{
|
||||
// if (HasChangeAddress != true)
|
||||
// Thread.Sleep(500);
|
||||
//}
|
||||
//if (!HasChangeAddress)
|
||||
//{
|
||||
// throw new Exception("订单收货地址修改失败");
|
||||
//}
|
||||
|
||||
await CheckSourceCode();
|
||||
|
||||
await SetAliPaySecret();
|
||||
}
|
||||
|
||||
public async Task SetAliPaySecret()
|
||||
{
|
||||
var host = cefWebBrowser.GetBrowser().GetHost();
|
||||
var client = cefWebBrowser.GetDevToolsClient();
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
Thread.Sleep(50);
|
||||
if (host == null || client == null)
|
||||
{
|
||||
host = cefWebBrowser.GetBrowser().GetHost();
|
||||
client = cefWebBrowser.GetDevToolsClient();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (host == null || client == null)
|
||||
{
|
||||
throw new Exception("页面加载异常");
|
||||
}
|
||||
|
||||
var sourceCode = txtSourceCode.Text.Trim();
|
||||
var jsStr1 = @"(function() { var elements = document.getElementsByTagName('span');
|
||||
for (i = elements.length - 1; i >= 0; i--){
|
||||
var element = elements[i];
|
||||
if (element.innerHTML.indexOf('支付宝') >= 0) {
|
||||
element.click();
|
||||
return 'success';
|
||||
}
|
||||
}
|
||||
return '';
|
||||
})();";
|
||||
Thread.Sleep(Randomx.GetId(500, 1000));
|
||||
var ts1 = await client.Runtime.EvaluateAsync(jsStr1, null, true, null, null, true, null, true);
|
||||
var jsStr2 = @"(function() { var elements = document.getElementsByTagName('span');
|
||||
for (i = elements.length - 1; i >= 0; i--){
|
||||
var element = elements[i];
|
||||
if (element.innerHTML.indexOf('立即支付') >= 0) {
|
||||
element.click();
|
||||
return 'success';
|
||||
}
|
||||
}
|
||||
return '';
|
||||
})();";
|
||||
var ts2 = await client.Runtime.EvaluateAsync(jsStr2, null, true, null, null, true, null, true);
|
||||
if (ts1.Result?.Value.ParseToString() != "success" || ts2.Result?.Value.ParseToString() != "success")
|
||||
{
|
||||
throw new Exception("支付方式获取失败");
|
||||
}
|
||||
|
||||
Thread.Sleep(Randomx.GetId(1500, 2000));
|
||||
var jsStr3 = @"(function() { var elements = document.getElementsByTagName('span');
|
||||
for (i = elements.length - 1; i >= 0; i--){
|
||||
var element = elements[i];
|
||||
if (element.innerHTML.indexOf('确认付款') >= 0) {
|
||||
element.click();
|
||||
return 'success';
|
||||
}
|
||||
}
|
||||
return '';
|
||||
})();";
|
||||
var ts3 = await client.Runtime.EvaluateAsync(jsStr3, null, true, null, null, true, null, true);
|
||||
if (!this.Created)
|
||||
throw new Exception("窗口已关闭");
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
if (ts3.Result?.Value is string rstStr)
|
||||
{
|
||||
if (rstStr == "success")
|
||||
break;
|
||||
}
|
||||
Thread.Sleep(200);
|
||||
ts3 = await client.Runtime.EvaluateAsync(jsStr3, null, true, null, null, true, null, true);
|
||||
}
|
||||
Thread.Sleep(Randomx.GetId(10000, 12500));
|
||||
}
|
||||
|
||||
public async Task CheckSourceCode()
|
||||
{
|
||||
var host = cefWebBrowser.GetBrowser().GetHost();
|
||||
var client = cefWebBrowser.GetDevToolsClient();
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
Thread.Sleep(50);
|
||||
if (host == null || client == null)
|
||||
{
|
||||
host = cefWebBrowser.GetBrowser().GetHost();
|
||||
client = cefWebBrowser.GetDevToolsClient();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (host == null || client == null)
|
||||
{
|
||||
throw new Exception("页面加载异常");
|
||||
}
|
||||
|
||||
var sourceCode = txtSourceCode.Text.Trim();
|
||||
var jsStr1 = @"(function() { var elements = document.getElementsByTagName('div');
|
||||
for (i = elements.length - 1; i >= 0; i--){
|
||||
var element = elements[i];
|
||||
if (element.innerHTML.indexOf('" + sourceCode + @"') >= 0) {
|
||||
return 'success';
|
||||
}
|
||||
}
|
||||
return '';
|
||||
})();";
|
||||
var ts1 = await client.Runtime.EvaluateAsync(jsStr1, null, true, null, null, true, null, true);
|
||||
if (ts1.Result?.Value.ParseToString() != "success")
|
||||
{
|
||||
throw new Exception("溯源码不匹配");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取溯源码
|
||||
/// </summary>
|
||||
|
||||
Reference in new issue
Block a user