diff --git a/BPA.SAAS.Manage.Application/DataBase/Dtos/Goods/GoodsDto.cs b/BPA.SAAS.Manage.Application/DataBase/Dtos/Goods/GoodsDto.cs index 6f82d0d..99d9933 100644 --- a/BPA.SAAS.Manage.Application/DataBase/Dtos/Goods/GoodsDto.cs +++ b/BPA.SAAS.Manage.Application/DataBase/Dtos/Goods/GoodsDto.cs @@ -17,10 +17,10 @@ namespace BPA.SAAS.Manage.Application.DataBase.Dtos.Goods public int Sort { get; set; } public decimal Price { get; set; } public string GoodsUintId { get; set; } - public string IsWeigh { get; set; } + public bool IsWeigh { get; set; } public string Design { get; set; } public string DefaultMate { get; set; } - public string IsAttrubute { get; set; } + public bool IsAttrubute { get; set; } public string GoodsTypeId { get; set; } public string Status { get; set; } } diff --git a/BPA.SAAS.Manage.Application/DataBase/Dtos/Goods/GoodsQueryDto.cs b/BPA.SAAS.Manage.Application/DataBase/Dtos/Goods/GoodsQueryDto.cs index 7c96dc5..99a6e94 100644 --- a/BPA.SAAS.Manage.Application/DataBase/Dtos/Goods/GoodsQueryDto.cs +++ b/BPA.SAAS.Manage.Application/DataBase/Dtos/Goods/GoodsQueryDto.cs @@ -14,7 +14,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Dtos.Goods public string DeviceId { get; set; } public string Code { get; set; } public string Design { get; set; } - public string GoodsTypeId { get; set; } + public string GoodsTypeName { get; set; } /// /// 状态 【正常 停用】默认 正常 /// diff --git a/BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeDto.cs b/BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeDto.cs index aa9923e..4a9a2e4 100644 --- a/BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeDto.cs +++ b/BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeDto.cs @@ -13,7 +13,8 @@ namespace BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsAttribute /// /// 商品小类id /// - public string[] GoodsTypeId { get; set; } + public string GoodsTypeId { get; set; } + public List GoodsAttributeValueList { get; set; } public int Sort { get; set; } } } diff --git a/BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeQueryDto.cs b/BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeQueryDto.cs index 93e2e00..516c4f7 100644 --- a/BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeQueryDto.cs +++ b/BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeQueryDto.cs @@ -10,6 +10,6 @@ namespace BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsAttribute public class GoodsAttributeQueryDto : PageInputBase { public string AttributeName { get; set; } - public string GoodsTypeName { get; set; } + public string GoodsTypeId { get; set; } } } diff --git a/BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeView.cs b/BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeView.cs index f619184..19a0263 100644 --- a/BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeView.cs +++ b/BPA.SAAS.Manage.Application/DataBase/Dtos/GoodsAttribute/GoodsAttributeView.cs @@ -1,4 +1,5 @@ -using System; +using BPA.SAAS.Manage.Core.DataBase; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -17,7 +18,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Dtos.GoodsAttribute /// 商品小类id /// public string GoodsTypeId { get; set; } - public string GoodsTypeName { get; set; } + public List AttributeValueList { get; set; } public int Sort { get; set; } } } diff --git a/BPA.SAAS.Manage.Application/DataBase/Services/GoodsAttributeService.cs b/BPA.SAAS.Manage.Application/DataBase/Services/GoodsAttributeService.cs index 369f1a0..50655e4 100644 --- a/BPA.SAAS.Manage.Application/DataBase/Services/GoodsAttributeService.cs +++ b/BPA.SAAS.Manage.Application/DataBase/Services/GoodsAttributeService.cs @@ -30,7 +30,7 @@ namespace BPA.Franchisee.Application.FranchiseeCenter.GoodsServices var res = _db.Queryable() .Where(a=> a.IsDeleted == 0) .WhereIF(!dto.AttributeName.IsNullOrWhiteSpace(),x=>x.AttributeName.Contains(dto.AttributeName)) - .WhereIF(!dto.GoodsTypeName.IsNullOrWhiteSpace(), x => x.GoodsTypeId.Contains(dto.GoodsTypeName)) + .WhereIF(!dto.GoodsTypeId.IsNullOrWhiteSpace(), x => x.GoodsTypeId.Contains(dto.GoodsTypeId)) .OrderBy(a => a.CreateAt, OrderByType.Desc) .Select(a => new GoodsAttributeView { @@ -41,8 +41,8 @@ namespace BPA.Franchisee.Application.FranchiseeCenter.GoodsServices }) .Mapper(x => { - var tyname=_db.Queryable().Where(p=> x.GoodsTypeId.Contains(p.Id)).Select(x=>x.Name).ToArray(); - x.GoodsTypeName = string.Join(",", tyname); + var list=_db.Queryable().Where(p=> p.GoodsAttributeId==x.Id).ToList(); + x.AttributeValueList = list; }) .ToPageList(dto.Current, dto.PageSize, ref total); PageUtil util = new PageUtil() @@ -59,30 +59,66 @@ namespace BPA.Franchisee.Application.FranchiseeCenter.GoodsServices /// public async Task AddGoodsAttribute(GoodsAttributeDto dto) { - if (!string.IsNullOrWhiteSpace(dto.Id)) + try { - var resEntity = _db.Queryable().Where(it => it.IsDeleted == 0).First(it => it.Id == dto.Id); - if (null == resEntity) + if (!string.IsNullOrWhiteSpace(dto.Id)) { - return false; + _db.Ado.BeginTran(); + var resEntity = _db.Queryable().Where(it => it.IsDeleted == 0).First(it => it.Id == dto.Id); + if (null == resEntity) + { + return false; + } + resEntity.AttributeName = dto.AttributeName; + resEntity.GoodsTypeId = dto.GoodsTypeId; + resEntity.Sort = dto.Sort; + await _db.Updateable(resEntity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); + + var dellist = _db.Queryable().Where(it => it.GoodsAttributeId == dto.Id).ToList(); + await _db.Deleteable(dellist).ExecuteCommandAsync(); ; + List list = new(); + for (int i = 0; i < dto.GoodsAttributeValueList.Count; i++) + { + BPA_GoodsAttributeValue GoodsAttributeValue = new(); + GoodsAttributeValue.AttributeValue = dto.GoodsAttributeValueList[i].AttributeValue; + GoodsAttributeValue.GoodsAttributeId = dto.Id; + GoodsAttributeValue.Sort= dto.GoodsAttributeValueList[i].Sort; + list.Add(GoodsAttributeValue); + } + var res = await _db.Insertable(list).CallEntityMethod(m => m.Create()).ExecuteCommandAsync(); + _db.Ado.CommitTran(); + return res > 0; + } + else + { + _db.Ado.BeginTran(); + var newGoodsAttribute = new BPA_GoodsAttribute + { + AttributeName = dto.AttributeName, + GoodsTypeId = dto.GoodsTypeId, + Sort = dto.Sort, + }; + var GoodsAttribute = await _db.Insertable(newGoodsAttribute).CallEntityMethod(m => m.Create()).ExecuteReturnEntityAsync(); + List list = new(); + for (int i = 0; i < dto.GoodsAttributeValueList.Count; i++) + { + BPA_GoodsAttributeValue GoodsAttributeValue = new(); + GoodsAttributeValue.AttributeValue = dto.GoodsAttributeValueList[i].AttributeValue; + GoodsAttributeValue.GoodsAttributeId = GoodsAttribute.Id; + GoodsAttributeValue.Sort = dto.GoodsAttributeValueList[i].Sort; + list.Add(GoodsAttributeValue); + } + var res = await _db.Insertable(list).CallEntityMethod(m => m.Create()).ExecuteCommandAsync(); + _db.Ado.CommitTran(); + return res > 0; } - resEntity.AttributeName = dto.AttributeName; - resEntity.GoodsTypeId = string.Join(',', dto.GoodsTypeId) ; - resEntity.Sort = dto.Sort; - var res =await _db.Updateable(resEntity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); - return res > 0; } - else + catch (Exception) { - var newGoodsAttribute = new BPA_GoodsAttribute - { - AttributeName = dto.AttributeName, - GoodsTypeId = string.Join(',', dto.GoodsTypeId), - Sort = dto.Sort, - }; - var res =await _db.Insertable(newGoodsAttribute).CallEntityMethod(m => m.Create()).ExecuteCommandAsync(); - return res > 0; + _db.Ado.RollbackTran(); + throw Oops.Oh("添加失败"); } + } /// @@ -92,25 +128,16 @@ namespace BPA.Franchisee.Application.FranchiseeCenter.GoodsServices /// public async Task DeleteGoodsAttribute(string[] Ids) { - // 查询数据库中是否存在未删除的商品 var resEntitites = _db.Queryable().In(Ids).ToList(); - - resEntitites.ForEach(x => - { - x.IsDeleted = 1; - }); - var res =await _db.Updateable(resEntitites).ExecuteCommandAsync(); + var res =await _db.Deleteable(resEntitites).ExecuteCommandAsync(); if (res > 0) { var resEntititesattr = _db.Queryable().In("GoodsAttributeId", Ids).ToList(); if (resEntititesattr != null) { - resEntititesattr.ForEach(x => - { - x.IsDeleted = 1; - }); - await _db.Updateable(resEntititesattr).ExecuteCommandAsync(); + + await _db.Deleteable(resEntititesattr).ExecuteCommandAsync(); } } return res > 0; @@ -188,12 +215,7 @@ namespace BPA.Franchisee.Application.FranchiseeCenter.GoodsServices // 查询数据库中是否存在未删除的商品 var resEntitites = _db.Queryable().In(id).ToList(); - - resEntitites.ForEach(x => - { - x.IsDeleted = 1; - }); - var res =await _db.Updateable(resEntitites).ExecuteCommandAsync(); + var res =await _db.Deleteable(resEntitites).ExecuteCommandAsync(); if (res > 0) { diff --git a/BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs b/BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs index 32a1148..6bf4e78 100644 --- a/BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs +++ b/BPA.SAAS.Manage.Application/DataBase/Services/GoodsService.cs @@ -57,9 +57,9 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services conModels.Add(new ConditionalModel() { FieldName = "a.Name", ConditionalType = ConditionalType.Like, FieldValue = dto.Name }); } - if (!string.IsNullOrEmpty(dto.GoodsTypeId)) + if (!string.IsNullOrEmpty(dto.GoodsTypeName)) { - conModels.Add(new ConditionalModel() { FieldName = "a.GoodsTypeId", ConditionalType = ConditionalType.Equal, FieldValue = dto.GoodsTypeId }); + conModels.Add(new ConditionalModel() { FieldName = "a.GoodsTypeId", ConditionalType = ConditionalType.Equal, FieldValue = dto.GoodsTypeName }); } if (!string.IsNullOrEmpty(dto.Status)) @@ -88,7 +88,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services Status = a.Status, GoodsTypeId = b.IsDeleted == 0 ? a.GoodsTypeId : "", GoodsTypeName = b.IsDeleted == 0 ? b.Name : "", - Remark = a.Descritption, + Descritption = a.Descritption, IsDeleted = a.IsDeleted, // CreateAt = a.CreateAt, @@ -135,9 +135,9 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services resEntity.Descritption = dto.Descritption; resEntity.ImgUrl = dto.ImgUrl; resEntity.Price = dto.Price; - resEntity.IsWeigh = dto.IsWeigh == "false" ? 0 : 1; + resEntity.IsWeigh = dto.IsWeigh; resEntity.GoodsUintId = dto.GoodsUintId; - resEntity.IsAttrubute = Convert.ToBoolean(dto.IsAttrubute); + resEntity.IsAttrubute = dto.IsAttrubute; resEntity.Code = GetNumber2(8); var data = _db.Queryable().Max(x => x.AutoKey); //if (data == 0) data = 1000; @@ -171,7 +171,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services resEntity.Descritption = dto.Descritption; resEntity.ImgUrl = dto.ImgUrl; resEntity.Price = dto.Price; - resEntity.IsWeigh = dto.IsWeigh=="false"?0:1; + resEntity.IsWeigh = dto.IsWeigh; resEntity.GoodsUintId = dto.GoodsUintId; resEntity.IsAttrubute = Convert.ToBoolean(dto.IsAttrubute); if (!string.IsNullOrWhiteSpace(dto.Status)) @@ -651,7 +651,7 @@ namespace BPA.SAAS.Manage.Application.DataBase.Services Price = 0, IsAttrubute = false, IsDeleted = 0, - IsWeigh = 0, + IsWeigh = false, Key = null, Status = 0, }); diff --git a/BPA.SAAS.Manage.Application/Device/Dtos/Device/ProductQueryInputDto.cs b/BPA.SAAS.Manage.Application/Device/Dtos/Device/ProductQueryInputDto.cs index 6d24596..e88ae6a 100644 --- a/BPA.SAAS.Manage.Application/Device/Dtos/Device/ProductQueryInputDto.cs +++ b/BPA.SAAS.Manage.Application/Device/Dtos/Device/ProductQueryInputDto.cs @@ -11,5 +11,7 @@ namespace BPA.SAAS.Manage.Application.Device.Dtos.Device { public string Name { get; set; } public string Key { get; set; } + public string Code { get; set; } + public string Remark { get; set; } } } diff --git a/BPA.SAAS.Manage.Application/Device/Dtos/ProductFunction/ProductFunctionBaseDto.cs b/BPA.SAAS.Manage.Application/Device/Dtos/ProductFunction/ProductFunctionBaseDto.cs index 5a664d2..722d07f 100644 --- a/BPA.SAAS.Manage.Application/Device/Dtos/ProductFunction/ProductFunctionBaseDto.cs +++ b/BPA.SAAS.Manage.Application/Device/Dtos/ProductFunction/ProductFunctionBaseDto.cs @@ -36,7 +36,7 @@ namespace BPA.SAAS.Manage.Application.Device.Dtos.ProductFunction /// /// 步长 /// - public int StepSize { get; set; } + public decimal StepSize { get; set; } /// /// 枚举值 /// diff --git a/BPA.SAAS.Manage.Application/Device/Services/ProductService.cs b/BPA.SAAS.Manage.Application/Device/Services/ProductService.cs index a129072..bb26cdc 100644 --- a/BPA.SAAS.Manage.Application/Device/Services/ProductService.cs +++ b/BPA.SAAS.Manage.Application/Device/Services/ProductService.cs @@ -31,6 +31,8 @@ namespace BPA.SAAS.Manage.Application.Device.Services var data = await _db.Queryable().Where((x) => x.IsDeleted == 0) .WhereIF(!string.IsNullOrWhiteSpace(inputDto.Name), x => x.Name.Contains(inputDto.Name)) .WhereIF(!string.IsNullOrWhiteSpace(inputDto.Key), x => x.Key.Contains(inputDto.Key)) + .WhereIF(!string.IsNullOrWhiteSpace(inputDto.Code), x => x.Code.Contains(inputDto.Code)) + .WhereIF(!string.IsNullOrWhiteSpace(inputDto.Remark), x => x.Remark.Contains(inputDto.Remark)) .OrderBy(x => x.CreateAt, OrderByType.Desc) .ToPageListAsync(inputDto.Current, inputDto.PageSize, total); diff --git a/BPA.SAAS.Manage.Application/Org/Interface/IOrganizeService.cs b/BPA.SAAS.Manage.Application/Org/Interface/IOrganizeService.cs index a4d89ca..8fcf241 100644 --- a/BPA.SAAS.Manage.Application/Org/Interface/IOrganizeService.cs +++ b/BPA.SAAS.Manage.Application/Org/Interface/IOrganizeService.cs @@ -13,7 +13,7 @@ namespace BPA.SAAS.Manage.Application.Org.Interface Task QueryOrgPageList(OrgPageInput input); Task> GetOrgList(OrgListInput input); Task AddOrg(OrgAddInput input); - Task DeleteOrg(DeleteOrgInput input); + Task DeleteOrg(string id); Task UpdateOrg(UpdateOrgInput input); Task GetOrgTree(); Task> GetOrgList(); diff --git a/BPA.SAAS.Manage.Application/Org/OrganizeServices.cs b/BPA.SAAS.Manage.Application/Org/OrganizeServices.cs index 45c43bd..e8378ba 100644 --- a/BPA.SAAS.Manage.Application/Org/OrganizeServices.cs +++ b/BPA.SAAS.Manage.Application/Org/OrganizeServices.cs @@ -52,10 +52,10 @@ namespace BPA.SAAS.Manage.Application.Org /// /// /// - [HttpPost("/api/organize/deleteorg")] - public async Task DeleteOrg(DeleteOrgInput input) + [HttpGet("/api/organize/deleteorg")] + public async Task DeleteOrg(string id) { - return await _organizeService.DeleteOrg(input); + return await _organizeService.DeleteOrg(id); } /// /// 修改 diff --git a/BPA.SAAS.Manage.Application/Org/Services/OrganizeService.cs b/BPA.SAAS.Manage.Application/Org/Services/OrganizeService.cs index a85f900..7b12ac8 100644 --- a/BPA.SAAS.Manage.Application/Org/Services/OrganizeService.cs +++ b/BPA.SAAS.Manage.Application/Org/Services/OrganizeService.cs @@ -82,9 +82,9 @@ namespace BPA.SAAS.Manage.Application.Org.Services /// /// /// - public async Task DeleteOrg(DeleteOrgInput input) + public async Task DeleteOrg(string id) { - var sysOrg = await _db.Queryable().FirstAsync(u => u.Id == input.Id); + var sysOrg = await _db.Queryable().FirstAsync(u => u.Id == id); // 级联删除子节点 var childIdList = await GetChildIdListWithSelfById(sysOrg.Id); var orgs = await _db.Queryable().Where(u => childIdList.Contains(u.Id)).ToListAsync(); diff --git a/BPA.SAAS.Manage.Core/DataBase/BPA_GoodsInfo.cs b/BPA.SAAS.Manage.Core/DataBase/BPA_GoodsInfo.cs index d541fcb..792c9a6 100644 --- a/BPA.SAAS.Manage.Core/DataBase/BPA_GoodsInfo.cs +++ b/BPA.SAAS.Manage.Core/DataBase/BPA_GoodsInfo.cs @@ -22,7 +22,7 @@ namespace BPA.SAAS.Manage.Core.DataBase public decimal Price { get; set; } public long AutoKey { get; set; } public string GoodsUintId { get; set; } - public int IsWeigh { get; set; } + public bool IsWeigh { get; set; } public string ForeignKeyRe { get; set; } public string Design { get; set; } public string DefaultMate { get; set; } diff --git a/BPA.SAAS.Manage.Core/Product/BPA_ProductFunction.cs b/BPA.SAAS.Manage.Core/Product/BPA_ProductFunction.cs index d999347..bfd81fa 100644 --- a/BPA.SAAS.Manage.Core/Product/BPA_ProductFunction.cs +++ b/BPA.SAAS.Manage.Core/Product/BPA_ProductFunction.cs @@ -54,7 +54,7 @@ namespace BPA.SAAS.Manage.Core.Product /// /// 步长 /// - public int StepSize { get; set; } + public decimal StepSize { get; set; } /// /// 枚举值 ///