ILogistics_ExpressSettlementAdjustmentRepository.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using XYY.Core.Standard.Data.Infrastructure;
  7. using XYY.Model.Standard.Enums;
  8. using XYY.Model.Standard.Finance;
  9. using Dapper;
  10. using System.Security.Policy;
  11. namespace XYY.Data.Standard.Finance
  12. {
  13. public interface ILogistics_ExpressSettlementAdjustmentRepository : IBaseRepository<Logistics_ExpressSettlementAdjustment>
  14. {
  15. Task<List<Tuple<string, string>>> ExpressSettlementAdjustmentLog(Logistics_ExpressSettlementAdjustmentDto adjustmentDto);
  16. }
  17. public class Logistics_ExpressSettlementAdjustmentRepository : BaseRepository<Logistics_ExpressSettlementAdjustment>, ILogistics_ExpressSettlementAdjustmentRepository
  18. {
  19. public Logistics_ExpressSettlementAdjustmentRepository(IUnitOfWork unitOfWork)
  20. : base(unitOfWork)
  21. {
  22. }
  23. public async Task<List<Tuple<string, string>>> ExpressSettlementAdjustmentLog(Logistics_ExpressSettlementAdjustmentDto adjustmentDto)
  24. {
  25. List<Tuple<string, string>> msgs = new List<Tuple<string, string>>();
  26. List<string> zones = adjustmentDto.Details.SelectMany(x => x.Zone.Split(",")).ToList();
  27. List<Logistics_ExpressSettlementAdjustmentDetail> details = new List<Logistics_ExpressSettlementAdjustmentDetail>();
  28. string dec = string.Empty;
  29. foreach (var item in zones)
  30. {
  31. string msg = $"分区[{item}],";
  32. var tempdata = adjustmentDto.Details.Where(x => x.Zone.Contains(item)).FirstOrDefault();
  33. string content = $"{tempdata.Mode.GetName()}:{tempdata.Value};";
  34. dec += msg + content;
  35. msgs.Add(Tuple.Create<string, string>(item, msg + content));
  36. Logistics_ExpressSettlementAdjustmentDetail detail = new Logistics_ExpressSettlementAdjustmentDetail()
  37. {
  38. Zone = item,
  39. IsAll =item== "全部"?true:false,
  40. Mode = tempdata.Mode,
  41. Value = tempdata.Value,
  42. };
  43. details.Add(detail);
  44. }
  45. Logistics_ExpressSettlementAdjustment expressSettlementAdjustment = new Logistics_ExpressSettlementAdjustment()
  46. {
  47. CustomerId = $",{string.Join(",", adjustmentDto.CustomerId)},",
  48. ExpressId = adjustmentDto.ExpressId,
  49. AdjTime = DateTime.Now,
  50. SettlementAdjustmentContent = dec,
  51. };
  52. int Id = (int)(await _unitOfWork.InsertAsync(expressSettlementAdjustment));
  53. details.ForEach(x => x.AdjustmentId = Id);
  54. await _unitOfWork.BulkToDBAsync(details);
  55. return msgs;
  56. }
  57. }
  58. }