InvoiceInfoController.cs 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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.Common;
  17. using ShwasherSys.CustomerInfo;
  18. using ShwasherSys.Invoice;
  19. using ShwasherSys.OrderSendInfo;
  20. using ShwasherSys.OrderSendInfo.Dto;
  21. using ShwasherSys.ProductInfo;
  22. namespace ShwasherSys.Controllers
  23. {
  24. [AbpMvcAuthorize, AuditLog("发票管理")]
  25. public class InvoiceInfoController : ShwasherControllerBase
  26. {
  27. protected IOrderSendBillAppService OrderSendBillAppService;
  28. public IRepository<OrderSendBill,string> OrderSendBillRepository { get; set; }
  29. protected IRepository<OrderSend> OrderSendRepository;
  30. protected IRepository<ViewOrderSend> ViewOrderSendRepository;
  31. protected IRepository<ViewOrderSendStickBill> ViewOrderSendStickBillRepository;
  32. protected IRepository<Customer,string> CustomerRepository;
  33. protected IStatementBillAppService StatementBillAppService;
  34. protected IRepository<StatementBill> StatementBillRepository;
  35. protected IRepository<OrderStickBill,string> OrderStickBillRepository;
  36. protected IQueryAppService QueryAppService;
  37. 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, IQueryAppService queryAppService)
  38. {
  39. OrderSendBillAppService = orderSendBillAppService;
  40. OrderSendRepository = orderSendRepository;
  41. CustomerRepository = customerRepository;
  42. ViewOrderSendRepository = viewOrderSendRepository;
  43. ViewOrderSendStickBillRepository = viewOrderSendStickBillRepository;
  44. OrderSendBillRepository = orderSendBillRepository;
  45. StatementBillAppService = statementBillAppService;
  46. StatesAppService = statesAppService;
  47. StatementBillRepository = statementBillRepository;
  48. OrderStickBillRepository = orderStickBillRepository;
  49. QueryAppService = queryAppService;
  50. }
  51. [AbpMvcAuthorize(PermissionNames.PagesInvoiceInfoInvoiceCreate), AuditLog("发票创建页面")]
  52. public ActionResult InvoiceCreate()
  53. {
  54. ViewBag.InitStickMan = AbpSession.UserName;
  55. return View();
  56. }
  57. [AbpMvcAuthorize(PermissionNames.PagesInvoiceInfoInvoiceMgShowStickBill), AuditLog("发票详情页面")]
  58. public async Task<ActionResult> InvoiceDetail(string id)
  59. {
  60. if (id.IsNullOrEmpty())
  61. {
  62. throw new UserFriendlyException("未传入对应编号!");
  63. }
  64. ViewBag.SendStickBillNo = id;
  65. var viewOrderSendStickBills =await ViewOrderSendStickBillRepository.GetAll().Where(i => i.OrderStickBillNo == id).OrderBy(i=>i.SendDate).ToListAsync();
  66. ViewBag.OrderSends = viewOrderSendStickBills;
  67. //var bill = await OrderSendBillAppService.Get(new EntityDto<string>(viewOrderSendStickBills.First().OrderSendBillNo));
  68. if (viewOrderSendStickBills.Any())
  69. {
  70. var bill = ObjectMapper.Map<OrderSendBillDto>(
  71. OrderSendBillRepository.Get(viewOrderSendStickBills.First().OrderSendBillNo));
  72. ViewBag.SendBill = bill;
  73. ViewBag.CustomerInfo = CustomerRepository.Get(bill.CustomerId);
  74. }
  75. else
  76. {
  77. ViewBag.CustomerInfo = CustomerRepository.Get(OrderStickBillRepository.FirstOrDefault(i => i.Id == id)?.CustomerId);
  78. }
  79. return View();
  80. }
  81. [AbpMvcAuthorize(PermissionNames.PagesInvoiceInfoInvoiceMg), AuditLog("发票管理页面")]
  82. public ActionResult InvoiceMg()
  83. {
  84. ViewBag.InvoiceState = StatesAppService.GetSelectLists("Invoice", "State");
  85. return View();
  86. }
  87. [AbpMvcAuthorize(PermissionNames.PagesInvoiceInfoStatementBill), AuditLog("对账单管理页面")]
  88. public ActionResult StatementBill()
  89. {
  90. ViewBag.CustomerList = StatementBillAppService.GetHasSendOrderCustomer();
  91. return View();
  92. }
  93. [AbpMvcAuthorize(PermissionNames.PagesInvoiceInfoStatementBillShowStickBill), AuditLog("对账单详情页面")]
  94. public async Task<ActionResult> StatementBillDetail(string id)
  95. {
  96. if (id.IsNullOrEmpty())
  97. {
  98. throw new UserFriendlyException("未传入对应编号!");
  99. }
  100. ViewBag.SendStickBillNo = id;
  101. var viewOrderSendStickBills =await ViewOrderSendStickBillRepository.GetAll().Where(i => i.StatementBillNo == id).OrderBy(i => i.SendDate).ThenBy((i => i.StatementBillSort)).ThenBy(i=>i.ProductName).ToListAsync();
  102. ViewBag.OrderSends = viewOrderSendStickBills;
  103. //var bill = await OrderSendBillAppService.Get(new EntityDto<string>(viewOrderSendStickBills.First().OrderSendBillNo));
  104. Customer customer = null;
  105. if (viewOrderSendStickBills.Any())
  106. {
  107. var bill = ObjectMapper.Map<OrderSendBillDto>(
  108. OrderSendBillRepository.Get(viewOrderSendStickBills.First().OrderSendBillNo));
  109. ViewBag.SendBill = bill;
  110. customer = CustomerRepository.Get(bill.CustomerId);
  111. }
  112. else
  113. {
  114. customer = CustomerRepository.Get(StatementBillRepository.FirstOrDefault(i=>i.StatementBillNo==id)?.CustomerId);
  115. }
  116. ViewBag.CustomerInfo = customer;
  117. if (customer != null)
  118. {
  119. var customerDefaultProducts = await QueryAppService.GetCustomerDefaultProductByCustomerId(customer.Id);
  120. ViewBag.CustomerDefaultProducts = customerDefaultProducts;
  121. var materialProductProperties = await QueryAppService.GetProductPropertyEntity(ProductProperty.ProductMaterial + "");
  122. ViewBag.MaterialProductProperties = materialProductProperties;
  123. }
  124. return View();
  125. }
  126. }
  127. }