|
|
|
1
|
+import 'dart:convert';
|
|
|
|
2
|
+
|
|
1
|
import 'package:common_utils/common_utils.dart';
|
3
|
import 'package:common_utils/common_utils.dart';
|
|
2
|
import 'package:flutter/material.dart';
|
4
|
import 'package:flutter/material.dart';
|
|
3
|
import 'package:flutter/services.dart';
|
5
|
import 'package:flutter/services.dart';
|
|
4
|
import 'package:flutter_picker_plus/picker.dart';
|
6
|
import 'package:flutter_picker_plus/picker.dart';
|
|
5
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
7
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
8
|
+import 'package:one_key/provider/user_model.dart';
|
|
6
|
import 'package:one_key/res/colors.dart';
|
9
|
import 'package:one_key/res/colors.dart';
|
|
7
|
import 'package:one_key/widgets/h_empty_view.dart';
|
10
|
import 'package:one_key/widgets/h_empty_view.dart';
|
|
8
|
import 'package:one_key/widgets/system_app_bar.dart';
|
11
|
import 'package:one_key/widgets/system_app_bar.dart';
|
|
@@ -29,7 +32,6 @@ class PaymentGiftPage extends StatefulWidget { |
|
@@ -29,7 +32,6 @@ class PaymentGiftPage extends StatefulWidget { |
|
29
|
|
32
|
|
|
30
|
class _PaymentGiftPageState extends State<PaymentGiftPage> {
|
33
|
class _PaymentGiftPageState extends State<PaymentGiftPage> {
|
|
31
|
bool fullReduction = true;
|
34
|
bool fullReduction = true;
|
|
32
|
- bool ladderReduction = false;
|
|
|
|
33
|
|
35
|
|
|
34
|
String fromDateFull = '选择日期';
|
36
|
String fromDateFull = '选择日期';
|
|
35
|
String endDateFull = '选择日期';
|
37
|
String endDateFull = '选择日期';
|
|
@@ -46,6 +48,117 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { |
|
@@ -46,6 +48,117 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { |
|
46
|
List coupons = ['1', '2', '3'];
|
48
|
List coupons = ['1', '2', '3'];
|
|
47
|
List ladders = ['1', '2', '3'];
|
49
|
List ladders = ['1', '2', '3'];
|
|
48
|
List<CouponSunModel>? couponSelectFree = [];
|
50
|
List<CouponSunModel>? couponSelectFree = [];
|
|
|
|
51
|
+ bool rule = true;
|
|
|
|
52
|
+
|
|
|
|
53
|
+ @override
|
|
|
|
54
|
+ void initState() {
|
|
|
|
55
|
+ super.initState();
|
|
|
|
56
|
+
|
|
|
|
57
|
+ WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
58
|
+ // _getCountCommentLabel(isShowLoading: false);
|
|
|
|
59
|
+ });
|
|
|
|
60
|
+ // bus.on("refresh_discount_order_list", (args) {
|
|
|
|
61
|
+ // // _getReserveDetail(isShowLoading: false);
|
|
|
|
62
|
+ // _getDiscountOrderList(isShowLoading: false);
|
|
|
|
63
|
+ // });
|
|
|
|
64
|
+ }
|
|
|
|
65
|
+
|
|
|
|
66
|
+ _setActivityConfig() async {
|
|
|
|
67
|
+ Map<String, String>? fullReductionData;
|
|
|
|
68
|
+ if (fullReduction) {
|
|
|
|
69
|
+ if (fromDateFull == '选择日期') {
|
|
|
|
70
|
+ Utils.showToast('请选择满减返券活动的开始时间!');
|
|
|
|
71
|
+ return;
|
|
|
|
72
|
+ }
|
|
|
|
73
|
+ if (endDateFull == '选择日期') {
|
|
|
|
74
|
+ Utils.showToast('请选择满减返券活动的结束时间!');
|
|
|
|
75
|
+ return;
|
|
|
|
76
|
+ }
|
|
|
|
77
|
+ if (fullC.text.trim().length == '0') {
|
|
|
|
78
|
+ Utils.showToast('请输入门槛金额!');
|
|
|
|
79
|
+ return;
|
|
|
|
80
|
+ }
|
|
|
|
81
|
+ if (couponSelectFree == null || couponSelectFree!.length == 0) {
|
|
|
|
82
|
+ Utils.showToast('请选择优惠券!');
|
|
|
|
83
|
+ return;
|
|
|
|
84
|
+ }
|
|
|
|
85
|
+ List<Map> couponsData = [];
|
|
|
|
86
|
+ couponSelectFree!.forEach((e) {
|
|
|
|
87
|
+ Map<String, String> coupon = {'id': e.id!, 'name': e.aname!};
|
|
|
|
88
|
+ couponsData.add(coupon);
|
|
|
|
89
|
+ });
|
|
|
|
90
|
+ String fromfull = fromDateFull + ' 00:00:00';
|
|
|
|
91
|
+ String endfull = endDateFull + ' 23:59:59';
|
|
|
|
92
|
+ String sfull =
|
|
|
|
93
|
+ '${(DateUtil.getDateMsByTimeStr(fromfull)! / 1000).floor()}';
|
|
|
|
94
|
+ String efull =
|
|
|
|
95
|
+ '${(DateUtil.getDateMsByTimeStr(endfull)! / 1000).floor()}';
|
|
|
|
96
|
+
|
|
|
|
97
|
+ String ruleString = rule ? '1' : '0'; //发放规则
|
|
|
|
98
|
+
|
|
|
|
99
|
+ fullReductionData = {
|
|
|
|
100
|
+ 'stime': sfull,
|
|
|
|
101
|
+ 'etime': efull,
|
|
|
|
102
|
+ 'price': fullC.text,
|
|
|
|
103
|
+ 'coupons': jsonEncode(couponsData),
|
|
|
|
104
|
+ 'rule': ruleString
|
|
|
|
105
|
+ };
|
|
|
|
106
|
+ } else {
|
|
|
|
107
|
+ //阶梯返券
|
|
|
|
108
|
+ if (fromDateLadder == '选择日期') {
|
|
|
|
109
|
+ Utils.showToast('请选择阶梯返券活动的开始时间!');
|
|
|
|
110
|
+ return;
|
|
|
|
111
|
+ }
|
|
|
|
112
|
+ if (endDateLadder == '选择日期') {
|
|
|
|
113
|
+ Utils.showToast('请选择阶梯返券活动的结束时间!');
|
|
|
|
114
|
+ return;
|
|
|
|
115
|
+ }
|
|
|
|
116
|
+ if (fullC.text.trim().length == '0') {
|
|
|
|
117
|
+ Utils.showToast('请输入门槛金额!');
|
|
|
|
118
|
+ return;
|
|
|
|
119
|
+ }
|
|
|
|
120
|
+ // if (couponSelectFree == null || couponSelectFree!.length == 0) {
|
|
|
|
121
|
+ // Utils.showToast('请选择优惠券!');
|
|
|
|
122
|
+ // return;
|
|
|
|
123
|
+ // }
|
|
|
|
124
|
+
|
|
|
|
125
|
+ List<Map<String, String>> stairsData = [];
|
|
|
|
126
|
+ stairsData.add(
|
|
|
|
127
|
+ {
|
|
|
|
128
|
+ 'price': '100',
|
|
|
|
129
|
+ 'coupons':
|
|
|
|
130
|
+ "[{\"id\":\"1059\",\"name\":\"150-20\"},{\"id\":\"1058\",\"name\":\"100-30\"},{\"id\":\"1057\",\"name\":\"100-30\"},{\"id\":\"1056\",\"name\":\"150-20\"},{\"id\":\"1055\",\"name\":\"100-30\"}]",
|
|
|
|
131
|
+ },
|
|
|
|
132
|
+ );
|
|
|
|
133
|
+ stairsData.add(
|
|
|
|
134
|
+ {
|
|
|
|
135
|
+ 'price': '100',
|
|
|
|
136
|
+ 'coupons':
|
|
|
|
137
|
+ "[{\"id\":\"1059\",\"name\":\"150-20\"},{\"id\":\"1058\",\"name\":\"100-30\"},{\"id\":\"1057\",\"name\":\"100-30\"},{\"id\":\"1056\",\"name\":\"150-20\"},{\"id\":\"1055\",\"name\":\"100-30\"}]",
|
|
|
|
138
|
+ },
|
|
|
|
139
|
+ );
|
|
|
|
140
|
+ stairsData.add(
|
|
|
|
141
|
+ {
|
|
|
|
142
|
+ 'price': '100',
|
|
|
|
143
|
+ 'coupons':
|
|
|
|
144
|
+ "[{\"id\":\"1059\",\"name\":\"150-20\"},{\"id\":\"1058\",\"name\":\"100-30\"},{\"id\":\"1057\",\"name\":\"100-30\"},{\"id\":\"1056\",\"name\":\"150-20\"},{\"id\":\"1055\",\"name\":\"100-30\"}]",
|
|
|
|
145
|
+ },
|
|
|
|
146
|
+ );
|
|
|
|
147
|
+ }
|
|
|
|
148
|
+
|
|
|
|
149
|
+ Map<String, String?> pramas = {
|
|
|
|
150
|
+ 'sellerid':
|
|
|
|
151
|
+ Provider.of<UserModel>(context, listen: false).user!.sellerid!,
|
|
|
|
152
|
+
|
|
|
|
153
|
+ 'full_reduction': fullReduction ? '1' : '0',
|
|
|
|
154
|
+
|
|
|
|
155
|
+ 'stairs': !fullReduction ? '1' : '0',
|
|
|
|
156
|
+ 'full_reduction_data':
|
|
|
|
157
|
+ fullReductionData == null ? null : jsonEncode(fullReductionData)
|
|
|
|
158
|
+// 'stairs_data':
|
|
|
|
159
|
+ };
|
|
|
|
160
|
+ await financeProvider!.setActivityConfig(context, pramas);
|
|
|
|
161
|
+ }
|
|
49
|
|
162
|
|
|
50
|
///是否立即启用
|
163
|
///是否立即启用
|
|
51
|
Widget _canUse(
|
164
|
Widget _canUse(
|
|
@@ -365,6 +478,17 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { |
|
@@ -365,6 +478,17 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { |
|
365
|
(value) {
|
478
|
(value) {
|
|
366
|
// {'text': picker.adapter.text, 'select': selecteds}
|
479
|
// {'text': picker.adapter.text, 'select': selecteds}
|
|
367
|
if (value != null) {
|
480
|
if (value != null) {
|
|
|
|
481
|
+ if (endDateFull != '选择日期') {
|
|
|
|
482
|
+ if (DateUtil.getDateTime(endDateFull).compareTo(
|
|
|
|
483
|
+ DateUtil.getDateTime(DateUtil.formatDateStr(
|
|
|
|
484
|
+ value,
|
|
|
|
485
|
+ format: DateFormats.y_mo_d))) <
|
|
|
|
486
|
+ 0) {
|
|
|
|
487
|
+ Utils.showToast('满减返券的活动开始时间不能迟于活动结束时间');
|
|
|
|
488
|
+ return;
|
|
|
|
489
|
+ }
|
|
|
|
490
|
+ }
|
|
|
|
491
|
+
|
|
368
|
setState(() {
|
492
|
setState(() {
|
|
369
|
print(value);
|
493
|
print(value);
|
|
370
|
fromDateFull = DateUtil.formatDateStr(value,
|
494
|
fromDateFull = DateUtil.formatDateStr(value,
|
|
@@ -393,6 +517,17 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { |
|
@@ -393,6 +517,17 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { |
|
393
|
(value) {
|
517
|
(value) {
|
|
394
|
// {'text': picker.adapter.text, 'select': selecteds}
|
518
|
// {'text': picker.adapter.text, 'select': selecteds}
|
|
395
|
if (value != null) {
|
519
|
if (value != null) {
|
|
|
|
520
|
+ if (fromDateFull != '选择日期') {
|
|
|
|
521
|
+ if (DateUtil.getDateTime(DateUtil.formatDateStr(
|
|
|
|
522
|
+ value,
|
|
|
|
523
|
+ format: DateFormats.y_mo_d))
|
|
|
|
524
|
+ .compareTo(
|
|
|
|
525
|
+ DateUtil.getDateTime(fromDateFull)) <
|
|
|
|
526
|
+ 0) {
|
|
|
|
527
|
+ Utils.showToast('满减返券的活动结束时间不能早于活动开始时间');
|
|
|
|
528
|
+ return;
|
|
|
|
529
|
+ }
|
|
|
|
530
|
+ }
|
|
396
|
setState(() {
|
531
|
setState(() {
|
|
397
|
print(value);
|
532
|
print(value);
|
|
398
|
endDateFull = DateUtil.formatDateStr(value,
|
533
|
endDateFull = DateUtil.formatDateStr(value,
|
|
@@ -455,46 +590,66 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { |
|
@@ -455,46 +590,66 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { |
|
455
|
color: MyColours.color_515151, fontSize: font(14)),
|
590
|
color: MyColours.color_515151, fontSize: font(14)),
|
|
456
|
),
|
591
|
),
|
|
457
|
Spacer(),
|
592
|
Spacer(),
|
|
458
|
- Container(
|
|
|
|
459
|
- // width: w(100),
|
|
|
|
460
|
- // height: w(30),
|
|
|
|
461
|
- padding: EdgeInsets.symmetric(
|
|
|
|
462
|
- horizontal: w(10), vertical: w(5)),
|
|
|
|
463
|
- decoration: BoxDecoration(
|
|
|
|
464
|
- color: MyColours.color_438E93,
|
|
|
|
465
|
- borderRadius: BorderRadius.only(
|
|
|
|
466
|
- topLeft: Radius.circular(r(5)),
|
|
|
|
467
|
- bottomLeft: Radius.circular(r(5)))),
|
|
|
|
468
|
- child: Text(
|
|
|
|
469
|
- '每满门槛均发放',
|
|
|
|
470
|
- style: TextStyle(
|
|
|
|
471
|
- color: MyColours.color_ffffff,
|
|
|
|
472
|
- fontSize: font(14)),
|
|
|
|
473
|
- ),
|
|
|
|
474
|
- ),
|
|
|
|
475
|
- Container(
|
|
|
|
476
|
- padding: EdgeInsets.symmetric(
|
|
|
|
477
|
- horizontal: w(10), vertical: w(5)),
|
|
|
|
478
|
- decoration: BoxDecoration(
|
|
|
|
479
|
- color: MyColours.color_DBDBDB,
|
|
|
|
480
|
- borderRadius: BorderRadius.only(
|
|
|
|
481
|
- topRight: Radius.circular(r(5)),
|
|
|
|
482
|
- bottomRight: Radius.circular(r(5)))),
|
|
|
|
483
|
- child: Text(
|
|
|
|
484
|
- '仅发放一次',
|
|
|
|
485
|
- style: TextStyle(
|
|
|
|
486
|
- color: MyColours.color_438E93,
|
|
|
|
487
|
- fontSize: font(14)),
|
|
|
|
488
|
- ),
|
|
|
|
489
|
- )
|
593
|
+ InkWell(
|
|
|
|
594
|
+ onTap: () {
|
|
|
|
595
|
+ setState(() {
|
|
|
|
596
|
+ rule = !rule;
|
|
|
|
597
|
+ });
|
|
|
|
598
|
+ },
|
|
|
|
599
|
+ child: Container(
|
|
|
|
600
|
+ // width: w(100),
|
|
|
|
601
|
+ // height: w(30),
|
|
|
|
602
|
+ padding: EdgeInsets.symmetric(
|
|
|
|
603
|
+ horizontal: w(10), vertical: w(5)),
|
|
|
|
604
|
+ decoration: BoxDecoration(
|
|
|
|
605
|
+ color: rule
|
|
|
|
606
|
+ ? MyColours.color_438E93
|
|
|
|
607
|
+ : MyColours.color_DBDBDB,
|
|
|
|
608
|
+ borderRadius: BorderRadius.only(
|
|
|
|
609
|
+ topLeft: Radius.circular(r(5)),
|
|
|
|
610
|
+ bottomLeft: Radius.circular(r(5)))),
|
|
|
|
611
|
+ child: Text(
|
|
|
|
612
|
+ '每满门槛均发放',
|
|
|
|
613
|
+ style: TextStyle(
|
|
|
|
614
|
+ color: rule
|
|
|
|
615
|
+ ? MyColours.color_ffffff
|
|
|
|
616
|
+ : MyColours.color_438E93,
|
|
|
|
617
|
+ fontSize: font(14)),
|
|
|
|
618
|
+ ),
|
|
|
|
619
|
+ )),
|
|
|
|
620
|
+ InkWell(
|
|
|
|
621
|
+ onTap: () {
|
|
|
|
622
|
+ setState(() {
|
|
|
|
623
|
+ rule = !rule;
|
|
|
|
624
|
+ });
|
|
|
|
625
|
+ },
|
|
|
|
626
|
+ child: Container(
|
|
|
|
627
|
+ padding: EdgeInsets.symmetric(
|
|
|
|
628
|
+ horizontal: w(10), vertical: w(5)),
|
|
|
|
629
|
+ decoration: BoxDecoration(
|
|
|
|
630
|
+ color: !rule
|
|
|
|
631
|
+ ? MyColours.color_438E93
|
|
|
|
632
|
+ : MyColours.color_DBDBDB,
|
|
|
|
633
|
+ borderRadius: BorderRadius.only(
|
|
|
|
634
|
+ topRight: Radius.circular(r(5)),
|
|
|
|
635
|
+ bottomRight: Radius.circular(r(5)))),
|
|
|
|
636
|
+ child: Text(
|
|
|
|
637
|
+ '仅发放一次',
|
|
|
|
638
|
+ style: TextStyle(
|
|
|
|
639
|
+ color: !rule
|
|
|
|
640
|
+ ? MyColours.color_ffffff
|
|
|
|
641
|
+ : MyColours.color_438E93,
|
|
|
|
642
|
+ fontSize: font(14)),
|
|
|
|
643
|
+ ),
|
|
|
|
644
|
+ ))
|
|
490
|
],
|
645
|
],
|
|
491
|
),
|
646
|
),
|
|
492
|
),
|
647
|
),
|
|
493
|
VEmptyView(22),
|
648
|
VEmptyView(22),
|
|
494
|
- _canUse('开通实际支付阶梯返券【提客单】', ladderReduction, () {
|
649
|
+ _canUse('开通实际支付阶梯返券【提客单】', !fullReduction, () {
|
|
495
|
//
|
650
|
//
|
|
496
|
setState(() {
|
651
|
setState(() {
|
|
497
|
- ladderReduction = !ladderReduction;
|
652
|
+ fullReduction = !fullReduction;
|
|
498
|
});
|
653
|
});
|
|
499
|
}),
|
654
|
}),
|
|
500
|
_select('活动开始于', fromDateLadder, () {
|
655
|
_select('活动开始于', fromDateLadder, () {
|
|
@@ -601,7 +756,10 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { |
|
@@ -601,7 +756,10 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { |
|
601
|
textColor: MyColours.color_ffffff,
|
756
|
textColor: MyColours.color_ffffff,
|
|
602
|
isBold: true,
|
757
|
isBold: true,
|
|
603
|
fontSize: 32,
|
758
|
fontSize: 32,
|
|
604
|
- onPressed: () {},
|
759
|
+ onPressed: () {
|
|
|
|
760
|
+ // 调用接口
|
|
|
|
761
|
+ _setActivityConfig();
|
|
|
|
762
|
+ },
|
|
605
|
),
|
763
|
),
|
|
606
|
)
|
764
|
)
|
|
607
|
],
|
765
|
],
|