Showing
3 changed files
with
66 additions
and
22 deletions
... | @@ -161,17 +161,22 @@ import SwiftEventBus | ... | @@ -161,17 +161,22 @@ import SwiftEventBus |
161 | func matchOldSMCoupons() { | 161 | func matchOldSMCoupons() { |
162 | var oldUnifiedCouponsArray:Array<swiftApi.CouponItemModel> = [] | 162 | var oldUnifiedCouponsArray:Array<swiftApi.CouponItemModel> = [] |
163 | 163 | ||
164 | - for smCouponSet in swiftApi().getCouponSetsDealsList() { | 164 | + // TODO: Check - Old implementation |
165 | - for oldCoupon in swiftApi().getAllOldCouponList() { | 165 | +// for smCouponSet in swiftApi().getCouponSetsDealsList() { |
166 | - if (smCouponSet.uuid != "" && oldCoupon.couponset_uuid != "" && smCouponSet.uuid == oldCoupon.couponset_uuid) { | 166 | +// for oldCoupon in swiftApi().getAllOldCouponList() { |
167 | - | 167 | +// if (smCouponSet.uuid != "" && oldCoupon.couponset_uuid != "" && smCouponSet.uuid == oldCoupon.couponset_uuid) { |
168 | - oldCoupon.setCouponSetData(smCouponSet); | 168 | +// |
169 | - oldUnifiedCouponsArray.append(oldCoupon); | 169 | +// oldCoupon.setCouponSetData(smCouponSet); |
170 | - | 170 | +// oldUnifiedCouponsArray.append(oldCoupon); |
171 | - break; | 171 | +// |
172 | - } | 172 | +// break; |
173 | - } | 173 | +// } |
174 | - } | 174 | +// } |
175 | +// } | ||
176 | + | ||
177 | + // TODO: DELETE - TEST | ||
178 | +// oldUnifiedCouponsArray = swiftApi().getAllOldCouponList().filter({ return $0.couponset_data?.couponset_type == "supermarket" }) | ||
179 | + oldUnifiedCouponsArray = swiftApi().getSMOldCouponList() | ||
175 | 180 | ||
176 | oldUnifiedCouponsArray.sort(by: { | 181 | oldUnifiedCouponsArray.sort(by: { |
177 | let date1 = $0.redeemed_date | 182 | let date1 = $0.redeemed_date | ... | ... |
... | @@ -715,17 +715,22 @@ import SwiftEventBus | ... | @@ -715,17 +715,22 @@ import SwiftEventBus |
715 | func matchOldSMCoupons() { | 715 | func matchOldSMCoupons() { |
716 | var oldUnifiedCouponsArray:Array<swiftApi.CouponItemModel> = [] | 716 | var oldUnifiedCouponsArray:Array<swiftApi.CouponItemModel> = [] |
717 | 717 | ||
718 | - for smCouponSet in swiftApi().getCouponSetsDealsList() { | 718 | + // TODO: Check - Old implementation |
719 | - for oldCoupon in swiftApi().getAllOldCouponList() { | 719 | +// for smCouponSet in swiftApi().getCouponSetsDealsList() { |
720 | - if (smCouponSet.uuid != "" && oldCoupon.couponset_uuid != "" && smCouponSet.uuid == oldCoupon.couponset_uuid) { | 720 | +// for oldCoupon in swiftApi().getAllOldCouponList() { |
721 | - | 721 | +// if (smCouponSet.uuid != "" && oldCoupon.couponset_uuid != "" && smCouponSet.uuid == oldCoupon.couponset_uuid) { |
722 | - oldCoupon.setCouponSetData(smCouponSet); | 722 | +// |
723 | - oldUnifiedCouponsArray.append(oldCoupon); | 723 | +// oldCoupon.setCouponSetData(smCouponSet); |
724 | - | 724 | +// oldUnifiedCouponsArray.append(oldCoupon); |
725 | - break; | 725 | +// |
726 | - } | 726 | +// break; |
727 | - } | 727 | +// } |
728 | - } | 728 | +// } |
729 | +// } | ||
730 | + | ||
731 | + // TODO: DELETE - TEST | ||
732 | +// oldUnifiedCouponsArray = swiftApi().getAllOldCouponList().filter({ return $0.couponset_data?.couponset_type == "supermarket" }) | ||
733 | + oldUnifiedCouponsArray = swiftApi().getSMOldCouponList() | ||
729 | 734 | ||
730 | oldUnifiedCouponsArray.sort(by: { | 735 | oldUnifiedCouponsArray.sort(by: { |
731 | let date1 = $0.redeemed_date | 736 | let date1 = $0.redeemed_date | ... | ... |
... | @@ -16,6 +16,7 @@ public struct GlobalVariables { | ... | @@ -16,6 +16,7 @@ public struct GlobalVariables { |
16 | static var dfyCoupons: Array<swiftApi.ActiveDFYCouponModel> = [] | 16 | static var dfyCoupons: Array<swiftApi.ActiveDFYCouponModel> = [] |
17 | static var couponList: Array<swiftApi.CouponItemModel> = [] | 17 | static var couponList: Array<swiftApi.CouponItemModel> = [] |
18 | static var oldCouponList: Array<swiftApi.CouponItemModel> = [] | 18 | static var oldCouponList: Array<swiftApi.CouponItemModel> = [] |
19 | + static var smOldCouponList: Array<swiftApi.CouponItemModel> = [] | ||
19 | static var allOldCouponList: Array<swiftApi.CouponItemModel> = [] | 20 | static var allOldCouponList: Array<swiftApi.CouponItemModel> = [] |
20 | static var couponSetList: Array<swiftApi.CouponSetItemModel> = [] | 21 | static var couponSetList: Array<swiftApi.CouponSetItemModel> = [] |
21 | static var couponsetsDealsList: Array<swiftApi.CouponSetItemModel> = [] // Supermarket couponsets | 22 | static var couponsetsDealsList: Array<swiftApi.CouponSetItemModel> = [] // Supermarket couponsets |
... | @@ -5345,6 +5346,37 @@ public class swiftApi { | ... | @@ -5345,6 +5346,37 @@ public class swiftApi { |
5345 | return GlobalVariables.oldCouponList | 5346 | return GlobalVariables.oldCouponList |
5346 | } | 5347 | } |
5347 | 5348 | ||
5349 | + public func setSMOldCouponList(_ coupons: Array<CouponItemModel>) { | ||
5350 | + // let filteredCoupons = coupons.filter { CharacterSet.decimalDigits.isSuperset(of: CharacterSet(charactersIn: $0.discount ?? "")) } | ||
5351 | + var oldCoupons = coupons.filter({ return $0.status == 0 }).filter({ return $0.couponset_data?.couponset_type == "supermarket" }) | ||
5352 | + | ||
5353 | + // sort oldCoupons by redeemed date | ||
5354 | +// let dateFormatter = DateFormatter() | ||
5355 | +// dateFormatter.dateFormat = "dd/MM/yyyy" | ||
5356 | + | ||
5357 | + oldCoupons.sort(by: { | ||
5358 | +// let date1 = dateFormatter.date(from: $0.redeemed ?? "") | ||
5359 | +// let date2 = dateFormatter.date(from: $1.redeemed ?? "") | ||
5360 | + | ||
5361 | + let date1 = $0.redeemed_date | ||
5362 | + let date2 = $1.redeemed_date | ||
5363 | + | ||
5364 | + if ((date1 != nil) && (date2 != nil)) { | ||
5365 | + return date1!.compare(date2!) == .orderedDescending | ||
5366 | + } else { | ||
5367 | + return false | ||
5368 | + } | ||
5369 | + | ||
5370 | + }) | ||
5371 | + | ||
5372 | + GlobalVariables.smOldCouponList = oldCoupons | ||
5373 | + } | ||
5374 | + | ||
5375 | + | ||
5376 | + public func getSMOldCouponList() -> Array<CouponItemModel> { | ||
5377 | + return GlobalVariables.smOldCouponList | ||
5378 | + } | ||
5379 | + | ||
5348 | public func setAllOldCouponList(_ coupons: Array<CouponItemModel>) { | 5380 | public func setAllOldCouponList(_ coupons: Array<CouponItemModel>) { |
5349 | // let filteredCoupons = coupons.filter { CharacterSet.decimalDigits.isSuperset(of: CharacterSet(charactersIn: $0.discount ?? "")) } | 5381 | // let filteredCoupons = coupons.filter { CharacterSet.decimalDigits.isSuperset(of: CharacterSet(charactersIn: $0.discount ?? "")) } |
5350 | var oldCoupons = coupons.filter({ return $0.status == 0 }) | 5382 | var oldCoupons = coupons.filter({ return $0.status == 0 }) |
... | @@ -8422,6 +8454,8 @@ public class swiftApi { | ... | @@ -8422,6 +8454,8 @@ public class swiftApi { |
8422 | swiftApi().setAllOldCouponList(couponsArray) | 8454 | swiftApi().setAllOldCouponList(couponsArray) |
8423 | // <== | 8455 | // <== |
8424 | 8456 | ||
8457 | + swiftApi().setSMOldCouponList(couponsArray) | ||
8458 | + | ||
8425 | let noSMCoupons = couponsArray.filter({ return $0.couponset_data?.couponset_type != "supermarket" }) | 8459 | let noSMCoupons = couponsArray.filter({ return $0.couponset_data?.couponset_type != "supermarket" }) |
8426 | 8460 | ||
8427 | swiftApi().setCouponList(noSMCoupons) | 8461 | swiftApi().setCouponList(noSMCoupons) | ... | ... |
-
Please register or login to post a comment