7 changed files with 261 additions and 37 deletions
@ -0,0 +1,52 @@ |
|||||
|
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(); |
||||
|
return new ShopResponse() |
||||
|
{ |
||||
|
AppKey = shopJToken.Value<string>("AppKey"), |
||||
|
AppSecret = shopJToken.Value<string>("AppSecret"), |
||||
|
AppToken = shopJToken.Value<string>("AppToken"), |
||||
|
Platform = (Enums.Platform)shopJToken.Value<int>("PlatformId"), |
||||
|
VenderType = shopJToken.Value<string>("ShopType"), |
||||
|
ShopId = shopId, |
||||
|
Name = shopJToken.Value<string>("ShopName") |
||||
|
}; |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,61 @@ |
|||||
|
using FreeSql.DataAnnotations; |
||||
|
using System; |
||||
|
|
||||
|
namespace BBWY.Server.Model.Db |
||||
|
{ |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 采购账号表
|
||||
|
/// </summary>
|
||||
|
[Table(Name = "purchaseaccount", DisableSyncStructure = true)] |
||||
|
public partial class PurchaseAccount |
||||
|
{ |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 主键
|
||||
|
/// </summary>
|
||||
|
[Column(StringLength = 50, IsPrimary = true, IsNullable = false)] |
||||
|
public string Id { get; set; } |
||||
|
|
||||
|
|
||||
|
public string AccountName { get; set; } |
||||
|
|
||||
|
|
||||
|
public string AppKey { get; set; } |
||||
|
|
||||
|
|
||||
|
public string AppSecret { get; set; } |
||||
|
|
||||
|
|
||||
|
public string AppToken { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 创建时间
|
||||
|
/// </summary>
|
||||
|
[Column(DbType = "datetime")] |
||||
|
public DateTime CreateTime { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 创建人Id
|
||||
|
/// </summary>
|
||||
|
[Column(StringLength = 50)] |
||||
|
public string CreatorId { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 否已删除
|
||||
|
/// </summary>
|
||||
|
[Column(DbType = "tinyint(4)")] |
||||
|
public sbyte Deleted { get; set; } |
||||
|
|
||||
|
[Column(DbType = "int(1)", MapType = typeof(int?))] |
||||
|
public Enums.Platform? PurchasePlatformId { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 采购账号归属店铺ID
|
||||
|
/// </summary>
|
||||
|
[Column(DbType = "bigint(1)")] |
||||
|
public long? ShopId { get; set; } |
||||
|
|
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,30 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
using static BBWY.Server.Model.Enums; |
||||
|
|
||||
|
namespace BBWY.Server.Model.Dto |
||||
|
{ |
||||
|
public class ShopResponse |
||||
|
{ |
||||
|
public long ShopId { get; set; } |
||||
|
|
||||
|
public string Name { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 商家类型
|
||||
|
/// </summary>
|
||||
|
public string VenderType { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 店铺平台
|
||||
|
/// </summary>
|
||||
|
public Platform Platform { get; set; } |
||||
|
|
||||
|
public string AppKey { get; set; } |
||||
|
|
||||
|
public string AppSecret { get; set; } |
||||
|
|
||||
|
public string AppToken { get; set; } |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue