增加项目,分层
This commit is contained in:
1 parent
6e995a5bdb
commit
0a3e5af6a9
234 files changed
+26994
-1
No files matched your search
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Store.Client.Agent
|
||||
{
|
||||
/// <summary>
|
||||
/// 代理配置
|
||||
/// </summary>
|
||||
public class AgentConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// 代理码
|
||||
/// </summary>
|
||||
public static string AgentCode { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Store.Framework.Apis;
|
||||
|
||||
public class ApiResponse<T>
|
||||
{
|
||||
public int Code { get; set; }
|
||||
|
||||
public string Msg { get; set; }
|
||||
|
||||
public T Data { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,241 @@
|
||||
using MAX.Core.DependencyInjection;
|
||||
using MAX.Core.Helpers;
|
||||
using Store.Client.HttpExtension;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Store.Client.Apis
|
||||
{
|
||||
/// <summary>
|
||||
/// 公共基础数据Api
|
||||
/// </summary>
|
||||
public partial class CommonApi : AppApiRequestBase, ITransientDependency
|
||||
{
|
||||
#region 公共基础
|
||||
/// <summary>
|
||||
/// 获取服务器时间校准时间
|
||||
/// </summary>
|
||||
public DateTime GetServerTime()
|
||||
{
|
||||
HttpResult result = ServerRequest(new ServerHttpItem { URL = $"{_config.Host}/time.php" });
|
||||
if (result.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
if (DateTime.TryParse(result.Html, out DateTime dt))
|
||||
{
|
||||
return dt;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("连接服务器失败,将导致无法登录");
|
||||
}
|
||||
|
||||
}
|
||||
return DateTime.Now;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取签名验证配置
|
||||
/// </summary>
|
||||
public string GetAuthConfig()
|
||||
{
|
||||
ServerHttpItem item = new ServerHttpItem();
|
||||
item.URL = $"{_config.Host}?obj=api/config&act=auth_config";
|
||||
HttpResult result = ServerRequest(item);
|
||||
if (result.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
return result.Html;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取缓存服务集群负载比例
|
||||
/// </summary>
|
||||
public string GetCacheServerRatio()
|
||||
{
|
||||
|
||||
ServerHttpItem item = new ServerHttpItem();
|
||||
item.URL = _config.Host + "?" + _config.ObjUrl + "config&act=cache_service_mode";
|
||||
item.Method = MethodType.Post;
|
||||
//item.SignUser();
|
||||
HttpResult result = ServerRequest(item);
|
||||
if (result.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
return result.Html;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
#endregion
|
||||
|
||||
///// <summary>
|
||||
///// 获取服务器图片缓存
|
||||
///// </summary>
|
||||
///// <param name="imgUrl"></param>
|
||||
///// <returns></returns>
|
||||
//public HttpResult GetImageCache(string imgUrl)
|
||||
//{
|
||||
// long id = MD5Helper.GetLong(imgUrl);
|
||||
// ServerHttpItem item = new ServerHttpItem();
|
||||
// item.Method = MethodType.Post;
|
||||
// item.URL = _config.Host + "?" + _config.ObjUrl + "add_img";
|
||||
// item.Postdata = "act=get&table=" + Math.Abs(id % 1024) + "&id=" + id;
|
||||
// return ServerRequest(item);
|
||||
//}
|
||||
|
||||
#region 默认服务接口
|
||||
/// <summary>
|
||||
/// common&act=get_agent_ip
|
||||
/// </summary>
|
||||
public HttpResult GetAgentIp(string postdata = "")
|
||||
{
|
||||
return Post("common&act=get_agent_ip", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// config&act=get_service_url
|
||||
/// </summary>
|
||||
public HttpResult GetServiceUrl(string postdata = "")
|
||||
{
|
||||
return Post("config&act=get_service_url", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// cookies&act=save
|
||||
/// </summary>
|
||||
public HttpResult SaveCookies(string postdata = "")
|
||||
{
|
||||
return Post("cookies&act=save", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// data_change&act=get_cache_title
|
||||
/// </summary>
|
||||
public HttpResult GetCacheTitle(string postdata = "")
|
||||
{
|
||||
return Post("data_change&act=get_cache_title", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// data_change&act=get_pid
|
||||
/// </summary>
|
||||
public HttpResult GetPid(string postdata = "")
|
||||
{
|
||||
return Post("data_change&act=get_pid", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// decode&act=get
|
||||
/// </summary>
|
||||
public HttpResult GetDecode(string postdata = "")
|
||||
{
|
||||
return Post("decode&act=get", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// decode&act=getx
|
||||
/// </summary>
|
||||
public HttpResult GetDecodeList(string postdata = "")
|
||||
{
|
||||
return Post("decode&act=getx", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get_taobao_sign&act=get_tb_sign
|
||||
/// </summary>
|
||||
public HttpResult GetTaobaoSign(string postdata = "")
|
||||
{
|
||||
return Post("get_taobao_sign&act=get_tb_sign", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// nav_group_list
|
||||
/// </summary>
|
||||
public HttpResult GetNavGroupList(string postdata = "")
|
||||
{
|
||||
return Post("nav_group_list", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// oem_config&act=get_config_info
|
||||
/// </summary>
|
||||
public HttpResult GetOemConfigInfo(string postdata = "")
|
||||
{
|
||||
return Post("oem_config&act=get_config_info", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// oem_config&act=get_version
|
||||
/// </summary>
|
||||
public HttpResult GetOemVersion(string postdata = "")
|
||||
{
|
||||
return Post("oem_config&act=get_version", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// regedit
|
||||
/// </summary>
|
||||
public HttpResult Regedit(string postdata = "")
|
||||
{
|
||||
return PostPublic("regedit", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// reset_password
|
||||
/// </summary>
|
||||
public HttpResult ResetPassword(string postdata = "")
|
||||
{
|
||||
return PostPublic("reset_password", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// sign
|
||||
/// </summary>
|
||||
public HttpResult GetPackageSign(string postdata = "")
|
||||
{
|
||||
return Post("sign", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// sign&act=get&type={type}&client_id={clientId}
|
||||
/// </summary>
|
||||
public HttpResult GetSign(string type, string clientId, string postdata = "")
|
||||
{
|
||||
return Post("sign&act=get&type=" + type + "&client_id=" + clientId, postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// sms_gate
|
||||
/// </summary>
|
||||
public HttpResult SmsGate(string postdata = "")
|
||||
{
|
||||
return PostPublic("sms_gate", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// upid&act=getx&page={page}
|
||||
/// </summary>
|
||||
public HttpResult GetUpidList(int page, string postdata = "")
|
||||
{
|
||||
return Post("upid&act=getx&page=" + page, postdata);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 默认兼容接口
|
||||
/// <summary>
|
||||
/// update/get_update_new
|
||||
/// </summary>
|
||||
public HttpResult DefaultUpdateGetUpdateNew(string postdata = "")
|
||||
{
|
||||
return PostDefault("update/get_update_new", postdata);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
using MAX.Core.DependencyInjection;
|
||||
using MAX.Core.Helpers;
|
||||
using Store.Client.HttpExtension;
|
||||
|
||||
namespace Store.Client.Apis
|
||||
{
|
||||
public partial class OrderApi : AppApiRequestBase, ITransientDependency
|
||||
{
|
||||
#region 默认服务接口
|
||||
/// <summary>
|
||||
/// order/add_order
|
||||
/// </summary>
|
||||
public HttpResult AddOrder(string postdata = "")
|
||||
{
|
||||
return Post("order/add_order", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// order/add_order_code_file
|
||||
/// </summary>
|
||||
public HttpResult AddOrderCodeFile(string postdata = "")
|
||||
{
|
||||
return Post("order/add_order_code_file", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// order/get_order_code_file
|
||||
/// </summary>
|
||||
public HttpResult GetOrderCodeFile(string postdata = "")
|
||||
{
|
||||
return Post("order/get_order_code_file", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// order/get_order_list
|
||||
/// </summary>
|
||||
public HttpResult GetOrderList(string postdata = "")
|
||||
{
|
||||
return Post("order/get_order_list", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// order/save_order_code_file_link
|
||||
/// </summary>
|
||||
public HttpResult SaveOrderCodeFileLink(string postdata = "")
|
||||
{
|
||||
return Post("order/save_order_code_file_link", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// order/update_order_status
|
||||
/// </summary>
|
||||
public HttpResult UpdateOrderStatus(string postdata = "")
|
||||
{
|
||||
return Post("order/update_order_status", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// order/update_order_status1
|
||||
/// </summary>
|
||||
public HttpResult UpdateOrderStatus1(string postdata = "")
|
||||
{
|
||||
return Post("order/update_order_status1", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// order/upload_order
|
||||
/// </summary>
|
||||
public HttpResult UploadOrder(string postdata = "")
|
||||
{
|
||||
return Post("order/upload_order", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// pay_group_order&act=get_confirm_order&buy_type={buyType}&page={page}
|
||||
/// </summary>
|
||||
public HttpResult GetPayGroupConfirmOrder(string buyType, int page, string postdata = "")
|
||||
{
|
||||
return Post("pay_group_order&act=get_confirm_order&buy_type=" + buyType + "&page=" + page, postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// pay_group_order&act=reset_status
|
||||
/// </summary>
|
||||
public HttpResult ResetPayGroupOrderStatus(string postdata = "")
|
||||
{
|
||||
return Post("pay_group_order&act=reset_status", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// pay_group_order&act=update&buy_type={buyType}
|
||||
/// </summary>
|
||||
public HttpResult UpdatePayGroupOrder(string buyType, string postdata = "")
|
||||
{
|
||||
return Post("pay_group_order&act=update&buy_type=" + buyType, postdata);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 微信服务接口
|
||||
/// <summary>
|
||||
/// order/get_erp_order_list
|
||||
/// </summary>
|
||||
public HttpResult WxGetErpOrderList(string postdata = "")
|
||||
{
|
||||
return PostWx("order/get_erp_order_list", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// order/wx_del_erp_transit_warehouse_order
|
||||
/// </summary>
|
||||
public HttpResult WxDelErpTransitWarehouseOrder(string postdata = "")
|
||||
{
|
||||
return PostWx("order/wx_del_erp_transit_warehouse_order", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// order/wx_get_transit_order
|
||||
/// </summary>
|
||||
public HttpResult WxGetTransitOrder(string postdata = "")
|
||||
{
|
||||
return PostWx("order/wx_get_transit_order", postdata);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
using MAX.Core.DependencyInjection;
|
||||
using MAX.Core.Helpers;
|
||||
using Store.Client.HttpExtension;
|
||||
|
||||
namespace Store.Client.Apis
|
||||
{
|
||||
public partial class PriceApi : AppApiRequestBase, ITransientDependency
|
||||
{
|
||||
#region 默认服务接口
|
||||
/// <summary>
|
||||
/// price/add_price
|
||||
/// </summary>
|
||||
public HttpResult AddPrice(string postdata = "")
|
||||
{
|
||||
return Post("price/add_price", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// price/add_purchase_price
|
||||
/// </summary>
|
||||
public HttpResult AddPurchasePrice(string postdata = "")
|
||||
{
|
||||
return Post("price/add_purchase_price", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// price/del_db_price
|
||||
/// </summary>
|
||||
public HttpResult DelDbPrice(string postdata = "")
|
||||
{
|
||||
return Post("price/del_db_price", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// price/get_price_list
|
||||
/// </summary>
|
||||
public HttpResult GetPriceList(string postdata = "")
|
||||
{
|
||||
return Post("price/get_price_list", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// price/get_purchase_price_list
|
||||
/// </summary>
|
||||
public HttpResult GetPurchasePriceList(string postdata = "")
|
||||
{
|
||||
return Post("price/get_purchase_price_list", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// price/mdy_db_price
|
||||
/// </summary>
|
||||
public HttpResult MdyDbPrice(string postdata = "")
|
||||
{
|
||||
return Post("price/mdy_db_price", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// price/mdy_purchase_price
|
||||
/// </summary>
|
||||
public HttpResult MdyPurchasePrice(string postdata = "")
|
||||
{
|
||||
return Post("price/mdy_purchase_price", postdata);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 拼多多服务接口
|
||||
/// <summary>
|
||||
/// price/add_ext_code_price
|
||||
/// </summary>
|
||||
public HttpResult PddAddExtCodePrice(string postdata = "")
|
||||
{
|
||||
return PostPdd("price/add_ext_code_price", postdata);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,654 @@
|
||||
using MAX.Core.DependencyInjection;
|
||||
using MAX.Core.Helpers;
|
||||
using Store.Client.HttpExtension;
|
||||
|
||||
namespace Store.Client.Apis
|
||||
{
|
||||
public partial class ProductApi : AppApiRequestBase, ITransientDependency
|
||||
{
|
||||
#region 默认服务接口
|
||||
/// <summary>
|
||||
/// product/add_cate_size_weight_config_v2
|
||||
/// </summary>
|
||||
public HttpResult AddCateSizeWeightConfigV2(string postdata = "")
|
||||
{
|
||||
return Post("product/add_cate_size_weight_config_v2", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/add_product
|
||||
/// </summary>
|
||||
public HttpResult AddProduct(string postdata = "")
|
||||
{
|
||||
return Post("product/add_product", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/add_sku_image
|
||||
/// </summary>
|
||||
public HttpResult AddSkuImage(string postdata = "")
|
||||
{
|
||||
return Post("product/add_sku_image", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/add_sku_img
|
||||
/// </summary>
|
||||
public HttpResult AddSkuImg(string postdata = "")
|
||||
{
|
||||
return Post("product/add_sku_img", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/add_sku_img_replace
|
||||
/// </summary>
|
||||
public HttpResult AddSkuImgReplace(string postdata = "")
|
||||
{
|
||||
return Post("product/add_sku_img_replace", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/add_user_select_product
|
||||
/// </summary>
|
||||
public HttpResult AddUserSelectProduct(string postdata = "")
|
||||
{
|
||||
return Post("product/add_user_select_product", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/admin_get_user_select_product_list
|
||||
/// </summary>
|
||||
public HttpResult AdminGetUserSelectProductList(string postdata = "")
|
||||
{
|
||||
return Post("product/admin_get_user_select_product_list", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/del_db_product
|
||||
/// </summary>
|
||||
public HttpResult DelDbProduct(string postdata = "")
|
||||
{
|
||||
return Post("product/del_db_product", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/del_select_product
|
||||
/// </summary>
|
||||
public HttpResult DelSelectProduct(string postdata = "")
|
||||
{
|
||||
return Post("product/del_select_product", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/del_sku_image
|
||||
/// </summary>
|
||||
public HttpResult DelSkuImage(string postdata = "")
|
||||
{
|
||||
return Post("product/del_sku_image", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/get_cate_size_weight_config_v2
|
||||
/// </summary>
|
||||
public HttpResult GetCateSizeWeightConfigV2(string postdata = "")
|
||||
{
|
||||
return Post("product/get_cate_size_weight_config_v2", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/get_pdd_prod_wx_complate_list
|
||||
/// </summary>
|
||||
public HttpResult GetPddProdWxComplateList(string postdata = "")
|
||||
{
|
||||
return Post("product/get_pdd_prod_wx_complate_list", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/get_pdd_product_cates
|
||||
/// </summary>
|
||||
public HttpResult GetPddProductCates(string postdata = "")
|
||||
{
|
||||
return Post("product/get_pdd_product_cates", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/get_pdd_product_detail_list
|
||||
/// </summary>
|
||||
public HttpResult GetPddProductDetailList(string postdata = "")
|
||||
{
|
||||
return Post("product/get_pdd_product_detail_list", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/get_pdd_product_list_random
|
||||
/// </summary>
|
||||
public HttpResult GetPddProductListRandom(string postdata = "")
|
||||
{
|
||||
return Post("product/get_pdd_product_list_random", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/get_product_detail_list
|
||||
/// </summary>
|
||||
public HttpResult GetProductDetailList(string postdata = "")
|
||||
{
|
||||
return Post("product/get_product_detail_list", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/get_product_group_list
|
||||
/// </summary>
|
||||
public HttpResult GetProductGroupList(string postdata = "")
|
||||
{
|
||||
return Post("product/get_product_group_list", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/get_product_list
|
||||
/// </summary>
|
||||
public HttpResult GetProductList(string postdata = "")
|
||||
{
|
||||
return Post("product/get_product_list", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/get_product_list_random
|
||||
/// </summary>
|
||||
public HttpResult GetProductListRandom(string postdata = "")
|
||||
{
|
||||
return Post("product/get_product_list_random", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/get_random_company_product_config
|
||||
/// </summary>
|
||||
public HttpResult GetRandomCompanyProductConfig(string postdata = "")
|
||||
{
|
||||
return Post("product/get_random_company_product_config", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/get_select_prod_db_id_map_draft_id_list
|
||||
/// </summary>
|
||||
public HttpResult GetSelectProdDbIdMapDraftIdList(string postdata = "")
|
||||
{
|
||||
return Post("product/get_select_prod_db_id_map_draft_id_list", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/get_select_prod_map_up_spu_id_list
|
||||
/// </summary>
|
||||
public HttpResult GetSelectProdMapUpSpuIdList(string postdata = "")
|
||||
{
|
||||
return Post("product/get_select_prod_map_up_spu_id_list", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/get_sku_image_list
|
||||
/// </summary>
|
||||
public HttpResult GetSkuImageList(string postdata = "")
|
||||
{
|
||||
return Post("product/get_sku_image_list", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/get_sku_img_replace_list
|
||||
/// </summary>
|
||||
public HttpResult GetSkuImgReplaceList(string postdata = "")
|
||||
{
|
||||
return Post("product/get_sku_img_replace_list", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/get_sku_replace_img_list_random
|
||||
/// </summary>
|
||||
public HttpResult GetSkuReplaceImgListRandom(string postdata = "")
|
||||
{
|
||||
return Post("product/get_sku_replace_img_list_random", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/get_user_select_product_list
|
||||
/// </summary>
|
||||
public HttpResult GetUserSelectProductList(string postdata = "")
|
||||
{
|
||||
return Post("product/get_user_select_product_list", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/is_get_wx_recommend_hot_prod
|
||||
/// </summary>
|
||||
public HttpResult IsGetWxRecommendHotProd(string postdata = "")
|
||||
{
|
||||
return Post("product/is_get_wx_recommend_hot_prod", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/mdy_base64_img_url
|
||||
/// </summary>
|
||||
public HttpResult MdyBase64ImgUrl(string postdata = "")
|
||||
{
|
||||
return Post("product/mdy_base64_img_url", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/mdy_base64_img_use_count
|
||||
/// </summary>
|
||||
public HttpResult MdyBase64ImgUseCount(string postdata = "")
|
||||
{
|
||||
return Post("product/mdy_base64_img_use_count", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/mdy_best_sale_prod
|
||||
/// </summary>
|
||||
public HttpResult MdyBestSaleProd(string postdata = "")
|
||||
{
|
||||
return Post("product/mdy_best_sale_prod", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/mdy_db_product
|
||||
/// </summary>
|
||||
public HttpResult MdyDbProduct(string postdata = "")
|
||||
{
|
||||
return Post("product/mdy_db_product", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/mdy_product
|
||||
/// </summary>
|
||||
public HttpResult MdyProduct(string postdata = "")
|
||||
{
|
||||
return Post("product/mdy_product", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/mdy_product_category
|
||||
/// </summary>
|
||||
public HttpResult MdyProductCategory(string postdata = "")
|
||||
{
|
||||
return Post("product/mdy_product_category", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/mdy_product_select_notes
|
||||
/// </summary>
|
||||
public HttpResult MdyProductSelectNotes(string postdata = "")
|
||||
{
|
||||
return Post("product/mdy_product_select_notes", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/mdy_sku_img_replace
|
||||
/// </summary>
|
||||
public HttpResult MdySkuImgReplace(string postdata = "")
|
||||
{
|
||||
return Post("product/mdy_sku_img_replace", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/mdy_user_select_product_status
|
||||
/// </summary>
|
||||
public HttpResult MdyUserSelectProductStatus(string postdata = "")
|
||||
{
|
||||
return Post("product/mdy_user_select_product_status", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/set_random_company_product_config
|
||||
/// </summary>
|
||||
public HttpResult SetRandomCompanyProductConfig(string postdata = "")
|
||||
{
|
||||
return Post("product/set_random_company_product_config", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/set_select_product_sub_sa
|
||||
/// </summary>
|
||||
public HttpResult SetSelectProductSubSa(string postdata = "")
|
||||
{
|
||||
return Post("product/set_select_product_sub_sa", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/wx_add_mdy_after_sale
|
||||
/// </summary>
|
||||
public HttpResult WxAddMdyAfterSale(string postdata = "")
|
||||
{
|
||||
return Post("product/wx_add_mdy_after_sale", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/wx_del_address
|
||||
/// </summary>
|
||||
public HttpResult WxDelAddress(string postdata = "")
|
||||
{
|
||||
return Post("product/wx_del_address", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/wx_del_qualification_image
|
||||
/// </summary>
|
||||
public HttpResult WxDelQualificationImage(string postdata = "")
|
||||
{
|
||||
return Post("product/wx_del_qualification_image", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/wx_get_after_sale
|
||||
/// </summary>
|
||||
public HttpResult WxGetAfterSale(string postdata = "")
|
||||
{
|
||||
return Post("product/wx_get_after_sale", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/wx_get_after_sale_list
|
||||
/// </summary>
|
||||
public HttpResult WxGetAfterSaleList(string postdata = "")
|
||||
{
|
||||
return Post("product/wx_get_after_sale_list", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/wx_get_qualification_image
|
||||
/// </summary>
|
||||
public HttpResult WxGetQualificationImage(string postdata = "")
|
||||
{
|
||||
return Post("product/wx_get_qualification_image", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/wx_get_random_after_sale_list
|
||||
/// </summary>
|
||||
public HttpResult WxGetRandomAfterSaleList(string postdata = "")
|
||||
{
|
||||
return Post("product/wx_get_random_after_sale_list", postdata);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 拼多多服务接口
|
||||
/// <summary>
|
||||
/// product/add_jst_sku
|
||||
/// </summary>
|
||||
public HttpResult PddAddJstSku(string postdata = "")
|
||||
{
|
||||
return PostPdd("product/add_jst_sku", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/add_mdy_jst_product_ban
|
||||
/// </summary>
|
||||
public HttpResult PddAddMdyJstProductBan(string postdata = "")
|
||||
{
|
||||
return PostPdd("product/add_mdy_jst_product_ban", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/add_prod_down_sku
|
||||
/// </summary>
|
||||
public HttpResult PddAddProdDownSku(string postdata = "")
|
||||
{
|
||||
return PostPdd("product/add_prod_down_sku", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/add_prod_wx_complate
|
||||
/// </summary>
|
||||
public HttpResult PddAddProdWxComplate(string postdata = "")
|
||||
{
|
||||
return PostPdd("product/add_prod_wx_complate", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/add_product
|
||||
/// </summary>
|
||||
public HttpResult PddAddProduct(string postdata = "")
|
||||
{
|
||||
return PostPdd("product/add_product", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/add_product_groups
|
||||
/// </summary>
|
||||
public HttpResult PddAddProductGroups(string postdata = "")
|
||||
{
|
||||
return PostPdd("product/add_product_groups", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/add_product_notes
|
||||
/// </summary>
|
||||
public HttpResult PddAddProductNotes(string postdata = "")
|
||||
{
|
||||
return PostPdd("product/add_product_notes", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/add_relation
|
||||
/// </summary>
|
||||
public HttpResult PddAddRelation(string postdata = "")
|
||||
{
|
||||
return PostPdd("product/add_relation", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/del_db_product
|
||||
/// </summary>
|
||||
public HttpResult PddDelDbProduct(string postdata = "")
|
||||
{
|
||||
return PostPdd("product/del_db_product", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/del_product_groups
|
||||
/// </summary>
|
||||
public HttpResult PddDelProductGroups(string postdata = "")
|
||||
{
|
||||
return PostPdd("product/del_product_groups", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/del_product_notes
|
||||
/// </summary>
|
||||
public HttpResult PddDelProductNotes(string postdata = "")
|
||||
{
|
||||
return PostPdd("product/del_product_notes", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/get_jst_product_coid_list
|
||||
/// </summary>
|
||||
public HttpResult PddGetJstProductCoidList(string postdata = "")
|
||||
{
|
||||
return PostPdd("product/get_jst_product_coid_list", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/get_jst_sku_list
|
||||
/// </summary>
|
||||
public HttpResult PddGetJstSkuList(string postdata = "")
|
||||
{
|
||||
return PostPdd("product/get_jst_sku_list", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/get_prod_down_sku_lst_by_sku_codes
|
||||
/// </summary>
|
||||
public HttpResult PddGetProdDownSkuLstBySkuCodes(string postdata = "")
|
||||
{
|
||||
return PostPdd("product/get_prod_down_sku_lst_by_sku_codes", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/get_product_detail_list
|
||||
/// </summary>
|
||||
public HttpResult PddGetProductDetailList(string postdata = "")
|
||||
{
|
||||
return PostPdd("product/get_product_detail_list", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/get_product_groups
|
||||
/// </summary>
|
||||
public HttpResult PddGetProductGroups(string postdata = "")
|
||||
{
|
||||
return PostPdd("product/get_product_groups", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/get_product_list
|
||||
/// </summary>
|
||||
public HttpResult PddGetProductList(string postdata = "")
|
||||
{
|
||||
return PostPdd("product/get_product_list", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/get_product_notes
|
||||
/// </summary>
|
||||
public HttpResult PddGetProductNotes(string postdata = "")
|
||||
{
|
||||
return PostPdd("product/get_product_notes", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/get_product_spu_id_list
|
||||
/// </summary>
|
||||
public HttpResult PddGetProductSpuIdList(string postdata = "")
|
||||
{
|
||||
return PostPdd("product/get_product_spu_id_list", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/get_relation
|
||||
/// </summary>
|
||||
public HttpResult PddGetRelation(string postdata = "")
|
||||
{
|
||||
return PostPdd("product/get_relation", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/mdy_db_product
|
||||
/// </summary>
|
||||
public HttpResult PddMdyDbProduct(string postdata = "")
|
||||
{
|
||||
return PostPdd("product/mdy_db_product", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/mdy_jst_sku
|
||||
/// </summary>
|
||||
public HttpResult PddMdyJstSku(string postdata = "")
|
||||
{
|
||||
return PostPdd("product/mdy_jst_sku", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/mdy_product
|
||||
/// </summary>
|
||||
public HttpResult PddMdyProduct(string postdata = "")
|
||||
{
|
||||
return PostPdd("product/mdy_product", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/mdy_violation_prod
|
||||
/// </summary>
|
||||
public HttpResult PddMdyViolationProd(string postdata = "")
|
||||
{
|
||||
return PostPdd("product/mdy_violation_prod", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/wx_api_category_classify
|
||||
/// </summary>
|
||||
public HttpResult PddWxApiCategoryClassify(string postdata = "")
|
||||
{
|
||||
return PostPdd("product/wx_api_category_classify", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/wx_api_get_all_cate
|
||||
/// </summary>
|
||||
public HttpResult PddWxApiGetAllCate(string postdata = "")
|
||||
{
|
||||
return PostPdd("product/wx_api_get_all_cate", postdata);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 微信服务接口
|
||||
/// <summary>
|
||||
/// product/e57_get_freight_template
|
||||
/// </summary>
|
||||
public HttpResult E57GetFreightTemplate(string postdata = "")
|
||||
{
|
||||
return PostWx("product/e57_get_freight_template", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/get_hot_product_detail_list
|
||||
/// </summary>
|
||||
public HttpResult WxGetHotProductDetailList(string postdata = "")
|
||||
{
|
||||
return PostWx("product/get_hot_product_detail_list", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/get_hot_product_list
|
||||
/// </summary>
|
||||
public HttpResult WxGetHotProductList(string postdata = "")
|
||||
{
|
||||
return PostWx("product/get_hot_product_list", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/wx_add_mdy_qualification_image
|
||||
/// </summary>
|
||||
public HttpResult WxAddMdyQualificationImage(string postdata = "")
|
||||
{
|
||||
return PostWx("product/wx_add_mdy_qualification_image", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/wx_add_mdy_shipping_template
|
||||
/// </summary>
|
||||
public HttpResult WxAddMdyShippingTemplate(string postdata = "")
|
||||
{
|
||||
return PostWx("product/wx_add_mdy_shipping_template", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/wx_get_product_latest_buy_amount_list
|
||||
/// </summary>
|
||||
public HttpResult WxGetProductLatestBuyAmountList(string postdata = "")
|
||||
{
|
||||
return PostWx("product/wx_get_product_latest_buy_amount_list", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product/wx_get_shipping_template
|
||||
/// </summary>
|
||||
public HttpResult WxGetShippingTemplate(string postdata = "")
|
||||
{
|
||||
return PostWx("product/wx_get_shipping_template", postdata);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 微信图片服务接口
|
||||
/// <summary>
|
||||
/// product/wx_api_upload_image
|
||||
/// </summary>
|
||||
public HttpResult WxApiUploadImage(string postdata = "")
|
||||
{
|
||||
return PostWxImg("product/wx_api_upload_image", postdata);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
using MAX.Core.DependencyInjection;
|
||||
using MAX.Core.Helpers;
|
||||
using Store.Client.HttpExtension;
|
||||
|
||||
namespace Store.Client.Apis
|
||||
{
|
||||
public partial class ProductThirdApi : AppApiRequestBase, ITransientDependency
|
||||
{
|
||||
#region 默认服务接口
|
||||
/// <summary>
|
||||
/// product_third/add_product
|
||||
/// </summary>
|
||||
public HttpResult AddProduct(string postdata = "")
|
||||
{
|
||||
return Post("product_third/add_product", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product_third/add_user_select_product
|
||||
/// </summary>
|
||||
public HttpResult AddUserSelectProduct(string postdata = "")
|
||||
{
|
||||
return Post("product_third/add_user_select_product", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product_third/admin_get_user_select_product_list
|
||||
/// </summary>
|
||||
public HttpResult AdminGetUserSelectProductList(string postdata = "")
|
||||
{
|
||||
return Post("product_third/admin_get_user_select_product_list", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product_third/del_select_product
|
||||
/// </summary>
|
||||
public HttpResult DelSelectProduct(string postdata = "")
|
||||
{
|
||||
return Post("product_third/del_select_product", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product_third/get_product_detail_list
|
||||
/// </summary>
|
||||
public HttpResult GetProductDetailList(string postdata = "")
|
||||
{
|
||||
return Post("product_third/get_product_detail_list", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product_third/get_product_detail_list_bak
|
||||
/// </summary>
|
||||
public HttpResult GetProductDetailListBak(string postdata = "")
|
||||
{
|
||||
return Post("product_third/get_product_detail_list_bak", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product_third/get_product_list
|
||||
/// </summary>
|
||||
public HttpResult GetProductList(string postdata = "")
|
||||
{
|
||||
return Post("product_third/get_product_list", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product_third/get_select_prod_db_id_map_draft_id_list
|
||||
/// </summary>
|
||||
public HttpResult GetSelectProdDbIdMapDraftIdList(string postdata = "")
|
||||
{
|
||||
return Post("product_third/get_select_prod_db_id_map_draft_id_list", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product_third/get_user_select_product_list
|
||||
/// </summary>
|
||||
public HttpResult GetUserSelectProductList(string postdata = "")
|
||||
{
|
||||
return Post("product_third/get_user_select_product_list", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product_third/mdy_db_product
|
||||
/// </summary>
|
||||
public HttpResult MdyDbProduct(string postdata = "")
|
||||
{
|
||||
return Post("product_third/mdy_db_product", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product_third/mdy_product_category
|
||||
/// </summary>
|
||||
public HttpResult MdyProductCategory(string postdata = "")
|
||||
{
|
||||
return Post("product_third/mdy_product_category", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product_third/mdy_product_select_notes
|
||||
/// </summary>
|
||||
public HttpResult MdyProductSelectNotes(string postdata = "")
|
||||
{
|
||||
return Post("product_third/mdy_product_select_notes", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product_third/mdy_user_select_product_status
|
||||
/// </summary>
|
||||
public HttpResult MdyUserSelectProductStatus(string postdata = "")
|
||||
{
|
||||
return Post("product_third/mdy_user_select_product_status", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// product_third/set_select_product_sub_sa
|
||||
/// </summary>
|
||||
public HttpResult SetSelectProductSubSa(string postdata = "")
|
||||
{
|
||||
return Post("product_third/set_select_product_sub_sa", postdata);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
|
||||
namespace Store.Client.Apis
|
||||
{
|
||||
///// <summary>
|
||||
///// 服务器
|
||||
///// </summary>
|
||||
//public class ServerHttpBase : ITransientDependency
|
||||
//{
|
||||
|
||||
// /// <summary>
|
||||
// /// 日志
|
||||
// /// </summary>
|
||||
// [Autowired]
|
||||
// protected ILog _log { get; set; }
|
||||
|
||||
// /// <summary>
|
||||
// /// 服务器配置
|
||||
// /// </summary>
|
||||
// [Autowired]
|
||||
// protected IServerConfig _config { get; set; }
|
||||
|
||||
// public ServerHttpBase()
|
||||
// {
|
||||
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// /// <summary>
|
||||
// /// 服务器请求
|
||||
// /// </summary>
|
||||
// /// <param name="item"></param>
|
||||
// /// <returns></returns>
|
||||
// public HttpResult ServerRequest(HttpItem item)
|
||||
// {
|
||||
// if (!item.URL.StartsWith("http"))
|
||||
// {
|
||||
// item.URL += _config.Host + item.URL;
|
||||
// }
|
||||
// item.Encoding = Encoding.UTF8;
|
||||
// // ////item
|
||||
// //#if PROXY
|
||||
// // item.ProxyIp = "127.0.0.1:8080";
|
||||
// //#endif
|
||||
// HttpHelper http = new HttpHelper();
|
||||
// HttpResult result = http.GetHtml(item);
|
||||
// if (result.StatusCode == HttpStatusCode.OK)
|
||||
// {
|
||||
// if (!string.IsNullOrEmpty(result.Html))
|
||||
// {
|
||||
// if (result.Html[0] == 65279)
|
||||
// {
|
||||
// result.Html = result.Html.Remove(0, 1);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
@@ -0,0 +1,472 @@
|
||||
using MAX.Core.DependencyInjection;
|
||||
using MAX.Core.Helpers;
|
||||
using Store.Client.HttpExtension;
|
||||
|
||||
namespace Store.Client.Apis
|
||||
{
|
||||
public partial class ShopApi : AppApiRequestBase, ITransientDependency
|
||||
{
|
||||
#region 默认服务接口
|
||||
/// <summary>
|
||||
/// pdd_shop_temp&act=goup
|
||||
/// </summary>
|
||||
public HttpResult GoupPddShopTemp(string postdata = "")
|
||||
{
|
||||
return Post("pdd_shop_temp&act=goup", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// pdd_shop_tempx&act=get_shop_cookies_list
|
||||
/// </summary>
|
||||
public HttpResult GetPddShopCookiesList(string postdata = "")
|
||||
{
|
||||
return Post("pdd_shop_tempx&act=get_shop_cookies_list", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop&act=get_shop_token
|
||||
/// </summary>
|
||||
public HttpResult GetShopToken(string postdata = "")
|
||||
{
|
||||
return Post("shop&act=get_shop_token", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop&act=update_mall_id
|
||||
/// </summary>
|
||||
public HttpResult UpdateMallId(string postdata = "")
|
||||
{
|
||||
return Post("shop&act=update_mall_id", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/active_jit_card_code
|
||||
/// </summary>
|
||||
public HttpResult ActiveJitCardCode(string postdata = "")
|
||||
{
|
||||
return Post("shop/active_jit_card_code", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/add_mdy_express_optimize_remark
|
||||
/// </summary>
|
||||
public HttpResult AddMdyExpressOptimizeRemark(string postdata = "")
|
||||
{
|
||||
return Post("shop/add_mdy_express_optimize_remark", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/add_mdy_express_optimize_rst
|
||||
/// </summary>
|
||||
public HttpResult AddMdyExpressOptimizeRst(string postdata = "")
|
||||
{
|
||||
return Post("shop/add_mdy_express_optimize_rst", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/add_mdy_shop_client_info
|
||||
/// </summary>
|
||||
public HttpResult AddMdyShopClientInfo(string postdata = "")
|
||||
{
|
||||
return Post("shop/add_mdy_shop_client_info", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/add_shop
|
||||
/// </summary>
|
||||
public HttpResult AddShop(string postdata = "")
|
||||
{
|
||||
return Post("shop/add_shop", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/add_waybill
|
||||
/// </summary>
|
||||
public HttpResult AddWaybill(string postdata = "")
|
||||
{
|
||||
return Post("shop/add_waybill", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/admin_add_shop
|
||||
/// </summary>
|
||||
public HttpResult AdminAddShop(string postdata = "")
|
||||
{
|
||||
return Post("shop/admin_add_shop", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/admin_del_shop
|
||||
/// </summary>
|
||||
public HttpResult AdminDelShop(string postdata = "")
|
||||
{
|
||||
return Post("shop/admin_del_shop", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/admin_get_shop_list
|
||||
/// </summary>
|
||||
public HttpResult AdminGetShopList(string postdata = "")
|
||||
{
|
||||
return Post("shop/admin_get_shop_list", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/admin_mdy_shop
|
||||
/// </summary>
|
||||
public HttpResult AdminMdyShop(string postdata = "")
|
||||
{
|
||||
return Post("shop/admin_mdy_shop", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/create_shop_card_code
|
||||
/// </summary>
|
||||
public HttpResult CreateShopCardCode(string postdata = "")
|
||||
{
|
||||
return Post("shop/create_shop_card_code", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/del_shop
|
||||
/// </summary>
|
||||
public HttpResult DelShop(string postdata = "")
|
||||
{
|
||||
return Post("shop/del_shop", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/del_shop_card_code
|
||||
/// </summary>
|
||||
public HttpResult DelShopCardCode(string postdata = "")
|
||||
{
|
||||
return Post("shop/del_shop_card_code", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/del_waybill
|
||||
/// </summary>
|
||||
public HttpResult DelWaybill(string postdata = "")
|
||||
{
|
||||
return Post("shop/del_waybill", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/e57_get_wx_shop_token
|
||||
/// </summary>
|
||||
public HttpResult E57GetWxShopToken(string postdata = "")
|
||||
{
|
||||
return Post("shop/e57_get_wx_shop_token", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/e57_get_wx_tokens
|
||||
/// </summary>
|
||||
public HttpResult E57GetWxTokens(string postdata = "")
|
||||
{
|
||||
return Post("shop/e57_get_wx_tokens", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/get_express_optimize_remark
|
||||
/// </summary>
|
||||
public HttpResult GetExpressOptimizeRemark(string postdata = "")
|
||||
{
|
||||
return Post("shop/get_express_optimize_remark", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/get_express_optimize_rst
|
||||
/// </summary>
|
||||
public HttpResult GetExpressOptimizeRst(string postdata = "")
|
||||
{
|
||||
return Post("shop/get_express_optimize_rst", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/get_shop_card_code_list
|
||||
/// </summary>
|
||||
public HttpResult GetShopCardCodeList(string postdata = "")
|
||||
{
|
||||
return Post("shop/get_shop_card_code_list", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/get_shop_list
|
||||
/// </summary>
|
||||
public HttpResult GetShopList(string postdata = "")
|
||||
{
|
||||
return Post("shop/get_shop_list", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/get_waybill
|
||||
/// </summary>
|
||||
public HttpResult GetWaybill(string postdata = "")
|
||||
{
|
||||
return Post("shop/get_waybill", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/get_waybill_no_user_name
|
||||
/// </summary>
|
||||
public HttpResult GetWaybillNoUserName(string postdata = "")
|
||||
{
|
||||
return Post("shop/get_waybill_no_user_name", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/get_weidian_shop
|
||||
/// </summary>
|
||||
public HttpResult GetWeidianShop(string postdata = "")
|
||||
{
|
||||
return Post("shop/get_weidian_shop", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/mdy_anti_content
|
||||
/// </summary>
|
||||
public HttpResult MdyAntiContent(string postdata = "")
|
||||
{
|
||||
return Post("shop/mdy_anti_content", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/mdy_shop
|
||||
/// </summary>
|
||||
public HttpResult MdyShop(string postdata = "")
|
||||
{
|
||||
return Post("shop/mdy_shop", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/mdy_shop_ads_cookie_and_login_status
|
||||
/// </summary>
|
||||
public HttpResult MdyShopAdsCookieAndLoginStatus(string postdata = "")
|
||||
{
|
||||
return Post("shop/mdy_shop_ads_cookie_and_login_status", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/mdy_shop_cookie_and_login_status
|
||||
/// </summary>
|
||||
public HttpResult MdyShopCookieAndLoginStatus(string postdata = "")
|
||||
{
|
||||
return Post("shop/mdy_shop_cookie_and_login_status", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/select_waybill
|
||||
/// </summary>
|
||||
public HttpResult SelectWaybill(string postdata = "")
|
||||
{
|
||||
return Post("shop/select_waybill", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/set_shop_sub_sa
|
||||
/// </summary>
|
||||
public HttpResult SetShopSubSa(string postdata = "")
|
||||
{
|
||||
return Post("shop/set_shop_sub_sa", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/update_add_prod_remaining
|
||||
/// </summary>
|
||||
public HttpResult UpdateAddProdRemaining(string postdata = "")
|
||||
{
|
||||
return Post("shop/update_add_prod_remaining", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/update_used_waybill
|
||||
/// </summary>
|
||||
public HttpResult UpdateUsedWaybill(string postdata = "")
|
||||
{
|
||||
return Post("shop/update_used_waybill", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/wx_add_mdy_29wx_pdd_shop
|
||||
/// </summary>
|
||||
public HttpResult WxAddMdy29wxPddShop(string postdata = "")
|
||||
{
|
||||
return Post("shop/wx_add_mdy_29wx_pdd_shop", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/wx_add_mdy_buy_url_notes
|
||||
/// </summary>
|
||||
public HttpResult WxAddMdyBuyUrlNotes(string postdata = "")
|
||||
{
|
||||
return Post("shop/wx_add_mdy_buy_url_notes", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/wx_add_mdy_order_address
|
||||
/// </summary>
|
||||
public HttpResult WxAddMdyOrderAddress(string postdata = "")
|
||||
{
|
||||
return Post("shop/wx_add_mdy_order_address", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/wx_add_mdy_shop_default_address
|
||||
/// </summary>
|
||||
public HttpResult WxAddMdyShopDefaultAddress(string postdata = "")
|
||||
{
|
||||
return Post("shop/wx_add_mdy_shop_default_address", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/wx_del_shop_default_address
|
||||
/// </summary>
|
||||
public HttpResult WxDelShopDefaultAddress(string postdata = "")
|
||||
{
|
||||
return Post("shop/wx_del_shop_default_address", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/wx_get_29wx_pdd_shop
|
||||
/// </summary>
|
||||
public HttpResult WxGet29wxPddShop(string postdata = "")
|
||||
{
|
||||
return Post("shop/wx_get_29wx_pdd_shop", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/wx_get_buy_url_notes
|
||||
/// </summary>
|
||||
public HttpResult WxGetBuyUrlNotes(string postdata = "")
|
||||
{
|
||||
return Post("shop/wx_get_buy_url_notes", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/wx_get_order_address
|
||||
/// </summary>
|
||||
public HttpResult WxGetOrderAddress(string postdata = "")
|
||||
{
|
||||
return Post("shop/wx_get_order_address", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/wx_get_shop_default_address_list
|
||||
/// </summary>
|
||||
public HttpResult WxGetShopDefaultAddressList(string postdata = "")
|
||||
{
|
||||
return Post("shop/wx_get_shop_default_address_list", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/wx_mdy_29wx_pdd_cookie_and_login_status
|
||||
/// </summary>
|
||||
public HttpResult WxMdy29wxPddCookieAndLoginStatus(string postdata = "")
|
||||
{
|
||||
return Post("shop/wx_mdy_29wx_pdd_cookie_and_login_status", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// taobao_id&act=add
|
||||
/// </summary>
|
||||
public HttpResult AddTaobaoId(string postdata = "")
|
||||
{
|
||||
return Post("taobao_id&act=add", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// taobao_id&act=get
|
||||
/// </summary>
|
||||
public HttpResult GetTaobaoId(string postdata = "")
|
||||
{
|
||||
return Post("taobao_id&act=get", postdata);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 拼多多服务接口
|
||||
/// <summary>
|
||||
/// shop/add_vdian
|
||||
/// </summary>
|
||||
public HttpResult PddAddVdian(string postdata = "")
|
||||
{
|
||||
return PostPdd("shop/add_vdian", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/add_weidian_shop
|
||||
/// </summary>
|
||||
public HttpResult PddAddWeidianShop(string postdata = "")
|
||||
{
|
||||
return PostPdd("shop/add_weidian_shop", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/admin_get_shop_list
|
||||
/// </summary>
|
||||
public HttpResult PddAdminGetShopList(string postdata = "")
|
||||
{
|
||||
return PostPdd("shop/admin_get_shop_list", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/del_weidian_shop
|
||||
/// </summary>
|
||||
public HttpResult PddDelWeidianShop(string postdata = "")
|
||||
{
|
||||
return PostPdd("shop/del_weidian_shop", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/e57_get_pdd_shop_token
|
||||
/// </summary>
|
||||
public HttpResult PddE57GetPddShopToken(string postdata = "")
|
||||
{
|
||||
return PostPdd("shop/e57_get_pdd_shop_token", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/get_pdd_client_info
|
||||
/// </summary>
|
||||
public HttpResult PddGetPddClientInfo(string postdata = "")
|
||||
{
|
||||
return PostPdd("shop/get_pdd_client_info", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/get_shop_client_info
|
||||
/// </summary>
|
||||
public HttpResult PddGetShopClientInfo(string postdata = "")
|
||||
{
|
||||
return PostPdd("shop/get_shop_client_info", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/mdy_vdian
|
||||
/// </summary>
|
||||
public HttpResult PddMdyVdian(string postdata = "")
|
||||
{
|
||||
return PostPdd("shop/mdy_vdian", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/mdy_vdian_cookie
|
||||
/// </summary>
|
||||
public HttpResult PddMdyVdianCookie(string postdata = "")
|
||||
{
|
||||
return PostPdd("shop/mdy_vdian_cookie", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// shop/mdy_weidian_shop_cookie
|
||||
/// </summary>
|
||||
public HttpResult PddMdyWeidianShopCookie(string postdata = "")
|
||||
{
|
||||
return PostPdd("shop/mdy_weidian_shop_cookie", postdata);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,398 @@
|
||||
using MAX.Core.DependencyInjection;
|
||||
using MAX.Core.Extensions;
|
||||
using MAX.Core.Helpers;
|
||||
using Store.Client.Agent;
|
||||
using Store.Client.Commons;
|
||||
using Store.Client.Extensions;
|
||||
using Store.Client.HttpExtension;
|
||||
using Store.Framework;
|
||||
using Store.Framework.Tools;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Store.Client.Apis
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户操作Api
|
||||
/// 登录,注册
|
||||
/// </summary>
|
||||
public partial class UserApi : AppApiRequestBase, ITransientDependency
|
||||
{
|
||||
|
||||
public HttpResult Login(string username, string password)
|
||||
{
|
||||
_logger.Info("123");
|
||||
int r2 = RandomHelper.GetRandomNumber(100000000, 899999999); //生成随机码
|
||||
ServerHttpItem item = new ServerHttpItem();
|
||||
item.URL = base.BuildServiceUrl("user/user_login");
|
||||
item.Method = MethodType.Post;
|
||||
Dictionary<string, string> param = new Dictionary<string, string>
|
||||
{
|
||||
{ "mobile", username },
|
||||
{ "r2", r2.ToString() },
|
||||
{ "password", password },
|
||||
{ "hw_code", HardwareTool.HardWareCode },
|
||||
{ "hw_code_new", HardwareTool.HardWareCodeNew },
|
||||
{ "hw_code_v3", HardwareTool.HardWareCodeV3 },
|
||||
{ "agent_code", AgentConfig.AgentCode },
|
||||
{ "version",Config.Version}
|
||||
//,
|
||||
//{ "client_ip", _client.Ip },
|
||||
//{ "client_addr", _client.Address }
|
||||
};
|
||||
item.Postdata = param.ToUrlParams();
|
||||
item.Sign();
|
||||
HttpResult result = ServerRequest(item);
|
||||
if (result.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
string chCode = Regex.Match(result.Html, "<c>([^<]+)</c>")?.Groups[1]?.Value ?? "";
|
||||
if (!string.IsNullOrEmpty(chCode))
|
||||
{
|
||||
string codex = SignTool.Encryption(r2);
|
||||
if (chCode != codex)
|
||||
{
|
||||
result.StatusCode = HttpStatusCode.Unauthorized;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#region 默认服务接口
|
||||
/// <summary>
|
||||
/// user&act=add_user_lock
|
||||
/// </summary>
|
||||
public HttpResult AddUserLock(string postdata = "")
|
||||
{
|
||||
return Post("user&act=add_user_lock", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user/add_sub_user
|
||||
/// </summary>
|
||||
public HttpResult AddSubUser(string postdata = "")
|
||||
{
|
||||
return Post("user/add_sub_user", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user/add_user
|
||||
/// </summary>
|
||||
public HttpResult AddUser(string postdata = "")
|
||||
{
|
||||
return Post("user/add_user", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user/apply_oem_withdrawal
|
||||
/// </summary>
|
||||
public HttpResult ApplyOemWithdrawal(string postdata = "")
|
||||
{
|
||||
return Post("user/apply_oem_withdrawal", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user/delete_user
|
||||
/// </summary>
|
||||
public HttpResult DeleteUser(string postdata = "")
|
||||
{
|
||||
return Post("user/delete_user", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user/get_all_user
|
||||
/// </summary>
|
||||
public HttpResult GetAllUser(string postdata = "")
|
||||
{
|
||||
return Post("user/get_all_user", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user/get_package_sign
|
||||
/// </summary>
|
||||
public HttpResult GetPackageSign(string postdata = "")
|
||||
{
|
||||
return Post("user/get_package_sign", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user/get_sub_user
|
||||
/// </summary>
|
||||
public HttpResult GetSubUser(string postdata = "")
|
||||
{
|
||||
return Post("user/get_sub_user", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user/get_user_amount
|
||||
/// </summary>
|
||||
public HttpResult GetUserAmount(string postdata = "")
|
||||
{
|
||||
return Post("user/get_user_amount", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user/is_get_return_package
|
||||
/// </summary>
|
||||
public HttpResult IsGetReturnPackage(string postdata = "")
|
||||
{
|
||||
return Post("user/is_get_return_package", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user/oem_audit_withdrawal
|
||||
/// </summary>
|
||||
public HttpResult OemAuditWithdrawal(string postdata = "")
|
||||
{
|
||||
return Post("user/oem_audit_withdrawal", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user/oem_settle_flows
|
||||
/// </summary>
|
||||
public HttpResult OemSettleFlows(string postdata = "")
|
||||
{
|
||||
return Post("user/oem_settle_flows", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user/oem_withdrawals
|
||||
/// </summary>
|
||||
public HttpResult OemWithdrawals(string postdata = "")
|
||||
{
|
||||
return Post("user/oem_withdrawals", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user/update_sub_user
|
||||
/// </summary>
|
||||
public HttpResult UpdateSubUser(string postdata = "")
|
||||
{
|
||||
return Post("user/update_sub_user", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user/update_user
|
||||
/// </summary>
|
||||
public HttpResult UpdateUser(string postdata = "")
|
||||
{
|
||||
return Post("user/update_user", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user/update_user_balance
|
||||
/// </summary>
|
||||
public HttpResult UpdateUserBalance(string postdata = "")
|
||||
{
|
||||
return Post("user/update_user_balance", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user/update_user_points
|
||||
/// </summary>
|
||||
public HttpResult UpdateUserPoints(string postdata = "")
|
||||
{
|
||||
return Post("user/update_user_points", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user/user_login
|
||||
/// </summary>
|
||||
public HttpResult UserLogin(string postdata = "")
|
||||
{
|
||||
return PostPublic("user/user_login", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user_login_cookies&act=get
|
||||
/// </summary>
|
||||
public HttpResult GetUserLoginCookies(string postdata = "")
|
||||
{
|
||||
return Post("user_login_cookies&act=get", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user_login_cookies&act=insert
|
||||
/// </summary>
|
||||
public HttpResult InsertUserLoginCookies(string postdata = "")
|
||||
{
|
||||
return Post("user_login_cookies&act=insert", postdata);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 拼多多服务接口
|
||||
/// <summary>
|
||||
/// user/add_buyer
|
||||
/// </summary>
|
||||
public HttpResult PddAddBuyer(string postdata = "")
|
||||
{
|
||||
return PostPdd("user/add_buyer", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user/del_buyer
|
||||
/// </summary>
|
||||
public HttpResult PddDelBuyer(string postdata = "")
|
||||
{
|
||||
return PostPdd("user/del_buyer", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user/get_buyer
|
||||
/// </summary>
|
||||
public HttpResult PddGetBuyer(string postdata = "")
|
||||
{
|
||||
return PostPdd("user/get_buyer", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user/get_scm121_cookie
|
||||
/// </summary>
|
||||
public HttpResult PddGetScm121Cookie(string postdata = "")
|
||||
{
|
||||
return PostPdd("user/get_scm121_cookie", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user/mdy_buyer
|
||||
/// </summary>
|
||||
public HttpResult PddMdyBuyer(string postdata = "")
|
||||
{
|
||||
return PostPdd("user/mdy_buyer", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user/mdy_buyer_cookie
|
||||
/// </summary>
|
||||
public HttpResult PddMdyBuyerCookie(string postdata = "")
|
||||
{
|
||||
return PostPdd("user/mdy_buyer_cookie", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user/update_scm121_cookie
|
||||
/// </summary>
|
||||
public HttpResult PddUpdateScm121Cookie(string postdata = "")
|
||||
{
|
||||
return PostPdd("user/update_scm121_cookie", postdata);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 微信服务接口
|
||||
/// <summary>
|
||||
/// user/add_mdy_oem
|
||||
/// </summary>
|
||||
public HttpResult WxAddMdyOem(string postdata = "")
|
||||
{
|
||||
return PostWx("user/add_mdy_oem", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user/del_oem
|
||||
/// </summary>
|
||||
public HttpResult WxDelOem(string postdata = "")
|
||||
{
|
||||
return PostWx("user/del_oem", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user/get_all_user
|
||||
/// </summary>
|
||||
public HttpResult WxGetAllUser(string postdata = "")
|
||||
{
|
||||
return PostWx("user/get_all_user", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user/get_e57_authorization
|
||||
/// </summary>
|
||||
public HttpResult WxGetE57Authorization(string postdata = "")
|
||||
{
|
||||
return PostWx("user/get_e57_authorization", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user/get_oem
|
||||
/// </summary>
|
||||
public HttpResult WxGetOem(string postdata = "")
|
||||
{
|
||||
return PostWx("user/get_oem", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user/get_oem_config_info
|
||||
/// </summary>
|
||||
public HttpResult WxGetOemConfigInfo(string postdata = "")
|
||||
{
|
||||
return PostWx("user/get_oem_config_info", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user/get_oem_version
|
||||
/// </summary>
|
||||
public HttpResult WxGetOemVersion(string postdata = "")
|
||||
{
|
||||
return PostWx("user/get_oem_version", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user/get_top_up_qrcode
|
||||
/// </summary>
|
||||
public HttpResult WxGetTopUpQrcode(string postdata = "")
|
||||
{
|
||||
return PostWx("user/get_top_up_qrcode", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user/get_user_balance
|
||||
/// </summary>
|
||||
public HttpResult WxGetUserBalance(string postdata = "")
|
||||
{
|
||||
return PostWx("user/get_user_balance", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user/get_user_points
|
||||
/// </summary>
|
||||
public HttpResult WxGetUserPoints(string postdata = "")
|
||||
{
|
||||
return PostWx("user/get_user_points", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user/get_wx_sale_assistant_cookie
|
||||
/// </summary>
|
||||
public HttpResult WxGetWxSaleAssistantCookie(string postdata = "")
|
||||
{
|
||||
return PostWx("user/get_wx_sale_assistant_cookie", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user/update_top_up_qrcode
|
||||
/// </summary>
|
||||
public HttpResult WxUpdateTopUpQrcode(string postdata = "")
|
||||
{
|
||||
return PostWx("user/update_top_up_qrcode", postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// user/update_wx_sale_assistant_cookie
|
||||
/// </summary>
|
||||
public HttpResult WxUpdateWxSaleAssistantCookie(string postdata = "")
|
||||
{
|
||||
return PostWx("user/update_wx_sale_assistant_cookie", postdata);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
//using MAX.Core.Helpers;
|
||||
//using Polly;
|
||||
//using Store.Framework.HttpResultParser;
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using System.Text;
|
||||
//using System.Threading.Tasks;
|
||||
|
||||
//namespace Store.Framework.Attributes
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// Http请求请求失败重新尝试 HttpStatusCode 状态不为Ok一律重新尝试
|
||||
// /// </summary>
|
||||
// [AttributeUsage(AttributeTargets.Method)]
|
||||
// public class HttpTryAttribute : AbstractInterceptorAttribute
|
||||
// {
|
||||
// /// <summary>
|
||||
// /// 最大尝试次数
|
||||
// /// </summary>
|
||||
// public int MaxRetryTimes { get; set; } = 3;
|
||||
// /// <summary>
|
||||
// /// 重新尝试延迟时间毫秒
|
||||
// /// </summary>
|
||||
// public int RetryIntervalMilliseconds { get; set; } = 1000;
|
||||
// protected Type[] VerifyTypes { get; set; }
|
||||
// //public HttpTryAttribute()
|
||||
// //{
|
||||
|
||||
// //}
|
||||
|
||||
// public HttpTryAttribute(params Type[] verifyTypes)
|
||||
// {
|
||||
// VerifyTypes = (verifyTypes ?? new Type[0]);
|
||||
// }
|
||||
// public override Task Invoke(AspectContext context, AspectDelegate next)
|
||||
// {
|
||||
// var verify = HttpResultVerify.TryVerify(() =>
|
||||
// {
|
||||
// next(context).Wait();
|
||||
// return (HttpResult)context.ReturnValue;
|
||||
// }, MaxRetryTimes, RetryIntervalMilliseconds);
|
||||
// if (VerifyTypes != null && VerifyTypes.Count() > 0)
|
||||
// {
|
||||
// foreach (Type item in VerifyTypes)
|
||||
// {
|
||||
// if (typeof(IHttpResultVerify).IsAssignableFrom(item))
|
||||
// {
|
||||
// verify.UseCheckResult((IHttpResultVerify)Activator.CreateInstance(item));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// verify.Exec();
|
||||
// return Task.FromResult(0);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -0,0 +1,70 @@
|
||||
//using AspectCore.DynamicProxy;
|
||||
////using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using System.Reflection;
|
||||
//using System.Text;
|
||||
//using System.Threading;
|
||||
//using System.Threading.Tasks;
|
||||
|
||||
//namespace Store.Framework.Attributes
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// Aop延迟时间
|
||||
// /// </summary>
|
||||
// ///
|
||||
// public class SleepAttribute : AopInterceptorAttribute
|
||||
// {
|
||||
// /// <summary>
|
||||
// /// 毫秒
|
||||
// /// </summary>
|
||||
// public int Millisecond { get; set; }
|
||||
// /// <summary>
|
||||
// /// 间隔区间
|
||||
// /// </summary>
|
||||
// public Tuple<int, int> ExtentMillisecond { get; set; }
|
||||
// /// <summary>
|
||||
// /// 执行位置
|
||||
// /// </summary>
|
||||
// public ExecOrder Location { get; set; } = ExecOrder.Before;
|
||||
// public SleepAttribute(int millisecond)
|
||||
// {
|
||||
// Millisecond = millisecond;
|
||||
// }
|
||||
// public SleepAttribute(int StartMillisecond, int EndMillisecond)
|
||||
// {
|
||||
// ExtentMillisecond = new Tuple<int, int>(StartMillisecond, EndMillisecond);
|
||||
// }
|
||||
// public override void BeforeAction(AspectContext context)
|
||||
// {
|
||||
// if (Location == ExecOrder.Before)
|
||||
// Exec();
|
||||
// }
|
||||
|
||||
// public override void AfterAction(AspectContext context)
|
||||
// {
|
||||
// if (Location == ExecOrder.After)
|
||||
// Exec();
|
||||
// }
|
||||
|
||||
// private void Exec()
|
||||
// {
|
||||
// if (ExtentMillisecond != null)
|
||||
// {
|
||||
// Millisecond = new Random().Next(ExtentMillisecond.Item1, ExtentMillisecond.Item2);
|
||||
// }
|
||||
// Thread.Sleep(Millisecond);
|
||||
// }
|
||||
// public enum ExecOrder
|
||||
// {
|
||||
// /// <summary>
|
||||
// /// 方法执行前
|
||||
// /// </summary>
|
||||
// Before,
|
||||
// /// <summary>
|
||||
// /// 方法执行后
|
||||
// /// </summary>
|
||||
// After
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -0,0 +1,46 @@
|
||||
using MAX.Core.Infrastructure;
|
||||
using Store.Framework.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Store.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// 客户端信息
|
||||
/// </summary>
|
||||
public class ClientInfo : SingleInstance<ClientInfo>
|
||||
{
|
||||
|
||||
public static UserInfo User
|
||||
{
|
||||
get
|
||||
{
|
||||
return Instance.UserInfo;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private ClientInfo()
|
||||
{
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 客户端IP
|
||||
/// </summary>
|
||||
public string Ip { get; }
|
||||
/// <summary>
|
||||
/// 客户端地址
|
||||
/// </summary>
|
||||
public string Address { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前登录用户
|
||||
/// </summary>
|
||||
public UserInfo UserInfo { get; private set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Store.Client.Commons
|
||||
{
|
||||
///// <summary>
|
||||
///// 商铺列表信息管理
|
||||
///// </summary>
|
||||
//public abstract class ShopManage<T> : ISingletonDependency, ILoginSuccessed where T : ShopBase
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// 日志
|
||||
// /// </summary>
|
||||
// [Autowired]
|
||||
// protected ILog _log { get; set; }
|
||||
// [Autowired]
|
||||
// internal ShopService _shopService { get; set; }
|
||||
// /// <summary>
|
||||
// /// 私有商铺集合
|
||||
// /// </summary>
|
||||
// private List<T> _shopsData = new List<T>();
|
||||
// /// <summary>
|
||||
// /// 私有商铺分组
|
||||
// /// </summary>
|
||||
// /// <returns></returns>
|
||||
// private List<string> _shopGroups = new List<string>();
|
||||
|
||||
// /// <summary>
|
||||
// /// 所有商铺
|
||||
// /// </summary>
|
||||
// public List<T> Shops
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// return _shopsData;
|
||||
// }
|
||||
// }
|
||||
// /// <summary>
|
||||
// /// 商铺分组
|
||||
// /// </summary>
|
||||
// public List<string> ShopGroups
|
||||
// {
|
||||
// get => _shopGroups;
|
||||
// }
|
||||
// /// <summary>
|
||||
// /// 获取随机Cookie
|
||||
// /// </summary>
|
||||
// /// <returns></returns>
|
||||
// public Cookies GetRandomCookies()
|
||||
// {
|
||||
// return Shops[RandomHelper.GetRandomNumber(Shops.Count - 1)].Cookie;
|
||||
// }
|
||||
|
||||
|
||||
// /// <summary>
|
||||
// /// 刷新
|
||||
// /// </summary>
|
||||
// public void Refresh()
|
||||
// {
|
||||
// LoadServerShops();
|
||||
// }
|
||||
|
||||
// void ILoginSuccessed.LoginSuccess(UserInfo user)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// LoadServerShops();
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// _log.Error(ex, "加载商铺列表");
|
||||
// }
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// 加载服务器商铺
|
||||
// /// </summary>
|
||||
// private void LoadServerShops()
|
||||
// {
|
||||
// _shopsData = _shopService.GetShops<T>();
|
||||
// _getshopGroup();
|
||||
// RefreshShopsCookie();
|
||||
// }
|
||||
|
||||
// private void RefreshShopsCookie()
|
||||
// {
|
||||
// var shops = Shops.Select(a => a as ShopBase).ToList();
|
||||
// _shopService.GetShopCookie(shops);
|
||||
// }
|
||||
// /// <summary>
|
||||
// /// 检测商铺登录状态
|
||||
// /// </summary>
|
||||
// public abstract void CheckShopStatus(T shop);
|
||||
// //{
|
||||
// // //string urlx = "https://myseller.taobao.com/ajaxProxy.do?_ksTS=1548152154745_13&callback=seller_layout_head&action=FrameworkLayoutAction&event_submit_do_layout_data=true";
|
||||
// // //string refere = "https://myseller.taobao.com";
|
||||
// // //string htmlx = GetPostTaobaoHtml.GetUrl(urlx, refere, true, "", Shop.Cookies);
|
||||
// // //Shop.MsgForCookiesLogin = htmlx.Contains("\"shopName\":\"") ? "登录成功" : "会话已过期";
|
||||
// // //GetTaobaoShops.ShopsTemp.Add(Shop);
|
||||
// //}
|
||||
|
||||
|
||||
// /// <summary>
|
||||
// /// 商铺分组
|
||||
// /// </summary>
|
||||
// private void _getshopGroup()
|
||||
// {
|
||||
// _shopGroups.Clear();
|
||||
// List<string> list = (from a in _shopsData group a by a.GroupName into b select b.Key).ToList();
|
||||
// foreach (var item in list)
|
||||
// {
|
||||
// _shopGroups.Add(item);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
//}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
using MAX.Core.Cryptography;
|
||||
using MAX.Core.Helpers;
|
||||
using Store.Client;
|
||||
using Store.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Store.Client.Commons
|
||||
{
|
||||
/// <summary>
|
||||
/// 签名工具
|
||||
/// </summary>
|
||||
public class SignTool
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取签名
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string GetSign()
|
||||
{
|
||||
long time = GetReviseUnix();
|
||||
string s = Encryption(time);
|
||||
return "time=" + time + "&code=" + s + "&NbCodeVersion=1";
|
||||
}
|
||||
/// <summary>
|
||||
/// 用户签名
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string GetUserSign()
|
||||
{
|
||||
return GetUserSign("", "");
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取当前用户签名
|
||||
/// </summary>
|
||||
/// <param name="shopId"></param>
|
||||
/// <param name="shopName"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetUserSign(string shopId, string shopName)
|
||||
{
|
||||
long time = GetReviseUnix();
|
||||
string time1 = Encryption(time);
|
||||
return "time=" + time + "&code=" + time1 + "&NbCodeVersion=1" + "&uid=" + ClientInfo.User.UserId + "&key=" + ClientInfo.User.UserKey +
|
||||
"&cid=" + ClientInfo.User.CompanyId + "&company=" + UrlHelper.Encode(ClientInfo.User.CompanyName) +
|
||||
"&sid=" + shopId + "&shop=" + UrlHelper.Encode(shopName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取校正后的时间戳
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static long GetReviseUnix()
|
||||
{
|
||||
return DateHelper.GetCurrentUnixTimestampInSeconds() + ServerConfig.TimeDifferent;
|
||||
}
|
||||
/// <summary>
|
||||
/// 签名算法
|
||||
/// </summary>
|
||||
/// <param name="s">随机数</param>
|
||||
/// <returns>加密签名结果</returns>
|
||||
public static string Encryption(long s)
|
||||
{
|
||||
string value = $"{s}sdhewu*/fhAAue48485ew5+5%@3485esGFFHFD";
|
||||
return MD5Helper.Md5_32(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
using MAX.Framework.Helpers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Store.Framework;
|
||||
|
||||
public static class Config
|
||||
{
|
||||
public const string AppVersion = "1312";
|
||||
|
||||
public static bool IsRelease
|
||||
{
|
||||
get
|
||||
{
|
||||
#if RELEASE
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
public static Guid SessionID { get; }
|
||||
public static DateTime AppStartTime { get; }
|
||||
public static string Version => AppVersion;
|
||||
static Config()
|
||||
{
|
||||
SessionID = Guid.NewGuid();
|
||||
AppStartTime = DateTime.Now;
|
||||
|
||||
//FileVersionInfo info = FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly().Location);
|
||||
//Version = new VersionStruct(info.FileMajorPart, info.ProductMinorPart, info.FileBuildPart, info.FilePrivatePart);
|
||||
|
||||
}
|
||||
public static string GetFullVersionString()
|
||||
{
|
||||
static IEnumerable<string> GetStrings()
|
||||
{
|
||||
yield return Version.ToString();
|
||||
yield return IsRelease ? "Release" : "Debug";
|
||||
if (SystemHelper.IsAdministratorSafe)
|
||||
{
|
||||
yield return "管理员权限";
|
||||
}
|
||||
}
|
||||
return string.Join(" - ", GetStrings());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Store.Framework.Configs
|
||||
{
|
||||
/// <summary>
|
||||
/// 全局配置
|
||||
/// </summary>
|
||||
public class GlobalConfig
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// app启动路径
|
||||
/// </summary>
|
||||
public static string AppDirectory
|
||||
{
|
||||
get
|
||||
{
|
||||
return AppDomain.CurrentDomain.BaseDirectory;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
|
||||
namespace Store.Client
|
||||
{
|
||||
public interface IApiServerConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// 服务器地址
|
||||
/// </summary>
|
||||
string Host { get; }
|
||||
/// <summary>
|
||||
/// 项目地址
|
||||
/// </summary>
|
||||
string ObjUrl { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
//namespace Store.Client
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// 根据 DI 注册 Key 获取服务配置。
|
||||
// /// Keyed DI 配置作为初始值,登录后获取到的服务地址可以覆盖初始值。
|
||||
// /// </summary>
|
||||
// public interface IServiceConfigProvider
|
||||
// {
|
||||
// /// <summary>
|
||||
// /// 获取指定 Key 的服务配置。
|
||||
// /// </summary>
|
||||
// IServerConfig Get(string key);
|
||||
|
||||
// /// <summary>
|
||||
// /// 尝试获取指定 Key 的服务配置。
|
||||
// /// </summary>
|
||||
// bool TryGet(string key, out IServerConfig config);
|
||||
|
||||
// /// <summary>
|
||||
// /// 设置或覆盖指定 Key 的完整服务配置。
|
||||
// /// </summary>
|
||||
// void Set(string key, IServerConfig config);
|
||||
|
||||
// /// <summary>
|
||||
// /// 设置或覆盖指定 Key 的服务配置。
|
||||
// /// </summary>
|
||||
// void Set(string key, string host, string objUrl);
|
||||
|
||||
// /// <summary>
|
||||
// /// 只更新指定 Key 的 Host,保留原有 ObjUrl。
|
||||
// /// </summary>
|
||||
// void SetHost(string key, string host);
|
||||
|
||||
// /// <summary>
|
||||
// /// 删除运行时覆盖配置。删除后会回退到 Keyed DI 初始配置。
|
||||
// /// </summary>
|
||||
// bool Remove(string key);
|
||||
// }
|
||||
//}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Store.Client
|
||||
{
|
||||
internal class ServerConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// 服务器时间差
|
||||
/// </summary>
|
||||
public static long TimeDifferent { get; internal set; }
|
||||
/// <summary>
|
||||
/// 是否使用新签名算法
|
||||
/// </summary>
|
||||
public static bool IsNewSignatureAuth { get; internal set; } = true;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace Store.Client
|
||||
{
|
||||
/// <summary>
|
||||
/// 服务配置默认 Key。
|
||||
/// </summary>
|
||||
public static class ServiceConfigKeys
|
||||
{
|
||||
/// <summary>
|
||||
/// 基础 Store API 使用的默认配置 Key。
|
||||
/// </summary>
|
||||
public const string Default = "Default";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
//using Autofac.Core.Registration;
|
||||
//using Autofac.Features.Indexed;
|
||||
//using MAX.Core.DependencyInjection;
|
||||
//using MAX.Core.Infrastructure;
|
||||
//using System;
|
||||
//using System.Collections.Concurrent;
|
||||
//using System.Collections.Generic;
|
||||
|
||||
//namespace Store.Client
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// 从 Autofac Keyed Service 中获取服务配置。
|
||||
// /// 登录后服务端下发的新地址会保存在运行时配置中,并优先于 Keyed DI 初始配置。
|
||||
// /// </summary>
|
||||
// public sealed class ServiceConfigProvider : IServiceConfigProvider, ISingletonDependency
|
||||
// {
|
||||
// private readonly IIndex<string, IApiServerConfig> _configs;
|
||||
// private readonly ConcurrentDictionary<string, IApiServerConfig> _runtimeConfigs = new ConcurrentDictionary<string, IApiServerConfig>();
|
||||
|
||||
// public ServiceConfigProvider(IIndex<string, IApiServerConfig> configs)
|
||||
// {
|
||||
// _configs = configs ?? throw new ArgumentNullException(nameof(configs));
|
||||
// }
|
||||
|
||||
// public IApiServerConfig Get(string key)
|
||||
// {
|
||||
// if (TryGet(key, out IApiServerConfig config))
|
||||
// {
|
||||
// return config;
|
||||
// }
|
||||
|
||||
// throw new InvalidOperationException($"未注册 Key 为“{key}”的 IApiServerConfig。");
|
||||
// }
|
||||
|
||||
// public bool TryGet(string key, out IApiServerConfig config)
|
||||
// {
|
||||
// config = null;
|
||||
// if (string.IsNullOrWhiteSpace(key))
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// if (_runtimeConfigs.TryGetValue(key, out config))
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// try
|
||||
// {
|
||||
// config = _configs[key];
|
||||
// return config != null;
|
||||
// }
|
||||
// catch (KeyNotFoundException)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
// catch (ComponentNotRegisteredException)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
|
||||
// public void Set(string key, IApiServerConfig config)
|
||||
// {
|
||||
// if (string.IsNullOrWhiteSpace(key))
|
||||
// {
|
||||
// throw new ArgumentException("服务配置 Key 不能为空。", nameof(key));
|
||||
// }
|
||||
// if (config == null)
|
||||
// {
|
||||
// throw new ArgumentNullException(nameof(config));
|
||||
// }
|
||||
|
||||
// _runtimeConfigs[key] = config;
|
||||
// }
|
||||
|
||||
// public void Set(string key, string host, string objUrl)
|
||||
// {
|
||||
// Set(key, new ServiceConfig(host, objUrl));
|
||||
// }
|
||||
|
||||
// public void SetHost(string key, string host)
|
||||
// {
|
||||
// string objUrl = TryGet(key, out IApiServerConfig config)
|
||||
// ? config.ObjUrl
|
||||
// : string.Empty;
|
||||
// Set(key, new ServiceConfig(host, objUrl));
|
||||
// }
|
||||
|
||||
// public bool Remove(string key)
|
||||
// {
|
||||
// return !string.IsNullOrWhiteSpace(key) && _runtimeConfigs.TryRemove(key, out _);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -0,0 +1,41 @@
|
||||
//using Autofac;
|
||||
//using System;
|
||||
|
||||
//namespace Store.Client
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// IServerConfig 的 Keyed DI 注册扩展。
|
||||
// /// </summary>
|
||||
// public static class ServiceConfigRegistrationExtensions
|
||||
// {
|
||||
// /// <summary>
|
||||
// /// 注册指定 Key 的服务配置。
|
||||
// /// </summary>
|
||||
// public static ContainerBuilder RegisterServiceConfig(this ContainerBuilder builder, string key, IServerConfig config)
|
||||
// {
|
||||
// if (builder == null)
|
||||
// {
|
||||
// throw new ArgumentNullException(nameof(builder));
|
||||
// }
|
||||
// if (string.IsNullOrWhiteSpace(key))
|
||||
// {
|
||||
// throw new ArgumentException("服务配置 Key 不能为空。", nameof(key));
|
||||
// }
|
||||
// if (config == null)
|
||||
// {
|
||||
// throw new ArgumentNullException(nameof(config));
|
||||
// }
|
||||
|
||||
// builder.RegisterInstance(config).Keyed<IServerConfig>(key);
|
||||
// return builder;
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// 注册指定 Key 的服务配置。
|
||||
// /// </summary>
|
||||
// public static ContainerBuilder RegisterServiceConfig(this ContainerBuilder builder, string key, string host, string objUrl)
|
||||
// {
|
||||
// return builder.RegisterServiceConfig(key, new ServiceConfig(host, objUrl));
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Store.Framework.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// 平台类型
|
||||
/// </summary>
|
||||
public enum PlatformType
|
||||
{
|
||||
/// <summary>
|
||||
/// 未知
|
||||
/// </summary>
|
||||
[Description("未知")]
|
||||
None = 0,
|
||||
/// <summary>
|
||||
/// 多多
|
||||
/// </summary>
|
||||
[Description("多多")]
|
||||
PDD = 1,
|
||||
/// <summary>
|
||||
/// 微信
|
||||
/// </summary>
|
||||
[Description("微信")]
|
||||
WX = 2,
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using MAX.Core.Cryptography;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Store.Framework.Extensions
|
||||
{
|
||||
public static class DictionaryExtension
|
||||
{
|
||||
/// <summary>
|
||||
/// 字典转url Get 参数
|
||||
/// </summary>
|
||||
/// <param name="parameters"></param>
|
||||
/// <returns></returns>
|
||||
public static string ToUrlParams(this IDictionary<string, string> parameters, bool IsUrlEncode = true)
|
||||
{
|
||||
IDictionary<string, string> sortedParams = new SortedDictionary<string, string>(parameters);
|
||||
IEnumerator<KeyValuePair<string, string>> dem = sortedParams.GetEnumerator();
|
||||
StringBuilder sb = new StringBuilder("");
|
||||
while (dem.MoveNext())
|
||||
{
|
||||
string key = dem.Current.Key;
|
||||
string value = dem.Current.Value;
|
||||
if (!string.IsNullOrEmpty(key))
|
||||
{
|
||||
sb.Append(key).Append("=").Append(IsUrlEncode ? UrlHelper.Encode(value) : value).Append("&");
|
||||
|
||||
}
|
||||
}
|
||||
string content = sb.ToString().Substring(0, sb.Length - 1);
|
||||
|
||||
return content;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,560 @@
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Web;
|
||||
|
||||
namespace Store.Framework.Extensions;
|
||||
|
||||
|
||||
public static class Extensions
|
||||
{
|
||||
public static long ParseToLong(this object obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
string text = ParseToString(obj);
|
||||
if (string.IsNullOrEmpty(text))
|
||||
{
|
||||
return 0L;
|
||||
}
|
||||
return long.Parse(text);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return 0L;
|
||||
}
|
||||
}
|
||||
|
||||
public static long ParseToLong(this string str, long defaultValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
return long.Parse(str);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
public static int ParseToInt(this object str)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Convert.ToInt32(str);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static int DecimalPointParseToInt(this object str)
|
||||
{
|
||||
try
|
||||
{
|
||||
string text = ParseToString(str);
|
||||
int num = text.IndexOf('.');
|
||||
if (num > 0)
|
||||
{
|
||||
text = text.Substring(0, num);
|
||||
}
|
||||
return Convert.ToInt32(text);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static int ParseToInt(this object str, int defaultValue)
|
||||
{
|
||||
if (str == null)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
try
|
||||
{
|
||||
return Convert.ToInt32(str);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
public static short ParseToShort(this object obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
return short.Parse(obj.ToString());
|
||||
}
|
||||
catch
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static short ParseToShort(this object str, short defaultValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
return short.Parse(str.ToString());
|
||||
}
|
||||
catch
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
public static decimal ParseToDecimal(this object str, decimal defaultValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
return decimal.Parse(str.ToString());
|
||||
}
|
||||
catch
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
public static decimal ParseToDecimal(this object str)
|
||||
{
|
||||
try
|
||||
{
|
||||
return decimal.Parse(str.ToString());
|
||||
}
|
||||
catch
|
||||
{
|
||||
return 0m;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool ParseToBool(this object str)
|
||||
{
|
||||
try
|
||||
{
|
||||
return bool.Parse(str.ToString());
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool ParseToBool(this object str, bool result)
|
||||
{
|
||||
try
|
||||
{
|
||||
return bool.Parse(str.ToString());
|
||||
}
|
||||
catch
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public static float ParseToFloat(this object str)
|
||||
{
|
||||
try
|
||||
{
|
||||
return float.Parse(str.ToString());
|
||||
}
|
||||
catch
|
||||
{
|
||||
return 0f;
|
||||
}
|
||||
}
|
||||
|
||||
public static float ParseToFloat(this object str, float result)
|
||||
{
|
||||
try
|
||||
{
|
||||
return float.Parse(str.ToString());
|
||||
}
|
||||
catch
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public static Guid ParseToGuid(this string str)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new Guid(str);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return Guid.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public static DateTime ParseToDateTime(this string str)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(str))
|
||||
{
|
||||
return DateTime.MinValue;
|
||||
}
|
||||
if (str.Contains("-") || str.Contains("/"))
|
||||
{
|
||||
return DateTime.Parse(str);
|
||||
}
|
||||
return str.Length switch
|
||||
{
|
||||
4 => DateTime.ParseExact(str, "yyyy", CultureInfo.CurrentCulture),
|
||||
6 => DateTime.ParseExact(str, "yyyyMM", CultureInfo.CurrentCulture),
|
||||
8 => DateTime.ParseExact(str, "yyyyMMdd", CultureInfo.CurrentCulture),
|
||||
10 => DateTime.ParseExact(str, "yyyyMMddHH", CultureInfo.CurrentCulture),
|
||||
12 => DateTime.ParseExact(str, "yyyyMMddHHmm", CultureInfo.CurrentCulture),
|
||||
14 => DateTime.ParseExact(str, "yyyyMMddHHmmss", CultureInfo.CurrentCulture),
|
||||
_ => DateTime.ParseExact(str, "yyyyMMddHHmmss", CultureInfo.CurrentCulture),
|
||||
};
|
||||
}
|
||||
catch
|
||||
{
|
||||
return DateTime.MinValue;
|
||||
}
|
||||
}
|
||||
|
||||
public static DateTime ParseToDateTime(this string str, DateTime? defaultValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(str))
|
||||
{
|
||||
return defaultValue.GetValueOrDefault();
|
||||
}
|
||||
if (str.Contains("-") || str.Contains("/"))
|
||||
{
|
||||
return DateTime.Parse(str);
|
||||
}
|
||||
return str.Length switch
|
||||
{
|
||||
4 => DateTime.ParseExact(str, "yyyy", CultureInfo.CurrentCulture),
|
||||
6 => DateTime.ParseExact(str, "yyyyMM", CultureInfo.CurrentCulture),
|
||||
8 => DateTime.ParseExact(str, "yyyyMMdd", CultureInfo.CurrentCulture),
|
||||
10 => DateTime.ParseExact(str, "yyyyMMddHH", CultureInfo.CurrentCulture),
|
||||
12 => DateTime.ParseExact(str, "yyyyMMddHHmm", CultureInfo.CurrentCulture),
|
||||
14 => DateTime.ParseExact(str, "yyyyMMddHHmmss", CultureInfo.CurrentCulture),
|
||||
_ => DateTime.ParseExact(str, "yyyyMMddHHmmss", CultureInfo.CurrentCulture),
|
||||
};
|
||||
}
|
||||
catch
|
||||
{
|
||||
return defaultValue.GetValueOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
public static string ParseToString(this object obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
return obj.ToString();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public static string ParseToStrings<T>(this object obj, string split = ",")
|
||||
{
|
||||
try
|
||||
{
|
||||
if (obj is IEnumerable<T> values)
|
||||
{
|
||||
return string.Join(split, values);
|
||||
}
|
||||
return obj.ToString();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public static double ParseToDouble(this object obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
return double.Parse(obj.ToString());
|
||||
}
|
||||
catch
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
public static double ParseToDouble(this object str, double defaultValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
return double.Parse(str.ToString());
|
||||
}
|
||||
catch
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
public static T[] SplitToArray<T>(this string value, string split = ",")
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return CastSuper<T>(value.Split(new string[1] { split }, StringSplitOptions.RemoveEmptyEntries)).ToArray();
|
||||
}
|
||||
|
||||
public static T[] SplitToArray<T>(this string value, string[] split)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return CastSuper<T>(value.Split(split, StringSplitOptions.RemoveEmptyEntries)).ToArray();
|
||||
}
|
||||
|
||||
public static List<T> SplitToList<T>(this string value, string split = ",")
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
return new List<T>();
|
||||
}
|
||||
return CastSuper<T>(value.Split(new string[1] { split }, StringSplitOptions.RemoveEmptyEntries)).ToList();
|
||||
}
|
||||
|
||||
public static List<T> SplitToList<T>(this string value, string[] split)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
return new List<T>();
|
||||
}
|
||||
return CastSuper<T>(value.Split(split, StringSplitOptions.RemoveEmptyEntries)).ToList();
|
||||
}
|
||||
|
||||
public static IEnumerable<TResult> CastSuper<TResult>(this IEnumerable source)
|
||||
{
|
||||
foreach (object item in source)
|
||||
{
|
||||
yield return (TResult)Convert.ChangeType(item, typeof(TResult));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static Dictionary<int, string> EnumToDictionary(this Type enumType)
|
||||
{
|
||||
Dictionary<int, string> dictionary = new Dictionary<int, string>();
|
||||
Type typeFromHandle = typeof(DescriptionAttribute);
|
||||
FieldInfo[] fields = enumType.GetFields();
|
||||
int num = 0;
|
||||
string empty = string.Empty;
|
||||
FieldInfo[] array = fields;
|
||||
foreach (FieldInfo fieldInfo in array)
|
||||
{
|
||||
if (fieldInfo.FieldType.IsEnum)
|
||||
{
|
||||
num = (int)enumType.InvokeMember(fieldInfo.Name, BindingFlags.GetField, null, null, null);
|
||||
object[] customAttributes = fieldInfo.GetCustomAttributes(typeFromHandle, inherit: true);
|
||||
if (customAttributes.Length != 0)
|
||||
{
|
||||
DescriptionAttribute descriptionAttribute = (DescriptionAttribute)customAttributes[0];
|
||||
empty = descriptionAttribute.Description;
|
||||
}
|
||||
else
|
||||
{
|
||||
empty = fieldInfo.Name;
|
||||
}
|
||||
dictionary.Add(num, empty);
|
||||
}
|
||||
}
|
||||
return dictionary.OrderBy((KeyValuePair<int, string> p) => p.Key).ToDictionary((KeyValuePair<int, string> p) => p.Key, (KeyValuePair<int, string> p) => p.Value);
|
||||
}
|
||||
|
||||
public static string GetDescription(this Enum enumType)
|
||||
{
|
||||
FieldInfo field = enumType.GetType().GetField(enumType.ToString());
|
||||
if (field != null)
|
||||
{
|
||||
DescriptionAttribute[] array = (DescriptionAttribute[])field.GetCustomAttributes(typeof(DescriptionAttribute), inherit: false);
|
||||
if (array.Length != 0)
|
||||
{
|
||||
return array[0].Description;
|
||||
}
|
||||
}
|
||||
return enumType.ToString();
|
||||
}
|
||||
|
||||
public static string GetDescriptionByEnum<T>(this object obj)
|
||||
{
|
||||
Enum enumType = Enum.Parse(typeof(T), ParseToString(obj)) as Enum;
|
||||
return GetDescription(enumType);
|
||||
}
|
||||
|
||||
public static int GetEnumValueByDescription<T>(this string description)
|
||||
{
|
||||
Dictionary<int, string> source = EnumToDictionary(typeof(T));
|
||||
return (from p in source
|
||||
where p.Value == description
|
||||
select p.Key).FirstOrDefault();
|
||||
}
|
||||
|
||||
public static int GetEnumValueByName<T>(this string name)
|
||||
{
|
||||
return (int)Enum.Parse(typeof(T), name);
|
||||
}
|
||||
|
||||
public static object GetEnumNameByValue<T>(this int value)
|
||||
{
|
||||
return Enum.ToObject(typeof(T), value);
|
||||
}
|
||||
|
||||
public static Exception GetOriginalException(this Exception ex)
|
||||
{
|
||||
if (ex.InnerException == null)
|
||||
{
|
||||
return ex;
|
||||
}
|
||||
return GetOriginalException(ex.InnerException);
|
||||
}
|
||||
|
||||
public static bool IsNullOrEmpty(this object value)
|
||||
{
|
||||
if (value != null && !string.IsNullOrEmpty(ParseToString(value)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool IsNullOrZero(this object value)
|
||||
{
|
||||
if (value == null || string.IsNullOrEmpty(ParseToString(value)) || ParseToString(value).Trim() == "0")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool IsNumericType(this object value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
TypeCode typeCode = Type.GetTypeCode(value.GetType());
|
||||
TypeCode typeCode2 = typeCode;
|
||||
if ((uint)(typeCode2 - 5) <= 10u)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool IsStringType(this object value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
TypeCode typeCode = Type.GetTypeCode(value.GetType());
|
||||
TypeCode typeCode2 = typeCode;
|
||||
if (typeCode2 == TypeCode.String)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool IsNumber(this string value)
|
||||
{
|
||||
return RegexHelper.IsNumber(value);
|
||||
}
|
||||
|
||||
public static bool IsAlphabet(this string value)
|
||||
{
|
||||
return RegexHelper.IsAlphabet(value);
|
||||
}
|
||||
|
||||
public static bool IsAlphabetOrNumber(this string value)
|
||||
{
|
||||
return RegexHelper.IsAlphabetOrNumber(value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
public class RegexHelper
|
||||
{
|
||||
public static MatchCollection GetMatchCollection(string html, string regex)
|
||||
{
|
||||
if (string.IsNullOrEmpty(html))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return Regex.Matches(html, regex, RegexOptions.IgnoreCase);
|
||||
}
|
||||
|
||||
public static string GetMatch(string html, string regex, int index = 0)
|
||||
{
|
||||
if (string.IsNullOrEmpty(html))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
MatchCollection matchCollection = Regex.Matches(html, regex, RegexOptions.IgnoreCase);
|
||||
if (matchCollection.Count > 0)
|
||||
{
|
||||
return matchCollection[index].Groups[1].Value.ToString();
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public static string GetMatchWithSingleLine(string html, string regex)
|
||||
{
|
||||
if (string.IsNullOrEmpty(html))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
MatchCollection matchCollection = Regex.Matches(html, regex, RegexOptions.IgnoreCase | RegexOptions.Singleline);
|
||||
if (matchCollection.Count > 0)
|
||||
{
|
||||
return matchCollection[0].Groups[1].ToString();
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public static bool IsNumber(string str)
|
||||
{
|
||||
Regex regex = new Regex("^[0-9\\.]+$");
|
||||
return regex.IsMatch(str);
|
||||
}
|
||||
|
||||
public static bool IsAlphabet(string str)
|
||||
{
|
||||
Regex regex = new Regex("^[A-Za-z]+$");
|
||||
return regex.IsMatch(str);
|
||||
}
|
||||
|
||||
public static bool IsAlphabetOrNumber(string str)
|
||||
{
|
||||
Regex regex = new Regex("^[A-Za-z0-9]+$");
|
||||
return regex.IsMatch(str);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
using MAX.Core.Helpers;
|
||||
using Store.Client.Commons;
|
||||
using Store.Client.HttpExtension;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Store.Client.Extensions
|
||||
{
|
||||
/// <summary>
|
||||
/// 请求扩展
|
||||
/// </summary>
|
||||
public static class HttpItemExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// 增加签名
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
public static void Sign(this ServerHttpItem item)
|
||||
{
|
||||
SetSign(item, SignTool.GetSign());
|
||||
}
|
||||
/// <summary>
|
||||
/// 增加用户签名
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
public static void SignUser(this ServerHttpItem item)
|
||||
{
|
||||
item.SignUser("", "");
|
||||
}
|
||||
/// <summary>
|
||||
/// 增加用户签名
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="shopId"></param>
|
||||
/// <param name="shopName"></param>
|
||||
public static void SignUser(this ServerHttpItem item, string shopId, string shopName)
|
||||
{
|
||||
SetSign(item, SignTool.GetUserSign(shopId, shopName));
|
||||
}
|
||||
private static void SetSign(ServerHttpItem item, string sign)
|
||||
{
|
||||
if (item.Method == MethodType.Get)
|
||||
{
|
||||
if (item.URL.Contains("?"))
|
||||
{
|
||||
item.URL += "&";
|
||||
}
|
||||
else
|
||||
{
|
||||
item.URL += "?";
|
||||
}
|
||||
item.URL += sign;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (item.Postdata.Length > 0)
|
||||
{
|
||||
item.Postdata += "&";
|
||||
}
|
||||
item.Postdata += sign;
|
||||
}
|
||||
item.IsSign = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
//using Autofac;
|
||||
////////////////using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using System.Text;
|
||||
//using System.Threading.Tasks;
|
||||
|
||||
//namespace LittleCow.Framework.Extensions
|
||||
//{
|
||||
//public static class InitialDataMiddlewareExtensions
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// 加载所有初始化信息
|
||||
// /// </summary>
|
||||
// /// <param name="engine"></param>
|
||||
// /// <returns></returns>
|
||||
// public static LittleBootstrap UseInitData(this LittleBootstrap engine)
|
||||
// {
|
||||
// engine.UseMiddleware<InitialDataMiddleware>();
|
||||
// return engine;
|
||||
// }
|
||||
//}
|
||||
//public class InitialDataMiddleware : IEngine, ILoginSuccessed
|
||||
//{
|
||||
// private IInitialLoading[] listInit = new IInitialLoading[0];
|
||||
// public void Build()
|
||||
// {
|
||||
// listInit = IocManager.ResolveAll<IInitialLoading>();
|
||||
// listInit = listInit.OrderBy(a => a.Order).ToArray();
|
||||
// foreach (IInitialLoading item in listInit)
|
||||
// {
|
||||
// item.AppInit();
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
// public void Use()
|
||||
// {
|
||||
|
||||
// }
|
||||
|
||||
// void ILoginSuccessed.LoginSuccess(UserInfo user)
|
||||
// {
|
||||
// foreach (IInitialLoading item in listInit)
|
||||
// {
|
||||
// item.LoginInit();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//}
|
||||
@@ -0,0 +1,144 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Store.Client.Helpers
|
||||
{
|
||||
public class DataOpenSSL
|
||||
{
|
||||
public static byte[] key = new byte[32] { 145, 232, 156, 201, 201, 0, 42, 184, 222, 111, 109, 49, 226, 169, 9, 44, 151, 148, 143, 120, 62, 84, 30, 170, 127, 242, 20, 141, 231, 33, 230, 6 };
|
||||
public static byte[] iv = new byte[16] { 113, 6, 75, 177, 160, 112, 73, 39, 178, 147, 82, 107, 186, 58, 144, 187 };
|
||||
|
||||
public static string EncryptString(string plainText)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
// Instantiate a new Aes object to perform string symmetric encryption
|
||||
Aes encryptor = Aes.Create();
|
||||
|
||||
encryptor.Mode = CipherMode.CBC;
|
||||
|
||||
// Set key and IV
|
||||
byte[] aesKey = new byte[32];
|
||||
Array.Copy(key, 0, aesKey, 0, 32);
|
||||
encryptor.Key = aesKey;
|
||||
encryptor.IV = iv;
|
||||
|
||||
// Instantiate a new MemoryStream object to contain the encrypted bytes
|
||||
MemoryStream memoryStream = new MemoryStream();
|
||||
|
||||
// Instantiate a new encryptor from our Aes object
|
||||
ICryptoTransform aesEncryptor = encryptor.CreateEncryptor();
|
||||
|
||||
// Instantiate a new CryptoStream object to process the data and write it to the
|
||||
// memory stream
|
||||
CryptoStream cryptoStream = new CryptoStream(memoryStream, aesEncryptor, CryptoStreamMode.Write);
|
||||
|
||||
// Convert the plainText string into a byte array
|
||||
byte[] plainBytes = Encoding.UTF8.GetBytes(plainText);
|
||||
|
||||
// Encrypt the input plaintext string
|
||||
cryptoStream.Write(plainBytes, 0, plainBytes.Length);
|
||||
|
||||
// Complete the encryption process
|
||||
cryptoStream.FlushFinalBlock();
|
||||
|
||||
// Convert the encrypted data from a MemoryStream to a byte array
|
||||
byte[] cipherBytes = memoryStream.ToArray();
|
||||
|
||||
// Close both the MemoryStream and the CryptoStream
|
||||
memoryStream.Close();
|
||||
cryptoStream.Close();
|
||||
|
||||
// Convert the encrypted byte array to a base64 encoded string
|
||||
string cipherText = Convert.ToBase64String(cipherBytes, 0, cipherBytes.Length);
|
||||
|
||||
|
||||
cipherText = cipherText.Replace("+", "-").Replace("/", "_").Replace("=", "");
|
||||
|
||||
// Return the encrypted data as a string
|
||||
return cipherText;
|
||||
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
//throw;
|
||||
}
|
||||
return plainText;
|
||||
}
|
||||
|
||||
public static string DecryptString(string cipherText)
|
||||
{
|
||||
cipherText = cipherText.Replace("-", "+").Replace("_", "/");
|
||||
var x1 = cipherText.Length % 4;
|
||||
if (x1 > 0)
|
||||
{
|
||||
cipherText = cipherText + "====".Substring(x1);
|
||||
}
|
||||
// Instantiate a new Aes object to perform string symmetric encryption
|
||||
Aes encryptor = Aes.Create();
|
||||
|
||||
encryptor.Mode = CipherMode.CBC;
|
||||
|
||||
// Set key and IV
|
||||
byte[] aesKey = new byte[32];
|
||||
Array.Copy(key, 0, aesKey, 0, 32);
|
||||
encryptor.Key = aesKey;
|
||||
encryptor.IV = iv;
|
||||
|
||||
// Instantiate a new MemoryStream object to contain the encrypted bytes
|
||||
MemoryStream memoryStream = new MemoryStream();
|
||||
|
||||
// Instantiate a new encryptor from our Aes object
|
||||
ICryptoTransform aesDecryptor = encryptor.CreateDecryptor();
|
||||
|
||||
// Instantiate a new CryptoStream object to process the data and write it to the
|
||||
// memory stream
|
||||
CryptoStream cryptoStream = new CryptoStream(memoryStream, aesDecryptor, CryptoStreamMode.Write);
|
||||
|
||||
// Will contain decrypted plaintext
|
||||
string plainText = String.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
// Convert the ciphertext string into a byte array
|
||||
byte[] cipherBytes = Convert.FromBase64String(cipherText);
|
||||
|
||||
// Decrypt the input ciphertext string
|
||||
cryptoStream.Write(cipherBytes, 0, cipherBytes.Length);
|
||||
|
||||
// Complete the decryption process
|
||||
cryptoStream.FlushFinalBlock();
|
||||
|
||||
// Convert the decrypted data from a MemoryStream to a byte array
|
||||
byte[] plainBytes = memoryStream.ToArray();
|
||||
|
||||
// Convert the decrypted byte array to string
|
||||
plainText = Encoding.UTF8.GetString(plainBytes, 0, plainBytes.Length);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
//throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
// Close both the MemoryStream and the CryptoStream
|
||||
memoryStream.Close();
|
||||
cryptoStream.Close();
|
||||
}
|
||||
|
||||
// Return the decrypted data as a string
|
||||
return plainText;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
using Store.Framework.Configs;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Store.Framework.Helpers
|
||||
{
|
||||
/// <summary>
|
||||
/// 文件操作帮助类
|
||||
/// </summary>
|
||||
public class FileHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取文件MD5值
|
||||
/// </summary>
|
||||
/// <param name="FilePath"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetFileMd5(string FilePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
FileStream get_file = new FileStream(FilePath, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
System.Security.Cryptography.MD5CryptoServiceProvider get_md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
|
||||
byte[] hash_byte = get_md5.ComputeHash(get_file);
|
||||
string resule = BitConverter.ToString(hash_byte);
|
||||
resule = resule.Replace("-", "");
|
||||
get_file.Close();
|
||||
return resule;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return e.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读取所有内容 相对路径Or绝对路径
|
||||
/// </summary>
|
||||
/// <param name="file"></param>
|
||||
/// <returns></returns>
|
||||
public static string ReadAllText(string file)
|
||||
{
|
||||
if (!Path.IsPathRooted(file))
|
||||
{
|
||||
file = Path.Combine(GlobalConfig.AppDirectory, file);
|
||||
}
|
||||
if (File.Exists(file))
|
||||
{
|
||||
return _ReadAllText(file, Encoding.UTF8);
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
/// <summary>
|
||||
/// 读取所有内容 绝对路径
|
||||
/// </summary>
|
||||
/// <param name="file"></param>
|
||||
/// <returns></returns>
|
||||
public static string ReadAbsAllText(string file)
|
||||
{
|
||||
return _ReadAllText(file, Encoding.UTF8);
|
||||
}
|
||||
/// <summary>
|
||||
/// 读取所有内容 相对路径
|
||||
/// </summary>
|
||||
/// <param name="file"></param>
|
||||
/// <returns></returns>
|
||||
public static string ReadPartialAllText(string file)
|
||||
{
|
||||
string _file = Path.Combine(GlobalConfig.AppDirectory, file);
|
||||
return _ReadAllText(_file, Encoding.UTF8);
|
||||
}
|
||||
|
||||
private static string _ReadAllText(string file, Encoding encoding)
|
||||
{
|
||||
if (File.Exists(file))
|
||||
{
|
||||
return File.ReadAllText(file, encoding);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"缺失文件{file}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,159 @@
|
||||
using MAX.Core.Autofac;
|
||||
using MAX.Core.DependencyInjection;
|
||||
using MAX.Core.Helpers;
|
||||
using MAX.Core.Logger;
|
||||
using Store.Client.Extensions;
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
|
||||
namespace Store.Client.HttpExtension
|
||||
{
|
||||
/// <summary>
|
||||
/// Store 基础 API 请求基类。
|
||||
/// 项目 API 可以继承该基类并重写 ServiceConfigKey,使用项目自己的服务配置。
|
||||
/// </summary>
|
||||
public class AppApiRequestBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 日志。
|
||||
/// </summary>
|
||||
[Autowired]
|
||||
protected ILoggerFacade _logger => LazyServiceProvider.Instance.LazyGetService<ILoggerFacade>();
|
||||
protected IApiServerConfig _config => LazyServiceProvider.Instance.LazyGetService<IApiServerConfig>();
|
||||
|
||||
/// <summary>
|
||||
/// 默认服务请求。
|
||||
/// </summary>
|
||||
protected HttpResult Post(string urlpath, string postdata = "")
|
||||
{
|
||||
return Request(BuildServiceUrl(urlpath), postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 公共签名服务请求。
|
||||
/// </summary>
|
||||
protected HttpResult PostPublic(string urlpath, string postdata = "")
|
||||
{
|
||||
return Request(BuildServiceUrl(urlpath), postdata, isUserSign: false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拼多多服务请求。
|
||||
/// </summary>
|
||||
protected HttpResult PostPdd(string urlpath, string postdata = "")
|
||||
{
|
||||
return Request(BuildServiceUrl("bxx_" + urlpath), postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 微信服务请求。
|
||||
/// </summary>
|
||||
protected HttpResult PostWx(string urlpath, string postdata = "")
|
||||
{
|
||||
return Request(BuildServiceUrl("wxxd_" + urlpath), postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 微信图片服务请求。
|
||||
/// </summary>
|
||||
protected HttpResult PostWxImg(string urlpath, string postdata = "")
|
||||
{
|
||||
return Request(BuildServiceUrl("wxxd_" + urlpath), postdata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 默认兼容服务请求。
|
||||
/// </summary>
|
||||
protected HttpResult PostDefault(string urlpath, string postdata = "")
|
||||
{
|
||||
return Request(BuildServiceUrl(urlpath), postdata);
|
||||
}
|
||||
/// <summary>
|
||||
/// 使用当前 Key 构建服务请求地址。
|
||||
/// </summary>
|
||||
protected string BuildServiceUrl(string urlPath)
|
||||
{
|
||||
return $"{_config.Host}/wxxd_{urlPath}?obj=29wx/wxxd_{urlPath}";
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 创建并执行服务端请求,默认使用当前用户签名。
|
||||
/// </summary>
|
||||
protected HttpResult Request(string url, string postdata = "", MethodType method = MethodType.Post, bool isUserSign = true)
|
||||
{
|
||||
ServerHttpItem item = new ServerHttpItem
|
||||
{
|
||||
URL = url,
|
||||
Method = method,
|
||||
Postdata = postdata ?? string.Empty
|
||||
};
|
||||
|
||||
if (isUserSign)
|
||||
{
|
||||
item.SignUser();
|
||||
}
|
||||
|
||||
return ServerRequest(item);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 服务器请求。
|
||||
/// </summary>
|
||||
public HttpResult ServerRequest(ServerHttpItem item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(item));
|
||||
}
|
||||
|
||||
#if RELEASE
|
||||
item.WebProxy = null;
|
||||
#endif
|
||||
if (!item.IsSign)
|
||||
{
|
||||
if (item.Shop != null)
|
||||
{
|
||||
item.SignUser(item.Shop.Id, item.Shop.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
item.Sign();
|
||||
}
|
||||
}
|
||||
|
||||
return Send(item);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 执行底层 HTTP 请求。
|
||||
/// </summary>
|
||||
protected HttpResult Send(ServerHttpItem item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(item));
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(item.URL))
|
||||
{
|
||||
throw new ArgumentException("请求地址不能为空。", nameof(item));
|
||||
}
|
||||
|
||||
if (!item.URL.StartsWith("http", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
item.URL = _config.Host + "/" + item.URL.TrimStart('/');
|
||||
}
|
||||
|
||||
item.Encoding = Encoding.UTF8;
|
||||
HttpResult result = HttpHelper.Request(item);
|
||||
if (result.StatusCode == HttpStatusCode.OK && !string.IsNullOrEmpty(result.Html) && result.Html[0] == 65279)
|
||||
{
|
||||
result.Html = result.Html.Remove(0, 1);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
|
||||
using MAX.Core.Helpers;
|
||||
using Store.Framework.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Store.Client.HttpExtension
|
||||
{
|
||||
public class ServerHttpItem : HttpItem
|
||||
{
|
||||
public ShopBase Shop { get; private set; }
|
||||
public ServerHttpItem()
|
||||
{
|
||||
|
||||
}
|
||||
public ServerHttpItem(ShopBase shop)
|
||||
{
|
||||
Shop = shop;
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否已签名
|
||||
/// </summary>
|
||||
public bool IsSign { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
//using MAX.Core.Autofac;
|
||||
//using MAX.Core.Helpers;
|
||||
//using System;
|
||||
//using System.Net;
|
||||
//using System.Text;
|
||||
|
||||
//namespace Store.Client.HttpExtension
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// 服务请求公共基类。
|
||||
// /// 该基类只负责按 Key 获取服务配置以及执行底层 HTTP 请求,不绑定具体业务签名规则。
|
||||
// /// </summary>
|
||||
// public abstract class ServiceRequestBase
|
||||
// {
|
||||
// /// <summary>
|
||||
// /// 服务配置提供器。由 Autofac 通过属性注入。
|
||||
// /// </summary>
|
||||
// [Autowired]
|
||||
// protected IServiceConfigProvider ServiceConfigProvider { get; set; }
|
||||
|
||||
// /// <summary>
|
||||
// /// 当前请求类使用的服务配置 Key。
|
||||
// /// 项目 API 可以重写该属性以使用自己的服务地址。
|
||||
// /// </summary>
|
||||
// protected virtual string ServiceConfigKey => ServiceConfigKeys.Default;
|
||||
|
||||
// /// <summary>
|
||||
// /// 获取当前服务配置。
|
||||
// /// </summary>
|
||||
// protected IApiServerConfig GetServiceConfig()
|
||||
// {
|
||||
// return GetServiceConfig(ServiceConfigKey);
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// 获取指定 Key 的服务配置。
|
||||
// /// </summary>
|
||||
// protected IApiServerConfig GetServiceConfig(string serviceConfigKey)
|
||||
// {
|
||||
// if (ServiceConfigProvider == null)
|
||||
// {
|
||||
// throw new InvalidOperationException("IServiceConfigProvider 未注入,请通过 DI 容器创建请求服务。");
|
||||
// }
|
||||
|
||||
// return ServiceConfigProvider.Get(serviceConfigKey);
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// 使用当前 Key 构建服务请求地址。
|
||||
// /// </summary>
|
||||
// protected string BuildServiceUrl(string urlPath)
|
||||
// {
|
||||
// return BuildServiceUrl(ServiceConfigKey, urlPath);
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// 使用指定 Key 构建服务请求地址。
|
||||
// /// </summary>
|
||||
// protected string BuildServiceUrl(string serviceConfigKey, string urlPath)
|
||||
// {
|
||||
// IApiServerConfig config = GetServiceConfig(serviceConfigKey);
|
||||
// return config.Host + "?" + config.ObjUrl + (urlPath ?? string.Empty);
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// 获取指定 Key 的基础地址。
|
||||
// /// </summary>
|
||||
// protected string GetServiceHost(string serviceConfigKey = null)
|
||||
// {
|
||||
// IApiServerConfig config = string.IsNullOrWhiteSpace(serviceConfigKey)
|
||||
// ? GetServiceConfig()
|
||||
// : GetServiceConfig(serviceConfigKey);
|
||||
// return config.Host;
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// 执行底层 HTTP 请求。
|
||||
// /// </summary>
|
||||
// protected HttpResult Send(ServerHttpItem item)
|
||||
// {
|
||||
// if (item == null)
|
||||
// {
|
||||
// throw new ArgumentNullException(nameof(item));
|
||||
// }
|
||||
// if (string.IsNullOrWhiteSpace(item.URL))
|
||||
// {
|
||||
// throw new ArgumentException("请求地址不能为空。", nameof(item));
|
||||
// }
|
||||
|
||||
// if (!item.URL.StartsWith("http", StringComparison.OrdinalIgnoreCase))
|
||||
// {
|
||||
// item.URL = GetServiceConfig().Host + "/" + item.URL.TrimStart('/');
|
||||
// }
|
||||
|
||||
// item.Encoding = Encoding.UTF8;
|
||||
// HttpResult result = HttpHelper.Request(item);
|
||||
// if (result.StatusCode == HttpStatusCode.OK && !string.IsNullOrEmpty(result.Html) && result.Html[0] == 65279)
|
||||
// {
|
||||
// result.Html = result.Html.Remove(0, 1);
|
||||
// }
|
||||
|
||||
// return result;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Store.Framework.HttpResultParser
|
||||
{
|
||||
/// <summary>
|
||||
/// Http异常
|
||||
/// </summary>
|
||||
public class HttpException : Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Cookie是否在线
|
||||
/// </summary>
|
||||
public bool IsOnline { get; set; } = true;
|
||||
public HttpException(string message) : base(message)
|
||||
{
|
||||
|
||||
}
|
||||
public HttpException(string message, Exception innerException) : base(message, innerException)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
using MAX.Core.Helpers;
|
||||
using Polly;
|
||||
using Polly.Retry;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
|
||||
namespace Store.Framework.HttpResultParser
|
||||
{
|
||||
public class HttpResultVerify
|
||||
{
|
||||
/// <summary>
|
||||
/// 重新尝试请求
|
||||
/// </summary>
|
||||
/// <param name="action">请求方法</param>
|
||||
/// <param name="retryCount">重试次数</param>
|
||||
/// <param name="sleepTime">间隔时间</param>
|
||||
/// <returns></returns>
|
||||
public static HttpResultVerify TryVerify(Func<HttpResult> action, int retryCount = 3, int sleepTime = 1000)
|
||||
{
|
||||
return new HttpResultVerify(action, retryCount, sleepTime);
|
||||
}
|
||||
private int retryCount = 3;
|
||||
private int sleepTime = 1000;
|
||||
private readonly Func<HttpResult> _action;
|
||||
private RetryPolicy<HttpResult> retryPolicy;
|
||||
private List<IHttpResultVerify> _listUse = new List<IHttpResultVerify>();
|
||||
private List<Func<HttpResult, bool>> _addRetTryList = new List<Func<HttpResult, bool>>();
|
||||
public HttpResultVerify(Func<HttpResult> action)
|
||||
{
|
||||
_action = action;
|
||||
retryPolicy = TryHttpExec(_action);
|
||||
}
|
||||
public HttpResultVerify(Func<HttpResult> action, int RetryCount) : this(action)
|
||||
{
|
||||
retryCount = RetryCount;
|
||||
}
|
||||
public HttpResultVerify(Func<HttpResult> action, int RetryCount, int SleepTime) : this(action, RetryCount)
|
||||
{
|
||||
sleepTime = SleepTime;
|
||||
}
|
||||
/// <summary>
|
||||
/// 添加检测Http返回
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public void UseCheckResult<T>() where T : IHttpResultVerify, new()
|
||||
{
|
||||
_listUse.Add(new T());
|
||||
}
|
||||
/// <summary>
|
||||
/// 添加检测Http返回
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public void UseCheckResult<T>(T checkResult) where T : IHttpResultVerify
|
||||
{
|
||||
_listUse.Add(checkResult);
|
||||
}
|
||||
/// <summary>
|
||||
/// 添加 是否再次尝试 true 再次尝试 false 不再尝试
|
||||
/// </summary>
|
||||
/// <param name="func"></param>
|
||||
/// <returns></returns>
|
||||
public HttpResultVerify AddRetTry(Func<HttpResult, bool> func)
|
||||
{
|
||||
_addRetTryList.Add(func);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public HttpResult Exec()
|
||||
{
|
||||
return retryPolicy.Execute(() =>
|
||||
{
|
||||
var result = _action();
|
||||
foreach (var item in _listUse)
|
||||
{
|
||||
result = item.CheckResult(result);
|
||||
}
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private bool RetTry(HttpResult result)
|
||||
{
|
||||
//返回结果状态判断 再次执行
|
||||
var ret = false;
|
||||
ret = result.StatusCode != HttpStatusCode.OK;
|
||||
foreach (var item in _listUse)
|
||||
{
|
||||
ret = item.RetTry(result);
|
||||
if (ret)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!ret)
|
||||
{
|
||||
foreach (var item in _addRetTryList)
|
||||
{
|
||||
ret = item(result);
|
||||
if (ret)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
/// <summary>
|
||||
/// 尝试执行
|
||||
/// </summary>
|
||||
/// <param name="action"></param>
|
||||
/// <returns></returns>
|
||||
private RetryPolicy<HttpResult> TryHttpExec(Func<HttpResult> action, int sleepTime = 1000)
|
||||
{
|
||||
if (retryCount == 0)
|
||||
{
|
||||
retryCount = 3;
|
||||
}
|
||||
var retryPolicy = Policy
|
||||
.Handle<Exception>(a =>
|
||||
{
|
||||
if (a.Message == "登录失效")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
})
|
||||
.OrResult<HttpResult>(RetTry)
|
||||
.WaitAndRetry(retryCount, retryAttempt =>
|
||||
{
|
||||
return TimeSpan.FromMilliseconds(sleepTime);
|
||||
}
|
||||
, (ex, timespan, retryindex, context) =>
|
||||
{
|
||||
Console.WriteLine($"开始第 {retryindex} 次重试:");
|
||||
});
|
||||
return retryPolicy;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using MAX.Core.Helpers;
|
||||
|
||||
namespace Store.Framework.HttpResultParser
|
||||
{
|
||||
public interface IHttpResultVerify
|
||||
{
|
||||
/// <summary>
|
||||
/// 重新尝试条件 true 再次尝试 false 不重新尝试
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
bool RetTry(HttpResult result);
|
||||
/// <summary>
|
||||
/// 检测请求结果
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
HttpResult CheckResult(HttpResult result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using Store.Framework.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Store.Framework.Inerterfaces;
|
||||
|
||||
public interface ICurrentUser
|
||||
{
|
||||
string UserName { get; }
|
||||
int GroupId { get; }
|
||||
bool IsAuthorized(string code);
|
||||
/// <summary>
|
||||
/// 是否超级管理员
|
||||
/// </summary>
|
||||
bool IsSuperAdmin { get; }
|
||||
UserInfo User { get; }
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Store.Framework.Models
|
||||
{
|
||||
public class Cookies : Dictionary<string, string>
|
||||
{
|
||||
private readonly string oldCookie;
|
||||
public Cookies(string cookie)
|
||||
{
|
||||
oldCookie = cookie;
|
||||
SplitCookie(oldCookie);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cookie字符串
|
||||
/// </summary>
|
||||
public string CookieString
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetCookieString();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拆分Cookie
|
||||
/// </summary>
|
||||
private void SplitCookie(string cookie)
|
||||
{
|
||||
this.Clear();
|
||||
Regex regCookie = new Regex("(?<key>.+?)=(?<value>.+?)(;|$)");
|
||||
if (regCookie.IsMatch(cookie))
|
||||
{
|
||||
MatchCollection matchs = regCookie.Matches(cookie);
|
||||
foreach (Match item in matchs)
|
||||
{
|
||||
string key = item.Groups["key"].Value.Trim();
|
||||
string value = item.Groups["value"].Value.Trim();
|
||||
if (!ContainsKey(key))
|
||||
{
|
||||
this.Add(key.Trim(), value.Trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定值
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="defvalue">默认值</param>
|
||||
/// <returns></returns>
|
||||
public string GetValue(string key, string defvalue)
|
||||
{
|
||||
if (ContainsKey(key))
|
||||
{
|
||||
return this[key];
|
||||
}
|
||||
return defvalue;
|
||||
}
|
||||
/// <summary>
|
||||
/// 添加或修改
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="value"></param>
|
||||
public void AddOrUpdate(string key, string value)
|
||||
{
|
||||
if (!this.ContainsKey(key))
|
||||
{
|
||||
Add(key, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
this[key] = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取Cookies字符串
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual string GetCookieString()
|
||||
{
|
||||
var list = this.Select(a => { return $"{a.Key}={a.Value}"; });
|
||||
return string.Join(";", list);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 隐式转换
|
||||
/// </summary>
|
||||
/// <param name="cookie"></param>
|
||||
public static implicit operator string (Cookies cookie)
|
||||
{
|
||||
return cookie.GetCookieString();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Store.Framework.Models.Product;
|
||||
|
||||
/// <summary>
|
||||
/// 商品类目
|
||||
/// </summary>
|
||||
public class CategoryModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public int ParentId { get; set; }
|
||||
public int MainCatId { get; set; }
|
||||
|
||||
public List<CategoryModel> Childs { get; set; }
|
||||
public CategoryModel()
|
||||
{
|
||||
Childs = new List<CategoryModel>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Store.Framework.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 商铺信息
|
||||
/// </summary>
|
||||
public class ShopBase
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Password { get; set; }
|
||||
/// <summary>
|
||||
/// Cookie信息
|
||||
public Cookies Cookie { get; set; }
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// 分组名称
|
||||
/// </summary>
|
||||
public string GroupName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 商铺提示信息
|
||||
/// </summary>
|
||||
public string Msg { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 商铺信息
|
||||
/// </summary>
|
||||
/// <typeparam name="TStatus">状态码</typeparam>
|
||||
public class ShopBase<TStatus> : ShopBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 状态
|
||||
/// </summary>
|
||||
public TStatus Status { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Store.Framework.Models
|
||||
{
|
||||
public class UserInfo
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public int UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 账号
|
||||
/// </summary>
|
||||
[JsonProperty("user_name")]
|
||||
public string UserName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 密码
|
||||
/// </summary>
|
||||
[JsonProperty("password")]
|
||||
public string Password { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 客服-4;采购-9;上货-10;数据-11;登录-8
|
||||
/// </summary>
|
||||
[JsonProperty("group_id")]
|
||||
public int GroupId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 注册用户Key
|
||||
/// </summary>
|
||||
[JsonProperty("user_key")]
|
||||
public string UserKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 所在企业ID
|
||||
/// </summary>
|
||||
[JsonProperty("company_Id")]
|
||||
public string CompanyId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 企业名称
|
||||
/// </summary>
|
||||
[JsonProperty("company_name")]
|
||||
public string CompanyName { get; set; }
|
||||
|
||||
[JsonProperty("nick_name")]
|
||||
public string NickName { get; set; }
|
||||
|
||||
[JsonProperty("parent_user_name")]
|
||||
public string ParentUserName { get; set; }
|
||||
|
||||
[JsonProperty("sa_level")]
|
||||
public int SaLevel { get; set; }
|
||||
|
||||
[JsonProperty("authority")]
|
||||
public string UserAuthority { get; set; }
|
||||
|
||||
[JsonProperty("parent_authority")]
|
||||
public string ParentAuthority { get; set; }
|
||||
|
||||
[JsonProperty("forbidden_page")]
|
||||
public string ForbiddenPage { get; set; }
|
||||
|
||||
[JsonProperty("mobile")]
|
||||
public string Mobile { get; set; }
|
||||
|
||||
[JsonProperty("version")]
|
||||
public int UserVersion { get; set; }
|
||||
|
||||
[JsonProperty("version_s")]
|
||||
public string UserVersionString { get; set; }
|
||||
|
||||
[JsonProperty("authorized_amount")]
|
||||
public decimal? AuthorizedAmount { get; set; }
|
||||
|
||||
[JsonProperty("points")]
|
||||
public int Points { get; set; }
|
||||
|
||||
[JsonProperty("shop_points_per_month")]
|
||||
public int ShopPointsPerMonth { get; set; }
|
||||
|
||||
[JsonProperty("balance")]
|
||||
public decimal Balance { get; set; }
|
||||
|
||||
[JsonProperty("recharge_amount_total")]
|
||||
public decimal RechargeAmountTotal { get; set; }
|
||||
|
||||
[JsonProperty("postage_per_order")]
|
||||
public decimal? PostagePerOrder { get; set; }
|
||||
|
||||
[JsonProperty("refund_postage_per_order")]
|
||||
public decimal? RefundPostagePerOrder { get; set; }
|
||||
|
||||
[JsonProperty("gift_oem_amount_per_order")]
|
||||
public decimal GiftOemAmountPerOrder { get; set; }
|
||||
|
||||
[JsonProperty("oem_id")]
|
||||
public string OemId { get; set; }
|
||||
|
||||
[JsonProperty("oem_name")]
|
||||
public string OemName { get; set; }
|
||||
|
||||
[JsonProperty("is_oem_owner")]
|
||||
public bool IsOemOwner { get; set; }
|
||||
|
||||
[JsonProperty("end")]
|
||||
public string EndDate { get; set; }
|
||||
|
||||
[JsonProperty("qq_group_num")]
|
||||
public string QqGroupNum { get; set; }
|
||||
|
||||
[JsonProperty("qq_group_url")]
|
||||
public string QqGroupUrl { get; set; }
|
||||
|
||||
[JsonProperty("wechat_url")]
|
||||
public string WechatUrl { get; set; }
|
||||
|
||||
[JsonProperty("pinduoduo")]
|
||||
public string Pinduoduo { get; set; }
|
||||
|
||||
[JsonProperty("alimama_domain")]
|
||||
public string AlimamaDomain { get; set; }
|
||||
|
||||
[JsonProperty("alimama_pid")]
|
||||
public string AlimamaPid { get; set; }
|
||||
|
||||
[JsonProperty("is_lock")]
|
||||
public int LockUserName { get; set; }
|
||||
|
||||
[JsonProperty("is_weak_password")]
|
||||
public int WeakPassword { get; set; }
|
||||
|
||||
[JsonProperty("message")]
|
||||
public string MessageInfo { get; set; }
|
||||
|
||||
[JsonProperty("agent_auth")]
|
||||
public string AgentAuth { get; set; }
|
||||
|
||||
[JsonProperty("is_import")]
|
||||
public bool IsImport { get; set; }
|
||||
|
||||
[JsonProperty("card_id")]
|
||||
public string CardId { get; set; }
|
||||
|
||||
[JsonProperty("is_sa")]
|
||||
public bool IsSa { get; set; }
|
||||
|
||||
[JsonProperty("add_time")]
|
||||
public DateTime AddTime { get; set; }
|
||||
|
||||
[JsonProperty("mdy_time")]
|
||||
public DateTime MdyTime { get; set; }
|
||||
|
||||
[JsonProperty("notes")]
|
||||
public string Notes { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using MAX.Core.DependencyInjection;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NLog;
|
||||
using Store.Client.Apis;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Store.Client.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// 缓存服务集群负载
|
||||
/// </summary>
|
||||
public class CacheServerService : ITransientDependency
|
||||
{
|
||||
private readonly CommonApi _commonApi;
|
||||
private readonly ILogger _logger;
|
||||
private readonly CommonApi _commonApi1;
|
||||
|
||||
/// <summary>
|
||||
/// 缓存服务集群负载占比
|
||||
/// </summary>
|
||||
private static Dictionary<string, int> _cacheServerRatio { get; set; } = new Dictionary<string, int>();
|
||||
|
||||
public CacheServerService(ILogger logger, CommonApi commonApi)
|
||||
{
|
||||
_commonApi = IocManager.Resolve<CommonApi>();// commonApi;
|
||||
_logger = logger;
|
||||
_commonApi1 = commonApi;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 默认数据
|
||||
/// </summary>
|
||||
private void SetDefaultData()
|
||||
{
|
||||
_cacheServerRatio.Add("https://temp-new1.taojinhu.com:10019", 5);
|
||||
_cacheServerRatio.Add("https://t3.1n11.com", 5);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
using MAX.Core.DependencyInjection;
|
||||
using MAX.Core.Helpers;
|
||||
using Store.Client;
|
||||
using Store.Client.Apis;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Store.Client.Services
|
||||
{
|
||||
internal class CommonService : ITransientDependency
|
||||
{
|
||||
private readonly CommonApi _commonApi;
|
||||
public CommonService(CommonApi commonApi)
|
||||
{
|
||||
_commonApi = commonApi;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取签名配置
|
||||
/// </summary>
|
||||
public void LoadAuthConfig()
|
||||
{
|
||||
var value = _commonApi.GetAuthConfig();
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
ServerConfig.IsNewSignatureAuth = value.Equals("1");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取本地与服务器时间差
|
||||
/// </summary>
|
||||
public void LoadServerTimeSpan()
|
||||
{
|
||||
DateTime SDateTime = _commonApi.GetServerTime();
|
||||
long s = DateHelper.GetUnixTimestampInSeconds(SDateTime);
|
||||
long a = DateHelper.GetUnixTimestampInSeconds(DateTime.Now);
|
||||
ServerConfig.TimeDifferent = s - a;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取服务器时间戳
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static long GetServerUnix()
|
||||
{
|
||||
return DateHelper.GetUnixTimestampInSeconds(DateTime.Now) + ServerConfig.TimeDifferent;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取服务器时间
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static DateTime GetServerDataTime()
|
||||
{
|
||||
return DateHelper.ConvertFromUnixTimestampInSeconds(GetServerUnix());
|
||||
}
|
||||
|
||||
|
||||
///// <summary>
|
||||
///// 获取服务器图片缓存
|
||||
///// </summary>
|
||||
///// <param name="imgUrl"></param>
|
||||
///// <returns></returns>
|
||||
//public string GetImageCache(string imgUrl)
|
||||
//{
|
||||
// string imgurl = "";
|
||||
// HttpResult result = _commonApi.GetImageCache(imgUrl);
|
||||
// if (result.StatusCode == System.Net.HttpStatusCode.OK)
|
||||
// {
|
||||
// result.Html = result.Html.Trim();
|
||||
// if (Regex.IsMatch(result.Html, "^http"))
|
||||
// {
|
||||
// imgurl = result.Html;
|
||||
|
||||
// }
|
||||
// }
|
||||
// return imgurl;
|
||||
//}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using MAX.Core.DependencyInjection;
|
||||
using MediatR;
|
||||
using Store.Framework.Inerterfaces;
|
||||
using Store.Framework.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Store.Framework.Services;
|
||||
|
||||
public record UserNotification(UserInfo user) : INotification;
|
||||
/// <summary>
|
||||
/// 当前用户
|
||||
/// </summary>
|
||||
internal class CurrentUserService : ICurrentUser, ISingletonDependency, INotificationHandler<UserNotification>
|
||||
{
|
||||
public string UserName => User?.UserName;
|
||||
|
||||
public int GroupId => User.GroupId;
|
||||
|
||||
public UserInfo User { get; private set; }
|
||||
|
||||
public bool IsSuperAdmin => User.IsSa;
|
||||
|
||||
public bool IsAuthorized(string code)
|
||||
{
|
||||
return User.UserAuthority.Contains(code);
|
||||
}
|
||||
|
||||
Task INotificationHandler<UserNotification>.Handle(UserNotification notification, CancellationToken cancellationToken)
|
||||
{
|
||||
User = notification.user;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
//using FkServices = LittleCow.Framework.Services;
|
||||
|
||||
namespace Store.Client.Services
|
||||
{
|
||||
///// <summary>
|
||||
///// 商铺服务
|
||||
///// </summary>
|
||||
//internal class ShopService : ITransientDependency
|
||||
//{
|
||||
// private readonly ShopApi _shopApi;
|
||||
// private readonly IEventBus _eventBus;
|
||||
|
||||
// public ShopService(ShopApi shopApi, IEventBus eventBus)
|
||||
// {
|
||||
// _shopApi = shopApi;
|
||||
// _eventBus = eventBus;
|
||||
// }
|
||||
|
||||
|
||||
// /// <summary>
|
||||
// /// 获取所有商铺信息
|
||||
// /// </summary>
|
||||
// /// <typeparam name="T"></typeparam>
|
||||
// /// <returns></returns>
|
||||
// public List<T> GetShops<T>() where T : ShopBase
|
||||
// {
|
||||
// HttpResult result = _shopApi.GetShops();
|
||||
// if (result.StatusCode == System.Net.HttpStatusCode.OK)
|
||||
// {
|
||||
// StringBuilder sb = new StringBuilder();
|
||||
// sb.Append("[");
|
||||
// Regex regShopList = new Regex("<shop([^>]+?)>");
|
||||
// if (regShopList.IsMatch(result.Html))
|
||||
// {
|
||||
// int index = 0;
|
||||
// MatchCollection matchs = regShopList.Matches(result.Html);
|
||||
// foreach (Match item in matchs)
|
||||
// {
|
||||
// string value = item.Value;
|
||||
// value = value.Replace("<shop '", "{\"");
|
||||
// value = value.Replace("'>", "\"}");
|
||||
// value = value.Replace("':'", "\":\"");
|
||||
// value = value.Replace("' '", "\",\"");
|
||||
// if (index > 0)
|
||||
// {
|
||||
// sb.Append(",");
|
||||
// }
|
||||
// sb.Append(value);
|
||||
// index++;
|
||||
|
||||
// }
|
||||
// sb.Append("]");
|
||||
// List<T> list = JsonConvert.DeserializeObject<List<T>>(sb.ToString());
|
||||
// list.RemoveAll(a => string.IsNullOrEmpty(a.Name));
|
||||
// return list;
|
||||
// }
|
||||
// }
|
||||
// return new List<T>();
|
||||
// }
|
||||
|
||||
|
||||
// public string GetShopCookie(List<ShopBase> shops)
|
||||
// {
|
||||
// HttpResult result = _shopApi.GetShopsCookie(shops);
|
||||
// if (result.StatusCode == System.Net.HttpStatusCode.OK)
|
||||
// {
|
||||
// MatchCollection matchs = Regex.Matches(result.Html, @"<shop id=""([^""]+?)"">([\w\W]+?)</shop>");
|
||||
// if (matchs != null)
|
||||
// {
|
||||
// foreach (Match item in matchs)
|
||||
// {
|
||||
// string shopId = item.Groups[1].Value;
|
||||
// string json = item.Groups[2].Value;
|
||||
// var rootToken = JToken.Parse(json);
|
||||
// string cookie = rootToken["Cookies"]?.ToString() ?? "";
|
||||
// var shop = shops.FirstOrDefault(a => a.Id == shopId);
|
||||
// if (shop != null)
|
||||
// {
|
||||
// shop.Cookie = new Cookies(cookie);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
|
||||
|
||||
// /// <summary>
|
||||
// /// 检测商铺登录状态
|
||||
// /// </summary>
|
||||
// public void CheckShopStatus(ShopBase shop)
|
||||
// {
|
||||
// HttpItem item = new HttpItem();
|
||||
// item.URL = "https://myseller.taobao.com/ajaxProxy.do?_ksTS=1548152154745_13&callback=seller_layout_head&action=FrameworkLayoutAction&event_submit_do_layout_data=true";
|
||||
// item.Referer = "https://myseller.taobao.com";
|
||||
// item.Method = MethodType.Post;
|
||||
// item.Cookie = shop.Cookie.GetCookieString();
|
||||
// HttpResult result = HttpHelper.Request(item);
|
||||
// if (result.StatusCode == System.Net.HttpStatusCode.OK)
|
||||
// {
|
||||
// string a = result.Html.Contains("\"shopName\":\"") ? "登录成功" : "会话已过期";
|
||||
// }
|
||||
// //string urlx =
|
||||
// //string refere =
|
||||
// //string htmlx = GetPostTaobaoHtml.GetUrl(urlx, refere, true, "", Shop.Cookies);
|
||||
// //Shop.MsgForCookiesLogin = htmlx.Contains("\"shopName\":\"") ? "登录成功" : "会话已过期";
|
||||
// //GetTaobaoShops.ShopsTemp.Add(Shop);
|
||||
// }
|
||||
// /// <summary>
|
||||
// /// 获取值
|
||||
// /// </summary>
|
||||
// /// <param name="html"></param>
|
||||
// /// <param name="reg"></param>
|
||||
// /// <returns></returns>
|
||||
// private string GetUserValue(string html, string reg)
|
||||
// {
|
||||
// string temp = Regex.Match(html, @"[""]" + reg + @"[""][\s]*:[\s]*[""]([^""]*?)[""]")?.Value;
|
||||
// if (string.IsNullOrEmpty(temp))
|
||||
// temp = Regex.Match(html, @"[']" + reg + @"['][\s]*:[\s]*[']([^']*?)[']")?.Groups[1].Value;
|
||||
// if (string.IsNullOrEmpty(temp))
|
||||
// temp = Regex.Match(html, @"['""]" + reg + @"['""][\s]*:[\s]*([\d]+)")?.Value;
|
||||
|
||||
// return temp;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
using MAX.Core.Commons;
|
||||
using MAX.Core.Cryptography;
|
||||
using MAX.Core.DependencyInjection;
|
||||
using MAX.Core.Helpers;
|
||||
using Newtonsoft.Json;
|
||||
using Store.Client.Apis;
|
||||
using Store.Framework.Apis;
|
||||
using Store.Framework.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Store.Client.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户操作
|
||||
/// </summary>
|
||||
public class UserService : ITransientDependency
|
||||
{
|
||||
private readonly UserApi _userApi;
|
||||
|
||||
public UserService(UserApi userApi)
|
||||
{
|
||||
_userApi = userApi;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用户登录
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
public Result<HttpResult> Login(UserInfo user)
|
||||
{
|
||||
Result<HttpResult> ret = new Result<HttpResult>();
|
||||
user.Password = MD5Helper.Md5_Lower32(user.Password);
|
||||
HttpResult result = _userApi.Login(user.UserName, user.Password);
|
||||
|
||||
if (result.StatusCode == HttpStatusCode.Unauthorized)
|
||||
{
|
||||
ret.Msg = "登录失败\r\n链接异常请重试";
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(result.Html))
|
||||
{
|
||||
ret.Msg = "链接服务器失败";
|
||||
return ret;
|
||||
}
|
||||
|
||||
ApiResponse<UserInfo> apiResponse = null;
|
||||
try
|
||||
{
|
||||
apiResponse = JsonConvert.DeserializeObject<ApiResponse<UserInfo>>(result.Html);
|
||||
}
|
||||
catch (JsonException)
|
||||
{
|
||||
}
|
||||
|
||||
if (apiResponse == null)
|
||||
{
|
||||
ret.Msg = result.Html;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret.Code = apiResponse.Code;
|
||||
if (apiResponse.Code != 200 || apiResponse.Data == null)
|
||||
{
|
||||
ret.Msg = string.IsNullOrEmpty(apiResponse.Msg) ? result.Html : apiResponse.Msg;
|
||||
return ret;
|
||||
}
|
||||
|
||||
FillUserInfo(user, apiResponse.Data);
|
||||
ret.Success = true;
|
||||
ret.Msg = apiResponse.Msg;
|
||||
ret.Data = result;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将接口返回的登录用户信息回填到调用方对象。
|
||||
/// </summary>
|
||||
private static void FillUserInfo(UserInfo target, UserInfo source)
|
||||
{
|
||||
target.UserId = source.UserId;
|
||||
target.UserName = source.UserName;
|
||||
target.Password = source.Password;
|
||||
target.GroupId = source.GroupId;
|
||||
target.UserKey = source.UserKey;
|
||||
target.CompanyId = source.CompanyId;
|
||||
target.CompanyName = source.CompanyName;
|
||||
target.NickName = source.NickName;
|
||||
target.ParentUserName = source.ParentUserName;
|
||||
target.SaLevel = source.SaLevel;
|
||||
target.UserAuthority = source.UserAuthority;
|
||||
target.ParentAuthority = source.ParentAuthority;
|
||||
target.ForbiddenPage = source.ForbiddenPage;
|
||||
target.Mobile = source.Mobile;
|
||||
target.UserVersion = source.UserVersion;
|
||||
target.UserVersionString = source.UserVersionString;
|
||||
target.AuthorizedAmount = source.AuthorizedAmount;
|
||||
target.Points = source.Points;
|
||||
target.ShopPointsPerMonth = source.ShopPointsPerMonth;
|
||||
target.Balance = source.Balance;
|
||||
target.RechargeAmountTotal = source.RechargeAmountTotal;
|
||||
target.PostagePerOrder = source.PostagePerOrder;
|
||||
target.RefundPostagePerOrder = source.RefundPostagePerOrder;
|
||||
target.GiftOemAmountPerOrder = source.GiftOemAmountPerOrder;
|
||||
target.OemId = source.OemId;
|
||||
target.OemName = source.OemName;
|
||||
target.IsOemOwner = source.IsOemOwner;
|
||||
target.EndDate = source.EndDate;
|
||||
target.QqGroupNum = source.QqGroupNum;
|
||||
target.QqGroupUrl = source.QqGroupUrl;
|
||||
target.WechatUrl = source.WechatUrl;
|
||||
target.Pinduoduo = source.Pinduoduo;
|
||||
target.AlimamaDomain = source.AlimamaDomain;
|
||||
target.AlimamaPid = source.AlimamaPid;
|
||||
target.LockUserName = source.LockUserName;
|
||||
target.WeakPassword = source.WeakPassword;
|
||||
target.MessageInfo = source.MessageInfo;
|
||||
target.AgentAuth = source.AgentAuth;
|
||||
target.IsImport = source.IsImport;
|
||||
target.CardId = source.CardId;
|
||||
target.IsSa = source.IsSa;
|
||||
target.AddTime = source.AddTime;
|
||||
target.MdyTime = source.MdyTime;
|
||||
target.Notes = source.Notes;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Autofac;
|
||||
using MAX.Core;
|
||||
using MAX.Core.Infrastructure;
|
||||
using Store.Client;
|
||||
using Store.Framework.Tools;
|
||||
|
||||
namespace Store.Framework
|
||||
{
|
||||
public class Startup : IStartup
|
||||
{
|
||||
public int Priority => IntPriority.Normal;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
HardwareTool.GetMacCode();
|
||||
}
|
||||
|
||||
public void Register(ContainerBuilder builder)
|
||||
{
|
||||
//builder.RegisterType<ServiceConfigProvider>()
|
||||
// .As<IServiceConfigProvider>()
|
||||
// .SingleInstance();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Commons\" />
|
||||
<Folder Include="Mvvm\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Polly" Version="7.2.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\MAX.Framework\MAX.Framework.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="System.Management" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,188 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Store.Framework.ThreadManage
|
||||
{
|
||||
/// <summary>
|
||||
/// 线程管理
|
||||
/// </summary>
|
||||
public class ThreadManager
|
||||
{
|
||||
//private int _sleep;
|
||||
private Thread _listen;
|
||||
private List<WorkUnit> _actions = new List<WorkUnit>();
|
||||
private CancellationTokenSource cancellationToken = new CancellationTokenSource();
|
||||
private int _countThreads = 10;
|
||||
/// <summary>
|
||||
/// 间隔秒数
|
||||
/// </summary>
|
||||
public int Interval { get; set; } = 1;
|
||||
/// <summary>
|
||||
/// 线程数
|
||||
/// </summary>
|
||||
public int CountThreads
|
||||
{
|
||||
get => _countThreads;
|
||||
set
|
||||
{
|
||||
_countThreads = value;
|
||||
ThreadPool.SetMinThreads(_countThreads, _countThreads);
|
||||
ThreadPool.SetMaxThreads(_countThreads, _countThreads);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否完成状态
|
||||
/// </summary>
|
||||
public bool Completed { get; private set; }
|
||||
/// <summary>
|
||||
/// 正在运行的线程数量
|
||||
/// </summary>
|
||||
public int CountActiveThreads
|
||||
{
|
||||
get
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实例 默认线程10 间隔 1秒
|
||||
/// </summary>
|
||||
public ThreadManager()
|
||||
{
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="countThreads">线程数</param>
|
||||
public ThreadManager(int countThreads)
|
||||
{
|
||||
CountThreads = countThreads;
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="countThreads">线程数</param>
|
||||
/// <param name="frequency">间隔时间</param>
|
||||
public ThreadManager(int countThreads, int interval)
|
||||
{
|
||||
CountThreads = countThreads;
|
||||
Interval = interval;
|
||||
}
|
||||
|
||||
private void Listen()
|
||||
{
|
||||
Completed = false;
|
||||
cancellationToken = new CancellationTokenSource();
|
||||
_listen = new Thread(() =>
|
||||
{
|
||||
while (!cancellationToken.IsCancellationRequested && _actions.Count > 0)
|
||||
{
|
||||
DateTime time = DateTime.Now;
|
||||
int countCompeleted = 0;
|
||||
for (int i = 0; i < _actions.Count; i++)
|
||||
{
|
||||
var action = _actions[i];
|
||||
if (action.Completed) countCompeleted++;
|
||||
if (!action.Completed && !action.IsWork && CountThreads > CountActiveThreads)
|
||||
//if (((time >= action.EndTime && action.Loop) || (!action.Completed && !action.Loop)) && !action.IsWork && CountThreads > CountActiveThreads)
|
||||
{
|
||||
action.IsWork = true;
|
||||
ThreadPool.QueueUserWorkItem(o =>
|
||||
{
|
||||
WorkUnit unit = (WorkUnit)o;
|
||||
unit.Action.Invoke(unit);
|
||||
unit.IsWork = false;
|
||||
unit.Completed = true; //!unit.Loop;
|
||||
}, action);
|
||||
}
|
||||
//int subTime = (int)(action.EndTime - time).TotalMilliseconds;
|
||||
//if (subTime < _sleep)
|
||||
//{
|
||||
// if (subTime < 0)
|
||||
// {
|
||||
// _sleep = 0;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// _sleep = subTime;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
Completed = countCompeleted == _actions.Count;
|
||||
//Thread.Sleep(_sleep);
|
||||
//_sleep = int.MaxValue;
|
||||
Thread.Sleep(1000 * Interval);
|
||||
}
|
||||
});
|
||||
_listen.IsBackground = true;
|
||||
_listen.Start();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clear all tasks.
|
||||
/// </summary>
|
||||
public void Clear() => _actions.Clear();
|
||||
/// <summary>
|
||||
/// Start Thread Manager.
|
||||
/// </summary>
|
||||
public async void Start()
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
//Console.WriteLine("123");
|
||||
Listen();
|
||||
}
|
||||
|
||||
);
|
||||
}
|
||||
/// <summary>
|
||||
/// Stop Thread Manager.
|
||||
/// </summary>
|
||||
public void Stop()
|
||||
{
|
||||
Completed = true;
|
||||
if (cancellationToken != null && !cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
cancellationToken.Cancel();
|
||||
cancellationToken.Dispose();
|
||||
}
|
||||
if (_listen != null)
|
||||
{
|
||||
_listen.Abort();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Waiting for work to finish
|
||||
/// </summary>
|
||||
public void Wait()
|
||||
{
|
||||
while (!Completed) { Thread.Sleep(100); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加任务
|
||||
/// </summary>
|
||||
/// <param name="action">委托任务</param>
|
||||
/// <param name="loop">Repeat the task.</param>
|
||||
public void AddTask(WorkAction action, object arg = null)
|
||||
{
|
||||
WorkUnit unit = new WorkUnit();
|
||||
unit.Action = action;
|
||||
unit.Completed = false;
|
||||
unit.Argument = arg;
|
||||
_actions.Add(unit);
|
||||
}
|
||||
|
||||
public void AddTask(Action action)
|
||||
{
|
||||
WorkUnit unit = new WorkUnit();
|
||||
unit.Action = a => action.Invoke();
|
||||
unit.Completed = false;
|
||||
_actions.Add(unit);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Store.Framework.ThreadManage
|
||||
{
|
||||
public static class ThreadManagerPool
|
||||
{
|
||||
private static ThreadManager _manager;
|
||||
|
||||
public static int CountThread { get; set; }
|
||||
public static int CountActiveThread { get => _manager.CountActiveThreads; }
|
||||
|
||||
static ThreadManagerPool()
|
||||
{
|
||||
_manager = new ThreadManager(CountThread);
|
||||
_manager.Start();
|
||||
}
|
||||
|
||||
public static void AddTask(WorkAction action)
|
||||
{
|
||||
_manager.AddTask(action, false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Store.Framework.ThreadManage
|
||||
{
|
||||
/// <summary>
|
||||
/// 工作委托
|
||||
/// </summary>
|
||||
/// <param name="unit"></param>
|
||||
public delegate void WorkAction(WorkUnit unit);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
/// <summary>
|
||||
/// Represents an instance of a task.
|
||||
/// </summary>
|
||||
namespace Store.Framework.ThreadManage
|
||||
{
|
||||
/// <summary>
|
||||
/// ¹¤×÷µ¥Ïî
|
||||
/// </summary>
|
||||
public class WorkUnit
|
||||
{
|
||||
internal bool IsWork { get; set; } = false;
|
||||
internal DateTime EndTime { get; set; } = DateTime.Now;
|
||||
internal WorkAction Action { get; set; }
|
||||
internal bool Completed { get; set; }
|
||||
internal object Argument { get; set; }
|
||||
|
||||
//public void Wait(int time)
|
||||
//{
|
||||
// EndTime = DateTime.Now.AddMilliseconds(time);
|
||||
// IsWork = false;
|
||||
//}
|
||||
|
||||
public T GetArg<T>()
|
||||
{
|
||||
return (T)Argument;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
using MAX.Core.Cryptography;
|
||||
using System;
|
||||
using System.Management;
|
||||
|
||||
namespace Store.Framework.Tools
|
||||
{
|
||||
/// <summary>
|
||||
/// 系统信息
|
||||
/// </summary>
|
||||
public class HardwareTool
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 机器硬件码
|
||||
/// </summary>
|
||||
public static string HardWareCode { get; private set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 机器硬件码新版
|
||||
/// </summary>
|
||||
public static string HardWareCodeNew { get; private set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 机器硬件码v3
|
||||
/// </summary>
|
||||
public static string HardWareCodeV3 { get; private set; } = "";
|
||||
/// <summary>
|
||||
/// 硬件信息
|
||||
/// </summary>
|
||||
public static string MacInfo { get; private set; } = "";
|
||||
/// <summary>
|
||||
/// 获取机器码
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
internal static void GetMacCode()
|
||||
{
|
||||
|
||||
string sHostName = GethostName();
|
||||
string sCpuSn = GetCPUSerialNumber();
|
||||
string sDiskSn = GetDiskSerialNumber();
|
||||
string sDiskSnNew = GetFirstDiskSnAndSignature();
|
||||
string sOs = Environment.OSVersion.VersionString;
|
||||
|
||||
HardWareCode = MD5Helper.Md5_32(sHostName + sCpuSn + sDiskSn + sOs);
|
||||
HardWareCodeNew = MD5Helper.Md5_32(sCpuSn + sDiskSn);
|
||||
HardWareCodeV3 = MD5Helper.Md5_32(sCpuSn + sDiskSnNew);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 取机器名
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private static string GethostName()
|
||||
{
|
||||
string sHostName = System.Net.Dns.GetHostName();
|
||||
MacInfo += "|HostName:" + sHostName;
|
||||
return sHostName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取cpu序列号
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private static string GetCPUSerialNumber()
|
||||
{
|
||||
string cpuSerialNumber = string.Empty;
|
||||
ManagementClass mc = new ManagementClass("Win32_Processor");
|
||||
ManagementObjectCollection moc = mc.GetInstances();
|
||||
foreach (ManagementObject mo in moc)
|
||||
{
|
||||
cpuSerialNumber = mo["ProcessorId"].ToString();
|
||||
MacInfo += "|CPU:" + mo["ProcessorId"].ToString() + "," + mo.Properties["Manufacturer"].Value.ToString().Trim() + "," + mo.Properties["Name"].Value.ToString().Trim();
|
||||
break;
|
||||
}
|
||||
mc.Dispose();
|
||||
moc.Dispose();
|
||||
return cpuSerialNumber;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取硬盘序列号
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private static string GetDiskSerialNumber()
|
||||
{
|
||||
ManagementObjectSearcher mos = new ManagementObjectSearcher();
|
||||
mos.Query = new SelectQuery("Win32_DiskDrive", "", new string[] { "PNPDeviceID", "Signature" });
|
||||
ManagementObjectCollection myCollection = mos.Get();
|
||||
ManagementObjectCollection.ManagementObjectEnumerator em = myCollection.GetEnumerator();
|
||||
em.MoveNext();
|
||||
ManagementBaseObject moo = em.Current;
|
||||
string id = "";
|
||||
if (moo.Properties["signature"].Value != null)
|
||||
{
|
||||
id = moo.Properties["signature"].Value.ToString().Trim();
|
||||
}
|
||||
MacInfo += "|DiskSignature:" + id;
|
||||
return id;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取硬盘序列号-New
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private static string GetFirstDiskSnAndSignature()
|
||||
{
|
||||
ManagementObjectSearcher mos = new ManagementObjectSearcher();
|
||||
mos.Query = new SelectQuery("Win32_DiskDrive", "Index=0", new string[] { "PNPDeviceID", "SerialNumber", "Signature" });
|
||||
ManagementObjectCollection myCollection = mos.Get();
|
||||
ManagementObjectCollection.ManagementObjectEnumerator em = myCollection.GetEnumerator();
|
||||
em.MoveNext();
|
||||
ManagementBaseObject moo = em.Current;
|
||||
string sn = "";
|
||||
string signature = "";
|
||||
if (moo.Properties["SerialNumber"].Value != null)
|
||||
{
|
||||
sn = moo.Properties["SerialNumber"].Value.ToString().Trim();
|
||||
}
|
||||
if (moo.Properties["Signature"].Value != null)
|
||||
{
|
||||
signature = moo.Properties["Signature"].Value.ToString().Trim();
|
||||
if (signature.Equals("0"))
|
||||
{
|
||||
signature = "";
|
||||
}
|
||||
}
|
||||
MacInfo += "|Disk:" + sn + "," + signature + "," + moo.Properties["PNPDeviceID"].Value.ToString().Trim();
|
||||
return sn + signature;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取网卡硬件地址
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private static string GetMoAddress()
|
||||
{
|
||||
string MoAddress = " ";
|
||||
using (ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration"))
|
||||
{
|
||||
ManagementObjectCollection moc2 = mc.GetInstances();
|
||||
foreach (ManagementObject mo in moc2)
|
||||
{
|
||||
//if ((bool)mo["IPEnabled"] == true)
|
||||
MoAddress = mo["MacAddress"].ToString();
|
||||
mo.Dispose();
|
||||
}
|
||||
}
|
||||
return MoAddress.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user