GroupCommission.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. using Microsoft.AspNetCore.Components.Web;
  2. using OASystem.Domain.Dtos.Financial;
  3. using OASystem.Domain.Dtos.Groups;
  4. using OASystem.Domain.ViewModels.Financial;
  5. using OASystem.Domain.ViewModels.Groups;
  6. using OASystem.Infrastructure.Repositories.Financial;
  7. using OASystem.Infrastructure.Repositories.Groups;
  8. namespace OASystem.API.OAMethodLib
  9. {
  10. /// <summary>
  11. /// 团组提成
  12. /// 雷怡 2023-08-14 16:04
  13. /// </summary>
  14. public static class GroupCommission
  15. {
  16. //团组信息
  17. private readonly static DelegationInfoRepository _dirRep = AutofacIocManager.Instance.GetService<DelegationInfoRepository>();
  18. //团组实付金额
  19. private readonly static CreditCardPaymentRepository _ccpRep = AutofacIocManager.Instance.GetService<CreditCardPaymentRepository>();
  20. //团组应收款项
  21. private readonly static ForeignReceivablesRepository _frRep = AutofacIocManager.Instance.GetService<ForeignReceivablesRepository>();
  22. //团组已收款项
  23. private readonly static ProceedsReceivedRepository _prRep = AutofacIocManager.Instance.GetService<ProceedsReceivedRepository>();
  24. //团组其他款项
  25. private readonly static OtherPriceRepository _opRep = AutofacIocManager.Instance.GetService<OtherPriceRepository>();
  26. /// <summary>
  27. /// 获取团组提成 Page List
  28. /// </summary>
  29. public static async Task<Result> GetCommissionPageList(GroupCommissionDto dto)
  30. {
  31. Result result = new Result() { Code = -1 };
  32. GroupListPageDto groupPageDto = new GroupListPageDto() { PortType = dto.PortType, PageIndex = dto.PageIndex, PageSize = dto.PageSize };
  33. var groupResult = await _dirRep.GetGroupPageList(groupPageDto);
  34. if (groupResult.Code != 0)
  35. {
  36. result.Code = groupResult.Code;
  37. result.Msg = groupResult.Msg;
  38. return result;
  39. }
  40. if (groupResult.Data == null) { }
  41. //List<DelegationListView> groupData = groupResult.Data;
  42. result.Data = groupResult.Data;
  43. return result;
  44. }
  45. /// <summary>
  46. /// 根据团组Id计算 团组利润
  47. /// </summary>
  48. /// <param name="DiId">团组Id</param>
  49. public static async void GetCommission(int DiId)
  50. {
  51. decimal sumFr = 0.00M, //团组 应收款项
  52. sumPr = 0.00M, //团组 已收款项
  53. refund = 0.00M, //团组 退款和其他费用
  54. cost = 0.00M; //团组成本费用
  55. if (DiId == 0) return;
  56. #region 计算各项费用
  57. //应收款项
  58. Result frData = await _frRep.GetGroupReceivablesByDiid(DiId);
  59. if (frData.Code == 0 && frData.Data != null)
  60. {
  61. foreach (var item in frData.Data)
  62. {
  63. sumFr += item.Price;
  64. }
  65. }
  66. //已收款项
  67. Result prData = await _prRep.GetGroupReceivedByDiid(DiId);
  68. if (frData.Code == 0 && frData.Data != null)
  69. {
  70. foreach (var item in prData.Data)
  71. {
  72. sumPr += item.Price;
  73. }
  74. }
  75. //收款退还费用
  76. Result ccpData = await _ccpRep.GetGroupRefundByDiid(DiId, true);
  77. if (ccpData.Code == 0 && ccpData.Data != null)
  78. {
  79. foreach (var item in ccpData.Data)
  80. {
  81. refund += item.Price;
  82. }
  83. }
  84. //实际的团组类型已收金额需除去退款
  85. sumPr = sumPr - refund;
  86. //团组与非团组产生的成本费用数据
  87. Result _ccpData = await _ccpRep.GetGroupPaymentInfoByDiid(DiId, true);
  88. if (_ccpData.Code == 0 && _ccpData.Data != null)
  89. {
  90. foreach (Grp_Fin_CreditCardPaymentView item in _ccpData.Data)
  91. {
  92. if (item.PayThenMoney != 0M)
  93. cost += item.PayThenMoney * item.DayRate;
  94. }
  95. }
  96. #endregion
  97. }
  98. }
  99. }