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
{
/// 微信小店资金余额、保证金及订单流水接口;独立于原窗体,使用 HttpHelper 发送请求。
/// 传入原 ShopLoginInfo 登录信息;方法同步执行,界面调用请置于后台任务。返回原始正文,不自动登录、重试或解释业务状态。
public static class WxFundsApi
{
/// 查询店铺通用资金账户余额。
/// 店铺登录信息;Cookies 为原程序保存的 CefSharp.Cookie 列表 JSON,图片上传还需 openid。
/// 微信接口原始 JSON 正文;传输或登录参数配置失败可能返回错误文字。调用方须验证响应格式和业务状态,不能仅以非空判断成功。
///
/// 来源:TEMUKJD\WXForms\ShopForms\WxShopStatisticsForm.cs,WxShopStatisticsForm.GetShopAmount。
/// 原方法中直接拼接的 ID、JSON 数值片段应按上述格式传入;不会自动转义或转换单位。参数模型构造或序列化失败会向调用方抛出异常。
///
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;
}
/// 查询店铺保证金支付状态。
/// 店铺登录信息;Cookies 为原程序保存的 CefSharp.Cookie 列表 JSON,图片上传还需 openid。
/// 微信接口原始 JSON 正文;传输或登录参数配置失败可能返回错误文字。调用方须验证响应格式和业务状态,不能仅以非空判断成功。
///
/// 来源:TEMUKJD\WXForms\ShopForms\WxShopStatisticsForm.cs,WxShopStatisticsForm.GetShopBalance。
/// 原方法中直接拼接的 ID、JSON 数值片段应按上述格式传入;不会自动转义或转换单位。参数模型构造或序列化失败会向调用方抛出异常。
///
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;
}
/// 分页查询订单资金流水,用于原税务管理页面。
/// 店铺登录信息;Cookies 为原程序保存的 CefSharp.Cookie 列表 JSON,图片上传还需 openid。
/// 页码,从 1 开始。 默认值:1。
/// 订单结算状态的接口筛选值,原税务查询使用 60。 默认值:60。
/// 资金流水的订单状态筛选值,原税务查询使用 100。 默认值:100。
/// 订单支付方式的接口筛选值,原税务查询使用 1。 默认值:1。
/// 订单创建开始时间的 Unix 秒时间戳,0 沿用原接口的起始条件。 默认值:0。
/// 订单创建结束时间的 Unix 秒时间戳;0 使用本机当天最后一秒。 默认值:0。
/// 兼容原签名的参数;原实现固定请求每页 20 条,传入其他值不生效。 默认值:20。
/// 微信接口原始 JSON 正文;传输或登录参数配置失败可能返回错误文字。调用方须验证响应格式和业务状态,不能仅以非空判断成功。
///
/// 来源:TEMUKJD\WXForms\ShopForms\WXTaxManage.cs,WXTaxBLL.getListOrderFlow。
/// 原方法中直接拼接的 ID、JSON 数值片段应按上述格式传入;不会自动转义或转换单位。参数模型构造或序列化失败会向调用方抛出异常。
///
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;
}
}
}