diff --git a/BBWY.Client/Views/FinancialTerminal/ProcurementAudit.xaml b/BBWY.Client/Views/FinancialTerminal/ProcurementAudit.xaml index ae0914a9..a33c7abf 100644 --- a/BBWY.Client/Views/FinancialTerminal/ProcurementAudit.xaml +++ b/BBWY.Client/Views/FinancialTerminal/ProcurementAudit.xaml @@ -24,8 +24,8 @@ - - + + @@ -43,11 +43,11 @@ - - - + + + - + - + - + + /// 获取部门和下属店铺 + /// + /// + [HttpGet] + public IList GetDeparmentList() + { + return venderBusiness.GetDeparmentList(); + } } } diff --git a/BBWY.Server.Business/Vender/VenderBusiness.cs b/BBWY.Server.Business/Vender/VenderBusiness.cs index 8ed2f251..715a19ce 100644 --- a/BBWY.Server.Business/Vender/VenderBusiness.cs +++ b/BBWY.Server.Business/Vender/VenderBusiness.cs @@ -9,6 +9,7 @@ using Microsoft.Extensions.Options; using Newtonsoft.Json; using System; using System.Collections.Generic; +using System.Linq; using System.Net.Http; using Yitter.IdGenerator; @@ -145,5 +146,34 @@ namespace BBWY.Server.Business } return shopSettingRequest.PurchaseAccountId; } + + public IList GetDeparmentList() + { + var relationGroups = freeSqlMultiDBManager.MDSfsql.Select() + .InnerJoin((ud, sd, s) => ud.Id == sd.DepartmentId) + .InnerJoin((ud, sd, s) => s.Id == sd.ShopId) + .Where((ud, sd, s) => !string.IsNullOrEmpty(s.ShopId)) + .ToList((ud, sd, s) => new + { + DepartmentId = ud.Id, + ud.DepartmentName, + s.ShopId, + s.ShopName + }).GroupBy(x => x.DepartmentId); + if (relationGroups.Count() == 0) + return null; + var list = new List(); + foreach (var relationGroup in relationGroups) + { + var department = new DepartmentResponse() + { + Id = relationGroup.Key, + Name = relationGroup.FirstOrDefault().DepartmentName, + ShopList = relationGroup.Select(x => new SimpleShopResponse() { Id = x.ShopId, Name = x.ShopName }).ToList() + }; + list.Add(department); + } + return list; + } } } diff --git a/BBWY.Server.Model/Db/Mds/Shopdepartment.cs b/BBWY.Server.Model/Db/Mds/Shopdepartment.cs new file mode 100644 index 00000000..fefb90ee --- /dev/null +++ b/BBWY.Server.Model/Db/Mds/Shopdepartment.cs @@ -0,0 +1,29 @@ +using FreeSql.DataAnnotations; + +namespace BBWY.Server.Model.Db.Mds +{ + + /// + /// 店铺与团关系 + /// + [Table(Name = "shopdepartment", DisableSyncStructure = true)] + public partial class Shopdepartment { + + [Column(StringLength = 50, IsPrimary = true, IsNullable = false)] + public string Id { get; set; } + + /// + /// 团队ID + /// + [Column(StringLength = 50)] + public string DepartmentId { get; set; } + + /// + /// 店铺ID + /// + [ Column(StringLength = 50)] + public string ShopId { get; set; } + + } + +} diff --git a/BBWY.Server.Model/Db/Mds/Userdepartment.cs b/BBWY.Server.Model/Db/Mds/Userdepartment.cs new file mode 100644 index 00000000..1e483e81 --- /dev/null +++ b/BBWY.Server.Model/Db/Mds/Userdepartment.cs @@ -0,0 +1,50 @@ +using FreeSql.DataAnnotations; +using System; + +namespace BBWY.Server.Model.Db.Mds +{ + + /// + /// 团队 + /// + [ Table(Name = "userdepartment", DisableSyncStructure = true)] + public partial class Userdepartment { + + /// + /// 主键 + /// + [Column(StringLength = 50, IsPrimary = true, IsNullable = false)] + public string Id { get; set; } + + /// + /// 创建时间 + /// + [Column(DbType = "datetime")] + public DateTime CreateTime { get; set; } + + /// + /// 创建人Id + /// + [Column(StringLength = 50)] + public string CreatorId { get; set; } + + /// + /// 否已删除 + /// + [Column(DbType = "tinyint(4)")] + public sbyte Deleted { get; set; } + + /// + /// 部门名称 + /// + public string DepartmentName { get; set; } + + /// + /// 上级部门 + /// + [Column(StringLength = 50)] + public string ParentDepartmentId { get; set; } + + } + +} diff --git a/BBWY.Server.Model/Dto/Response/Vender/DepartmentResponse.cs b/BBWY.Server.Model/Dto/Response/Vender/DepartmentResponse.cs new file mode 100644 index 00000000..56e8d6a8 --- /dev/null +++ b/BBWY.Server.Model/Dto/Response/Vender/DepartmentResponse.cs @@ -0,0 +1,28 @@ +using System.Collections.Generic; + +namespace BBWY.Server.Model.Dto +{ + public class DepartmentResponse + { + public string Id { get; set; } + + public string Name { get; set; } + + public IList ShopList { get; set; } + + public DepartmentResponse() + { + ShopList = new List(); + } + } + + public class SimpleShopResponse + { + /// + /// ShopId + /// + public string Id { get; set; } + + public string Name { get; set; } + } +}