From 3dc3211a2ec411eb16e1a55c2b01b356ad5ef90b Mon Sep 17 00:00:00 2001 From: w-R <953969641@qq.com> Date: Mon, 14 Feb 2022 18:45:33 +0800 Subject: [PATCH] =?UTF-8?q?=E9=82=80=E8=AF=B7=E7=A0=81=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E6=9B=B4=E6=96=B0;=20=E6=A0=B8=E9=94=80=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E6=9B=B4=E6=96=B0;=20=E6=A0=B8=E9=94=80=E5=90=8E=E5=85=B3?= =?UTF-8?q?=E9=97=AD=E4=BA=8C=E7=BB=B4=E7=A0=81;=20=E7=A4=BE=E7=BE=A4?= =?UTF-8?q?=E5=90=88=E5=B9=B6=E6=9B=B4=E6=94=B9;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/community/community_child_page.dart | 4 +- lib/generated/intl/messages_zh_Hant_CN.dart | 2 +- lib/generated/intl/messages_zh_TW.dart | 2 +- lib/home/home_page.dart | 24 +++ lib/home/huixiang_brand_page.dart | 1 - lib/l10n/intl_zh_Hant_CN.arb | 2 +- lib/l10n/intl_zh_TW.arb | 2 +- lib/login/login_page.dart | 8 +- lib/mine/coupons_page.dart | 10 +- lib/mine/invitation_record.dart | 58 ++++--- lib/mine/mine_card_page.dart | 4 +- lib/mine/mine_view/mine_view.dart | 31 ++++ lib/mine/roll_center_page.dart | 2 +- lib/order/order_history_page.dart | 2 +- lib/order/write_off_page.dart | 66 ++++++-- lib/qr/qr_share.dart | 32 ++-- lib/retrofit/data/coupon_detail.dart | 120 ++++++++++++++ lib/retrofit/min_api.dart | 4 +- lib/retrofit/retrofit_api.dart | 13 +- lib/retrofit/retrofit_api.g.dart | 43 +++++ lib/settlement/settlement.dart | 150 ++++++++---------- .../activity_coupon_remarks.dart | 4 +- lib/view_widget/invite_success_dialog.dart | 2 +- lib/view_widget/new_coupon_widget.dart | 5 +- 24 files changed, 429 insertions(+), 162 deletions(-) create mode 100644 lib/retrofit/data/coupon_detail.dart diff --git a/lib/community/community_child_page.dart b/lib/community/community_child_page.dart index 5b0f021f..449d5701 100644 --- a/lib/community/community_child_page.dart +++ b/lib/community/community_child_page.dart @@ -143,7 +143,9 @@ class _CommunityChildPage extends State with AutomaticKeepAl "businessId": articles[position].id, "userId": userId, }, - ); + ).then((value) { + _onRefresh(); + }); }, ); }, diff --git a/lib/generated/intl/messages_zh_Hant_CN.dart b/lib/generated/intl/messages_zh_Hant_CN.dart index f3a037d6..c5161822 100644 --- a/lib/generated/intl/messages_zh_Hant_CN.dart +++ b/lib/generated/intl/messages_zh_Hant_CN.dart @@ -65,7 +65,7 @@ class MessageLookup extends MessageLookupByLibrary { static m22(zhe) => "全場${zhe}折"; - static m23(num) => "取膽號${num}"; + static m23(num) => "取單號${num}"; static m24(ren) => "¥${ren}/人"; diff --git a/lib/generated/intl/messages_zh_TW.dart b/lib/generated/intl/messages_zh_TW.dart index 738e14c7..2d174d30 100644 --- a/lib/generated/intl/messages_zh_TW.dart +++ b/lib/generated/intl/messages_zh_TW.dart @@ -65,7 +65,7 @@ class MessageLookup extends MessageLookupByLibrary { static m22(zhe) => "全場${zhe}折"; - static m23(num) => "取膽號${num}"; + static m23(num) => "取單號${num}"; static m24(ren) => "¥${ren}/人"; diff --git a/lib/home/home_page.dart b/lib/home/home_page.dart index cfa541fa..a7f5674d 100644 --- a/lib/home/home_page.dart +++ b/lib/home/home_page.dart @@ -1,8 +1,10 @@ import 'dart:convert'; + import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_swiper/flutter_swiper.dart'; import 'package:huixiang/generated/l10n.dart'; @@ -271,6 +273,24 @@ class _HomePage extends State with AutomaticKeepAliveClientMixin { EasyLoading.dismiss(); } + ///核销用户优惠券 + queryWiped(memberCouponId) async { + if (apiService == null) { + SharedPreferences value = await SharedPreferences.getInstance(); + apiService = ApiService( + Dio(), + context: context, + token: value.getString("token"), + ); + } + BaseData baseData = await apiService.wiped(memberCouponId); + if (baseData != null && baseData.isSuccess) { + SmartDialog.showToast("核销成功", alignment: Alignment.center); + } else { + SmartDialog.showToast(baseData.msg, alignment: Alignment.center); + } + } + _onRefresh(){ queryHome(); queryMsgStats(); @@ -483,6 +503,10 @@ class _HomePage extends State with AutomaticKeepAliveClientMixin { ///活动优惠券赠送弹窗 activityShowAlertDialog(result.toString()); return; + }if(result.toString().contains("type\":\"wiped")){ + ///核销券 + queryWiped(jsonDecode(result.toString())["memberCouponId"]); + return; } // String result = await scanner.scan(); Uri uri = Uri.parse(result); diff --git a/lib/home/huixiang_brand_page.dart b/lib/home/huixiang_brand_page.dart index 2595066d..22ec8ead 100644 --- a/lib/home/huixiang_brand_page.dart +++ b/lib/home/huixiang_brand_page.dart @@ -51,7 +51,6 @@ class _BrandPage extends State Dio(), context: context, token: value.getString('token'), - showLoading: false, ); BaseData baseData = diff --git a/lib/l10n/intl_zh_Hant_CN.arb b/lib/l10n/intl_zh_Hant_CN.arb index 811a8988..4df95fbc 100644 --- a/lib/l10n/intl_zh_Hant_CN.arb +++ b/lib/l10n/intl_zh_Hant_CN.arb @@ -338,7 +338,7 @@ "chakanwuliu": "查看物流", "zailaiyidan": "再來一單", "shanchudingdan": "刪除訂單", - "qudanhao": "取膽號{num}", + "qudanhao": "取單號{num}", "lingquchenggong": "領取成功", "dianwolingqu": "點我領取", "chengweidianpuzhuanshuhuiyuan": "成為專屬會員,享專屬權益", diff --git a/lib/l10n/intl_zh_TW.arb b/lib/l10n/intl_zh_TW.arb index 91303103..cbcc9430 100644 --- a/lib/l10n/intl_zh_TW.arb +++ b/lib/l10n/intl_zh_TW.arb @@ -338,7 +338,7 @@ "chakanwuliu": "查看物流", "zailaiyidan": "再來一單", "shanchudingdan": "刪除訂單", - "qudanhao": "取膽號{num}", + "qudanhao": "取單號{num}", "lingquchenggong": "領取成功", "dianwolingqu": "點我領取", "chengweidianpuzhuanshuhuiyuan": "成為專屬會員,享專屬權益", diff --git a/lib/login/login_page.dart b/lib/login/login_page.dart index 224f8a93..0560384a 100644 --- a/lib/login/login_page.dart +++ b/lib/login/login_page.dart @@ -706,7 +706,7 @@ class _MyLoginPageState extends State with TickerProviderStateMixin { ), ), Container( - height: 40.h, + height:35.h, width: MediaQuery.of(context).size.width - 80.h, // margin: EdgeInsets.only(top: 12.h), child: TextField( @@ -773,7 +773,7 @@ class _MyLoginPageState extends State with TickerProviderStateMixin { ), ), Container( - height: 40.h, + height:35.h, width: MediaQuery.of(context).size.width - 80.h, child: Row( mainAxisAlignment: MainAxisAlignment.end, @@ -923,7 +923,7 @@ class _MyLoginPageState extends State with TickerProviderStateMixin { ), ), Container( - height: 40.h, + height:35.h, width: MediaQuery.of(context).size.width - 80.h, child: TextField( style: TextStyle( @@ -949,7 +949,7 @@ class _MyLoginPageState extends State with TickerProviderStateMixin { ), ), textInputAction: TextInputAction.next, - inputFormatters: [LengthLimitingTextInputFormatter(11)], + inputFormatters: [LengthLimitingTextInputFormatter(6)], cursorColor: Colors.grey, maxLines: 1, ), diff --git a/lib/mine/coupons_page.dart b/lib/mine/coupons_page.dart index a0f3bc1e..1d89e3e3 100644 --- a/lib/mine/coupons_page.dart +++ b/lib/mine/coupons_page.dart @@ -1,3 +1,5 @@ +import 'dart:convert'; + import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -172,13 +174,15 @@ class _CouponsPage extends State { if (type == 1) { receiveCoupon(coupons[position].id); } else { - if (coupons[position].bizType == 5) { + if (coupons[position].bizType == 5 || coupons[position].bizType == 3) { Navigator.of(context).pushNamed( '/router/write_off_page', arguments: { "couponId": coupons[position].id, - "coupon": coupons[position].toJson(), - }); + "coupon": jsonEncode(coupons[position]), + }).then((value) { + _onRefresh(); + }); } else { showStoreSelector(coupons[position].storeList); } diff --git a/lib/mine/invitation_record.dart b/lib/mine/invitation_record.dart index c77a0b23..359a2698 100644 --- a/lib/mine/invitation_record.dart +++ b/lib/mine/invitation_record.dart @@ -13,6 +13,9 @@ import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/utils/flutter_utils.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:huixiang/view_widget/classic_header.dart'; +import 'package:huixiang/view_widget/my_footer.dart'; +import 'package:huixiang/view_widget/no_data_view.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -27,6 +30,7 @@ class _InvitationRecord extends State with AutomaticKeepAliveClientMixin { ApiService apiService; RefreshController _refreshController = RefreshController(); + ScrollController scrollController = ScrollController(); List invitationList = []; UserInfo userInfo; int pageNum = 1; @@ -132,31 +136,32 @@ class _InvitationRecord extends State right: 16.w), child: Column( children: [ + GestureDetector( - onTap: (){ - Navigator.of(context).pop(); - }, - child:Padding( - padding: EdgeInsets.only(top: 15.h, bottom: 30.h), - child: Row( - children: [ - Icon( - Icons.arrow_back_ios, - size: 24, - ), - SizedBox( - width: 1.w, - ), - Text( - "我的邀请记录", - style: TextStyle( - fontSize: 18.sp, - color: Color(0xFF000000), - fontWeight: MyFontWeight.semi_bold, + onTap: (){ + Navigator.of(context).pop(); + }, + child:Padding( + padding: EdgeInsets.only(top: 15.h, bottom: 30.h), + child: Row( + children: [ + Icon( + Icons.arrow_back_ios, + size: 24, + ), + SizedBox( + width: 1.w, + ), + Text( + "我的邀请记录", + style: TextStyle( + fontSize: 18.sp, + color: Color(0xFF000000), + fontWeight: MyFontWeight.semi_bold, + ), ), - ), - ], - )) + ], + )) ), Container( margin: EdgeInsets.only(bottom: 16.h), @@ -298,6 +303,13 @@ class _InvitationRecord extends State ], ), Expanded(child: + (invitationList.length == null || invitationList.length == 0) + ? NoDataView( + isShowBtn: false, + text:"还没有邀请记录哦~", + fontSize: 16.sp, + margin: EdgeInsets.only(top: 120.h), + ): ListView.builder( itemCount:invitationList.length, shrinkWrap: true, diff --git a/lib/mine/mine_card_page.dart b/lib/mine/mine_card_page.dart index 03ba185d..8317d904 100644 --- a/lib/mine/mine_card_page.dart +++ b/lib/mine/mine_card_page.dart @@ -46,13 +46,13 @@ class _MineCardPage extends State indicatorSize: TabBarIndicatorSize.label, //指示器与文字等宽 tabs: [ - MyTab(text: S.of(context).huiyuanka), MyTab(text: S.of(context).quanbao), + MyTab(text: S.of(context).huiyuanka), ], ), ), body: TabBarView( - children: [VipCardPage(), CouponsPage()], + children: [CouponsPage(),VipCardPage(), ], ), ), ); diff --git a/lib/mine/mine_view/mine_view.dart b/lib/mine/mine_view/mine_view.dart index f7cbae28..d8012d70 100644 --- a/lib/mine/mine_view/mine_view.dart +++ b/lib/mine/mine_view/mine_view.dart @@ -1,7 +1,13 @@ +import 'dart:convert'; + +import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:huixiang/generated/l10n.dart'; +import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/user_info.dart'; +import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/activity_coupons.dart'; import 'package:huixiang/view_widget/custom_image.dart'; @@ -9,6 +15,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:huixiang/view_widget/login_tips_dialog.dart'; import 'package:huixiang/view_widget/request_permission.dart'; import 'package:permission_handler/permission_handler.dart'; +import 'package:shared_preferences/shared_preferences.dart'; // import 'package:qrscan/qrscan.dart' as scanner; class MineView extends StatefulWidget { @@ -25,6 +32,26 @@ class MineView extends StatefulWidget { } class _MineView extends State { + ApiService apiService; + + ///核销用户优惠券 + queryWiped(memberCouponId) async { + if (apiService == null) { + SharedPreferences value = await SharedPreferences.getInstance(); + apiService = ApiService( + Dio(), + context: context, + token: value.getString("token"), + ); + } + BaseData baseData = await apiService.wiped(memberCouponId); + if (baseData != null && baseData.isSuccess) { + SmartDialog.showToast("核销成功", alignment: Alignment.center); + } else { + SmartDialog.showToast(baseData.msg, alignment: Alignment.center); + } + } + @override Widget build(BuildContext context) { return Column( @@ -98,6 +125,10 @@ class _MineView extends State { ///活动优惠券赠送弹窗 activityShowAlertDialog(result.toString()); return; + }if(result.toString().contains("type\":\"wiped")){ + ///核销券 + queryWiped(jsonDecode(result.toString())["memberCouponId"]); + return; } // String result = await scanner.scan(); Uri uri = Uri.parse(result); diff --git a/lib/mine/roll_center_page.dart b/lib/mine/roll_center_page.dart index 2c46d765..d4a5eccc 100644 --- a/lib/mine/roll_center_page.dart +++ b/lib/mine/roll_center_page.dart @@ -128,7 +128,7 @@ class _RollCenterPage extends State { if (type == 1) { receiveCoupon(coupons[position].id); } else { - if (coupons[position].bizType == 5) { + if (coupons[position].bizType == 5 || coupons[position].bizType == 3) { Navigator.of(context).pushNamed( '/router/write_off_page', arguments: { diff --git a/lib/order/order_history_page.dart b/lib/order/order_history_page.dart index 0e2dc417..a002c5df 100644 --- a/lib/order/order_history_page.dart +++ b/lib/order/order_history_page.dart @@ -200,7 +200,7 @@ class _OrderHistoryList extends State } else { current += 1; } - setState(() {}); + // setState(() {}); } else { refreshController.refreshFailed(); refreshController.loadFailed(); diff --git a/lib/order/write_off_page.dart b/lib/order/write_off_page.dart index 6325dcb3..1b3ecc8c 100644 --- a/lib/order/write_off_page.dart +++ b/lib/order/write_off_page.dart @@ -1,12 +1,20 @@ +import 'dart:convert'; + import 'package:barcode_widget/barcode_widget.dart'; +import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:huixiang/generated/l10n.dart'; +import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/coupon.dart'; +import 'package:huixiang/retrofit/data/coupon_detail.dart'; +import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:huixiang/view_widget/separator.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:qr_flutter/qr_flutter.dart'; +import 'package:shared_preferences/shared_preferences.dart'; class WriteOffPage extends StatefulWidget { final arguments; @@ -20,14 +28,44 @@ class WriteOffPage extends StatefulWidget { } class _WriteOffPage extends State { - Coupon coupon; + dynamic coupon; + ApiService apiService; + CouponDetail queryCoupon; @override void initState() { super.initState(); - coupon = Coupon.fromJson(widget.arguments["coupon"]); + coupon = jsonDecode(widget.arguments["coupon"]); if (mounted) setState(() {}); + + queryCouponDetail(coupon["memberCouponId"]); + } + + ///查询核销券状态/查询优惠券详情 + queryCouponDetail(memberCouponId) async { + if (apiService == null) { + SharedPreferences value = await SharedPreferences.getInstance(); + apiService = ApiService( + Dio(), + context: context, + token: value.getString("token"), + ); + } + BaseData baseData = await apiService.couponDetail(memberCouponId); + if (baseData != null && baseData.isSuccess) { + setState(() { + queryCoupon = baseData.data; + if(queryCoupon.status==2){ + Navigator.of(context).pop(true); + } + else Future.delayed(Duration(seconds: 1), () { + queryCouponDetail(coupon["memberCouponId"]); + }); + }); + } else { + SmartDialog.showToast(baseData.msg, alignment: Alignment.center); + } } @override @@ -61,7 +99,7 @@ class _WriteOffPage extends State { child: Column( children: [ Text( - coupon != null ? coupon.couponName : "", + coupon != null ? coupon["couponName"] : "", style: TextStyle( fontSize: 16.sp, fontWeight: FontWeight.bold, @@ -71,8 +109,8 @@ class _WriteOffPage extends State { height: 8.h, ), Text( - (coupon.useStartTime == null || coupon.useEndTime == null) ? "" : S.of(context).youxiaoqi( - "${coupon.useStartTime.replaceAll("-", ".").split(" ")[0]}-${coupon.useEndTime.replaceAll("-", ".").split(" ")[0]}"), + (coupon["useStartTime"] == null || coupon["useEndTime"] == null) ? "" : S.of(context).youxiaoqi( + "${coupon["useStartTime"].replaceAll("-", ".").split(" ")[0]}-${coupon["useEndTime"].replaceAll("-", ".").split(" ")[0]}"), style: TextStyle( fontSize: 12.sp, color: Color(0xFF353535), @@ -103,11 +141,11 @@ class _WriteOffPage extends State { children: [ Text( coupon != null - ? "${coupon.id.substring(0, 4)} " - "${coupon.id.substring(4, 8)} " - "${coupon.id.substring(8, 12)} " - "${coupon.id.substring(12, 16)} " - "${coupon.id.substring(16, coupon.id.length)}" + ? "${coupon["memberCouponId"].substring(0, 4)} " + "${coupon["memberCouponId"].substring(4, 8)} " + "${coupon["memberCouponId"].substring(8, 12)} " + "${coupon["memberCouponId"].substring(12, 16)} " + "${coupon["memberCouponId"].substring(16, coupon["memberCouponId"].length)}" : "", style: TextStyle( fontSize: 14.sp, @@ -115,12 +153,12 @@ class _WriteOffPage extends State { ? 10 : (MediaQuery.of(context).size.width - 64.w) / - (((coupon.id.length) * 4)), + (((coupon["memberCouponId"].length) * 4)), letterSpacing: coupon == null ? 8 : (MediaQuery.of(context).size.width - 64.w) / - (((coupon.id.length) * 4)), + (((coupon["memberCouponId"].length) * 4)), fontWeight: MyFontWeight.semi_bold, color: Color(0xFF353535), ), @@ -130,7 +168,7 @@ class _WriteOffPage extends State { ), BarcodeWidget( barcode: Barcode.code128(useCode128C: true), - data: coupon != null ? coupon.id : "", + data: coupon != null ? coupon["memberCouponId"] : "", height: 72.h, color: Colors.black, drawText: false, @@ -139,7 +177,7 @@ class _WriteOffPage extends State { height: 16.h, ), Expanded(child: QrImage( - data: coupon != null ? coupon.id : "", + data: "{\"type\":\"wiped\",\"memberCouponId\":\"${coupon["memberCouponId"]}\"}", version: QrVersions.auto, size: 200.w, gapless: true, diff --git a/lib/qr/qr_share.dart b/lib/qr/qr_share.dart index 09d32323..66bb89ce 100644 --- a/lib/qr/qr_share.dart +++ b/lib/qr/qr_share.dart @@ -29,7 +29,8 @@ class _QrSharePage extends State { SharedPreferences.getInstance().then((value) { if (value.getString('user') != null && value.getString('user') != "") { - phone = UserInfo.fromJson(jsonDecode(value.getString('user'))).inviteCode; + phone = + UserInfo.fromJson(jsonDecode(value.getString('user'))).inviteCode; setState(() {}); } }); @@ -114,21 +115,20 @@ class _QrSharePage extends State { children: [ shareTypeTitle(S.of(context).wodeyaoqingma), Container( - margin: EdgeInsets.only(left: 16.w, right: 24.w), - child: GestureDetector( - child: Text( - // S.of(context).baocunsaoma, - phone, - textAlign: TextAlign.center, - style: TextStyle( - color: Color(0xFF2E3552), - fontSize: 40.sp, - fontWeight: MyFontWeight.semi_bold, + margin: EdgeInsets.only(left: 16.w, right: 24.w), + child: GestureDetector( + child: SelectableText( + // S.of(context).baocunsaoma, + phone, + textAlign: TextAlign.center, + style: TextStyle( + color: Color(0xFF2E3552), + fontSize: 40.sp, + fontWeight: MyFontWeight.semi_bold, + ), ), - ), - onTap: this.copy(phone), - ) - ), + onTap: this.copy(phone), + )), // Container( // width: 152.w, // height: 152.w, @@ -228,7 +228,7 @@ class _QrSharePage extends State { } copy(String phone) { - print("..."+phone); + print("..." + phone); Clipboard.setData(ClipboardData(text: phone)); } } diff --git a/lib/retrofit/data/coupon_detail.dart b/lib/retrofit/data/coupon_detail.dart new file mode 100644 index 00000000..3badc924 --- /dev/null +++ b/lib/retrofit/data/coupon_detail.dart @@ -0,0 +1,120 @@ +/// id : "1493050078934335488" +/// createTime : "2022-02-14 10:30:53" +/// createUser : "1307141152536788992" +/// updateTime : "2022-02-14 10:30:53" +/// updateUser : "1307141152536788992" +/// mid : "1486626867212451840" +/// couponId : "1435510333782360064" +/// receiveTime : "2022-02-14 10:30:53" +/// useTime : null +/// useTimeStart : "2022-02-14 10:30:53" +/// useTimeEnd : "2022-02-15 10:30:53" +/// status : 1 +/// isDeleted : false +/// tenantCode : "1166" +/// couponCode : "" + +class CouponDetail { + CouponDetail({ + String id, + String createTime, + String createUser, + String updateTime, + String updateUser, + String mid, + String couponId, + String receiveTime, + dynamic useTime, + String useTimeStart, + String useTimeEnd, + int status, + bool isDeleted, + String tenantCode, + String couponCode,}){ + _id = id; + _createTime = createTime; + _createUser = createUser; + _updateTime = updateTime; + _updateUser = updateUser; + _mid = mid; + _couponId = couponId; + _receiveTime = receiveTime; + _useTime = useTime; + _useTimeStart = useTimeStart; + _useTimeEnd = useTimeEnd; + _status = status; + _isDeleted = isDeleted; + _tenantCode = tenantCode; + _couponCode = couponCode; +} + + CouponDetail.fromJson(dynamic json) { + _id = json['id']; + _createTime = json['createTime']; + _createUser = json['createUser']; + _updateTime = json['updateTime']; + _updateUser = json['updateUser']; + _mid = json['mid']; + _couponId = json['couponId']; + _receiveTime = json['receiveTime']; + _useTime = json['useTime']; + _useTimeStart = json['useTimeStart']; + _useTimeEnd = json['useTimeEnd']; + _status = json['status']; + _isDeleted = json['isDeleted']; + _tenantCode = json['tenantCode']; + _couponCode = json['couponCode']; + } + String _id; + String _createTime; + String _createUser; + String _updateTime; + String _updateUser; + String _mid; + String _couponId; + String _receiveTime; + dynamic _useTime; + String _useTimeStart; + String _useTimeEnd; + int _status; + bool _isDeleted; + String _tenantCode; + String _couponCode; + + String get id => _id; + String get createTime => _createTime; + String get createUser => _createUser; + String get updateTime => _updateTime; + String get updateUser => _updateUser; + String get mid => _mid; + String get couponId => _couponId; + String get receiveTime => _receiveTime; + dynamic get useTime => _useTime; + String get useTimeStart => _useTimeStart; + String get useTimeEnd => _useTimeEnd; + int get status => _status; + bool get isDeleted => _isDeleted; + String get tenantCode => _tenantCode; + String get couponCode => _couponCode; + + Map toJson() { + final map = {}; + map['id'] = _id; + map['createTime'] = _createTime; + map['createUser'] = _createUser; + map['updateTime'] = _updateTime; + map['updateUser'] = _updateUser; + map['mid'] = _mid; + map['couponId'] = _couponId; + map['receiveTime'] = _receiveTime; + map['useTime'] = _useTime; + map['useTimeStart'] = _useTimeStart; + map['useTimeEnd'] = _useTimeEnd; + map['status'] = _status; + map['isDeleted'] = _isDeleted; + map['tenantCode'] = _tenantCode; + map['couponCode'] = _couponCode; + return map; + } + +} \ No newline at end of file diff --git a/lib/retrofit/min_api.dart b/lib/retrofit/min_api.dart index ec58b78d..84461685 100644 --- a/lib/retrofit/min_api.dart +++ b/lib/retrofit/min_api.dart @@ -61,8 +61,8 @@ abstract class MinApiService { } headers["Environment"] = "app"; dio.options = BaseOptions( - connectTimeout: 60000, - receiveTimeout: 60000, + connectTimeout: 15000, + receiveTimeout: 15000, headers: headers, responseType: ResponseType.json, ); diff --git a/lib/retrofit/retrofit_api.dart b/lib/retrofit/retrofit_api.dart index 5c404dc9..0f0d7451 100644 --- a/lib/retrofit/retrofit_api.dart +++ b/lib/retrofit/retrofit_api.dart @@ -25,6 +25,7 @@ import 'data/brand_data.dart'; import 'data/category_select_list.dart'; import 'data/chapter.dart'; import 'data/collect_class_list.dart'; +import 'data/coupon_detail.dart'; import 'data/course_details.dart'; import 'data/course_list.dart'; import 'data/exchange_order.dart'; @@ -87,8 +88,8 @@ abstract class ApiService { headers["Environment"] = "app"; } dio.options = BaseOptions( - connectTimeout: 60000, - receiveTimeout: 60000, + connectTimeout: 20000, + receiveTimeout: 20000, headers: headers, responseType: ResponseType.json, ); @@ -490,4 +491,12 @@ abstract class ApiService { @POST("/member/inviteMemberList") Future>> inviteMemberList(@Body() Map map); + ///核销优惠券 + @GET("/coupon/wiped/{memberCouponId}") + Future wiped(@Path("memberCouponId") String memberCouponId); + + ///查询优惠券详情 + @GET("coupon/detail/") + Future> couponDetail(@Path("") String memberCouponId); + } diff --git a/lib/retrofit/retrofit_api.g.dart b/lib/retrofit/retrofit_api.g.dart index fd2b2232..beaea183 100644 --- a/lib/retrofit/retrofit_api.g.dart +++ b/lib/retrofit/retrofit_api.g.dart @@ -1827,5 +1827,48 @@ class _ApiService implements ApiService { return value; } + @override + Future> wiped(memberCouponId) async { + ArgumentError.checkNotNull(memberCouponId, 'memberCouponId'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + '/coupon/wiped/$memberCouponId', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json as dynamic, + ); + return value; + } + + @override + Future> couponDetail(memberCouponId) async { + ArgumentError.checkNotNull(memberCouponId, 'memberCouponId'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + 'coupon/detail/$memberCouponId', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => CouponDetail.fromJson(json), + ); + return value; + } } diff --git a/lib/settlement/settlement.dart b/lib/settlement/settlement.dart index 4b7331e1..28c40564 100644 --- a/lib/settlement/settlement.dart +++ b/lib/settlement/settlement.dart @@ -20,7 +20,6 @@ import 'package:huixiang/retrofit/data/wx_pay.dart'; import 'package:huixiang/retrofit/min_api.dart'; import 'package:huixiang/settlement/settlement_view/activity_coupon_remarks.dart'; import 'package:huixiang/settlement/settlement_view/distribution.dart'; -import 'package:huixiang/settlement/settlement_view/edit_phone.dart'; import 'package:huixiang/settlement/settlement_view/pay_method.dart'; import 'package:huixiang/settlement/settlement_view/settlement_activity.dart'; import 'package:huixiang/settlement/settlement_view/settlement_coupon.dart'; @@ -53,7 +52,7 @@ class _Settlement extends State { SettleOrderInfo settleOrderInfo; MinOrderInfo minOrderInfo; int selectedBtn = 0; - String remakers = "口味、面包硬度等"; + String remakers = ""; String parentCode = ""; String parentId = ""; int payChannel = 4; @@ -74,8 +73,8 @@ class _Settlement extends State { parentId = widget.arguments["parentId"] ?? ""; storeInfo = widget.arguments["storeInfo"]; numberOfPeople = widget.arguments["numberOfPeople"] ?? 0; - promotions=widget.arguments["pName"]??""; - coupons=widget.arguments["cName"]??""; + promotions = widget.arguments["pName"] ?? ""; + coupons = widget.arguments["cName"] ?? ""; if (tableId == 0) { placeOrder = true; } @@ -84,14 +83,13 @@ class _Settlement extends State { String minToken = value.getString("minToken"); String tenant = value.getString("tenant"); String storeId = value.getString("storeId"); - minService = MinApiService( - Dio(), - context: context, - token: minToken, - tenant: tenant, - storeId: storeId, - ); - if(promotions != null && promotions != "" || tableId <=0){ + minService = MinApiService(Dio(), + context: context, + token: minToken, + tenant: tenant, + storeId: storeId, + showLoading: true); + if (promotions != null && promotions != "" || tableId <= 0) { queryOrderInfo( address != null ? address.id : null, selectedBtn, @@ -99,7 +97,7 @@ class _Settlement extends State { 0, widget.arguments["pid"], ); - }else if(coupons != null && coupons != "" || tableId <=0){ + } else if (coupons != null && coupons != "" || tableId <= 0) { queryOrderInfo( address != null ? address.id : null, selectedBtn, @@ -107,8 +105,7 @@ class _Settlement extends State { 0, null, ); - } - else + } else queryOrderInfo(null, selectedBtn, null, 0, null); }); @@ -142,7 +139,6 @@ class _Settlement extends State { queryOrderDetails(parentId); } }); - } } @@ -215,13 +211,12 @@ class _Settlement extends State { ///选择收货地址 selectedAddress(String addId) async { BaseData> baseDate = - await minService.queryAddress().catchError((error) {}); + await minService.queryAddress().catchError((error) {}); if (baseDate != null && baseDate.isSuccess) { setState(() { baseDate.data.forEach((element) { - if(element.id == addId) - address = element; + if (element.id == addId) address = element; }); }); @@ -259,9 +254,13 @@ class _Settlement extends State { placeOrderFirst.payChannel = payChannel; placeOrderFirst.promotionInfoDTO = PromotionInfoDTOBean(); placeOrderFirst.promotionInfoDTO.promotionId = - (promotion != null && tableId <= 0) ? promotion.id : widget.arguments["pid"]??""; + (promotion != null && tableId <= 0) + ? promotion.id + : widget.arguments["pid"] ?? ""; placeOrderFirst.promotionInfoDTO.couponId = - (couponListBean != null && tableId <= 0) ? couponListBean.id : widget.arguments["cid"]??""; + (couponListBean != null && tableId <= 0) + ? couponListBean.id + : widget.arguments["cid"] ?? ""; placeOrderFirst.recMobile = (mobile == null || mobile == "") ? mobile : storeInfo.headMobile; placeOrderFirst.shoppingCartSkuItemList = settleOrderInfo.orderProductList; @@ -282,10 +281,8 @@ class _Settlement extends State { placeOrder = true; this.downOrder = baseData.data; querySettlement(); - } - else{ - SmartDialog.showToast(baseData.msg, - alignment: Alignment.center); + } else { + SmartDialog.showToast(baseData.msg, alignment: Alignment.center); } } else { ///火锅店下单, 等待结算 @@ -342,7 +339,7 @@ class _Settlement extends State { BaseData baseData = await minService .settlementWx(placeOrderFirst.toJson()) .catchError((error) { - print(error); + print(error); }); if (baseData != null && baseData.isSuccess) { WxPay wxPay = baseData.data; @@ -361,13 +358,12 @@ class _Settlement extends State { sign: wxPay.sign, ); } - } - else { + } else { BaseData baseData = await minService .settlementApi(placeOrderFirst.toJson()) .catchError((error) { print(error); - }); + }); if (baseData != null && baseData.isSuccess) { toOrderDetails(placeOrderFirst.id); } else { @@ -429,26 +425,15 @@ class _Settlement extends State { child: Container( child: Column( children: [ - DistributionMode( - (addressId, - isTake, - memberCouponId, - orderId, - promotionId){ - setState(() { - this.selectedBtn = 0; - }); - queryOrderInfo(addressId, - isTake, - memberCouponId, - orderId, - promotionId); - }, - queryAddress, - storeInfo, - address, - selectedAddress - ), + DistributionMode((addressId, isTake, + memberCouponId, orderId, promotionId) { + setState(() { + this.selectedBtn = 0; + }); + queryOrderInfo(addressId, isTake, + memberCouponId, orderId, promotionId); + }, queryAddress, storeInfo, address, + selectedAddress), SizedBox( height: 16, @@ -470,24 +455,26 @@ class _Settlement extends State { ///优惠券/备注/会员优惠金额 ActivityCouponRemarks( - couponCart, - activityCart, - settleOrderInfo, - coupons, - promotions, - couponCount(), - placeOrder, - remakers, () { - Navigator.of(context).pushNamed( - '/router/edit_remarks_page', - arguments: {}, - ).then((value) => { - setState(() { - if (value != null) remakers = value; - }) - }); - }, - tableId,), + couponCart, + activityCart, + settleOrderInfo, + coupons, + promotions, + couponCount(), + placeOrder, + remakers, + () { + Navigator.of(context).pushNamed( + '/router/edit_remarks_page', + arguments: {}, + ).then((value) => { + setState(() { + if (value != null) remakers = value; + }) + }); + }, + tableId, + ), if (placeOrder) @@ -598,13 +585,13 @@ class _Settlement extends State { this.couponListBean = couponBean; coupons = couponListBean.promotionName; promotions = ""; - queryOrderInfo( - address != null ? address.id : null, - selectedBtn, - couponListBean != null ? couponListBean.id : null, - 0, - null, - ); + queryOrderInfo( + address != null ? address.id : null, + selectedBtn, + couponListBean != null ? couponListBean.id : null, + 0, + null, + ); } } @@ -622,14 +609,13 @@ class _Settlement extends State { this.promotion = pro; promotions = promotion.name; coupons = ""; - queryOrderInfo( - address != null ? address.id : null, - selectedBtn, - null, - 0, - promotion != null ? promotion.id : null, - ); - + queryOrderInfo( + address != null ? address.id : null, + selectedBtn, + null, + 0, + promotion != null ? promotion.id : null, + ); } } } diff --git a/lib/settlement/settlement_view/activity_coupon_remarks.dart b/lib/settlement/settlement_view/activity_coupon_remarks.dart index 657d8a53..2eab3dbf 100644 --- a/lib/settlement/settlement_view/activity_coupon_remarks.dart +++ b/lib/settlement/settlement_view/activity_coupon_remarks.dart @@ -200,11 +200,11 @@ class _ActivityCouponRemarks extends State { ), Expanded( child: Text( - widget.remark, + widget.remark != ""? widget.remark:"口味、面包硬度等", textAlign: TextAlign.end, style: TextStyle( fontSize: 14.sp, - color: Color(0xFF353535), + color: Color(0xFFA29E9E), fontWeight: MyFontWeight.semi_bold, ), ), diff --git a/lib/view_widget/invite_success_dialog.dart b/lib/view_widget/invite_success_dialog.dart index d3ed9309..a1f8f722 100644 --- a/lib/view_widget/invite_success_dialog.dart +++ b/lib/view_widget/invite_success_dialog.dart @@ -64,7 +64,7 @@ class _InviteSuccessDialog extends State { textAlign: TextAlign.center, text: TextSpan( text: - "通过${widget.invite.substring(0, 3)}****${widget.invite.substring(7, 11)}的邀请码完成邀请,获得", + "通过${widget.invite}的邀请码完成邀请,获得", style: TextStyle( color: Color(0xFF1A1A1A), fontSize: 14.sp, diff --git a/lib/view_widget/new_coupon_widget.dart b/lib/view_widget/new_coupon_widget.dart index 98a382c0..b381c0f8 100644 --- a/lib/view_widget/new_coupon_widget.dart +++ b/lib/view_widget/new_coupon_widget.dart @@ -254,8 +254,7 @@ class NewCouponWidget extends StatelessWidget { ), Text( S.of(context).manyuankeyong(coupon != null - ? double.tryParse("${coupon.fullAmount}" ?? "0") - .toInt() + ? ("${coupon.fullAmount}" ?? "0") .toString() : ""), style: TextStyle( @@ -436,7 +435,7 @@ class NewCouponWidget extends StatelessWidget { color: Color(0xFF32A060), ), child: Text( - (coupon.bizType == 5) + (coupon.bizType == 5 || coupon.bizType == 3) ? S.of(context).quhexiao : S.of(context).qushiyong, style: TextStyle(