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.
56 lines
2.4 KiB
56 lines
2.4 KiB
using BBWY.Common.Http;
|
|
using BBWY.Common.Models;
|
|
using BBWY.Server.Model;
|
|
using BBWY.Server.Model.Dto;
|
|
using Microsoft.Extensions.Options;
|
|
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net.Http;
|
|
|
|
namespace BBWY.Server.Business
|
|
{
|
|
public class MDSBusiness : IDenpendency
|
|
{
|
|
private RestApiService restApiService;
|
|
private GlobalConfig globalConfig;
|
|
private IDictionary<string, string> mdsApiHeader;
|
|
|
|
public MDSBusiness(RestApiService restApiService, IOptions<GlobalConfig> options)
|
|
{
|
|
this.restApiService = restApiService;
|
|
this.globalConfig = options.Value;
|
|
mdsApiHeader = new Dictionary<string, string>() {
|
|
{ "qy","qy"}
|
|
};
|
|
}
|
|
|
|
public ShopResponse GetShopInfoByShopId(long shopId)
|
|
{
|
|
var shopResult = restApiService.SendRequest(globalConfig.MdsApi, "/TaskList/Shop/GetShopsByShopId", $"shopId={shopId}", mdsApiHeader, HttpMethod.Get, enableRandomTimeStamp: true);
|
|
if (shopResult.StatusCode != System.Net.HttpStatusCode.OK)
|
|
throw new Exception($"SyncOrder 获取店铺信息失败 shopId:{shopId} httpCode:{shopResult.StatusCode} httpContent:{shopResult.Content}");
|
|
|
|
var shopResponseJToken = JToken.Parse(shopResult.Content);
|
|
if (shopResponseJToken.Value<bool>("Success") != true)
|
|
throw new Exception($"SyncOrder 获取店铺信息失败 shopId:{shopId} ErrorMsg:{shopResponseJToken.Value<string>("Msg")}");
|
|
|
|
var shopJToken = shopResponseJToken["Data"].FirstOrDefault();
|
|
var shopResponse = new ShopResponse()
|
|
{
|
|
AppKey = shopJToken.Value<string>("AppKey"),
|
|
AppSecret = shopJToken.Value<string>("AppSecret"),
|
|
AppToken = shopJToken.Value<string>("AppToken"),
|
|
PlatformId = (Enums.Platform)shopJToken.Value<int>("PlatformId"),
|
|
ShopType = shopJToken.Value<string>("ShopType"),
|
|
ShopId = shopId.ToString(),
|
|
ShopName = shopJToken.Value<string>("ShopName"),
|
|
ManagePwd = shopJToken.Value<string>("ManagePwd")
|
|
};
|
|
try { shopResponse.PlatformCommissionRatio = shopJToken.Value<decimal?>("PlatformCommissionRatio"); }
|
|
catch { }
|
|
return shopResponse;
|
|
}
|
|
}
|
|
}
|
|
|