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 19:33:09 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5ce6e7794fb74921e5d3cccce32300caf9fa42fd
5ce6e779
1 parent
e181f08e
fix redeemed coupons and unified coupons sorting
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
1 deletions
SwiftWarplyFramework/SwiftWarplyFramework/swiftApi.swift
SwiftWarplyFramework/SwiftWarplyFramework/swiftApi.swift
View file @
5ce6e77
...
...
@@ -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
...
...
@@ -673,15 +674,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
()
}
}
...
...
@@ -4410,7 +4414,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
}
...
...
@@ -6940,8 +6963,21 @@ public class swiftApi {
// dateFormatter.dateFormat = "dd/MM/yyyy"
dateFormatter
.
dateFormat
=
"yyyy-MM-dd HH:mm:ss.SSSSSS"
let
sortedUnifiedCouponsArray
=
unifiedCouponsArray
.
sorted
(
by
:
{
dateFormatter
.
date
(
from
:
$0
.
_created
)?
.
compare
(
dateFormatter
.
date
(
from
:
$1
.
_created
)
!
)
==
.
orderedDescending
})
// let sortedOldUnifiedCouponsArray = oldUnifiedCouponsArray.sorted(by: { $0.redeemed_date?.compare($1.redeemed_date!) == .orderedDescending })
swiftApi
()
.
setUnifiedCouponList
(
sortedUnifiedCouponsArray
)
oldUnifiedCouponsArray
.
sort
(
by
:
{
let
date1
=
$0
.
redeemed_date
let
date2
=
$1
.
redeemed_date
if
((
date1
!=
nil
)
&&
(
date2
!=
nil
))
{
return
date1
!.
compare
(
date2
!
)
==
.
orderedDescending
}
else
{
return
false
}
})
swiftApi
()
.
setOldUnifiedCouponList
(
oldUnifiedCouponsArray
)
successCallback
(
sortedUnifiedCouponsArray
)
}
...
...
Please
register
or
login
to post a comment