Commit 7fe5fbde5c99da87b787f7733a6b83dabd44bc13

Authored by wdn127929
1 parent 1d335869

优惠券核销

import 'dart:convert';
import 'package:one_key/models/coupon_model.dart';
class OrderRechargeByidModel {
int ret;
OrderRechargeByidSunModel data;
String msg;
OrderRechargeByidModel({this.ret, this.data, this.msg});
OrderRechargeByidModel.fromJson(Map<String, dynamic> json) {
ret = json['ret'];
data = json['data'] != null
? new OrderRechargeByidSunModel.fromJson(json['data'])
: null;
msg = json['msg'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['ret'] = this.ret;
if (this.data != null) {
data['data'] = this.data.toJson();
}
data['msg'] = this.msg;
return data;
}
}
class OrderRechargeByidSunModel {
String id;
String sellerid;
String sellername;
String orderid;
String orderNo;
String rechargeId;
String rechargeName;
String isExamine;
String expDate;
String qrcode;
String type;
String cdate;
Activity activity;
OrderRechargeByidSunModel(
{this.id,
this.sellerid,
this.sellername,
this.orderid,
this.orderNo,
this.rechargeId,
this.rechargeName,
this.isExamine,
this.expDate,
this.qrcode,
this.type,
this.cdate,
this.activity});
OrderRechargeByidSunModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
sellerid = json['sellerid'];
sellername = json['sellername'];
orderid = json['orderid'];
orderNo = json['order_no'];
rechargeId = json['recharge_id'];
rechargeName = json['recharge_name'];
isExamine = json['is_examine'];
expDate = json['exp_date'];
qrcode = json['qrcode'];
type = json['type'];
cdate = json['cdate'];
activity = json['activity'] != null
? new Activity.fromJson(json['activity'])
: null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['sellerid'] = this.sellerid;
data['sellername'] = this.sellername;
data['orderid'] = this.orderid;
data['order_no'] = this.orderNo;
data['recharge_id'] = this.rechargeId;
data['recharge_name'] = this.rechargeName;
data['is_examine'] = this.isExamine;
data['exp_date'] = this.expDate;
data['qrcode'] = this.qrcode;
data['type'] = this.type;
data['cdate'] = this.cdate;
if (this.activity != null) {
data['activity'] = this.activity.toJson();
}
return data;
}
}
class Activity {
String id;
String uid;
String sellerid;
String uidList;
String isType;
String isExamine;
String aname;
String desc;
String stime;
String etime;
String explain;
String isOpen;
String price;
CouponUse use;
ExpDate expDate;
String status;
String cdate;
Activity(
{this.id,
this.uid,
this.sellerid,
this.uidList,
this.isType,
this.isExamine,
this.aname,
this.desc,
this.stime,
this.etime,
this.explain,
this.isOpen,
this.price,
this.use,
this.expDate,
this.status,
this.cdate});
Activity.fromJson(Map<String, dynamic> json) {
id = json['id'];
uid = json['uid'];
sellerid = json['sellerid'];
uidList = json['uid_list'];
isType = json['is_type'];
isExamine = json['is_examine'];
aname = json['aname'];
desc = json['desc'];
stime = json['stime'];
etime = json['etime'];
explain = json['explain'];
isOpen = json['is_open'];
price = json['price'];
// use = json['use'];
// expDate = json['exp_date'];
use = json['use'] == null
? null
: (json['use'] is String)
? CouponUse.fromJson(jsonDecode(json['use']))
: (json['use'] is Map)
? CouponUse.fromJson(json['use'])
: null;
expDate = json['exp_date'] == null
? null
: (json['exp_date'] is String)
? ExpDate.fromJson(jsonDecode(json['exp_date']))
: (json['exp_date'] is Map)
? ExpDate.fromJson(json['exp_date'])
: null;
status = json['status'];
cdate = json['cdate'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['uid'] = this.uid;
data['sellerid'] = this.sellerid;
data['uid_list'] = this.uidList;
data['is_type'] = this.isType;
data['is_examine'] = this.isExamine;
data['aname'] = this.aname;
data['desc'] = this.desc;
data['stime'] = this.stime;
data['etime'] = this.etime;
data['explain'] = this.explain;
data['is_open'] = this.isOpen;
data['price'] = this.price;
data['use'] = this.use;
data['exp_date'] = this.expDate;
data['status'] = this.status;
data['cdate'] = this.cdate;
return data;
}
}
... ...
... ... @@ -409,9 +409,13 @@ class HttpUrl {
static const String get_new_recharge_detail =
"?service=App.Activity.GetNewRecharge"; // 获取新充值活动详情
static const String get_activity_by_id =
"?service=App.Activity.GetActivityById"; // 客户经理优惠券信息
static const String get_order_recharge_by_id =
"?service=App.Activity.GetOrderRechargeByid"; // 获取订单中券详情
static const String set_new_recharge_write_off =
"?service=App.Activity.SetNewRechargeWriteOff"; // 核销未使用优惠券
}
... ...
... ... @@ -18,6 +18,7 @@ import 'package:barcode_scan2/barcode_scan2.dart';
import '../../utils/dialog_util.dart';
import '../../utils/misc.dart';
import '../../utils/utils.dart';
/**
* 优惠券列表
... ... @@ -127,7 +128,12 @@ class _CouponPageState extends State<CouponPage> with TickerProviderStateMixin {
// result.rawContent
setState(() => scanResult = result);
print(result);
NavigatorUtil.goVerificationCouponPage(context);
if (result.rawContent is String) {
if (Utils.cnIsNumber(result.rawContent)) {
NavigatorUtil.goVerificationCouponPage(context, result.rawContent);
}
}
} on PlatformException catch (e) {
setState(() {
scanResult = ScanResult(
... ...
... ... @@ -4,6 +4,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/net/dio_util.dart';
import 'package:one_key/provider/coupon_provider.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/dialog_util.dart';
... ... @@ -15,15 +16,19 @@ import 'package:one_key/widgets/system_app_bar.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:provider/provider.dart';
import '../../constant/state.dart';
import '../../utils/screen_util.dart';
import '../../widgets/page_exception.dart';
/**
* 核销券详情页
*/
class VerificationCouponPage extends StatefulWidget {
final String idstr;
VerificationCouponPage({
Key key,
this.idstr,
}) : super(key: key);
@override
... ... @@ -34,10 +39,135 @@ class _VerificationCouponPageState extends State<VerificationCouponPage> {
ScrollController controller = ScrollController();
final heightCell = ScreenUtil().setWidth(80);
CouponProvider couponProvider;
PageState pageState = PageState.Loading;
bool canUse = true;
bool past = false; //是否过期
int currTimeIndex;
bool limit = false;
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
// _couponNetworkData(0);
initTime(context);
_getOrderRechargeByid();
});
}
//初始化时间
initTime(BuildContext context) async {
UserModel userModel = Provider.of<UserModel>(context, listen: false);
DateTime dateTime = DateTime.now();
// String morning =
// userModel.user.morning.isEmpty ? "00:00-00:00" : userModel.user.morning;
String noon =
userModel.user.noon.isEmpty ? "00:00-00:00" : userModel.user.noon;
String night =
userModel.user.night.isEmpty ? "00:00-00:00" : userModel.user.night;
if (dateTime.isAfter(DateTime.parse(dateTime.year.toString() +
"-" +
Utils.addZeroNumber(dateTime.month) +
"-" +
Utils.addZeroNumber(dateTime.day) +
" " +
noon.split("-")[0] +
":00")) &&
dateTime.isBefore(DateTime.parse(dateTime.year.toString() +
"-" +
Utils.addZeroNumber(dateTime.month) +
"-" +
Utils.addZeroNumber(dateTime.day) +
" " +
noon.split("-")[1] +
":00"))) {
//午餐时间内
currTimeIndex = 2;
} else if (dateTime.isAfter(DateTime.parse(dateTime.year.toString() +
"-" +
Utils.addZeroNumber(dateTime.month) +
"-" +
Utils.addZeroNumber(dateTime.day) +
" " +
night.split("-")[0] +
":00")) &&
dateTime.isBefore(DateTime.parse(dateTime.year.toString() +
"-" +
Utils.addZeroNumber(dateTime.month) +
"-" +
Utils.addZeroNumber(dateTime.day) +
" " +
night.split("-")[1] +
":00"))) {
//晚市
currTimeIndex = 3;
} else {
//不在时间段内,不可使用
currTimeIndex = null;
}
}
_getOrderRechargeByid(
{PageState pageS = PageState.Loading, bool isShowLoading = true}) async {
pageState = pageS;
bool success = await couponProvider.getOrderRechargeByid(
context, {'id': widget.idstr},
isShowLoading: isShowLoading);
if (success) {
pageState = PageState.Success;
DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(
int.parse(couponProvider.orderRechargeByidSunModel.activity.etime) *
1000);
Duration days = dateTime.difference(DateTime.now());
print(days);
if (days.inDays < 0) {
//
past = true; //过期了
} else {
past = false; //没过期
}
if (couponProvider.orderRechargeByidSunModel.activity.expDate.isWeek) {
//使用限制是每周
List noonWeek = [];
List nightWeek = [];
couponProvider.orderRechargeByidSunModel.activity.expDate.weekData
.forEach((element) {
if (element.selectNoon) {
//午餐选中
noonWeek.add(element.title);
} else if (element.selectNig) {
//晚餐选中
nightWeek.add(element.title);
}
});
//获取当前是周几
String weekday = '周${Utils.formatWeekDayNum(DateTime.now().weekday)}';
if ((currTimeIndex == 2 && noonWeek.contains(weekday)) ||
(currTimeIndex == 3 && nightWeek.contains(weekday))) {
//可用
} else {
//不可用
limit = true;
}
}
if (couponProvider.orderRechargeByidSunModel.isExamine == '1' || past) {
//已核销or过期
canUse = false;
} else {
canUse = true;
}
} else {
pageState = PageState.ConnectivityError;
}
setState(() {});
}
///时间选择
... ... @@ -118,175 +248,281 @@ class _VerificationCouponPageState extends State<VerificationCouponPage> {
Widget build(BuildContext context) {
couponProvider = Provider.of<CouponProvider>(context, listen: true);
return Scaffold(
backgroundColor: MyColours.color_ffffff,
appBar: SystemAppBar(
'优惠券详情',
onTap: () {
Navigator.pop(context);
},
),
body: Column(children: [
Expanded(
child: SingleChildScrollView(
controller: controller,
physics: BouncingScrollPhysics(),
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(32)),
child: Column(
children: [
VEmptyView(56),
_item('券用途', '代金券/折扣券/菜品券',
textColor: MyColours.color_438E93, fontSize: 20),
Container(
height: ScreenUtil().setWidth(2),
color: MyColours.color_E7E7E7,
),
VEmptyView(24),
_item('券金额/折扣率/所含菜品', '200元/9折/精品烤鸭',
textColor: MyColours.color_438E93, fontSize: 20),
Container(
height: ScreenUtil().setWidth(2),
color: MyColours.color_E7E7E7,
backgroundColor: MyColours.color_ffffff,
appBar: SystemAppBar(
'优惠券详情',
onTap: () {
Navigator.pop(context);
},
),
body: Consumer<CouponProvider>(builder: (context, model, _) {
if (pageState != PageState.Success) {
return ExceptionPage(
pageState: pageState,
callback: () {
_getOrderRechargeByid();
},
emptyMsg: "暂时没有数据哦,",
emptyImg: "empty_search",
showMsg: "加载中,请稍后...",
);
} else {
return Column(children: [
Expanded(
child: SingleChildScrollView(
controller: controller,
physics: BouncingScrollPhysics(),
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(32)),
child: Column(
children: [
VEmptyView(56),
_item(
model.orderRechargeByidSunModel.activity.use ==
null
? '券名称'
: '券用途',
model.orderRechargeByidSunModel.activity.use ==
null
? model.orderRechargeByidSunModel.activity
.aname
: model.orderRechargeByidSunModel.activity
.use.isCash
? '代金券'
: model.orderRechargeByidSunModel
.activity.use.isDiscount
? '折扣券'
: model.orderRechargeByidSunModel
.activity.use.isDish
? '菜品券'
: '',
textColor: MyColours.color_438E93,
fontSize: 20),
if (model.orderRechargeByidSunModel.activity.use !=
null)
Column(
children: [
Container(
height: ScreenUtil().setWidth(2),
color: MyColours.color_E7E7E7,
),
VEmptyView(24),
_item(
model.orderRechargeByidSunModel.activity
.use.isCash
? '券金额'
: model.orderRechargeByidSunModel
.activity.use.isDiscount
? '折扣率'
: model.orderRechargeByidSunModel
.activity.use.isDish
? '所含菜品'
: '',
model.orderRechargeByidSunModel.activity
.use.isCash
? '${model.orderRechargeByidSunModel.activity.use.cash}元'
: model.orderRechargeByidSunModel
.activity.use.isDiscount
? '${model.orderRechargeByidSunModel.activity.use.discount}折'
: model.orderRechargeByidSunModel
.activity.use.isDish
? model
.couponSunModel.use.dish
: '',
textColor: MyColours.color_438E93,
fontSize: 20),
],
),
Container(
height: ScreenUtil().setWidth(2),
color: MyColours.color_E7E7E7,
),
VEmptyView(24),
_item(
'券要求',
model.orderRechargeByidSunModel.activity.desc ??
''),
Container(
height: ScreenUtil().setWidth(2),
color: MyColours.color_E7E7E7,
),
VEmptyView(24),
_item(
'有效期从',
Utils.getDateStrFromJiekou(model
.orderRechargeByidSunModel.activity.stime)),
Container(
height: ScreenUtil().setWidth(2),
color: MyColours.color_E7E7E7,
),
VEmptyView(24),
_item(
'有效期至',
Utils.getDateStrFromJiekou(model
.orderRechargeByidSunModel.activity.etime)),
// widget.couponSunModel.isType == '1'
// ? Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Container(
// height: ScreenUtil().setWidth(2),
// color: MyColours.color_E7E7E7,
// ),
// VEmptyView(24),
// _item('创建人', widget.couponSunModel.uid),
// ],
// )
// : SizedBox(),
// widget.couponSunModel.isType == '1'
// ? Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Container(
// height: ScreenUtil().setWidth(2),
// color: MyColours.color_E7E7E7,
// ),
// VEmptyView(24),
// _select(
// '谁可以发放',
// '查看',
// () async {
// await NavigatorUtil.goCouponToPersonnalPage(
// context, widget.couponSunModel.uidList,
// onlyShow: true);
// },
// )
// ],
// )
// : SizedBox(),
// widget.couponSunModel.explain != null &&
// widget.couponSunModel.explain != ''
// ? Container(
// height: ScreenUtil().setWidth(2),
// color: MyColours.color_E7E7E7,
// )
// : SizedBox(),
// widget.couponSunModel.explain != null &&
// widget.couponSunModel.explain != ''
// ? VEmptyView(24)
// : SizedBox(),
if (model.orderRechargeByidSunModel.activity
.expDate !=
null)
Column(children: [
Container(
height: ScreenUtil().setWidth(2),
color: MyColours.color_E7E7E7,
),
VEmptyView(24),
_item(
'使用限制',
model.orderRechargeByidSunModel.activity
.expDate.isNone
? '无'
: model.orderRechargeByidSunModel
.activity.expDate.isBirthday
? '会员生日当天'
: model.orderRechargeByidSunModel
.activity.expDate.isWeek
? model
.orderRechargeByidSunModel
.activity
.expDate
.weekShow
: ''),
]),
Container(
height: ScreenUtil().setWidth(2),
color: MyColours.color_E7E7E7,
),
VEmptyView(24),
_item(
'券说明',
model.orderRechargeByidSunModel.activity
.explain ??
''),
Container(
height: ScreenUtil().setWidth(2),
color: MyColours.color_E7E7E7,
),
// VEmptyView(24),
// _item('券状态',
// widget.couponSunModel.status == '1' ? '发放中' : '停用')
],
))),
),
!canUse
? Padding(
padding: EdgeInsets.only(bottom: w(58)),
child: Image.asset(
Utils.getImgPath(past ? 'past' : 'has_use'),
width: w(50),
),
VEmptyView(24),
_item('券要求', '满200可用'),
Container(
height: ScreenUtil().setWidth(2),
color: MyColours.color_E7E7E7,
)
: Container(
height: ScreenUtil().setWidth(91 * 2),
width: double.infinity,
padding: EdgeInsets.only(
top: ScreenUtil().setWidth(16 * 2),
bottom: ScreenUtil().setWidth(35 * 2),
left: ScreenUtil().setWidth(45 * 2),
right: ScreenUtil().setWidth(45 * 2),
),
VEmptyView(24),
_item('有效期从', '2022-4-4'), //Utils.getDateStrFromJiekou(
// widget.couponSunModel.stime)
Container(
height: ScreenUtil().setWidth(2),
color: MyColours.color_E7E7E7,
decoration: BoxDecoration(
color: MyColours.color_ffffff,
boxShadow: [
BoxShadow(
spreadRadius: ScreenUtil().setWidth(2),
color: Color.fromRGBO(0, 0, 0, 0.1),
offset: Offset(0, ScreenUtil().setWidth(-2)),
blurRadius: ScreenUtil().setWidth(8))
],
borderRadius: BorderRadius.all(
Radius.circular(ScreenUtil().setWidth(16)),
),
),
VEmptyView(24),
_item('有效期至', '2022-4-4'),
// widget.couponSunModel.isType == '1'
// ? Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Container(
// height: ScreenUtil().setWidth(2),
// color: MyColours.color_E7E7E7,
// ),
// VEmptyView(24),
// _item('创建人', widget.couponSunModel.uid),
// ],
// )
// : SizedBox(),
// widget.couponSunModel.isType == '1'
// ? Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Container(
// height: ScreenUtil().setWidth(2),
// color: MyColours.color_E7E7E7,
// ),
// VEmptyView(24),
// _select(
// '谁可以发放',
// '查看',
// () async {
// await NavigatorUtil.goCouponToPersonnalPage(
// context, widget.couponSunModel.uidList,
// onlyShow: true);
// },
// )
// ],
// )
// : SizedBox(),
// widget.couponSunModel.explain != null &&
// widget.couponSunModel.explain != ''
// ? Container(
// height: ScreenUtil().setWidth(2),
// color: MyColours.color_E7E7E7,
// )
// : SizedBox(),
// widget.couponSunModel.explain != null &&
// widget.couponSunModel.explain != ''
// ? VEmptyView(24)
// : SizedBox(),
_item('券说明',
'最多最多最多最多最多最多最多最多最多最多最多最多最多最多最多最多最多最多最多最多最多最多最多最多最多'),
child: RoundButton(
text: '核销使用',
height: ScreenUtil().setWidth(80),
radius: ScreenUtil().setWidth(14),
isBold: false,
fontSize: 28,
onPressed: () async {
// if (limit) {
// Utils.showToast('不在使用限制范围内,不可使用!');
// return;
// } else {
String limitStr = '';
if (limit) {
limitStr = '当前优惠券不在可用时间段内,';
} else if (couponProvider.orderRechargeByidSunModel
.activity.expDate.isBirthday) {
limitStr = '当前券只有生日可用,请核实后核销。';
}
DialogUtil.cupertinoAlertDialog(context,
textAlign: TextAlign.left,
content: '${limitStr}确定要核销当前优惠券吗?核销使用后,该券不能再次使用。',
rCallback: () async {
//确定核销
Container(
height: ScreenUtil().setWidth(2),
color: MyColours.color_E7E7E7,
bool success = await couponProvider
.setNewRechargeWriteOff(
context, {'id': widget.idstr});
if (success) {
//核销成功,刷新当前页面
_getOrderRechargeByid(
pageS: PageState.Success,
isShowLoading: true);
}
});
// }
},
),
// VEmptyView(24),
// _item('券状态',
// widget.couponSunModel.status == '1' ? '发放中' : '停用')
],
))),
),
true
? Padding(
padding: EdgeInsets.only(bottom: w(58)),
child: Image.asset(
Utils.getImgPath('has_use'),
width: w(50),
),
)
: Container(
height: ScreenUtil().setWidth(91 * 2),
width: double.infinity,
padding: EdgeInsets.only(
top: ScreenUtil().setWidth(16 * 2),
bottom: ScreenUtil().setWidth(35 * 2),
left: ScreenUtil().setWidth(45 * 2),
right: ScreenUtil().setWidth(45 * 2),
),
decoration: BoxDecoration(
color: MyColours.color_ffffff,
boxShadow: [
BoxShadow(
spreadRadius: ScreenUtil().setWidth(2),
color: Color.fromRGBO(0, 0, 0, 0.1),
offset: Offset(0, ScreenUtil().setWidth(-2)),
blurRadius: ScreenUtil().setWidth(8))
],
borderRadius: BorderRadius.all(
Radius.circular(ScreenUtil().setWidth(16)),
),
),
child: RoundButton(
text: '核销使用',
height: ScreenUtil().setWidth(80),
radius: ScreenUtil().setWidth(14),
isBold: false,
fontSize: 28,
onPressed: () async {
DialogUtil.cupertinoAlertDialog(context,
content: '确定要核销当前优惠券吗?核销使用后,该券不能再次使用。');
// "stime": fromDate == '点击选择'
// ? ""
// : '${DateUtil.getDateMsByTimeStr(fromDate) / 1000}',
// "etime": endDate == '点击选择'
// ? ''
// : '${DateUtil.getDateMsByTimeStr(endDate) / 1000}',
// UserModel userModel =
// Provider.of<UserModel>(context, listen: false);
// if (userModel.user.role_name == '管理员' ||
// userModel.user.role_name == '店长') {
// NavigatorUtil.goRechargeEditPage(context);
// } else {
// bool needRefresh =
// await NavigatorUtil.goCouponEditPage(context);
// print(needRefresh);
// if (needRefresh != null && needRefresh) {
// bus.emit('refresh_coupon_list_f');
// //刷新页面数据
// // _controller.callRefresh();
// // _couponNetworkData(tabController.index);
// }
// }
},
),
)
]),
);
)
]);
}
}));
}
}
... ...
... ... @@ -965,7 +965,15 @@ class _RechargeEditPageState extends State<RechargeEditPage> {
return;
}
if (priceminC.text.trim().length == 0) {
Utils.showToast('请输入充值金额门槛!');
Utils.showToast('请输入充值门槛金额!');
return;
}
if (!Utils.isNumeric(priceminC.text.trim())) {
Utils.showToast('充值门槛金额请输入数字!');
return;
}
if (double.parse(priceminC.text.trim()) <= 0) {
Utils.showToast('充值门槛金额需大于0!');
return;
}
//优惠活动
... ...
... ... @@ -84,7 +84,7 @@ class _OrderPreviewPageState extends State<OrderPreviewPage> {
? '预计可以节约${marketingCenterProvider.rechargeList[index].rechargeList.price}元!'
: '预计可以享受大量优惠!';
String name = widget.detailEntity.rnameStr == null
String name = widget.detailEntity.rnameStr != null
? '${widget.detailEntity.rnameStr}:\n'
: '';
... ... @@ -731,6 +731,7 @@ class _OrderPreviewPageState extends State<OrderPreviewPage> {
// widget.isSelect ? Colors.white : MyColours.color_199095,
//输入文本的样式
style: TextStyle(
height: 1.3,
color: MyColours.color_999999,
fontSize: font(12),
),
... ...
... ... @@ -592,6 +592,7 @@ class _OrderSharePageState extends State<OrderSharePage> {
child: Text(
widget.recommend,
style: TextStyle(
height: 1.3,
color: MyColours.color_999999,
fontSize: font(12),
),
... ...
... ... @@ -12,6 +12,8 @@ import 'package:one_key/provider/user_model.dart';
import 'package:one_key/utils/utils.dart';
import 'package:provider/provider.dart';
import '../models/order_recharge_by_id_model.dart';
class CouponProvider with ChangeNotifier {
List<bool> swichStateData = []; //优惠券是否启用 true启用 false停用
PageState pageState = PageState.Loading;
... ... @@ -32,6 +34,7 @@ class CouponProvider with ChangeNotifier {
List<CouponSunModel> couponListSelect = []; //优惠券选择列表
int index = 0; //选中的优惠券index
CouponSunModel couponSunModel; //优惠券详情
OrderRechargeByidSunModel orderRechargeByidSunModel; //核销详情页
CouponProvider() {
// for (int i = 0; i < 20; i++) {
... ... @@ -556,6 +559,34 @@ class CouponProvider with ChangeNotifier {
}
}
///核销未使用优惠券
Future<dynamic> setNewRechargeWriteOff(
BuildContext context, Map<String, String> params,
{isShowLoading = true}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(
context, Method.get, HttpUrl.set_new_recharge_write_off,
data: params, showLoading: isShowLoading)
.catchError((error) {
print(error.toString());
if (error is MyError) {}
return false;
});
if (baseResp.code == Constant.status_success) {
if (int.parse(baseResp.data.toString()) == 1) {
return true;
} else {
// Utils.showToast(baseResp.msg ?? "修改失败");
return false;
}
} else {
if (baseResp != null) {
// Utils.showToast(baseResp.msg ?? "");
}
return false;
}
}
///设置预定绑定活动ID
Future<dynamic> setActivityAsReserve(
BuildContext context, Map<String, String> params,
... ... @@ -656,6 +687,35 @@ class CouponProvider with ChangeNotifier {
}
}
///获取订单中券详情
Future<bool> getOrderRechargeByid(
BuildContext context, Map<String, String> params,
{isShowLoading = true}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.get_order_recharge_by_id,
data: params, showLoading: isShowLoading)
.catchError((error) {
print(error.toString());
if (error is MyError) {}
return false;
});
if (baseResp.code == Constant.status_success) {
if (baseResp.data == null) {
return false;
} else {
orderRechargeByidSunModel =
OrderRechargeByidModel.fromJson(baseResp.responseData).data;
return true;
}
} else {
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
return false;
}
}
///预定安排微信发短信
Future<bool> sendSMSWxSendSms(
BuildContext context, Map<String, String> params,
... ...
... ... @@ -1588,10 +1588,12 @@ class NavigatorUtil {
///核销使用
static Future<dynamic> goVerificationCouponPage(
BuildContext context, {
BuildContext context,
String idstr, {
replace = false,
}) {
return _navigateTo(context, "${Routes.verification_coupon_page}",
return _navigateTo(
context, "${Routes.verification_coupon_page}?idstr=$idstr",
replace: replace);
}
... ...
... ... @@ -2580,13 +2580,13 @@ var verificationCouponPageHandle = new Handler(
// json.decode(
// FluroConvertUtils.fluroCnParamsDecode(params["detail"].first)));
// String selectIDs = params["selectIDs"].first;
String idstr = params["idstr"].first;
// List<String> selectList = [];
// if (selectIDs.length > 0) {
// selectList = selectIDs.split(',');
// }
return ChangeNotifierProvider<CouponProvider>(
create: (_) => CouponProvider(), child: VerificationCouponPage());
create: (_) => CouponProvider(), child: VerificationCouponPage(idstr:idstr));
});
///充值优惠选择
... ...
... ... @@ -5923,7 +5923,6 @@ class DialogUtil {
}
}
static Future cupertinoAlertDialogFeast(BuildContext context,
{String title = "",
String content = "内容",
... ... @@ -6062,6 +6061,7 @@ class DialogUtil {
bool isBoldContent = false,
Color contentColor = MyColours.color_99000000,
VoidCallback lCallback,
TextAlign textAlign = TextAlign.center,
VoidCallback rCallback}) {
showCupertinoDialog(
context: context,
... ... @@ -6075,6 +6075,7 @@ class DialogUtil {
color: MyColours.color_E6000000))
: SizedBox(),
content: Text(content,
textAlign:textAlign,
style: TextStyle(
fontWeight:
isBoldContent ? FontWeight.bold : FontWeight.normal,
... ...
... ... @@ -39,6 +39,11 @@ import 'package:image_cropper/image_cropper.dart';
typedef BookTimeSetCallback = void Function(bool needChange);
class Utils {
static bool cnIsNumber(String str) {
final reg = RegExp(r'^-?[0-9.]+$');
return reg.hasMatch(str);
}
///2023-03-11 二月二十
static String returnYMDandLunarCalendar(DateTime day, BuildContext context) {
String date =
... ...