Browse Source

对接新部门接口

qianyi
shanji 3 years ago
parent
commit
7da6e6a6c8
  1. 2
      BBWY.Client/APIServices/BaseApiService.cs
  2. 80
      BBWY.Client/APIServices/MdsApiService.cs
  3. 3
      BBWY.Client/App.xaml.cs
  4. 5
      BBWY.Client/Models/User/User.cs
  5. 57
      BBWY.Client/ViewModels/MainViewModel.cs
  6. 1
      BBWY.Client/ViewModels/Order/ChoosePurchaseSchemeViewModel.cs

2
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");

80
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<IList<ShopResponse>> GetShopsByUserTeam(long userId)
//public ApiResponse<IList<ShopResponse>> GetShopsByUserTeam(long userId)
//{
// return SendRequest<IList<ShopResponse>>(globalContext.MDSApiHost, "TaskList/Shop/GetShopsByUserTeam", $"userId={userId}", null, System.Net.Http.HttpMethod.Get);
//}
public ApiResponse<IList<Department>> GetShopDetailList()
{
return SendRequest<IList<ShopResponse>>(globalContext.MDSApiHost, "TaskList/Shop/GetShopsByUserTeam", $"userId={userId}", null, System.Net.Http.HttpMethod.Get);
var response = new ApiResponse<IList<Department>>();
var response2 = SendRequest<JArray>(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<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)
{
if (jShop.Value<long?>("ShopId") == null || string.IsNullOrEmpty(jShop.Value<string>("AppToken")))
continue; //排除未授权
try
{
var shop = new Shop()
{
ShopId = jShop.Value<long>("ShopId"),
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);
var jayAccounts = jShop.Value<JArray>("AccountList");
if (jayAccounts == null || !jayAccounts.HasValues)
continue;
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 = jPurchaseAccount.Value<long>()
});
}
}
catch (Exception ex)
{
Console.WriteLine(jShop.ToString());
throw;
}
}
}
return response;
}
}
}

3
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"; //齐越珍珍

5
BBWY.Client/Models/User/User.cs

@ -11,11 +11,6 @@ namespace BBWY.Client.Models
public long Id { get; set; }
/// <summary>
/// 登录Token
/// </summary>
public string Token { get; set; }
public string Name { get; set; }
public string TeamId { get; set; }

57
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<IList<Shop>>();
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<Department>();
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<IList<Shop>>();
//if (shopList.Count == 1)
//{
// ShowShopChoosePanel = false;
// ChooseShop(shopList[0], true);
// return;
//}
//else
//{
// ShowShopChoosePanel = true;
// departmentList = new List<Department>();
// 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
{

1
BBWY.Client/ViewModels/Order/ChoosePurchaseSchemeViewModel.cs

@ -107,6 +107,7 @@ namespace BBWY.Client.ViewModels
if (count > 1)
{
//选择采购账号
//验证采购账号的所属平台
}
else if (count == 1)
{

Loading…
Cancel
Save