fix 移除无用代码
This commit is contained in:
@@ -430,68 +430,6 @@ public class OrderService : BaseOrderService, IOrderService
|
||||
return pageResult;
|
||||
}
|
||||
|
||||
|
||||
public async Task UpdateOffline(UpdateOfflineRequest outRequest)
|
||||
{
|
||||
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 == CanteenApplicationTypeEnumType.Device)
|
||||
.Where(x => SqlFunc.IsNullOrEmpty(x.BusinessShiftCode))
|
||||
.WhereIF(outRequest.No.IsPresent(), x => x.No == outRequest.No)
|
||||
.ToListAsync();
|
||||
|
||||
foreach (var item in orders)
|
||||
{
|
||||
var request = item.RequestJson.ToObject<ConsumeRequest>();
|
||||
|
||||
var registry = await DbContext.Queryable<DeviceRegistryEntity>()
|
||||
.Where(x => x.DeviceUniqueNo == request.DeviceUniqueNo)
|
||||
.FirstAsync();
|
||||
|
||||
var businessPlaceInfo = await DbContext.Queryable<BusinessPlaceEntity>()
|
||||
.LeftJoin<BusinessPlaceShiftRelationshipEntity>((x, sr) => x.Code == sr.PlaceCode)
|
||||
.Where(x => x.Code == registry.BusinessPlaceCode)
|
||||
.Select((x, sr) => new
|
||||
{
|
||||
x.Code,
|
||||
sr.ShiftCode,
|
||||
x.TenantId
|
||||
})
|
||||
.FirstAsync();
|
||||
|
||||
|
||||
//获取当前消费餐次
|
||||
var shifts = await DbContext.Queryable<BusinessShiftMealRelationshipEntity>().Where(x => x.ShiftCode == businessPlaceInfo.ShiftCode).ToListAsync();
|
||||
|
||||
var shift = shifts.FirstOrDefault(x => new TimePeriod()
|
||||
{
|
||||
Start = x.Start,
|
||||
End = x.End
|
||||
}.IsPresent1(request.CostDateTime));
|
||||
|
||||
var costDate = await GetCostDateAsync(shift, request.CostDateTime);
|
||||
|
||||
var shiftType = shift?.ShiftType;
|
||||
|
||||
await DbContext.Updateable<CanteenOrderEntity>()
|
||||
.SetColumns(x => x.BusinessShiftCode == businessPlaceInfo.ShiftCode)
|
||||
.SetColumns(x => x.CostDate == costDate)
|
||||
.SetColumns(x => x.CostDateTime == request.CostDateTime)
|
||||
.SetColumns(x => x.ShiftType == shiftType)
|
||||
.Where(x => x.No == item.No)
|
||||
.ExecuteCommandAsync();
|
||||
|
||||
await DbContext.Updateable<BalanceRecordEntity>()
|
||||
.SetColumns(x => x.BusinessShiftCode == businessPlaceInfo.ShiftCode)
|
||||
.SetColumns(x => x.CostDate == costDate)
|
||||
.SetColumns(x => x.CostDateTime == request.CostDateTime)
|
||||
.SetColumns(x => x.ShiftType == shiftType)
|
||||
.Where(x => x.No == item.No)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
|
||||
//******************************************************* help methods ************************************************************/
|
||||
|
||||
/// <summary>
|
||||
@@ -637,56 +575,6 @@ public class OrderService : BaseOrderService, IOrderService
|
||||
// }
|
||||
}
|
||||
|
||||
public async Task ReCalcOfflineAsync(ReCalcOfflineRequest request)
|
||||
{
|
||||
var gainfo = await DbContext.Queryable<GainfoEntity>().Where(x => x.Code == request.UserCode).FirstAsync();
|
||||
var nos = await DbContext.Queryable<BalanceRecordEntity>().Where(x => x.UserCode == request.UserCode).Select(x => x.No).ToListAsync();
|
||||
|
||||
var orders = await DbContext.Queryable<CanteenOrderEntity>()
|
||||
.Where(x => x.IsOffline)
|
||||
.Where(x => !nos.Contains(x.No))
|
||||
.Where(x => x.UserCode == request.UserCode)
|
||||
.ToListAsync();
|
||||
|
||||
|
||||
var gainfoMeal = await DbContext.Queryable<GainfoMealEntity>().Where(x => x.UserNo == gainfo.No).FirstAsync();
|
||||
if (gainfoMeal == null)
|
||||
{
|
||||
gainfoMeal = new GainfoMealEntity
|
||||
{
|
||||
Balance = 0,
|
||||
BalanceOfRecharge = 0,
|
||||
BalanceOfSubsidies = 0,
|
||||
Version = 0,
|
||||
UserNo = gainfo.No,
|
||||
UserCode = gainfo.Code,
|
||||
};
|
||||
|
||||
await DbContext.InsertAsync(gainfoMeal);
|
||||
}
|
||||
|
||||
foreach (var order in orders)
|
||||
{
|
||||
await CommonHelper.RetryAsync(async () =>
|
||||
{
|
||||
var currentGainfoMeal = await DbContext.Queryable<GainfoMealEntity>().Where(x => x.UserNo == order.UserNo).FirstAsync();
|
||||
//金额+-
|
||||
currentGainfoMeal.Balance += order.Amount;
|
||||
|
||||
await DbContext.Updateable<GainfoMealEntity>()
|
||||
.SetColumns(x => x.Balance == currentGainfoMeal.Balance)
|
||||
.SetColumns(x => x.Version == x.Version + 1)
|
||||
.SetColumns(x => x.ModifiedTime == DateTime.Now)
|
||||
.Where(x => x.UserNo == order.UserNo && x.Version == currentGainfoMeal.Version) //必须与查询时的version一致
|
||||
.ExecuteCommandThrowVersionAsync();
|
||||
//写入记录
|
||||
var balanceRecord = order.Adapt<BalanceRecordEntity>();
|
||||
balanceRecord.Id = 0;
|
||||
await DbContext.InsertAsync(balanceRecord);
|
||||
}, 5);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据二维码获取消费用户
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user