Showing
1 changed file
with
102 additions
and
80 deletions
| @@ -87,35 +87,43 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { | @@ -87,35 +87,43 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { | ||
| 87 | : financeProvider!.giftData!.fullReductionData!.rule == '0' | 87 | : financeProvider!.giftData!.fullReductionData!.rule == '0' |
| 88 | ? false | 88 | ? false |
| 89 | : true; | 89 | : true; |
| 90 | + if (financeProvider!.giftData!.fullReductionData!.stime != null) { | ||
| 91 | + DateTime dateTimes = DateTime.fromMillisecondsSinceEpoch(int.parse( | ||
| 92 | + financeProvider!.giftData!.fullReductionData!.stime | ||
| 93 | + .toString()) * | ||
| 94 | + 1000); | ||
| 95 | + fromDateFull = | ||
| 96 | + DateUtil.formatDate(dateTimes, format: DateFormats.y_mo_d); | ||
| 97 | + } | ||
| 98 | + if (financeProvider!.giftData!.fullReductionData!.etime != null) { | ||
| 99 | + DateTime dateTimee = DateTime.fromMillisecondsSinceEpoch(int.parse( | ||
| 100 | + financeProvider!.giftData!.fullReductionData!.etime | ||
| 101 | + .toString()) * | ||
| 102 | + 1000); | ||
| 103 | + endDateFull = | ||
| 104 | + DateUtil.formatDate(dateTimee, format: DateFormats.y_mo_d); | ||
| 105 | + } | ||
| 90 | 106 | ||
| 91 | - DateTime dateTimes = DateTime.fromMillisecondsSinceEpoch(int.parse( | ||
| 92 | - financeProvider!.giftData!.fullReductionData!.stime | ||
| 93 | - .toString()) * | ||
| 94 | - 1000); | ||
| 95 | - fromDateFull = | ||
| 96 | - DateUtil.formatDate(dateTimes, format: DateFormats.y_mo_d); | ||
| 97 | - DateTime dateTimee = DateTime.fromMillisecondsSinceEpoch(int.parse( | ||
| 98 | - financeProvider!.giftData!.fullReductionData!.etime | ||
| 99 | - .toString()) * | ||
| 100 | - 1000); | ||
| 101 | - endDateFull = | ||
| 102 | - DateUtil.formatDate(dateTimee, format: DateFormats.y_mo_d); | ||
| 103 | fullC.text = financeProvider!.giftData!.fullReductionData!.price ?? ''; | 107 | fullC.text = financeProvider!.giftData!.fullReductionData!.price ?? ''; |
| 104 | 108 | ||
| 105 | couponSelectFree = | 109 | couponSelectFree = |
| 106 | financeProvider!.giftData!.fullReductionData!.coupons ?? []; | 110 | financeProvider!.giftData!.fullReductionData!.coupons ?? []; |
| 107 | } | 111 | } |
| 108 | if (financeProvider!.giftData!.stairsData != null) { | 112 | if (financeProvider!.giftData!.stairsData != null) { |
| 109 | - DateTime dateTimes = DateTime.fromMillisecondsSinceEpoch( | ||
| 110 | - int.parse(financeProvider!.giftData!.stairsData!.stime.toString()) * | ||
| 111 | - 1000); | ||
| 112 | - fromDateLadder = | ||
| 113 | - DateUtil.formatDate(dateTimes, format: DateFormats.y_mo_d); | ||
| 114 | - DateTime dateTimee = DateTime.fromMillisecondsSinceEpoch( | ||
| 115 | - int.parse(financeProvider!.giftData!.stairsData!.etime.toString()) * | ||
| 116 | - 1000); | ||
| 117 | - endDateLadder = | ||
| 118 | - DateUtil.formatDate(dateTimee, format: DateFormats.y_mo_d); | 113 | + if (financeProvider!.giftData!.stairsData!.stime != null) { |
| 114 | + DateTime dateTimes = DateTime.fromMillisecondsSinceEpoch(int.parse( | ||
| 115 | + financeProvider!.giftData!.stairsData!.stime.toString()) * | ||
| 116 | + 1000); | ||
| 117 | + fromDateLadder = | ||
| 118 | + DateUtil.formatDate(dateTimes, format: DateFormats.y_mo_d); | ||
| 119 | + } | ||
| 120 | + if (financeProvider!.giftData!.stairsData!.etime != null) { | ||
| 121 | + DateTime dateTimee = DateTime.fromMillisecondsSinceEpoch(int.parse( | ||
| 122 | + financeProvider!.giftData!.stairsData!.etime.toString()) * | ||
| 123 | + 1000); | ||
| 124 | + endDateLadder = | ||
| 125 | + DateUtil.formatDate(dateTimee, format: DateFormats.y_mo_d); | ||
| 126 | + } | ||
| 119 | 127 | ||
| 120 | ladderSelectFree = | 128 | ladderSelectFree = |
| 121 | financeProvider!.giftData!.stairsData!.ladderData ?? []; | 129 | financeProvider!.giftData!.stairsData!.ladderData ?? []; |
| @@ -125,8 +133,8 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { | @@ -125,8 +133,8 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { | ||
| 125 | 133 | ||
| 126 | _setActivityConfig() async { | 134 | _setActivityConfig() async { |
| 127 | FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘 | 135 | FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘 |
| 128 | - Map<String, String>? fullReductionData; | ||
| 129 | - Map<String, String>? stairsData; | 136 | + Map<String, String?> fullReductionData = {}; |
| 137 | + Map<String, String?> stairsData = {}; | ||
| 130 | 138 | ||
| 131 | if (fullReduction) { | 139 | if (fullReduction) { |
| 132 | if (fromDateFull == '选择日期') { | 140 | if (fromDateFull == '选择日期') { |
| @@ -138,34 +146,13 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { | @@ -138,34 +146,13 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { | ||
| 138 | return; | 146 | return; |
| 139 | } | 147 | } |
| 140 | if (fullC.text.trim().length == 0) { | 148 | if (fullC.text.trim().length == 0) { |
| 141 | - Utils.showToast('请输入门槛金额!'); | 149 | + Utils.showToast('请输入满减返券活动的门槛金额!'); |
| 142 | return; | 150 | return; |
| 143 | } | 151 | } |
| 144 | if (couponSelectFree == null || couponSelectFree!.length == 0) { | 152 | if (couponSelectFree == null || couponSelectFree!.length == 0) { |
| 145 | - Utils.showToast('请选择优惠券!'); | 153 | + Utils.showToast('请选择满减返券活动的优惠券!'); |
| 146 | return; | 154 | return; |
| 147 | } | 155 | } |
| 148 | - List<Map> couponsData = []; | ||
| 149 | - couponSelectFree!.forEach((e) { | ||
| 150 | - Map<String, String> coupon = {'id': e.id!, 'aname': e.aname!}; | ||
| 151 | - couponsData.add(coupon); | ||
| 152 | - }); | ||
| 153 | - String fromfull = fromDateFull + ' 00:00:00'; | ||
| 154 | - String endfull = endDateFull + ' 23:59:59'; | ||
| 155 | - String sfull = | ||
| 156 | - '${(DateUtil.getDateMsByTimeStr(fromfull)! / 1000).floor()}'; | ||
| 157 | - String efull = | ||
| 158 | - '${(DateUtil.getDateMsByTimeStr(endfull)! / 1000).floor()}'; | ||
| 159 | - | ||
| 160 | - String ruleString = rule ? '1' : '0'; //发放规则 | ||
| 161 | - | ||
| 162 | - fullReductionData = { | ||
| 163 | - 'stime': sfull, | ||
| 164 | - 'etime': efull, | ||
| 165 | - 'price': fullC.text, | ||
| 166 | - 'coupons': jsonEncode(couponsData), | ||
| 167 | - 'rule': ruleString | ||
| 168 | - }; | ||
| 169 | } else { | 156 | } else { |
| 170 | //阶梯返券 | 157 | //阶梯返券 |
| 171 | if (fromDateLadder == '选择日期') { | 158 | if (fromDateLadder == '选择日期') { |
| @@ -181,6 +168,15 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { | @@ -181,6 +168,15 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { | ||
| 181 | Utils.showToast('请点击增加阶梯设置数据!'); | 168 | Utils.showToast('请点击增加阶梯设置数据!'); |
| 182 | return; | 169 | return; |
| 183 | } | 170 | } |
| 171 | + bool canPrice = | ||
| 172 | + ladderSelectFree.any((e) => e.priceC.text.trim().length == 0); | ||
| 173 | + if (canPrice) { | ||
| 174 | + int index = ladderSelectFree | ||
| 175 | + .indexWhere((e) => e.priceC.text.trim().length == 0); | ||
| 176 | + | ||
| 177 | + Utils.showToast('请选择阶梯(${index + 1})的消费门槛金额!'); | ||
| 178 | + return; | ||
| 179 | + } | ||
| 184 | bool can = ladderSelectFree | 180 | bool can = ladderSelectFree |
| 185 | .any((e) => e.coupons == null || e.coupons?.length == 0); | 181 | .any((e) => e.coupons == null || e.coupons?.length == 0); |
| 186 | if (can) { | 182 | if (can) { |
| @@ -190,45 +186,67 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { | @@ -190,45 +186,67 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { | ||
| 190 | Utils.showToast('请选择阶梯(${index + 1})的优惠券!'); | 186 | Utils.showToast('请选择阶梯(${index + 1})的优惠券!'); |
| 191 | return; | 187 | return; |
| 192 | } | 188 | } |
| 189 | + } | ||
| 193 | 190 | ||
| 194 | - bool canPrice = | ||
| 195 | - ladderSelectFree.any((e) => e.priceC.text.trim().length == 0); | ||
| 196 | - if (canPrice) { | ||
| 197 | - int index = ladderSelectFree | ||
| 198 | - .indexWhere((e) => e.priceC.text.trim().length == 0); | 191 | + List<Map> couponsData = []; |
| 192 | + couponSelectFree?.forEach((e) { | ||
| 193 | + Map<String, String> coupon = {'id': e.id!, 'aname': e.aname!}; | ||
| 194 | + couponsData.add(coupon); | ||
| 195 | + }); | ||
| 196 | + if (fromDateFull != '选择日期') { | ||
| 197 | + String fromfull = fromDateFull + ' 00:00:00'; | ||
| 199 | 198 | ||
| 200 | - Utils.showToast('请选择阶梯(${index + 1})的消费门槛金额!'); | ||
| 201 | - return; | ||
| 202 | - } | ||
| 203 | - String fromfull = fromDateLadder + ' 00:00:00'; | ||
| 204 | - String endfull = endDateLadder + ' 23:59:59'; | ||
| 205 | String sfull = | 199 | String sfull = |
| 206 | '${(DateUtil.getDateMsByTimeStr(fromfull)! / 1000).floor()}'; | 200 | '${(DateUtil.getDateMsByTimeStr(fromfull)! / 1000).floor()}'; |
| 201 | + | ||
| 202 | + fullReductionData['stime'] = sfull; | ||
| 203 | + } | ||
| 204 | + if (endDateFull != '选择日期') { | ||
| 205 | + String endfull = endDateFull + ' 23:59:59'; | ||
| 206 | + | ||
| 207 | String efull = | 207 | String efull = |
| 208 | '${(DateUtil.getDateMsByTimeStr(endfull)! / 1000).floor()}'; | 208 | '${(DateUtil.getDateMsByTimeStr(endfull)! / 1000).floor()}'; |
| 209 | - List<Map<String, String>> ladderData = []; | ||
| 210 | - ladderSelectFree.forEach((e) { | ||
| 211 | - List<Map<String, String>> coupons = []; | ||
| 212 | - e.coupons?.forEach((value) { | ||
| 213 | - Map<String, String> coupon = { | ||
| 214 | - 'id': value.id!, | ||
| 215 | - 'aname': value.aname!, | ||
| 216 | - }; | ||
| 217 | - coupons.add(coupon); | ||
| 218 | - }); | 209 | + |
| 210 | + fullReductionData['etime'] = efull; | ||
| 211 | + } | ||
| 212 | + | ||
| 213 | + String ruleString = rule ? '1' : '0'; //发放规则 | ||
| 214 | + fullReductionData['rule'] = ruleString; | ||
| 215 | + fullReductionData['price'] = fullC.text; | ||
| 216 | + fullReductionData['coupons'] = jsonEncode(couponsData); | ||
| 217 | + | ||
| 218 | + if (fromDateLadder != '选择日期') { | ||
| 219 | + String fromLad = fromDateLadder + ' 00:00:00'; | ||
| 220 | + String sLad = '${(DateUtil.getDateMsByTimeStr(fromLad)! / 1000).floor()}'; | ||
| 221 | + stairsData['stime'] = sLad; | ||
| 222 | + } | ||
| 223 | + | ||
| 224 | + if (endDateLadder != '选择日期') { | ||
| 225 | + String endLad = endDateLadder + ' 23:59:59'; | ||
| 226 | + | ||
| 227 | + String eLad = '${(DateUtil.getDateMsByTimeStr(endLad)! / 1000).floor()}'; | ||
| 228 | + stairsData['etime'] = eLad; | ||
| 229 | + } | ||
| 230 | + | ||
| 231 | + List<Map<String, String>> ladderData = []; | ||
| 232 | + ladderSelectFree.forEach((e) { | ||
| 233 | + List<Map<String, String>> coupons = []; | ||
| 234 | + e.coupons?.forEach((value) { | ||
| 219 | Map<String, String> coupon = { | 235 | Map<String, String> coupon = { |
| 220 | - 'price': e.priceC.text, | ||
| 221 | - 'coupons': jsonEncode(coupons), | 236 | + 'id': value.id!, |
| 237 | + 'aname': value.aname!, | ||
| 222 | }; | 238 | }; |
| 223 | - ladderData.add(coupon); | 239 | + coupons.add(coupon); |
| 224 | }); | 240 | }); |
| 225 | - stairsData = { | ||
| 226 | - 'stime': sfull, | ||
| 227 | - 'etime': efull, | ||
| 228 | - 'ladder_data': jsonEncode(ladderData) | 241 | + Map<String, String> coupon = { |
| 242 | + 'price': e.priceC.text, | ||
| 243 | + 'coupons': jsonEncode(coupons), | ||
| 229 | }; | 244 | }; |
| 230 | - } | ||
| 231 | - print(stairsData); | 245 | + ladderData.add(coupon); |
| 246 | + }); | ||
| 247 | + | ||
| 248 | + stairsData['ladder_data'] = | ||
| 249 | + (ladderData.length == 0 ? null : jsonEncode(ladderData)); | ||
| 232 | 250 | ||
| 233 | Map<String, String?> pramas = { | 251 | Map<String, String?> pramas = { |
| 234 | 'sellerid': | 252 | 'sellerid': |
| @@ -236,8 +254,8 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { | @@ -236,8 +254,8 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { | ||
| 236 | 'full_reduction': fullReduction ? '1' : '0', | 254 | 'full_reduction': fullReduction ? '1' : '0', |
| 237 | 'stairs': !fullReduction ? '1' : '0', | 255 | 'stairs': !fullReduction ? '1' : '0', |
| 238 | 'full_reduction_data': | 256 | 'full_reduction_data': |
| 239 | - fullReductionData == null ? null : jsonEncode(fullReductionData), | ||
| 240 | - 'stairs_data': stairsData == null ? null : jsonEncode(stairsData), | 257 | + fullReductionData.length == 0 ? null : jsonEncode(fullReductionData), |
| 258 | + 'stairs_data': stairsData.length == 0 ? null : jsonEncode(stairsData), | ||
| 241 | }; | 259 | }; |
| 242 | // if (fullReductionData != null) { | 260 | // if (fullReductionData != null) { |
| 243 | // pramas['full_reduction_data'] = jsonEncode(fullReductionData); | 261 | // pramas['full_reduction_data'] = jsonEncode(fullReductionData); |
| @@ -421,7 +439,9 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { | @@ -421,7 +439,9 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { | ||
| 421 | mainAxisSize: MainAxisSize.min, | 439 | mainAxisSize: MainAxisSize.min, |
| 422 | children: [ | 440 | children: [ |
| 423 | Container( | 441 | Container( |
| 424 | - padding: EdgeInsets.symmetric(horizontal: w(10), vertical: w(4)), | 442 | + height: w(24), |
| 443 | + alignment: Alignment.center, | ||
| 444 | + padding: EdgeInsets.symmetric(horizontal: w(10)), | ||
| 425 | decoration: BoxDecoration( | 445 | decoration: BoxDecoration( |
| 426 | border: Border.all(color: MyColours.color_999999, width: w(1)), | 446 | border: Border.all(color: MyColours.color_999999, width: w(1)), |
| 427 | borderRadius: BorderRadius.only( | 447 | borderRadius: BorderRadius.only( |
| @@ -436,7 +456,9 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { | @@ -436,7 +456,9 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { | ||
| 436 | InkWell( | 456 | InkWell( |
| 437 | onTap: onTap, | 457 | onTap: onTap, |
| 438 | child: Container( | 458 | child: Container( |
| 439 | - padding: EdgeInsets.symmetric(horizontal: w(5), vertical: w(4)), | 459 | + height: w(24), |
| 460 | + alignment: Alignment.center, | ||
| 461 | + padding: EdgeInsets.symmetric(horizontal: w(5)), | ||
| 440 | decoration: BoxDecoration( | 462 | decoration: BoxDecoration( |
| 441 | color: MyColours.color_999999, | 463 | color: MyColours.color_999999, |
| 442 | border: | 464 | border: |
-
Please register or login to post a comment