fix 订单取消接口,分页权限控制

This commit is contained in:
2024-03-21 18:14:33 +08:00
parent 653548be24
commit df8976ed03

View File

@@ -14,6 +14,7 @@ using Dlhis.Basic.Api;
using Kurisu.SqlSugar.Extensions;
using SqlSugar;
using Mapster;
using MySqlX.XDevAPI.Relational;
namespace Dlhis.Canteen.Order.Services.Implements;
@@ -297,6 +298,37 @@ public class BookingOrderService : BaseOrderService, IBookingOrderService
}, 5);
}
var balance = await DbContext.Queryable<BalanceRecordEntity>().Where(x => x.No == request.No).SingleAsync();
await DbContext.Updateable<BalanceRecordEntity>()
.SetColumns(x => x.Status == BalanceRecordStatusEnumType.Obsolute)
.SetColumns(x => x.Remark == request.Reason)
.SetColumns(x => x.ModifiedTime == now)
.SetColumns(x => x.ModifiedBy == userId)
.Where(x => x.No == request.No)
.ExecuteCommandAsync();
var amount = Math.Abs(order.Amount);
//尝试5次
await ContinueUpdateAsync(async () =>
{
var mealInfo = await DbContext.Queryable<GainfoMealEntity>().Where(x => x.UserNo == order.UserNo).FirstAsync();
var effect = await DbContext.Updateable<GainfoMealEntity>()
.SetColumns(x => x.Balance == x.Balance + amount)
.SetColumns(x => x.ModifiedTime == now)
.SetColumns(x => x.ModifiedBy == userId)
.Where(x => x.Id == mealInfo.Id && x.Version == mealInfo.Version)
.ExecuteCommandAsync();
if (effect <= 0)
{
throw new VersionExceptions("取消订单失败!");
}
}, 5);
}
/// <summary>
/// 检查我的订餐是否存在,存在抛出异常