fix 金额小于等于零
This commit is contained in:
@@ -177,7 +177,6 @@ public class BalanceService : IBalanceService
|
||||
newBalanceRecord.Remark = balanceInfo.No + ":" + request.Reason;
|
||||
newBalanceRecord.Status = BalanceRecordStatusEnumType.Valid;
|
||||
|
||||
|
||||
await _dbContext.Client.Ado.BeginTranAsync();
|
||||
try
|
||||
{
|
||||
@@ -203,7 +202,7 @@ public class BalanceService : IBalanceService
|
||||
.SetColumns(x => x.ModifiedTime == DateTime.Now)
|
||||
.Where(x => x.UserCode == balanceInfo.UserCode && x.Version == gainfoMeal.Version)
|
||||
.ExecuteCommandThrowVersionAsync();
|
||||
});
|
||||
}, 10);
|
||||
}
|
||||
|
||||
|
||||
@@ -586,35 +585,6 @@ public class BalanceService : IBalanceService
|
||||
};
|
||||
}
|
||||
|
||||
public async Task ObsoluteAsync(BalanceRecordObsoluteRequest request)
|
||||
{
|
||||
var balanceRecord = await _dbContext.Queryable<BalanceRecordEntity>().Where(x => x.Id == request.Id).SingleAsync();
|
||||
balanceRecord.ThrowIfNull("记录不存在");
|
||||
|
||||
(balanceRecord.Type != BalanceRecordTypeEnumType.Out).ThrowIfTrue("非消费记录,无法操作");
|
||||
|
||||
balanceRecord.Status = BalanceRecordStatusEnumType.Obsolute;
|
||||
balanceRecord.Remark = request.Reason;
|
||||
|
||||
await CommonHelper.RetryAsync(async () =>
|
||||
{
|
||||
//重算金额
|
||||
var canteenUser = await _dbContext.Queryable<GainfoMealEntity>().Where(x => x.UserNo == balanceRecord.UserNo).SingleAsync();
|
||||
|
||||
//金额 +
|
||||
canteenUser.Balance += Math.Abs(balanceRecord.Amount);
|
||||
|
||||
await _dbContext.Updateable<GainfoMealEntity>()
|
||||
.SetColumns(x => x.Balance == canteenUser.Balance)
|
||||
.SetColumns(x => x.Version == x.Version + 1)
|
||||
.SetColumns(x => x.ModifiedTime == DateTime.Now)
|
||||
.Where(x => x.UserNo == balanceRecord.UserNo && x.Version == canteenUser.Version)
|
||||
.ExecuteCommandThrowVersionAsync();
|
||||
|
||||
await _dbContext.UpdateAsync(balanceRecord);
|
||||
|
||||
}, 5);
|
||||
}
|
||||
|
||||
public async Task<ConsumeNumberResponse> GetConsumeNumberAsync()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user