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

47 lines
3.3 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 WxCustomerServiceApi
{
/// <summary>提交 AI 客服消息推送回调验证,对应 WxAiTalkForm.Lf_SaveComplete 中的微信请求。</summary>
/// <param name="shop">店铺登录信息,Cookies 为原程序保存的 Cookie 列表 JSON。</param>
/// <param name="callbackUrl">客服服务提供方返回的消息推送回调 URL。</param>
/// <param name="token">回调验证 token,原流程传入客服应用 appId。</param>
/// <param name="base64Key">客服服务提供方返回的 Base64 消息加解密密钥。</param>
/// <returns>微信原始 JSON 或传输错误文字;调用方检查 code,不自动重试。</returns>
public static string VerifyCallback(ShopLoginInfo shop, string callbackUrl, string token, string base64Key)
{
var body = new JObject { ["url"] = callbackUrl, ["token"] = token, ["base64Key"] = base64Key };
return WxHttpClient.Post(shop, WxHttpClient.ShopHost + "/shop-faas/mmecnodeservicemarket/channel/ChannelsEcVerifyCallbackInfo?token=&lang=zh_CN",
body.ToString(), WxHttpClient.ShopHost + "/shop/servicemarket/home");
}
/// <summary>查询客服实时接待统计;原人工客服与 AI 客服共用此接口。</summary>
/// <param name="shop">店铺登录信息;Cookies 为原程序保存的 CefSharp.Cookie 列表 JSON,图片上传还需 openid。</param>
/// <param name="beginDateTick">开始时间的 Unix 毫秒时间戳;请求发送时转换为秒。</param>
/// <param name="endDateTick">结束时间的 Unix 毫秒时间戳;请求发送时转换为含三位小数的秒。</param>
/// <returns>微信接口原始 JSON 正文;传输或登录参数配置失败可能返回错误文字。调用方须验证响应格式和业务状态,不能仅以非空判断成功。</returns>
/// <remarks>
/// 来源:TEMUKJD\WXForms\AiTalkForms\WxAiTalkForm.cs,WxAiTalkForm.GetKfMsgStatistics。
/// 来源:TEMUKJD\WXForms\TalkForms\WxTalkForm.cs,WxTalkForm.GetKfMsgStatistics。
/// 原方法中直接拼接的 ID、JSON 数值片段应按上述格式传入;不会自动转义或转换单位。参数模型构造或序列化失败会向调用方抛出异常。
/// </remarks>
public static string GetKfMsgStatistics(ShopLoginInfo shop, long beginDateTick, long endDateTick)
{
string url = "https://store.weixin.qq.com/shop/kf/cgi/data/getRealTimeShopV2?" + "beginDate=" + (beginDateTick / 1000) + "&endDate=" + (endDateTick / 1000m).ToString("0.000");
string referer = "https://store.weixin.qq.com/shop/kf/data/store";
var result = WxHttpClient.Get(shop, url, referer);
return result;
}
}
}