店铺优化数据抓取 拼多多买手刷新订单逻辑优化

This commit is contained in:
wule_5900x committed 2026-04-26 01:30:31 +08:00
1 parent 0e6a927cf2
commit b5d8818485
14 files changed
+2492 -615

No files matched your search

+424 -21
View File
@@ -43,6 +43,7 @@ namespace TemuKJD.WXForms.TalkForms
ShopLoginInfo currentShop { get { return this.lblCurrentShop.Tag as ShopLoginInfo; } }
//ConcurrentList<WxOrderInfoLite> lstWxOrderInfoLite { get; set; } = new ConcurrentList<WxOrderInfoLite>();
ConcurrentList<PddBuyerOrderInfoLite> lstPddBuyerOrderInfoLite { get; set; } = new ConcurrentList<PddBuyerOrderInfoLite>();
ConcurrentList<PddBuyerAfterSaleInfoLite> lstPddBuyerAfterSaleInfoLite { get; set; } = new ConcurrentList<PddBuyerAfterSaleInfoLite>();
public CancellationTokenSource cancellationTokenSource { get; set; } = new CancellationTokenSource();
public ChromiumWebBrowser cefWebBrowser = null;
public BuyerOrderConfig buyerOrderConfig = new BuyerOrderConfig();
@@ -50,6 +51,7 @@ namespace TemuKJD.WXForms.TalkForms
public bool isLoadComplate = false;
public bool firstVisible = false;
bool isInitOrder = false;
bool isInitAfterSale = false;
bool isInitBuyer = false;
bool isReadOrder = false;
@@ -65,6 +67,10 @@ namespace TemuKJD.WXForms.TalkForms
dtpStartTime.Value = DateTime.Now.Date.AddMonths(-1);
dtpEndTime.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
dgvBuyer.AddSelectorColumn("colSelect");
dgvAfterSale.Location = new Point(dgvPddBuyerOrder.Location.X, dgvPddBuyerOrder.Location.Y);
dgvAfterSale.Width = dgvPddBuyerOrder.Width;
dgvAfterSale.Height = dgvPddBuyerOrder.Height;
dgvAfterSale.SendToBack();
InitCef();
@@ -82,6 +88,11 @@ namespace TemuKJD.WXForms.TalkForms
lstPddBuyerOrderInfoLite = new ConcurrentList<PddBuyerOrderInfoLite>();
lstPddBuyerOrderInfoLite.RemoveAll(o => o.order_time < BaseClass.DateTimeToTimestampSeconds(DateTime.Now.AddMonths(-1)));
lstPddBuyerAfterSaleInfoLite = NaiBa.Util.Helper.ConfigHelper.LoadConfig<ConcurrentList<PddBuyerAfterSaleInfoLite>>("pdd_buyer_after_sale_list");
if (lstPddBuyerAfterSaleInfoLite == null)
lstPddBuyerAfterSaleInfoLite = new ConcurrentList<PddBuyerAfterSaleInfoLite>();
lstPddBuyerAfterSaleInfoLite.RemoveAll(o => o.orderDate < DateTime.Now.AddMonths(-1).ToString("yyMMdd").ParseToInt());
GetBuyer();
Task.Run(() =>
@@ -92,7 +103,7 @@ namespace TemuKJD.WXForms.TalkForms
}
ShowExistOrder();
while (isInitOrder)
while (isInitOrder || isInitAfterSale)
{
Thread.Sleep(500);
}
@@ -104,7 +115,7 @@ namespace TemuKJD.WXForms.TalkForms
while(true)
{
Thread.Sleep(500);
if (isReadOrder || isInitBuyer || isInitOrder)
if (isReadOrder || isInitBuyer || isInitOrder || isInitAfterSale)
{
Invoke(new Action(() => { pictureBox1.Visible = true; }));
}
@@ -138,6 +149,21 @@ namespace TemuKJD.WXForms.TalkForms
}
isInitOrder = false;
});
isInitAfterSale = true;
Task.Run(() => {
foreach (var afterSale in lstPddBuyerAfterSaleInfoLite)
{
if (GlobalConfig.BuyerLoginList.Any(b => b.buyer_id == afterSale.buyerId))
{
Invoke(new Action(() =>
{
ShowAfterSale(afterSale);
}));
}
}
isInitAfterSale = false;
});
}
void ShowOrder(PddBuyerOrderInfoLite order)
@@ -180,7 +206,7 @@ namespace TemuKJD.WXForms.TalkForms
// 商品信息
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["colOStatus"].Value = order.order_status_prompt;
row.Cells["colOExpressName"].Value = order.outExpressCompanyName;
row.Cells["colOExpressId"].Value = order.tracking_number;
row.Cells["colOMsg"].Value = order.sendStatus;
@@ -217,6 +243,80 @@ namespace TemuKJD.WXForms.TalkForms
}
}
void ShowAfterSale(PddBuyerAfterSaleInfoLite afterSale)
{
if (afterSale == null)
return;
var row = dgvAfterSale.Rows.Cast<DataGridViewRow>().FirstOrDefault(p => p.Cells.GetCellValueFromColumnName("colRPddOrderSn").ParseToString() == afterSale.orderSn);
if (row == null)
{
var rowIndex = this.dgvAfterSale.Rows.Add(
false,
afterSale.buyerId,
afterSale.buyerName,
afterSale.orderSn,
afterSale.orderDate,
"", // 图片路径,
DataGridViewExtension.defaultBitmap, // 订单图片
afterSale.listItemGoodsVO == null ? "" : afterSale.listItemGoodsVO.goodsName + " " + afterSale.listItemGoodsVO.spec + " x" + afterSale.listItemGoodsVO.goodsNumber, // 商品信息
afterSale.listItemAmountVO.orderAmount * 0.01m,
afterSale.listItemAmountVO.refundAmount * 0.01m,
afterSale.listItemStatusVO.statusText,
afterSale.sendStatus,
"发送",
"退货"
);
row = dgvAfterSale.Rows[rowIndex];
row.Height = 40;
}
else
{
//row.Cells["colOSelect"].Value = selectIds.Contains(buyer.buyer_id);
row.Cells["colRBuyerId"].Value = afterSale.buyerId;
row.Cells["colRBuyerName"].Value = afterSale.buyerName;
row.Cells["colRPddOrderSn"].Value = afterSale.orderSn;
row.Cells["colROrderDate"].Value = afterSale.orderDate;
//row.Cells["colOImgUrl"].Value = "";
// 商品信息
row.Cells["colRGoodsInfo"].Value = afterSale.listItemGoodsVO == null ? "" : afterSale.listItemGoodsVO.goodsName + " " + afterSale.listItemGoodsVO.spec + " x" + afterSale.listItemGoodsVO.goodsNumber; // 商品信息
row.Cells["colROrderAmount"].Value = afterSale.listItemAmountVO.orderAmount * 0.01;
row.Cells["colRRefundAmount"].Value = afterSale.listItemAmountVO.refundAmount * 0.01;
row.Cells["colRStatus"].Value = afterSale.listItemStatusVO.statusText;
row.Cells["colRMsg"].Value = afterSale.sendStatus;
}
//if (afterSale.outExpressCompanyName == "物流名称获取失败")
// row.Cells["colOExpressName"].Style.ForeColor = Color.Orange;
//else
// row.Cells["colOExpressName"].Style.ForeColor = Control.DefaultForeColor;
//if (afterSale.order_status_prompt.Contains("交易成功"))
//{
// row.Cells["colOMsg"].Value = "[完]" + row.Cells["colOMsg"].Value.ParseToString();
// row.Cells["colOMsg"].Style.ForeColor = Color.Green;
//}
//else if (afterSale.order_status_prompt.Contains("退款成功") || afterSale.order_status_prompt.Contains("交易已取消"))
//{
// row.Cells["colOMsg"].Value = "[已退]" + row.Cells["colOMsg"].Value.ParseToString();
// row.Cells["colOMsg"].Style.ForeColor = Color.Gray;
//}
//else if (afterSale.after_sales != null)
//{
// row.Cells["colOMsg"].Value = "[退货中]" + row.Cells["colOMsg"].Value.ParseToString();
// row.Cells["colOMsg"].Style.ForeColor = Color.DeepSkyBlue;
//}
//else if (!string.IsNullOrEmpty(afterSale.wxRefundStatus))
//{
// row.Cells["colOMsg"].Value = "[" + afterSale.wxRefundStatus + "]" + row.Cells["colOMsg"].Value.ParseToString();
// row.Cells["colOMsg"].Style.ForeColor = Color.Red;
//}
//else
//{
// row.Cells["colOMsg"].Style.ForeColor = Control.DefaultForeColor;
//}
}
private void InitCef()
{
cefWebBrowser = CEFBrowser.CreateChromiumWebBrowser("about:blank", false);
@@ -248,6 +348,7 @@ namespace TemuKJD.WXForms.TalkForms
private void RequestHandler_ResourceLoadComplete(object sender, string url, string postData, string responseData, IRequest request)
{
var cookie1 = request.Headers["Cookie"];
Task.Run(() =>
{
var url1 = url;
@@ -267,6 +368,7 @@ namespace TemuKJD.WXForms.TalkForms
//if (url1.StartsWith("https://mobile.yangkeduo.com/orders.html?type=3&order_index=0"))
//{
//}
// 已发货 第一页
if (url1.StartsWith("https://mobile.yangkeduo.com/orders.html?type=3")) //https://mobile.yangkeduo.com/orders.html?type=3
{
Task.Run(() =>
@@ -291,6 +393,7 @@ namespace TemuKJD.WXForms.TalkForms
}
});
}
// 待发货 第一页
if (url1.StartsWith("https://mobile.yangkeduo.com/orders.html?type=2"))
{
Task.Run(() =>
@@ -323,6 +426,61 @@ namespace TemuKJD.WXForms.TalkForms
});
}
// 读取售后
if (url1.StartsWith("https://mobile.yangkeduo.com/proxy/api/api/blade/after_sales_list"))
{
Task.Run(() =>
{
CefReadBuyerAfterSale(url1, data1);
});
}
// 售后 第一页
if (url1.StartsWith("https://mobile.yangkeduo.com/complaint_list.html"))
{
Task.Run(() =>
{
if (data1.Contains("listItemStatusVo") && data1.Contains("afterSalesId") && data1.Contains("statusText"))
{
var cookie2 = cookie1.Replace(";" , "&").Replace(" ", "");
//var jsonDatas = BaseRegex.GetJsonObjStrJson(ref data1, "pending");
var jsonDatas = BaseRegex.GetJsonObjStrJson(ref data1, "listDataMap");
var jsonData = jsonDatas?.OrderByDescending(x => x.Length).FirstOrDefault();
//var nickName = BaseRegex.GetStringJson(ref data1, "nickName");
//var uid = BaseRegex.GetStringJson(ref data1, "uid");
//var buyerId = GlobalConfig.BuyerLoginList.FirstOrDefault(b => b.buyer_id == uid)?.buyer_id;
//if (buyerId.IsNullOrEmpty())
// buyerId = GlobalConfig.BuyerLoginList.FirstOrDefault(b => b.buyer_nick == nickName)?.buyer_id;
//if (!string.IsNullOrEmpty(jsonData) && !string.IsNullOrEmpty(buyerId))
//{
// var ordersStr = BaseRegex.GetJsonObjStrJson(ref jsonData, "initOdersList")?.FirstOrDefault();
// if (ordersStr != null && ordersStr.StartsWith("{\"2\":"))
// {
// ordersStr = "{\"orders\":" + ordersStr.Substring(5);
// CefReadBuyerOrder(buyerId, ordersStr);
// }
//}
var uid = BaseRegex.GetStringQuery(ref cookie2, "pdd_user_id");
var buyerId = GlobalConfig.BuyerLoginList.FirstOrDefault(b => b.buyer_id == uid)?.buyer_id;
if (!string.IsNullOrEmpty(buyerId) && !string.IsNullOrEmpty(jsonData))
{
try
{
var jObj = JsonHelper.JObjectParse(jsonData);
jObj["result"] = jObj["all"];
jObj["result"]["listItemVOList"] = jObj["result"]["list"];
CefReadBuyerAfterSale(buyerId, JsonHelper.SerializeObject(jObj));
}
catch
{
}
}
}
});
}
});
}
@@ -417,6 +575,83 @@ namespace TemuKJD.WXForms.TalkForms
NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_buyer_order_list", lstPddBuyerOrderInfoLite);
}
void CefReadBuyerAfterSale(string url, string data)
{
var buyer = GlobalConfig.BuyerLoginList.FirstOrDefault(b => url.Contains(b.buyer_id));
if (buyer == null)
return;
if (data.Contains("\"listItemVOList\":[]") || data.Contains("\"hasNextQuery\":false"))
{
Invoke(new Action(() =>
{
lblMsg.Text = buyer.buyer_name + " 获取到空售后列表,退出自动滑动 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}));
currentReadBuyer = "";
return;
}
if (data.Contains("\"error_code\":40001"))
{
currentReadBuyer = "";
CheckBuyerLogin(new List<BuyerLoginInfo> { buyer }, false);
return;
}
Invoke(new Action(() =>
{
lblMsg.Text = buyer.buyer_name + " 正在获取售后列表 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}));
var list = JsonHelper.DeserializeJsonToList<PddBuyerAfterSaleInfoLite>(JsonHelper.JObjectParse(data)["result"]["listItemVOList"].ParseToString());
foreach (var af in list)
{
af.buyerId = buyer.buyer_id;
af.buyerName = buyer.buyer_name;
PddBuyerAfterSaleInfoLite afterSale = null;
if (!this.lstPddBuyerAfterSaleInfoLite.Any(or => or.afterSalesId == af.afterSalesId))
{
afterSale = af;
lstPddBuyerAfterSaleInfoLite.Add(afterSale);
}
else
{
afterSale = this.lstPddBuyerAfterSaleInfoLite.FirstOrDefault(aft => aft.afterSalesId == af.afterSalesId);
if (JsonHelper.SerializeObject(afterSale) != JsonHelper.SerializeObject(af))
{
//order = JsonHelper.DeserializeJsonToObject<PddBuyerOrderInfoLite>(JsonHelper.SerializeObject(o));
afterSale.afterSalesId = af.afterSalesId;
afterSale.listItemAmountVO = JsonHelper.DeserializeJsonToObject<ListItemAmountVO>(JsonHelper.SerializeObject(af.listItemAmountVO));
afterSale.listItemExtraVO = JsonHelper.DeserializeJsonToObject<ListItemExtraVO>(JsonHelper.SerializeObject(af.listItemExtraVO));
afterSale.listItemGoodsVO = JsonHelper.DeserializeJsonToObject<ListItemGoodsVO>(JsonHelper.SerializeObject(af.listItemGoodsVO));
afterSale.listItemMallVO = JsonHelper.DeserializeJsonToObject<ListItemMallVO>(JsonHelper.SerializeObject(af.listItemMallVO));
afterSale.listItemStatusVO = JsonHelper.DeserializeJsonToObject<ListItemStatusVO>(JsonHelper.SerializeObject(af.listItemStatusVO));
}
}
if (afterSale.orderDate < DateTime.Now.AddMonths(-2).ToString("yyMMdd").ParseToInt())
{
Invoke(new Action(() =>
{
lblMsg.Text = buyer.buyer_name + " 近2个月售后列表获取完成,退出自动滑动 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}));
currentReadBuyer = "";
return;
}
Task.Run(() =>
{
SendAfterSaleE57(afterSale);
});
Invoke(new Action(() =>
{
ShowAfterSale(afterSale);
}));
}
NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_buyer_after_sale_list", lstPddBuyerAfterSaleInfoLite);
}
private bool RequestHandler_BeforeResourceLoad(object sender, string url, string postData, IRequest request)
{
return false;
@@ -587,7 +822,7 @@ namespace TemuKJD.WXForms.TalkForms
{
nextGetOrderTime = DateTime.Now.AddMinutes(30);
GetPddOrder();
MakeAfterSales();
MakeWxToPddAfterSales();
}
Thread.Sleep(1000);
Invoke(new Action(() =>
@@ -634,9 +869,10 @@ namespace TemuKJD.WXForms.TalkForms
cefWebBrowser.Load("https://mobile.yangkeduo.com/personal.html");
Thread.Sleep(Randomx.GetId(2000, 3000));
// 售后
string readBuyer = buyer.buyer_id;
currentReadBuyer = buyer.buyer_id;
cefWebBrowser.Load("https://mobile.yangkeduo.com/orders.html?type=2");
cefWebBrowser.Load("https://mobile.yangkeduo.com/complaint_list.html?refer_page_name=personal&refer_page_sn=10001&tab=all");
Thread.Sleep(Randomx.GetId(2000, 3000));
int top = 0;
@@ -645,8 +881,8 @@ namespace TemuKJD.WXForms.TalkForms
if (cancellationTokenSource.IsCancellationRequested)
break;
Thread.Sleep(Randomx.GetId(100,300));
top += Randomx.GetId(400, 500);
top += Randomx.GetId(450, 600);
Thread.Sleep(Randomx.GetId(100, 300));
var jsStr = @"window.scroll({
top: document.body.scrollHeight,
@@ -663,6 +899,37 @@ namespace TemuKJD.WXForms.TalkForms
}
Thread.Sleep(Randomx.GetId(2000, 3000));
// 待发货
readBuyer = buyer.buyer_id;
currentReadBuyer = buyer.buyer_id;
cefWebBrowser.Load("https://mobile.yangkeduo.com/orders.html?type=2");
Thread.Sleep(Randomx.GetId(2000, 3000));
top = 0;
while (currentReadBuyer == readBuyer)
{
if (cancellationTokenSource.IsCancellationRequested)
break;
top += Randomx.GetId(450, 600);
Thread.Sleep(Randomx.GetId(100,300));
var jsStr = @"window.scroll({
top: document.body.scrollHeight,
left: 0,
behavior: 'smooth' // 可选,使滚动平滑
});";
jsStr = @"window.scroll({
top: " + top + @",
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");
@@ -674,7 +941,7 @@ namespace TemuKJD.WXForms.TalkForms
if (cancellationTokenSource.IsCancellationRequested)
break;
top += Randomx.GetId(400, 500);
top += Randomx.GetId(450, 600);
Thread.Sleep(Randomx.GetId(100, 300));
var jsStr = @"window.scroll({
@@ -704,7 +971,7 @@ namespace TemuKJD.WXForms.TalkForms
{
nextGetOrderTime = DateTime.Now.AddMinutes(30);
GetPddOrder();
MakeAfterSales();
MakeWxToPddAfterSales();
}
private void pnlEmpty_Click(object sender, EventArgs e)
@@ -1030,7 +1297,7 @@ namespace TemuKJD.WXForms.TalkForms
pictureBox1.Visible = true;
Task.Run(() =>
{
MakeAfterSale(order);
MakeWxToPddAfterSale(order);
Invoke(new Action(() => { pictureBox1.Visible = false; }));
});
break;
@@ -1041,8 +1308,17 @@ namespace TemuKJD.WXForms.TalkForms
public void SendOrderE57(PddBuyerOrderInfoLite order, bool resetSendStatus = false)
{
if (order == null)
return;
if (resetSendStatus)
order.sendStatus = "";
var row = dgvPddBuyerOrder.Rows.Cast<DataGridViewRow>().FirstOrDefault(p => p.Cells.GetCellValueFromColumnName("colOPddOrderSn").ParseToString() == order.order_sn);
Invoke(new Action(() =>
{
if (row != null)
row.Cells["colOMsg"].Value = "";
}));
Thread.Sleep(100);
// 已发货且没有运单号的属于已退货,不再发送
if (order.order_status_prompt != "拼单成功,待发货" && order.order_status_prompt != "免拼成功,待发货" && (
@@ -1065,6 +1341,10 @@ namespace TemuKJD.WXForms.TalkForms
// return;
if (order.sendStatus.Contains("外采订单已发货"))
{
Invoke(new Action(() =>
{
ShowOrder(order);
}));
return;
}
@@ -1081,21 +1361,26 @@ namespace TemuKJD.WXForms.TalkForms
//失败 已存在
//<ResultVo><code>1505</code><msg>调用微信接口更新物流信息失败: 非法参数, 同运单号拦截 rid: 69d8ab9c-22baa3b1-67de0d95</msg><data/><totalRecords/></ResultVo>
var exportRst = WXHttpResponseBLL.e57PostResponse(url, dataStr, "");
if (exportRst.Contains("发送失败 操作超时"))
for (int i = 0; i < 5 && exportRst.Contains("操作超时"); i++)
{
Thread.Sleep(2000);
WXHttpResponseBLL.e57PostResponse(url, dataStr, "");
if (exportRst.Contains("SUCCESS") /*|| exportRst.Contains("已存在") || exportRst.Contains("同运单号拦截") || exportRst.Contains("订单已绑定外采订单")*/)
{
order.sendStatus = "已发送";
NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_buyer_order_list", lstPddBuyerOrderInfoLite);
}
else if (exportRst != null && exportRst.Contains("<msg>") && exportRst.Contains("</msg>"))
// exportRst.Contains("已存在") || exportRst.Contains("同运单号拦截") || exportRst.Contains("订单已绑定外采订单")
System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
xmlDoc.LoadXml(exportRst); //<ResultVo><code>1505</code><msg>不支持的平台类型: WEISHOP</msg><data/><totalRecords/></ResultVo>
string msg = xmlDoc["ResultVo"]["msg"].InnerText;
string data = xmlDoc["ResultVo"]["data"].InnerText;
if (msg == "SUCCESS")
{
order.sendStatus = exportRst.Substring(0, exportRst.IndexOf("</msg>")).Substring(exportRst.IndexOf("<msg>") + 5);
order.sendStatus = string.IsNullOrEmpty(data) ? msg : data;
if (order.sendStatus == "更新微信外采订单状态成功")
order.sendStatus = "已发送";
NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_buyer_order_list", lstPddBuyerOrderInfoLite);
}
else
{
order.sendStatus = "发送失败 " + exportRst;
order.sendStatus = "发送失败 " + (string.IsNullOrEmpty(msg) ? data : msg);
NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_buyer_order_list", lstPddBuyerOrderInfoLite);
}
Invoke(new Action(() =>
@@ -1105,7 +1390,7 @@ namespace TemuKJD.WXForms.TalkForms
//Thread.Sleep(500);
}
public void MakeAfterSales()
public void MakeWxToPddAfterSales()
{
Task.Run(() =>
{
@@ -1154,7 +1439,7 @@ namespace TemuKJD.WXForms.TalkForms
}));
if (chkAutoAfterSale.Checked)
{
MakeAfterSale(order);
MakeWxToPddAfterSale(order);
}
}
}
@@ -1166,7 +1451,8 @@ namespace TemuKJD.WXForms.TalkForms
});
}
public string MakeAfterSale(PddBuyerOrderInfoLite order)
// 通过服务端读取微信售后并触发拼多多售后或显示提示供买手手动退货
public string MakeWxToPddAfterSale(PddBuyerOrderInfoLite order)
{
//if (isReadOrder)
//{
@@ -1225,6 +1511,67 @@ namespace TemuKJD.WXForms.TalkForms
}
}
// 向服务端更新售后退货信息更新状态
public void SendAfterSaleE57(PddBuyerAfterSaleInfoLite afterSale, bool resetSendStatus = false)
{
if (resetSendStatus)
afterSale.sendStatus = "";
var row = dgvAfterSale.Rows.Cast<DataGridViewRow>().FirstOrDefault(p => p.Cells.GetCellValueFromColumnName("colRPddOrderSn").ParseToString() == afterSale.orderSn);
Invoke(new Action(() =>
{
if (row != null)
row.Cells["colRMsg"].Value = "";
}));
Thread.Sleep(100);
// 已退款成功且发送过的,不再发送
if (afterSale.listItemStatusVO.statusText.Contains("退款成功") && afterSale.sendStatus == "发送成功")
{
Invoke(new Action(() =>
{
ShowAfterSale(afterSale);
}));
return;
}
JObject obj = new JObject();
obj["platform"] = "WEISHOP";
obj["outOrderNo"] = afterSale.orderSn;
obj["afterSaleStatus"] = afterSale.listItemStatusVO.statusText;
var dataStr = JsonHelper.SerializeObject(obj);
string url = "https://po.e57.cn/prod-api/api/oms-api/external_procurement/updateAfterSaleStatus";
//成功 "<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, "");
for (int i = 0; i < 5 && exportRst.Contains("操作超时"); i++)
{
Thread.Sleep(2000);
WXHttpResponseBLL.e57PostResponse(url, dataStr, "");
}
if (exportRst.Contains("SUCCESS") || exportRst.Contains("更新外采订单的售后成功") /*|| exportRst.Contains("已存在") || exportRst.Contains("同运单号拦截") || exportRst.Contains("订单已绑定外采订单")*/)
{
afterSale.sendStatus = "发送成功";
NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_buyer_after_sale_list", lstPddBuyerAfterSaleInfoLite);
}
else if (exportRst != null && exportRst.Contains("<msg>") && exportRst.Contains("</msg>"))
{
afterSale.sendStatus = exportRst.Substring(0, exportRst.IndexOf("</msg>")).Substring(exportRst.IndexOf("<msg>") + 5);
NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_buyer_after_sale_list", lstPddBuyerAfterSaleInfoLite);
}
else
{
afterSale.sendStatus = "发送失败 " + exportRst;
NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_buyer_after_sale_list", lstPddBuyerAfterSaleInfoLite);
}
Invoke(new Action(() =>
{
ShowAfterSale(afterSale);
}));
//Thread.Sleep(500);
}
private void btnClose_Click(object sender, EventArgs e)
{
panel2.Visible = !panel2.Visible;
@@ -1273,6 +1620,15 @@ namespace TemuKJD.WXForms.TalkForms
else
row.Visible = false;
}
foreach (DataGridViewRow row in dgvAfterSale.Rows)
{
if (row.Cells["colRPddOrderSn"].Value.ParseToString().Contains(txtOrderSnFilter.Text.Trim()))
row.Visible = true;
//else if (row.Cells["colOBuyerName"].Value.ParseToString().Contains(txtOrderSnFilter.Text.Trim()))
// row.Visible = true;
else
row.Visible = false;
}
}
private void btnRestore_Click(object sender, EventArgs e)
@@ -1291,6 +1647,53 @@ namespace TemuKJD.WXForms.TalkForms
buyerOrderConfig.IsAutoAfterSale = chkAutoAfterSale.Checked;
NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_buyer_order_config", buyerOrderConfig);
}
private void btnExchange_Click(object sender, EventArgs e)
{
if (btnExchange.Text == "切换售后")
{
this.dgvPddBuyerOrder.SendToBack();
btnExchange.Text = "切换订单";
}
else
{
this.dgvAfterSale.SendToBack();
btnExchange.Text = "切换售后";
}
}
private void dgvAfterSale_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex < 0 || e.RowIndex < 0)
return;
string headerText = dgvAfterSale.Columns[e.ColumnIndex].HeaderText;
var orderSn = dgvAfterSale.Rows[e.RowIndex].Cells["colRPddOrderSn"].Value.ParseToString();
var order = lstPddBuyerAfterSaleInfoLite.FirstOrDefault(p => p.orderSn == orderSn);
switch (headerText)
{
case "详情":
case "编辑/详情":
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;
case "发送":
Task.Run(() =>
{
SendAfterSaleE57(order, true);
});
break;
default:
break;
}
}
}
public class YkdBuyerOrder