You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
106 lines
4.7 KiB
106 lines
4.7 KiB
using Newtonsoft.Json.Linq;
|
|
using QYMessageCenter.Client.Models;
|
|
using QYMessageCenter.Common.Http;
|
|
using QYMessageCenter.Common.Models;
|
|
using System.Net.Http;
|
|
|
|
namespace QYMessageCenter.Client.APIServices
|
|
{
|
|
public class MdsApiService : BaseApiService, IDenpendency
|
|
{
|
|
private string mdsApi = "http://mdsapi.qiyue666.com";
|
|
|
|
public MdsApiService(RestApiService restApiService, GlobalContext globalContext) : base(restApiService, globalContext)
|
|
{
|
|
|
|
}
|
|
|
|
public ApiResponse<MDSUserResponse> GetUserInfo(string userToken)
|
|
{
|
|
return SendRequest<MDSUserResponse>(mdsApi,
|
|
"/TaskList/User/GetUserInfo",
|
|
null,
|
|
new Dictionary<string, string>()
|
|
{
|
|
{ "Authorization", $"Bearer {userToken}" }
|
|
}, HttpMethod.Get);
|
|
}
|
|
|
|
|
|
public ApiResponse<IList<Department>> GetShopDetailList()
|
|
{
|
|
var response = new ApiResponse<IList<Department>>();
|
|
var response2 = SendRequest<JArray>(mdsApi, "TaskList/UserDepartment/GetShopDetailList", null, null, HttpMethod.Get);
|
|
if (!response.Success)
|
|
{
|
|
response.Code = response2.Code;
|
|
response.Msg = response2.Msg;
|
|
return response;
|
|
}
|
|
|
|
response.Data = new List<Department>();
|
|
foreach (var jDepartment in response2.Data)
|
|
{
|
|
var jayShops = jDepartment.Value<JArray>("ShopList");
|
|
if (jayShops == null || !jayShops.HasValues)
|
|
continue; //排除空店部门
|
|
var d = new Department()
|
|
{
|
|
Id = jDepartment.Value<string>("Id"),
|
|
Name = jDepartment.Value<string>("DepartmentName")
|
|
};
|
|
response.Data.Add(d);
|
|
foreach (var jShop in jayShops)
|
|
{
|
|
var shopId = jShop.Value<long?>("ShopId");
|
|
if (shopId == null || string.IsNullOrEmpty(jShop.Value<string>("AppToken")))
|
|
continue; //排除未授权
|
|
try
|
|
{
|
|
var jayAccounts = jShop.Value<JArray>("AccountList");
|
|
if ((jayAccounts == null || !jayAccounts.HasValues) && d.ShopList.Count(s => s.ShopId == shopId) > 0)
|
|
{
|
|
continue;
|
|
}
|
|
var shop = new Shop()
|
|
{
|
|
ShopId = shopId.Value,
|
|
AppKey = jShop.Value<string>("AppKey"),
|
|
AppSecret = jShop.Value<string>("AppSecret"),
|
|
AppToken = jShop.Value<string>("AppToken"),
|
|
ManagePwd = jShop.Value<string>("ManagePwd"),
|
|
Platform = (Platform)jShop.Value<int>("PlatformId"),
|
|
PlatformCommissionRatio = jShop.Value<decimal?>("PlatformCommissionRatio") ?? 0.05M,
|
|
ShopName = jShop.Value<string>("ShopName"),
|
|
VenderType = jShop.Value<string>("ShopType"),
|
|
TeamId = jShop.Value<string>("TeamId")
|
|
};
|
|
d.ShopList.Add(shop);
|
|
|
|
shop.PurchaseAccountList = new List<PurchaseAccount>();
|
|
foreach (var jPurchaseAccount in jayAccounts)
|
|
{
|
|
shop.PurchaseAccountList.Add(new PurchaseAccount()
|
|
{
|
|
Id = jPurchaseAccount.Value<long>("Id"),
|
|
AccountName = jPurchaseAccount.Value<string>("AccountName"),
|
|
AppKey = jPurchaseAccount.Value<string>("AppKey"),
|
|
AppSecret = jPurchaseAccount.Value<string>("AppSecret"),
|
|
AppToken = jPurchaseAccount.Value<string>("AppToken"),
|
|
ShopId = shop.ShopId,
|
|
PurchasePlatformId = (Platform)jPurchaseAccount.Value<int>("AppPlatformId")
|
|
});
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine(jShop.ToString());
|
|
throw;
|
|
}
|
|
}
|
|
}
|
|
|
|
return response;
|
|
}
|
|
}
|
|
}
|
|
|