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

54 lines
3.9 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 WxAssistantApi
{
/// <summary>在微信带货助手选品池中查询商品;结构化参数重载执行列表筛选,商品 ID 重载执行关键词搜索。</summary>
/// <param name="shop">店铺登录信息;Cookies 为原程序保存的 CefSharp.Cookie 列表 JSON,图片上传还需 openid。</param>
/// <param name="wxCateAuthParam">选品池列表筛选 JSON;原参数名沿用旧方法,实际并非类目资质参数。</param>
/// <returns>微信接口原始 JSON 正文;传输或登录参数配置失败可能返回错误文字。调用方须验证响应格式和业务状态,不能仅以非空判断成功。</returns>
/// <remarks>
/// 来源:TEMUKJD\WXForms\AdminForms\WXSaleAssistantForm.cs,WxGetAssistant.wxGetAssistant。
/// 原方法中直接拼接的 ID、JSON 数值片段应按上述格式传入;不会自动转义或转换单位。参数模型构造或序列化失败会向调用方抛出异常。
/// </remarks>
public static string WxGetAssistant(ShopLoginInfo shop, JObject wxCateAuthParam)
{
string url = "https://store.weixin.qq.com/shop-faas/mmeckolpoolnode/ecListSelectionSpuItems?token=&lang=zh_CN";
string referer = "https://store.weixin.qq.com/talent/pool/home";
string data = JsonHelper.SerializeObject(wxCateAuthParam);
var result = WxHttpClient.PostAssistant(shop, url, data, referer);
return result;
}
/// <summary>在微信带货助手选品池中查询商品;结构化参数重载执行列表筛选,商品 ID 重载执行关键词搜索。</summary>
/// <param name="shop">店铺登录信息;Cookies 为原程序保存的 CefSharp.Cookie 列表 JSON,图片上传还需 openid。</param>
/// <param name="prodId">微信商品 ID。</param>
/// <returns>微信接口原始 JSON 正文;传输或登录参数配置失败可能返回错误文字。调用方须验证响应格式和业务状态,不能仅以非空判断成功。</returns>
/// <remarks>
/// 来源:TEMUKJD\WXForms\AdminForms\WXSaleAssistantForm.cs,WxGetAssistant.wxGetAssistant。
/// 原方法中直接拼接的 ID、JSON 数值片段应按上述格式传入;不会自动转义或转换单位。参数模型构造或序列化失败会向调用方抛出异常。
/// </remarks>
public static string WxGetAssistant(ShopLoginInfo shop, string prodId)
{
string url = "https://store.weixin.qq.com/shop-faas/mmeckolpoolnode/ecSearchSelectionSpuItems?token=&lang=zh_CN";
string referer = "https://store.weixin.qq.com/talent/pool/home?keyword=" + prodId;
string body = @"{""filter"":{""spuFilter"":{""monthlySalesRange"":null,""goodEvaluationRatioRange"":null,""shopScoreRange"":null},
""spuSort"":{""sortOrder"":0,""sortType"":0},""category"":null},""pageContext"":{""pageContext"":null,""limit"":15},
""requestContext"":{""sessionId"":""" + BaseClass.DateTimeToTimestampMilliseconds(DateTime.Now.AddSeconds(-Randomx.GetId(10, 100))) + @""",
""requestId"":""" + BaseClass.DateTimeToTimestampMilliseconds(DateTime.Now) + @""",""parentSearchId"":""53"",""displayedSpus"":null},
""keyword"":""" + prodId + @"""}";
var result = WxHttpClient.PostAssistant(shop, url, body, referer);
return result;
}
}
}