diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoCardService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoCardService.cs index ab5abeeb..fe50aada 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoCardService.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoCardService.cs @@ -36,15 +36,27 @@ public class GainfoCardService : IGainfoCardService var gainfo = await _gainfoStore.Queryable().Where(x => x.No == request.UserNo).FirstAsync(); gainfo.ThrowIfNull("档案不存在"); + if (gainfo.CardNo == request.CardNo) + { + true.ThrowIfTrue("卡号未发生变化"); + } + + if (gainfo.CardNo.IsPresent()) + { + var oldCardRecord = new GainfoCardRecordEntity + { + UserNo = gainfo.No, + CardNo = gainfo.CardNo, + Reason = "换卡", + Remark = $"换卡前卡号:{gainfo.CardNo}" + }; + oldCardRecord.TenantId = gainfo.Factory; + await _dbContext.InsertAsync(oldCardRecord); + } gainfo.CardNo = request.CardNo; - await _gainfoStore.UpdateAsync(gainfo); - var cardRecord = request.Adapt(); - cardRecord.TenantId = gainfo.Factory; - await _dbContext.InsertAsync(cardRecord); - await _gainfoPermissionService.ResetPermissionsAsync(gainfo.No, DeviceTaskEnumType.Update, null, null, "更新卡号下发"); }