|
@@ -2,6 +2,7 @@
|
|
|
using OASystem.Domain;
|
|
|
using OASystem.Domain.Dtos.Financial;
|
|
|
using OASystem.Domain.Entities.Financial;
|
|
|
+using OASystem.Domain.Entities.Groups;
|
|
|
using OASystem.Domain.ViewModels.Financial;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
@@ -293,11 +294,11 @@ namespace OASystem.Infrastructure.Repositories.Financial
|
|
|
SectionTime = item.SectionTime,
|
|
|
Price = item.Price,
|
|
|
Currency = item.Currency,
|
|
|
- ReceivablesType= item.ReceivablesType,
|
|
|
+ ReceivablesType = item.ReceivablesType,
|
|
|
Client = item.Client,
|
|
|
- CustomerName= item.CustomerName,
|
|
|
+ CustomerName = item.CustomerName,
|
|
|
CustomerTel = item.CustomerTel,
|
|
|
- Remark= item.Remark
|
|
|
+ Remark = item.Remark
|
|
|
});
|
|
|
if (!res)
|
|
|
{
|
|
@@ -306,7 +307,7 @@ namespace OASystem.Infrastructure.Repositories.Financial
|
|
|
}
|
|
|
updateCount++;
|
|
|
}
|
|
|
- _sqlSugar.CommitTran();
|
|
|
+ _sqlSugar.CommitTran();
|
|
|
//updateCount = x.AsUpdateable.IgnoreColumns(p => new
|
|
|
//{
|
|
|
// p.SectionTime,
|
|
@@ -321,8 +322,52 @@ namespace OASystem.Infrastructure.Repositories.Financial
|
|
|
}
|
|
|
result.Code = 0;
|
|
|
result.Msg = string.Format(@"操作成功!添加:{0}条;更新:{1};", addCount, updateCount);
|
|
|
+
|
|
|
+
|
|
|
+ //修改团组状态
|
|
|
+ int diId = dto.DiId;
|
|
|
+ decimal sum_fr = 0M;
|
|
|
+ decimal sum_pr = 0M;
|
|
|
+ decimal sum_refund = 0M; //收款退还
|
|
|
+ decimal sum_extra = 0M; //超支费用
|
|
|
+
|
|
|
+ //1.应收
|
|
|
+ string sql_fr = string.Format(@" Select * From Fin_ForeignReceivables Where IsDel=0 And Diid={0} ", diId);
|
|
|
+ List<Fin_ForeignReceivables> list_fr = _sqlSugar.SqlQueryable<Fin_ForeignReceivables>(sql_fr).ToList();
|
|
|
+ sum_fr = list_fr.Sum(s => s.ItemSumPrice);
|
|
|
+
|
|
|
+ //2.已收
|
|
|
+ string sql_pr = string.Format(@" Select * From Fin_ProceedsReceived Where IsDel=0 And Diid={0} ", diId);
|
|
|
+ List<Fin_ProceedsReceived> list_pr = _sqlSugar.SqlQueryable<Fin_ProceedsReceived>(sql_pr).ToList();
|
|
|
+ sum_pr = list_pr.Sum(s => s.Price);
|
|
|
+
|
|
|
+ //3.收款退还
|
|
|
+ string sql_other = string.Format(@"Select * From Fin_PaymentRefundAndOtherMoney prao
|
|
|
+ Inner Join Grp_CreditCardPayment ccp On prao.Id = ccp.CId
|
|
|
+ Where ccp.CTable = 285 And ccp.IsPay = 1 And prao.IsDel = 0 And ccp.IsDel = 0 And prao.DiId = {0}", diId);
|
|
|
+ List<Grp_CreditCardPayment> list_other = _sqlSugar.SqlQueryable<Grp_CreditCardPayment>(sql_other).ToList();
|
|
|
+ sum_refund = list_other.Sum(s => s.RMBPrice);
|
|
|
+
|
|
|
+ //4.超支
|
|
|
+ string sql_extra = string.Format(@" Select c.* From Fin_GroupExtraCost f
|
|
|
+ Inner join Grp_CreditCardPayment c On f.Id = c.CId
|
|
|
+ Where c.CTable = 1015 And c.IsPay = 1 And f.IsDel = 0 And c.IsDel = 0 And f.DiId = {0} ", diId);
|
|
|
+ List<Grp_CreditCardPayment> list_extra = _sqlSugar.SqlQueryable<Grp_CreditCardPayment>(sql_extra).ToList();
|
|
|
+ sum_extra = list_extra.Sum(s => s.RMBPrice);
|
|
|
+
|
|
|
+ decimal balance = ((sum_fr + sum_extra) - (sum_pr - sum_refund));
|
|
|
+
|
|
|
+ if (balance <= 0)
|
|
|
+ {
|
|
|
+ bool res = await UpdateAsync<Grp_DelegationInfo>(s => s.Id == dto.DiId, s => new Grp_DelegationInfo
|
|
|
+ {
|
|
|
+ IsSure = 1
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
return result;
|
|
|
}
|
|
|
|