Commit 7fe5fbde5c99da87b787f7733a6b83dabd44bc13

Authored by wdn127929
1 parent 1d335869

优惠券核销

  1 +import 'dart:convert';
  2 +
  3 +import 'package:one_key/models/coupon_model.dart';
  4 +
  5 +class OrderRechargeByidModel {
  6 + int ret;
  7 + OrderRechargeByidSunModel data;
  8 + String msg;
  9 +
  10 + OrderRechargeByidModel({this.ret, this.data, this.msg});
  11 +
  12 + OrderRechargeByidModel.fromJson(Map<String, dynamic> json) {
  13 + ret = json['ret'];
  14 + data = json['data'] != null
  15 + ? new OrderRechargeByidSunModel.fromJson(json['data'])
  16 + : null;
  17 + msg = json['msg'];
  18 + }
  19 +
  20 + Map<String, dynamic> toJson() {
  21 + final Map<String, dynamic> data = new Map<String, dynamic>();
  22 + data['ret'] = this.ret;
  23 + if (this.data != null) {
  24 + data['data'] = this.data.toJson();
  25 + }
  26 + data['msg'] = this.msg;
  27 + return data;
  28 + }
  29 +}
  30 +
  31 +class OrderRechargeByidSunModel {
  32 + String id;
  33 + String sellerid;
  34 + String sellername;
  35 + String orderid;
  36 + String orderNo;
  37 + String rechargeId;
  38 + String rechargeName;
  39 + String isExamine;
  40 + String expDate;
  41 + String qrcode;
  42 + String type;
  43 + String cdate;
  44 + Activity activity;
  45 +
  46 + OrderRechargeByidSunModel(
  47 + {this.id,
  48 + this.sellerid,
  49 + this.sellername,
  50 + this.orderid,
  51 + this.orderNo,
  52 + this.rechargeId,
  53 + this.rechargeName,
  54 + this.isExamine,
  55 + this.expDate,
  56 + this.qrcode,
  57 + this.type,
  58 + this.cdate,
  59 + this.activity});
  60 +
  61 + OrderRechargeByidSunModel.fromJson(Map<String, dynamic> json) {
  62 + id = json['id'];
  63 + sellerid = json['sellerid'];
  64 + sellername = json['sellername'];
  65 + orderid = json['orderid'];
  66 + orderNo = json['order_no'];
  67 + rechargeId = json['recharge_id'];
  68 + rechargeName = json['recharge_name'];
  69 + isExamine = json['is_examine'];
  70 + expDate = json['exp_date'];
  71 + qrcode = json['qrcode'];
  72 + type = json['type'];
  73 + cdate = json['cdate'];
  74 + activity = json['activity'] != null
  75 + ? new Activity.fromJson(json['activity'])
  76 + : null;
  77 + }
  78 +
  79 + Map<String, dynamic> toJson() {
  80 + final Map<String, dynamic> data = new Map<String, dynamic>();
  81 + data['id'] = this.id;
  82 + data['sellerid'] = this.sellerid;
  83 + data['sellername'] = this.sellername;
  84 + data['orderid'] = this.orderid;
  85 + data['order_no'] = this.orderNo;
  86 + data['recharge_id'] = this.rechargeId;
  87 + data['recharge_name'] = this.rechargeName;
  88 + data['is_examine'] = this.isExamine;
  89 + data['exp_date'] = this.expDate;
  90 + data['qrcode'] = this.qrcode;
  91 + data['type'] = this.type;
  92 + data['cdate'] = this.cdate;
  93 + if (this.activity != null) {
  94 + data['activity'] = this.activity.toJson();
  95 + }
  96 + return data;
  97 + }
  98 +}
  99 +
  100 +class Activity {
  101 + String id;
  102 + String uid;
  103 + String sellerid;
  104 + String uidList;
  105 + String isType;
  106 + String isExamine;
  107 + String aname;
  108 + String desc;
  109 + String stime;
  110 + String etime;
  111 + String explain;
  112 + String isOpen;
  113 + String price;
  114 + CouponUse use;
  115 + ExpDate expDate;
  116 + String status;
  117 + String cdate;
  118 +
  119 + Activity(
  120 + {this.id,
  121 + this.uid,
  122 + this.sellerid,
  123 + this.uidList,
  124 + this.isType,
  125 + this.isExamine,
  126 + this.aname,
  127 + this.desc,
  128 + this.stime,
  129 + this.etime,
  130 + this.explain,
  131 + this.isOpen,
  132 + this.price,
  133 + this.use,
  134 + this.expDate,
  135 + this.status,
  136 + this.cdate});
  137 +
  138 + Activity.fromJson(Map<String, dynamic> json) {
  139 + id = json['id'];
  140 + uid = json['uid'];
  141 + sellerid = json['sellerid'];
  142 + uidList = json['uid_list'];
  143 + isType = json['is_type'];
  144 + isExamine = json['is_examine'];
  145 + aname = json['aname'];
  146 + desc = json['desc'];
  147 + stime = json['stime'];
  148 + etime = json['etime'];
  149 + explain = json['explain'];
  150 + isOpen = json['is_open'];
  151 + price = json['price'];
  152 + // use = json['use'];
  153 + // expDate = json['exp_date'];
  154 +
  155 + use = json['use'] == null
  156 + ? null
  157 + : (json['use'] is String)
  158 + ? CouponUse.fromJson(jsonDecode(json['use']))
  159 + : (json['use'] is Map)
  160 + ? CouponUse.fromJson(json['use'])
  161 + : null;
  162 + expDate = json['exp_date'] == null
  163 + ? null
  164 + : (json['exp_date'] is String)
  165 + ? ExpDate.fromJson(jsonDecode(json['exp_date']))
  166 + : (json['exp_date'] is Map)
  167 + ? ExpDate.fromJson(json['exp_date'])
  168 + : null;
  169 + status = json['status'];
  170 + cdate = json['cdate'];
  171 + }
  172 +
  173 + Map<String, dynamic> toJson() {
  174 + final Map<String, dynamic> data = new Map<String, dynamic>();
  175 + data['id'] = this.id;
  176 + data['uid'] = this.uid;
  177 + data['sellerid'] = this.sellerid;
  178 + data['uid_list'] = this.uidList;
  179 + data['is_type'] = this.isType;
  180 + data['is_examine'] = this.isExamine;
  181 + data['aname'] = this.aname;
  182 + data['desc'] = this.desc;
  183 + data['stime'] = this.stime;
  184 + data['etime'] = this.etime;
  185 + data['explain'] = this.explain;
  186 + data['is_open'] = this.isOpen;
  187 + data['price'] = this.price;
  188 + data['use'] = this.use;
  189 + data['exp_date'] = this.expDate;
  190 + data['status'] = this.status;
  191 + data['cdate'] = this.cdate;
  192 + return data;
  193 + }
  194 +}
@@ -409,9 +409,13 @@ class HttpUrl { @@ -409,9 +409,13 @@ class HttpUrl {
409 static const String get_new_recharge_detail = 409 static const String get_new_recharge_detail =
410 "?service=App.Activity.GetNewRecharge"; // 获取新充值活动详情 410 "?service=App.Activity.GetNewRecharge"; // 获取新充值活动详情
411 411
412 -  
413 static const String get_activity_by_id = 412 static const String get_activity_by_id =
414 "?service=App.Activity.GetActivityById"; // 客户经理优惠券信息 413 "?service=App.Activity.GetActivityById"; // 客户经理优惠券信息
415 - 414 +
  415 + static const String get_order_recharge_by_id =
  416 + "?service=App.Activity.GetOrderRechargeByid"; // 获取订单中券详情
  417 +
  418 + static const String set_new_recharge_write_off =
  419 + "?service=App.Activity.SetNewRechargeWriteOff"; // 核销未使用优惠券
416 420
417 } 421 }
@@ -18,6 +18,7 @@ import 'package:barcode_scan2/barcode_scan2.dart'; @@ -18,6 +18,7 @@ import 'package:barcode_scan2/barcode_scan2.dart';
18 18
19 import '../../utils/dialog_util.dart'; 19 import '../../utils/dialog_util.dart';
20 import '../../utils/misc.dart'; 20 import '../../utils/misc.dart';
  21 +import '../../utils/utils.dart';
21 22
22 /** 23 /**
23 * 优惠券列表 24 * 优惠券列表
@@ -127,7 +128,12 @@ class _CouponPageState extends State<CouponPage> with TickerProviderStateMixin { @@ -127,7 +128,12 @@ class _CouponPageState extends State<CouponPage> with TickerProviderStateMixin {
127 // result.rawContent 128 // result.rawContent
128 setState(() => scanResult = result); 129 setState(() => scanResult = result);
129 print(result); 130 print(result);
130 - NavigatorUtil.goVerificationCouponPage(context); 131 +
  132 + if (result.rawContent is String) {
  133 + if (Utils.cnIsNumber(result.rawContent)) {
  134 + NavigatorUtil.goVerificationCouponPage(context, result.rawContent);
  135 + }
  136 + }
131 } on PlatformException catch (e) { 137 } on PlatformException catch (e) {
132 setState(() { 138 setState(() {
133 scanResult = ScanResult( 139 scanResult = ScanResult(
@@ -4,6 +4,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -4,6 +4,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
4 import 'package:one_key/net/dio_util.dart'; 4 import 'package:one_key/net/dio_util.dart';
5 5
6 import 'package:one_key/provider/coupon_provider.dart'; 6 import 'package:one_key/provider/coupon_provider.dart';
  7 +import 'package:one_key/provider/user_model.dart';
7 8
8 import 'package:one_key/res/colors.dart'; 9 import 'package:one_key/res/colors.dart';
9 import 'package:one_key/utils/dialog_util.dart'; 10 import 'package:one_key/utils/dialog_util.dart';
@@ -15,15 +16,19 @@ import 'package:one_key/widgets/system_app_bar.dart'; @@ -15,15 +16,19 @@ import 'package:one_key/widgets/system_app_bar.dart';
15 import 'package:one_key/widgets/v_empty_view.dart'; 16 import 'package:one_key/widgets/v_empty_view.dart';
16 import 'package:provider/provider.dart'; 17 import 'package:provider/provider.dart';
17 18
  19 +import '../../constant/state.dart';
18 import '../../utils/screen_util.dart'; 20 import '../../utils/screen_util.dart';
  21 +import '../../widgets/page_exception.dart';
19 22
20 /** 23 /**
21 * 核销券详情页 24 * 核销券详情页
22 */ 25 */
23 26
24 class VerificationCouponPage extends StatefulWidget { 27 class VerificationCouponPage extends StatefulWidget {
  28 + final String idstr;
25 VerificationCouponPage({ 29 VerificationCouponPage({
26 Key key, 30 Key key,
  31 + this.idstr,
27 }) : super(key: key); 32 }) : super(key: key);
28 33
29 @override 34 @override
@@ -34,10 +39,135 @@ class _VerificationCouponPageState extends State<VerificationCouponPage> { @@ -34,10 +39,135 @@ class _VerificationCouponPageState extends State<VerificationCouponPage> {
34 ScrollController controller = ScrollController(); 39 ScrollController controller = ScrollController();
35 final heightCell = ScreenUtil().setWidth(80); 40 final heightCell = ScreenUtil().setWidth(80);
36 CouponProvider couponProvider; 41 CouponProvider couponProvider;
  42 + PageState pageState = PageState.Loading;
  43 + bool canUse = true;
  44 + bool past = false; //是否过期
  45 + int currTimeIndex;
  46 + bool limit = false;
37 47
38 @override 48 @override
39 void initState() { 49 void initState() {
40 super.initState(); 50 super.initState();
  51 +
  52 + WidgetsBinding.instance.addPostFrameCallback((_) {
  53 + // _couponNetworkData(0);
  54 + initTime(context);
  55 + _getOrderRechargeByid();
  56 + });
  57 + }
  58 +
  59 + //初始化时间
  60 + initTime(BuildContext context) async {
  61 + UserModel userModel = Provider.of<UserModel>(context, listen: false);
  62 + DateTime dateTime = DateTime.now();
  63 +
  64 + // String morning =
  65 + // userModel.user.morning.isEmpty ? "00:00-00:00" : userModel.user.morning;
  66 + String noon =
  67 + userModel.user.noon.isEmpty ? "00:00-00:00" : userModel.user.noon;
  68 + String night =
  69 + userModel.user.night.isEmpty ? "00:00-00:00" : userModel.user.night;
  70 +
  71 + if (dateTime.isAfter(DateTime.parse(dateTime.year.toString() +
  72 + "-" +
  73 + Utils.addZeroNumber(dateTime.month) +
  74 + "-" +
  75 + Utils.addZeroNumber(dateTime.day) +
  76 + " " +
  77 + noon.split("-")[0] +
  78 + ":00")) &&
  79 + dateTime.isBefore(DateTime.parse(dateTime.year.toString() +
  80 + "-" +
  81 + Utils.addZeroNumber(dateTime.month) +
  82 + "-" +
  83 + Utils.addZeroNumber(dateTime.day) +
  84 + " " +
  85 + noon.split("-")[1] +
  86 + ":00"))) {
  87 + //午餐时间内
  88 + currTimeIndex = 2;
  89 + } else if (dateTime.isAfter(DateTime.parse(dateTime.year.toString() +
  90 + "-" +
  91 + Utils.addZeroNumber(dateTime.month) +
  92 + "-" +
  93 + Utils.addZeroNumber(dateTime.day) +
  94 + " " +
  95 + night.split("-")[0] +
  96 + ":00")) &&
  97 + dateTime.isBefore(DateTime.parse(dateTime.year.toString() +
  98 + "-" +
  99 + Utils.addZeroNumber(dateTime.month) +
  100 + "-" +
  101 + Utils.addZeroNumber(dateTime.day) +
  102 + " " +
  103 + night.split("-")[1] +
  104 + ":00"))) {
  105 + //晚市
  106 + currTimeIndex = 3;
  107 + } else {
  108 + //不在时间段内,不可使用
  109 + currTimeIndex = null;
  110 + }
  111 + }
  112 +
  113 + _getOrderRechargeByid(
  114 + {PageState pageS = PageState.Loading, bool isShowLoading = true}) async {
  115 + pageState = pageS;
  116 + bool success = await couponProvider.getOrderRechargeByid(
  117 + context, {'id': widget.idstr},
  118 + isShowLoading: isShowLoading);
  119 + if (success) {
  120 + pageState = PageState.Success;
  121 +
  122 + DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(
  123 + int.parse(couponProvider.orderRechargeByidSunModel.activity.etime) *
  124 + 1000);
  125 +
  126 + Duration days = dateTime.difference(DateTime.now());
  127 +
  128 + print(days);
  129 + if (days.inDays < 0) {
  130 + //
  131 + past = true; //过期了
  132 + } else {
  133 + past = false; //没过期
  134 + }
  135 +
  136 + if (couponProvider.orderRechargeByidSunModel.activity.expDate.isWeek) {
  137 + //使用限制是每周
  138 + List noonWeek = [];
  139 + List nightWeek = [];
  140 + couponProvider.orderRechargeByidSunModel.activity.expDate.weekData
  141 + .forEach((element) {
  142 + if (element.selectNoon) {
  143 + //午餐选中
  144 + noonWeek.add(element.title);
  145 + } else if (element.selectNig) {
  146 + //晚餐选中
  147 + nightWeek.add(element.title);
  148 + }
  149 + });
  150 + //获取当前是周几
  151 + String weekday = '周${Utils.formatWeekDayNum(DateTime.now().weekday)}';
  152 + if ((currTimeIndex == 2 && noonWeek.contains(weekday)) ||
  153 + (currTimeIndex == 3 && nightWeek.contains(weekday))) {
  154 + //可用
  155 + } else {
  156 + //不可用
  157 + limit = true;
  158 + }
  159 + }
  160 +
  161 + if (couponProvider.orderRechargeByidSunModel.isExamine == '1' || past) {
  162 + //已核销or过期
  163 + canUse = false;
  164 + } else {
  165 + canUse = true;
  166 + }
  167 + } else {
  168 + pageState = PageState.ConnectivityError;
  169 + }
  170 + setState(() {});
41 } 171 }
42 172
43 ///时间选择 173 ///时间选择
@@ -118,175 +248,281 @@ class _VerificationCouponPageState extends State<VerificationCouponPage> { @@ -118,175 +248,281 @@ class _VerificationCouponPageState extends State<VerificationCouponPage> {
118 Widget build(BuildContext context) { 248 Widget build(BuildContext context) {
119 couponProvider = Provider.of<CouponProvider>(context, listen: true); 249 couponProvider = Provider.of<CouponProvider>(context, listen: true);
120 return Scaffold( 250 return Scaffold(
121 - backgroundColor: MyColours.color_ffffff,  
122 - appBar: SystemAppBar(  
123 - '优惠券详情',  
124 - onTap: () {  
125 - Navigator.pop(context);  
126 - },  
127 - ),  
128 - body: Column(children: [  
129 - Expanded(  
130 - child: SingleChildScrollView(  
131 - controller: controller,  
132 - physics: BouncingScrollPhysics(),  
133 - child: Padding(  
134 - padding: EdgeInsets.symmetric(  
135 - horizontal: ScreenUtil().setWidth(32)),  
136 - child: Column(  
137 - children: [  
138 - VEmptyView(56),  
139 - _item('券用途', '代金券/折扣券/菜品券',  
140 - textColor: MyColours.color_438E93, fontSize: 20),  
141 - Container(  
142 - height: ScreenUtil().setWidth(2),  
143 - color: MyColours.color_E7E7E7,  
144 - ),  
145 - VEmptyView(24),  
146 - _item('券金额/折扣率/所含菜品', '200元/9折/精品烤鸭',  
147 - textColor: MyColours.color_438E93, fontSize: 20),  
148 - Container(  
149 - height: ScreenUtil().setWidth(2),  
150 - color: MyColours.color_E7E7E7, 251 + backgroundColor: MyColours.color_ffffff,
  252 + appBar: SystemAppBar(
  253 + '优惠券详情',
  254 + onTap: () {
  255 + Navigator.pop(context);
  256 + },
  257 + ),
  258 + body: Consumer<CouponProvider>(builder: (context, model, _) {
  259 + if (pageState != PageState.Success) {
  260 + return ExceptionPage(
  261 + pageState: pageState,
  262 + callback: () {
  263 + _getOrderRechargeByid();
  264 + },
  265 + emptyMsg: "暂时没有数据哦,",
  266 + emptyImg: "empty_search",
  267 + showMsg: "加载中,请稍后...",
  268 + );
  269 + } else {
  270 + return Column(children: [
  271 + Expanded(
  272 + child: SingleChildScrollView(
  273 + controller: controller,
  274 + physics: BouncingScrollPhysics(),
  275 + child: Padding(
  276 + padding: EdgeInsets.symmetric(
  277 + horizontal: ScreenUtil().setWidth(32)),
  278 + child: Column(
  279 + children: [
  280 + VEmptyView(56),
  281 + _item(
  282 + model.orderRechargeByidSunModel.activity.use ==
  283 + null
  284 + ? '券名称'
  285 + : '券用途',
  286 + model.orderRechargeByidSunModel.activity.use ==
  287 + null
  288 + ? model.orderRechargeByidSunModel.activity
  289 + .aname
  290 + : model.orderRechargeByidSunModel.activity
  291 + .use.isCash
  292 + ? '代金券'
  293 + : model.orderRechargeByidSunModel
  294 + .activity.use.isDiscount
  295 + ? '折扣券'
  296 + : model.orderRechargeByidSunModel
  297 + .activity.use.isDish
  298 + ? '菜品券'
  299 + : '',
  300 + textColor: MyColours.color_438E93,
  301 + fontSize: 20),
  302 + if (model.orderRechargeByidSunModel.activity.use !=
  303 + null)
  304 + Column(
  305 + children: [
  306 + Container(
  307 + height: ScreenUtil().setWidth(2),
  308 + color: MyColours.color_E7E7E7,
  309 + ),
  310 + VEmptyView(24),
  311 + _item(
  312 + model.orderRechargeByidSunModel.activity
  313 + .use.isCash
  314 + ? '券金额'
  315 + : model.orderRechargeByidSunModel
  316 + .activity.use.isDiscount
  317 + ? '折扣率'
  318 + : model.orderRechargeByidSunModel
  319 + .activity.use.isDish
  320 + ? '所含菜品'
  321 + : '',
  322 + model.orderRechargeByidSunModel.activity
  323 + .use.isCash
  324 + ? '${model.orderRechargeByidSunModel.activity.use.cash}元'
  325 + : model.orderRechargeByidSunModel
  326 + .activity.use.isDiscount
  327 + ? '${model.orderRechargeByidSunModel.activity.use.discount}折'
  328 + : model.orderRechargeByidSunModel
  329 + .activity.use.isDish
  330 + ? model
  331 + .couponSunModel.use.dish
  332 + : '',
  333 + textColor: MyColours.color_438E93,
  334 + fontSize: 20),
  335 + ],
  336 + ),
  337 + Container(
  338 + height: ScreenUtil().setWidth(2),
  339 + color: MyColours.color_E7E7E7,
  340 + ),
  341 + VEmptyView(24),
  342 + _item(
  343 + '券要求',
  344 + model.orderRechargeByidSunModel.activity.desc ??
  345 + ''),
  346 + Container(
  347 + height: ScreenUtil().setWidth(2),
  348 + color: MyColours.color_E7E7E7,
  349 + ),
  350 + VEmptyView(24),
  351 + _item(
  352 + '有效期从',
  353 + Utils.getDateStrFromJiekou(model
  354 + .orderRechargeByidSunModel.activity.stime)),
  355 + Container(
  356 + height: ScreenUtil().setWidth(2),
  357 + color: MyColours.color_E7E7E7,
  358 + ),
  359 + VEmptyView(24),
  360 + _item(
  361 + '有效期至',
  362 + Utils.getDateStrFromJiekou(model
  363 + .orderRechargeByidSunModel.activity.etime)),
  364 + // widget.couponSunModel.isType == '1'
  365 + // ? Column(
  366 + // crossAxisAlignment: CrossAxisAlignment.start,
  367 + // children: [
  368 + // Container(
  369 + // height: ScreenUtil().setWidth(2),
  370 + // color: MyColours.color_E7E7E7,
  371 + // ),
  372 + // VEmptyView(24),
  373 + // _item('创建人', widget.couponSunModel.uid),
  374 + // ],
  375 + // )
  376 + // : SizedBox(),
  377 + // widget.couponSunModel.isType == '1'
  378 + // ? Column(
  379 + // crossAxisAlignment: CrossAxisAlignment.start,
  380 + // children: [
  381 + // Container(
  382 + // height: ScreenUtil().setWidth(2),
  383 + // color: MyColours.color_E7E7E7,
  384 + // ),
  385 + // VEmptyView(24),
  386 + // _select(
  387 + // '谁可以发放',
  388 + // '查看',
  389 + // () async {
  390 + // await NavigatorUtil.goCouponToPersonnalPage(
  391 + // context, widget.couponSunModel.uidList,
  392 + // onlyShow: true);
  393 + // },
  394 + // )
  395 + // ],
  396 + // )
  397 + // : SizedBox(),
  398 + // widget.couponSunModel.explain != null &&
  399 + // widget.couponSunModel.explain != ''
  400 + // ? Container(
  401 + // height: ScreenUtil().setWidth(2),
  402 + // color: MyColours.color_E7E7E7,
  403 + // )
  404 + // : SizedBox(),
  405 + // widget.couponSunModel.explain != null &&
  406 + // widget.couponSunModel.explain != ''
  407 + // ? VEmptyView(24)
  408 + // : SizedBox(),
  409 + if (model.orderRechargeByidSunModel.activity
  410 + .expDate !=
  411 + null)
  412 + Column(children: [
  413 + Container(
  414 + height: ScreenUtil().setWidth(2),
  415 + color: MyColours.color_E7E7E7,
  416 + ),
  417 + VEmptyView(24),
  418 + _item(
  419 + '使用限制',
  420 + model.orderRechargeByidSunModel.activity
  421 + .expDate.isNone
  422 + ? '无'
  423 + : model.orderRechargeByidSunModel
  424 + .activity.expDate.isBirthday
  425 + ? '会员生日当天'
  426 + : model.orderRechargeByidSunModel
  427 + .activity.expDate.isWeek
  428 + ? model
  429 + .orderRechargeByidSunModel
  430 + .activity
  431 + .expDate
  432 + .weekShow
  433 + : ''),
  434 + ]),
  435 + Container(
  436 + height: ScreenUtil().setWidth(2),
  437 + color: MyColours.color_E7E7E7,
  438 + ),
  439 + VEmptyView(24),
  440 + _item(
  441 + '券说明',
  442 + model.orderRechargeByidSunModel.activity
  443 + .explain ??
  444 + ''),
  445 +
  446 + Container(
  447 + height: ScreenUtil().setWidth(2),
  448 + color: MyColours.color_E7E7E7,
  449 + ),
  450 + // VEmptyView(24),
  451 + // _item('券状态',
  452 + // widget.couponSunModel.status == '1' ? '发放中' : '停用')
  453 + ],
  454 + ))),
  455 + ),
  456 + !canUse
  457 + ? Padding(
  458 + padding: EdgeInsets.only(bottom: w(58)),
  459 + child: Image.asset(
  460 + Utils.getImgPath(past ? 'past' : 'has_use'),
  461 + width: w(50),
151 ), 462 ),
152 - VEmptyView(24),  
153 - _item('券要求', '满200可用'),  
154 - Container(  
155 - height: ScreenUtil().setWidth(2),  
156 - color: MyColours.color_E7E7E7, 463 + )
  464 + : Container(
  465 + height: ScreenUtil().setWidth(91 * 2),
  466 + width: double.infinity,
  467 + padding: EdgeInsets.only(
  468 + top: ScreenUtil().setWidth(16 * 2),
  469 + bottom: ScreenUtil().setWidth(35 * 2),
  470 + left: ScreenUtil().setWidth(45 * 2),
  471 + right: ScreenUtil().setWidth(45 * 2),
157 ), 472 ),
158 - VEmptyView(24),  
159 - _item('有效期从', '2022-4-4'), //Utils.getDateStrFromJiekou(  
160 - // widget.couponSunModel.stime)  
161 - Container(  
162 - height: ScreenUtil().setWidth(2),  
163 - color: MyColours.color_E7E7E7, 473 + decoration: BoxDecoration(
  474 + color: MyColours.color_ffffff,
  475 + boxShadow: [
  476 + BoxShadow(
  477 + spreadRadius: ScreenUtil().setWidth(2),
  478 + color: Color.fromRGBO(0, 0, 0, 0.1),
  479 + offset: Offset(0, ScreenUtil().setWidth(-2)),
  480 + blurRadius: ScreenUtil().setWidth(8))
  481 + ],
  482 + borderRadius: BorderRadius.all(
  483 + Radius.circular(ScreenUtil().setWidth(16)),
  484 + ),
164 ), 485 ),
165 - VEmptyView(24),  
166 - _item('有效期至', '2022-4-4'),  
167 - // widget.couponSunModel.isType == '1'  
168 - // ? Column(  
169 - // crossAxisAlignment: CrossAxisAlignment.start,  
170 - // children: [  
171 - // Container(  
172 - // height: ScreenUtil().setWidth(2),  
173 - // color: MyColours.color_E7E7E7,  
174 - // ),  
175 - // VEmptyView(24),  
176 - // _item('创建人', widget.couponSunModel.uid),  
177 - // ],  
178 - // )  
179 - // : SizedBox(),  
180 - // widget.couponSunModel.isType == '1'  
181 - // ? Column(  
182 - // crossAxisAlignment: CrossAxisAlignment.start,  
183 - // children: [  
184 - // Container(  
185 - // height: ScreenUtil().setWidth(2),  
186 - // color: MyColours.color_E7E7E7,  
187 - // ),  
188 - // VEmptyView(24),  
189 - // _select(  
190 - // '谁可以发放',  
191 - // '查看',  
192 - // () async {  
193 - // await NavigatorUtil.goCouponToPersonnalPage(  
194 - // context, widget.couponSunModel.uidList,  
195 - // onlyShow: true);  
196 - // },  
197 - // )  
198 - // ],  
199 - // )  
200 - // : SizedBox(),  
201 - // widget.couponSunModel.explain != null &&  
202 - // widget.couponSunModel.explain != ''  
203 - // ? Container(  
204 - // height: ScreenUtil().setWidth(2),  
205 - // color: MyColours.color_E7E7E7,  
206 - // )  
207 - // : SizedBox(),  
208 - // widget.couponSunModel.explain != null &&  
209 - // widget.couponSunModel.explain != ''  
210 - // ? VEmptyView(24)  
211 - // : SizedBox(),  
212 - _item('券说明',  
213 - '最多最多最多最多最多最多最多最多最多最多最多最多最多最多最多最多最多最多最多最多最多最多最多最多最多'), 486 + child: RoundButton(
  487 + text: '核销使用',
  488 + height: ScreenUtil().setWidth(80),
  489 + radius: ScreenUtil().setWidth(14),
  490 + isBold: false,
  491 + fontSize: 28,
  492 + onPressed: () async {
  493 + // if (limit) {
  494 + // Utils.showToast('不在使用限制范围内,不可使用!');
  495 + // return;
  496 + // } else {
  497 + String limitStr = '';
  498 + if (limit) {
  499 + limitStr = '当前优惠券不在可用时间段内,';
  500 + } else if (couponProvider.orderRechargeByidSunModel
  501 + .activity.expDate.isBirthday) {
  502 + limitStr = '当前券只有生日可用,请核实后核销。';
  503 + }
  504 + DialogUtil.cupertinoAlertDialog(context,
  505 + textAlign: TextAlign.left,
  506 + content: '${limitStr}确定要核销当前优惠券吗?核销使用后,该券不能再次使用。',
  507 + rCallback: () async {
  508 + //确定核销
214 509
215 - Container(  
216 - height: ScreenUtil().setWidth(2),  
217 - color: MyColours.color_E7E7E7, 510 + bool success = await couponProvider
  511 + .setNewRechargeWriteOff(
  512 + context, {'id': widget.idstr});
  513 + if (success) {
  514 + //核销成功,刷新当前页面
  515 + _getOrderRechargeByid(
  516 + pageS: PageState.Success,
  517 + isShowLoading: true);
  518 + }
  519 + });
  520 + // }
  521 + },
218 ), 522 ),
219 - // VEmptyView(24),  
220 - // _item('券状态',  
221 - // widget.couponSunModel.status == '1' ? '发放中' : '停用')  
222 - ],  
223 - ))),  
224 - ),  
225 - true  
226 - ? Padding(  
227 - padding: EdgeInsets.only(bottom: w(58)),  
228 - child: Image.asset(  
229 - Utils.getImgPath('has_use'),  
230 - width: w(50),  
231 - ),  
232 - )  
233 - : Container(  
234 - height: ScreenUtil().setWidth(91 * 2),  
235 - width: double.infinity,  
236 - padding: EdgeInsets.only(  
237 - top: ScreenUtil().setWidth(16 * 2),  
238 - bottom: ScreenUtil().setWidth(35 * 2),  
239 - left: ScreenUtil().setWidth(45 * 2),  
240 - right: ScreenUtil().setWidth(45 * 2),  
241 - ),  
242 - decoration: BoxDecoration(  
243 - color: MyColours.color_ffffff,  
244 - boxShadow: [  
245 - BoxShadow(  
246 - spreadRadius: ScreenUtil().setWidth(2),  
247 - color: Color.fromRGBO(0, 0, 0, 0.1),  
248 - offset: Offset(0, ScreenUtil().setWidth(-2)),  
249 - blurRadius: ScreenUtil().setWidth(8))  
250 - ],  
251 - borderRadius: BorderRadius.all(  
252 - Radius.circular(ScreenUtil().setWidth(16)),  
253 - ),  
254 - ),  
255 - child: RoundButton(  
256 - text: '核销使用',  
257 - height: ScreenUtil().setWidth(80),  
258 - radius: ScreenUtil().setWidth(14),  
259 - isBold: false,  
260 - fontSize: 28,  
261 - onPressed: () async {  
262 - DialogUtil.cupertinoAlertDialog(context,  
263 - content: '确定要核销当前优惠券吗?核销使用后,该券不能再次使用。');  
264 - // "stime": fromDate == '点击选择'  
265 - // ? ""  
266 - // : '${DateUtil.getDateMsByTimeStr(fromDate) / 1000}',  
267 - // "etime": endDate == '点击选择'  
268 - // ? ''  
269 - // : '${DateUtil.getDateMsByTimeStr(endDate) / 1000}',  
270 - // UserModel userModel =  
271 - // Provider.of<UserModel>(context, listen: false);  
272 - // if (userModel.user.role_name == '管理员' ||  
273 - // userModel.user.role_name == '店长') {  
274 - // NavigatorUtil.goRechargeEditPage(context);  
275 - // } else {  
276 - // bool needRefresh =  
277 - // await NavigatorUtil.goCouponEditPage(context);  
278 - // print(needRefresh);  
279 - // if (needRefresh != null && needRefresh) {  
280 - // bus.emit('refresh_coupon_list_f');  
281 - // //刷新页面数据  
282 - // // _controller.callRefresh();  
283 - // // _couponNetworkData(tabController.index);  
284 - // }  
285 - // }  
286 - },  
287 - ),  
288 - )  
289 - ]),  
290 - ); 523 + )
  524 + ]);
  525 + }
  526 + }));
291 } 527 }
292 } 528 }
@@ -965,7 +965,15 @@ class _RechargeEditPageState extends State<RechargeEditPage> { @@ -965,7 +965,15 @@ class _RechargeEditPageState extends State<RechargeEditPage> {
965 return; 965 return;
966 } 966 }
967 if (priceminC.text.trim().length == 0) { 967 if (priceminC.text.trim().length == 0) {
968 - Utils.showToast('请输入充值金额门槛!'); 968 + Utils.showToast('请输入充值门槛金额!');
  969 + return;
  970 + }
  971 + if (!Utils.isNumeric(priceminC.text.trim())) {
  972 + Utils.showToast('充值门槛金额请输入数字!');
  973 + return;
  974 + }
  975 + if (double.parse(priceminC.text.trim()) <= 0) {
  976 + Utils.showToast('充值门槛金额需大于0!');
969 return; 977 return;
970 } 978 }
971 //优惠活动 979 //优惠活动
@@ -84,7 +84,7 @@ class _OrderPreviewPageState extends State<OrderPreviewPage> { @@ -84,7 +84,7 @@ class _OrderPreviewPageState extends State<OrderPreviewPage> {
84 ? '预计可以节约${marketingCenterProvider.rechargeList[index].rechargeList.price}元!' 84 ? '预计可以节约${marketingCenterProvider.rechargeList[index].rechargeList.price}元!'
85 : '预计可以享受大量优惠!'; 85 : '预计可以享受大量优惠!';
86 86
87 - String name = widget.detailEntity.rnameStr == null 87 + String name = widget.detailEntity.rnameStr != null
88 ? '${widget.detailEntity.rnameStr}:\n' 88 ? '${widget.detailEntity.rnameStr}:\n'
89 : ''; 89 : '';
90 90
@@ -731,6 +731,7 @@ class _OrderPreviewPageState extends State<OrderPreviewPage> { @@ -731,6 +731,7 @@ class _OrderPreviewPageState extends State<OrderPreviewPage> {
731 // widget.isSelect ? Colors.white : MyColours.color_199095, 731 // widget.isSelect ? Colors.white : MyColours.color_199095,
732 //输入文本的样式 732 //输入文本的样式
733 style: TextStyle( 733 style: TextStyle(
  734 + height: 1.3,
734 color: MyColours.color_999999, 735 color: MyColours.color_999999,
735 fontSize: font(12), 736 fontSize: font(12),
736 ), 737 ),
@@ -592,6 +592,7 @@ class _OrderSharePageState extends State<OrderSharePage> { @@ -592,6 +592,7 @@ class _OrderSharePageState extends State<OrderSharePage> {
592 child: Text( 592 child: Text(
593 widget.recommend, 593 widget.recommend,
594 style: TextStyle( 594 style: TextStyle(
  595 + height: 1.3,
595 color: MyColours.color_999999, 596 color: MyColours.color_999999,
596 fontSize: font(12), 597 fontSize: font(12),
597 ), 598 ),
@@ -12,6 +12,8 @@ import 'package:one_key/provider/user_model.dart'; @@ -12,6 +12,8 @@ import 'package:one_key/provider/user_model.dart';
12 import 'package:one_key/utils/utils.dart'; 12 import 'package:one_key/utils/utils.dart';
13 import 'package:provider/provider.dart'; 13 import 'package:provider/provider.dart';
14 14
  15 +import '../models/order_recharge_by_id_model.dart';
  16 +
15 class CouponProvider with ChangeNotifier { 17 class CouponProvider with ChangeNotifier {
16 List<bool> swichStateData = []; //优惠券是否启用 true启用 false停用 18 List<bool> swichStateData = []; //优惠券是否启用 true启用 false停用
17 PageState pageState = PageState.Loading; 19 PageState pageState = PageState.Loading;
@@ -32,6 +34,7 @@ class CouponProvider with ChangeNotifier { @@ -32,6 +34,7 @@ class CouponProvider with ChangeNotifier {
32 List<CouponSunModel> couponListSelect = []; //优惠券选择列表 34 List<CouponSunModel> couponListSelect = []; //优惠券选择列表
33 int index = 0; //选中的优惠券index 35 int index = 0; //选中的优惠券index
34 CouponSunModel couponSunModel; //优惠券详情 36 CouponSunModel couponSunModel; //优惠券详情
  37 + OrderRechargeByidSunModel orderRechargeByidSunModel; //核销详情页
35 38
36 CouponProvider() { 39 CouponProvider() {
37 // for (int i = 0; i < 20; i++) { 40 // for (int i = 0; i < 20; i++) {
@@ -556,6 +559,34 @@ class CouponProvider with ChangeNotifier { @@ -556,6 +559,34 @@ class CouponProvider with ChangeNotifier {
556 } 559 }
557 } 560 }
558 561
  562 + ///核销未使用优惠券
  563 + Future<dynamic> setNewRechargeWriteOff(
  564 + BuildContext context, Map<String, String> params,
  565 + {isShowLoading = true}) async {
  566 + BaseResp<dynamic> baseResp = await DioUtil()
  567 + .request<dynamic>(
  568 + context, Method.get, HttpUrl.set_new_recharge_write_off,
  569 + data: params, showLoading: isShowLoading)
  570 + .catchError((error) {
  571 + print(error.toString());
  572 + if (error is MyError) {}
  573 + return false;
  574 + });
  575 + if (baseResp.code == Constant.status_success) {
  576 + if (int.parse(baseResp.data.toString()) == 1) {
  577 + return true;
  578 + } else {
  579 + // Utils.showToast(baseResp.msg ?? "修改失败");
  580 + return false;
  581 + }
  582 + } else {
  583 + if (baseResp != null) {
  584 + // Utils.showToast(baseResp.msg ?? "");
  585 + }
  586 + return false;
  587 + }
  588 + }
  589 +
559 ///设置预定绑定活动ID 590 ///设置预定绑定活动ID
560 Future<dynamic> setActivityAsReserve( 591 Future<dynamic> setActivityAsReserve(
561 BuildContext context, Map<String, String> params, 592 BuildContext context, Map<String, String> params,
@@ -656,6 +687,35 @@ class CouponProvider with ChangeNotifier { @@ -656,6 +687,35 @@ class CouponProvider with ChangeNotifier {
656 } 687 }
657 } 688 }
658 689
  690 + ///获取订单中券详情
  691 + Future<bool> getOrderRechargeByid(
  692 + BuildContext context, Map<String, String> params,
  693 + {isShowLoading = true}) async {
  694 + BaseResp<dynamic> baseResp = await DioUtil()
  695 + .request<dynamic>(context, Method.get, HttpUrl.get_order_recharge_by_id,
  696 + data: params, showLoading: isShowLoading)
  697 + .catchError((error) {
  698 + print(error.toString());
  699 + if (error is MyError) {}
  700 +
  701 + return false;
  702 + });
  703 + if (baseResp.code == Constant.status_success) {
  704 + if (baseResp.data == null) {
  705 + return false;
  706 + } else {
  707 + orderRechargeByidSunModel =
  708 + OrderRechargeByidModel.fromJson(baseResp.responseData).data;
  709 + return true;
  710 + }
  711 + } else {
  712 + if (baseResp != null) {
  713 + Utils.showToast(baseResp.msg ?? "");
  714 + }
  715 + return false;
  716 + }
  717 + }
  718 +
659 ///预定安排微信发短信 719 ///预定安排微信发短信
660 Future<bool> sendSMSWxSendSms( 720 Future<bool> sendSMSWxSendSms(
661 BuildContext context, Map<String, String> params, 721 BuildContext context, Map<String, String> params,
@@ -1588,10 +1588,12 @@ class NavigatorUtil { @@ -1588,10 +1588,12 @@ class NavigatorUtil {
1588 1588
1589 ///核销使用 1589 ///核销使用
1590 static Future<dynamic> goVerificationCouponPage( 1590 static Future<dynamic> goVerificationCouponPage(
1591 - BuildContext context, { 1591 + BuildContext context,
  1592 + String idstr, {
1592 replace = false, 1593 replace = false,
1593 }) { 1594 }) {
1594 - return _navigateTo(context, "${Routes.verification_coupon_page}", 1595 + return _navigateTo(
  1596 + context, "${Routes.verification_coupon_page}?idstr=$idstr",
1595 replace: replace); 1597 replace: replace);
1596 } 1598 }
1597 1599
@@ -2580,13 +2580,13 @@ var verificationCouponPageHandle = new Handler( @@ -2580,13 +2580,13 @@ var verificationCouponPageHandle = new Handler(
2580 // json.decode( 2580 // json.decode(
2581 // FluroConvertUtils.fluroCnParamsDecode(params["detail"].first))); 2581 // FluroConvertUtils.fluroCnParamsDecode(params["detail"].first)));
2582 2582
2583 - // String selectIDs = params["selectIDs"].first; 2583 + String idstr = params["idstr"].first;
2584 // List<String> selectList = []; 2584 // List<String> selectList = [];
2585 // if (selectIDs.length > 0) { 2585 // if (selectIDs.length > 0) {
2586 // selectList = selectIDs.split(','); 2586 // selectList = selectIDs.split(',');
2587 // } 2587 // }
2588 return ChangeNotifierProvider<CouponProvider>( 2588 return ChangeNotifierProvider<CouponProvider>(
2589 - create: (_) => CouponProvider(), child: VerificationCouponPage()); 2589 + create: (_) => CouponProvider(), child: VerificationCouponPage(idstr:idstr));
2590 }); 2590 });
2591 2591
2592 ///充值优惠选择 2592 ///充值优惠选择
@@ -5923,7 +5923,6 @@ class DialogUtil { @@ -5923,7 +5923,6 @@ class DialogUtil {
5923 } 5923 }
5924 } 5924 }
5925 5925
5926 -  
5927 static Future cupertinoAlertDialogFeast(BuildContext context, 5926 static Future cupertinoAlertDialogFeast(BuildContext context,
5928 {String title = "", 5927 {String title = "",
5929 String content = "内容", 5928 String content = "内容",
@@ -6062,6 +6061,7 @@ class DialogUtil { @@ -6062,6 +6061,7 @@ class DialogUtil {
6062 bool isBoldContent = false, 6061 bool isBoldContent = false,
6063 Color contentColor = MyColours.color_99000000, 6062 Color contentColor = MyColours.color_99000000,
6064 VoidCallback lCallback, 6063 VoidCallback lCallback,
  6064 + TextAlign textAlign = TextAlign.center,
6065 VoidCallback rCallback}) { 6065 VoidCallback rCallback}) {
6066 showCupertinoDialog( 6066 showCupertinoDialog(
6067 context: context, 6067 context: context,
@@ -6075,6 +6075,7 @@ class DialogUtil { @@ -6075,6 +6075,7 @@ class DialogUtil {
6075 color: MyColours.color_E6000000)) 6075 color: MyColours.color_E6000000))
6076 : SizedBox(), 6076 : SizedBox(),
6077 content: Text(content, 6077 content: Text(content,
  6078 + textAlign:textAlign,
6078 style: TextStyle( 6079 style: TextStyle(
6079 fontWeight: 6080 fontWeight:
6080 isBoldContent ? FontWeight.bold : FontWeight.normal, 6081 isBoldContent ? FontWeight.bold : FontWeight.normal,
@@ -39,6 +39,11 @@ import 'package:image_cropper/image_cropper.dart'; @@ -39,6 +39,11 @@ import 'package:image_cropper/image_cropper.dart';
39 typedef BookTimeSetCallback = void Function(bool needChange); 39 typedef BookTimeSetCallback = void Function(bool needChange);
40 40
41 class Utils { 41 class Utils {
  42 + static bool cnIsNumber(String str) {
  43 + final reg = RegExp(r'^-?[0-9.]+$');
  44 + return reg.hasMatch(str);
  45 + }
  46 +
42 ///2023-03-11 二月二十 47 ///2023-03-11 二月二十
43 static String returnYMDandLunarCalendar(DateTime day, BuildContext context) { 48 static String returnYMDandLunarCalendar(DateTime day, BuildContext context) {
44 String date = 49 String date =