Toggle navigation
Toggle navigation
This project
Loading...
Sign in
open-source
/
warply_sdk_framework
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
Manos Chorianopoulos
2023-07-06 18:59:30 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c72fdbbb393667a100b0388f65a417693d6c1d8a
c72fdbbb
1 parent
28c5a08b
fix redeemed coupons sorting
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
1 deletions
SwiftWarplyFramework/SwiftWarplyFramework/swiftApi.swift
SwiftWarplyFramework/SwiftWarplyFramework/swiftApi.swift
View file @
c72fdbb
...
...
@@ -605,6 +605,7 @@ public class swiftApi {
public
let
barcode
:
String
?
public
let
status
:
Int
?
public
let
redeemed
:
String
?
public
let
redeemed_date
:
Date
?
public
var
couponset_data
:
CouponSetItemModel
?
// Market Coupon
...
...
@@ -669,15 +670,18 @@ public class swiftApi {
let
dateFormatter3
=
DateFormatter
()
dateFormatter3
.
dateFormat
=
"yyyy-MM-dd HH:mm:ss.SSSSSS"
if
let
date
=
dateFormatter3
.
date
(
from
:
redeemedString
??
""
)
{
self
.
redeemed_date
=
date
dateFormatter3
.
dateFormat
=
"dd/MM/yyyy"
let
resultString
=
dateFormatter3
.
string
(
from
:
date
)
self
.
redeemed
=
resultString
}
else
{
self
.
redeemed
=
""
self
.
redeemed_date
=
Date
()
}
}
else
{
self
.
redeemed
=
""
self
.
redeemed_date
=
Date
()
}
}
...
...
@@ -4398,7 +4402,26 @@ public class swiftApi {
public
func
setOldCouponList
(
_
coupons
:
Array
<
CouponItemModel
>
)
{
// let filteredCoupons = coupons.filter { CharacterSet.decimalDigits.isSuperset(of: CharacterSet(charactersIn: $0.discount ?? "")) }
let
oldCoupons
=
coupons
.
filter
({
return
$0
.
status
==
0
})
var
oldCoupons
=
coupons
.
filter
({
return
$0
.
status
==
0
})
// sort oldCoupons by redeemed date
// let dateFormatter = DateFormatter()
// dateFormatter.dateFormat = "dd/MM/yyyy"
oldCoupons
.
sort
(
by
:
{
// let date1 = dateFormatter.date(from: $0.redeemed ?? "")
// let date2 = dateFormatter.date(from: $1.redeemed ?? "")
let
date1
=
$0
.
redeemed_date
let
date2
=
$1
.
redeemed_date
if
((
date1
!=
nil
)
&&
(
date2
!=
nil
))
{
return
date1
!.
compare
(
date2
!
)
==
.
orderedDescending
}
else
{
return
false
}
})
GlobalVariables
.
oldCouponList
=
oldCoupons
}
...
...
Please
register
or
login
to post a comment