diff --git a/BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs b/BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs index 70009436..86cca9d9 100644 --- a/BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs +++ b/BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs @@ -20,6 +20,12 @@ namespace BBWY.Client.Models public string AppToken { get; set; } + public string AppKey2 { get; set; } + + public string AppSecret2 { get; set; } + + public string AppToken2 { get; set; } + public IList PurchaseList { get; set; } public string ManagePwd { get; set; } diff --git a/BBWY.Client/Models/Shop/Shop.cs b/BBWY.Client/Models/Shop/Shop.cs index ca2d2e74..0ebec5fa 100644 --- a/BBWY.Client/Models/Shop/Shop.cs +++ b/BBWY.Client/Models/Shop/Shop.cs @@ -29,6 +29,12 @@ namespace BBWY.Client.Models public string AppToken { get; set; } + public string AppKey2 { get; set; } + + public string AppSecret2 { get; set; } + + public string AppToken2 { get; set; } + public string ShopName { get => shopName; set { Set(ref shopName, value); } } public IList PurchaseAccountList { get; set; } diff --git a/BBWY.Client/ViewModels/MainViewModel.cs b/BBWY.Client/ViewModels/MainViewModel.cs index 4bdd34d1..9819ef2e 100644 --- a/BBWY.Client/ViewModels/MainViewModel.cs +++ b/BBWY.Client/ViewModels/MainViewModel.cs @@ -250,6 +250,9 @@ namespace BBWY.Client.ViewModels shop.SiNanPolicyLevel = s2.SiNanPolicyLevel; shop.SiNanDingDingKey = s2.SiNanDingDingKey; shop.SiNanDingDingWebHook = s2.SiNanDingDingWebHook; + shop.AppKey2 = s2.AppKey2; + shop.AppSecret2 = s2.AppSecret2; + shop.AppToken2 = s2.AppToken2; } } } diff --git a/BBWY.Server.Business/Vender/VenderBusiness.cs b/BBWY.Server.Business/Vender/VenderBusiness.cs index f2977973..d1e3c5af 100644 --- a/BBWY.Server.Business/Vender/VenderBusiness.cs +++ b/BBWY.Server.Business/Vender/VenderBusiness.cs @@ -54,22 +54,53 @@ namespace BBWY.Server.Business public string AcceptJDShopToken(JDShopToken jDShopToken) { + string appKey, appSecret; + Enums.AppKeyType appKeyType; + if (jDShopToken.State == "merp_1034059314253266944") + { + //订单Key + appKey = "120EA9EC65AB017567D78CC1139EEEA5"; + appSecret = "8a42bc2301e8439b896e99f5475e0a9b"; + appKeyType = Enums.AppKeyType.订单管理; + } + else if (jDShopToken.State == "merp_1058051655896924160") + { + //商品Key + appKey = "E1AA9247D5583A6D87449CE6AB290185"; + appSecret = "e479558ddd9e40f8929cfc00c6cbbc9c"; + appKeyType = Enums.AppKeyType.商品管理; + } + else + { + throw new BusinessException($"不识别的state {jDShopToken.State}"); + } + var venderResponse = GetVenderInfo(new PlatformRequest() { - AppKey = "120EA9EC65AB017567D78CC1139EEEA5", - AppSecret = "8a42bc2301e8439b896e99f5475e0a9b", + AppKey = appKey, + AppSecret = appSecret, AppToken = jDShopToken.AccessToken, Platform = Enums.Platform.京东 }); - _ = restApiService.SendRequest(globalConfig.MdsApi, "/TaskList/Shop/UpdateShop", new + //_ = restApiService.SendRequest(globalConfig.MdsApi, "/TaskList/Shop/UpdateShop", new + //{ + // venderResponse.ShopName, + // venderResponse.ShopId, + // ShopType = venderResponse.ColType, + // AppToken = jDShopToken.AccessToken, + // venderResponse.VenderId + //}, new Dictionary() { { "qy", "qy" } }, HttpMethod.Post); + + var shop = freeSqlMultiDBManager.MDSfsql.Select().Where(s => s.ShopName == venderResponse.ShopName).ToOne(); + if (shop == null) + throw new BusinessException($"未找到店铺 {venderResponse.ShopName}"); + + if (appKeyType == Enums.AppKeyType.订单管理) { - venderResponse.ShopName, - venderResponse.ShopId, - ShopType = venderResponse.ColType, - AppToken = jDShopToken.AccessToken, - venderResponse.VenderId - }, new Dictionary() { { "qy", "qy" } }, HttpMethod.Post); + //freeSqlMultiDBManager.MDSfsql.Update(shop.Id) + } + return JsonConvert.SerializeObject(jDShopToken); } @@ -180,6 +211,9 @@ namespace BBWY.Server.Business s.AppKey, s.AppSecret, s.AppToken, + s.AppKey2, + s.AppSecret2, + s.AppToken2, s.ManagePwd, s.PlatformCommissionRatio, s.PlatformId, @@ -207,6 +241,9 @@ namespace BBWY.Server.Business AppKey = string.IsNullOrEmpty(x.AppKey) ? "120EA9EC65AB017567D78CC1139EEEA5" : x.AppKey, AppSecret = string.IsNullOrEmpty(x.AppSecret) ? "8a42bc2301e8439b896e99f5475e0a9b" : x.AppSecret, AppToken = x.AppToken, + AppKey2 = x.AppKey2, + AppSecret2 = x.AppSecret2, + AppToken2 = x.AppToken2, ManagePwd = x.ManagePwd, PlatformId = (Enums.Platform)x.PlatformId, PlatformCommissionRatio = x.PlatformCommissionRatio, @@ -236,6 +273,7 @@ namespace BBWY.Server.Business ShopId = pa.ShopId, PurchasePlatformId = (Enums.Platform)int.Parse(pa.PurchasePlatformId) }); + foreach (var d in departmentList) { foreach (var s in d.ShopList) diff --git a/BBWY.Server.Model/Db/Mds/Shops.cs b/BBWY.Server.Model/Db/Mds/Shops.cs index 61656471..e3557801 100644 --- a/BBWY.Server.Model/Db/Mds/Shops.cs +++ b/BBWY.Server.Model/Db/Mds/Shops.cs @@ -32,6 +32,24 @@ namespace BBWY.Server.Model.Db.Mds public string AppToken { get; set; } + /// + /// 店铺Key 暂定商品管理Key + /// + + public string AppKey2 { get; set; } + + /// + /// 店铺Secret 暂定商品管理Secret + /// + + public string AppSecret2 { get; set; } + + /// + /// 店铺Token + /// + + public string AppToken2 { get; set; } + /// /// 创建时间 /// diff --git a/BBWY.Server.Model/Dto/Response/Vender/ShopResponse.cs b/BBWY.Server.Model/Dto/Response/Vender/ShopResponse.cs index 112af8ab..17ff7c4a 100644 --- a/BBWY.Server.Model/Dto/Response/Vender/ShopResponse.cs +++ b/BBWY.Server.Model/Dto/Response/Vender/ShopResponse.cs @@ -30,12 +30,18 @@ namespace BBWY.Server.Model.Dto public string AppToken { get; set; } + public string AppKey2 { get; set; } + + public string AppSecret2 { get; set; } + + public string AppToken2 { get; set; } + public string ManagePwd { get; set; } public decimal? PlatformCommissionRatio { get; set; } public IList PurchaseList { get; set; } - + /// /// SKU库存安全周转天数 /// diff --git a/BBWY.Server.Model/Enums.cs b/BBWY.Server.Model/Enums.cs index 0e66d157..072517e8 100644 --- a/BBWY.Server.Model/Enums.cs +++ b/BBWY.Server.Model/Enums.cs @@ -245,5 +245,13 @@ 进行中 = 1, 已完成 = 2 } + + /// + /// AppKey类型 全类型 = 0, 订单管理 = 1, 商品管理 = 2 + /// + public enum AppKeyType + { + 全类型 = 0, 订单管理 = 1, 商品管理 = 2 + } } } diff --git a/BBWY.Test/Program.cs b/BBWY.Test/Program.cs index 33623dcb..cea8cf03 100644 --- a/BBWY.Test/Program.cs +++ b/BBWY.Test/Program.cs @@ -1,4 +1,6 @@ using Jd.Api; +using Jd.Api.Request; +using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; @@ -35,15 +37,14 @@ namespace BBWY.Test //}).ToList(); - //10023500913672 含赠品SPU - //10022515718131 需要进行赠品上架的SPU IJdClient client = GetJdClient(appkey, appSecret); var test1 = new JDProductAPITest(); test1.GetPromotionById(client, token); - //test1.ShangJiaTest(client, token); - //test1.修改属性别名(client, token); - //test1.QueryTouTu(client,token); + + var venderJDResponse = client.Execute(new SellerVenderInfoGetRequest(), token, DateTime.Now.ToLocalTime()); + Console.WriteLine(JsonConvert.SerializeObject(venderJDResponse)); + Console.ReadKey(); } }