|
|
@@ -129,11 +129,11 @@ namespace BPA.KitChen.GroupMeal.Application.Service.Applet |
|
|
|
[HttpPost("/api/AppletService/MaterialAdd")] |
|
|
|
public async Task MaterialAdd(AddMiniStorePageMaterialInput input) |
|
|
|
{ |
|
|
|
//var res = await db.Queryable<MiniStorePageConfig>().FirstAsync(x => x.MaterialCode == input.MaterialCode && x.PageId==input.PageId); |
|
|
|
//if (res != null) |
|
|
|
//{ |
|
|
|
// throw Oops.Bah("素材编码重复"); |
|
|
|
//} |
|
|
|
var res = await db.Queryable<MiniStorePageConfig>().FirstAsync(x => x.MaterialCode == input.MaterialCode && x.PageId == input.PageId); |
|
|
|
if (res != null) |
|
|
|
{ |
|
|
|
throw Oops.Bah("素材编码重复"); |
|
|
|
} |
|
|
|
MiniStorePageConfig data = input.Adapt<MiniStorePageConfig>(); |
|
|
|
await db.Insertable(data).ExecuteCommandAsync(); |
|
|
|
} |
|
|
@@ -210,11 +210,11 @@ namespace BPA.KitChen.GroupMeal.Application.Service.Applet |
|
|
|
throw Oops.Bah("没有找到数据"); |
|
|
|
} |
|
|
|
//判断编码重复 |
|
|
|
//var data1 = await db.Queryable<MiniStorePageConfig>().FirstAsync(x => x.Id != input.Id && x.MaterialCode == input.MaterialCode&& x.PageId != input.PageId); |
|
|
|
//if (data1!=null) |
|
|
|
//{ |
|
|
|
// throw Oops.Bah("编码重复"); |
|
|
|
//} |
|
|
|
var data1 = await db.Queryable<MiniStorePageConfig>().FirstAsync(x => x.Id != input.Id && x.MaterialCode == input.MaterialCode && x.PageId == input.PageId); |
|
|
|
if (data1 != null) |
|
|
|
{ |
|
|
|
throw Oops.Bah("编码重复"); |
|
|
|
} |
|
|
|
data.MaterialName = input.MaterialName; |
|
|
|
data.MaterialPath = input.MaterialPath; |
|
|
|
data.PageId = input.PageId; |
|
|
@@ -229,17 +229,25 @@ namespace BPA.KitChen.GroupMeal.Application.Service.Applet |
|
|
|
/// <returns></returns> |
|
|
|
[HttpPost("/api/AppletService/MiniStoreMaterial")] |
|
|
|
[AllowAnonymous] |
|
|
|
public async Task<List<MiniStorePageConfigOutput>> MiniStoreMaterial(QueryMiniStorePageInput input) |
|
|
|
public async Task<SqlSugarPagedList<MiniStorePageConfigOutput>> MiniStoreMaterial(QueryMiniStorePageInput input) |
|
|
|
{ |
|
|
|
List<MiniStorePageConfigOutput> outputs = new(); |
|
|
|
var datas = await db.Queryable<MiniStorePage>().Where(x => x.StoreId == input.StoreId).ToListAsync(); |
|
|
|
foreach (var item in datas) |
|
|
|
var datas = await db.Queryable<MiniStorePage>().Where(x => x.StoreId == input.StoreId && x.Id == input.PageId).ToListAsync(); |
|
|
|
|
|
|
|
if (datas.Count > 0) |
|
|
|
{ |
|
|
|
var ids = datas.Select(x => x.Id); |
|
|
|
|
|
|
|
var pageList = await db.Queryable<MiniStorePageConfig>().Where(x => ids.Contains(x.PageId)) |
|
|
|
.OrderBy(x => x.Id) |
|
|
|
.ToPagedListAsync(input.Current, input.PageSize); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MiniStorePageConfigOutput output = new(); |
|
|
|
output.PageName = item.PageName; |
|
|
|
output.PageRoute = item.PageRoute; |
|
|
|
var lists = await db.Queryable<MiniStorePageConfig>().Where(x => x.PageId == item.Id).ToListAsync(); |
|
|
|
foreach (var materialItem in lists) |
|
|
|
output.PageName = datas[0]?.PageName ?? ""; |
|
|
|
output.PageRoute = datas[0]?.PageRoute ?? ""; |
|
|
|
foreach (var materialItem in pageList.Items) |
|
|
|
{ |
|
|
|
MiniStorePageMaterialOutput material = new(); |
|
|
|
material.MaterialName = materialItem.MaterialName; |
|
|
@@ -250,9 +258,23 @@ namespace BPA.KitChen.GroupMeal.Application.Service.Applet |
|
|
|
output.List.Add(material); |
|
|
|
} |
|
|
|
outputs.Add(output); |
|
|
|
return new SqlSugarPagedList<MiniStorePageConfigOutput>() |
|
|
|
{ |
|
|
|
Items = outputs, |
|
|
|
PageIndex = pageList.PageIndex, |
|
|
|
PageSize = pageList.PageSize, |
|
|
|
TotalCount = pageList.TotalCount, |
|
|
|
TotalPages = pageList.TotalPages, |
|
|
|
|
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
return outputs; |
|
|
|
|
|
|
|
return new SqlSugarPagedList<MiniStorePageConfigOutput>() |
|
|
|
{ |
|
|
|
Items = new List<MiniStorePageConfigOutput>() |
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
#endregion |
|
|
|
|
|
|
@@ -264,7 +286,13 @@ namespace BPA.KitChen.GroupMeal.Application.Service.Applet |
|
|
|
try |
|
|
|
{ |
|
|
|
db.Ado.BeginTran(); |
|
|
|
var payTemplate = await db.Insertable(new BPA_PayTemplate() |
|
|
|
|
|
|
|
var payTemplate = db.Queryable<BPA_PayTemplate>().First(x => x.IsDeleted == 0 && x.Name == inputDto.Name); |
|
|
|
if (payTemplate != null) |
|
|
|
{ |
|
|
|
throw Oops.Bah("名称重复"); |
|
|
|
} |
|
|
|
payTemplate = await db.Insertable(new BPA_PayTemplate() |
|
|
|
{ |
|
|
|
Name = inputDto.Name, |
|
|
|
}).CallEntityMethod(t => t.Create()).ExecuteReturnEntityAsync(); |
|
|
@@ -300,9 +328,10 @@ namespace BPA.KitChen.GroupMeal.Application.Service.Applet |
|
|
|
db.Ado.CommitTran(); |
|
|
|
return result; |
|
|
|
} |
|
|
|
catch (Exception) |
|
|
|
catch (Exception e) |
|
|
|
{ |
|
|
|
db.Ado.RollbackTran(); |
|
|
|
throw Oops.Bah(e.Message); |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
@@ -345,7 +374,7 @@ namespace BPA.KitChen.GroupMeal.Application.Service.Applet |
|
|
|
int total = 0; |
|
|
|
var res = db.Queryable<BPA_PayTemplate>() |
|
|
|
.Where(x => x.IsDeleted == 0) |
|
|
|
.WhereIF(!string.IsNullOrEmpty(inputDto.Name),x=>x.Name.Contains(inputDto.Name)) |
|
|
|
.WhereIF(!string.IsNullOrEmpty(inputDto.Name), x => x.Name.Contains(inputDto.Name)) |
|
|
|
.Select(t => new PayTemplateOutDto |
|
|
|
{ |
|
|
|
Id = t.Id.SelectAll(), |
|
|
@@ -385,10 +414,17 @@ namespace BPA.KitChen.GroupMeal.Application.Service.Applet |
|
|
|
[HttpPost("/api/paytemplate/update")] |
|
|
|
public async Task<bool> Update(PayTemplateCreateOrUpdateInputDto inputDto) |
|
|
|
{ |
|
|
|
var payTemplate = db.Queryable<BPA_PayTemplate>().First(x => x.Id == inputDto.Id && x.IsDeleted == 0); |
|
|
|
var payTemplate = db.Queryable<BPA_PayTemplate>().First(x => x.Id != inputDto.Id && x.IsDeleted == 0 && x.Name == inputDto.Name); |
|
|
|
if (payTemplate != null) |
|
|
|
{ |
|
|
|
throw Oops.Bah("名称重复"); |
|
|
|
} |
|
|
|
|
|
|
|
payTemplate = db.Queryable<BPA_PayTemplate>().First(x => x.Id == inputDto.Id && x.IsDeleted == 0); |
|
|
|
if (payTemplate == null) return false; |
|
|
|
payTemplate.Name = inputDto.Name; |
|
|
|
|
|
|
|
|
|
|
|
var payTemplateInfo = db.Queryable<BPA_PayTemplateInfo>().Where(x => x.PayTemplateId == inputDto.Id).ToList(); |
|
|
|
foreach (var item in payTemplateInfo) |
|
|
|
{ |
|
|
@@ -432,6 +468,12 @@ namespace BPA.KitChen.GroupMeal.Application.Service.Applet |
|
|
|
[HttpPost("/api/appid/add")] |
|
|
|
public async Task<bool> AppidAdd(BPA_AppIdConfig inputDto) |
|
|
|
{ |
|
|
|
var data = db.Queryable<BPA_AppIdConfig>().First(x => x.IsDeleted == 0 && x.AppId == inputDto.AppId); |
|
|
|
if (data != null) |
|
|
|
{ |
|
|
|
throw Oops.Bah("AppId重复"); |
|
|
|
} |
|
|
|
|
|
|
|
try |
|
|
|
{ |
|
|
|
var result = await db.Insertable(inputDto).CallEntityMethod(t => t.Create()).ExecuteCommandAsync() > 0; |
|
|
@@ -489,7 +531,12 @@ namespace BPA.KitChen.GroupMeal.Application.Service.Applet |
|
|
|
[HttpPost("/api/appid/update")] |
|
|
|
public async Task<bool> AppidUpdate(BPA_AppIdConfig inputDto) |
|
|
|
{ |
|
|
|
var data = db.Queryable<BPA_AppIdConfig>().First(x => x.Id == inputDto.Id && x.IsDeleted == 0); |
|
|
|
var data= db.Queryable<BPA_AppIdConfig>().First(x => x.Id != inputDto.Id && x.IsDeleted == 0&&x.AppId==inputDto.AppId); |
|
|
|
if (data != null) |
|
|
|
{ |
|
|
|
throw Oops.Bah("AppId重复"); |
|
|
|
} |
|
|
|
data = db.Queryable<BPA_AppIdConfig>().First(x => x.Id == inputDto.Id && x.IsDeleted == 0); |
|
|
|
if (data == null) return false; |
|
|
|
data.AppId = inputDto.AppId; |
|
|
|
try |
|
|
|