拼多多买手订单抓取推送
This commit is contained in:
1 parent
fa96cc1444
commit
caeea6e0c3
18 files changed
+1703
-215
No files matched your search
@@ -4,6 +4,10 @@ using AllBase.Model.Param;
|
||||
using AllBase.Model.Result;
|
||||
using AllBase.Model.Result.PDDResult;
|
||||
using AllBase.Model.Result.WXResult;
|
||||
using CefSharp;
|
||||
using CefSharp.WinForms;
|
||||
using NaiBa.CefHelper;
|
||||
using NaiBa.CefHelper.Handler;
|
||||
using NaiBa.Util;
|
||||
using NaiBa.Util.Extension;
|
||||
using Newtonsoft.Json.Linq;
|
||||
@@ -24,6 +28,7 @@ using System.Windows.Forms;
|
||||
using TemuKJD.BaseForms;
|
||||
using TemuKJD.BLL;
|
||||
using TemuKJD.Extension;
|
||||
using TemuKJD.Helper;
|
||||
using TemuKJD.PDDForms.ProductSelectForms;
|
||||
using TemuKJD.PDDForms.ShopForms;
|
||||
using TemuKJD.ToolForms;
|
||||
@@ -36,11 +41,13 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
private static BuyerOrderListForm instance = null;
|
||||
public static BuyerOrderListForm Instance { get { if (instance == null || instance.IsDisposed || instance.Disposing) instance = new BuyerOrderListForm(); return instance; } }
|
||||
ShopLoginInfo currentShop { get { return this.lblCurrentShop.Tag as ShopLoginInfo; } }
|
||||
ConcurrentList<WxOrderInfoLite> lstWxOrderInfoLite { get; set; } = new ConcurrentList<WxOrderInfoLite>();
|
||||
//ConcurrentList<WxOrderInfoLite> lstWxOrderInfoLite { get; set; } = new ConcurrentList<WxOrderInfoLite>();
|
||||
ConcurrentList<PddBuyerOrderInfoLite> lstPddBuyerOrderInfoLite { get; set; } = new ConcurrentList<PddBuyerOrderInfoLite>();
|
||||
public CancellationTokenSource cancellationTokenSource { get; set; } = new CancellationTokenSource();
|
||||
public ChromiumWebBrowser cefWebBrowser = null;
|
||||
public bool loadComplate = false;
|
||||
public bool firstVisible = false;
|
||||
public DateTime nextGetOrderTime = DateTime.Now;
|
||||
public DateTime nextGetOrderTime = DateTime.MinValue;
|
||||
|
||||
public BuyerOrderListForm()
|
||||
{
|
||||
@@ -54,8 +61,14 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
dtpEndTime.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
|
||||
dgvBuyer.AddSelectorColumn("colSelect");
|
||||
|
||||
|
||||
lstPddBuyerOrderInfoLite = NaiBa.Util.Helper.ConfigHelper.LoadConfig<ConcurrentList<PddBuyerOrderInfoLite>> ("pdd_buyer_order");
|
||||
if (lstPddBuyerOrderInfoLite == null)
|
||||
lstPddBuyerOrderInfoLite = new ConcurrentList<PddBuyerOrderInfoLite>();
|
||||
ShowOrder();
|
||||
|
||||
GetBuyer();
|
||||
AutoGetOrder();
|
||||
AutoGetPddOrder();
|
||||
loadComplate = true;
|
||||
}
|
||||
|
||||
@@ -63,6 +76,223 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
{
|
||||
}
|
||||
|
||||
void ShowOrder()
|
||||
{
|
||||
Task.Run(() => {
|
||||
|
||||
foreach(var order in lstPddBuyerOrderInfoLite)
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
ShowOrder(order);
|
||||
}));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void ShowOrder(PddBuyerOrderInfoLite order)
|
||||
{
|
||||
if (order == null)
|
||||
return;
|
||||
|
||||
var row = dgvPddBuyerOrder.Rows.Cast<DataGridViewRow>().FirstOrDefault(p => p.Cells.GetCellValueFromColumnName("colOPddOrderSn").ParseToString() == order.order_sn);
|
||||
if (row == null)
|
||||
{
|
||||
var rowIndex = this.dgvPddBuyerOrder.Rows.Add(
|
||||
false,
|
||||
order.buyerId,
|
||||
order.buyerName,
|
||||
order.order_sn,
|
||||
order.order_time == null ? "" : BaseClass.StampToDateTime(order.order_time.ParseToInt()).ToString("yy-MM-dd HH:ss"),
|
||||
"", // 图片路径,
|
||||
DataGridViewExtension.defaultBitmap, // 订单图片
|
||||
order.order_Goods == null ? "" : string.Join("\r\n", order.order_Goods.Select(g => g.goods_name + " x" + g.goods_number)), // 商品信息
|
||||
order.order_amount * 0.01,
|
||||
order.order_status_prompt,
|
||||
order.outExpressCompanyName,
|
||||
order.tracking_number,
|
||||
order.sendStatus,
|
||||
"发送"
|
||||
);
|
||||
row = dgvPddBuyerOrder.Rows[rowIndex];
|
||||
row.Height = 40;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//row.Cells["colOSelect"].Value = selectIds.Contains(buyer.buyer_id);
|
||||
row.Cells["colOBuyerId"].Value = order.buyerId;
|
||||
row.Cells["colOBuyerName"].Value = order.buyerName;
|
||||
row.Cells["colOPddOrderSn"].Value = order.order_sn;
|
||||
row.Cells["colOOrderTime"].Value = order.order_time == null ? "" : BaseClass.StampToDateTime(order.order_time.ParseToInt()).ToString("yy-MM-dd HH:ss");
|
||||
//row.Cells["colOImgUrl"].Value = "";
|
||||
// 商品信息
|
||||
row.Cells["colOGoodsInfo"].Value = order.order_Goods == null ? "" : string.Join("\r\n", order.order_Goods.Select(g => g.goods_name + " x" + g.goods_number));
|
||||
row.Cells["colOOrderAmount"].Value = order.order_amount * 0.01;
|
||||
row.Cells["dgvOStatus"].Value = order.order_status_prompt;
|
||||
row.Cells["colOExpressName"].Value = order.outExpressCompanyName;
|
||||
row.Cells["colOExpressId"].Value = order.tracking_number;
|
||||
row.Cells["colOMsg"].Value = order.sendStatus;
|
||||
}
|
||||
}
|
||||
|
||||
private void InitCef()
|
||||
{
|
||||
cefWebBrowser = CEFBrowser.CreateChromiumWebBrowser("about:blank", false);
|
||||
CustomResourceRequestHandlerLocal resourceRequestHandler = new CustomResourceRequestHandlerLocal();
|
||||
resourceRequestHandler.ResourceLoadCompleteEvent += RequestHandler_ResourceLoadComplete;
|
||||
resourceRequestHandler.BeforeResourceLoadEvent += RequestHandler_BeforeResourceLoad;
|
||||
cefWebBrowser.RequestHandler = new CustomRequestHandler(resourceRequestHandler);
|
||||
var lifeSapnHandler = new LifeSpanHandlerLocal(PopWindowType.SelfWindow);
|
||||
cefWebBrowser.LifeSpanHandler = lifeSapnHandler;
|
||||
cefWebBrowser.KeyboardHandler = new KeyboardHandler();
|
||||
cefWebBrowser.FrameLoadEnd += CefWebBrowser_FrameLoadEnd;
|
||||
cefWebBrowser.AddressChanged += CefWebBrowser_AddressChanged;
|
||||
cefWebBrowser.LoadError += CefWebBrowser_LoadError;
|
||||
cefWebBrowser.Dock = DockStyle.Fill;
|
||||
cefWebBrowser.SendToBack();
|
||||
splitContainer3.Panel2.Controls.Add(cefWebBrowser);
|
||||
|
||||
//js绑定C#对象
|
||||
//PDDShopBrowserObject shopObj = new PDDShopBrowserObject();
|
||||
//shopObj.OnInfoReceived += ShopObj_OnInfoReceived;
|
||||
//CefSharpSettings.WcfEnabled = true;
|
||||
//cefWebBrowser.JavascriptObjectRepository.Register(
|
||||
// name: "shopObj",
|
||||
// objectToBind: shopObj,
|
||||
// isAsync: false,
|
||||
// options: new BindingOptions { Binder = BindingOptions.DefaultBinder.Binder /*CamelCaseJavascriptNames = false*/ /*cef79*/ }
|
||||
//);
|
||||
}
|
||||
|
||||
private void RequestHandler_ResourceLoadComplete(object sender, string url, string postData, string responseData, IRequest request)
|
||||
{
|
||||
if (url.StartsWith("https://mobile.yangkeduo.com/orders.html?type=3&order_index=0"))
|
||||
{
|
||||
|
||||
}
|
||||
if (url.StartsWith("https://mobile.yangkeduo.com/orders.html?type=3"))
|
||||
{
|
||||
|
||||
}
|
||||
if (url.StartsWith("https://mobile.yangkeduo.com/orders.html?type=2"))
|
||||
{
|
||||
|
||||
}
|
||||
if (url.StartsWith("https://mobile.yangkeduo.com/proxy/api/api/aristotle/order_list_v3"))
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
CefReadBuyerOrder(url, responseData);
|
||||
});
|
||||
}
|
||||
//if (url.StartsWith("https://mobile.yangkeduo.com/proxy/api/api/caterham/v3/query/my_order_group") && !string.IsNullOrEmpty(currentReadBuyer))
|
||||
// currentReadBuyer = "";
|
||||
}
|
||||
|
||||
string currentReadBuyer = "";
|
||||
void CefReadBuyerOrder(string url, string data)
|
||||
{
|
||||
if (data.Contains("轻奢壁挂式香皂盒置物架卫生间沥水家居可拆卸收纳盒翻盖肥皂盒"))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
var buyer = GlobalConfig.BuyerLoginList.FirstOrDefault(b => url.Contains(b.buyer_id));
|
||||
if (buyer == null)
|
||||
return;
|
||||
|
||||
//{"server_time":1775789489,"orders":[],"extra_info":{}}
|
||||
if (data.Contains("\"orders\":[]"))
|
||||
{
|
||||
currentReadBuyer = "";
|
||||
return;
|
||||
}
|
||||
if (data.Contains("\"error_code\":40001"))
|
||||
{
|
||||
currentReadBuyer = "";
|
||||
CheckBuyerLogin(new List<BuyerLoginInfo> { buyer }, false);
|
||||
return;
|
||||
}
|
||||
|
||||
var list = JsonHelper.DeserializeJsonToList<PddBuyerOrderInfoLite>(JsonHelper.JObjectParse(data)["orders"].ParseToString());
|
||||
foreach (var o in list)
|
||||
{
|
||||
o.buyerId = buyer.buyer_id;
|
||||
o.buyerName = buyer.buyer_name;
|
||||
o.outExpressCompanyMsg = o.extra_info.order_hint?.message; // todo 此处转换
|
||||
|
||||
PddBuyerOrderInfoLite order = null;
|
||||
if (!this.lstPddBuyerOrderInfoLite.Any(or => or.order_sn == o.order_sn))
|
||||
{
|
||||
order = o;
|
||||
lstPddBuyerOrderInfoLite.Add(order);
|
||||
}
|
||||
else
|
||||
{
|
||||
order = this.lstPddBuyerOrderInfoLite.FirstOrDefault(or => or.order_sn == o.order_sn);
|
||||
if (JsonHelper.SerializeObject(order) != JsonHelper.SerializeObject(o))
|
||||
{
|
||||
//order = JsonHelper.DeserializeJsonToObject<PddBuyerOrderInfoLite>(JsonHelper.SerializeObject(o));
|
||||
order.activity_type = o.activity_type;
|
||||
order.discount_amount = o.discount_amount;
|
||||
order.display_amount = o.display_amount;
|
||||
order.extra_info = JsonHelper.DeserializeJsonToObject<extra_info>(JsonHelper.SerializeObject(o.extra_info));
|
||||
order.order_amount = o.order_amount;
|
||||
order.order_Goods = JsonHelper.DeserializeJsonToList<order_good>(JsonHelper.SerializeObject(o.order_Goods));
|
||||
order.order_link_url = o.order_link_url;
|
||||
order.order_prompt_color = o.order_prompt_color;
|
||||
order.order_status_prompt = o.order_status_prompt;
|
||||
order.parent_order_sn = o.parent_order_sn;
|
||||
order.service_amount = o.service_amount;
|
||||
order.shipping_amount = o.shipping_amount;
|
||||
order.outExpressCompanyMsg = o.outExpressCompanyMsg;
|
||||
order.order_time = o.order_time;
|
||||
order.tracking_number = o.tracking_number;
|
||||
}
|
||||
}
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
//SendOrderE57(order);
|
||||
});
|
||||
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
ShowOrder(order);
|
||||
}));
|
||||
}
|
||||
NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_buyer_order", lstPddBuyerOrderInfoLite);
|
||||
}
|
||||
|
||||
private bool RequestHandler_BeforeResourceLoad(object sender, string url, string postData, IRequest request)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
private void CefWebBrowser_FrameLoadEnd(object sender, CefSharp.FrameLoadEndEventArgs e)
|
||||
{
|
||||
////js绑定C#对象 html页面内声明绑定的C#对象
|
||||
//StringBuilder sb = new StringBuilder();
|
||||
//sb.Append("(function(){");
|
||||
//sb.Append("CefSharp.BindObjectAsync('shopObj');");
|
||||
//sb.Append("})();");
|
||||
//cefWebBrowser.GetBrowser().MainFrame.EvaluateScriptAsync(sb.ToString());
|
||||
}
|
||||
private void CefWebBrowser_AddressChanged(object sender, CefSharp.AddressChangedEventArgs e)
|
||||
{
|
||||
if (this.Created && !this.Disposing && !this.IsDisposed)
|
||||
{
|
||||
//Invoke(new Action(() =>
|
||||
//{
|
||||
// currentUrl = e.Address;
|
||||
// txtAddress.Text = e.Address;
|
||||
//}));
|
||||
}
|
||||
}
|
||||
private void CefWebBrowser_LoadError(object sender, CefSharp.LoadErrorEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
void GetBuyer()
|
||||
{
|
||||
var ids = dgvBuyer.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colSelect"].Value.ParseToBool() == true).Select(s => s.Cells["colBuyerId"].Value.ParseToString()).ToList();
|
||||
@@ -81,8 +311,25 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
if (result.Contains("\"code\":200"))
|
||||
{
|
||||
List<BuyerLoginInfo> loginInfoLst = JsonHelper.DeserializeJsonToList<BuyerLoginInfo>(JsonHelper.JObjectParse(result)["data"].ParseToString());
|
||||
GlobalConfig.BuyerLoginList.Clear();
|
||||
GlobalConfig.BuyerLoginList.AddRange(loginInfoLst);
|
||||
GlobalConfig.BuyerLoginList.RemoveAll(bu => !loginInfoLst.Any(b => b.buyer_id == bu.buyer_id));
|
||||
foreach (var b in loginInfoLst)
|
||||
{
|
||||
var buyer = GlobalConfig.BuyerLoginList.FirstOrDefault(bu => bu.buyer_id == b.buyer_id);
|
||||
if (buyer == null)
|
||||
GlobalConfig.BuyerLoginList.Add(b);
|
||||
else
|
||||
{
|
||||
buyer.add_time = b.add_time;
|
||||
buyer.buyer_id = b.buyer_id;
|
||||
buyer.buyer_name = b.buyer_name;
|
||||
buyer.buyer_nick = b.buyer_nick;
|
||||
buyer.cookie = b.cookie;
|
||||
buyer.mdy_time = b.mdy_time;
|
||||
buyer.notes = b.notes;
|
||||
buyer.status = b.status;
|
||||
buyer.user_name = b.user_name;
|
||||
}
|
||||
}
|
||||
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
@@ -93,15 +340,7 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
var rowIndex = this.dgvBuyer.Rows.Add(
|
||||
ids.Contains(buyer.buyer_id),
|
||||
buyer.buyer_id,
|
||||
buyer.buyer_name,
|
||||
buyer.buyer_nick,
|
||||
buyer.notes,
|
||||
"访问",
|
||||
buyer.status
|
||||
);
|
||||
BindBuyer(buyer, "", ids);
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -113,16 +352,70 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
});
|
||||
}
|
||||
|
||||
void AutoGetOrder()
|
||||
private void BindBuyer(List<BuyerLoginInfo> buyers, string msg = "", List<string> selectIds = null)
|
||||
{
|
||||
foreach (var buyer in buyers)
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
BindBuyer(buyer, msg, selectIds);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
private void BindBuyer(BuyerLoginInfo buyer, string msg = "", List<string> selectIds = null)
|
||||
{
|
||||
if (buyer == null)
|
||||
return;
|
||||
|
||||
if (selectIds == null)
|
||||
selectIds = dgvBuyer.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colSelect"].Value.ParseToBool() == true).Select(s => s.Cells["colBuyerId"].Value.ParseToString()).ToList();
|
||||
|
||||
bool canUse = buyer.status == "在线";
|
||||
var row = dgvBuyer.Rows.Cast<DataGridViewRow>().FirstOrDefault(p => p.Cells.GetCellValueFromColumnName("colBuyerId").ParseToString() == buyer.buyer_id);
|
||||
if (row == null)
|
||||
{
|
||||
var rowIndex = this.dgvBuyer.Rows.Add(
|
||||
selectIds.Contains(buyer.buyer_id),
|
||||
buyer.buyer_id,
|
||||
buyer.buyer_name,
|
||||
buyer.buyer_nick,
|
||||
buyer.notes,
|
||||
"访问",
|
||||
buyer.status
|
||||
);
|
||||
row = dgvBuyer.Rows[rowIndex];
|
||||
}
|
||||
else
|
||||
{
|
||||
row.Cells["colSelect"].Value = selectIds.Contains(buyer.buyer_id);
|
||||
row.Cells["colBuyerId"].Value = buyer.buyer_id;
|
||||
row.Cells["dgvBuyerName"].Value = buyer.buyer_name;
|
||||
row.Cells["dgvBuyerNick"].Value = buyer.buyer_nick;
|
||||
row.Cells["colShopNotes"].Value = buyer.notes;
|
||||
row.Cells["colBuyerId"].Value = buyer.buyer_id;
|
||||
row.Cells["colLoginStatus"].Value = buyer.status;
|
||||
row.Cells["colMessage"].Value = msg;
|
||||
}
|
||||
|
||||
(row.Cells["colLoginStatus"] as DataGridViewLinkCell).Style.ForeColor = canUse ? Color.Blue : Color.Red;
|
||||
(row.Cells["colLoginStatus"] as DataGridViewLinkCell).LinkColor = canUse ? Color.Blue : Color.Red;
|
||||
(row.Cells["colLoginStatus"] as DataGridViewLinkCell).ActiveLinkColor = canUse ? Color.LightBlue : Color.OrangeRed;
|
||||
(row.Cells["colLoginStatus"] as DataGridViewLinkCell).VisitedLinkColor = canUse ? Color.DarkBlue : Color.DarkRed;
|
||||
}
|
||||
|
||||
|
||||
void AutoGetPddOrder()
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
{
|
||||
Thread.Sleep(5000);
|
||||
while (true)
|
||||
{
|
||||
if (DateTime.Now > nextGetOrderTime)
|
||||
{
|
||||
nextGetOrderTime = DateTime.Now.AddMinutes(30);
|
||||
GetOrder();
|
||||
GetPddOrder();
|
||||
}
|
||||
Thread.Sleep(1000);
|
||||
Invoke(new Action(() =>
|
||||
@@ -134,14 +427,89 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
});
|
||||
}
|
||||
|
||||
void GetOrder()
|
||||
void GetPddOrder()
|
||||
{
|
||||
if (cancellationTokenSource != null)
|
||||
cancellationTokenSource.Cancel();
|
||||
cancellationTokenSource = new CancellationTokenSource();
|
||||
Task.Run(() =>
|
||||
{
|
||||
foreach (var shop in GlobalConfig.ShopLoginList)
|
||||
{
|
||||
currentReadBuyer = "";
|
||||
|
||||
foreach (var buyer in GlobalConfig.BuyerLoginList)
|
||||
{
|
||||
if (cancellationTokenSource.IsCancellationRequested)
|
||||
break;
|
||||
|
||||
if (buyer.status != "在线")
|
||||
continue;
|
||||
|
||||
try
|
||||
{
|
||||
if (cefWebBrowser == null)
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
InitCef();
|
||||
}));
|
||||
while (!cefWebBrowser.IsBrowserInitialized || !cefWebBrowser.GetBrowser().MainFrame.IsValid)
|
||||
{
|
||||
Thread.Sleep(1);
|
||||
}
|
||||
}
|
||||
|
||||
CEFBrowser.DeleteCookie(cefWebBrowser.GetCookieManager(null));
|
||||
|
||||
var cookieLst = JsonHelper.DeserializeJsonToList<CefSharp.Cookie>(buyer?.cookie);
|
||||
var t = CEFBrowser.SetCookieAsync(JsonHelper.SerializeObject(cookieLst), cefWebBrowser.GetCookieManager(null));
|
||||
|
||||
string readBuyer = buyer.buyer_id;
|
||||
currentReadBuyer = buyer.buyer_id;
|
||||
cefWebBrowser.Load("https://mobile.yangkeduo.com/orders.html?type=2");
|
||||
Thread.Sleep(Randomx.GetId(2000, 3000));
|
||||
|
||||
while (currentReadBuyer == readBuyer)
|
||||
{
|
||||
if (cancellationTokenSource.IsCancellationRequested)
|
||||
break;
|
||||
|
||||
Thread.Sleep(Randomx.GetId(100,300));
|
||||
|
||||
var jsStr = @"window.scroll({
|
||||
top: document.body.scrollHeight,
|
||||
left: 0,
|
||||
behavior: 'smooth' // 可选,使滚动平滑
|
||||
});";
|
||||
var t1 = cefWebBrowser.GetMainFrame().EvaluateScriptAsync(jsStr);
|
||||
t1.Wait(1000);
|
||||
}
|
||||
Thread.Sleep(Randomx.GetId(2000, 3000));
|
||||
|
||||
readBuyer = buyer.buyer_id;
|
||||
currentReadBuyer = buyer.buyer_id;
|
||||
cefWebBrowser.Load("https://mobile.yangkeduo.com/orders.html?type=3");
|
||||
Thread.Sleep(Randomx.GetId(2000, 3000));
|
||||
|
||||
while (currentReadBuyer == readBuyer)
|
||||
{
|
||||
if (cancellationTokenSource.IsCancellationRequested)
|
||||
break;
|
||||
|
||||
Thread.Sleep(Randomx.GetId(100, 300));
|
||||
|
||||
var jsStr = @"window.scroll({
|
||||
top: document.body.scrollHeight,
|
||||
left: 0,
|
||||
behavior: 'smooth' // 可选,使滚动平滑
|
||||
});";
|
||||
var t1 = cefWebBrowser.GetMainFrame().EvaluateScriptAsync(jsStr);
|
||||
t1.Wait(1000);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
Thread.Sleep(Randomx.GetId(6000, 8000));
|
||||
}
|
||||
}, cancellationTokenSource.Token);
|
||||
}
|
||||
@@ -149,7 +517,7 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
private void btnSearch_Click(object sender, EventArgs e)
|
||||
{
|
||||
nextGetOrderTime = DateTime.Now.AddMinutes(30);
|
||||
GetOrder();
|
||||
GetPddOrder();
|
||||
}
|
||||
|
||||
private void pnlEmpty_Click(object sender, EventArgs e)
|
||||
@@ -161,7 +529,7 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
{
|
||||
if (e.ColumnIndex < 0 || e.RowIndex < 0)
|
||||
return;
|
||||
string headerText = dgvDbProduct.Columns[e.ColumnIndex].HeaderText;
|
||||
string headerText = dgvWxOrder.Columns[e.ColumnIndex].HeaderText;
|
||||
//var dbId = dgvDbProduct.Rows[e.RowIndex].Cells["col_db_id"].Value.ParseToString();
|
||||
//var dbProduct = lstTemuDbProduct.FirstOrDefault(p => p.id.ToString() == dbId);
|
||||
|
||||
@@ -187,23 +555,20 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
//dgvDbProduct.Rows[e.RowIndex].Cells["colSkuReplaceImgUrl"].Value = dbProduct.sku_img_replace_url;
|
||||
break;
|
||||
case "主图":
|
||||
ShowImgForm imgFrom = new ShowImgForm(dgvDbProduct.Rows[e.RowIndex].Cells["colImgUrl"].Value.ParseToString().Replace("?imageView2/2/w/90/h/90", ""));
|
||||
ShowImgForm imgFrom = new ShowImgForm(dgvWxOrder.Rows[e.RowIndex].Cells["colImgUrl"].Value.ParseToString().Replace("?imageView2/2/w/90/h/90", ""));
|
||||
imgFrom.ShowDialog();
|
||||
break;
|
||||
case "":
|
||||
dgvDbProduct.Rows[e.RowIndex].Cells["colCheck"].Value = !(bool)dgvDbProduct.Rows[e.RowIndex].Cells["colCheck"].Value;
|
||||
dgvWxOrder.Rows[e.RowIndex].Cells["colCheck"].Value = !(bool)dgvWxOrder.Rows[e.RowIndex].Cells["colCheck"].Value;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void dgvDbProduct_Scroll(object sender, ScrollEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void btnStopStop_Click(object sender, EventArgs e)
|
||||
{
|
||||
currentReadBuyer = "";
|
||||
if (cancellationTokenSource != null)
|
||||
cancellationTokenSource.Cancel();
|
||||
Task.Run(() =>
|
||||
@@ -320,7 +685,7 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
// 先从服务端取最新cookie
|
||||
var url = BaseClass.BuildPDDObjString("user/get_buyer");
|
||||
var data = UserLogin.GetSignaturex();
|
||||
data += "&buyer_id=" + buyer.buyer_id;
|
||||
data += "&buyer_ids=" + buyer.buyer_id;
|
||||
data += "&page_size=1";
|
||||
var result = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(result) || !result.Contains("\"code\":200"))
|
||||
@@ -342,7 +707,7 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
if (buyer != null)
|
||||
{
|
||||
var loginResult = CheckBuyerLogin(buyer);
|
||||
if (loginResult.Contains("\"success\":true") && !loginResult.Contains("\"login\":true"))
|
||||
if (!loginResult.Contains("\"success\":true") && !loginResult.Contains("\"login\":true") && !loginResult.Contains("\"nickname\""))
|
||||
{
|
||||
buyer.cookie = "[]";
|
||||
foreach (var buy in buys)
|
||||
@@ -367,6 +732,7 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
this.statusBar.lblTaskStatus.Text = "正在检测...";
|
||||
this.statusBar.pgbTaskProgress.Value = (i + 1);
|
||||
this.statusBar.pgbTaskProgress.Text = (i + 1) + "/" + checkBuyers.Count;
|
||||
BindBuyer(buyer);
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -402,7 +768,6 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
var buyers = GlobalConfig.BuyerLoginList.Where(b => ids.Contains(b.buyer_id)).ToList();
|
||||
Task.Run(() => {
|
||||
CheckBuyerLogin(buyers);
|
||||
GetBuyer();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -445,6 +810,114 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
GetBuyer();
|
||||
});
|
||||
}
|
||||
|
||||
private void dgvPddBuyerOrder_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
if (e.ColumnIndex < 0 || e.RowIndex < 0)
|
||||
return;
|
||||
string headerText = dgvPddBuyerOrder.Columns[e.ColumnIndex].HeaderText;
|
||||
var orderSn = dgvPddBuyerOrder.Rows[e.RowIndex].Cells["colOPddOrderSn"].Value.ParseToString();
|
||||
var order = lstPddBuyerOrderInfoLite.FirstOrDefault(p => p.order_sn == orderSn);
|
||||
|
||||
|
||||
switch (headerText)
|
||||
{
|
||||
case "详情":
|
||||
case "编辑/详情":
|
||||
break;
|
||||
case "发送":
|
||||
SendOrderE57(order);
|
||||
break;
|
||||
case "图片":
|
||||
ShowImgForm imgFrom = new ShowImgForm(dgvPddBuyerOrder.Rows[e.RowIndex].Cells["colImgUrl"].Value.ParseToString().Replace("?imageView2/2/w/90/h/90", ""));
|
||||
imgFrom.ShowDialog();
|
||||
break;
|
||||
case "":
|
||||
case "全选":
|
||||
dgvPddBuyerOrder.Rows[e.RowIndex].Cells["colCheck"].Value = !(bool)dgvPddBuyerOrder.Rows[e.RowIndex].Cells["colCheck"].Value;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void SendOrderE57(PddBuyerOrderInfoLite order)
|
||||
{
|
||||
if (order.sendStatus == "已发送")
|
||||
{
|
||||
return;
|
||||
}
|
||||
// 已发货且没有运单号的属于已退货,不再发送
|
||||
if (order.order_status_prompt != "拼单成功,待发货" && string.IsNullOrEmpty(order.tracking_number))
|
||||
{
|
||||
order.sendStatus = "已发货无运单号";
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
ShowOrder(order);
|
||||
}));
|
||||
NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_buyer_order", lstPddBuyerOrderInfoLite);
|
||||
return;
|
||||
}
|
||||
|
||||
JObject obj = new JObject();
|
||||
obj["platform"] = "WEISHOP";
|
||||
obj["outAmount"] = order.order_amount;
|
||||
obj["outAccount"] = order.buyerName;
|
||||
obj["outOrderNo"] = order.order_sn;
|
||||
obj["outExpressCompany"] = order.outExpressCompanyCode;
|
||||
obj["outExpressNo"] = order.tracking_number;
|
||||
var dataStr = JsonHelper.SerializeObject(obj);
|
||||
string url = "https://po.e57.cn/prod-api/api/oms-api/external_procurement/bind";
|
||||
//成功 "<ResultVo><code>0</code><msg>SUCCESS</msg><data/><totalRecords/></ResultVo>"
|
||||
//失败 已存在
|
||||
//<ResultVo><code>1505</code><msg>调用微信接口更新物流信息失败: 非法参数, 同运单号拦截 rid: 69d8ab9c-22baa3b1-67de0d95</msg><data/><totalRecords/></ResultVo>
|
||||
var exportRst = WXHttpResponseBLL.e57PostResponse(url, dataStr, "");
|
||||
if(exportRst.Contains("SUCCESS") || exportRst.Contains("已存在") || exportRst.Contains("同运单号拦截"))
|
||||
{
|
||||
order.sendStatus = "已发送";
|
||||
NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_buyer_order", lstPddBuyerOrderInfoLite);
|
||||
}
|
||||
else if (exportRst != null && exportRst.Contains("<msg>") && exportRst.Contains("</msg>"))
|
||||
{
|
||||
order.sendStatus = exportRst.Substring(exportRst.IndexOf("<msg>") + 5).Substring(0, exportRst.IndexOf("</msg>"));
|
||||
NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_buyer_order", lstPddBuyerOrderInfoLite);
|
||||
}
|
||||
else
|
||||
{
|
||||
order.sendStatus = "发送失败 " + exportRst;
|
||||
NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_buyer_order", lstPddBuyerOrderInfoLite);
|
||||
}
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
ShowOrder(order);
|
||||
}));
|
||||
//Thread.Sleep(500);
|
||||
}
|
||||
|
||||
private void panelEx3_Click(object sender, EventArgs e)
|
||||
{
|
||||
dgvPddBuyerOrder.Visible = !dgvPddBuyerOrder.Visible;
|
||||
if (dgvPddBuyerOrder.Visible == false)
|
||||
panelEx3.Text = "打开";
|
||||
else
|
||||
panelEx3.Text = "折叠";
|
||||
}
|
||||
|
||||
private void panelEx1_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dgvPddBuyerOrder.Height < dgvPddBuyerOrder.Parent.Height)
|
||||
dgvPddBuyerOrder.Height += 50;
|
||||
if (dgvPddBuyerOrder.Height > dgvPddBuyerOrder.Parent.Height)
|
||||
dgvPddBuyerOrder.Height = dgvPddBuyerOrder.Parent.Height;
|
||||
}
|
||||
|
||||
private void panelEx2_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dgvPddBuyerOrder.Height > 100)
|
||||
dgvPddBuyerOrder.Height -= 100;
|
||||
if (dgvPddBuyerOrder.Height < 100)
|
||||
dgvPddBuyerOrder.Height = 100;
|
||||
}
|
||||
}
|
||||
|
||||
public class YkdBuyerOrder
|
||||
|
||||
Reference in new issue
Block a user