优化买手订单读取
This commit is contained in:
1 parent
44a26f4c2c
commit
9f26f03474
11 files changed
+1841
-979
No files matched your search
@@ -45,9 +45,13 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
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 BuyerOrderConfig buyerOrderConfig = new BuyerOrderConfig();
|
||||
public DateTime nextGetOrderTime = DateTime.MinValue;
|
||||
public bool isLoadComplate = false;
|
||||
public bool firstVisible = false;
|
||||
bool isInitOrder = false;
|
||||
bool isInitBuyer = false;
|
||||
bool isReadOrder = false;
|
||||
|
||||
public BuyerOrderListForm()
|
||||
{
|
||||
@@ -64,31 +68,75 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
|
||||
InitCef();
|
||||
|
||||
lstPddBuyerOrderInfoLite = NaiBa.Util.Helper.ConfigHelper.LoadConfig<ConcurrentList<PddBuyerOrderInfoLite>> ("pdd_buyer_order");
|
||||
buyerOrderConfig = NaiBa.Util.Helper.ConfigHelper.LoadConfig<BuyerOrderConfig>("pdd_buyer_order_config");
|
||||
if (buyerOrderConfig == null)
|
||||
buyerOrderConfig = new BuyerOrderConfig();
|
||||
|
||||
this.chkPause.Checked = buyerOrderConfig.IsPause;
|
||||
this.chkAutoAfterSale.Checked = buyerOrderConfig.IsAutoAfterSale;
|
||||
|
||||
lstPddBuyerOrderInfoLite = NaiBa.Util.Helper.ConfigHelper.LoadConfig<ConcurrentList<PddBuyerOrderInfoLite>>("pdd_buyer_order_list");
|
||||
if (lstPddBuyerOrderInfoLite == null)
|
||||
lstPddBuyerOrderInfoLite = NaiBa.Util.Helper.ConfigHelper.LoadConfig<ConcurrentList<PddBuyerOrderInfoLite>>("pdd_buyer_order");
|
||||
if (lstPddBuyerOrderInfoLite == null)
|
||||
lstPddBuyerOrderInfoLite = new ConcurrentList<PddBuyerOrderInfoLite>();
|
||||
ShowOrder();
|
||||
lstPddBuyerOrderInfoLite.RemoveAll(o => o.order_time < BaseClass.DateTimeToTimestampSeconds(DateTime.Now.AddMonths(-1)));
|
||||
|
||||
GetBuyer();
|
||||
AutoGetPddOrder();
|
||||
loadComplate = true;
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
while (isInitBuyer)
|
||||
{
|
||||
Thread.Sleep(500);
|
||||
}
|
||||
ShowExistOrder();
|
||||
|
||||
while (isInitOrder)
|
||||
{
|
||||
Thread.Sleep(500);
|
||||
}
|
||||
AutoGetPddOrder();
|
||||
});
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
Thread.Sleep(500);
|
||||
if (isReadOrder || isInitBuyer || isInitOrder)
|
||||
{
|
||||
Invoke(new Action(() => { pictureBox1.Visible = true; }));
|
||||
}
|
||||
else
|
||||
{
|
||||
Invoke(new Action(() => { pictureBox1.Visible = false; }));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
isLoadComplate = true;
|
||||
}
|
||||
|
||||
private void ProductListForm_VisibleChanged(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
void ShowOrder()
|
||||
void ShowExistOrder()
|
||||
{
|
||||
isInitOrder = true;
|
||||
Task.Run(() => {
|
||||
|
||||
foreach(var order in lstPddBuyerOrderInfoLite)
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
if (GlobalConfig.BuyerLoginList.Any(b => b.buyer_id == order.buyerId))
|
||||
{
|
||||
ShowOrder(order);
|
||||
}));
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
ShowOrder(order);
|
||||
}));
|
||||
}
|
||||
}
|
||||
isInitOrder = false;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -113,8 +161,9 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
order.order_status_prompt,
|
||||
order.outExpressCompanyName,
|
||||
order.tracking_number,
|
||||
order.sendStatus,
|
||||
"发送"
|
||||
order.sendStatus.IsNullOrEmpty() ? order.refundStatus : order.sendStatus,
|
||||
"发送",
|
||||
"退货"
|
||||
);
|
||||
row = dgvPddBuyerOrder.Rows[rowIndex];
|
||||
row.Height = 40;
|
||||
@@ -134,7 +183,22 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
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;
|
||||
row.Cells["colOMsg"].Value = order.sendStatus.IsNullOrEmpty() ? order.refundStatus : order.sendStatus;
|
||||
}
|
||||
if (order.order_status_prompt.Contains("交易成功"))
|
||||
{
|
||||
row.Cells["colOMsg"].Value = "[完]" + row.Cells["colOMsg"].Value.ParseToString();
|
||||
row.Cells["colOMsg"].Style.ForeColor = Color.Green;
|
||||
}
|
||||
if (order.order_status_prompt.Contains("退款成功") || order.order_status_prompt.Contains("交易已取消"))
|
||||
{
|
||||
row.Cells["colOMsg"].Value = "[退]" + row.Cells["colOMsg"].Value.ParseToString();
|
||||
row.Cells["colOMsg"].Style.ForeColor = Color.Gray;
|
||||
}
|
||||
else if (order.refundStatus.Contains("待退款") || order.refundStatus.Contains("待退货"))
|
||||
{
|
||||
row.Cells["colOMsg"].Value = "[待退]" + row.Cells["colOMsg"].Value.ParseToString();
|
||||
row.Cells["colOMsg"].Style.ForeColor = Color.Red;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,7 +313,7 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
lblMsg.Text = "获取空商品列表,退出自动滑动 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
lblMsg.Text = buyer.buyer_name + " 获取到空订单列表,退出自动滑动 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
}));
|
||||
currentReadBuyer = "";
|
||||
return;
|
||||
@@ -261,6 +325,12 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
lblMsg.Text = buyer.buyer_name + " 正在获取订单列表 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
}));
|
||||
|
||||
var list = JsonHelper.DeserializeJsonToList<PddBuyerOrderInfoLite>(JsonHelper.JObjectParse(data)["orders"].ParseToString());
|
||||
foreach (var o in list)
|
||||
{
|
||||
@@ -313,7 +383,7 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
ShowOrder(order);
|
||||
}));
|
||||
}
|
||||
NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_buyer_order", lstPddBuyerOrderInfoLite);
|
||||
NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_buyer_order_list", lstPddBuyerOrderInfoLite);
|
||||
}
|
||||
|
||||
private bool RequestHandler_BeforeResourceLoad(object sender, string url, string postData, IRequest request)
|
||||
@@ -346,56 +416,65 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
|
||||
void GetBuyer()
|
||||
{
|
||||
isInitBuyer = true;
|
||||
|
||||
var ids = dgvBuyer.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colSelect"].Value.ParseToBool() == true).Select(s => s.Cells["colBuyerId"].Value.ParseToString()).ToList();
|
||||
Invoke(new Action(() => { pbLoading.Visible = true; }));
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
var url = BaseClass.BuildPDDObjString("user/get_buyer");
|
||||
var data = UserLogin.GetSignaturex();
|
||||
data += "&page_size=200";
|
||||
|
||||
var result = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(result) || !result.Contains("\"code\":200"))
|
||||
result = GetHtml.PostUtf8(url, data);
|
||||
|
||||
if (result.Contains("\"code\":200"))
|
||||
try
|
||||
{
|
||||
List<BuyerLoginInfo> loginInfoLst = JsonHelper.DeserializeJsonToList<BuyerLoginInfo>(JsonHelper.JObjectParse(result)["data"].ParseToString());
|
||||
GlobalConfig.BuyerLoginList.RemoveAll(bu => !loginInfoLst.Any(b => b.buyer_id == bu.buyer_id));
|
||||
foreach (var b in loginInfoLst)
|
||||
var url = BaseClass.BuildPDDObjString("user/get_buyer");
|
||||
var data = UserLogin.GetSignaturex();
|
||||
data += "&page_size=200";
|
||||
|
||||
var result = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(result) || !result.Contains("\"code\":200"))
|
||||
result = GetHtml.PostUtf8(url, data);
|
||||
|
||||
if (result.Contains("\"code\":200"))
|
||||
{
|
||||
var buyer = GlobalConfig.BuyerLoginList.FirstOrDefault(bu => bu.buyer_id == b.buyer_id);
|
||||
if (buyer == null)
|
||||
GlobalConfig.BuyerLoginList.Add(b);
|
||||
else
|
||||
List<BuyerLoginInfo> loginInfoLst = JsonHelper.DeserializeJsonToList<BuyerLoginInfo>(JsonHelper.JObjectParse(result)["data"].ParseToString());
|
||||
GlobalConfig.BuyerLoginList.RemoveAll(bu => !loginInfoLst.Any(b => b.buyer_id == bu.buyer_id));
|
||||
foreach (var b in loginInfoLst)
|
||||
{
|
||||
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;
|
||||
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(() =>
|
||||
{
|
||||
dgvBuyer.Rows.Clear();
|
||||
}));
|
||||
|
||||
foreach (var buyer in GlobalConfig.BuyerLoginList)
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
BindBuyer(buyer, "", ids);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
dgvBuyer.Rows.Clear();
|
||||
}));
|
||||
|
||||
foreach (var buyer in GlobalConfig.BuyerLoginList)
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
BindBuyer(buyer, "", ids);
|
||||
}));
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
isInitBuyer = false;
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
pbLoading.Visible = false;
|
||||
@@ -477,6 +556,7 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
{
|
||||
nextGetOrderTime = DateTime.Now.AddMinutes(30);
|
||||
GetPddOrder();
|
||||
MakeAfterSales();
|
||||
}
|
||||
Thread.Sleep(1000);
|
||||
Invoke(new Action(() =>
|
||||
@@ -490,9 +570,12 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
|
||||
void GetPddOrder()
|
||||
{
|
||||
isReadOrder = true;
|
||||
|
||||
if (cancellationTokenSource != null)
|
||||
cancellationTokenSource.Cancel();
|
||||
cancellationTokenSource = new CancellationTokenSource();
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
currentReadBuyer = "";
|
||||
@@ -525,18 +608,25 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
cefWebBrowser.Load("https://mobile.yangkeduo.com/orders.html?type=2");
|
||||
Thread.Sleep(Randomx.GetId(2000, 3000));
|
||||
|
||||
int top = 0;
|
||||
while (currentReadBuyer == readBuyer)
|
||||
{
|
||||
if (cancellationTokenSource.IsCancellationRequested)
|
||||
break;
|
||||
|
||||
Thread.Sleep(Randomx.GetId(100,300));
|
||||
top += Randomx.GetId(400, 500);
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -547,11 +637,13 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
cefWebBrowser.Load("https://mobile.yangkeduo.com/orders.html?type=3");
|
||||
Thread.Sleep(Randomx.GetId(2000, 3000));
|
||||
|
||||
top = 0;
|
||||
while (currentReadBuyer == readBuyer)
|
||||
{
|
||||
if (cancellationTokenSource.IsCancellationRequested)
|
||||
break;
|
||||
|
||||
top += Randomx.GetId(400, 500);
|
||||
Thread.Sleep(Randomx.GetId(100, 300));
|
||||
|
||||
var jsStr = @"window.scroll({
|
||||
@@ -559,6 +651,11 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
left: 0,
|
||||
behavior: 'smooth' // 可选,使滚动平滑
|
||||
});";
|
||||
jsStr = @"window.scroll({
|
||||
top: " + top + @",
|
||||
left: 0,
|
||||
behavior: 'smooth' // 可选,使滚动平滑
|
||||
});";
|
||||
var t1 = cefWebBrowser.GetMainFrame().EvaluateScriptAsync(jsStr);
|
||||
t1.Wait(1000);
|
||||
}
|
||||
@@ -568,6 +665,7 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
}
|
||||
Thread.Sleep(Randomx.GetId(6000, 8000));
|
||||
}
|
||||
isReadOrder = false;
|
||||
}, cancellationTokenSource.Token);
|
||||
}
|
||||
|
||||
@@ -575,6 +673,7 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
{
|
||||
nextGetOrderTime = DateTime.Now.AddMinutes(30);
|
||||
GetPddOrder();
|
||||
MakeAfterSales();
|
||||
}
|
||||
|
||||
private void pnlEmpty_Click(object sender, EventArgs e)
|
||||
@@ -882,12 +981,6 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
case "详情":
|
||||
case "编辑/详情":
|
||||
break;
|
||||
case "发送":
|
||||
Task.Run(() =>
|
||||
{
|
||||
SendOrderE57(order, true);
|
||||
});
|
||||
break;
|
||||
case "图片":
|
||||
ShowImgForm imgFrom = new ShowImgForm(dgvPddBuyerOrder.Rows[e.RowIndex].Cells["colImgUrl"].Value.ParseToString().Replace("?imageView2/2/w/90/h/90", ""));
|
||||
imgFrom.ShowDialog();
|
||||
@@ -896,6 +989,20 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
case "全选":
|
||||
dgvPddBuyerOrder.Rows[e.RowIndex].Cells["colCheck"].Value = !(bool)dgvPddBuyerOrder.Rows[e.RowIndex].Cells["colCheck"].Value;
|
||||
break;
|
||||
case "发送":
|
||||
Task.Run(() =>
|
||||
{
|
||||
SendOrderE57(order, true);
|
||||
});
|
||||
break;
|
||||
case "退货":
|
||||
pictureBox1.Visible = true;
|
||||
Task.Run(() =>
|
||||
{
|
||||
MakeAfterSale(order);
|
||||
Invoke(new Action(() => { pictureBox1.Visible = false; }));
|
||||
});
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -906,20 +1013,28 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
if (resetSendStatus)
|
||||
order.sendStatus = "";
|
||||
|
||||
if (order.sendStatus == "已发送")
|
||||
//if (order.sendStatus == "已发货")
|
||||
//if (order.sendStatus == "已发送")
|
||||
// return;
|
||||
//if (order.sendStatus == "已完成/退货")
|
||||
// return;
|
||||
if (order.sendStatus.Contains("外采订单已发货"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
// 已发货且没有运单号的属于已退货,不再发送
|
||||
if (order.order_status_prompt != "拼单成功,待发货" && order.order_status_prompt != "免拼成功,待发货" && (string.IsNullOrEmpty(order.tracking_number) || string.IsNullOrEmpty(order.outExpressCompanyName)))
|
||||
if (order.order_status_prompt != "拼单成功,待发货" && order.order_status_prompt != "免拼成功,待发货" && (
|
||||
order.order_status_prompt.Contains("交易成功") ||
|
||||
order.order_status_prompt.Contains("退款成功") ||
|
||||
order.order_status_prompt.Contains("交易已取消") ||
|
||||
string.IsNullOrEmpty(order.tracking_number) ||
|
||||
string.IsNullOrEmpty(order.outExpressCompanyName)))
|
||||
{
|
||||
order.sendStatus = "已发货退货";
|
||||
order.refundStatus = "已完成/退货";
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
ShowOrder(order);
|
||||
}));
|
||||
NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_buyer_order", lstPddBuyerOrderInfoLite);
|
||||
NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_buyer_order_list", lstPddBuyerOrderInfoLite);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -938,20 +1053,20 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
var exportRst = WXHttpResponseBLL.e57PostResponse(url, dataStr, "");
|
||||
if (exportRst.Contains("发送失败 操作超时"))
|
||||
WXHttpResponseBLL.e57PostResponse(url, dataStr, "");
|
||||
if (exportRst.Contains("SUCCESS") || exportRst.Contains("已存在") || exportRst.Contains("同运单号拦截") || exportRst.Contains("订单已绑定外采订单"))
|
||||
if (exportRst.Contains("SUCCESS") /*|| exportRst.Contains("已存在") || exportRst.Contains("同运单号拦截") || exportRst.Contains("订单已绑定外采订单")*/)
|
||||
{
|
||||
order.sendStatus = "已发送";
|
||||
NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_buyer_order", lstPddBuyerOrderInfoLite);
|
||||
NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_buyer_order_list", lstPddBuyerOrderInfoLite);
|
||||
}
|
||||
else if (exportRst != null && exportRst.Contains("<msg>") && exportRst.Contains("</msg>"))
|
||||
{
|
||||
order.sendStatus = exportRst.Substring(0, exportRst.IndexOf("</msg>")).Substring(exportRst.IndexOf("<msg>") + 5);
|
||||
NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_buyer_order", lstPddBuyerOrderInfoLite);
|
||||
NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_buyer_order_list", lstPddBuyerOrderInfoLite);
|
||||
}
|
||||
else
|
||||
{
|
||||
order.sendStatus = "发送失败 " + exportRst;
|
||||
NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_buyer_order", lstPddBuyerOrderInfoLite);
|
||||
NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_buyer_order_list", lstPddBuyerOrderInfoLite);
|
||||
}
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
@@ -960,7 +1075,127 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
//Thread.Sleep(500);
|
||||
}
|
||||
|
||||
private void panelEx3_Click(object sender, EventArgs e)
|
||||
public void MakeAfterSales()
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
while (isReadOrder)
|
||||
{
|
||||
Thread.Sleep(500);
|
||||
//break;
|
||||
}
|
||||
|
||||
foreach (var buyer in GlobalConfig.BuyerLoginList)
|
||||
{
|
||||
//postman request POST 'https://po.e57.cn/prod-api/api/oms-api/external_procurement/hasAfterSsale' \
|
||||
//--header 'Content-Type: application/json' \
|
||||
//--body '{ "platform": "WEISHOP", "startTime": 1774763836, "endTime": "1776050614" , "userAccount": "闲鱼会开车的鱼2343"}'
|
||||
|
||||
JObject body = new JObject();
|
||||
body["platform"] = "WEISHOP";
|
||||
body["startTime"] = BaseClass.DateTimeToTimestampSeconds(DateTime.Now.AddDays(-7));
|
||||
body["endTime"] = BaseClass.DateTimeToTimestampSeconds(DateTime.Now);
|
||||
body["userAccount"] = buyer.buyer_name;
|
||||
string url = "https://po.e57.cn/prod-api/api/oms-api/external_procurement/hasAfterSsale";
|
||||
var getE57AfterSaleRst = WXHttpResponseBLL.e57PostResponse(url, JsonHelper.SerializeObject(body), "");
|
||||
if (getE57AfterSaleRst.ParseToString().Contains("<msg>success</msg>"))
|
||||
{
|
||||
try
|
||||
{
|
||||
var rstData = getE57AfterSaleRst.Substring(0, getE57AfterSaleRst.IndexOf("</data></AjaxResult>")).Substring(getE57AfterSaleRst.IndexOf("<data>") + "<data>".Length);
|
||||
|
||||
List<string> rstStrLst = rstData.Split(new string[] { "},{" }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
||||
foreach (var rstStr in rstStrLst)
|
||||
{
|
||||
var rstStrTmp = rstStr;
|
||||
var outOrderNo = BaseRegex.GetStringJson(ref rstStrTmp, "outOrderNo");
|
||||
if (outOrderNo.IsNullOrEmpty())
|
||||
continue;
|
||||
var afterSaleId = BaseRegex.GetStringJson(ref rstStrTmp, "afterSaleId");
|
||||
var order = lstPddBuyerOrderInfoLite.FirstOrDefault(o => o.order_sn == outOrderNo);
|
||||
if (order == null)
|
||||
continue;
|
||||
|
||||
order.refundStatus = order.order_status_prompt.Contains("待发货") ? "待退款" : "待退货";
|
||||
NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_buyer_order_list", lstPddBuyerOrderInfoLite);
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
ShowOrder(order);
|
||||
}));
|
||||
if (chkAutoAfterSale.Checked)
|
||||
{
|
||||
MakeAfterSale(order);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public string MakeAfterSale(PddBuyerOrderInfoLite order)
|
||||
{
|
||||
//if (isReadOrder)
|
||||
//{
|
||||
// BaseMsgForm.ShowError("正再读取订单,请稍候");
|
||||
// return;
|
||||
//}
|
||||
//// 订单详情页
|
||||
////https://mobile.yangkeduo.com/order.html?order_sn=260417-318525949581688
|
||||
//// 退货详情页
|
||||
////https://mobile.yangkeduo.com/complaint.html?order_sn=260417-357103060621688&after_sales_reason=0&after_sales_type=1&after_sales_code=1001
|
||||
|
||||
if(!order.order_status_prompt.Contains("待发货"))
|
||||
{
|
||||
return "{\"success\":false,\"msg\":\"仅未发货单可以自动退货\"}";
|
||||
}
|
||||
|
||||
var buyer = GlobalConfig.BuyerLoginList.FirstOrDefault(b => b.buyer_id == order.buyerId);
|
||||
var rst = YkdBuyerOrder.GetInitAfterSale(buyer, order.order_sn);
|
||||
//<script>window.rawData={"store":{"errorRedirectUrl":"\u002F","abMap":{"allowPerItemAs":false,"allowPercentAs":true,"isSpringOn":false,"applyPlatformJoinText":false,"newResendEntrance":true,"newExchangeEntrance":true,"shippingTicketOcr":true,"applyAfterSalesChoose":true,"inSpringFestival":false,"openSpringFestival":false,"shippingTipsView":true,"expressRejectShowContact":true,"newApplyPage":true,"newApplyDetailPage":false,"newFeeDetailGray":true,"qualityReasonNoticeProof":true,"newQualityReasonNoticeProof":true,"freeNoCouponOrder":false,"userShippingStatusReject":false,"applyAmountDisplayAsCompensateAmount":false,"compensateAmountChoosePopUp":false,"maintainDescOptimize":true},"goodsInfo":{"skuId":1884196560652,"catId1":6398,"goodsId":936888997232,"goodsName":"【三只松鼠新疆灰枣】免洗红枣150g新疆特产枣子干货休闲零食","goodsPrice":1350,"goodsNumber":1,"goodsSpec":"新疆灰枣150g*5袋","goodsType":1,"goodsImage":"https:\u002F\u002Fimg.pddpic.com\u002Fmms-goods-image\u002F2026-04-11\u002F336d9a71-d957-4121-a84b-f70f084226c9.jpeg"},"reasonData":{"map1":[{"type":220003,"desc":"重量\u002F数量\u002F大小等描述不符","subDesc":null,"url":"https:\u002F\u002Ffunimg.pddpic.com\u002F200702_Food_and_Health_Category\u002F21_Weight_quantity_size_mismatch.png","reasonType":2200},{"type":220005,"desc":"图片\u002F品种\u002F口味\u002F标签等描述不符","subDesc":null,"url":"https:\u002F\u002Ffunimg.pddpic.com\u002F200702_Food_and_Health_Category\u002F23_Picture_mismatch.png","reasonType":2200},{"type":220001,"desc":"包装\u002F商品破损","subDesc":null,"url":"https:\u002F\u002Ffunimg.pddpic.com\u002F200702_Food_and_Health_Category\u002F28_Damaged_packaging9.png","reasonType":2100},{"type":220004,"desc":"少件\u002F漏发","subDesc":null,"url":"https:\u002F\u002Ffunimg.pddpic.com\u002F20_Quantity_mismatch.png","reasonType":2400},{"type":294,"desc":"商品变质\u002F发霉\u002F有异物","subDesc":null,"url":"https:\u002F\u002Ffunimg.pddpic.com\u002F200702_Food_and_Health_Category\u002F25_Spoiled_food.png","reasonType":2100},{"type":292,"desc":"生产日期\u002F保质期与商品描述不符","subDesc":null,"url":"https:\u002F\u002Ffunimg.pddpic.com\u002F22_Expired_food.png","reasonType":2200},{"type":81,"desc":"质量问题","subDesc":null,"url":null,"reasonType":2100},{"type":83,"desc":"商家发错货","subDesc":null,"url":"https:\u002F\u002Ffunimg.pddpic.com\u002F30_Inconsistent_product.png","reasonType":2200},{"type":262,"desc":"空包裹","subDesc":null,"url":null,"reasonType":2400},{"type":86,"desc":"假冒品牌","subDesc":null,"url":null,"reasonType":2500},{"type":95,"desc":"其他原因","subDesc":null,"url":null,"reasonType":1200}],"map2":[{"type":197,"desc":"不想要了","subDesc":null,"url":null,"reasonType":1100},{"type":194,"desc":"快递无跟踪记录","subDesc":null,"url":null,"reasonType":2300},{"type":4008,"desc":"发货慢\u002F未按承诺时间发货","subDesc":null,"url":null,"reasonType":2300},{"type":220001,"desc":"包装\u002F商品破损","subDesc":null,"url":null,"reasonType":2100},{"type":220002,"desc":"未收到货\u002F签收地址错误","subDesc":null,"url":null,"reasonType":2300},{"type":207,"desc":"其他原因","subDesc":null,"url":null,"reasonType":1200}],"map3":[{"type":88,"desc":"不想要了","subDesc":null,"url":null,"reasonType":1100},{"type":220003,"desc":"重量\u002F数量\u002F大小等描述不符","subDesc":null,"url":"https:\u002F\u002Ffunimg.pddpic.com\u002F200702_Food_and_Health_Category\u002F21_Weight_quantity_size_mismatch.png","reasonType":2200},{"type":220005,"desc":"图片\u002F品种\u002F口味\u002F标签等描述不符","subDesc":null,"url":"https:\u002F\u002Ffunimg.pddpic.com\u002F200702_Food_and_Health_Category\u002F23_Picture_mismatch.png","reasonType":2200},{"type":220001,"desc":"包装\u002F商品破损","subDesc":null,"url":"https:\u002F\u002Ffunimg.pddpic.com\u002F200702_Food_and_Health_Category\u002F28_Damaged_packaging9.png","reasonType":2100},{"type":220004,"desc":"少件\u002F漏发","subDesc":null,"url":"https:\u002F\u002Ffunimg.pddpic.com\u002F20_Quantity_mismatch.png","reasonType":2400},{"type":294,"desc":"商品变质\u002F发霉\u002F有异物","subDesc":null,"url":"https:\u002F\u002Ffunimg.pddpic.com\u002F200702_Food_and_Health_Category\u002F25_Spoiled_food.png","reasonType":2100},{"type":292,"desc":"生产日期\u002F保质期与商品描述不符","subDesc":null,"url":"https:\u002F\u002Ffunimg.pddpic.com\u002F22_Expired_food.png","reasonType":2200},{"type":81,"desc":"质量问题","subDesc":null,"url":null,"reasonType":2100},{"type":83,"desc":"商家发错货","subDesc":null,"url":"https:\u002F\u002Ffunimg.pddpic.com\u002F30_Inconsistent_product.png","reasonType":2200},{"type":86,"desc":"假冒品牌","subDesc":null,"url":null,"reasonType":2500},{"type":95,"desc":"其他原因","subDesc":null,"url":null,"reasonType":1200}],"map4":[{"type":66,"desc":"不想要了","subDesc":null,"uLine truncated
|
||||
var mobile = BaseRegex.GetStringJson(ref rst, "userReceivePhone");
|
||||
var applyAmount = BaseRegex.GetIntJson(ref rst, "applyAmount");
|
||||
var refundAmount = BaseRegex.GetIntJson(ref rst, "refundAmount");
|
||||
var newMaxApplyAmount = BaseRegex.GetIntJson(ref rst, "newMaxApplyAmount");
|
||||
var shippingStatus = BaseRegex.GetIntJson(ref rst, "shippingStatus");
|
||||
if (shippingStatus == 1 || !rst.Contains("\"shippingStatus\":0,") || !order.order_status_prompt.Contains("待发货"))
|
||||
{
|
||||
return "{\"success\":false,\"msg\":\"仅未发货单可以自动退货\"}";
|
||||
}
|
||||
|
||||
if (applyAmount == 0) applyAmount = order.order_amount.ParseToInt();
|
||||
if (refundAmount == 0) refundAmount = order.order_amount.ParseToInt();
|
||||
if (newMaxApplyAmount == 0) newMaxApplyAmount = order.order_amount.ParseToInt();
|
||||
if (string.IsNullOrEmpty(mobile))
|
||||
{
|
||||
return "{\"success\":false,\"msg\":\"退货信息获取失败,请检查买手是否掉线\"}";
|
||||
}
|
||||
Thread.Sleep(Randomx.GetId(1000, 2000));
|
||||
var afterSaleRst = YkdBuyerOrder.SetOrderAfterSale(buyer, mobile, order.order_sn, applyAmount, refundAmount, newMaxApplyAmount);
|
||||
if (afterSaleRst.Contains("\"after_sales_status\":1") || afterSaleRst.Contains("该订单已全额退款"))
|
||||
{
|
||||
order.refundStatus = "已完成/退货";
|
||||
order.order_status_prompt = "退款成功";
|
||||
NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_buyer_order_list", lstPddBuyerOrderInfoLite);
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
ShowOrder(order);
|
||||
}));
|
||||
return "{\"success\":true,\"msg\":\"操作成功\"}";
|
||||
}
|
||||
else
|
||||
{
|
||||
var error_msg = BaseRegex.GetStringJson(ref afterSaleRst, "error_msg");
|
||||
if (string.IsNullOrEmpty(error_msg))
|
||||
error_msg = afterSaleRst;
|
||||
return "{\"success\":false,\"msg\":\"" + error_msg + "\"}";
|
||||
}
|
||||
}
|
||||
|
||||
private void btnClose_Click(object sender, EventArgs e)
|
||||
{
|
||||
panel2.Visible = !panel2.Visible;
|
||||
if (panel2.Visible == false)
|
||||
@@ -993,6 +1228,8 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
else
|
||||
PauseTick = nextGetOrderTime - DateTime.Now;
|
||||
|
||||
buyerOrderConfig.IsPause = chkPause.Checked;
|
||||
NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_buyer_order_config", buyerOrderConfig);
|
||||
}
|
||||
|
||||
private void btnFilterOrder_Click(object sender, EventArgs e)
|
||||
@@ -1001,6 +1238,8 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
{
|
||||
if (row.Cells["colOPddOrderSn"].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;
|
||||
}
|
||||
@@ -1016,11 +1255,37 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void chkAutoAfterSale_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
buyerOrderConfig.IsAutoAfterSale = chkAutoAfterSale.Checked;
|
||||
NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_buyer_order_config", buyerOrderConfig);
|
||||
}
|
||||
}
|
||||
|
||||
public class YkdBuyerOrder
|
||||
{
|
||||
public static string GetInitAfterSale(BuyerLoginInfo buyer, string orderSn)
|
||||
{
|
||||
string url = "https://mobile.yangkeduo.com/complaint.html?order_sn=" + orderSn + "&after_sales_reason=0&after_sales_type=1&after_sales_code=1001";
|
||||
var rst = YkdHttpResponseBLL.YangkeduoGetPageResponse(buyer, url);
|
||||
return rst;
|
||||
}
|
||||
|
||||
public static string SetOrderAfterSale(BuyerLoginInfo buyer, string user_phone, string order_sn, int apply_amount, int refund_amount, int new_refund_amount)
|
||||
{
|
||||
string url = "https://mobile.yangkeduo.com/proxy/api/after_sales/create?pdduid=" + buyer.buyer_id;
|
||||
string body = @"{""order_sn"":""260417-318525949581688"",""coupon_return_control_type"":0,""after_sales_type"":1,""user_ship_status"":0,""user_phone"":""17855141112"",""images"":[],""return_coupon_amount"":0,""question_type"":66,""question_desc"":"""",""apply_amount"":1568,""refund_amount"":1568,""new_refund_amount"":1568,""is_lite"":true}";
|
||||
body = @"{""order_sn"":""" + order_sn + @""",""coupon_return_control_type"":0,""after_sales_type"":1,""user_ship_status"":0,""user_phone"":""" + user_phone +
|
||||
@""",""images"":[],""return_coupon_amount"":0,""question_type"":66,""question_desc"":"""",""apply_amount"":" + apply_amount +
|
||||
@",""refund_amount"":" + refund_amount + @",""new_refund_amount"":" + new_refund_amount + @",""is_lite"":true}";
|
||||
|
||||
string referer = "https://mobile.yangkeduo.com/complaint.html?order_sn=260417-318525949581688&refer_page_name=order_detail&refer_page_id=10038_1776391960785_p20v9j3op4&refer_page_sn=10038&after_sales_reason=66&after_sales_type=1&after_sales_code=1001";
|
||||
referer = "https://mobile.yangkeduo.com/complaint.html?order_sn=" + order_sn + "&refer_page_name=order_detail&&after_sales_reason=66";
|
||||
|
||||
var rst = YkdHttpResponseBLL.YangkeduoPostResponse(buyer, url, body, referer);
|
||||
return rst;
|
||||
}
|
||||
}
|
||||
|
||||
public class WxOrder
|
||||
@@ -1046,4 +1311,10 @@ namespace TemuKJD.WXForms.TalkForms
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class BuyerOrderConfig
|
||||
{
|
||||
public bool IsPause = false;
|
||||
public bool IsAutoAfterSale = true;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user