feat 内部余额写入
This commit is contained in:
@@ -29,4 +29,7 @@ public interface IBalanceService : IScopeDependency
|
||||
Task<Pagination<AverageDailyResponse>> AverageDailyAsync(AverageDailyRequest request);
|
||||
|
||||
Task<Pagination<DevicePageResponse>> GetConsumeDeviceAsync(GetConsumeDeviceRequest request);
|
||||
|
||||
|
||||
Task Import(BalanceHainingImportRequest request);
|
||||
}
|
||||
|
||||
@@ -494,6 +494,58 @@ public class BalanceService : IBalanceService
|
||||
return page;
|
||||
}
|
||||
|
||||
public async Task Import(BalanceHainingImportRequest request)
|
||||
{
|
||||
var gainfo = await _dbContext.Queryable<GainfoEntity>().Where(x => x.Code == request.UserCode).SingleAsync();
|
||||
gainfo.ThrowIfNull($"工号{request.UserCode}不存在");
|
||||
var gainfoMeal = await _dbContext.Queryable<GainfoMealEntity>().Where(x => x.UserCode == request.UserCode).SingleAsync();
|
||||
|
||||
|
||||
await _dbContext.InsertAsync(new BalanceRecordEntity
|
||||
{
|
||||
Amount = request.Amount,
|
||||
ApplicationType = request.ApplicationType,
|
||||
Type = request.Type,
|
||||
BusinessPlaceCode = request.BusinessPlaceCode,
|
||||
BusinessShiftCode = null,
|
||||
ShiftType = request.ShiftType,
|
||||
CostDate = request.CostDate,
|
||||
CostDateTime = request.CostDateTime,
|
||||
UserNo = gainfo.No,
|
||||
No = request.No,
|
||||
UserCode = gainfo.Code,
|
||||
TenantId = request.Factory,
|
||||
Status = BalanceRecordStatusEnumType.Valid,
|
||||
Source = request.Source,
|
||||
Remark = request.Remark,
|
||||
CostId = gainfo.CostId,
|
||||
SubsidiesFromMonth = request.CostDate.ToString("yyyyMM"),
|
||||
OriginTenantId = gainfo.Factory,
|
||||
Werks = gainfo.Werks,
|
||||
Name = gainfo.Name,
|
||||
IsCostCrossTenant = false,
|
||||
DepartmentNo = gainfo.DepartmentNo,
|
||||
DeviceUniqueNo = request.DeviceUniqueNo,
|
||||
|
||||
IsDeleted = false,
|
||||
|
||||
CreatedBy = 1,
|
||||
CreateTime = DateTime.Now,
|
||||
ModifiedBy = 1,
|
||||
ModifiedTime = DateTime.Now,
|
||||
});
|
||||
|
||||
var newBalance = gainfoMeal.Balance += request.Amount;
|
||||
|
||||
await _dbContext.Updateable<GainfoMealEntity>()
|
||||
.SetColumns(x => x.Balance == newBalance)
|
||||
.SetColumns(x => x.ModifiedBy == 1)
|
||||
.SetColumns(x => x.ModifiedTime == DateTime.Now)
|
||||
.SetColumns(x => x.Version == x.Version + 1)
|
||||
.Where(x => x.UserCode == request.UserCode && x.Version == gainfoMeal.Version)
|
||||
.ExecuteCommandThrowVersionAsync("写入失败,正在消费中");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取离线设备
|
||||
|
||||
@@ -55,7 +55,7 @@ public class BookingOrderService : BaseOrderService, IBookingOrderService
|
||||
RequestJson = request.ToJson(),
|
||||
ThirdNo = string.Empty,
|
||||
Type = BalanceRecordTypeEnumType.Out,
|
||||
ApplicationType = CanteenApplicaitonTypeEnumType.Booking,
|
||||
ApplicationType = CanteenApplicationTypeEnumType.Booking,
|
||||
Name = gainfo.Name,
|
||||
Source = request.Source,
|
||||
UserNo = gainfo.No,
|
||||
@@ -287,7 +287,7 @@ public class BookingOrderService : BaseOrderService, IBookingOrderService
|
||||
var end = start.AddDays(1).AddSeconds(-1);
|
||||
|
||||
var exists = await DbContext.Queryable<CanteenOrderEntity>()
|
||||
.Where(x => x.ApplicationType == CanteenApplicaitonTypeEnumType.Booking)
|
||||
.Where(x => x.ApplicationType == CanteenApplicationTypeEnumType.Booking)
|
||||
.Where(x => x.OrderStatus == CanteenOrderStatusEnumType.Success)
|
||||
.Where(x => x.ShiftType == shiftType)
|
||||
.Where(x => x.UserNo == gainfo.No)
|
||||
|
||||
@@ -182,7 +182,7 @@ public class OrderService : BaseOrderService, IOrderService
|
||||
RequestJson = request.ToJson(),
|
||||
ThirdNo = request.ThirdNo,
|
||||
Type = BalanceRecordTypeEnumType.Out,
|
||||
ApplicationType = CanteenApplicaitonTypeEnumType.Device,
|
||||
ApplicationType = CanteenApplicationTypeEnumType.Device,
|
||||
Name = gainfo.Name,
|
||||
Source = request.Source,
|
||||
UserNo = gainfo.No,
|
||||
@@ -314,7 +314,7 @@ public class OrderService : BaseOrderService, IOrderService
|
||||
RequestJson = request.ToJson(),
|
||||
ThirdNo = request.ThirdNo,
|
||||
Type = BalanceRecordTypeEnumType.Out,
|
||||
ApplicationType = CanteenApplicaitonTypeEnumType.Device,
|
||||
ApplicationType = CanteenApplicationTypeEnumType.Device,
|
||||
Name = gainfo.Name,
|
||||
Source = request.Source,
|
||||
UserNo = gainfo.No,
|
||||
@@ -383,7 +383,7 @@ public class OrderService : BaseOrderService, IOrderService
|
||||
|
||||
var pageResult = await DbContext.Queryable<CanteenOrderEntity>().Where(x => x.UserNo == gainfo.No)
|
||||
.LeftJoin<BusinessPlaceEntity>((x, bplace) => x.BusinessPlaceCode == bplace.Code)
|
||||
.Where(x => x.ApplicationType == CanteenApplicaitonTypeEnumType.Booking)
|
||||
.Where(x => x.ApplicationType == CanteenApplicationTypeEnumType.Booking)
|
||||
.OrderBy(x => x.CreateTime, OrderByType.Desc)
|
||||
.Select((x, bplace) => new OrderAggregationResponse
|
||||
{
|
||||
@@ -422,7 +422,7 @@ public class OrderService : BaseOrderService, IOrderService
|
||||
var orders = await DbContext.Queryable<CanteenOrderEntity>().Where(x => x.IsOffline)
|
||||
.Where(x => x.Status == BalanceRecordStatusEnumType.Valid)
|
||||
.Where(x => x.OrderStatus == CanteenOrderStatusEnumType.Success)
|
||||
.Where(x => x.ApplicationType == CanteenApplicaitonTypeEnumType.Device)
|
||||
.Where(x => x.ApplicationType == CanteenApplicationTypeEnumType.Device)
|
||||
.Where(x => SqlFunc.IsNullOrEmpty(x.BusinessShiftCode))
|
||||
.WhereIF(outRequest.No.IsPresent(), x => x.No == outRequest.No)
|
||||
.ToListAsync();
|
||||
|
||||
Reference in New Issue
Block a user