|
...
|
...
|
@@ -87,35 +87,43 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { |
|
|
|
: financeProvider!.giftData!.fullReductionData!.rule == '0'
|
|
|
|
? false
|
|
|
|
: true;
|
|
|
|
if (financeProvider!.giftData!.fullReductionData!.stime != null) {
|
|
|
|
DateTime dateTimes = DateTime.fromMillisecondsSinceEpoch(int.parse(
|
|
|
|
financeProvider!.giftData!.fullReductionData!.stime
|
|
|
|
.toString()) *
|
|
|
|
1000);
|
|
|
|
fromDateFull =
|
|
|
|
DateUtil.formatDate(dateTimes, format: DateFormats.y_mo_d);
|
|
|
|
}
|
|
|
|
if (financeProvider!.giftData!.fullReductionData!.etime != null) {
|
|
|
|
DateTime dateTimee = DateTime.fromMillisecondsSinceEpoch(int.parse(
|
|
|
|
financeProvider!.giftData!.fullReductionData!.etime
|
|
|
|
.toString()) *
|
|
|
|
1000);
|
|
|
|
endDateFull =
|
|
|
|
DateUtil.formatDate(dateTimee, format: DateFormats.y_mo_d);
|
|
|
|
}
|
|
|
|
|
|
|
|
DateTime dateTimes = DateTime.fromMillisecondsSinceEpoch(int.parse(
|
|
|
|
financeProvider!.giftData!.fullReductionData!.stime
|
|
|
|
.toString()) *
|
|
|
|
1000);
|
|
|
|
fromDateFull =
|
|
|
|
DateUtil.formatDate(dateTimes, format: DateFormats.y_mo_d);
|
|
|
|
DateTime dateTimee = DateTime.fromMillisecondsSinceEpoch(int.parse(
|
|
|
|
financeProvider!.giftData!.fullReductionData!.etime
|
|
|
|
.toString()) *
|
|
|
|
1000);
|
|
|
|
endDateFull =
|
|
|
|
DateUtil.formatDate(dateTimee, format: DateFormats.y_mo_d);
|
|
|
|
fullC.text = financeProvider!.giftData!.fullReductionData!.price ?? '';
|
|
|
|
|
|
|
|
couponSelectFree =
|
|
|
|
financeProvider!.giftData!.fullReductionData!.coupons ?? [];
|
|
|
|
}
|
|
|
|
if (financeProvider!.giftData!.stairsData != null) {
|
|
|
|
DateTime dateTimes = DateTime.fromMillisecondsSinceEpoch(
|
|
|
|
int.parse(financeProvider!.giftData!.stairsData!.stime.toString()) *
|
|
|
|
1000);
|
|
|
|
fromDateLadder =
|
|
|
|
DateUtil.formatDate(dateTimes, format: DateFormats.y_mo_d);
|
|
|
|
DateTime dateTimee = DateTime.fromMillisecondsSinceEpoch(
|
|
|
|
int.parse(financeProvider!.giftData!.stairsData!.etime.toString()) *
|
|
|
|
1000);
|
|
|
|
endDateLadder =
|
|
|
|
DateUtil.formatDate(dateTimee, format: DateFormats.y_mo_d);
|
|
|
|
if (financeProvider!.giftData!.stairsData!.stime != null) {
|
|
|
|
DateTime dateTimes = DateTime.fromMillisecondsSinceEpoch(int.parse(
|
|
|
|
financeProvider!.giftData!.stairsData!.stime.toString()) *
|
|
|
|
1000);
|
|
|
|
fromDateLadder =
|
|
|
|
DateUtil.formatDate(dateTimes, format: DateFormats.y_mo_d);
|
|
|
|
}
|
|
|
|
if (financeProvider!.giftData!.stairsData!.etime != null) {
|
|
|
|
DateTime dateTimee = DateTime.fromMillisecondsSinceEpoch(int.parse(
|
|
|
|
financeProvider!.giftData!.stairsData!.etime.toString()) *
|
|
|
|
1000);
|
|
|
|
endDateLadder =
|
|
|
|
DateUtil.formatDate(dateTimee, format: DateFormats.y_mo_d);
|
|
|
|
}
|
|
|
|
|
|
|
|
ladderSelectFree =
|
|
|
|
financeProvider!.giftData!.stairsData!.ladderData ?? [];
|
|
...
|
...
|
@@ -125,8 +133,8 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { |
|
|
|
|
|
|
|
_setActivityConfig() async {
|
|
|
|
FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
Map<String, String>? fullReductionData;
|
|
|
|
Map<String, String>? stairsData;
|
|
|
|
Map<String, String?> fullReductionData = {};
|
|
|
|
Map<String, String?> stairsData = {};
|
|
|
|
|
|
|
|
if (fullReduction) {
|
|
|
|
if (fromDateFull == '选择日期') {
|
|
...
|
...
|
@@ -138,34 +146,13 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { |
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (fullC.text.trim().length == 0) {
|
|
|
|
Utils.showToast('请输入门槛金额!');
|
|
|
|
Utils.showToast('请输入满减返券活动的门槛金额!');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (couponSelectFree == null || couponSelectFree!.length == 0) {
|
|
|
|
Utils.showToast('请选择优惠券!');
|
|
|
|
Utils.showToast('请选择满减返券活动的优惠券!');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
List<Map> couponsData = [];
|
|
|
|
couponSelectFree!.forEach((e) {
|
|
|
|
Map<String, String> coupon = {'id': e.id!, 'aname': e.aname!};
|
|
|
|
couponsData.add(coupon);
|
|
|
|
});
|
|
|
|
String fromfull = fromDateFull + ' 00:00:00';
|
|
|
|
String endfull = endDateFull + ' 23:59:59';
|
|
|
|
String sfull =
|
|
|
|
'${(DateUtil.getDateMsByTimeStr(fromfull)! / 1000).floor()}';
|
|
|
|
String efull =
|
|
|
|
'${(DateUtil.getDateMsByTimeStr(endfull)! / 1000).floor()}';
|
|
|
|
|
|
|
|
String ruleString = rule ? '1' : '0'; //发放规则
|
|
|
|
|
|
|
|
fullReductionData = {
|
|
|
|
'stime': sfull,
|
|
|
|
'etime': efull,
|
|
|
|
'price': fullC.text,
|
|
|
|
'coupons': jsonEncode(couponsData),
|
|
|
|
'rule': ruleString
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
//阶梯返券
|
|
|
|
if (fromDateLadder == '选择日期') {
|
|
...
|
...
|
@@ -181,6 +168,15 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { |
|
|
|
Utils.showToast('请点击增加阶梯设置数据!');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
bool canPrice =
|
|
|
|
ladderSelectFree.any((e) => e.priceC.text.trim().length == 0);
|
|
|
|
if (canPrice) {
|
|
|
|
int index = ladderSelectFree
|
|
|
|
.indexWhere((e) => e.priceC.text.trim().length == 0);
|
|
|
|
|
|
|
|
Utils.showToast('请选择阶梯(${index + 1})的消费门槛金额!');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
bool can = ladderSelectFree
|
|
|
|
.any((e) => e.coupons == null || e.coupons?.length == 0);
|
|
|
|
if (can) {
|
|
...
|
...
|
@@ -190,45 +186,67 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { |
|
|
|
Utils.showToast('请选择阶梯(${index + 1})的优惠券!');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool canPrice =
|
|
|
|
ladderSelectFree.any((e) => e.priceC.text.trim().length == 0);
|
|
|
|
if (canPrice) {
|
|
|
|
int index = ladderSelectFree
|
|
|
|
.indexWhere((e) => e.priceC.text.trim().length == 0);
|
|
|
|
List<Map> couponsData = [];
|
|
|
|
couponSelectFree?.forEach((e) {
|
|
|
|
Map<String, String> coupon = {'id': e.id!, 'aname': e.aname!};
|
|
|
|
couponsData.add(coupon);
|
|
|
|
});
|
|
|
|
if (fromDateFull != '选择日期') {
|
|
|
|
String fromfull = fromDateFull + ' 00:00:00';
|
|
|
|
|
|
|
|
Utils.showToast('请选择阶梯(${index + 1})的消费门槛金额!');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
String fromfull = fromDateLadder + ' 00:00:00';
|
|
|
|
String endfull = endDateLadder + ' 23:59:59';
|
|
|
|
String sfull =
|
|
|
|
'${(DateUtil.getDateMsByTimeStr(fromfull)! / 1000).floor()}';
|
|
|
|
|
|
|
|
fullReductionData['stime'] = sfull;
|
|
|
|
}
|
|
|
|
if (endDateFull != '选择日期') {
|
|
|
|
String endfull = endDateFull + ' 23:59:59';
|
|
|
|
|
|
|
|
String efull =
|
|
|
|
'${(DateUtil.getDateMsByTimeStr(endfull)! / 1000).floor()}';
|
|
|
|
List<Map<String, String>> ladderData = [];
|
|
|
|
ladderSelectFree.forEach((e) {
|
|
|
|
List<Map<String, String>> coupons = [];
|
|
|
|
e.coupons?.forEach((value) {
|
|
|
|
Map<String, String> coupon = {
|
|
|
|
'id': value.id!,
|
|
|
|
'aname': value.aname!,
|
|
|
|
};
|
|
|
|
coupons.add(coupon);
|
|
|
|
});
|
|
|
|
|
|
|
|
fullReductionData['etime'] = efull;
|
|
|
|
}
|
|
|
|
|
|
|
|
String ruleString = rule ? '1' : '0'; //发放规则
|
|
|
|
fullReductionData['rule'] = ruleString;
|
|
|
|
fullReductionData['price'] = fullC.text;
|
|
|
|
fullReductionData['coupons'] = jsonEncode(couponsData);
|
|
|
|
|
|
|
|
if (fromDateLadder != '选择日期') {
|
|
|
|
String fromLad = fromDateLadder + ' 00:00:00';
|
|
|
|
String sLad = '${(DateUtil.getDateMsByTimeStr(fromLad)! / 1000).floor()}';
|
|
|
|
stairsData['stime'] = sLad;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (endDateLadder != '选择日期') {
|
|
|
|
String endLad = endDateLadder + ' 23:59:59';
|
|
|
|
|
|
|
|
String eLad = '${(DateUtil.getDateMsByTimeStr(endLad)! / 1000).floor()}';
|
|
|
|
stairsData['etime'] = eLad;
|
|
|
|
}
|
|
|
|
|
|
|
|
List<Map<String, String>> ladderData = [];
|
|
|
|
ladderSelectFree.forEach((e) {
|
|
|
|
List<Map<String, String>> coupons = [];
|
|
|
|
e.coupons?.forEach((value) {
|
|
|
|
Map<String, String> coupon = {
|
|
|
|
'price': e.priceC.text,
|
|
|
|
'coupons': jsonEncode(coupons),
|
|
|
|
'id': value.id!,
|
|
|
|
'aname': value.aname!,
|
|
|
|
};
|
|
|
|
ladderData.add(coupon);
|
|
|
|
coupons.add(coupon);
|
|
|
|
});
|
|
|
|
stairsData = {
|
|
|
|
'stime': sfull,
|
|
|
|
'etime': efull,
|
|
|
|
'ladder_data': jsonEncode(ladderData)
|
|
|
|
Map<String, String> coupon = {
|
|
|
|
'price': e.priceC.text,
|
|
|
|
'coupons': jsonEncode(coupons),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
print(stairsData);
|
|
|
|
ladderData.add(coupon);
|
|
|
|
});
|
|
|
|
|
|
|
|
stairsData['ladder_data'] =
|
|
|
|
(ladderData.length == 0 ? null : jsonEncode(ladderData));
|
|
|
|
|
|
|
|
Map<String, String?> pramas = {
|
|
|
|
'sellerid':
|
|
...
|
...
|
@@ -236,8 +254,8 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { |
|
|
|
'full_reduction': fullReduction ? '1' : '0',
|
|
|
|
'stairs': !fullReduction ? '1' : '0',
|
|
|
|
'full_reduction_data':
|
|
|
|
fullReductionData == null ? null : jsonEncode(fullReductionData),
|
|
|
|
'stairs_data': stairsData == null ? null : jsonEncode(stairsData),
|
|
|
|
fullReductionData.length == 0 ? null : jsonEncode(fullReductionData),
|
|
|
|
'stairs_data': stairsData.length == 0 ? null : jsonEncode(stairsData),
|
|
|
|
};
|
|
|
|
// if (fullReductionData != null) {
|
|
|
|
// pramas['full_reduction_data'] = jsonEncode(fullReductionData);
|
|
...
|
...
|
@@ -421,7 +439,9 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { |
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: w(10), vertical: w(4)),
|
|
|
|
height: w(24),
|
|
|
|
alignment: Alignment.center,
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: w(10)),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
border: Border.all(color: MyColours.color_999999, width: w(1)),
|
|
|
|
borderRadius: BorderRadius.only(
|
|
...
|
...
|
@@ -436,7 +456,9 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { |
|
|
|
InkWell(
|
|
|
|
onTap: onTap,
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: w(5), vertical: w(4)),
|
|
|
|
height: w(24),
|
|
|
|
alignment: Alignment.center,
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: w(5)),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: MyColours.color_999999,
|
|
|
|
border:
|
...
|
...
|
|