You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
3.7 KiB

2 years ago
  1. using EasyBL.WebApi.Message;
  2. using Entity.Sugar;
  3. using Entity.ViewModels;
  4. using Newtonsoft.Json;
  5. using Newtonsoft.Json.Linq;
  6. using SqlSugar;
  7. using SqlSugar.Base;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Data;
  11. using System.Linq;
  12. namespace EasyBL.WEBAPP.OPM
  13. {
  14. public class BillChangeLog_QryService : ServiceBase
  15. {
  16. #region 賬單狀態(分頁查詢)
  17. /// <summary>
  18. /// 賬單狀態(分頁查詢)
  19. /// </summary>
  20. /// <param name="i_crm"></param>
  21. /// <returns></returns>
  22. public ResponseMessage QueryPage(RequestMessage i_crm)
  23. {
  24. ResponseMessage rm = null;
  25. string sMsg = null;
  26. var db = SugarBase.GetIntance();
  27. try
  28. {
  29. do
  30. {
  31. var pml = new PageModel
  32. {
  33. PageIndex = _fetchInt(i_crm, @"pageIndex"),
  34. PageSize = _fetchInt(i_crm, @"pageSize")
  35. };
  36. var iPageCount = 0;
  37. var sSortField = _fetchString(i_crm, @"sortField");
  38. var sSortOrder = _fetchString(i_crm, @"sortOrder");
  39. var sBillNO = _fetchString(i_crm, @"BillNO");
  40. var Operation = _fetchString(i_crm, @"Operation");
  41. var sModifyDateStart = _fetchString(i_crm, @"ModifyDateStart");
  42. var sModifyDateEnd = _fetchString(i_crm, @"ModifyDateEnd");
  43. var rCreateDateStart = new DateTime();
  44. var rCreateDateEnd = new DateTime();
  45. if (!string.IsNullOrEmpty(sModifyDateStart))
  46. {
  47. rCreateDateStart = SqlFunc.ToDate(sModifyDateStart);
  48. }
  49. if (!string.IsNullOrEmpty(sModifyDateEnd))
  50. {
  51. rCreateDateEnd = SqlFunc.ToDate(sModifyDateEnd).AddDays(1);
  52. }
  53. var spOrgID = new SugarParameter("@OrgID", i_crm.ORIGID);
  54. var spUserID = new SugarParameter("@UserID", i_crm.USERID);
  55. pml.DataList = db.Queryable<OTB_OPM_BillChangeLog>()
  56. .Where((t1) => t1.OrgID == i_crm.ORIGID)
  57. .WhereIF(!string.IsNullOrEmpty(sBillNO), (t1) => t1.BillNO.Contains(sBillNO))
  58. .WhereIF(!string.IsNullOrEmpty(sModifyDateStart), (t1) => SqlFunc.ToDate(t1.ModifyDate) >= rCreateDateStart.Date)
  59. .WhereIF(!string.IsNullOrEmpty(sModifyDateEnd), (t1) => SqlFunc.ToDate(t1.ModifyDate) <= rCreateDateEnd.Date)
  60. .WhereIF(!string.IsNullOrEmpty(Operation), (t1) => t1.Operation.Contains(Operation))
  61. .OrderBy(sSortField, sSortOrder)
  62. .ToPageList(pml.PageIndex, pml.PageSize, ref iPageCount);
  63. pml.Total = iPageCount;
  64. rm = new SuccessResponseMessage(null, i_crm);
  65. rm.DATA.Add(BLWording.REL, pml);
  66. } while (false);
  67. }
  68. catch (Exception ex)
  69. {
  70. sMsg = Util.GetLastExceptionMsg(ex);
  71. LogAndSendEmail(sMsg + "Params:" + JsonToString(i_crm), ex, i_crm.ORIGID, i_crm.USERID, nameof(BillStatus_QryService), "", "QueryPage(賬單狀態(分頁查詢))", "", "", "");
  72. }
  73. finally
  74. {
  75. if (null != sMsg)
  76. {
  77. rm = new ErrorResponseMessage(sMsg, i_crm);
  78. }
  79. }
  80. return rm;
  81. }
  82. #endregion 賬單狀態(分頁查詢)
  83. }
  84. }