|
|
|
import 'dart:convert';
|
|
|
|
|
|
|
|
import 'package:common_utils/common_utils.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'package:flutter_picker_plus/picker.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:one_key/provider/user_model.dart';
|
|
|
|
import 'package:one_key/res/colors.dart';
|
|
|
|
import 'package:one_key/widgets/h_empty_view.dart';
|
|
|
|
import 'package:one_key/widgets/system_app_bar.dart';
|
|
...
|
...
|
@@ -29,7 +32,6 @@ class PaymentGiftPage extends StatefulWidget { |
|
|
|
|
|
|
|
class _PaymentGiftPageState extends State<PaymentGiftPage> {
|
|
|
|
bool fullReduction = true;
|
|
|
|
bool ladderReduction = false;
|
|
|
|
|
|
|
|
String fromDateFull = '选择日期';
|
|
|
|
String endDateFull = '选择日期';
|
|
...
|
...
|
@@ -46,6 +48,117 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { |
|
|
|
List coupons = ['1', '2', '3'];
|
|
|
|
List ladders = ['1', '2', '3'];
|
|
|
|
List<CouponSunModel>? couponSelectFree = [];
|
|
|
|
bool rule = true;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
// _getCountCommentLabel(isShowLoading: false);
|
|
|
|
});
|
|
|
|
// bus.on("refresh_discount_order_list", (args) {
|
|
|
|
// // _getReserveDetail(isShowLoading: false);
|
|
|
|
// _getDiscountOrderList(isShowLoading: false);
|
|
|
|
// });
|
|
|
|
}
|
|
|
|
|
|
|
|
_setActivityConfig() async {
|
|
|
|
Map<String, String>? fullReductionData;
|
|
|
|
if (fullReduction) {
|
|
|
|
if (fromDateFull == '选择日期') {
|
|
|
|
Utils.showToast('请选择满减返券活动的开始时间!');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (endDateFull == '选择日期') {
|
|
|
|
Utils.showToast('请选择满减返券活动的结束时间!');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (fullC.text.trim().length == '0') {
|
|
|
|
Utils.showToast('请输入门槛金额!');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (couponSelectFree == null || couponSelectFree!.length == 0) {
|
|
|
|
Utils.showToast('请选择优惠券!');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
List<Map> couponsData = [];
|
|
|
|
couponSelectFree!.forEach((e) {
|
|
|
|
Map<String, String> coupon = {'id': e.id!, 'name': 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 == '选择日期') {
|
|
|
|
Utils.showToast('请选择阶梯返券活动的开始时间!');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (endDateLadder == '选择日期') {
|
|
|
|
Utils.showToast('请选择阶梯返券活动的结束时间!');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (fullC.text.trim().length == '0') {
|
|
|
|
Utils.showToast('请输入门槛金额!');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// if (couponSelectFree == null || couponSelectFree!.length == 0) {
|
|
|
|
// Utils.showToast('请选择优惠券!');
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
|
|
|
|
List<Map<String, String>> stairsData = [];
|
|
|
|
stairsData.add(
|
|
|
|
{
|
|
|
|
'price': '100',
|
|
|
|
'coupons':
|
|
|
|
"[{\"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\"}]",
|
|
|
|
},
|
|
|
|
);
|
|
|
|
stairsData.add(
|
|
|
|
{
|
|
|
|
'price': '100',
|
|
|
|
'coupons':
|
|
|
|
"[{\"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\"}]",
|
|
|
|
},
|
|
|
|
);
|
|
|
|
stairsData.add(
|
|
|
|
{
|
|
|
|
'price': '100',
|
|
|
|
'coupons':
|
|
|
|
"[{\"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\"}]",
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Map<String, String?> pramas = {
|
|
|
|
'sellerid':
|
|
|
|
Provider.of<UserModel>(context, listen: false).user!.sellerid!,
|
|
|
|
|
|
|
|
'full_reduction': fullReduction ? '1' : '0',
|
|
|
|
|
|
|
|
'stairs': !fullReduction ? '1' : '0',
|
|
|
|
'full_reduction_data':
|
|
|
|
fullReductionData == null ? null : jsonEncode(fullReductionData)
|
|
|
|
// 'stairs_data':
|
|
|
|
};
|
|
|
|
await financeProvider!.setActivityConfig(context, pramas);
|
|
|
|
}
|
|
|
|
|
|
|
|
///是否立即启用
|
|
|
|
Widget _canUse(
|
|
...
|
...
|
@@ -365,6 +478,17 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { |
|
|
|
(value) {
|
|
|
|
// {'text': picker.adapter.text, 'select': selecteds}
|
|
|
|
if (value != null) {
|
|
|
|
if (endDateFull != '选择日期') {
|
|
|
|
if (DateUtil.getDateTime(endDateFull).compareTo(
|
|
|
|
DateUtil.getDateTime(DateUtil.formatDateStr(
|
|
|
|
value,
|
|
|
|
format: DateFormats.y_mo_d))) <
|
|
|
|
0) {
|
|
|
|
Utils.showToast('满减返券的活动开始时间不能迟于活动结束时间');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
print(value);
|
|
|
|
fromDateFull = DateUtil.formatDateStr(value,
|
|
...
|
...
|
@@ -393,6 +517,17 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { |
|
|
|
(value) {
|
|
|
|
// {'text': picker.adapter.text, 'select': selecteds}
|
|
|
|
if (value != null) {
|
|
|
|
if (fromDateFull != '选择日期') {
|
|
|
|
if (DateUtil.getDateTime(DateUtil.formatDateStr(
|
|
|
|
value,
|
|
|
|
format: DateFormats.y_mo_d))
|
|
|
|
.compareTo(
|
|
|
|
DateUtil.getDateTime(fromDateFull)) <
|
|
|
|
0) {
|
|
|
|
Utils.showToast('满减返券的活动结束时间不能早于活动开始时间');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setState(() {
|
|
|
|
print(value);
|
|
|
|
endDateFull = DateUtil.formatDateStr(value,
|
|
...
|
...
|
@@ -455,46 +590,66 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { |
|
|
|
color: MyColours.color_515151, fontSize: font(14)),
|
|
|
|
),
|
|
|
|
Spacer(),
|
|
|
|
Container(
|
|
|
|
// width: w(100),
|
|
|
|
// height: w(30),
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: w(10), vertical: w(5)),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: MyColours.color_438E93,
|
|
|
|
borderRadius: BorderRadius.only(
|
|
|
|
topLeft: Radius.circular(r(5)),
|
|
|
|
bottomLeft: Radius.circular(r(5)))),
|
|
|
|
child: Text(
|
|
|
|
'每满门槛均发放',
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_ffffff,
|
|
|
|
fontSize: font(14)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: w(10), vertical: w(5)),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: MyColours.color_DBDBDB,
|
|
|
|
borderRadius: BorderRadius.only(
|
|
|
|
topRight: Radius.circular(r(5)),
|
|
|
|
bottomRight: Radius.circular(r(5)))),
|
|
|
|
child: Text(
|
|
|
|
'仅发放一次',
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_438E93,
|
|
|
|
fontSize: font(14)),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
InkWell(
|
|
|
|
onTap: () {
|
|
|
|
setState(() {
|
|
|
|
rule = !rule;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
// width: w(100),
|
|
|
|
// height: w(30),
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: w(10), vertical: w(5)),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: rule
|
|
|
|
? MyColours.color_438E93
|
|
|
|
: MyColours.color_DBDBDB,
|
|
|
|
borderRadius: BorderRadius.only(
|
|
|
|
topLeft: Radius.circular(r(5)),
|
|
|
|
bottomLeft: Radius.circular(r(5)))),
|
|
|
|
child: Text(
|
|
|
|
'每满门槛均发放',
|
|
|
|
style: TextStyle(
|
|
|
|
color: rule
|
|
|
|
? MyColours.color_ffffff
|
|
|
|
: MyColours.color_438E93,
|
|
|
|
fontSize: font(14)),
|
|
|
|
),
|
|
|
|
)),
|
|
|
|
InkWell(
|
|
|
|
onTap: () {
|
|
|
|
setState(() {
|
|
|
|
rule = !rule;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: w(10), vertical: w(5)),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: !rule
|
|
|
|
? MyColours.color_438E93
|
|
|
|
: MyColours.color_DBDBDB,
|
|
|
|
borderRadius: BorderRadius.only(
|
|
|
|
topRight: Radius.circular(r(5)),
|
|
|
|
bottomRight: Radius.circular(r(5)))),
|
|
|
|
child: Text(
|
|
|
|
'仅发放一次',
|
|
|
|
style: TextStyle(
|
|
|
|
color: !rule
|
|
|
|
? MyColours.color_ffffff
|
|
|
|
: MyColours.color_438E93,
|
|
|
|
fontSize: font(14)),
|
|
|
|
),
|
|
|
|
))
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
VEmptyView(22),
|
|
|
|
_canUse('开通实际支付阶梯返券【提客单】', ladderReduction, () {
|
|
|
|
_canUse('开通实际支付阶梯返券【提客单】', !fullReduction, () {
|
|
|
|
//
|
|
|
|
setState(() {
|
|
|
|
ladderReduction = !ladderReduction;
|
|
|
|
fullReduction = !fullReduction;
|
|
|
|
});
|
|
|
|
}),
|
|
|
|
_select('活动开始于', fromDateLadder, () {
|
|
...
|
...
|
@@ -601,7 +756,10 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { |
|
|
|
textColor: MyColours.color_ffffff,
|
|
|
|
isBold: true,
|
|
|
|
fontSize: 32,
|
|
|
|
onPressed: () {},
|
|
|
|
onPressed: () {
|
|
|
|
// 调用接口
|
|
|
|
_setActivityConfig();
|
|
|
|
},
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
...
|
...
|
|