Files
KJD/Work/AfterSaleSet.cs
2025-06-29 19:38:31 +08:00

120 lines
5.3 KiB
C#

using AllBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Work.Api;
namespace Work
{
public class AfterSaleSet
{
public ShopChatBase shop;
public string id;
public static List<RefundAdd> refundAddList = new List<RefundAdd>();
public static List<RefundAdd> refundTempAddList = new List<RefundAdd>();
public static void query()
{
refundAddList.Clear();
for (int i = 0; i < GetShopLoginInfo.Shops.Count; i++)
{
var shop = GetShopLoginInfo.Shops[i];
if (!shop.SelectReplace || !shop.Showed)
continue;
string url = "https://mms.pinduoduo.com/earth/api/refundAddress/list";
string refere = "https://mms.pinduoduo.com/order.html";
string data = "{}";
//第一页匹配结果
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, shop.Cookies);
if (html.Contains("\"success\":true"))
{
LogSave.Add("售后设置", "读取店铺" + shop.ShopName + ",售后地址信息。");
var m = BaseRegex.GetMatchRegex(ref html, @"{""id"":[^}]+?}");
for (int j = 0; m != null && j < m.Count; j++)
{
string list = m[j].Groups[0].Value;
RefundAdd refundAdd = new RefundAdd();
refundAdd.shopName = shop.ShopName;
refundAdd.id = BaseRegex.GetLongJson(ref list, "id");
refundAdd.refundAddress = BaseRegex.GetStringJson(ref list, "refundAddress");
refundAdd.refundName = BaseRegex.GetStringJson(ref list, "refundName");
refundAdd.refundPhone = BaseRegex.GetStringJson(ref list, "refundPhone");
refundAdd.refundTel = BaseRegex.GetStringJson(ref list, "refundTel");
refundAdd.provinceName = BaseRegex.GetStringJson(ref list, "provinceName");
refundAdd.cityName = BaseRegex.GetStringJson(ref list, "cityName");
refundAdd.districtName = BaseRegex.GetStringJson(ref list, "districtName");
refundAdd.isDefault = BaseRegex.GetStringJson(ref list, "isDefault");
refundAdd.refundId = BaseRegex.GetStringJson(ref list, "refundId");
refundAdd.mallId = BaseRegex.GetLongJson(ref list, "mallId");
refundAddList.Add(refundAdd);
refundTempAddList.Add(refundAdd);
Thread.Sleep(1*1000);
}
}
else
{
string errorMsg = BaseRegex.GetStringJson(ref html, "errorMsg");
LogSave.Add("售后设置", "读取店铺" + shop.ShopName + ",售后地址失败," + errorMsg);
}
}
}
public void del()
{
string url = "https://mms.pinduoduo.com/earth/api/refundAddress/delete";
string refere = "https://mms.pinduoduo.com/order.html";
string data = "{\"id\":" + id + "}";
//第一页匹配结果
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, shop.Cookies);
if (html.Contains("\"success\":true"))
{
LogSave.Add("售后设置", "店铺" + shop.ShopName + ",删除售后地址信息成功。");
}
else
{
string errorMsg = BaseRegex.GetStringJson(ref html, "errorMsg");
LogSave.Add("售后设置", "店铺" + shop.ShopName + ",删除售后地址信息失败。"+ errorMsg);
}
}
public void defaultAddress()
{
string url = "https://mms.pinduoduo.com/earth/api/refundAddress/default";
string refere = "https://mms.pinduoduo.com/order.html";
string data = "{\"id\":" + id + "}";
//第一页匹配结果
string html = GetPostTaobaoHtml.UploadTaobaoPost(url, refere, true, data, shop.Cookies);
if (html.Contains("\"success\":true"))
{
LogSave.Add("售后设置", "店铺" + shop.ShopName + ",设置默认售后地址信息成功。");
}
else
{
string errorMsg = BaseRegex.GetStringJson(ref html, "errorMsg");
LogSave.Add("售后设置", "店铺" + shop.ShopName + ",设置默认售后地址信息失败。" + errorMsg);
}
}
public static void SysAddress()
{
}
}
public class RefundAdd
{
public string shopName = "";
public long id = 0;
public string refundAddress = "";
public string refundName = "";
public string refundPhone = "";
public string refundTel = "";
public string provinceName = "";
public string cityName = "";
public string districtName = "";
public string isDefault = "";
public string refundId = "";
public long mallId = 0;
}
}