diff --git a/BBWY.Client/APIServices/BaseApiService.cs b/BBWY.Client/APIServices/BaseApiService.cs index 2c8f72ae..2234c1f0 100644 --- a/BBWY.Client/APIServices/BaseApiService.cs +++ b/BBWY.Client/APIServices/BaseApiService.cs @@ -37,7 +37,7 @@ namespace BBWY.Client.APIServices if (!headers.ContainsKey("ClientVersion")) headers.Add("ClientVersion", "1.0.0.0"); if (!headers.ContainsKey("Authorization") && !string.IsNullOrEmpty(globalContext.UserToken)) - headers.Add("Authorization", $"Bearer {globalContext.User.Token}"); + headers.Add("Authorization", $"Bearer {globalContext.UserToken}"); if (!headers.ContainsKey("qy")) headers.Add("qy", "qy"); diff --git a/BBWY.Client/APIServices/MdsApiService.cs b/BBWY.Client/APIServices/MdsApiService.cs index 3c918089..8a6d32e5 100644 --- a/BBWY.Client/APIServices/MdsApiService.cs +++ b/BBWY.Client/APIServices/MdsApiService.cs @@ -1,6 +1,8 @@ using BBWY.Client.Models; using BBWY.Common.Http; using BBWY.Common.Models; +using Newtonsoft.Json.Linq; +using System; using System.Collections.Generic; using System.Net.Http; @@ -24,9 +26,83 @@ namespace BBWY.Client.APIServices }, HttpMethod.Get); } - public ApiResponse> GetShopsByUserTeam(long userId) + + + //public ApiResponse> GetShopsByUserTeam(long userId) + //{ + // return SendRequest>(globalContext.MDSApiHost, "TaskList/Shop/GetShopsByUserTeam", $"userId={userId}", null, System.Net.Http.HttpMethod.Get); + //} + + public ApiResponse> GetShopDetailList() { - return SendRequest>(globalContext.MDSApiHost, "TaskList/Shop/GetShopsByUserTeam", $"userId={userId}", null, System.Net.Http.HttpMethod.Get); + var response = new ApiResponse>(); + var response2 = SendRequest(globalContext.MDSApiHost, "TaskList/UserDepartment/GetShopDetailList", null, null, HttpMethod.Get); + if (!response.Success) + { + response.Code = response2.Code; + response.Msg = response2.Msg; + return response; + } + + response.Data = new List(); + foreach (var jDepartment in response2.Data) + { + var jayShops = jDepartment.Value("ShopList"); + if (jayShops == null || !jayShops.HasValues) + continue; //排除空店部门 + var d = new Department() + { + Id = jDepartment.Value("Id"), + Name = jDepartment.Value("DepartmentName") + }; + response.Data.Add(d); + foreach (var jShop in jayShops) + { + if (jShop.Value("ShopId") == null || string.IsNullOrEmpty(jShop.Value("AppToken"))) + continue; //排除未授权 + try + { + var shop = new Shop() + { + ShopId = jShop.Value("ShopId"), + AppKey = jShop.Value("AppKey"), + AppSecret = jShop.Value("AppSecret"), + AppToken = jShop.Value("AppToken"), + ManagePwd = jShop.Value("ManagePwd"), + Platform = (Platform)jShop.Value("PlatformId"), + PlatformCommissionRatio = jShop.Value("PlatformCommissionRatio") ?? 0.05M, + ShopName = jShop.Value("ShopName"), + VenderType = jShop.Value("ShopType"), + TeamId = jShop.Value("TeamId") + }; + d.ShopList.Add(shop); + var jayAccounts = jShop.Value("AccountList"); + if (jayAccounts == null || !jayAccounts.HasValues) + continue; + shop.PurchaseAccountList = new List(); + foreach (var jPurchaseAccount in jayAccounts) + { + shop.PurchaseAccountList.Add(new PurchaseAccount() + { + Id = jPurchaseAccount.Value("Id"), + AccountName = jPurchaseAccount.Value("AccountName"), + AppKey = jPurchaseAccount.Value("AppKey"), + AppSecret = jPurchaseAccount.Value("AppSecret"), + AppToken = jPurchaseAccount.Value("AppToken"), + ShopId = shop.ShopId + //PurchasePlatformId = jPurchaseAccount.Value() + }); + } + } + catch (Exception ex) + { + Console.WriteLine(jShop.ToString()); + throw; + } + } + } + + return response; } } } diff --git a/BBWY.Client/App.xaml.cs b/BBWY.Client/App.xaml.cs index 760a8ef5..6e289318 100644 --- a/BBWY.Client/App.xaml.cs +++ b/BBWY.Client/App.xaml.cs @@ -31,7 +31,8 @@ namespace BBWY.Client var gl = new GlobalContext(); string userToken = string.Empty; #if DEBUG - userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxNDA1MTUxNjE5NTk0NTg4MTYwIiwidGVhbUlkIjoiMTQxMDk1NTYwNDYxMjA5MTkwNCIsImV4cCI6MTY4NjQ4MjU0M30.emnQNDcbqnuO2jH0Kgfk2Ui7crrwzRb986Sa511iS-U"; //齐越小一 + userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxNDE1OTMxMjU4NjEzMDEwNDMyIiwidGVhbUlkIjoiMTQxNDkzNTcwNDQ2MjQzMDIwOCIsInNvblRlYW1JZHMiOiIiLCJleHAiOjE2OTQxMDY1MjV9.XeMruS0YkwI7B6nODGe-vbdUqA_PSAt4EacfRAHIjV0"; //齐越文魁 + //userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxNDA1MTUxNjE5NTk0NTg4MTYwIiwidGVhbUlkIjoiMTQxMDk1NTYwNDYxMjA5MTkwNCIsImV4cCI6MTY4NjQ4MjU0M30.emnQNDcbqnuO2jH0Kgfk2Ui7crrwzRb986Sa511iS-U"; //齐越小一 //userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxNDM5OTA1OTcyOTk3ODUzMTg0IiwidGVhbUlkIjoiMTQzOTkwNDA1MDc3NzY5MDExMiIsImV4cCI6MTY4NjQxODcyOH0.K7-MXjt_zfNK5v_08VjmCDnhAGF6SI7sEQr5sgDn7Jk"; //齐越珍珍 diff --git a/BBWY.Client/Models/User/User.cs b/BBWY.Client/Models/User/User.cs index 6c6b3f22..cd762422 100644 --- a/BBWY.Client/Models/User/User.cs +++ b/BBWY.Client/Models/User/User.cs @@ -11,11 +11,6 @@ namespace BBWY.Client.Models public long Id { get; set; } - /// - /// 登录Token - /// - public string Token { get; set; } - public string Name { get; set; } public string TeamId { get; set; } diff --git a/BBWY.Client/ViewModels/MainViewModel.cs b/BBWY.Client/ViewModels/MainViewModel.cs index 8b7de01d..fdf2d5cc 100644 --- a/BBWY.Client/ViewModels/MainViewModel.cs +++ b/BBWY.Client/ViewModels/MainViewModel.cs @@ -174,33 +174,44 @@ namespace BBWY.Client.ViewModels if (!managerDepartment.Contains(GlobalContext.User.TeamName)) { - var shopListResponse = mdsApiService.GetShopsByUserTeam(GlobalContext.User.Id); - if (!shopListResponse.Success) - throw new Exception(shopListResponse.Msg); - if (shopListResponse.Data == null || shopListResponse.Data.Count == 0) - throw new Exception("未绑定店铺"); - var shopList = shopListResponse.Data.Map>(); - if (shopList.Count == 1) + var response = mdsApiService.GetShopDetailList(); + if (!response.Success) + throw new Exception(response.Msg); + departmentList = response.Data; + + if (departmentList.Count == 1 && departmentList[0].ShopList.Count == 1) { ShowShopChoosePanel = false; - ChooseShop(shopList[0], true); + ChooseShop(departmentList[0].ShopList[0], true); return; } - else - { - ShowShopChoosePanel = true; - departmentList = new List(); - foreach (var shop in shopList) - { - var department = departmentList.FirstOrDefault(d => d.Id == shop.TeamId); - if (department == null) - { - department = new Department() { Id = shop.TeamId, Name = shop.TeamName }; - departmentList.Add(department); - } - department.ShopList.Add(shop); - } - } + //var shopListResponse = mdsApiService.GetShopsByUserTeam(GlobalContext.User.Id); + //if (!shopListResponse.Success) + // throw new Exception(shopListResponse.Msg); + //if (shopListResponse.Data == null || shopListResponse.Data.Count == 0) + // throw new Exception("未绑定店铺"); + //var shopList = shopListResponse.Data.Map>(); + //if (shopList.Count == 1) + //{ + // ShowShopChoosePanel = false; + // ChooseShop(shopList[0], true); + // return; + //} + //else + //{ + // ShowShopChoosePanel = true; + // departmentList = new List(); + // foreach (var shop in shopList) + // { + // var department = departmentList.FirstOrDefault(d => d.Id == shop.TeamId); + // if (department == null) + // { + // department = new Department() { Id = shop.TeamId, Name = shop.TeamName }; + // departmentList.Add(department); + // } + // department.ShopList.Add(shop); + // } + //} } else { diff --git a/BBWY.Client/ViewModels/Order/ChoosePurchaseSchemeViewModel.cs b/BBWY.Client/ViewModels/Order/ChoosePurchaseSchemeViewModel.cs index 3d669f48..9eab7d00 100644 --- a/BBWY.Client/ViewModels/Order/ChoosePurchaseSchemeViewModel.cs +++ b/BBWY.Client/ViewModels/Order/ChoosePurchaseSchemeViewModel.cs @@ -107,6 +107,7 @@ namespace BBWY.Client.ViewModels if (count > 1) { //选择采购账号 + //验证采购账号的所属平台 } else if (count == 1) {