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

74 lines
5.7 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 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 WxFundsApi
{
/// <summary>查询店铺通用资金账户余额。</summary>
/// <param name="shop">店铺登录信息;Cookies 为原程序保存的 CefSharp.Cookie 列表 JSON,图片上传还需 openid。</param>
/// <returns>微信接口原始 JSON 正文;传输或登录参数配置失败可能返回错误文字。调用方须验证响应格式和业务状态,不能仅以非空判断成功。</returns>
/// <remarks>
/// 来源:TEMUKJD\WXForms\ShopForms\WxShopStatisticsForm.cs,WxShopStatisticsForm.GetShopAmount。
/// 原方法中直接拼接的 ID、JSON 数值片段应按上述格式传入;不会自动转义或转换单位。参数模型构造或序列化失败会向调用方抛出异常。
/// </remarks>
public static string GetShopAmount(ShopLoginInfo shop)
{
string url = "https://store.weixin.qq.com/shop-faas/mmchannelstradefunds/cgi/generalAccount/getGeneralAccountBalance?token=&lang=zh_CN";
string referer = "https://store.weixin.qq.com/shop/funds/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\ShopForms\WxShopStatisticsForm.cs,WxShopStatisticsForm.GetShopBalance。
/// 原方法中直接拼接的 ID、JSON 数值片段应按上述格式传入;不会自动转义或转换单位。参数模型构造或序列化失败会向调用方抛出异常。
/// </remarks>
public static string GetShopBalance(ShopLoginInfo shop)
{
string url = "https://store.weixin.qq.com/shop-faas/mmchannelstradedeposit/home/cgi/getDepositMPayState?token=&lang=zh_CN";
string referer = "https://store.weixin.qq.com/shop/funds/home";
var result = WxHttpClient.Get(shop, url, referer);
return result;
}
/// <summary>分页查询订单资金流水,用于原税务管理页面。</summary>
/// <param name="shop">店铺登录信息;Cookies 为原程序保存的 CefSharp.Cookie 列表 JSON,图片上传还需 openid。</param>
/// <param name="page">页码,从 1 开始。 默认值:1。</param>
/// <param name="orderSettleState">订单结算状态的接口筛选值,原税务查询使用 60。 默认值:60。</param>
/// <param name="orderState">资金流水的订单状态筛选值,原税务查询使用 100。 默认值:100。</param>
/// <param name="orderPayMethod">订单支付方式的接口筛选值,原税务查询使用 1。 默认值:1。</param>
/// <param name="createTimeBegin">订单创建开始时间的 Unix 秒时间戳,0 沿用原接口的起始条件。 默认值:0。</param>
/// <param name="createTimeEnd">订单创建结束时间的 Unix 秒时间戳;0 使用本机当天最后一秒。 默认值:0。</param>
/// <param name="pageSize">兼容原签名的参数;原实现固定请求每页 20 条,传入其他值不生效。 默认值:20。</param>
/// <returns>微信接口原始 JSON 正文;传输或登录参数配置失败可能返回错误文字。调用方须验证响应格式和业务状态,不能仅以非空判断成功。</returns>
/// <remarks>
/// 来源:TEMUKJD\WXForms\ShopForms\WXTaxManage.cs,WXTaxBLL.getListOrderFlow。
/// 原方法中直接拼接的 ID、JSON 数值片段应按上述格式传入;不会自动转义或转换单位。参数模型构造或序列化失败会向调用方抛出异常。
/// </remarks>
public static string GetListOrderFlow(ShopLoginInfo shop, int page = 1, int orderSettleState = 60, int orderState = 100, int orderPayMethod = 1, int createTimeBegin = 0, int createTimeEnd = 0, int pageSize = 20)
{
// shortcut: 原接口固定每页 20 条,确认平台支持自定义条数后再启用 pageSize 参数。
if (createTimeEnd == 0)
createTimeEnd = BaseClass.DateTimeToTimestampSeconds(DateTime.Now.Date.AddDays(1).AddSeconds(-1));
pageSize = 20;
var offset = Math.Max(page - 1, 0) * pageSize;
string url = "https://store.weixin.qq.com/shop-faas/mmchannelstradefunds/cgi/listOrderFlow?token=&lang=zh_CN";
string body = @"{""orderSettleState"":" + orderSettleState + @",""orderState"":" + orderState + @",""orderPayMethod"":" + orderPayMethod + @",""createTimeBegin"":""" + createTimeBegin + @""",""createTimeEnd"":""" + createTimeEnd + @""",""paginationInfo"":{""limit"":20,""offset"":" + offset + "}}";
string referer = "https://store.weixin.qq.com/shop/funds/moneyManage?section=3";
var result = WxHttpClient.Post(shop, url, body, referer);
return result;
}
}
}