2138 lines
120 KiB
C#
2138 lines
120 KiB
C#
using AllBase;
|
||
using AllBase.Helper;
|
||
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;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.ComponentModel;
|
||
using System.Data;
|
||
using System.Diagnostics;
|
||
using System.Drawing;
|
||
using System.IO;
|
||
using System.Linq;
|
||
using System.Net;
|
||
using System.Text;
|
||
using System.Text.RegularExpressions;
|
||
using System.Threading;
|
||
using System.Threading.Tasks;
|
||
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;
|
||
using Work;
|
||
|
||
namespace TemuKJD.WXForms.TalkForms
|
||
{
|
||
public partial class PDDBuyerOrderListForm : BaseGeneralForm
|
||
{
|
||
private static PDDBuyerOrderListForm instance = null;
|
||
|
||
public DateTime lastCefReadOrderTime = DateTime.Now;
|
||
public static PDDBuyerOrderListForm Instance { get { if (instance == null || instance.IsDisposed || instance.Disposing) instance = new PDDBuyerOrderListForm(); return instance; } }
|
||
ShopLoginInfo currentShop { get { return this.lblCurrentShop.Tag as ShopLoginInfo; } }
|
||
//ConcurrentList<WxOrderInfoLite> lstWxOrderInfoLite { get; set; } = new ConcurrentList<WxOrderInfoLite>();
|
||
ConcurrentList<PddBuyerOrderLiteInfo> lstPddBuyerOrderInfoLite { get; set; } = new ConcurrentList<PddBuyerOrderLiteInfo>();
|
||
ConcurrentList<PddBuyerAfterSaleLiteInfo> lstPddBuyerAfterSaleInfoLite { get; set; } = new ConcurrentList<PddBuyerAfterSaleLiteInfo>();
|
||
public CancellationTokenSource cancellationTokenSource { get; set; } = new CancellationTokenSource();
|
||
//public ChromiumWebBrowser cefWebBrowser = null;
|
||
public BuyerReadOrderConfig buyerOrderConfig = new BuyerReadOrderConfig();
|
||
public DateTime nextGetOrderTime = DateTime.MinValue;
|
||
public bool isLoadComplate = false;
|
||
public bool firstVisible = false;
|
||
bool isInitOrder = false;
|
||
bool isInitAfterSale = false;
|
||
bool isInitBuyer = false;
|
||
bool isReadBuyerOrder = false;
|
||
|
||
public PDDBuyerOrderListForm()
|
||
{
|
||
InitializeComponent();
|
||
instance = this;
|
||
}
|
||
|
||
private void ProductListForm_Load(object sender, EventArgs e)
|
||
{
|
||
lblMsg.Text = "";
|
||
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();
|
||
|
||
buyerOrderConfig = NaiBa.Util.Helper.ConfigHelper.LoadConfig<BuyerReadOrderConfig>("pdd_buyer_order_config");
|
||
if (buyerOrderConfig == null)
|
||
buyerOrderConfig = new BuyerReadOrderConfig();
|
||
|
||
this.chkPause.Checked = buyerOrderConfig.IsPause;
|
||
this.chkAutoAfterSale.Checked = buyerOrderConfig.IsAutoAfterSale;
|
||
|
||
lstPddBuyerOrderInfoLite = NaiBa.Util.Helper.ConfigHelper.LoadConfig<ConcurrentList<PddBuyerOrderLiteInfo>>("pdd_buyer_order_list");
|
||
if (lstPddBuyerOrderInfoLite == null)
|
||
lstPddBuyerOrderInfoLite = NaiBa.Util.Helper.ConfigHelper.LoadConfig<ConcurrentList<PddBuyerOrderLiteInfo>>("pdd_buyer_order");
|
||
if (lstPddBuyerOrderInfoLite == null)
|
||
lstPddBuyerOrderInfoLite = new ConcurrentList<PddBuyerOrderLiteInfo>();
|
||
lstPddBuyerOrderInfoLite.RemoveAll(o => o.order_time < BaseClass.DateTimeToTimestampSeconds(DateTime.Now.AddMonths(-1)));
|
||
|
||
lstPddBuyerAfterSaleInfoLite = NaiBa.Util.Helper.ConfigHelper.LoadConfig<ConcurrentList<PddBuyerAfterSaleLiteInfo>>("pdd_buyer_after_sale_list");
|
||
if (lstPddBuyerAfterSaleInfoLite == null)
|
||
lstPddBuyerAfterSaleInfoLite = new ConcurrentList<PddBuyerAfterSaleLiteInfo>();
|
||
lstPddBuyerAfterSaleInfoLite.RemoveAll(o => o.orderDate < DateTime.Now.AddMonths(-1).ToString("yyMMdd").ParseToInt());
|
||
|
||
GetBuyer();
|
||
|
||
Task.Run(() =>
|
||
{
|
||
while (isInitBuyer)
|
||
{
|
||
Thread.Sleep(500);
|
||
}
|
||
InitCef();
|
||
ShowExistOrder();
|
||
|
||
while (isInitOrder || isInitAfterSale)
|
||
{
|
||
Thread.Sleep(500);
|
||
}
|
||
AutoGetPddOrder();
|
||
});
|
||
|
||
Task.Run(() =>
|
||
{
|
||
while(true)
|
||
{
|
||
Thread.Sleep(500);
|
||
if (isReadBuyerOrder || isInitBuyer || isInitOrder || isInitAfterSale)
|
||
{
|
||
Invoke(new Action(() => { pictureBox1.Visible = true; }));
|
||
}
|
||
else
|
||
{
|
||
Invoke(new Action(() => { pictureBox1.Visible = false; }));
|
||
}
|
||
}
|
||
});
|
||
|
||
isLoadComplate = true;
|
||
}
|
||
|
||
private void ProductListForm_VisibleChanged(object sender, EventArgs e)
|
||
{
|
||
}
|
||
|
||
void ShowExistOrder()
|
||
{
|
||
isInitOrder = true;
|
||
//Task.Run(() => {
|
||
int index = 0;
|
||
foreach (var order in lstPddBuyerOrderInfoLite)
|
||
{
|
||
if (index % 100 == 0)
|
||
Thread.Sleep(1);
|
||
index++;
|
||
if (GlobalConfig.BuyerLoginList.Any(b => b.buyer_id == order.buyerId))
|
||
{
|
||
Invoke(new Action(() =>
|
||
{
|
||
ShowOrder(order);
|
||
}));
|
||
}
|
||
}
|
||
isInitOrder = false;
|
||
//});
|
||
|
||
isInitAfterSale = true;
|
||
//Task.Run(() => {
|
||
//int index = 0;
|
||
foreach (var afterSale in lstPddBuyerAfterSaleInfoLite)
|
||
{
|
||
if (index % 100 == 0)
|
||
Thread.Sleep(1);
|
||
index++;
|
||
if (GlobalConfig.BuyerLoginList.Any(b => b.buyer_id == afterSale.buyerId))
|
||
{
|
||
Invoke(new Action(() =>
|
||
{
|
||
ShowAfterSale(lstPddBuyerAfterSaleInfoLite.FirstOrDefault(a => a.orderSn == afterSale.orderSn));
|
||
}));
|
||
}
|
||
}
|
||
isInitAfterSale = false;
|
||
//});
|
||
}
|
||
|
||
void ShowOrder(PddBuyerOrderLiteInfo 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:mm"),
|
||
"", // 图片路径,
|
||
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["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;
|
||
}
|
||
//
|
||
if (order.outExpressCompanyName == "物流名称获取失败")
|
||
row.Cells["colOExpressName"].Style.ForeColor = Color.Orange;
|
||
else
|
||
row.Cells["colOExpressName"].Style.ForeColor = Control.DefaultForeColor;
|
||
|
||
if (order.order_status_prompt.Contains("交易成功"))
|
||
{
|
||
row.Cells["colOMsg"].Value = "[完]" + row.Cells["colOMsg"].Value.ParseToString();
|
||
row.Cells["colOMsg"].Style.ForeColor = Color.Green;
|
||
}
|
||
else 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.after_sales != null)
|
||
{
|
||
if (order.order_sn == "260417-009038743070257")
|
||
{
|
||
//after_sales_id 20093344800098 after_sales_status 12 after_sales_type 2
|
||
}
|
||
if (order.order_sn == "260427-536315174430257")
|
||
{
|
||
|
||
}
|
||
if(order.after_sales.after_sales_status == 12 && order.after_sales.after_sales_type == 2)
|
||
{
|
||
row.Cells["colOMsg"].Value = "[退货失败]" + row.Cells["colOMsg"].Value.ParseToString();
|
||
row.Cells["colOMsg"].Style.ForeColor = Color.SlateBlue;
|
||
}
|
||
else
|
||
{
|
||
row.Cells["colOMsg"].Value = "[退货中]" + row.Cells["colOMsg"].Value.ParseToString();
|
||
row.Cells["colOMsg"].Style.ForeColor = Color.DeepSkyBlue;
|
||
}
|
||
}
|
||
else if (!string.IsNullOrEmpty(order.wxRefundStatus))
|
||
{
|
||
row.Cells["colOMsg"].Value = "[" + order.wxRefundStatus + "]" + row.Cells["colOMsg"].Value.ParseToString();
|
||
row.Cells["colOMsg"].Style.ForeColor = Color.Red;
|
||
}
|
||
else
|
||
{
|
||
row.Cells["colOMsg"].Style.ForeColor = Control.DefaultForeColor;
|
||
}
|
||
}
|
||
|
||
void ShowAfterSale(PddBuyerAfterSaleLiteInfo afterSale)
|
||
{
|
||
if (afterSale == null)
|
||
return;
|
||
|
||
if (afterSale.orderSn == "260414-035525772830257")
|
||
{
|
||
|
||
}
|
||
|
||
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.afterSalesId,
|
||
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["colRAfterSaleId"].Value = afterSale.afterSalesId;
|
||
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()
|
||
{
|
||
foreach (var buyer in GlobalConfig.BuyerLoginList)
|
||
{
|
||
Thread.Sleep(1);
|
||
Invoke(new Action(() =>
|
||
{
|
||
buyer.browser = CEFBrowser.CreateChromiumWebBrowser("about:blank", false);
|
||
CustomResourceRequestHandlerLocal resourceRequestHandler = new CustomResourceRequestHandlerLocal();
|
||
resourceRequestHandler.ResourceLoadCompleteEvent += RequestHandler_ResourceLoadComplete;
|
||
resourceRequestHandler.BeforeResourceLoadEvent += RequestHandler_BeforeResourceLoad;
|
||
buyer.browser.RequestHandler = new CustomRequestHandler(resourceRequestHandler);
|
||
var lifeSapnHandler = new LifeSpanHandlerLocal(PopWindowType.SelfWindow);
|
||
buyer.browser.LifeSpanHandler = lifeSapnHandler;
|
||
buyer.browser.KeyboardHandler = new KeyboardHandler();
|
||
buyer.browser.FrameLoadEnd += CefWebBrowser_FrameLoadEnd;
|
||
buyer.browser.AddressChanged += CefWebBrowser_AddressChanged;
|
||
buyer.browser.LoadError += CefWebBrowser_LoadError;
|
||
buyer.browser.Dock = DockStyle.Fill;
|
||
buyer.browser.SendToBack();
|
||
splitContainer3.Panel2.Controls.Add(buyer.browser);
|
||
}));
|
||
}
|
||
|
||
//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)
|
||
{
|
||
var cookie1 = request.Headers["Cookie"];
|
||
Task.Run(() =>
|
||
{
|
||
var url1 = url;
|
||
var data1 = responseData;
|
||
|
||
//if (data1.Contains("260415-154067299863696") || data1.Contains("待用户退回商品") || data1.Contains("已寄出,待商家处理") || data1.Contains("待商家处理退货申请") || data1.Contains("待用户拒收商品"))
|
||
//{
|
||
|
||
//}
|
||
if (data1.Contains("260416-143256471130828"))
|
||
{
|
||
|
||
}
|
||
//if (data1.Contains("260415-279781076570828"))
|
||
//{
|
||
//}
|
||
//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(() =>
|
||
{
|
||
if (data1.Contains("display_amount"))
|
||
{
|
||
var jsonData = BaseRegex.GetJsonObjStrJson(ref data1, "ordersStore")?.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("{\"3\":"))
|
||
{
|
||
ordersStr = "{\"orders\":" + ordersStr.Substring(5);
|
||
CefReadBuyerOrder(buyerId, ordersStr);
|
||
}
|
||
}
|
||
}
|
||
});
|
||
}
|
||
// 待发货 第一页
|
||
if (url1.StartsWith("https://mobile.yangkeduo.com/orders.html?type=2"))
|
||
{
|
||
Task.Run(() =>
|
||
{
|
||
if (data1.Contains("display_amount"))
|
||
{
|
||
var jsonData = BaseRegex.GetJsonObjStrJson(ref data1, "ordersStore")?.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);
|
||
}
|
||
}
|
||
}
|
||
});
|
||
}
|
||
if (url1.StartsWith("https://mobile.yangkeduo.com/proxy/api/api/aristotle/order_list_v"))
|
||
{
|
||
Task.Run(() =>
|
||
{
|
||
CefReadBuyerOrder(url1, data1);
|
||
|
||
});
|
||
}
|
||
// 读取售后
|
||
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
|
||
{
|
||
|
||
}
|
||
}
|
||
}
|
||
});
|
||
}
|
||
});
|
||
}
|
||
|
||
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;
|
||
|
||
lastCefReadOrderTime = DateTime.Now;
|
||
|
||
//{"server_time":1775789489,"orders":[],"extra_info":{}}
|
||
if (data.Contains("\"orders\":[]"))
|
||
{
|
||
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<PddBuyerOrderLiteInfo>(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 此处转换
|
||
|
||
PddBuyerOrderLiteInfo 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))
|
||
{
|
||
if(order.order_status_prompt.Contains("待发货") && !o.order_status_prompt.Contains("待发货"))
|
||
{
|
||
order.sendStatus = "";
|
||
}
|
||
|
||
//order = JsonHelper.DeserializeJsonToObject<PddBuyerOrderInfoLite>(JsonHelper.SerializeObject(o));
|
||
order.activity_type = o.activity_type;
|
||
order.after_sales = o.after_sales;
|
||
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_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("260414-035525772830257"))
|
||
{
|
||
|
||
}
|
||
|
||
lastCefReadOrderTime = DateTime.Now;
|
||
|
||
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<PddBuyerAfterSaleLiteInfo>(JsonHelper.JObjectParse(data)["result"]["listItemVOList"].ParseToString());
|
||
foreach (var af in list)
|
||
{
|
||
if (af.orderSn == "260414-035525772830257")
|
||
{
|
||
|
||
}
|
||
|
||
af.buyerId = buyer.buyer_id;
|
||
af.buyerName = buyer.buyer_name;
|
||
|
||
bool isUpdate = false;
|
||
PddBuyerAfterSaleLiteInfo afterSale = null;
|
||
if (!this.lstPddBuyerAfterSaleInfoLite.Any(or => or.afterSalesId == af.afterSalesId))
|
||
{
|
||
isUpdate = true;
|
||
afterSale = af;
|
||
lstPddBuyerAfterSaleInfoLite.Add(afterSale);
|
||
}
|
||
else
|
||
{
|
||
afterSale = this.lstPddBuyerAfterSaleInfoLite.FirstOrDefault(aft => aft.afterSalesId == af.afterSalesId);
|
||
var afterSaleTmp = JsonHelper.DeserializeJsonToObject<PddBuyerAfterSaleLiteInfo>(JsonHelper.SerializeObject(afterSale));
|
||
afterSaleTmp.sendStatus = "";
|
||
afterSaleTmp.listItemMallVO = new ListItemMallVO();
|
||
var afTmp = JsonHelper.DeserializeJsonToObject<PddBuyerAfterSaleLiteInfo>(JsonHelper.SerializeObject(af));
|
||
afTmp.listItemMallVO = new ListItemMallVO();
|
||
//"{\"buyerId\":\"9303896321\",\"buyerName\":\"吴镇强\",\"sendStatus\":\"\",\"orderSn\":\"260419-166104962590257\",\"orderDate\":260419,\"afterSalesId\":20379701953346,\"listItemExtraVO\":{\"navToDetailPageUrl\":\"/complaints_new_detail.html?after_sales_id=20379701953346&order_sn=260419-166104962590257\"},\"listItemMallVO\":{\"mallName\":\"喜悦时光婚礼屋\",\"mallLogo\":\"http://t16img.yangkeduo.com/pdd_ims/img_check/v2/F3E6FF9A2BE40120200112155401880/9632a275dd974e9aa2e138cde6d0adf9.png\",\"mallTagLink\":null,\"pddRoute\":\"mall_page.html?mall_id=938572084&msn=zjdvupyguflkhtcgugbw3hbdpm_axbuy&_sop_rcto=YWLr7xLhO9bbI6L9S-r6ALQbTuXTx_3fIjo\"},\"listItemStatusVO\":{\"statusText\":\"待用户发货\"},\"listItemGoodsVO\":{\"goodsImage\":\"https://img.pddpic.com/mms-material-img/2026-03-21/005e0aa1-ad62-4db3-8018-00490ddc0a82.jpeg\",\"goodsName\":\"2026高级可折叠蚊帐家用卧室懒人免安装加高加厚加密学生宿舍蚊帐\",\"spec\":\"免安装/可折叠/网眼加密【可爱粉】+固定器,适用双人1.8m床【190*160*80】\",\"goodsPrice\":1890,\"goodsNumber\":1,\"richTextList\":null},\"listItemAmountVO\":{\"orderAmountTitle\":\"实付:\",\"orderAmount\":1890,\"payLaterAmountTitle\":null,\"payLaterAmount\":null,\"refundAmountTitle\":\"退款金额:\",\"refundAmount\":1890,\"refundAmountText\":null,\"useCoupon\":false}}"
|
||
//"{\"buyerId\":\"9303896321\",\"buyerName\":\"吴镇强\",\"sendStatus\":\"\",\"orderSn\":\"260419-166104962590257\",\"orderDate\":260419,\"afterSalesId\":20379701953346,\"listItemExtraVO\":{\"navToDetailPageUrl\":\"/complaints_new_detail.html?after_sales_id=20379701953346&order_sn=260419-166104962590257\"},\"listItemMallVO\":{\"mallName\":\"喜悦时光婚礼屋\",\"mallLogo\":\"http://t16img.yangkeduo.com/pdd_ims/img_check/v2/F3E6FF9A2BE40120200112155401880/9632a275dd974e9aa2e138cde6d0adf9.png\",\"mallTagLink\":null,\"pddRoute\":\"mall_page.html?mall_id=938572084&msn=zjdvupyguflkhtcgugbw3hbdpm_axbuy&_sop_rcto=YWKCoxwbKDHFAaL9S-r6ALQbTuXTx_3fIjo\"},\"listItemStatusVO\":{\"statusText\":\"待用户发货\"},\"listItemGoodsVO\":{\"goodsImage\":\"https://img.pddpic.com/mms-material-img/2026-03-21/005e0aa1-ad62-4db3-8018-00490ddc0a82.jpeg\",\"goodsName\":\"2026高级可折叠蚊帐家用卧室懒人免安装加高加厚加密学生宿舍蚊帐\",\"spec\":\"免安装/可折叠/网眼加密【可爱粉】+固定器,适用双人1.8m床【190*160*80】\",\"goodsPrice\":1890,\"goodsNumber\":1,\"richTextList\":null},\"listItemAmountVO\":{\"orderAmountTitle\":\"实付:\",\"orderAmount\":1890,\"payLaterAmountTitle\":null,\"payLaterAmount\":null,\"refundAmountTitle\":\"退款金额:\",\"refundAmount\":1890,\"refundAmountText\":null,\"useCoupon\":false}}"
|
||
if (JsonHelper.SerializeObject(afterSaleTmp) != JsonHelper.SerializeObject(afTmp))
|
||
{
|
||
isUpdate = true;
|
||
//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;
|
||
}
|
||
|
||
if (isUpdate)
|
||
{
|
||
Task.Run(() =>
|
||
{
|
||
SendAfterSaleE57(lstPddBuyerAfterSaleInfoLite.FirstOrDefault(a => a.orderSn == afterSale.orderSn));
|
||
});
|
||
|
||
Invoke(new Action(() =>
|
||
{
|
||
ShowAfterSale(lstPddBuyerAfterSaleInfoLite.FirstOrDefault(a => a.orderSn == afterSale.orderSn));
|
||
}));
|
||
}
|
||
}
|
||
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;
|
||
}
|
||
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()
|
||
{
|
||
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(() =>
|
||
{
|
||
try
|
||
{
|
||
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"))
|
||
{
|
||
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 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();
|
||
cmbBuyer.Items.Clear();
|
||
}));
|
||
|
||
foreach (var buyer in GlobalConfig.BuyerLoginList)
|
||
{
|
||
Invoke(new Action(() =>
|
||
{
|
||
BindBuyer(buyer, "", ids);
|
||
cmbBuyer.Items.Add(buyer.buyer_nick);
|
||
}));
|
||
}
|
||
}
|
||
}
|
||
catch
|
||
{
|
||
}
|
||
|
||
isInitBuyer = false;
|
||
Invoke(new Action(() =>
|
||
{
|
||
pbLoading.Visible = false;
|
||
}));
|
||
});
|
||
}
|
||
|
||
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;
|
||
|
||
Invoke(new Action(() =>
|
||
{
|
||
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(
|
||
true,
|
||
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["colBuyerName"].Value = buyer.buyer_name;
|
||
row.Cells["colBuyerNick"].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(chkPause.Checked)
|
||
{
|
||
Thread.Sleep(1000);
|
||
Invoke(new Action(() =>
|
||
{
|
||
btnSearch.Text = "自动刷新暂停中";
|
||
}));
|
||
continue;
|
||
}
|
||
|
||
if (DateTime.Now > nextGetOrderTime)
|
||
{
|
||
nextGetOrderTime = DateTime.Now.AddMinutes(25);
|
||
GetPddOrder();
|
||
MakeWxToPddAfterSales();
|
||
}
|
||
if (isReadBuyerOrder)
|
||
{
|
||
nextGetOrderTime = DateTime.Now.AddMinutes(25);
|
||
}
|
||
Thread.Sleep(1000);
|
||
Invoke(new Action(() =>
|
||
{
|
||
var ticks = nextGetOrderTime - DateTime.Now;
|
||
btnSearch.Text = "刷新订单 " + ticks.Minutes + ":" + ticks.Seconds;
|
||
}));
|
||
}
|
||
});
|
||
}
|
||
|
||
void GetPddOrder()
|
||
{
|
||
isReadBuyerOrder = true;
|
||
|
||
if (cancellationTokenSource != null)
|
||
cancellationTokenSource.Cancel();
|
||
cancellationTokenSource = new CancellationTokenSource();
|
||
|
||
Task.Run(() =>
|
||
{
|
||
while (isInitOrder || isInitAfterSale)
|
||
{
|
||
Thread.Sleep(500);
|
||
}
|
||
|
||
currentReadBuyer = "";
|
||
|
||
foreach (var buyer in GlobalConfig.BuyerLoginList)
|
||
{
|
||
if (cancellationTokenSource.IsCancellationRequested)
|
||
break;
|
||
|
||
CheckBuyerLogin(new List<BuyerLoginInfo>() { buyer });
|
||
if (buyer.status != "在线")
|
||
continue;
|
||
|
||
var row = dgvBuyer.Rows.Cast<DataGridViewRow>().FirstOrDefault(r => r.Cells["colBuyerNick"].Value.ParseToString() == buyer.buyer_nick);
|
||
if (row == null)
|
||
{
|
||
continue;
|
||
}
|
||
if (row.Cells["colSelect"].Value.ParseToBool() != true)
|
||
{
|
||
Invoke(new Action(() => { row.Cells["colMessage"].Value = "未勾选买手号,跳过"; }));
|
||
continue;
|
||
}
|
||
|
||
try
|
||
{
|
||
while (buyer.browser == null || !buyer.browser.IsBrowserInitialized || !buyer.browser.GetBrowser().MainFrame.IsValid)
|
||
{
|
||
Thread.Sleep(1);
|
||
}
|
||
|
||
CEFBrowser.DeleteCookie(buyer.browser.GetCookieManager(null));
|
||
|
||
var cookieLst = JsonHelper.DeserializeJsonToList<CefSharp.Cookie>(buyer?.cookie);
|
||
var t = CEFBrowser.SetCookieAsync(JsonHelper.SerializeObject(cookieLst), buyer.browser.GetCookieManager(null));
|
||
|
||
buyer.browser.Load("https://mobile.yangkeduo.com/personal.html");
|
||
Thread.Sleep(Randomx.GetId(2000, 3000));
|
||
|
||
// 售后
|
||
string readBuyer = buyer.buyer_id;
|
||
currentReadBuyer = buyer.buyer_id;
|
||
buyer.browser.Load("https://mobile.yangkeduo.com/complaint_list.html?refer_page_name=personal&refer_page_sn=10001&tab=all");
|
||
Thread.Sleep(Randomx.GetId(2000, 3000));
|
||
|
||
Invoke(new Action(() => { WxTalkForm.instance.TitleText = buyer.buyer_nick + " 售后读取中"; }));
|
||
BindBuyer(buyer, "正在读取售后");
|
||
|
||
int top = 0;
|
||
int times = 0;
|
||
lastCefReadOrderTime = DateTime.Now;
|
||
while (currentReadBuyer == readBuyer)
|
||
{
|
||
if (cancellationTokenSource.IsCancellationRequested)
|
||
{
|
||
BindBuyer(buyer, "已取消读取");
|
||
break;
|
||
}
|
||
|
||
if (lastCefReadOrderTime < DateTime.Now.AddSeconds(-30))
|
||
{
|
||
CheckBuyerLogin(new List<BuyerLoginInfo>() { buyer });
|
||
if (buyer.status != "在线")
|
||
{
|
||
BindBuyer(buyer, "店铺掉线");
|
||
break;
|
||
}
|
||
BindBuyer(buyer, "停滞时间超过30秒,跳过");
|
||
break;
|
||
}
|
||
|
||
Invoke(new Action(() => { buyer.browser.BringToFront(); }));
|
||
|
||
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);
|
||
var client = buyer.browser.GetDevToolsClient();
|
||
if (client != null)
|
||
{
|
||
var result = client.Runtime.EvaluateAsync(jsStr, null, true, null, null, true, null, true);
|
||
result.Wait(5000);
|
||
}
|
||
}
|
||
if (cancellationTokenSource.IsCancellationRequested)
|
||
{
|
||
BindBuyer(buyer, "已取消读取");
|
||
break;
|
||
}
|
||
Thread.Sleep(Randomx.GetId(2000, 3000));
|
||
|
||
Invoke(new Action(() => { WxTalkForm.instance.TitleText = buyer.buyer_nick + " 待发货读取中"; }));
|
||
BindBuyer(buyer, "正在读取待发货");
|
||
|
||
// 待发货
|
||
readBuyer = buyer.buyer_id;
|
||
currentReadBuyer = buyer.buyer_id;
|
||
buyer.browser.Load("https://mobile.yangkeduo.com/orders.html?type=2");
|
||
Thread.Sleep(Randomx.GetId(2000, 3000));
|
||
|
||
top = 0;
|
||
lastCefReadOrderTime = DateTime.Now;
|
||
while (currentReadBuyer == readBuyer)
|
||
{
|
||
if (cancellationTokenSource.IsCancellationRequested)
|
||
{
|
||
BindBuyer(buyer, "已取消读取");
|
||
break;
|
||
}
|
||
|
||
if (lastCefReadOrderTime < DateTime.Now.AddSeconds(-30))
|
||
{
|
||
CheckBuyerLogin(new List<BuyerLoginInfo>() { buyer });
|
||
if (buyer.status != "在线")
|
||
{
|
||
BindBuyer(buyer, "店铺掉线");
|
||
break;
|
||
}
|
||
BindBuyer(buyer, "停滞时间超过30秒,跳过");
|
||
break;
|
||
}
|
||
|
||
if (times % 100 == 0)
|
||
{
|
||
CheckBuyerLogin(new List<BuyerLoginInfo>() { buyer });
|
||
}
|
||
if (buyer.status != "在线")
|
||
break;
|
||
times++;
|
||
|
||
Invoke(new Action(() => { buyer.browser.BringToFront(); }));
|
||
|
||
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);
|
||
var client = buyer.browser.GetDevToolsClient();
|
||
if (client != null)
|
||
{
|
||
var result = client.Runtime.EvaluateAsync(jsStr, null, true, null, null, true, null, true);
|
||
result.Wait(5000);
|
||
}
|
||
}
|
||
if (cancellationTokenSource.IsCancellationRequested)
|
||
{
|
||
BindBuyer(buyer, "已取消读取");
|
||
break;
|
||
}
|
||
Thread.Sleep(Randomx.GetId(2000, 3000));
|
||
|
||
Invoke(new Action(() => { WxTalkForm.instance.TitleText = buyer.buyer_nick + " 已发货读取中"; }));
|
||
BindBuyer(buyer, "正在读取已发货");
|
||
|
||
// 已发货
|
||
readBuyer = buyer.buyer_id;
|
||
currentReadBuyer = buyer.buyer_id;
|
||
buyer.browser.Load("https://mobile.yangkeduo.com/orders.html?type=3");
|
||
Thread.Sleep(Randomx.GetId(2000, 3000));
|
||
|
||
top = 0;
|
||
lastCefReadOrderTime = DateTime.Now;
|
||
while (currentReadBuyer == readBuyer)
|
||
{
|
||
if (cancellationTokenSource.IsCancellationRequested)
|
||
{
|
||
BindBuyer(buyer, "已取消读取");
|
||
break;
|
||
}
|
||
|
||
if (lastCefReadOrderTime < DateTime.Now.AddSeconds(-30))
|
||
{
|
||
CheckBuyerLogin(new List<BuyerLoginInfo>() { buyer });
|
||
if (buyer.status != "在线")
|
||
{
|
||
BindBuyer(buyer, "店铺掉线");
|
||
break;
|
||
}
|
||
BindBuyer(buyer, "停滞时间超过30秒,跳过");
|
||
break;
|
||
}
|
||
|
||
Invoke(new Action(() => { buyer.browser.BringToFront(); }));
|
||
|
||
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);
|
||
var client = buyer.browser.GetDevToolsClient();
|
||
if (client != null)
|
||
{
|
||
var result = client.Runtime.EvaluateAsync(jsStr, null, true, null, null, true, null, true);
|
||
result.Wait(5000);
|
||
}
|
||
}
|
||
Invoke(new Action(() =>
|
||
{
|
||
if (row.Cells["colMessage"].Value.ParseToString().StartsWith("正在读取"))
|
||
BindBuyer(buyer, " ");
|
||
}));
|
||
}
|
||
catch
|
||
{
|
||
}
|
||
Thread.Sleep(Randomx.GetId(6000, 8000));
|
||
}
|
||
isReadBuyerOrder = false;
|
||
|
||
Invoke(new Action(() => { WxTalkForm.instance.TitleText = "订单读取已结束,等待下次读取"; }));
|
||
}, cancellationTokenSource.Token);
|
||
}
|
||
|
||
private void btnSearch_Click(object sender, EventArgs e)
|
||
{
|
||
nextGetOrderTime = DateTime.Now.AddMinutes(25);
|
||
GetPddOrder();
|
||
MakeWxToPddAfterSales();
|
||
}
|
||
|
||
private void pnlEmpty_Click(object sender, EventArgs e)
|
||
{
|
||
this.txtOrderSn.Text = "";
|
||
}
|
||
|
||
private void dgvDbProduct_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
||
{
|
||
if (e.ColumnIndex < 0 || e.RowIndex < 0)
|
||
return;
|
||
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);
|
||
|
||
switch (headerText)
|
||
{
|
||
case "详情":
|
||
case "编辑/详情":
|
||
//PDDDBProdEditForm editForm = new PDDDBProdEditForm(dbProduct);
|
||
//if (BaseClass.MainPath != "29pdd")
|
||
//{
|
||
// editForm.pnlSkuOption.Visible = false;
|
||
// editForm.txtProductName.ReadOnly = true;
|
||
// editForm.txtExtCode.ReadOnly = true;
|
||
// editForm.lblSkcId.Text = "仓库编码";
|
||
//}
|
||
//editForm.ShowDialog();
|
||
//dgvDbProduct.Rows[e.RowIndex].Cells["col_notes"].Value = dbProduct.notes;
|
||
//dgvDbProduct.Rows[e.RowIndex].Cells["col_ext_code"].Value = dbProduct.ext_code;
|
||
//dgvDbProduct.Rows[e.RowIndex].Cells["colHeadWords"].Value = dbProduct.head_words;
|
||
//dgvDbProduct.Rows[e.RowIndex].Cells["colEndWords"].Value = dbProduct.end_words;
|
||
//dgvDbProduct.Rows[e.RowIndex].Cells["colFissionWords"].Value = dbProduct.fission_words;
|
||
//dgvDbProduct.Rows[e.RowIndex].Cells["col_product_name"].Value = dbProduct.product_name;
|
||
//dgvDbProduct.Rows[e.RowIndex].Cells["colSkuReplaceImgUrl"].Value = dbProduct.sku_img_replace_url;
|
||
break;
|
||
case "主图":
|
||
ShowImgForm imgFrom = new ShowImgForm(dgvWxOrder.Rows[e.RowIndex].Cells["colImgUrl"].Value.ParseToString().Replace("?imageView2/2/w/90/h/90", ""));
|
||
imgFrom.ShowDialog();
|
||
break;
|
||
case "":
|
||
dgvWxOrder.Rows[e.RowIndex].Cells["colCheck"].Value = !(bool)dgvWxOrder.Rows[e.RowIndex].Cells["colCheck"].Value;
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
private void btnStopStop_Click(object sender, EventArgs e)
|
||
{
|
||
currentReadBuyer = "";
|
||
if (cancellationTokenSource != null)
|
||
cancellationTokenSource.Cancel();
|
||
Task.Run(() =>
|
||
{
|
||
Thread.Sleep(3000);
|
||
Invoke(new Action(() =>
|
||
{
|
||
if (cancellationTokenSource == null || cancellationTokenSource.IsCancellationRequested)
|
||
pbLoading.Visible = false;
|
||
}));
|
||
});
|
||
}
|
||
|
||
private void PDDDBProdListForm_KeyDown(object sender, KeyEventArgs e)
|
||
{
|
||
}
|
||
|
||
private void PDDDBProdListForm_KeyUp(object sender, KeyEventArgs e)
|
||
{
|
||
}
|
||
|
||
private void WXUserProdListForm_FormClosing(object sender, FormClosingEventArgs e)
|
||
{
|
||
this.Hide();
|
||
e.Cancel = true;
|
||
}
|
||
|
||
private void btnAddBuyler_Click(object sender, EventArgs e)
|
||
{
|
||
PddMobileLoginForm buyerLoginForm = new PddMobileLoginForm(null);
|
||
buyerLoginForm.openType = EnumOpenType.login;
|
||
buyerLoginForm.InitUrl = "https://mobile.yangkeduo.com/login.html?from=https%3A%2F%2Fmobile.yangkeduo.com%2Fpersonal.html";
|
||
buyerLoginForm.ShowDialog();
|
||
GetBuyer();
|
||
}
|
||
|
||
private void dgvShop_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
||
{
|
||
if (e.ColumnIndex < 0 || e.RowIndex < 0)
|
||
return;
|
||
|
||
string headerText = dgvBuyer.Columns[e.ColumnIndex].HeaderText;
|
||
var buyerId = dgvBuyer.Rows[e.RowIndex].Cells["colBuyerId"].Value.ParseToString();
|
||
var buyer = GlobalConfig.BuyerLoginList.FirstOrDefault(p => p.buyer_id.ToString() == buyerId);
|
||
|
||
switch (headerText)
|
||
{
|
||
case "状态":
|
||
case "登录":
|
||
CheckBuyerLogin(new List<BuyerLoginInfo> { buyer }, false);
|
||
if (buyer.status == "在线")
|
||
{
|
||
PddMobileLoginForm shopLoginForm = new PddMobileLoginForm(buyer);
|
||
shopLoginForm.openType = EnumOpenType.manage;
|
||
shopLoginForm.WindowState = FormWindowState.Maximized;
|
||
shopLoginForm.InitUrl = "https://mobile.yangkeduo.com";
|
||
shopLoginForm.Show();
|
||
}
|
||
else
|
||
{
|
||
PddMobileLoginForm shopLoginForm = new PddMobileLoginForm(buyer);
|
||
shopLoginForm.openType = EnumOpenType.login;
|
||
shopLoginForm.InitUrl = "https://mobile.yangkeduo.com/login.html?from=https%3A%2F%2Fmobile.yangkeduo.com%2Fpersonal.html";
|
||
shopLoginForm.ShowDialog();
|
||
GetBuyer();
|
||
}
|
||
break;
|
||
case "访问":
|
||
{
|
||
PddMobileLoginForm shopLoginForm = new PddMobileLoginForm(buyer);
|
||
shopLoginForm.openType = EnumOpenType.manage;
|
||
shopLoginForm.WindowState = FormWindowState.Maximized;
|
||
shopLoginForm.InitUrl = "https://mobile.yangkeduo.com";
|
||
shopLoginForm.Show();
|
||
}
|
||
break;
|
||
case "买手昵称":
|
||
Task.Run(() =>
|
||
{
|
||
try
|
||
{
|
||
while (buyer.browser == null || !buyer.browser.IsBrowserInitialized || !buyer.browser.GetBrowser().MainFrame.IsValid)
|
||
{
|
||
Thread.Sleep(1);
|
||
}
|
||
if (!buyer.browser.Address.ParseToString().Contains("yangkeduo.com"))
|
||
{
|
||
CEFBrowser.DeleteCookie(buyer.browser.GetCookieManager(null));
|
||
var cookieLst = JsonHelper.DeserializeJsonToList<CefSharp.Cookie>(buyer?.cookie);
|
||
var t = CEFBrowser.SetCookieAsync(JsonHelper.SerializeObject(cookieLst), buyer.browser.GetCookieManager(null));
|
||
buyer.browser.Load("https://mobile.yangkeduo.com/personal.html");
|
||
}
|
||
Invoke(new Action(()=> { buyer.browser?.BringToFront(); }));
|
||
}
|
||
catch
|
||
{ }
|
||
Thread.Sleep(Randomx.GetId(2000, 3000));
|
||
});
|
||
break;
|
||
case "":
|
||
case "全选":
|
||
dgvBuyer.Rows[e.RowIndex].Cells["colSelect"].Value = !(bool)dgvBuyer.Rows[e.RowIndex].Cells["colSelect"].Value;
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
public void CheckBuyerLogin(List<BuyerLoginInfo> checkBuyers, bool isShowProgress = true)
|
||
{
|
||
for (int i = 0; i < checkBuyers.Count; i++)
|
||
{
|
||
var buyer = GlobalConfig.BuyerLoginList.FirstOrDefault(v => v.buyer_id == checkBuyers[i].buyer_id);
|
||
var buys = GlobalConfig.BuyerLoginList.Where(v => v.buyer_id == checkBuyers[i].buyer_id).ToList();
|
||
if (buyer == null)
|
||
continue;
|
||
|
||
// 先从服务端取最新cookie
|
||
var url = BaseClass.BuildPDDObjString("user/get_buyer");
|
||
var data = UserLogin.GetSignaturex();
|
||
data += "&buyer_ids=" + buyer.buyer_id;
|
||
data += "&page_size=1";
|
||
var result = GetHtml.PostUtf8(url, data);
|
||
if (string.IsNullOrEmpty(result) || !result.Contains("\"code\":200"))
|
||
result = GetHtml.PostUtf8(url, data);
|
||
if (!result.Contains("\"code\":200"))
|
||
continue;
|
||
List<BuyerLoginInfo> loginInfoLst = JsonHelper.DeserializeJsonToList<BuyerLoginInfo>(JsonHelper.JObjectParse(result)["data"].ParseToString());
|
||
|
||
var serverBuyer = loginInfoLst.FirstOrDefault();
|
||
if (buyer != null && serverBuyer != null)
|
||
{
|
||
buyer.cookie = serverBuyer.cookie;
|
||
foreach (var buy in buys)
|
||
{
|
||
buy.cookie = serverBuyer.cookie;
|
||
}
|
||
}
|
||
|
||
if (buyer != null)
|
||
{
|
||
var loginResult = CheckBuyerLogin(buyer);
|
||
if (!loginResult.Contains("\"success\":true") && !loginResult.Contains("\"login\":true") && !loginResult.Contains("\"nickname\""))
|
||
{
|
||
buyer.cookie = "[]";
|
||
foreach (var buy in buys)
|
||
{
|
||
buy.status = "掉线";
|
||
buy.cookie = "[]";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
foreach (var buy in buys)
|
||
{
|
||
buy.status = "在线";
|
||
}
|
||
}
|
||
UpdateServerBuyerCookies(buyer); // 店铺cookie和状态写入服务端
|
||
}
|
||
if (this.Created && isShowProgress)
|
||
{
|
||
this.Invoke(new Action(() =>
|
||
{
|
||
this.statusBar.lblTaskStatus.Text = "正在检测...";
|
||
this.statusBar.pgbTaskProgress.Value = (i + 1);
|
||
this.statusBar.pgbTaskProgress.Text = (i + 1) + "/" + checkBuyers.Count;
|
||
BindBuyer(buyer);
|
||
}));
|
||
}
|
||
}
|
||
}
|
||
|
||
public static string CheckBuyerLogin(BuyerLoginInfo buyer, string refere = "https://mobile.yangkeduo.com/goods.html")
|
||
{
|
||
string url = "https://mobile.yangkeduo.com/proxy/api/api/apollo/v3/user/me?pdduid=" + buyer.buyer_id;
|
||
return YkdHttpResponseBLL.YangkeduoGetResponse(buyer, url, refere);
|
||
}
|
||
|
||
public static string UpdateServerBuyerCookies(BuyerLoginInfo buyer, string fromTool = null)
|
||
{
|
||
var url = BaseClass.BuildPDDObjString("user/mdy_buyer_cookie");
|
||
var data = UserLogin.GetSignaturex()
|
||
+ "&status=" + buyer.status
|
||
+ "&cookie=" + GetHtml.UrlEncodeUtf8(buyer.cookie)
|
||
+ "&buyer_id=" + buyer.buyer_id;
|
||
var result = GetHtml.PostUtf8(url, data);
|
||
if (!result.Contains("\"code\":200"))
|
||
result = GetHtml.PostUtf8(url, data);
|
||
return result;
|
||
}
|
||
|
||
private void btnRefresh_Click(object sender, EventArgs e)
|
||
{
|
||
GetBuyer();
|
||
}
|
||
|
||
private void btnCheck_Click(object sender, EventArgs e)
|
||
{
|
||
var ids = dgvBuyer.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colSelect"].Value.ParseToBool() == true).Select(s => s.Cells["colBuyerId"].Value.ParseToString()).ToList();
|
||
var buyers = GlobalConfig.BuyerLoginList.Where(b => ids.Contains(b.buyer_id)).ToList();
|
||
Task.Run(() => {
|
||
CheckBuyerLogin(buyers);
|
||
});
|
||
}
|
||
|
||
private void btnDel_Click(object sender, EventArgs e)
|
||
{
|
||
if (BaseMsgForm.ShowConfirm("确定删除吗?删除后不可恢复!").DialogResult == DialogResult.Cancel)
|
||
return;
|
||
|
||
var ids = dgvBuyer.Rows.Cast<DataGridViewRow>().Where(r => r.Cells["colSelect"].Value.ParseToBool() == true).Select(s => s.Cells["colBuyerId"].Value.ParseToString()).ToList();
|
||
var buyers = GlobalConfig.BuyerLoginList.Where(b => ids.Contains(b.buyer_id)).ToList();
|
||
this.statusBar.pgbTaskProgress.Maximum = buyers.Count;
|
||
pbLoading.Visible = true;
|
||
|
||
Task.Run(() =>
|
||
{
|
||
int i = 0;
|
||
foreach (var buyer in buyers)
|
||
{
|
||
i++;
|
||
this.Invoke(new Action(() =>
|
||
{
|
||
this.statusBar.lblTaskStatus.Text = "正在删除...";
|
||
this.statusBar.pgbTaskProgress.Value = i;
|
||
this.statusBar.pgbTaskProgress.Text = i + "/" + buyers.Count;
|
||
}));
|
||
|
||
var url = BaseClass.BuildPDDObjString("user/del_buyer");
|
||
var data = UserLogin.GetSignaturex()
|
||
+ "&buyer_id=" + buyer.buyer_id;
|
||
var result = GetHtml.PostUtf8(url, data);
|
||
|
||
Thread.Sleep(100);
|
||
}
|
||
this.Invoke(new Action(() =>
|
||
{
|
||
this.statusBar.lblTaskStatus.Text = "删除完成";
|
||
this.statusBar.pgbTaskProgress.Value = buyers.Count;
|
||
this.statusBar.pgbTaskProgress.Text = buyers.Count + "/" + buyers.Count;
|
||
}));
|
||
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 "图片":
|
||
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 "发送":
|
||
if (tempWaitOrderLst.Any(o => o.order_sn == order.order_sn))
|
||
return;
|
||
Task.Run(() =>
|
||
{
|
||
if (1 == 1)
|
||
SendOrderE57(order, true);
|
||
else // 测试用
|
||
SendOrderE57(order);
|
||
});
|
||
break;
|
||
case "退货":
|
||
pictureBox1.Visible = true;
|
||
Task.Run(() =>
|
||
{
|
||
PddAutoAfterSale(order);
|
||
Invoke(new Action(() => { pictureBox1.Visible = false; }));
|
||
});
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
ConcurrentList<PddBuyerOrderLiteInfo> tempWaitOrderLst { get; set; } = new ConcurrentList<PddBuyerOrderLiteInfo>();
|
||
/// <summary>
|
||
/// 调用e57接口更新web端订单数据信息
|
||
/// </summary>
|
||
/// <param name="order"></param>
|
||
/// <param name="resetSendStatus">手动强制重置状态,一定重新发送</param>
|
||
public void SendOrderE57(PddBuyerOrderLiteInfo order, bool resetSendStatus = false)
|
||
{
|
||
//if (resetSendStatus == true)
|
||
//{
|
||
// // 防止重复点击发送按钮
|
||
// if (isSendOrderE57)
|
||
// return;
|
||
// isSendOrderE57 = true;
|
||
// Task.Run(() => { Thread.Sleep(3000); isSendOrderE57 = false; });
|
||
//}
|
||
|
||
if (tempWaitOrderLst.Any(o => o.order_sn == order.order_sn))
|
||
return;
|
||
tempWaitOrderLst.Add(order);
|
||
Task.Run(() =>
|
||
{
|
||
var orderSn = order.order_sn;
|
||
Thread.Sleep(5000);
|
||
tempWaitOrderLst.RemoveAll(o => o.order_sn == orderSn);
|
||
});
|
||
|
||
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 != "免拼成功,待发货" && (
|
||
// order.order_status_prompt.Contains("交易成功") ||
|
||
// order.order_status_prompt.Contains("退款成功") ||
|
||
// order.after_sales != null ||
|
||
// order.order_status_prompt.Contains("交易已取消") ||
|
||
// string.IsNullOrEmpty(order.tracking_number) ||
|
||
// string.IsNullOrEmpty(order.outExpressCompanyCode)))
|
||
//{
|
||
// Invoke(new Action(() =>
|
||
// {
|
||
// ShowOrder(order);
|
||
// }));
|
||
// NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_buyer_order_list", lstPddBuyerOrderInfoLite);
|
||
// return;
|
||
//}
|
||
// 外采订单已发货的订单不再尝试发货
|
||
// 已存在 同运单号拦截 订单已绑定外采订单 -- 原提示词
|
||
// 微信发货成功,外采订单已发货, orderNo:260429-064214802032823 | 外采订单已发货, orderNo:260429-438189442672823 -- 新提示词
|
||
if (order.sendStatus.Contains("外采订单已发货") || order.sendStatus.Contains("微信发货成功") ||
|
||
order.sendStatus.Contains("已发送待发货订单") || order.sendStatus.Contains("接收成功") ||
|
||
order.sendStatus.Contains("已发送售后订单"))
|
||
{
|
||
Invoke(new Action(() =>
|
||
{
|
||
ShowOrder(order);
|
||
}));
|
||
return;
|
||
}
|
||
|
||
JObject obj = new JObject();
|
||
obj["platform"] = "WEISHOP";
|
||
obj["outAmount"] = order.order_amount;
|
||
obj["outAccount"] = order.buyerName;
|
||
obj["outOrderNo"] = order.order_sn;
|
||
if (!order.outExpressCompanyCode.IsNullOrEmpty() && !order.tracking_number.IsNullOrEmpty())
|
||
{
|
||
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 == null)
|
||
{
|
||
|
||
}
|
||
for (int i = 0; i < 3 && exportRst.Contains("操作超时") && resetSendStatus == false; i++)
|
||
{
|
||
Thread.Sleep(210000);
|
||
WXHttpResponseBLL.e57PostResponse(url, dataStr, "");
|
||
}
|
||
if (exportRst.Contains("操作超时"))
|
||
{
|
||
order.sendStatus = "发送失败 操作超时";
|
||
NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_buyer_order_list", lstPddBuyerOrderInfoLite);
|
||
Invoke(new Action(() =>
|
||
{
|
||
ShowOrder(order);
|
||
}));
|
||
return;
|
||
}
|
||
System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
|
||
string msg = "";
|
||
string data = "";
|
||
string code = "";
|
||
try
|
||
{
|
||
xmlDoc.LoadXml(exportRst); //<ResultVo><code>1505</code><msg>不支持的平台类型: WEISHOP</msg><data/><totalRecords/></ResultVo>
|
||
code = xmlDoc["AjaxResult"]["code"].InnerText;
|
||
msg = xmlDoc["AjaxResult"]["msg"].InnerText;
|
||
//data = xmlDoc["AjaxResult"]["data"].InnerText;
|
||
|
||
// <AjaxResult><msg>更新微信外采订单信息成功, orderNo:260430-306551232030257</msg><code>1</code></AjaxResult>
|
||
}
|
||
catch
|
||
{
|
||
msg = exportRst.ParseToString();
|
||
}
|
||
if (code == "0" || code == "1") //if (msg == "SUCCESS") // || msg == "SUCCESS"
|
||
{
|
||
var sendStatusTmp = string.IsNullOrEmpty(data) ? msg : data;
|
||
order.sendStatus = sendStatusTmp;
|
||
|
||
if (code == "0" && !order.sendStatus.Contains("微信发货成功"))
|
||
order.sendStatus = ("微信发货成功 " + sendStatusTmp).Trim();
|
||
if (code == "1" && !order.sendStatus.Contains("接收成功"))
|
||
order.sendStatus = ("接收成功 " + sendStatusTmp).Trim();
|
||
|
||
// 处理特殊情况 如未发货或退货订单
|
||
//if (order.sendStatus == "处理完成" || order.sendStatus == "快递公司和快递单号必须同时提供或同时为空")
|
||
// order.sendStatus = "已发送完成";
|
||
if (order.order_status_prompt.Contains("待发货")) // 更新微信外采订单状态成功
|
||
order.sendStatus = "已发送待发货订单";
|
||
if (order.after_sales != null)
|
||
order.sendStatus = "已发送售后订单 " + sendStatusTmp;
|
||
NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_buyer_order_list", lstPddBuyerOrderInfoLite);
|
||
}
|
||
else
|
||
{
|
||
order.sendStatus = "发送失败 " + (string.IsNullOrEmpty(msg) ? data : msg);
|
||
NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_buyer_order_list", lstPddBuyerOrderInfoLite);
|
||
}
|
||
Invoke(new Action(() =>
|
||
{
|
||
ShowOrder(order);
|
||
}));
|
||
//Thread.Sleep(500);
|
||
}
|
||
|
||
public void MakeWxToPddAfterSales()
|
||
{
|
||
Task.Run(() =>
|
||
{
|
||
while (isReadBuyerOrder)
|
||
{
|
||
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.wxRefundStatus = order.order_status_prompt.Contains("待发货") ? "待退款" : "待退货";
|
||
NaiBa.Util.Helper.ConfigHelper.SaveConfig("pdd_buyer_order_list", lstPddBuyerOrderInfoLite);
|
||
Invoke(new Action(() =>
|
||
{
|
||
ShowOrder(order);
|
||
}));
|
||
if (chkAutoAfterSale.Checked)
|
||
{
|
||
PddAutoAfterSale(order);
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
}
|
||
}
|
||
}
|
||
});
|
||
}
|
||
|
||
// 通过服务端读取微信售后并触发拼多多售后或显示提示供买手手动退货
|
||
public string PddAutoAfterSale(PddBuyerOrderLiteInfo 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,"url":null,"reasonType":1100},{"type":289,"desc":"协商一致退款","subDesc":null,"url":null,"reasonType":1200},{"type":290,"desc":"缺货","subDesc":null,"url":null,"reasonType":2300},{"type":4000,"desc":"发货慢","subDesc":null,"url":null,"reasonType":2300},{"type":4003,"desc":"地址\u002F信息填写错误","subDesc":null,"url":null,"reasonType":1100},{"type":79,"desc":"其他原因","subDesc":null,"url":null,"reasonType":1200}],"map5":[{"type":502,"desc":"材质、面料与商品描述不符","subDesc":null,"url":null,"reasonType":2200},{"type":503,"desc":"大小尺寸与商品描述不符","subDesc":null,"url":null,"reasonType":2200},{"type":504,"desc":"颜色、款式、图案与描述不符","subDesc":null,"url":null,"reasonType":2200},{"type":505,"desc":"质量问题","subDesc":null,"url":null,"reasonType":2100},{"type":90,"desc":"收到商品少件(含少配件)","subDesc":null,"url":null,"reasonType":2400},{"type":91,"desc":"商品破损或污渍","subDesc":null,"url":null,"reasonType":2100},{"type":507,"desc":"商家发错货","subDesc":null,"url":null,"reasonType":2200},{"type":508,"desc":"其他原因","subDesc":null,"url":null,"reasonType":1200}],"map6":[{"type":901,"desc":"少发、漏发","subDesc":null,"url":null,"reasonType":2400},{"type":902,"desc":"配件破损","subDesc":null,"url":null,"reasonType":2100},{"type":903,"desc":"主商品破损","subDesc":null,"url":null,"reasonType":2100},{"type":196,"desc":"快递一直未送达","subDesc":null,"url":null,"reasonType":2300}],"map7":[{"type":401,"desc":"配件故障","subDesc":null,"url":null,"reasonType":2100},{"type":402,"desc":"性能故障","subDesc":null,"url":null,"reasonType":2100},{"type":403,"desc":"屏幕故障","subDesc":null,"url":null,"reasonType":2100},{"type":404,"desc":"制冷系统故障","subDesc":null,"url":null,"reasonType":2100},{"type":405,"desc":"其他原因","subDesc":null,"url":null,"reasonType":1200}],"map8":[{"type":97,"desc":"质量问题","subDesc":null,"url":null,"reasonType":2100}]},"selectGoodsMetricInfo":{"page_el_sn":"9415312"},"forwardLogisticsVo":{"title":"商品正在运输中","content":"圆通快递: 您的快件离开【芜湖转运中心】,已发往【长春转运中心】。预计【04月18日】到达【长春市】,因运输距离较远,预计将在【18日晚上】为您更新快件状态,请您放心!","jumpExpressUrl":"\u002Fgoods_express.html?shipping_id=85&thumb_url=https:\u002F\u002Fimg.pddpic.com\u002Fmms-goods-image\u002F2026-04-11\u002F336d9a71-d957-4121-a84b-f70f084226c9.jpeg&hide_address=1&tracking_number=YT8859108440293&goods_id=936888997232&order_sn=260415-355310016032464"},"leftChar":170,"serviceTypeInfo":[],"priceArr":[13.5,13.5,13.5],"autoImageUploader":false,"firstSelectParams":null,"isPre":false,"isAllImageReady":true,"triggerAction":2,"finalCreateParam":{},"preBlockedPopupList":[],"hitSupplyDesc":false,"isServerRendered":true,"isFinishInitLoading":true,"selectedFakeCodes":[],"priceArrInPanel":[],"hasShowMoneyInputPanelOnce":false,"hasChangeAsTypeInHuanhuo":false,"userReceiveInfo":{"userReceiveName":"王(66187","userReceivePhone":"13439731154","userReceiveProvince":15,"userReceiveProvinceName":"吉林省","userReceiveCity":211,"userReceiveCityName":"长春市","userReceiveDistrict":1774,"userReceiveDistrictName":"绿园区","userReceiveAddressId":59596218123,"userReceiveAddress":"城西镇聚富家园28栋","userReceiveAddressDetail":"\n 吉林省\n 长春市\n 绿园区\n 城西镇聚富家园28栋\n ","userReceiveAddressSnapshotId":"1000000051695684417"},"imageUrlList":[],"mediaUrlList":[],"isPreferPickup":true,"userSatisfaction":-1,"bookBatchDecision":{},"proposedShowGuideTips":false,"isShowCouponRulePop":false,"showCheckPopType":null,"afterCheckCallback":null,"popupWindowData":null,"preCheckLayer":null,"showBookBatchCheckPanel":false,"showMultipleSkuCheckPanel":false,"showReturnOrRefundPanel":false,"entryBoardBlockLayerData":null,"multipleSkuStatus":0,"curReturnIntention":-1,"isShowGoodsProblemPage":false,"userfullRefundReasonCode":0,"helpedFeedback":0,"solvedProblem":0,"handleMode":0,"applyPddJudgeDesc":null,"showAmountChoosePopUp":false,"floatingLayerDataMap":null,"hasShowFastAsPopOnce":false,"mustUploadProof":false,"hasSupplyReason":false,"showDescLessHover":false,"showNoProofReasonPop":false,"firstEnteringUpdateAstype":false,"canSupportReturnNumLogic":false,"orderModuleInfo":{"goodsName":"【三只松鼠新疆灰枣】免洗红枣150g新疆特产枣子干货休闲零食","spec":"新疆灰枣150g*5袋","thumbUrl":"https:\u002F\u002Fimg.pddpic.com\u002Fmms-goods-image\u002F2026-04-11\u002F336d9a71-d957-4121-a84b-f70f084226c9.jpeg","goodsNumber":1,"orderDetailUrl":"\u002Forder.html?page_from=702&order_sn=260415-355310016032464"},"selectedReturnGoodsNum":1,"mode":16,"orderSn":"260415-355310016032464","curVersion":0,"predictAmountTips":"","priceModifyArr":[],"afterSalesStatus":"","userPhone":"13439731154","afterSalesIds":[],"complaintReason":0,"complaintGoodProblem":null,"lastComplaintReason":0,"afterSalesTrigger":3,"afterSalesType":1,"afterSalesCode":1001,"subAfterSalesType":0,"exchangeAfterSalesType":0,"afterSalesTypePopUpMap":{},"shippingStatus":1,"tempUserShipStatus":0,"orderAmount":1350,"goodsAmount":1350,"shippingAmount":0,"returnCouponAmount":0,"complaintPrice":13.5,"complaintGoodsNumber":1,"complaintPercent":0,"complaintPartAsType":1,"goodsSkuInfo":{"isOnSale":true,"quantity":100,"imageUrl":"","thumbUrl":"https:\u002F\u002Fimg.pddpic.com\u002Fgaudit-image\u002F2026-04-11\u002F1d246236f884010908095da02c3a759a.jpeg","linkUrl":"goods.html?goods_id=936888997232&_oak_rcto=YWK-VzKCPlTWOOqfF_24n6zP10ePnWAlqiOmSz41CZfdbHO2Mjf7X5-V","skuList":[{"skuId":1884196560650,"goodsId":936888997232,"groupPrice":360,"quantity":159,"spec":"新疆灰枣150g*1袋","thumbUrl":"https:\u002F\u002Fimg.pddpic.com\u002Fmms-goods-image\u002F2026-04-11\u002F336d9a71-d957-4121-a84b-f70f084226c9.jpeg"},{"skuId":1884196560652,"goodsId":936888997232,"groupPrice":1350,"quantity":644,"spec":"新疆灰枣150g*5袋","thumbUrl":"https:\u002F\u002Fimg.pddpic.com\u002Fmms-goods-image\u002F2026-04-11\u002F336d9a71-d957-4121-a84b-f70f084226c9.jpeg"}],"mallId":166290398,"badGoodsType":null,"isShowBadCommonGoodsService":null,"afterSalesType":null,"exceptionInfo":"","defaultSkuId":""},"selectedSkuId":0,"selectedSkuInfo":{},"exchangeGoodsNumber":1,"complaintDesc":"","images":[],"showRightsModal":false,"showTicketsRefundAmountDescModal":false,"showRefundDescModal":false,"showRefundAmountDescModal":false,"joinSceneList":[],"reasonList":[],"showSceneSelect":false,"sceneCode":0,"reasonCode":0,"autoFocusJoinScene":false,"autoFocusJoinReason":false,"autoFocusASType":false,"autoFocusMoney":false,"autoFocusUserShip":false,"autoFocusReason":false,"autoFocusDescription":false,"autoFocusMobile":false,"autoFocusSpecificSituation":false,"entryApplyBtnList":[],"afterSalesRightsList":[],"reasonCodeMappingTips":"","hasExchangeFreight":false,"orderInsuranceDto":{"amount":0,"insuranceCombineType":1,"extraSubsidyType":0,"hasOrderInsurance":false,"monthMembershipStrengthenGray":false,"insuranceAmountYuan":0,"insuranceLabelNew":{"type":"solid-hollow","char":["享","退货包运费"]}},"goodsProblemInfo":null,"updateAfterSalesRightsSeed":1,"veriRefresh":false,"compensatePercentCouponAmount":0,"inputMoneyTimes":3,"activityRetrieveInfoList":[],"retrieveSummaryTitle":[],"refundLayerTitle":"","newMaxApplyAmount":1350,"applyMoneyVO":{"applyAmountInfo":{"applyAmount":1350,"maxApplyAmount":1350,"amountLocked":false},"blankAmountInfo":false,"blankAmountText":"请输入申请金额,最多13.5元","createAfterSalesInfo":{"refundAmount":1350,"returnCashCouponAmount":0},"mergePaymentOrderNote":"","metricInfo":{},"extension":{"payRemitDetail":"1"}},"isIllegalInput":false,"isQualityReason":false,"reasonLock":false,"joinRemindInfo":null,"initService":{},"submitService":{},"refundPollingConfig":[2000,300,900],"isComplaintVideoLongDuration":false,"originMode":64,"afterSalesId":"","proposedAfterSalesType":0,"webpEnable":true,"msgId":0,"joinPageSource":0,"isMiniProgramNewShop":false,"isNativePlatform":false,"curPlatform":"unknown","modifySource":"","isMiniProgramKTT":false,"isAddInvisibleChar":false,"isCsr":false,"appVersion":"","firstVisitAfterSalesType":1,"applyInfoReturnMark":true,"noPriceTips":false,"couponAmount":0,"couponReturnControlType":0,"remainFullBackCouponAmount":0,"remainMallFullBackCouponAmount":0,"couponType":0,"orderPayType":0,"couponDelayDisplayType":0,"retrieveCouponNum":0,"retrieveCouponAmount":0,"retrieveCashAmount":0,"refundAmount":0,"predictRetrievePayReductionAmount":0,"predictRetrieveInstallPayReductionAmount":0,"partakeRetrieveCashActivities":[],"retrieveCash":false,"retrieveCoupon":false,"isPartakeFullBack":false,"isPartakeMallFullBack":false,"isReturnCoupon":true,"couponEndTimeDisplay":"","payLater":false,"payLaterStatus":0,"refundDesc":"","automaticTicket":false,"pattern":0,"serviceCharge":0,"refundAmountRules":[],"refundAmountTitle":"","payReductionOrder":false,"compensateCouponInfo":{"maxCouponAmount":0,"couponTypeText":"","rulesDesc":"","couponExpireText":""},"mergePaymentOrderNote":"","orchardZeroYuanOrder":false,"fillPartAsVal":1,"returnableGoodsNum":1,"deliveryScheduleOrder":false,"isUserReceiveAddressLock":false,"showShippingStatusSelect":true,"mustProofInfo":[],"RemindInfo":[{"remindType":23,"applyRemindFilter":{"includeAfterSalesType":[1,2],"includeAfterSalesReason":[86,102]},"params":{"applyRemarkTips":"请详细描述您\u003Cspan style=\"color:#E02E24\"\u003E认为商品为假货品牌的具体理由 \u003C\u002Fspan\u003E,并提供相应凭证;有助于更好的帮您处理退款","specificSituation":[{"code":1,"text":"品牌标识不符","metricInfo":{"page_el_sn":"10155064"}},{"code":2,"text":"已鉴定是假货","metricInfo":{"page_el_sn":"10155065"}},{"code":3,"text":"商家承认售假","metricInfo":{"page_el_sn":"10155066"}},{"code":4,"text":"做工、质量与正品有明显差异","metricInfo":{"page_el_sn":"10155067"}}]}}],"remindInfoBelow":[{"remindType":10,"applyRemindFilter":{"includeAfterSalesType":[2]}},{"remindType":5,"applyRemindFilter":{"includeAfterSalesType":[1,2],"includeUserShippingStatus":[2],"includeAfterSalesReason":[66,79,88,95,104,111,197,4005]}}],"remindInfoAbove":[],"belowAfterSalesTypeRemindInfoList":[{"remindType":9,"applyRemindFilter":{"includeAfterSalesType":[3],"availableAfterSalesType":2}}],"remindInfoAboveRemark":[],"topBannerRemindInfoList":[],"aboveApplyButtonRemindInfoList":[],"bizType":0,"discountAmount":0,"serviceAmount":0,"sfExpressAmount":0,"provinceId":15,"cityId":211,"districtId":1774,"addressId":59596218123,"mallId":166290398,"receiveName":"王(66187","mobile":"13439731154","provinceName":"吉林省","cityName":"长春市","districtName":"绿园区","shippingAddress":"城西镇聚富家园28栋","addressSnapshotId":"1000000051695684417","refundableAmount":1350,"alreadyRefundAmount":0,"refundAmountLocked":false,"aliveAfterSales":false,"compensateType":999,"unSignSelectOption":true,"goodsType":1,"originComplaintPrice":13.5,"installFeeAmount":0,"canEditShipping":true,"isDeletedOrder":false,"isOutsideConsoOrder":false,"isCrossConsoOrder":false,"isKTTOrder":false,"isVegetableOrder":false,"kttSplitBillOrder":false,"paidOver2Days":false,"entryExtraButtonList":[],"showAppendContent":false,"payReductionAmount":0,"payReductionText":"信用卡分期立减"},"deliveryStore":{"errorRedirectUrl":"\u002F","lightImageLoaderViewID":"tracking-number-image-uploader","isAllImageReady":true,"canMergeTrackingNumber":false,"isServerRendered":true,"isFinishInitLoading":true,"currCurrency":null,"showEmptyInputErr":false,"rawShippingList":[],"imageInfoList":[],"shipAmountTips":"","showEqualMoneyPopUp":false,"showProofTips":false,"remarkShippingName":"","showRemarkShippingName":false,"showSelfProofPopup":false,"hasShowModifyDeliveryFeePop":false,"guidePutProofTextView":null,"contactSelectedValue":1,"paymentSelectedValue":1,"freightCollectSelectedValue":1,"showSearch":false,"complaintShippingName":"","complaintShippingLogo":"","complaintShippingId":0,"tipsDesc":"","complaintDeliverySn":"","checkedDeliverySn":"","complaintDeliveryFee":"","ocrDeliverySn":"","ocrShippingId":0,"isOcrFromDetail":false,"complaintDesc":"","leftChar":170,"ocrImgUrl":"","newOrcImg":"","ocrOriginImg":"","cachedOcrOriginImg":"","isMatchingCompany":false,"canAutoMatchCompany":true,"hasMatched":false,"isShowConfirmPage":false,"isShowExpressPhotoDemo":true,"isShowOcrProgressToast":false,"ocrProgressValue":0,"ocrProgressStep":300,"autoExpandCurrency":false,"autoFocusDeliveryCompany":false,"autoFocusDeliveryNo":false,"autoFocusDescription":false,"autoFocusDeliveryFee":false,"veriDeliveryRefresh":false,"initService":{},"deliveryService":{},"mode":64,"orderSn":"260415-355310016032464","afterSalesId":"","webpEnable":true,"autoOcr":false,"isNativePlatform":false}};</script>
|
||
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);
|
||
}));
|
||
PddBuyerAfterSaleLiteInfo afterSale = new PddBuyerAfterSaleLiteInfo();
|
||
afterSale.listItemStatusVO = new ListItemStatusVO();
|
||
afterSale.listItemStatusVO.statusText = "退款成功";
|
||
afterSale.listItemExtraVO = new ListItemExtraVO();
|
||
//afterSale.listItemExtraVO.navToDetailPageUrl = "&order_sn=" + txtForceSendAfterSale.Text.Trim();
|
||
afterSale.listItemExtraVO.navToDetailPageUrl = "&order_sn=" + order.order_sn;
|
||
SendAfterSaleE57(afterSale, true);
|
||
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 + "\"}";
|
||
}
|
||
}
|
||
|
||
// 向服务端更新售后退货信息更新状态
|
||
public void SendAfterSaleE57(PddBuyerAfterSaleLiteInfo afterSale, bool resetSendStatus = false, bool isManualSendNoRecordCancelOrder = 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 < 3 && exportRst.Contains("操作超时"); i++)
|
||
{
|
||
Thread.Sleep(210000);
|
||
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(() =>
|
||
{
|
||
var after = lstPddBuyerAfterSaleInfoLite.FirstOrDefault(a => a.orderSn == afterSale.orderSn);
|
||
if (after != null)
|
||
{
|
||
after.sendStatus = afterSale.sendStatus;
|
||
ShowAfterSale(after);
|
||
}
|
||
|
||
if (isManualSendNoRecordCancelOrder)
|
||
{
|
||
BaseMsgForm.ShowInfo(afterSale.sendStatus);
|
||
}
|
||
}));
|
||
}
|
||
|
||
private void btnClose_Click(object sender, EventArgs e)
|
||
{
|
||
panel2.Visible = !panel2.Visible;
|
||
if (panel2.Visible == false)
|
||
btnClose.Text = "打开";
|
||
else
|
||
btnClose.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;
|
||
}
|
||
|
||
TimeSpan PauseTick = new TimeSpan(1);
|
||
private void chkPause_CheckedChanged(object sender, EventArgs e)
|
||
{
|
||
if (chkPause.Checked != true)
|
||
nextGetOrderTime = DateTime.Now + PauseTick;
|
||
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)
|
||
{
|
||
foreach(DataGridViewRow row in dgvPddBuyerOrder.Rows)
|
||
{
|
||
if (!row.Cells["colOPddOrderSn"].Value.ParseToString().Contains(txtOrderSnFilter.Text.Trim()) &&
|
||
!row.Cells["colOBuyerName"].Value.ParseToString().Contains(txtOrderSnFilter.Text.Trim()) &&
|
||
!row.Cells["colOMsg"].Value.ParseToString().Contains(txtOrderSnFilter.Text.Trim()))
|
||
{
|
||
row.Visible = false;
|
||
continue;
|
||
}
|
||
if (chkHideSuccessOrder.Checked && row.Cells["colOMsg"].Value.ParseToString().Contains("外采订单已发货"))
|
||
{
|
||
row.Visible = false;
|
||
continue;
|
||
}
|
||
row.Visible = true;
|
||
}
|
||
foreach (DataGridViewRow row in dgvAfterSale.Rows)
|
||
{
|
||
if (!row.Cells["colRPddOrderSn"].Value.ParseToString().Contains(txtOrderSnFilter.Text.Trim()) &&
|
||
!row.Cells["colRBuyerName"].Value.ParseToString().Contains(txtOrderSnFilter.Text.Trim()) &&
|
||
!row.Cells["colRAfterSaleId"].Value.ParseToString().Contains(txtOrderSnFilter.Text.Trim()) &&
|
||
!row.Cells["colRMsg"].Value.ParseToString().Contains(txtOrderSnFilter.Text.Trim()))
|
||
row.Visible = false;
|
||
else
|
||
row.Visible = true;
|
||
}
|
||
}
|
||
|
||
private void btnRestore_Click(object sender, EventArgs e)
|
||
{
|
||
txtOrderSnFilter.Text = "";
|
||
btnFilterOrder_Click(null, null);
|
||
}
|
||
|
||
private void lblMsg_Click(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
private void chkAutoAfterSale_CheckedChanged(object sender, EventArgs e)
|
||
{
|
||
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 = "切换订单";
|
||
btnForceSendAfterSale.Visible = true;
|
||
lblForceSendAfterSale.Visible = true;
|
||
txtForceSendAfterSale.Visible = true;
|
||
cmbBuyer.Visible = true;
|
||
}
|
||
else
|
||
{
|
||
this.dgvAfterSale.SendToBack();
|
||
btnExchange.Text = "切换售后";
|
||
btnForceSendAfterSale.Visible = false;
|
||
lblForceSendAfterSale.Visible = false;
|
||
txtForceSendAfterSale.Visible = false;
|
||
cmbBuyer.Visible = false;
|
||
}
|
||
}
|
||
|
||
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;
|
||
}
|
||
}
|
||
|
||
private void btnForceSendAfterSale_Click(object sender, EventArgs e)
|
||
{
|
||
if (cmbBuyer.Text == "666")
|
||
{
|
||
Task.Run(() =>
|
||
{
|
||
var orderId = txtForceSendAfterSale.Text.Trim();
|
||
|
||
PddBuyerAfterSaleLiteInfo afterSale = new PddBuyerAfterSaleLiteInfo();
|
||
afterSale.listItemStatusVO = new ListItemStatusVO();
|
||
afterSale.listItemStatusVO.statusText = "退款成功";
|
||
afterSale.listItemExtraVO = new ListItemExtraVO();
|
||
afterSale.listItemExtraVO.navToDetailPageUrl = "&order_sn=" + orderId;
|
||
SendAfterSaleE57(afterSale, true, true);
|
||
});
|
||
return;
|
||
}
|
||
|
||
var buyer = GlobalConfig.BuyerLoginList.FirstOrDefault(b => b.buyer_nick == cmbBuyer.Text.Trim());
|
||
if (cmbBuyer.Text.Trim().IsNullOrEmpty() || buyer == null)
|
||
{
|
||
BaseMsgForm.ShowError("请选择买手!");
|
||
return;
|
||
}
|
||
if (txtForceSendAfterSale.Text.Trim().IsNullOrEmpty() || !txtForceSendAfterSale.Text.Trim().Contains("-"))
|
||
{
|
||
BaseMsgForm.ShowError("请填写正确买手订单格式!");
|
||
return;
|
||
}
|
||
|
||
Task.Run(() =>
|
||
{
|
||
var orderId = txtForceSendAfterSale.Text.Trim();
|
||
var rst = YkdBuyerOrder.GetSearchOrder(buyer, orderId);
|
||
if (!rst.Contains("订单已取消") && !rst.Contains("退款成功"))
|
||
{
|
||
BaseMsgForm.ShowError("买手下未找到订单售后退款成功信息,请确定订单存在且订单已取消或退款。");
|
||
return;
|
||
}
|
||
|
||
PddBuyerAfterSaleLiteInfo afterSale = new PddBuyerAfterSaleLiteInfo();
|
||
afterSale.listItemStatusVO = new ListItemStatusVO();
|
||
afterSale.listItemStatusVO.statusText = "退款成功";
|
||
afterSale.listItemExtraVO = new ListItemExtraVO();
|
||
afterSale.listItemExtraVO.navToDetailPageUrl = "&order_sn=" + orderId;
|
||
SendAfterSaleE57(afterSale, true, true);
|
||
});
|
||
}
|
||
|
||
private void chkHideSuccessOrder_CheckedChanged(object sender, EventArgs e)
|
||
{
|
||
btnFilterOrder_Click(sender, e);
|
||
}
|
||
|
||
private void btnOtherPlatformOrder_Click(object sender, EventArgs e)
|
||
{
|
||
if (OtherBuyerOrderListForm.Instance == null)
|
||
{
|
||
OtherBuyerOrderListForm bo = new OtherBuyerOrderListForm();
|
||
}
|
||
OtherBuyerOrderListForm.Instance.Hide();
|
||
OtherBuyerOrderListForm.Instance.Show();
|
||
}
|
||
}
|
||
|
||
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 static string GetSearchOrder(BuyerLoginInfo buyer, string orderSn)
|
||
{
|
||
//1778823980132_ro0aie9x73
|
||
var page_id = "10032_" + BaseClass.DateTimeToTimestampMilliseconds(DateTime.Now) + "_" + Randomx.GetWordWithNumber(10);
|
||
string url = "https://mobile.yangkeduo.com/transac_orders_search_results.html?keyWord=" + orderSn +
|
||
"&type=0&main_orders=1&refer_page_name=my_order&refer_page_id=" + page_id + "&refer_page_sn=10032";
|
||
|
||
string refere = "https://mobile.yangkeduo.com/orders.html?type=0&comment_tab=1&combine_orders=1&main_orders=1&refer_page_name=personal&refer_page_id=&refer_page_sn=10001&page_id=" + page_id + "&is_back=1";
|
||
var rst = YkdHttpResponseBLL.YangkeduoGetSearchOrderResponse(buyer, url, refere);
|
||
return rst;
|
||
}
|
||
}
|
||
|
||
public class WxOrder
|
||
{
|
||
// orderStatus:20待发货 0售后中 30已发货
|
||
public static string OrderSeach(ShopLoginInfo shop, string orderId, string telNumber, int orderStatus = 20, int page = 1, string startTime="", string endTime="")
|
||
{
|
||
if (string.IsNullOrWhiteSpace(startTime))
|
||
startTime = BaseClass.DateTimeToTimestampMilliseconds(DateTime.Now.Date.AddMonths(-1)).ToString();
|
||
if (string.IsNullOrWhiteSpace(endTime))
|
||
endTime = BaseClass.DateTimeToTimestampMilliseconds(DateTime.Now.Date).ToString();
|
||
|
||
string url = "https://store.weixin.qq.com/shop-faas/mmchannelstradeorder/list/cgi/orderSearch?token=&lang=zh_CN";
|
||
string referer = "https://store.weixin.qq.com/shop/order/list";
|
||
string body = @"{""isSearch"":true,""pageSize"":100,""overTime"":0,""pengingShipOneDay"":0,""pengingShipSixHour"":0,""expediteDelivery"":0," +
|
||
@"""stockoutPunishAlert"":0,""waybillStatus"":0,""pageNum"":1,""onAftersaleOrderExist"":0,""orderStatus"":" + orderStatus +
|
||
@",""page"":" + page + @",""orderId"":""" + orderId + @""",""orderTime"":{""type"":0,""time"":[" + startTime + @"," + endTime + @"]}," +
|
||
@"""telNumber"":""" + telNumber + @""",""title"":"""",""receiverName"":"""",""finderNickName"":"""",""merchantNotes"":""""," +
|
||
@"""merchantNotesTagColor"":0,""waybillId"":"""",""productCode"":"""",""inspectStatus"":"""",""finderWay"":0,""searchOrderType"":0," +
|
||
@"""payMethod"":0,""orderChannel"":0,""bulkbuyActivityId"":"""",""deliveryNegotiationFlag"":0,""transactionId"":""""," +
|
||
@"""startCreateTime"":" + startTime + @",""endCreateTime"":" + endTime + @"}";
|
||
var result = WXHttpResponseBLL.WeiXinPostResponse(shop, url, body, referer);
|
||
return result;
|
||
}
|
||
}
|
||
|
||
public class BuyerReadOrderConfig
|
||
{
|
||
public bool IsPause = false;
|
||
public bool IsAutoAfterSale = true;
|
||
}
|
||
}
|