Browse Source

Merge branch 'develop' of http://132.232.92.186:3000/XinXiBu/OA2023 into develop

wangh 1 year ago
parent
commit
8dcc123210

+ 25 - 5
OASystem/OASystem.Infrastructure/Repositories/Financial/PaymentRefundAndOtherMoneyRepository.cs

@@ -56,7 +56,8 @@ namespace OASystem.Infrastructure.Repositories.Financial
 				                         From Fin_PaymentRefundAndOtherMoney prom
 				                         Left Join Sys_Users u On u.Id = prom.CreateUserId 
 				                         Left Join Sys_SetData sd On prom.CurrencyId = sd.Id
-					                     Left Join Grp_CreditCardPayment ccp On ccp.CTable = 98 And ccp.CId = prom.Id
+					                     Left Join Grp_CreditCardPayment ccp 
+                                         On ccp.CTable = 98 And ccp.CId = prom.Id And ccp.DIId = prom.DiId
 				                         Where prom.IsDel = 0 And u.IsDel = 0 And sd.IsDel = 0 And  ccp.IsDel = 0
 					                     And prom.DiId = {0}", diId);
 
@@ -195,8 +196,8 @@ namespace OASystem.Infrastructure.Repositories.Financial
 										 ccp.OrbitalPrivateTransfer,ccp.ConsumptionPatterns,prom.PayType,prom.Remark
 										 From Fin_PaymentRefundAndOtherMoney prom 
 										 Left Join Grp_CreditCardPayment ccp On ccp.CId = prom.id And ccp.CTable = 98 And ccp.IsDel = 0
-										 Where prom.IsDel = 0 And prom.Id = {0}", dto.Id);
-                var data = await _sqlSugar.SqlQueryable<Fin_PaymentRefundAndOtherMoneyInfoView>(sql).ToListAsync();
+										 Where prom.IsDel = 0 And ccp.DIId = prom.DiId And prom.Id = {0}", dto.Id);
+                var data = await _sqlSugar.SqlQueryable<Fin_PaymentRefundAndOtherMoneyInfoView>(sql).FirstAsync();
 
                 if (data != null)
                 {
@@ -233,7 +234,7 @@ namespace OASystem.Infrastructure.Repositories.Financial
                 Fin_PaymentRefundAndOtherMoney _PaymentRefundAndOtherMoney = new Fin_PaymentRefundAndOtherMoney() { 
                     //Id = dto.Id,
                     DiId = dto.DiId,
-                    PriceName = dto.PriceName,
+                    PriceName = dto.PriceName.Trim(),
                     Price = dto.Price,
                     CurrencyId = dto.CurrencyId,
                     PayType = dto.PayType,
@@ -332,6 +333,25 @@ namespace OASystem.Infrastructure.Repositories.Financial
 
                 if (dto.Status == 1) //添加
                 {
+                    #region 添加数据验证
+
+                    string sql = string.Format(@"Select prom.Id,ccp.Id CcpId,prom.DiId,prom.PriceName,prom.Price,prom.CurrencyId,ccp.Payee,ccp.PayDId,
+										 ccp.OrbitalPrivateTransfer,ccp.ConsumptionPatterns,prom.PayType,prom.Remark
+										 From Fin_PaymentRefundAndOtherMoney prom 
+										 Left Join Grp_CreditCardPayment ccp On ccp.CId = prom.id And ccp.CTable = 98 
+										 Where prom.IsDel = 0 And ccp.IsDel = 0 And ccp.DIId = prom.DiId And prom.PriceName = '{0}'",
+                                         _PaymentRefundAndOtherMoney.PriceName);
+                    var data = await _sqlSugar.SqlQueryable<Fin_PaymentRefundAndOtherMoneyInfoView>(sql).FirstAsync();
+
+                    if (data != null)
+                    {
+                        _result.Msg = "费用名称已存在,请勿重新添加!";
+                        return _result;
+                    }
+                   
+                    #endregion
+
+
                     _sqlSugar.BeginTran();
 
                     var addReturnId = await _sqlSugar.Insertable(_PaymentRefundAndOtherMoney).ExecuteReturnIdentityAsync();
@@ -362,7 +382,7 @@ namespace OASystem.Infrastructure.Repositories.Financial
 
                     _sqlSugar.BeginTran();
 
-                    var prom_update = await _sqlSugar.Updateable(_CreditCardPayment)
+                    var prom_update = await _sqlSugar.Updateable(_PaymentRefundAndOtherMoney)
                                                      .IgnoreColumns(it => new { it.CreateUserId, it.CreateTime, it.DeleteUserId, it.DeleteTime, it.IsDel })
                                                      .WhereColumns(it => new { it.Id })
                                                      .ExecuteCommandAsync();