|
|
|
@ -363,7 +363,7 @@ namespace Shentun.Peis.RegisterAsbitems |
|
|
|
}).OrderBy(o => o.ItemType.DisplayOrder) |
|
|
|
.OrderBy(o => o.Asbitem.DisplayOrder) |
|
|
|
.ToList(); |
|
|
|
|
|
|
|
|
|
|
|
var chargeRequests = ( |
|
|
|
from registerCheckAsbitem in await _registerCheckAsbitemRepository.GetQueryableAsync() |
|
|
|
join chargeRequest in await _chargeRequestRepository.GetQueryableAsync() |
|
|
|
@ -565,13 +565,35 @@ namespace Shentun.Peis.RegisterAsbitems |
|
|
|
{ |
|
|
|
if (input != null && input.Asbitems.Any() && input.ChargePays.Any()) |
|
|
|
{ |
|
|
|
#region 验证是否多张同样的卡
|
|
|
|
|
|
|
|
var cardList = input.ChargePays.Where(m => m.PayModeId == "05").ToList(); |
|
|
|
if (cardList.Any()) |
|
|
|
{ |
|
|
|
if (cardList.GroupBy(g => g.CardRegisterId).Count() < cardList.Count) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("同一张会员卡不能重复提交"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 验证项目金额跟收费的金额合计是否一致
|
|
|
|
|
|
|
|
if (input.Asbitems.Sum(s => s.ChargePrice * s.Amount) != input.ChargePays.Sum(s => s.ChargeMoney)) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("收费金额合计跟项目金额合计不一致"); |
|
|
|
} |
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
//更新收费状态
|
|
|
|
List<RegisterCheckAsbitem> registerAsbitems = await _registerCheckAsbitemRepository.GetListAsync(m => input.Asbitems.Select(s => s.RegisterAsbitemId).Contains(m.Id)); |
|
|
|
registerAsbitems.ForEach(f => f.IsCharge = 'Y'); |
|
|
|
#region 插入主表Charge
|
|
|
|
Guid chargeId = GuidGenerator.Create(); |
|
|
|
|
|
|
|
Charge charge = new Charge |
|
|
|
Charge charge = new Charge(chargeId) |
|
|
|
{ |
|
|
|
ChargeFlag = '0', |
|
|
|
InvoiceNo = input.InvoiceNo, |
|
|
|
@ -579,7 +601,7 @@ namespace Shentun.Peis.RegisterAsbitems |
|
|
|
PatientRegisterId = input.PatientRegisterId |
|
|
|
}; |
|
|
|
|
|
|
|
var charge_new = await _chargeRepository.InsertAsync(charge, true); |
|
|
|
var charge_new = await _chargeRepository.InsertAsync(charge); |
|
|
|
|
|
|
|
#region 收费项目
|
|
|
|
|
|
|
|
@ -591,7 +613,7 @@ namespace Shentun.Peis.RegisterAsbitems |
|
|
|
{ |
|
|
|
Amount = item.Amount, |
|
|
|
AsbitemId = item.AsbitemId, |
|
|
|
ChargeId = charge_new.Id, |
|
|
|
ChargeId = chargeId, |
|
|
|
RegisterAsbitemId = item.RegisterAsbitemId, |
|
|
|
ChargePrice = item.ChargePrice |
|
|
|
}); |
|
|
|
@ -611,8 +633,11 @@ namespace Shentun.Peis.RegisterAsbitems |
|
|
|
{ |
|
|
|
if (item.PayModeId == "05") |
|
|
|
{ |
|
|
|
|
|
|
|
Guid cardBillId = GuidGenerator.Create(); |
|
|
|
|
|
|
|
//会员卡
|
|
|
|
CardBill cardBill = new CardBill(GuidGenerator.Create()) |
|
|
|
CardBill cardBill = new CardBill(cardBillId) |
|
|
|
{ |
|
|
|
PayModeId = item.PayModeId, |
|
|
|
BillFlag = CardBillFlag.Deduction, |
|
|
|
@ -620,17 +645,18 @@ namespace Shentun.Peis.RegisterAsbitems |
|
|
|
CardRegisterId = item.CardRegisterId.Value |
|
|
|
}; |
|
|
|
cardBill = _cardBillManager.CreateAsync(cardBill); |
|
|
|
var cardBill_new = await _cardBillRepository.InsertAsync(cardBill); |
|
|
|
if (cardBill_new != null) |
|
|
|
await _cardBillRepository.InsertAsync(cardBill); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
chargePays.Add(new ChargePay |
|
|
|
{ |
|
|
|
chargePays.Add(new ChargePay |
|
|
|
{ |
|
|
|
ChargeMoney = item.ChargeMoney, |
|
|
|
PayModeId = item.PayModeId, |
|
|
|
ChargeId = charge_new.Id, |
|
|
|
CardBillId = cardBill_new.Id |
|
|
|
}); |
|
|
|
} |
|
|
|
ChargeMoney = item.ChargeMoney, |
|
|
|
PayModeId = item.PayModeId, |
|
|
|
ChargeId = charge_new.Id, |
|
|
|
CardBillId = cardBillId |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
#region 扣除会员卡余额
|
|
|
|
|
|
|
|
|