InvoiceInfoController.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data.Entity;
  4. using System.Linq;
  5. using System.Threading.Tasks;
  6. using System.Web;
  7. using System.Web.Mvc;
  8. using Abp.Application.Services.Dto;
  9. using Abp.Domain.Repositories;
  10. using Abp.Extensions;
  11. using Abp.UI;
  12. using Abp.Web.Mvc.Authorization;
  13. using IwbZero.Auditing;
  14. using ShwasherSys.Authorization.Permissions;
  15. using ShwasherSys.BaseSysInfo.States;
  16. using ShwasherSys.CustomerInfo;
  17. using ShwasherSys.Invoice;
  18. using ShwasherSys.OrderSendInfo;
  19. using ShwasherSys.OrderSendInfo.Dto;
  20. namespace ShwasherSys.Controllers
  21. {
  22. [AbpMvcAuthorize, AuditLog("发票管理")]
  23. public class InvoiceInfoController : ShwasherControllerBase
  24. {
  25. protected IOrderSendBillAppService OrderSendBillAppService;
  26. public IRepository<OrderSendBill,string> OrderSendBillRepository { get; set; }
  27. protected IRepository<OrderSend> OrderSendRepository;
  28. protected IRepository<ViewOrderSend> ViewOrderSendRepository;
  29. protected IRepository<ViewOrderSendStickBill> ViewOrderSendStickBillRepository;
  30. protected IRepository<Customer,string> CustomerRepository;
  31. protected IStatementBillAppService StatementBillAppService;
  32. protected IRepository<StatementBill> StatementBillRepository;
  33. protected IRepository<OrderStickBill,string> OrderStickBillRepository;
  34. public InvoiceInfoController(IStatesAppService statesAppService, IOrderSendBillAppService orderSendBillAppService, IRepository<OrderSend> orderSendRepository, IRepository<Customer, string> customerRepository, IRepository<ViewOrderSend> viewOrderSendRepository, IRepository<ViewOrderSendStickBill> viewOrderSendStickBillRepository, IRepository<OrderSendBill, string> orderSendBillRepository, IStatementBillAppService statementBillAppService, IRepository<StatementBill> statementBillRepository,IRepository<OrderStickBill, string> orderStickBillRepository)
  35. {
  36. OrderSendBillAppService = orderSendBillAppService;
  37. OrderSendRepository = orderSendRepository;
  38. CustomerRepository = customerRepository;
  39. ViewOrderSendRepository = viewOrderSendRepository;
  40. ViewOrderSendStickBillRepository = viewOrderSendStickBillRepository;
  41. OrderSendBillRepository = orderSendBillRepository;
  42. StatementBillAppService = statementBillAppService;
  43. StatesAppService = statesAppService;
  44. StatementBillRepository = statementBillRepository;
  45. OrderStickBillRepository = orderStickBillRepository;
  46. }
  47. [AbpMvcAuthorize(PermissionNames.PagesInvoiceInfoInvoiceCreate), AuditLog("发票创建页面")]
  48. public ActionResult InvoiceCreate()
  49. {
  50. ViewBag.InitStickMan = AbpSession.UserName;
  51. return View();
  52. }
  53. [AbpMvcAuthorize(PermissionNames.PagesInvoiceInfoInvoiceMgShowStickBill), AuditLog("发票详情页面")]
  54. public async Task<ActionResult> InvoiceDetail(string id)
  55. {
  56. if (id.IsNullOrEmpty())
  57. {
  58. throw new UserFriendlyException("未传入对应编号!");
  59. }
  60. ViewBag.SendStickBillNo = id;
  61. var viewOrderSendStickBills =await ViewOrderSendStickBillRepository.GetAll().Where(i => i.OrderStickBillNo == id).OrderBy(i=>i.SendDate).ToListAsync();
  62. ViewBag.OrderSends = viewOrderSendStickBills;
  63. //var bill = await OrderSendBillAppService.Get(new EntityDto<string>(viewOrderSendStickBills.First().OrderSendBillNo));
  64. if (viewOrderSendStickBills.Any())
  65. {
  66. var bill = ObjectMapper.Map<OrderSendBillDto>(
  67. OrderSendBillRepository.Get(viewOrderSendStickBills.First().OrderSendBillNo));
  68. ViewBag.SendBill = bill;
  69. ViewBag.CustomerInfo = CustomerRepository.Get(bill.CustomerId);
  70. }
  71. else
  72. {
  73. ViewBag.CustomerInfo = CustomerRepository.Get(OrderStickBillRepository.FirstOrDefault(i => i.Id == id)?.CustomerId);
  74. }
  75. return View();
  76. }
  77. [AbpMvcAuthorize(PermissionNames.PagesInvoiceInfoInvoiceMg), AuditLog("发票管理页面")]
  78. public ActionResult InvoiceMg()
  79. {
  80. ViewBag.InvoiceState = StatesAppService.GetSelectLists("Invoice", "State");
  81. return View();
  82. }
  83. [AbpMvcAuthorize(PermissionNames.PagesInvoiceInfoStatementBill), AuditLog("对账单管理页面")]
  84. public ActionResult StatementBill()
  85. {
  86. ViewBag.CustomerList = StatementBillAppService.GetHasSendOrderCustomer();
  87. return View();
  88. }
  89. [AbpMvcAuthorize(PermissionNames.PagesInvoiceInfoStatementBillShowStickBill), AuditLog("对账单详情页面")]
  90. public async Task<ActionResult> StatementBillDetail(string id)
  91. {
  92. if (id.IsNullOrEmpty())
  93. {
  94. throw new UserFriendlyException("未传入对应编号!");
  95. }
  96. ViewBag.SendStickBillNo = id;
  97. var viewOrderSendStickBills =await ViewOrderSendStickBillRepository.GetAll().Where(i => i.StatementBillNo == id).OrderBy(i => i.SendDate).ThenBy((i => i.StatementBillSort)).ThenBy(i=>i.ProductName).ToListAsync();
  98. ViewBag.OrderSends = viewOrderSendStickBills;
  99. //var bill = await OrderSendBillAppService.Get(new EntityDto<string>(viewOrderSendStickBills.First().OrderSendBillNo));
  100. if (viewOrderSendStickBills.Any())
  101. {
  102. var bill = ObjectMapper.Map<OrderSendBillDto>(
  103. OrderSendBillRepository.Get(viewOrderSendStickBills.First().OrderSendBillNo));
  104. ViewBag.SendBill = bill;
  105. ViewBag.CustomerInfo = CustomerRepository.Get(bill.CustomerId);
  106. }
  107. else
  108. {
  109. ViewBag.CustomerInfo = CustomerRepository.Get(StatementBillRepository.FirstOrDefault(i=>i.StatementBillNo==id)?.CustomerId);
  110. }
  111. return View();
  112. }
  113. }
  114. }