Skip to content

Commit ccf9e62

Browse files
committed
Merge branch 'issue-1511-Search-return-requests-by-customer-number-dates-status' into develop
2 parents 1d5bdfc + f9895af commit ccf9e62

File tree

9 files changed

+300
-93
lines changed

9 files changed

+300
-93
lines changed

src/Libraries/Nop.Services/Orders/IReturnRequestService.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.Collections.Generic;
23
using Nop.Core;
34
using Nop.Core.Domain.Orders;
@@ -21,20 +22,23 @@ public partial interface IReturnRequestService
2122
/// <param name="returnRequestId">Return request identifier</param>
2223
/// <returns>Return request</returns>
2324
ReturnRequest GetReturnRequestById(int returnRequestId);
24-
25+
2526
/// <summary>
2627
/// Search return requests
2728
/// </summary>
2829
/// <param name="storeId">Store identifier; 0 to load all entries</param>
2930
/// <param name="customerId">Customer identifier; 0 to load all entries</param>
3031
/// <param name="orderItemId">Order item identifier; 0 to load all entries</param>
32+
/// <param name="customNumber">Custom number; null or empty to load all entries</param>
3133
/// <param name="rs">Return request status; null to load all entries</param>
34+
/// <param name="createdFromUtc">Created date from (UTC); null to load all records</param>
35+
/// <param name="createdToUtc">Created date to (UTC); null to load all records</param>
3236
/// <param name="pageIndex">Page index</param>
3337
/// <param name="pageSize">Page size</param>
3438
/// <returns>Return requests</returns>
3539
IPagedList<ReturnRequest> SearchReturnRequests(int storeId = 0, int customerId = 0,
36-
int orderItemId = 0, ReturnRequestStatus? rs = null,
37-
int pageIndex = 0, int pageSize = int.MaxValue);
40+
int orderItemId = 0, string customNumber = "", ReturnRequestStatus? rs = null, DateTime? createdFromUtc = null,
41+
DateTime? createdToUtc = null, int pageIndex = 0, int pageSize = int.MaxValue);
3842

3943

4044

src/Libraries/Nop.Services/Orders/ReturnRequestService.cs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,23 @@ public virtual ReturnRequest GetReturnRequestById(int returnRequestId)
7373

7474
return _returnRequestRepository.GetById(returnRequestId);
7575
}
76-
76+
7777
/// <summary>
7878
/// Search return requests
7979
/// </summary>
8080
/// <param name="storeId">Store identifier; 0 to load all entries</param>
81-
/// <param name="customerId">Customer identifier; null to load all entries</param>
81+
/// <param name="customerId">Customer identifier; 0 to load all entries</param>
8282
/// <param name="orderItemId">Order item identifier; 0 to load all entries</param>
83+
/// <param name="customNumber">Custom number; null or empty to load all entries</param>
8384
/// <param name="rs">Return request status; null to load all entries</param>
85+
/// <param name="createdFromUtc">Created date from (UTC); null to load all records</param>
86+
/// <param name="createdToUtc">Created date to (UTC); null to load all records</param>
8487
/// <param name="pageIndex">Page index</param>
8588
/// <param name="pageSize">Page size</param>
8689
/// <returns>Return requests</returns>
87-
public virtual IPagedList<ReturnRequest> SearchReturnRequests(int storeId = 0, int customerId = 0,
88-
int orderItemId = 0, ReturnRequestStatus? rs = null,
89-
int pageIndex = 0, int pageSize = int.MaxValue)
90+
public IPagedList<ReturnRequest> SearchReturnRequests(int storeId = 0, int customerId = 0,
91+
int orderItemId = 0, string customNumber = "", ReturnRequestStatus? rs = null, DateTime? createdFromUtc = null,
92+
DateTime? createdToUtc = null, int pageIndex = 0, int pageSize = int.MaxValue)
9093
{
9194
var query = _returnRequestRepository.Table;
9295
if (storeId > 0)
@@ -101,6 +104,14 @@ public virtual IPagedList<ReturnRequest> SearchReturnRequests(int storeId = 0, i
101104
if (orderItemId > 0)
102105
query = query.Where(rr => rr.OrderItemId == orderItemId);
103106

107+
if(!string.IsNullOrEmpty(customNumber))
108+
query = query.Where(rr => rr.CustomNumber == customNumber);
109+
110+
if (createdFromUtc.HasValue)
111+
query = query.Where(rr => createdFromUtc.Value <= rr.CreatedOnUtc);
112+
if (createdToUtc.HasValue)
113+
query = query.Where(rr => createdToUtc.Value >= rr.CreatedOnUtc);
114+
104115
query = query.OrderByDescending(rr => rr.CreatedOnUtc).ThenByDescending(rr=>rr.Id);
105116

106117
var returnRequests = new PagedList<ReturnRequest>(query, pageIndex, pageSize);

src/Presentation/Nop.Web/Administration/Controllers/ReturnRequestController.cs

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Linq;
34
using System.Web.Mvc;
45
using Nop.Admin.Models.Orders;
56
using Nop.Core;
67
using Nop.Core.Domain.Customers;
7-
using Nop.Core.Domain.Localization;
88
using Nop.Core.Domain.Orders;
9+
using Nop.Services;
910
using Nop.Services.Customers;
1011
using Nop.Services.Helpers;
1112
using Nop.Services.Localization;
@@ -118,16 +119,37 @@ public ActionResult List()
118119
if (!_permissionService.Authorize(StandardPermissionProvider.ManageReturnRequests))
119120
return AccessDeniedView();
120121

121-
return View();
122+
var model = new ReturnRequestListModel
123+
{
124+
ReturnRequestStatusList = ReturnRequestStatus.Cancelled.ToSelectList(false).ToList(),
125+
ReturnRequestStatusId = -1
126+
};
127+
128+
model.ReturnRequestStatusList.Insert(0, new SelectListItem
129+
{
130+
Value = "-1",
131+
Text = _localizationService.GetResource("Admin.ReturnRequests.SearchReturnRequestStatus.All"),
132+
Selected = true
133+
});
134+
135+
return View(model);
122136
}
123137

124138
[HttpPost]
125-
public ActionResult List(DataSourceRequest command)
139+
public ActionResult List(DataSourceRequest command, ReturnRequestListModel model)
126140
{
127141
if (!_permissionService.Authorize(StandardPermissionProvider.ManageReturnRequests))
128142
return AccessDeniedView();
129143

130-
var returnRequests = _returnRequestService.SearchReturnRequests(0, 0, 0, null, command.Page - 1, command.PageSize);
144+
var rrs = model.ReturnRequestStatusId == -1 ? null : (ReturnRequestStatus?) model.ReturnRequestStatusId;
145+
146+
var startDateValue = model.StartDate == null ? null
147+
: (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.StartDate.Value, _dateTimeHelper.CurrentTimeZone);
148+
149+
var endDateValue = model.EndDate == null ? null
150+
: (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.EndDate.Value, _dateTimeHelper.CurrentTimeZone).AddDays(1);
151+
152+
var returnRequests = _returnRequestService.SearchReturnRequests(0, 0, 0, model.CustomNumber, rrs, startDateValue, endDateValue, command.Page - 1, command.PageSize);
131153
var returnRequestModels = new List<ReturnRequestModel>();
132154
foreach (var rr in returnRequests)
133155
{
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel.DataAnnotations;
4+
using System.Web.Mvc;
5+
using Nop.Web.Framework;
6+
using Nop.Web.Framework.Mvc;
7+
8+
namespace Nop.Admin.Models.Orders
9+
{
10+
public class ReturnRequestListModel: BaseNopModel
11+
{
12+
public ReturnRequestListModel()
13+
{
14+
ReturnRequestStatusList = new List<SelectListItem>();
15+
}
16+
17+
[NopResourceDisplayName("Admin.ReturnRequests.SearchStartDate")]
18+
[UIHint("DateNullable")]
19+
public DateTime? StartDate { get; set; }
20+
21+
[NopResourceDisplayName("Admin.ReturnRequests.SearchEndDate")]
22+
[UIHint("DateNullable")]
23+
public DateTime? EndDate { get; set; }
24+
25+
[NopResourceDisplayName("Admin.ReturnRequests.SearchCustomNumber")]
26+
public string CustomNumber { get; set; }
27+
28+
[NopResourceDisplayName("Admin.ReturnRequests.SearchReturnRequestStatus")]
29+
public int ReturnRequestStatusId { get; set; }
30+
public IList<SelectListItem> ReturnRequestStatusList { get; set; }
31+
}
32+
}

src/Presentation/Nop.Web/Administration/Nop.Admin.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@
246246
<Compile Include="Models\Messages\TestMessageTemplateModel.cs" />
247247
<Compile Include="Models\Orders\CountryReportLineModel.cs" />
248248
<Compile Include="Models\Orders\CountryReportModel.cs" />
249+
<Compile Include="Models\Orders\ReturnRequestListModel.cs" />
249250
<Compile Include="Models\Payments\PaymentMethodRestrictionModel.cs" />
250251
<Compile Include="Models\Plugins\OfficialFeedListModel.cs" />
251252
<Compile Include="Models\Plugins\PluginListModel.cs" />

0 commit comments

Comments
 (0)