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

192 lines
16 KiB
C#
Raw 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 NaiBa.Util.Extension;
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 WxTalentApi
{
/// <summary>按完整筛选 JSON 查询达人广场列表。</summary>
/// <param name="shop">店铺登录信息;Cookies 为原程序保存的 CefSharp.Cookie 列表 JSON,图片上传还需 openid。</param>
/// <param name="bodyJson">符合原接口结构的完整筛选请求 JSON。</param>
/// <returns>微信接口原始 JSON 正文;传输或登录参数配置失败可能返回错误文字。调用方须验证响应格式和业务状态,不能仅以非空判断成功。</returns>
/// <remarks>
/// 来源:TEMUKJD\WXForms\ProductForms\WXFinderSquareForm.cs,WXFinderSquareBLL.getSquareTalentList。
/// 原方法中直接拼接的 ID、JSON 数值片段应按上述格式传入;不会自动转义或转换单位。参数模型构造或序列化失败会向调用方抛出异常。
/// </remarks>
public static string GetSquareTalentList(ShopLoginInfo shop, string bodyJson)
{
string url = "https://store.weixin.qq.com/shop-faas/mmchannelstradeleague/finderSquare/cgi/getSquareTalentList?token=&lang=zh_CN";
string referer = "https://store.weixin.qq.com/shop/findersquare/find";
string body = bodyJson;
var result = WxHttpClient.Post(shop, url, body, referer);
return result;
}
/// <summary>查询指定达人橱窗中的商品列表。</summary>
/// <param name="shop">店铺登录信息;Cookies 为原程序保存的 CefSharp.Cookie 列表 JSON,图片上传还需 openid。</param>
/// <param name="page">页码,从 1 开始。</param>
/// <param name="finderUsername">达人视频号在平台中的 finderUsername 标识。</param>
/// <param name="talentAppid">达人关联的 talentAppid 标识。</param>
/// <returns>微信接口原始 JSON 正文;传输或登录参数配置失败可能返回错误文字。调用方须验证响应格式和业务状态,不能仅以非空判断成功。</returns>
/// <remarks>
/// 来源:TEMUKJD\WXForms\ProductForms\WXFinderSquareForm.cs,WXFinderSquareBLL.WxFinderSquareGetProdList。
/// 原方法中直接拼接的 ID、JSON 数值片段应按上述格式传入;不会自动转义或转换单位。参数模型构造或序列化失败会向调用方抛出异常。
/// </remarks>
public static string WxFinderSquareGetProdList(ShopLoginInfo shop, int page, string finderUsername, string talentAppid)
{
string url = "https://store.weixin.qq.com/shop-faas/mmchannelstradeleague/finderSquare/cgi/getItemList?token=&lang=zh_CN&offset=" + (page - 1) * 10 + "&pageSize=10&productTitle=";
string referer = "https://store.weixin.qq.com/shop/findersquare/initiate-invite?finderUsername=" + finderUsername + "&talentAppid=" + talentAppid + "&from=5";
var result = WxHttpClient.Get(shop, url, referer);
return result;
}
/// <summary>批量查询商品,并按销量排序。</summary>
/// <param name="shop">店铺登录信息;Cookies 为原程序保存的 CefSharp.Cookie 列表 JSON,图片上传还需 openid。</param>
/// <param name="spuIdLst">微信商品 SPU ID 列表。</param>
/// <param name="page">页码,从 1 开始。 默认值:1。</param>
/// <returns>微信接口原始 JSON 正文;传输或登录参数配置失败可能返回错误文字。调用方须验证响应格式和业务状态,不能仅以非空判断成功。</returns>
/// <remarks>
/// 来源:TEMUKJD\WXForms\ProductForms\WXFinderSquareForm.cs,WXFinderSquareBLL.getSaleSortProduct。
/// 原方法中直接拼接的 ID、JSON 数值片段应按上述格式传入;不会自动转义或转换单位。参数模型构造或序列化失败会向调用方抛出异常。
/// </remarks>
public static string GetSaleSortProduct(ShopLoginInfo shop, List<string> spuIdLst, int page = 1)
{
var spuIdStr = "+" + string.Join("+", spuIdLst);
string url = "https://store.weixin.qq.com/shop-faas/mmchannelstradeproductcore/cgi/goods/searchProduct" + "?token=&lang=zh_CN&pageSize=50&productStatus[]=-1&productSource=[1,16,32]&searchSource=1&useNew=true&pageNum=" + page + "&status[]=5&spuId=" + spuIdStr + "&sortType=6";
string referer = "https://store.weixin.qq.com/shop/goods/list?currentTab=PRODUCT_STATUS_ON";
var result = WxHttpClient.Get(shop, url, referer);
return result;
}
/// <summary>批量查询商品,并按上架时间排序。</summary>
/// <param name="shop">店铺登录信息;Cookies 为原程序保存的 CefSharp.Cookie 列表 JSON,图片上传还需 openid。</param>
/// <param name="spuIdLst">微信商品 SPU ID 列表。</param>
/// <param name="page">页码,从 1 开始。 默认值:1。</param>
/// <returns>微信接口原始 JSON 正文;传输或登录参数配置失败可能返回错误文字。调用方须验证响应格式和业务状态,不能仅以非空判断成功。</returns>
/// <remarks>
/// 来源:TEMUKJD\WXForms\ProductForms\WXFinderSquareForm.cs,WXFinderSquareBLL.getListingTimeSortProduct。
/// 原方法中直接拼接的 ID、JSON 数值片段应按上述格式传入;不会自动转义或转换单位。参数模型构造或序列化失败会向调用方抛出异常。
/// </remarks>
public static string GetListingTimeSortProduct(ShopLoginInfo shop, List<string> spuIdLst, int page = 1)
{
var spuIdStr = "+" + string.Join("+", spuIdLst);
string url = "https://store.weixin.qq.com/shop-faas/mmchannelstradeproductcore/cgi/goods/searchProduct" + "?token=&lang=zh_CN&pageSize=50&productStatus[]=-1&productSource=[1,16,32]&searchSource=1&useNew=true&pageNum=" + page + "&status[]=5&spuId=" + spuIdStr + "&sortType=18";
string referer = "https://store.weixin.qq.com/shop/goods/list?currentTab=PRODUCT_STATUS_ON";
var result = WxHttpClient.Get(shop, url, referer);
return result;
}
/// <summary>向指定达人提交商品推广邀请及商家联系方式。</summary>
/// <param name="shop">店铺登录信息;Cookies 为原程序保存的 CefSharp.Cookie 列表 JSON,图片上传还需 openid。</param>
/// <param name="productIdLst">微信商品 ID 列表。</param>
/// <param name="finderUsername">达人视频号在平台中的 finderUsername 标识。</param>
/// <param name="talentAppid">达人关联的 talentAppid 标识。</param>
/// <param name="contactName">推广邀请中展示的商家联系人姓名。</param>
/// <param name="contactWxId">商家联系人的微信号。</param>
/// <param name="contactPhoneNumber">商家联系人手机号。</param>
/// <param name="invitationIntroduction">发送给达人的推广邀请说明。</param>
/// <returns>微信接口原始 JSON 正文;传输或登录参数配置失败可能返回错误文字。调用方须验证响应格式和业务状态,不能仅以非空判断成功。</returns>
/// <remarks>
/// 来源:TEMUKJD\WXForms\ProductForms\WXFinderSquareForm.cs,WXFinderSquareBLL.createPromotionInvitation。
/// 原方法中直接拼接的 ID、JSON 数值片段应按上述格式传入;不会自动转义或转换单位。参数模型构造或序列化失败会向调用方抛出异常。
/// </remarks>
public static string CreatePromotionInvitation(ShopLoginInfo shop, List<string> productIdLst, string finderUsername, string talentAppid, string contactName, string contactWxId, string contactPhoneNumber, string invitationIntroduction)
{
string url = "https://store.weixin.qq.com/shop-faas/mmchannelstradeleague/finderSquare/cgi/createPromotionInvitation?token=&lang=zh_CN";
string referer = "https://store.weixin.qq.com/shop/findersquare/initiate-invite?finderUsername=" + "&talentAppid=" + "&from=5";
string body = @"{""finderUsername"":""" + finderUsername + @""",""talentAppid"":""" + talentAppid + @""",""itemList"":{""itemInfo"":[";
foreach (var spuId in productIdLst)
{
body += @"{""spuId"":""" + spuId + @"""},";
}
body = body.TrimEnd(',');
body += @"]},""contactInfo"":{""contactName"":""" + contactName + @""",""contactWxId"":""" + contactWxId + @""",""contactPhoneNumber"":""" + contactPhoneNumber + @""",""invitationIntroduction"":""" + invitationIntroduction + @""",""inviteScene"":""5""}}";
var result = WxHttpClient.Post(shop, url, body, referer);
return result;
}
/// <summary>查询达人在指定时间范围内的直播或短视频内容列表。</summary>
/// <param name="shop">店铺登录信息;Cookies 为原程序保存的 CefSharp.Cookie 列表 JSON,图片上传还需 openid。</param>
/// <param name="finderUsername">达人视频号在平台中的 finderUsername 标识。</param>
/// <param name="mpAppid">达人关联的 mpAppid 标识。</param>
/// <param name="talentAppid">达人关联的 talentAppid 标识。</param>
/// <param name="startMs">统计开始时间的 Unix 毫秒时间戳。</param>
/// <param name="endMs">统计结束时间的 Unix 毫秒时间戳。</param>
/// <param name="liveOrFeed">内容类型:1 直播、2 短视频,来自原页面调用。 默认值:1。</param>
/// <param name="page">页码,从 1 开始。 默认值:1。</param>
/// <param name="pageSize">每页条数,默认值沿用原调用。 默认值:10。</param>
/// <returns>微信接口原始 JSON 正文;传输或登录参数配置失败可能返回错误文字。调用方须验证响应格式和业务状态,不能仅以非空判断成功。</returns>
/// <remarks>
/// 来源:TEMUKJD\WXForms\ProductForms\WXFinderSquareForm.cs,WXFinderSquareBLL.GetDaRenLiveFeedList。
/// 原方法中直接拼接的 ID、JSON 数值片段应按上述格式传入;不会自动转义或转换单位。参数模型构造或序列化失败会向调用方抛出异常。
/// </remarks>
public static string GetDaRenLiveFeedList(ShopLoginInfo shop, string finderUsername, string mpAppid, string talentAppid, long startMs, long endMs, int liveOrFeed = 1, int page = 1, int pageSize = 10)
{
string url = "https://store.weixin.qq.com/shop-faas/mmchannelstradeleague/finderSquare/cgi/GetSameIndustryDetailLiveFeedList?token=&lang=zh_CN";
string referer = "https://store.weixin.qq.com/shop/findersquare/finder-detail?from=5&fromTab=all&finderUsername=" + finderUsername;
if (!mpAppid.IsNullOrEmpty())
referer += "&mpAppid=" + mpAppid;
referer += "&talentAppid=" + talentAppid;
string body = @"{""appid"":""" + talentAppid + @""",""liveOrFeed"":" + liveOrFeed + @",""page"":{""limit"":" + pageSize + @",""offset"":" + (page - 1) * 10 + @"},""startMs"":" + startMs + @",""endMs"":" + endMs + @",""sortControl"":null}";
var result = WxHttpClient.Post(shop, url, body, referer);
return result;
}
/// <summary>查询达人指定直播或短视频内容中的商品列表。</summary>
/// <param name="shop">店铺登录信息;Cookies 为原程序保存的 CefSharp.Cookie 列表 JSON,图片上传还需 openid。</param>
/// <param name="finderUsername">达人视频号在平台中的 finderUsername 标识。</param>
/// <param name="mpAppid">达人关联的 mpAppid 标识。</param>
/// <param name="talentAppid">达人关联的 talentAppid 标识。</param>
/// <param name="objectId">目标直播或短视频内容的 objectId。</param>
/// <param name="page">页码,从 1 开始。 默认值:1。</param>
/// <param name="pageSize">每页条数,默认值沿用原调用。 默认值:10。</param>
/// <returns>微信接口原始 JSON 正文;传输或登录参数配置失败可能返回错误文字。调用方须验证响应格式和业务状态,不能仅以非空判断成功。</returns>
/// <remarks>
/// 来源:TEMUKJD\WXForms\ProductForms\WXFinderSquareForm.cs,WXFinderSquareBLL.GetDaRenLiveProductList。
/// 原方法中直接拼接的 ID、JSON 数值片段应按上述格式传入;不会自动转义或转换单位。参数模型构造或序列化失败会向调用方抛出异常。
/// </remarks>
public static string GetDaRenLiveProductList(ShopLoginInfo shop, string finderUsername, string mpAppid, string talentAppid, string objectId, int page = 1, int pageSize = 10)
{
string url = "https://store.weixin.qq.com/shop-faas/mmchannelstradeleague/finderSquare/cgi/getLiveProductList?token=&lang=zh_CN";
string referer = "https://store.weixin.qq.com/shop/findersquare/finder-detail?from=5&fromTab=all&finderUsername=" + finderUsername;
if (!mpAppid.IsNullOrEmpty())
referer += "&mpAppid=" + mpAppid;
referer += "&talentAppid=" + talentAppid;
string body = @"{""appid"":""" + talentAppid + @""",""objectId"":""" + objectId + @""",""limit"":" + pageSize + @",""offset"":" + (page - 1) * 10 + @"}";
var result = WxHttpClient.Post(shop, url, body, referer);
return result;
}
/// <summary>创建与指定达人的客服会话。</summary>
/// <param name="shop">店铺登录信息;Cookies 为原程序保存的 CefSharp.Cookie 列表 JSON,图片上传还需 openid。</param>
/// <param name="finderUsername">达人视频号在平台中的 finderUsername 标识。</param>
/// <param name="mpAppid">达人关联的 mpAppid 标识。</param>
/// <param name="talentAppid">达人关联的 talentAppid 标识。</param>
/// <returns>微信接口原始 JSON 正文;传输或登录参数配置失败可能返回错误文字。调用方须验证响应格式和业务状态,不能仅以非空判断成功。</returns>
/// <remarks>
/// 来源:TEMUKJD\WXForms\ProductForms\WXFinderSquareForm.cs,WXFinderSquareBLL.userCreateChatRoom。
/// 原方法中直接拼接的 ID、JSON 数值片段应按上述格式传入;不会自动转义或转换单位。参数模型构造或序列化失败会向调用方抛出异常。
/// </remarks>
public static string UserCreateChatRoom(ShopLoginInfo shop, string finderUsername, string mpAppid, string talentAppid)
{
string url = "https://store.weixin.qq.com/shop/commkf/user_room?action=user_create_room&token=&lang=zh_CN";
string referer = "https://store.weixin.qq.com/shop/findersquare/finder-detail?from=1&fromTab=all&finderUsername=" + finderUsername;
if (!mpAppid.IsNullOrEmpty())
referer += "&mpAppid=" + mpAppid;
referer += "&talentAppid=" + talentAppid;
string body = @"{""open_account"":""" + talentAppid + @"""}";
var result = WxHttpClient.PostCustomerService(shop, url, body, referer);
return result;
}
}
}