RedPackApplication.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using Hotline.Orders;
  2. using Hotline.Share.Dtos.Snapshot;
  3. using Hotline.Share.Enums.Order;
  4. using Hotline.Share.Tools;
  5. using Hotline.Snapshot;
  6. using Hotline.Snapshot.Interfaces;
  7. using SqlSugar;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using XF.Domain.Dependency;
  14. namespace Hotline.Application.Snapshot;
  15. public class RedPackApplication : IRedPackApplication, IScopeDependency
  16. {
  17. private readonly IOrderSnapshotRepository _orderSnapshotRepository;
  18. public RedPackApplication(IOrderSnapshotRepository orderSnapshotRepository)
  19. {
  20. _orderSnapshotRepository = orderSnapshotRepository;
  21. }
  22. public ISugarQueryable<SnapshotOrderAuditItemsOutDto> GetRedPackAuditItemsAsync(SnapshotOrderAuditItemsInDto dto)
  23. {
  24. var query = _orderSnapshotRepository.Queryable()
  25. .LeftJoin<Order>((s, o) => s.Id == o.Id)
  26. .LeftJoin<RedPackAudit>((s, o, r) => s.Id == r.OrderId)
  27. .LeftJoin<RedPackRecord>((s, o, r, j) => s.Id == j.OrderId)
  28. .LeftJoin<Industry>((s, o, r, j, i) => s.IndustryId == i.Id)
  29. .WhereIF(dto.No.NotNullOrEmpty(), (s, o, r, j) => o.No.Contains(dto.No))
  30. .WhereIF(dto.Title.NotNullOrEmpty(), (s, o, r, j) => o.Title.Contains(dto.Title))
  31. .WhereIF(dto.FromPhone.NotNullOrEmpty(), (s, o, r, j) => o.FromPhone.Contains(dto.FromPhone))
  32. .WhereIF(dto.BeginCreationTime.HasValue && dto.EndCreationTime.HasValue, (s, o, r, j) => o.CreationTime <= dto.EndCreationTime && o.CreationTime >= dto.BeginCreationTime)
  33. .WhereIF(dto.IsDeal.HasValue, (s, o, r, j) => s.IsDeal == dto.IsDeal)
  34. .WhereIF(dto.IsTruth.HasValue, (s, o, r, j) => s.IsTruth == dto.IsTruth)
  35. .WhereIF(dto.BeginAuditTime.HasValue && dto.EndAuditTime.HasValue, (s, o, r, j) => r.AuditTime <= dto.EndAuditTime && r.AuditTime >= dto.BeginAuditTime)
  36. .WhereIF(dto.IsIssued.HasValue, (s, o, r, j)=> r.IsIssued == dto.IsIssued)
  37. .WhereIF(dto.IndustryId.NotNullOrEmpty(), (s, o, r, j) => s.IndustryId == dto.IndustryId)
  38. .WhereIF(dto.ConfigAmount.HasValue, (s, o, r, j, i) => i.CitizenReadPackAmount == dto.ConfigAmount)
  39. .WhereIF(dto.AcutalAmount.HasValue, (s, o, r, j) => r.AcutalAmount == dto.AcutalAmount)
  40. .WhereIF(dto.ApprovedAmount.HasValue, (s, o, r, j) => r.ApprovedAmount == dto.ApprovedAmount)
  41. .WhereIF(dto.IsDanger.HasValue, (s, o, r, j) => s.IsDanger == dto.IsDanger)
  42. .Select((s, o, r, j) => new SnapshotOrderAuditItemsOutDto
  43. {
  44. No = o.No,
  45. Title = o.Title,
  46. IndustryName = s.IndustryName,
  47. IndustryId = s.IndustryId,
  48. SourceChannel = o.SourceChannel,
  49. SourceChannelCode = o.SourceChannelCode,
  50. Status = o.Status,
  51. IsDanger = s.IsDanger,
  52. FromPhone = o.FromPhone,
  53. FromName = o.FromName,
  54. AuditTime = r.AuditTime,
  55. ApprovedAmount = r.ApprovedAmount,
  56. AcutalAmount = r.AcutalAmount,
  57. IsIssued = r.IsIssued,
  58. RecordRemark = j.Remark,
  59. County = o.County,
  60. // IsRectify = s.IsRepetition
  61. IsDeal = s.IsDeal,
  62. NetworkENumber = s.NetworkENumber,
  63. IsTruth = s.IsTruth,
  64. IsRepetition = s.IsRepetition,
  65. CreationTime = o.CreationTime,
  66. OrgLevelOneCode = o.OrgLevelOneCode,
  67. OrgLevelOneName = o.OrgLevelOneName,
  68. AuditId = r.AuditId,
  69. AuditName = r.AuditName,
  70. AuditOrgId = r.AuditOrgId,
  71. AuditOrgName = r.AuditOrgName,
  72. AuditRemark = r.AuditRemark,
  73. BankCardNo = j.BankCardNo,
  74. OpenBank = j.OpenBank,
  75. });
  76. return query;
  77. }
  78. }