增加 新版本登录请求
This commit is contained in:
1 parent
afeb7e5d90
commit
b28940c02d
10 files changed
+865
-592
No files matched your search
@@ -6,7 +6,7 @@ using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Work.Store.Api;
|
||||
using System.Threading.Tasks;
|
||||
using Work.Api.Wx;
|
||||
|
||||
@@ -17,35 +17,13 @@ namespace Work.Services
|
||||
/// </summary>
|
||||
public class CloudGoodsService
|
||||
{
|
||||
private static string ServerUrl = "http://103.90.155.78:9001";
|
||||
static CloudGoodsService()
|
||||
{
|
||||
if (EnvironmentHelper.IsDevelopment)
|
||||
{
|
||||
ServerUrl = "http://localhost:14312";
|
||||
}
|
||||
}
|
||||
public static async Task<PageData<CloudGoods>> GetGoods(GoodsSearchRequest request)
|
||||
{
|
||||
var html = await GetHtml.PostJsonAsync(ServerUrl + "/api/CloudGoods/SearchGoods", request);
|
||||
|
||||
var ret = JsonConvert.DeserializeObject<Result<PageData<CloudGoods>>>(html);
|
||||
if (ret.Code != 200)
|
||||
{
|
||||
throw new Exception(ret.Msg);
|
||||
}
|
||||
return ret.Data;
|
||||
return await StoreApiClient.Instance.CloudGoods.GetGoods(request);
|
||||
}
|
||||
public static string GetGoodsDetail(long goodsId)
|
||||
{
|
||||
var html = GetHtml.PostJson(ServerUrl + $"/api/CloudGoods/GetGoodsRawData?goodsId={goodsId}", "");
|
||||
|
||||
var ret = JsonConvert.DeserializeObject<Result<string>>(html);
|
||||
if (ret.Code != 200)
|
||||
{
|
||||
throw new Exception(ret.Msg);
|
||||
}
|
||||
return ret.Data;
|
||||
return StoreApiClient.Instance.CloudGoods.GetGoodsDetail(goodsId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -338,17 +316,7 @@ namespace Work.Services
|
||||
throw new ArgumentException("违规商品列表不能包含空项。", nameof(items));
|
||||
}
|
||||
|
||||
var html = await GetHtml.PostJsonAsync(ServerUrl + "/api/CloudGoods/ReportViolations", items, timeOut: 5);
|
||||
var ret = JsonConvert.DeserializeObject<Result<List<ReportGoodsViolationResult>>>(html);
|
||||
if (ret == null)
|
||||
{
|
||||
throw new Exception("批量上报违规商品返回为空。");
|
||||
}
|
||||
if (ret.Code != 200)
|
||||
{
|
||||
throw new Exception(ret.Msg);
|
||||
}
|
||||
return ret.Data ?? throw new Exception("批量上报违规商品返回数据为空。");
|
||||
return await StoreApiClient.Instance.CloudGoods.ReportViolations(items);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -361,17 +329,7 @@ namespace Work.Services
|
||||
throw new ArgumentNullException(nameof(goodsIds));
|
||||
}
|
||||
|
||||
var html = GetHtml.PostJson(ServerUrl + "/api/CloudGoods/GetViolationStatus", goodsIds, timeOut: 5);
|
||||
var ret = JsonConvert.DeserializeObject<Result<List<GoodsViolationStatus>>>(html);
|
||||
if (ret == null)
|
||||
{
|
||||
throw new Exception("批量查询商品违规状态返回为空。");
|
||||
}
|
||||
if (ret.Code != 200)
|
||||
{
|
||||
throw new Exception(ret.Msg);
|
||||
}
|
||||
return ret.Data ?? throw new Exception("批量查询商品违规状态返回数据为空。");
|
||||
return StoreApiClient.Instance.CloudGoods.GetViolationStatus(goodsIds);
|
||||
}
|
||||
|
||||
/// <summary>逐原因记录店铺动作。日志请求失败不能改变剔除决定或中断后续下架。</summary>
|
||||
@@ -424,23 +382,13 @@ namespace Work.Services
|
||||
{
|
||||
if (requests == null || requests.Count == 0 || requests.Any(item => item == null))
|
||||
throw new ArgumentException("请提供有效的违规日志。", nameof(requests));
|
||||
var html = await GetHtml.PostJsonAsync(ServerUrl + "/api/CloudGoods/RecordViolationLog", requests, timeOut: 5);
|
||||
var ret = JsonConvert.DeserializeObject<Result>(html) ?? throw new Exception("记录违规日志返回为空。");
|
||||
if (ret.Code != 200)
|
||||
throw new Exception(ret.Msg);
|
||||
await StoreApiClient.Instance.CloudGoods.RecordViolationLogs(requests);
|
||||
}
|
||||
|
||||
/// <summary>读取日志筛选和显示使用的违规原因字典。</summary>
|
||||
public static async Task<List<ViolationReason>> GetViolationReasons()
|
||||
{
|
||||
using (var web = new System.Net.WebClient { Encoding = Encoding.UTF8 })
|
||||
{
|
||||
var html = await web.DownloadStringTaskAsync(ServerUrl + "/api/CloudGoods/GetViolationReasons");
|
||||
var ret = JsonConvert.DeserializeObject<Result<List<ViolationReason>>>(html);
|
||||
if (ret?.Code != 200 || ret.Data == null)
|
||||
throw new Exception(ret?.Msg ?? "查询违规类型返回为空。");
|
||||
return ret.Data;
|
||||
}
|
||||
return await StoreApiClient.Instance.CloudGoods.GetViolationReasons();
|
||||
}
|
||||
|
||||
public class ViolationReason
|
||||
@@ -457,12 +405,7 @@ namespace Work.Services
|
||||
if (shopIds == null || shopIds.Length == 0 || shopIds.Any(string.IsNullOrWhiteSpace))
|
||||
throw new ArgumentException("请提供有效的店铺编号。", nameof(shopIds));
|
||||
var request = new GetViolationLogsRequest { ShopIds = shopIds, GoodsId = goodsId, BeforeId = beforeId, Size = size };
|
||||
var html = await GetHtml.PostJsonAsync(ServerUrl + "/api/CloudGoods/GetViolationLogs", request, timeOut: 5);
|
||||
var ret = JsonConvert.DeserializeObject<Result<List<GoodsViolationLogEntity>>>(html)
|
||||
?? throw new Exception("查询违规日志返回为空。");
|
||||
if (ret.Code != 200)
|
||||
throw new Exception(ret.Msg);
|
||||
return ret.Data ?? throw new Exception("查询违规日志返回数据为空。");
|
||||
return await StoreApiClient.Instance.CloudGoods.GetViolationLogs(request);
|
||||
}
|
||||
|
||||
#region user
|
||||
@@ -475,14 +418,7 @@ namespace Work.Services
|
||||
public static async Task<PageData<CloudGoods>> SearchFavorites(UserFavoritesGoodsSearchRequest request)
|
||||
{
|
||||
request.UserName = GetUserName();
|
||||
var html = await GetHtml.PostJsonAsync(ServerUrl + "/api/CloudGoods/SearchFavorites", request);
|
||||
|
||||
var ret = JsonConvert.DeserializeObject<Result<PageData<CloudGoods>>>(html);
|
||||
if (ret.Code != 200)
|
||||
{
|
||||
throw new Exception(ret.Msg);
|
||||
}
|
||||
return ret.Data;
|
||||
return await StoreApiClient.Instance.CloudGoods.SearchFavorites(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -494,18 +430,7 @@ namespace Work.Services
|
||||
|
||||
public static async Task<int> Favorite(List<long> goodsIds)
|
||||
{
|
||||
var html = await GetHtml.PostJsonAsync(ServerUrl + $"/api/CloudGoods/AddFavorite", new
|
||||
{
|
||||
UserName = GetUserName(),
|
||||
GoodsIds = goodsIds,
|
||||
});
|
||||
|
||||
var ret = JsonConvert.DeserializeObject<Result<int>>(html);
|
||||
if (ret.Code != 200)
|
||||
{
|
||||
throw new Exception(ret.Msg);
|
||||
}
|
||||
return ret.Data;
|
||||
return await StoreApiClient.Instance.CloudGoods.Favorite(GetUserName(), goodsIds);
|
||||
}
|
||||
/// <summary>
|
||||
/// 取消收藏
|
||||
@@ -516,18 +441,7 @@ namespace Work.Services
|
||||
|
||||
public static async Task<int> RemoveFavorites(List<long> goodsIds)
|
||||
{
|
||||
var html = await GetHtml.PostJsonAsync(ServerUrl + $"/api/CloudGoods/RemoveFavorites", new
|
||||
{
|
||||
UserName = GetUserName(),
|
||||
GoodsIds = goodsIds,
|
||||
});
|
||||
|
||||
var ret = JsonConvert.DeserializeObject<Result<int>>(html);
|
||||
if (ret.Code != 200)
|
||||
{
|
||||
throw new Exception(ret.Msg);
|
||||
}
|
||||
return ret.Data;
|
||||
return await StoreApiClient.Instance.CloudGoods.RemoveFavorites(GetUserName(), goodsIds);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
Reference in new issue
Block a user