diff --git a/Src/Dlhis.Canteen/Order/Services/ConsumeHandlers/OrderCommonHandler.cs b/Src/Dlhis.Canteen/Order/Services/ConsumeHandlers/OrderCommonHandler.cs
index 21ac6801..08d5164e 100644
--- a/Src/Dlhis.Canteen/Order/Services/ConsumeHandlers/OrderCommonHandler.cs
+++ b/Src/Dlhis.Canteen/Order/Services/ConsumeHandlers/OrderCommonHandler.cs
@@ -80,7 +80,7 @@ public class OrderCommonHandler : IOrderCommonHandler
{
b.Code,
bs.ShiftCode,
- Factory = x.TenantId
+ Factory = b.TenantId
})
.SingleAsync();
@@ -111,7 +111,7 @@ public class OrderCommonHandler : IOrderCommonHandler
BusinessShiftCode = bindingInfo.ShiftCode
};
}
-
+
///
/// 消费更新处理
///
diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs
index 9978e812..c674bbc2 100644
--- a/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs
+++ b/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs
@@ -487,143 +487,7 @@ public class OrderService : IOrderService
return await _dbContext.Queryable().Where(x => x.Code == gainfoQrCode.UserCode).SingleAsync();
}
-
- ///
- /// 电子餐券消费
- ///
- ///
- ///
- ///
- ///
- ///
- private async Task EMealVoucherConsumeAsync(ConsumeRequest request, GainfoEntity gainfo, string originData, string no, string idNo)
- {
- var now = DateTime.Now;
-
- var current = await _dbContext.Queryable()
- .Where(x => x.No == no && x.IdNo == idNo)
- .Select(x => new { x.Name, x.Start, x.End })
- .SingleAsync();
-
- (now >= current.Start && now <= current.End).ThrowIfFalse("餐券已过期");
-
-
- var eMealVoucher = await _dbContext.Queryable().Where(x => x.No == no).SingleAsync();
-
- var checkData = await PreCheckAsync(request.DeviceUniqueNo, request.CostDateTime);
- var isSupermarket = await _dbContext.Queryable().Where(x => x.Code == checkData.BusinessPlaceCode)
- .Select(x => x.Catalog == CanteenBusinessPlaceCatalogEnumType.Supermarket)
- .SingleAsync();
-
- isSupermarket.ThrowIfTrue("禁止在超市消费");
-
- eMealVoucher.Factories.Contains(checkData.Factory).ThrowIfFalse("禁止在当前厂区消费");
-
- gainfo.No = originData;
- var order = await _orderRepository.CreateDeviceConsumeOrderAsync(checkData, request, gainfo);
-
- await TryConsumeAsync(order.Id, async () =>
- {
- await CommonHelper.RetryAsync(async () =>
- {
- var detail = await _dbContext.Queryable().Where(x => x.No == no && x.IdNo == idNo).SingleAsync();
- //金额+-
- detail.Balance += order.Amount;
- (detail.Balance < 0).ThrowIfTrue("余额不足,无法消费");
-
- await _dbContext.Updateable()
- .SetColumns(x => x.Balance == detail.Balance)
- .SetColumns(x => x.Version == x.Version + 1)
- .SetColumns(x => x.ModifiedTime == DateTime.Now)
- .Where(x => x.No == no && x.IdNo == idNo && x.Version == detail.Version) //必须与查询时的version一致
- .ExecuteCommandThrowVersionAsync();
-
- //写入记录
- var balanceRecord = order.Adapt();
- balanceRecord.Remark = $"({no})" + current.Name;
- await _dbContext.InsertAsync(balanceRecord);
- }, 5);
- });
- }
-
- ///
- /// 消费前预检
- ///
- ///
- ///
- ///
- private async Task PreCheckAsync(string deviceUniqueNo, DateTime costDateTime)
- {
- var device = await _dbContext.Queryable().Where(x => x.UniqueNo == deviceUniqueNo).SingleAsync();
- device.ThrowIfNull("设备尚未登记");
- device.Enable.ThrowIfFalse("设备已被停用");
- (device.Type != DeviceTypeEnumType.Meal).ThrowIfTrue("设备类型有误");
-
- var bindingInfo = await _dbContext.Queryable()
- .LeftJoin((x, b) => x.BusinessPlaceCode == b.Code)
- .LeftJoin((x, b, bs) => bs.PlaceCode == b.Code)
- .Where(x => x.DeviceUniqueNo == deviceUniqueNo && x.BusinessPlaceCode.HasValue)
- .Select((x, b, bs) => new
- {
- b.Code, bs.ShiftCode, Factory = b.TenantId
- })
- .SingleAsync();
-
- bindingInfo.ThrowIfNull("设备尚未登记营业点");
-
- //获取当前消费餐次
- var shifts = await _dbContext.Queryable()
- .Where(x => x.ShiftCode == bindingInfo.ShiftCode)
- .Select(x => new { x.ShiftType, x.Start, x.End })
- .ToListAsync();
- shifts.ThrowIfEmpty("营业点餐次尚未设置");
-
- var shift = shifts.FirstOrDefault(x => new TimePeriod
- {
- Start = x.Start,
- End = x.End
- }.IsPresent(costDateTime));
- shift.ThrowIfNull("非就餐时间");
-
- var costDate = await _canteenSettingService.GetCostDateAsync(bindingInfo.Factory, costDateTime);
-
- return new OrderPreCheckDto
- {
- Factory = bindingInfo.Factory,
- CostDate = costDate,
- ShiftType = shift!.ShiftType,
- BusinessPlaceCode = bindingInfo.Code,
- BusinessShiftCode = bindingInfo.ShiftCode
- };
- }
-
- ///
- /// 设置设备ip
- ///
- ///
- private async Task SetDeviceIpInfoAsync(string deviceNo)
- {
- try
- {
- if (_httpContextAccessor.HttpContext!.Request.Headers.TryGetValue("X-Requested-DeviceIp", out var ip))
- {
- var device = await _dbContext.Queryable().Where(x => x.UniqueNo == deviceNo).SingleAsync();
- device.ConnectionInfo = new
- {
- ip = ip.ToString()
- }.ToJson();
-
- await _dbContext.UpdateAsync(device);
- }
-
- _logger.LogInformation("设备ip获取:{deviceNo} {ip}", deviceNo, ip);
- }
- catch (Exception)
- {
- //ignore
- }
- }
-
+
///
/// 检查是否能够进行离线消费,处理hpt重复提交
///