Files
KJD/Work/Api/Wx/WxShopApi.cs
2026-10-30 11:30:02 +08:00

107 lines
7.8 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using AllBase;
using AllBase.Model.Result;
using AllBase.Model.Param.WXParam;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Work.Api.Wx
{
/// <summary>微信小店店铺登录、服务、状态及违规接口;独立于原窗体,使用 HttpHelper 发送请求。</summary>
/// <remarks>传入原 ShopLoginInfo 登录信息;方法同步执行,界面调用请置于后台任务。返回原始正文,不自动登录、重试或解释业务状态。</remarks>
public static class WxShopApi
{
/// <summary>查询店铺违规商品信息。</summary>
/// <param name="shop">店铺登录信息;Cookies 为原程序保存的 CefSharp.Cookie 列表 JSON,图片上传还需 openid。</param>
/// <returns>微信接口原始 JSON 正文;传输或登录参数配置失败可能返回错误文字。调用方须验证响应格式和业务状态,不能仅以非空判断成功。</returns>
/// <remarks>
/// 来源:TEMUKJD\PDDForms\ProductForms\WXProdViolationManage.cs,WXProdViolationManage.getShopiolationProd。
/// 原方法中直接拼接的 ID、JSON 数值片段应按上述格式传入;不会自动转义或转换单位。参数模型构造或序列化失败会向调用方抛出异常。
/// </remarks>
public static string GetShopViolationProducts(ShopLoginInfo shop)
{
string url = "https://store.weixin.qq.com/shop-faas/mmecnodeviolationsec/violation/cgi/get?token=&lang=zh_CN&violationType=finder&shopId=";
string referer = "https://store.weixin.qq.com/shop/violation/home";
var result = WxHttpClient.Get(shop, url, referer);
return result;
}
/// <summary>查询店铺当前已订购的服务列表。</summary>
/// <param name="shop">店铺登录信息;Cookies 为原程序保存的 CefSharp.Cookie 列表 JSON,图片上传还需 openid。</param>
/// <returns>微信接口原始 JSON 正文;传输或登录参数配置失败可能返回错误文字。调用方须验证响应格式和业务状态,不能仅以非空判断成功。</returns>
/// <remarks>
/// 来源:TEMUKJD\WXForms\ProductForms\WXDBProdUploadForm.cs,WXUpload.GetApiServiceList。
/// 原方法中直接拼接的 ID、JSON 数值片段应按上述格式传入;不会自动转义或转换单位。参数模型构造或序列化失败会向调用方抛出异常。
/// </remarks>
public static string GetApiServiceList(ShopLoginInfo shop)
{
string url = "https://store.weixin.qq.com/shop-faas/mmecnodeservicemarket/service/GetMyServiceList?offset=0&limit=20&status=2&token=&lang=zh_CN";
string referer = "https://store.weixin.qq.com/shop/servicemarket/myServices?status=2";
var result = WxHttpClient.Get(shop, url, referer);
return result;
}
/// <summary>获取并更新微信小店后台在线状态。</summary>
/// <param name="shop">店铺登录信息;Cookies 为原程序保存的 CefSharp.Cookie 列表 JSON,图片上传还需 openid。</param>
/// <returns>微信接口原始 JSON 正文;传输或登录参数配置失败可能返回错误文字。调用方须验证响应格式和业务状态,不能仅以非空判断成功。</returns>
/// <remarks>
/// 来源:TEMUKJD\WXForms\ProductForms\WXDBProdUploadForm.cs,WXUpload.GetAndUpdateWebStatus。
/// 原方法中直接拼接的 ID、JSON 数值片段应按上述格式传入;不会自动转义或转换单位。参数模型构造或序列化失败会向调用方抛出异常。
/// </remarks>
public static string GetAndUpdateWebStatus(ShopLoginInfo shop)
{
string url = "https://store.weixin.qq.com/shop-faas/mmchannelstradehome/home/getAndUpdateWebStatus?token=&lang=zh_CN";
string referer = "https://store.weixin.qq.com/shop/home";
string body = @"{""timeQuery"":{""startMs"":" + BaseClass.DateTimeToTimestampMilliseconds(DateTime.Now.Date.AddDays(-1)) + @",""endMs"":" + BaseClass.DateTimeToTimestampMilliseconds(DateTime.Now.Date.AddSeconds(-1)) + @"}}";
var result = WxHttpClient.Post(shop, url, body, referer);
return result;
}
/// <summary>读取店铺后台首页 HTML,用于原店铺登录信息提取流程。</summary>
/// <param name="shop">店铺登录信息;Cookies 为原程序保存的 CefSharp.Cookie 列表 JSON,图片上传还需 openid。</param>
/// <returns>后台首页原始 HTML;传输或登录参数配置失败可能返回错误文字。调用方须验证响应格式和业务状态,不能仅以非空判断成功。</returns>
/// <remarks>
/// 来源:TEMUKJD\WXForms\ShopForms\WXShopListForm.cs,WXShopListForm.GetShopInfo。
/// 原方法中直接拼接的 ID、JSON 数值片段应按上述格式传入;不会自动转义或转换单位。参数模型构造或序列化失败会向调用方抛出异常。
/// </remarks>
public static string GetShopInfo(ShopLoginInfo shop)
{
string url = "https://store.weixin.qq.com/shop/home";
string refere = "";
var result = WxHttpClient.Get(shop, url, refere, true);
return result;
}
/// <summary>请求店铺通知配置,用于判断当前 Cookie 是否仍可访问后台。</summary>
/// <param name="shop">店铺登录信息;Cookies 为原程序保存的 CefSharp.Cookie 列表 JSON,图片上传还需 openid。</param>
/// <param name="refere">请求的 Referer 页面地址。 默认值:&quot;https://store.weixin.qq.com/shop/home&quot;。</param>
/// <returns>微信接口原始 JSON 正文;传输或登录参数配置失败可能返回错误文字。调用方须验证响应格式和业务状态,不能仅以非空判断成功。</returns>
/// <remarks>
/// 来源:TEMUKJD\WXForms\ShopForms\WXShopListForm.cs,WXShopListForm.CheckShopLogin。
/// 原方法中直接拼接的 ID、JSON 数值片段应按上述格式传入;不会自动转义或转换单位。参数模型构造或序列化失败会向调用方抛出异常。
/// </remarks>
public static string CheckShopLogin(ShopLoginInfo shop, string refere = "https://store.weixin.qq.com/shop/home")
{
string url = "https://store.weixin.qq.com/shop-faas/mmecnodebase/reachDiolog/getBizNotifyConfig?token=&lang=zh_CN";
string body = @"{""path"":""https://store.weixin.qq.com/shop/home""}";
return WxHttpClient.Post(shop, url, body, refere);
}
/// <summary>查询当前登录账号可切换的店铺列表。</summary>
/// <param name="shop">店铺登录信息;Cookies 为原程序保存的 CefSharp.Cookie 列表 JSON,图片上传还需 openid。</param>
/// <returns>微信接口原始 JSON 正文;传输或登录参数配置失败可能返回错误文字。调用方须验证响应格式和业务状态,不能仅以非空判断成功。</returns>
/// <remarks>
/// 来源:TEMUKJD\WXForms\ShopForms\WXShopMultiLoginForm.cs,WXShopSwitch.getShopSwitchList。
/// 原方法中直接拼接的 ID、JSON 数值片段应按上述格式传入;不会自动转义或转换单位。参数模型构造或序列化失败会向调用方抛出异常。
/// </remarks>
public static string GetShopSwitchList(ShopLoginInfo shop)
{
string url = "https://store.weixin.qq.com/shop-faas/mmecnodelogin/session/getShopSwitchList?token=&lang=zh_CN";
string refere = "https://store.weixin.qq.com/shop/home";
var result = WxHttpClient.Get(shop, url, refere);
return result;
}
}
}