diff --git a/assets/image/2x/ion_vip_recharge.webp b/assets/image/2x/icon_vip_recharge.webp similarity index 100% rename from assets/image/2x/ion_vip_recharge.webp rename to assets/image/2x/icon_vip_recharge.webp diff --git a/assets/image/3x/ion_vip_recharge.webp b/assets/image/3x/icon_vip_recharge.webp similarity index 100% rename from assets/image/3x/ion_vip_recharge.webp rename to assets/image/3x/icon_vip_recharge.webp diff --git a/assets/image/ion_vip_recharge.webp b/assets/image/icon_vip_recharge.webp similarity index 100% rename from assets/image/ion_vip_recharge.webp rename to assets/image/icon_vip_recharge.webp diff --git a/lib/business_system/date_select/custom_page.dart b/lib/business_system/date_select/custom_page.dart index f13fa5d1..1d10d4b0 100644 --- a/lib/business_system/date_select/custom_page.dart +++ b/lib/business_system/date_select/custom_page.dart @@ -62,10 +62,11 @@ class _CustomPage extends State{ bottom: 0, child: SfDateRangePicker( onSelectionChanged: _onSelectionChanged, + maxDate: DateTime.now(), selectionMode: DateRangePickerSelectionMode.range, initialSelectedRange: PickerDateRange( DateTime.now().subtract(const Duration(days: 4)), - DateTime.now().add(const Duration(days: 3))), + DateTime.now().add(const Duration(days: 3)),), startRangeSelectionColor: Color(0xFF30415B), endRangeSelectionColor: Color(0xFF30415B), todayHighlightColor: Color(0xFF30415B), diff --git a/lib/business_system/date_select/day_report_page.dart b/lib/business_system/date_select/day_report_page.dart index 008e3b9e..81d59a5f 100644 --- a/lib/business_system/date_select/day_report_page.dart +++ b/lib/business_system/date_select/day_report_page.dart @@ -69,6 +69,7 @@ class _DayReportPage extends State{ bottom: 0, child: SfDateRangePicker( onSelectionChanged: _onSelectionChanged, + maxDate: DateTime.now(), selectionMode: DateRangePickerSelectionMode.single, selectionColor: Color(0xFF30415B), initialSelectedRange: PickerDateRange( diff --git a/lib/business_system/date_select/monthly_report_page.dart b/lib/business_system/date_select/monthly_report_page.dart index 5a997e1c..568633bc 100644 --- a/lib/business_system/date_select/monthly_report_page.dart +++ b/lib/business_system/date_select/monthly_report_page.dart @@ -55,6 +55,7 @@ class _MonthlyReportPage extends State{ bottom: 0, child: SfDateRangePicker( onSelectionChanged: _onSelectionChanged, + maxDate: DateTime.now(), selectionMode: DateRangePickerSelectionMode.single, view: DateRangePickerView.year, controller: _controller, diff --git a/lib/business_system/date_select/week_report_page.dart b/lib/business_system/date_select/week_report_page.dart index e9041873..a3659f07 100644 --- a/lib/business_system/date_select/week_report_page.dart +++ b/lib/business_system/date_select/week_report_page.dart @@ -78,7 +78,8 @@ class _WeekReportPage extends State{ onSelectionChanged: _onSelectionChanged, minDate: DateTime.now().subtract(const Duration(days: 361)), controller: _controller, // 添加控制器 - maxDate: DateTime.now().add(Duration(days: 365)), + // maxDate: DateTime.now().add(Duration(days: 365)), + maxDate: DateTime.now(), selectionMode: DateRangePickerSelectionMode.range, startRangeSelectionColor: Color(0xFF30415B), endRangeSelectionColor: Color(0xFF30415B), diff --git a/lib/business_system/home/business_home_page.dart b/lib/business_system/home/business_home_page.dart index 532d77fa..0b1ac543 100644 --- a/lib/business_system/home/business_home_page.dart +++ b/lib/business_system/home/business_home_page.dart @@ -2,7 +2,9 @@ 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:huixiang/business_system/home/home_view/home_sideslip_dialog.dart'; +import 'package:huixiang/retrofit/data/day_flow_list.dart'; import 'package:huixiang/utils/business_instance.dart'; import 'package:huixiang/view_widget/classic_header.dart'; import 'package:huixiang/view_widget/my_footer.dart'; @@ -18,7 +20,10 @@ import '../../retrofit/data/business_login_info.dart'; import '../../retrofit/data/day_count.dart'; import '../../retrofit/data/order_trend.dart'; import '../../retrofit/data/popular_sales_list.dart'; +import '../../retrofit/data/vip_counts_info.dart'; +import '../../utils/flutter_utils.dart'; import '../../utils/font_weight.dart'; +import '../../view_widget/no_data_view.dart'; import 'home_view/my_line_chart.dart'; class BusinessHomePage extends StatefulWidget { @@ -44,6 +49,10 @@ class _BusinessHomePage extends State int _loadCount = 0; PopularSalesList popularSalesList; List orderTrend = []; + VipCountsInfo vipCountsInfo; + int daySelectIndex = 0; + String offsetDay; + List dayFlowList = []; List lineChartSample2Data = [ LineChartSample2Data(0, 0, "2023-03-09"), LineChartSample2Data(1, 0, "2023-03-10"), @@ -79,14 +88,16 @@ class _BusinessHomePage extends State ? "0" : widget.businessLoginInfo.storeList[widget.selectStoreIndex].id); queryDayAmount(); - queryPopularList(); + queryPopularList(offsetDay); queryOrderTrend(); + queryVipCounts(); + queryDayFlow(); }); } addLoadCount() { _loadCount += 1; - if (_loadCount == 3) { + if (_loadCount == 5) { _loadCount = 0; EasyLoading.dismiss(); if (refreshController.isRefresh) refreshController.refreshCompleted(); @@ -99,7 +110,10 @@ class _BusinessHomePage extends State try { BaseData baseData = await businessService.getDayCounts({ "summaryDate": "${DateFormat("yyyy-MM-dd").format(DateTime.now())}" - }).catchError((error) {}); + }).catchError((error) { + SmartDialog.showToast(AppUtils.dioErrorTypeToString(error.type), + alignment: Alignment.center); + }); if (baseData != null && baseData.isSuccess) { dayCount = baseData.data; } @@ -109,12 +123,13 @@ class _BusinessHomePage extends State } ///热销榜单 - queryPopularList() async { + queryPopularList(offsetDay) async { try { BaseData baseData = - await businessService.popularList("30").catchError((error) {}); + await businessService.popularList(offsetDay).catchError((error) {}); if (baseData != null && baseData.isSuccess) { popularSalesList = baseData.data; + setState(() {}); } } finally { addLoadCount(); @@ -128,12 +143,13 @@ class _BusinessHomePage extends State await businessService.orderTrend().catchError((error) {}); if (baseData != null && baseData.isSuccess) { double index = 0; - if(baseData.data.isNotEmpty){ + if (baseData.data.isNotEmpty) { orderTrend.clear(); } orderTrend = baseData.data; orderTrend.forEach((element) { - lineChartSample2Data.add(LineChartSample2Data(index,element.number,element.date)); + lineChartSample2Data.add(LineChartSample2Data( + index, double.tryParse(element.number.toString()), element.date)); index += 1; }); } @@ -142,6 +158,38 @@ class _BusinessHomePage extends State } } + ///用户总览/会员统计数据 + queryVipCounts() async { + try { + BaseData baseData = await businessService + .vipCounts("${DateFormat("yyyy-MM-dd").format(DateTime.now())}") + .catchError((error) {}); + if (baseData != null && baseData.isSuccess) { + vipCountsInfo = baseData.data; + } + } finally { + addLoadCount(); + } + } + + ///今日流水/isMonth=0(当月数据),isMonth=1(当日数据) + queryDayFlow() async { + try { + BaseData> baseData = await businessService + .dayFlow( + // "${DateFormat("yyyy-MM-dd").format(DateTime.now())}", + "2023-09-04", + "1") + .catchError((error) {}); + if (baseData != null && baseData.isSuccess) { + dayFlowList = baseData.data; + setState(() {}); + } + } finally { + addLoadCount(); + } + } + @override Widget build(BuildContext context) { super.build(context); @@ -437,6 +485,7 @@ class _BusinessHomePage extends State return; } widget.changeIndex(index); + _onRefresh(); } } @@ -475,7 +524,14 @@ class _BusinessHomePage extends State behavior: HitTestBehavior.opaque, onTap: () { Navigator.of(context) - .pushNamed('/router/trade_overview_page'); + .pushNamed('/router/trade_overview_page', arguments: { + "storeId": widget.businessLoginInfo + .storeList[widget.selectStoreIndex].name == + "所有门店" + ? "0" + : widget.businessLoginInfo + .storeList[widget.selectStoreIndex].id, + }); }, child: Row( children: [ @@ -503,8 +559,16 @@ class _BusinessHomePage extends State SizedBox( height: 18.h, ), - if(lineChartSample2Data.isNotEmpty) - LineChartSample2(lineChartSample2Data, "销售量"), + // if (lineChartSample2Data.isNotEmpty) + (lineChartSample2Data.isNotEmpty) + ? NoDataView( + src: "assets/image/xiao_fei.webp", + isShowBtn: false, + text: "暂无数据", + fontSize: 16.sp, + margin: EdgeInsets.all(20.h), + ) + : LineChartSample2(lineChartSample2Data, "销售量"), ], ), ); @@ -543,155 +607,173 @@ class _BusinessHomePage extends State Row( children: [ Expanded( - child: Container( - padding: EdgeInsets.symmetric(horizontal: 8.w, vertical: 6.h), - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [Color(0xFFFC5A58), Color(0xFFFF716F)], - begin: Alignment.topCenter, - end: Alignment.bottomCenter, + child: GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + showVipTipDialog(1); + }, + child: Container( + padding: EdgeInsets.symmetric(horizontal: 8.w, vertical: 6.h), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [Color(0xFFFC5A58), Color(0xFFFF716F)], + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + ), + borderRadius: BorderRadius.circular(6.w), ), - borderRadius: BorderRadius.circular(6.w), - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Padding( - padding: EdgeInsets.only(right: 6.w), - child: Text( - "今日会员充值", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: Colors.white, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Padding( + padding: EdgeInsets.only(right: 6.w), + child: Text( + "今日会员充值", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: Colors.white, + ), ), ), + Image.asset( + "assets/image/bs_query_logo.webp", + width: 14, + height: 14, + ), + ], + ), + SizedBox( + height: 7.h, + ), + Text( + vipCountsInfo?.rechargeMoney ?? "0", + style: TextStyle( + fontSize: 24.sp, + fontWeight: MyFontWeight.medium, + color: Colors.white, ), - Image.asset( - "assets/image/bs_query_logo.webp", - width: 14, - height: 14, - ), - ], - ), - SizedBox( - height: 7.h, - ), - Text( - "108088", - style: TextStyle( - fontSize: 24.sp, - fontWeight: MyFontWeight.medium, - color: Colors.white, ), - ), - ], + ], + ), ), )), SizedBox( width: 9.w, ), Expanded( - child: Container( - padding: EdgeInsets.symmetric(horizontal: 8.w, vertical: 6.h), - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [Color(0xFFFFA238), Color(0xFFFFBA6D)], - begin: Alignment.topCenter, - end: Alignment.bottomCenter, - ), - borderRadius: BorderRadius.circular(6.w), - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Padding( - padding: EdgeInsets.only(right: 6.w), - child: Text( - "今日新增会员", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: Colors.white, - ), + child: GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + showVipTipDialog(2); + }, + child: Container( + padding: EdgeInsets.symmetric( + horizontal: 8.w, vertical: 6.h), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [Color(0xFFFFA238), Color(0xFFFFBA6D)], + begin: Alignment.topCenter, + end: Alignment.bottomCenter, ), + borderRadius: BorderRadius.circular(6.w), ), - Image.asset( - "assets/image/bs_query_logo.webp", - width: 14, - height: 14, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Padding( + padding: EdgeInsets.only(right: 6.w), + child: Text( + "今日新增会员", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: Colors.white, + ), + ), + ), + Image.asset( + "assets/image/bs_query_logo.webp", + width: 14, + height: 14, + ), + ], + ), + SizedBox( + height: 7.h, + ), + Text( + (vipCountsInfo?.newMemberNum ?? 0).toString(), + style: TextStyle( + fontSize: 24.sp, + fontWeight: MyFontWeight.medium, + color: Colors.white, + ), + ), + ], ), - ], - ), - SizedBox( - height: 7.h, - ), - Text( - "666", - style: TextStyle( - fontSize: 24.sp, - fontWeight: MyFontWeight.medium, - color: Colors.white, - ), - ), - ], - ), - )), + ))), SizedBox( width: 9.w, ), Expanded( - child: Container( - padding: EdgeInsets.symmetric(horizontal: 8.w, vertical: 6.h), - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [Color(0xFF4B77FC), Color(0xFF7091FF)], - begin: Alignment.topCenter, - end: Alignment.bottomCenter, - ), - borderRadius: BorderRadius.circular(6.w), - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Padding( - padding: EdgeInsets.only(right: 6.w), - child: Text( - "总会员数", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, - color: Colors.white, - ), + child: GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + showVipTipDialog(3); + }, + child: Container( + padding: EdgeInsets.symmetric( + horizontal: 8.w, vertical: 6.h), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [Color(0xFF4B77FC), Color(0xFF7091FF)], + begin: Alignment.topCenter, + end: Alignment.bottomCenter, ), + borderRadius: BorderRadius.circular(6.w), ), - Image.asset( - "assets/image/bs_query_logo.webp", - width: 14, - height: 14, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Padding( + padding: EdgeInsets.only(right: 6.w), + child: Text( + "总会员数", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: Colors.white, + ), + ), + ), + Image.asset( + "assets/image/bs_query_logo.webp", + width: 14, + height: 14, + ), + ], + ), + SizedBox( + height: 7.h, + ), + Text( + (vipCountsInfo?.memberNum ?? 0).toString(), + style: TextStyle( + fontSize: 24.sp, + fontWeight: MyFontWeight.medium, + color: Colors.white, + ), + ), + ], ), - ], - ), - SizedBox( - height: 7.h, - ), - Text( - "23455", - style: TextStyle( - fontSize: 24.sp, - fontWeight: MyFontWeight.medium, - color: Colors.white, - ), - ), - ], - ), - )), + ))), ], ) ], @@ -699,6 +781,58 @@ class _BusinessHomePage extends State ); } + ///用户概览弹窗提示 + showVipTipDialog(index) { + showDialog( + context: context, + builder: (context) { + return AlertDialog( + content: Column( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Image.asset( + index == 1 + ? "assets/image/icon_vip_recharge.webp" + : (index == 2 + ? "assets/image/icon_new_vip.webp" + : "assets/image/icon_vip_total.webp"), + width: 20.h, + height: 20.h, + ), + SizedBox( + height: 6.h, + ), + Text( + index == 1 ? "今日会员充值" : (index == 2 ? "今日新增会员" : "总会员数"), + style: TextStyle( + color: Color(0xFF0D0D0D), + fontSize: 15.sp, + fontWeight: MyFontWeight.bold, + ), + ), + SizedBox( + height: 13.h, + ), + Text( + index == 1 + ? "今日会员充值指今天所选门店会员充值额度" + : (index == 2 ? "今日新增会员指今天所选门店新增会员" : "总会员数指所选门店会员总会员人数"), + textAlign: TextAlign.center, + style: TextStyle( + color: Color(0xFF666666), + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + ), + ), + ], + ), + ); + }, + ); + } + ///热销榜单 Widget hotSellHotCharts() { return Container( @@ -729,91 +863,213 @@ class _BusinessHomePage extends State SizedBox( height: 14.h, ), - Container( - height: 25.h, - margin: EdgeInsets.only(bottom: 26.h), - child: ListView.builder( - scrollDirection: Axis.horizontal, - physics: BouncingScrollPhysics(), - itemCount: 4, - itemBuilder: (context, position) { - return GestureDetector( - onTap: () {}, - child: dayItem(), - ); - }, - ), + Row( + children: [ + GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + setState(() { + daySelectIndex = 0; + queryPopularList("0"); + }); + }, + child: Container( + padding: + EdgeInsets.symmetric(horizontal: 19.w, vertical: 5.h), + alignment: Alignment.center, + margin: EdgeInsets.only(right: 16.w, bottom: 16.h), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(2.w), + color: daySelectIndex == 0 + ? Color(0xFF30415B) + : Colors.transparent, + border: Border.all( + color: Color(0xFF30415B), + width: 1.w, + ), + ), + child: Text( + "今天", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: daySelectIndex == 0 + ? Colors.white + : Color(0XFF30415B), + ), + ), + ), + ), + GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + setState(() { + daySelectIndex = 1; + queryPopularList("1"); + }); + }, + child: Container( + padding: + EdgeInsets.symmetric(horizontal: 19.w, vertical: 5.h), + alignment: Alignment.center, + margin: EdgeInsets.only(right: 16.w, bottom: 16.h), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(2.w), + color: daySelectIndex == 1 + ? Color(0xFF30415B) + : Colors.transparent, + border: Border.all( + color: Color(0xFF30415B), + width: 1.w, + ), + ), + child: Text( + "昨天", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: daySelectIndex == 1 + ? Colors.white + : Color(0XFF30415B), + ), + ), + )), + GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + setState(() { + daySelectIndex = 2; + queryPopularList("7"); + }); + }, + child: Container( + padding: + EdgeInsets.symmetric(horizontal: 10.w, vertical: 5.h), + alignment: Alignment.center, + margin: EdgeInsets.only(right: 16.w, bottom: 16.h), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(2.w), + color: daySelectIndex == 2 + ? Color(0xFF30415B) + : Colors.transparent, + border: Border.all( + color: Color(0xFF30415B), + width: 1.w, + ), + ), + child: Text( + "最近7天", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: daySelectIndex == 2 + ? Colors.white + : Color(0XFF30415B), + ), + ), + )), + GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + setState(() { + daySelectIndex = 3; + queryPopularList("30"); + }); + }, + child: Container( + padding: + EdgeInsets.symmetric(horizontal: 10.w, vertical: 5.h), + alignment: Alignment.center, + margin: EdgeInsets.only(right: 16.w, bottom: 16.h), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(2.w), + color: daySelectIndex == 3 + ? Color(0xFF30415B) + : Colors.transparent, + border: Border.all( + color: Color(0xFF30415B), + width: 1.w, + ), + ), + child: Text( + "最近30天", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: daySelectIndex == 3 + ? Colors.white + : Color(0XFF30415B), + ), + ), + )), + ], ), - ListView.builder( - padding: EdgeInsets.zero, - itemCount: 5, - scrollDirection: Axis.vertical, - shrinkWrap: true, - physics: BouncingScrollPhysics(), - itemBuilder: (context, position) { - return GestureDetector( - onTap: () {}, - child: salesVolumeItem(), - ); - }, + Container( + height: 310.h, + child: (popularSalesList == null || + popularSalesList.saleProductList.length == 0) + ? NoDataView( + src: "assets/image/xiao_fei.webp", + isShowBtn: false, + text: "暂无数据", + fontSize: 16.sp, + margin: EdgeInsets.all(20.h), + ) + : ListView.builder( + padding: EdgeInsets.zero, + itemCount: popularSalesList?.saleProductList?.length ?? 0, + scrollDirection: Axis.vertical, + shrinkWrap: true, + physics: BouncingScrollPhysics(), + itemBuilder: (context, position) { + return GestureDetector( + onTap: () {}, + child: salesVolumeItem( + popularSalesList.saleProductList[position], + position), + ); + }, + ), ), ], ), ); } - ///天数item - Widget dayItem() { - return Container( - padding: EdgeInsets.symmetric( - horizontal: 19.w, - ), - alignment: Alignment.center, - margin: EdgeInsets.only(right: 16.w), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(2.w), - // color: Color(0xFF30415B), - border: Border.all( - color: Color(0xFF30415B), - width: 1.w, - ), - ), - child: Text( - "今天", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.medium, - color: Color(0XFF30415B), - ), - ), - ); - } - ///销量item - Widget salesVolumeItem() { + Widget salesVolumeItem(SaleProductList saleProductList, index) { return Container( padding: EdgeInsets.only(bottom: 12.h), child: Row( children: [ - Image.asset( - "assets/image/bs_trophy_one.webp", - width: 26, - height: 26, - ), - // Text( - // "1", - // style: TextStyle( - // fontSize: 12.sp, - // fontWeight: MyFontWeight.regular, - // color: Color(0xFF0D0D0D), - // ), - // ), + if (index == 0 || index == 1 || index == 2) + Image.asset( + index == 0 + ? "assets/image/bs_trophy_one.webp" + : (index == 1 + ? "assets/image/bs_trophy_two.webp" + : "assets/image/bs_trophy_three.webp"), + width: 26.h, + height: 26.h, + ), + if (index != 0 && index != 1 && index != 2) + Padding( + padding: EdgeInsets.symmetric(horizontal: 8.w), + child: Text( + (index + 1).toString(), + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF0D0D0D), + ), + ), + ), SizedBox( width: 8.w, ), Expanded( child: Text( - "满杯花青素", + saleProductList?.productName ?? "", style: TextStyle( fontSize: 12.sp, fontWeight: MyFontWeight.regular, @@ -832,7 +1088,7 @@ class _BusinessHomePage extends State Padding( padding: EdgeInsets.only(left: 7.w), child: Text( - "1888件", + "${(saleProductList?.saleNum ?? 0).toString()}件", style: TextStyle( fontSize: 12.sp, fontWeight: MyFontWeight.regular, @@ -874,7 +1130,18 @@ class _BusinessHomePage extends State GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { - Navigator.of(context).pushNamed('/router/flow_page'); + Navigator.of(context).pushNamed('/router/flow_page', + arguments: { + "storeName": widget?.businessLoginInfo + ?.storeList[widget.selectStoreIndex].name ?? + "", + "storeId": widget.businessLoginInfo + .storeList[widget.selectStoreIndex].name == + "所有门店" + ? "0" + : widget.businessLoginInfo + .storeList[widget.selectStoreIndex].id, + }); }, child: Row( children: [ @@ -902,26 +1169,36 @@ class _BusinessHomePage extends State SizedBox( height: 20.h, ), - ListView.builder( - padding: EdgeInsets.zero, - itemCount: 5, - scrollDirection: Axis.vertical, - shrinkWrap: true, - physics: BouncingScrollPhysics(), - itemBuilder: (context, position) { - return GestureDetector( - onTap: () {}, - child: flowItem(), - ); - }, - ) + Container( + height: 360.h, + child: (dayFlowList.length == null || dayFlowList?.length == 0) + ? NoDataView( + src: "assets/image/xiao_fei.webp", + isShowBtn: false, + text: "暂无数据", + fontSize: 16.sp, + margin: EdgeInsets.all(20.h), + ) + : ListView.builder( + padding: EdgeInsets.zero, + itemCount: dayFlowList?.length ?? 0, + scrollDirection: Axis.vertical, + shrinkWrap: true, + physics: BouncingScrollPhysics(), + itemBuilder: (context, position) { + return GestureDetector( + onTap: () {}, + child: flowItem(dayFlowList[position]), + ); + }, + )) ], ), ); } ///流水item - Widget flowItem() { + Widget flowItem(DayFlowList dayFlowList) { return Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(0.w), @@ -936,7 +1213,7 @@ class _BusinessHomePage extends State crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - "2023-06-04 9:00:05", + dayFlowList?.localDateTime ?? "", style: TextStyle( fontSize: 12.sp, fontWeight: MyFontWeight.medium, @@ -947,7 +1224,7 @@ class _BusinessHomePage extends State height: 7.h, ), Text( - "海峽姐妹茶 郑州新田360店", + dayFlowList?.storeName ?? "", style: TextStyle( fontSize: 12.sp, fontWeight: MyFontWeight.regular, @@ -960,7 +1237,7 @@ class _BusinessHomePage extends State TextSpan( children: [ TextSpan( - text: "+", + text: (dayFlowList?.amount != "0.00") ? "+" : "-", style: TextStyle( fontSize: 12.sp, fontWeight: MyFontWeight.medium, @@ -968,7 +1245,9 @@ class _BusinessHomePage extends State ), ), TextSpan( - text: "34.00", + text: (dayFlowList?.amount != "0.00") + ? (dayFlowList?.amount ?? "") + : (dayFlowList?.refundAmount ?? ""), style: TextStyle( fontSize: 14.sp, fontWeight: MyFontWeight.medium, diff --git a/lib/business_system/home/flow_page.dart b/lib/business_system/home/flow_page.dart index 20dbb697..cd9667e1 100644 --- a/lib/business_system/home/flow_page.dart +++ b/lib/business_system/home/flow_page.dart @@ -1,13 +1,26 @@ +import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_datetime_picker/flutter_datetime_picker.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import '../../generated/l10n.dart'; +import '../../retrofit/business_api.dart'; +import '../../retrofit/data/base_data.dart'; +import '../../retrofit/data/day_flow_list.dart'; +import '../../utils/business_instance.dart'; import '../../view_widget/classic_header.dart'; import '../../view_widget/my_footer.dart'; class FlowPage extends StatefulWidget { + final arguments; + + FlowPage({this.arguments}); + @override State createState() { return _FlowPage(); @@ -16,48 +29,88 @@ class FlowPage extends StatefulWidget { class _FlowPage extends State { final RefreshController refreshController = RefreshController(); - var isShowMore = false; + String storeId; + BusinessApiService businessService; + List dayFlowList = []; @override void initState() { super.initState(); + storeId = widget.arguments["storeId"]; + SharedPreferences.getInstance().then((value) { + businessService = BusinessApiService(Dio(), + context: context, + token: BusinessInstance.instance.businessToken, + tenant: BusinessInstance.instance.businessTenant, + storeId: storeId); + queryDayFlow("2023-09-04", "0"); + }); + } + + ///今日流水/isMonth=0(当月数据),isMonth=1(当日数据) + queryDayFlow(yearMonth, isMonth) async { + EasyLoading.show( + status: S.current.zhengzaijiazai, maskType: EasyLoadingMaskType.black); + try { + BaseData> baseData = await businessService + .dayFlow( + // "${DateFormat("yyyy-MM-dd").format(DateTime.now())}", + yearMonth, + isMonth) + .catchError((error) {}); + if (baseData != null && baseData.isSuccess) { + if (isMonth == "0") { + dayFlowList = baseData.data; + } else { + dayFlowList + .firstWhere((element) => element.localDate == yearMonth) + .detailList = baseData.data.first.detailList; + } + setState(() {}); + } + } finally { + EasyLoading.dismiss(); + } } @override Widget build(BuildContext context) { - return - Scaffold( - backgroundColor: Color(0xFFF8F8FA), - appBar: MyAppBar( - title: "海峡姐妹茶", - titleColor: Colors.black, - background: Colors.white, - leadingColor: Colors.black, - brightness: Brightness.dark, + return Scaffold( + backgroundColor: Color(0xFFF8F8FA), + appBar: MyAppBar( + title: widget.arguments["storeName"], + titleColor: Colors.black, + background: Colors.white, + leadingColor: Colors.black, + brightness: Brightness.dark, + ), + body: SmartRefresher( + controller: refreshController, + enablePullDown: true, + enablePullUp: false, + header: MyHeader( + color: Colors.white, ), - body: SmartRefresher( - controller: refreshController, - enablePullDown: true, - enablePullUp: false, - header: MyHeader( - color: Colors.white, - ), - footer: CustomFooter( - builder: (context, mode) { - return MyFooter(mode); - }, - ), - onRefresh: () { + footer: CustomFooter( + builder: (context, mode) { + return MyFooter(mode); }, + ), + onRefresh: () {}, + physics: BouncingScrollPhysics(), + scrollController: ScrollController(), + child: SingleChildScrollView( physics: BouncingScrollPhysics(), - scrollController: ScrollController(), - child: SingleChildScrollView( - physics: BouncingScrollPhysics(), - child:Container( - margin: EdgeInsets.only(top: 24.h,left: 16.w,right: 16.w), - child:Column( - children: [ - Row( + child: Container( + margin: EdgeInsets.only(top: 24.h, left: 16.w, right: 16.w), + child: Column( + children: [ + GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + showDateSelector(); + }, + child: Row( children: [ Text( "2023年6月", @@ -74,50 +127,57 @@ class _FlowPage extends State { ), ], ), - SizedBox(height: 16.h,), - ListView.builder( - padding: EdgeInsets.zero, - itemCount:5, - scrollDirection: Axis.vertical, - shrinkWrap: true, - physics: BouncingScrollPhysics(), - itemBuilder: (context, position) { - return GestureDetector( - onTap: () { - }, - child: billItem(), - ); - }, - ) - ], - ), + ), + SizedBox( + height: 16.h, + ), + ListView.builder( + padding: EdgeInsets.zero, + itemCount: dayFlowList?.length ?? 0, + scrollDirection: Axis.vertical, + shrinkWrap: true, + physics: BouncingScrollPhysics(), + itemBuilder: (context, position) { + return GestureDetector( + onTap: () {}, + child: billItem(dayFlowList[position]), + ); + }, + ) + ], ), ), ), - ); + ), + ); } ///月份账单大概 - Widget billItem(){ + Widget billItem(DayFlowList dayFlowList) { return Container( padding: EdgeInsets.all(12.h), - margin: EdgeInsets.only(bottom:12.h), + margin: EdgeInsets.only(bottom: 12.h), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(8.w), ), - child:Column( + child: Column( children: [ GestureDetector( - onTap: (){ - setState((){ - isShowMore = !isShowMore; - }); + onTap: () { + if(dayFlowList.detailList != null){ + setState((){ + dayFlowList.detailList = null; + }); + }else{ + queryDayFlow("2023-09-04", "1"); + } }, child: Row( children: [ - Expanded(child: Text( - "06/10", + Expanded( + child: Text( + dayFlowList?.localDate ?? "", style: TextStyle( fontSize: 18.sp, fontWeight: MyFontWeight.medium, @@ -125,18 +185,23 @@ class _FlowPage extends State { ), )), Icon( - isShowMore ? Icons.keyboard_arrow_up :Icons.keyboard_arrow_down, + dayFlowList.detailList == null + ? Icons.keyboard_arrow_up + : Icons.keyboard_arrow_down, color: Color(0xFF0D0D0D), size: 24, ), ], ), ), - SizedBox(height:15.h,), + SizedBox( + height: 15.h, + ), Row( children: [ - Expanded(child: Text( - "交易金额 76555.22元", + Expanded( + child: Text( + "交易金额 ${dayFlowList?.amount ?? ""}元", style: TextStyle( fontSize: 12.sp, fontWeight: MyFontWeight.regular, @@ -144,7 +209,7 @@ class _FlowPage extends State { ), )), Text( - "共76笔", + "共${(dayFlowList?.count ?? 0).toString()}笔", style: TextStyle( fontSize: 12.sp, fontWeight: MyFontWeight.regular, @@ -153,82 +218,111 @@ class _FlowPage extends State { ) ], ), - SizedBox(height:20.h,), - if(isShowMore) - ListView.builder( - padding: EdgeInsets.zero, - itemCount:5, - scrollDirection: Axis.vertical, - shrinkWrap: true, - physics: BouncingScrollPhysics(), - itemBuilder: (context, position) { - return GestureDetector( - onTap: () { - - }, - child: billIDetailsItem(), - ); - }, - ) + SizedBox( + height: 20.h, + ), + if(dayFlowList.detailList != null) + Column( + children:dayFlowList.detailList.map((e) { + return billIDetailsItem(e); + }).toList(), + ) + // if (isShowMore) + // ListView.builder( + // padding: EdgeInsets.zero, + // itemCount: 5, + // scrollDirection: Axis.vertical, + // shrinkWrap: true, + // physics: BouncingScrollPhysics(), + // itemBuilder: (context, position) { + // return GestureDetector( + // onTap: () {}, + // child: billIDetailsItem(), + // ); + // }, + // ) ], ), ); } ///月份账单明细 - Widget billIDetailsItem(){ + Widget billIDetailsItem(DayFlowList detailList) { return Container( - margin: EdgeInsets.only(bottom:20.h), - child: Row( - children: [ - Expanded(child: - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding(padding:EdgeInsets.only(bottom:15.h), - child:Text( - "11:20:12", - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFF1A1A1A), + margin: EdgeInsets.only(bottom: 20.h), + child: Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: EdgeInsets.only(bottom: 15.h), + child: Text( + detailList?.localDateTime ??"", + style: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.regular, + color: Color(0xFF1A1A1A), + ), + ), ), - ),), - Text( - "JJJJ", - style: TextStyle( - fontSize: 14.sp, - fontWeight: MyFontWeight.regular, - color: Color(0xFF1A1A1A), - ), + Text( + detailList?.phone ?? "", + style: TextStyle( + fontSize: 14.sp, + fontWeight: MyFontWeight.regular, + color: Color(0xFF1A1A1A), + ), + ), + ], ), - ], - ),), - Text.rich( - TextSpan( - children: [ - TextSpan( - text:"+", - style: TextStyle( - fontSize: 18.sp, - fontWeight: MyFontWeight.medium, - color: Color(0xFF0D0D0D), + ), + Text.rich( + TextSpan( + children: [ + TextSpan( + text: "+", + style: TextStyle( + fontSize: 18.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF0D0D0D), + ), ), - ), - TextSpan( - text: "22.33", - style: TextStyle( - fontSize: 18.sp, - fontWeight: MyFontWeight.medium, - color: Color(0xFF0D0D0D), + TextSpan( + text: detailList?.amount ?? "", + style: TextStyle( + fontSize: 18.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF0D0D0D), + ), ), - ), - ], + ], + ), ), - ), - ], - ) - ); + ], + )); } + showDateSelector() { + DatePicker.showDatePicker(context, + showTitleActions: true, + minTime: DateTime.now(), + maxTime: DateTime.now(), + theme: DatePickerTheme( + headerColor: Colors.white, + backgroundColor: Colors.white, + itemStyle: TextStyle( + color: Colors.black, + fontWeight: MyFontWeight.bold, + fontSize: 18), + doneStyle: TextStyle(color: Color(0xFF32A060), fontSize: 16.sp)), + onChanged: (date) { + print('change $date in time zone ' + + date.timeZoneOffset.inHours.toString()); + }, onConfirm: (date) { + // "2023-09-04"; + setState(() {}); + }, currentTime: DateTime.now(), locale: LocaleType.zh); + } } diff --git a/lib/business_system/home/overview/trade_goods.dart b/lib/business_system/home/overview/trade_goods.dart index 27707da4..194a77a2 100644 --- a/lib/business_system/home/overview/trade_goods.dart +++ b/lib/business_system/home/overview/trade_goods.dart @@ -1,14 +1,30 @@ +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:huixiang/view_widget/classic_header.dart'; import 'package:huixiang/view_widget/my_footer.dart'; import 'package:intl/intl.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import '../../../generated/l10n.dart'; +import '../../../retrofit/business_api.dart'; +import '../../../retrofit/data/base_data.dart'; +import '../../../retrofit/data/goods_type_sales_list.dart'; +import '../../../retrofit/data/single_sales_list.dart'; +import '../../../utils/business_instance.dart'; +import '../../../utils/flutter_utils.dart'; import '../../../utils/font_weight.dart'; +import '../../../view_widget/no_data_view.dart'; class TradeGoods extends StatefulWidget { + final storeId; + + TradeGoods(this.storeId); + @override State createState() { return _TradeGoods(); @@ -21,13 +37,18 @@ class _TradeGoods extends State { int dateIndex = 0; String selectedDate = ""; String dayDate = "${DateFormat("yyyy年MM月dd日").format(DateTime.now())}"; - String weekDate =""; - String weekDateNum = "${DateFormat("yyyy年MM月dd日").format(DateTime.now().subtract(Duration(days:6)))} 至 " + String weekDate = ""; + String weekDateNum = + "${DateFormat("yyyy年MM月dd日").format(DateTime.now().subtract(Duration(days: 6)))} 至 " "${DateFormat("yyyy年MM月dd日").format(DateTime.now())}"; - String monthlyDate =""; - String monthlyDateNum = "${DateFormat("yyyy年MM月").format(DateTime.now())}"; - String customDate =""; + String monthlyDate = ""; + String monthlyDateNum = "${DateFormat("yyyy年MM月dd").format(DateTime.now())}"; + String customDate = ""; String customDateNum = "${DateFormat("yyyy年MM月dd日").format(DateTime.now())}"; + int _loadCount = 0; + BusinessApiService businessService; + List singleSalesList = []; + List goodsTypeSalesList = []; @override void dispose() { @@ -38,9 +59,87 @@ class _TradeGoods extends State { @override void initState() { super.initState(); + _onRefresh(); } _onRefresh() async { + EasyLoading.show( + status: S.current.zhengzaijiazai, maskType: EasyLoadingMaskType.black); + SharedPreferences.getInstance().then((value) { + businessService = BusinessApiService(Dio(), + context: context, + token: BusinessInstance.instance.businessToken, + tenant: BusinessInstance.instance.businessTenant, + storeId: widget.storeId); + querySingleSales( + dayDate.replaceAll("年", "-").replaceAll("月", "-").replaceAll("日", ""), + dayDate + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "")); + queryGoodsSalesList( + dayDate.replaceAll("年", "-").replaceAll("月", "-").replaceAll("日", ""), + dayDate + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "")); + }); + } + + addLoadCount() { + _loadCount += 1; + if (_loadCount == 2) { + _loadCount = 0; + EasyLoading.dismiss(); + if (_refreshController.isRefresh) _refreshController.refreshCompleted(); + if (mounted) setState(() {}); + } + } + + ///商品种类销售数据 + queryGoodsSalesList(date, endDat) async { + try { + BaseData> baseData = + await businessService.goodsSalesList({ + "date": date, + "endDate": endDat, + "groupId": 0, + "orderBy": 1, + "searchType": 2, + "type": 1 + }).catchError((error) { + SmartDialog.showToast(AppUtils.dioErrorTypeToString(error.type), + alignment: Alignment.center); + }); + if (baseData != null && baseData.isSuccess) { + goodsTypeSalesList = baseData.data; + } + } finally { + addLoadCount(); + } + } + + ///单品销量报表 + querySingleSales(date, endDate) async { + try { + BaseData> baseData = + await businessService.singleSales({ + "date": date, + "endDate": endDate, + "groupId": 0, + "orderBy": 1, + "searchType": 2, + "type": 1 + }).catchError((error) { + SmartDialog.showToast(AppUtils.dioErrorTypeToString(error.type), + alignment: Alignment.center); + }); + if (baseData != null && baseData.isSuccess) { + singleSalesList = baseData.data; + } + } finally { + addLoadCount(); + } } @override @@ -54,268 +153,484 @@ class _TradeGoods extends State { width: double.infinity, height: 1.h, ), - Expanded(child: SmartRefresher( - controller: _refreshController, - enablePullDown: true, - enablePullUp: false, - header: MyHeader(), - physics: BouncingScrollPhysics(), - scrollController: scrollController, - footer: CustomFooter( - builder: (context, mode) { - return MyFooter(mode); - }, - ), - onRefresh: () { - setState(() { - _onRefresh(); - }); - }, - child: SingleChildScrollView( - physics: NeverScrollableScrollPhysics(), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - decoration: BoxDecoration( - color: Color(0xFFF6F6F6), - borderRadius: BorderRadius.circular(2), - border: Border.all(color: Color(0xFFCFD0D1), - width: 1.w), - ), - margin: EdgeInsets.only( - top: 16.h, right: 20.w, left: 20.w, bottom: 12.h), - child: Row( - children: [ - Expanded(child: GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: (){ - setState((){ - dateIndex = 0; - }); - }, - child: Container( - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(2), - color: dateIndex == 0 ? Color(0xFF30415B):Colors.transparent, - ), - padding: EdgeInsets.symmetric(vertical: 9.h), - child: Text( - "日报", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.medium, - color: dateIndex == 0 ? Colors.white:Color(0xFF30415B), + Expanded( + child: SmartRefresher( + controller: _refreshController, + enablePullDown: true, + enablePullUp: false, + header: MyHeader(), + physics: BouncingScrollPhysics(), + scrollController: scrollController, + footer: CustomFooter( + builder: (context, mode) { + return MyFooter(mode); + }, + ), + onRefresh: _onRefresh, + child: SingleChildScrollView( + physics: NeverScrollableScrollPhysics(), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + decoration: BoxDecoration( + color: Color(0xFFF6F6F6), + borderRadius: BorderRadius.circular(2), + border: + Border.all(color: Color(0xFFCFD0D1), width: 1.w), + ), + margin: EdgeInsets.only( + top: 16.h, right: 20.w, left: 20.w, bottom: 12.h), + child: Row( + children: [ + Expanded( + child: GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + setState(() { + dateIndex = 0; + querySingleSales( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10)); + queryGoodsSalesList( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10)); + }); + }, + child: Container( + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(2), + color: dateIndex == 0 + ? Color(0xFF30415B) + : Colors.transparent, ), - ), - ), - )), - Expanded(child: GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: (){ - setState((){ - dateIndex = 1; - });}, - child: Container( - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(2), - color: dateIndex == 1 ? Color(0xFF30415B):Colors.transparent, - ), - padding: EdgeInsets.symmetric(vertical: 9.h), - child: Text( - "周报", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.medium, - color: dateIndex == 1 ? Colors.white:Color(0xFF30415B), + padding: EdgeInsets.symmetric(vertical: 9.h), + child: Text( + "日报", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: dateIndex == 0 + ? Colors.white + : Color(0xFF30415B), + ), ), ), - ),)), - Expanded(child: GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: (){ - setState((){ - dateIndex = 2; - }); - }, - child: Container( - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(2), - color: dateIndex == 2 ? Color(0xFF30415B):Colors.transparent, - ), - padding: EdgeInsets.symmetric(vertical: 9.h), - child: Text( - "月报", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.medium, - color: dateIndex == 2 ? Colors.white:Color(0xFF30415B), + )), + Expanded( + child: GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + setState(() { + dateIndex = 1; + querySingleSales( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(12, 23)); + queryGoodsSalesList( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(12, 23)); + }); + }, + child: Container( + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(2), + color: dateIndex == 1 + ? Color(0xFF30415B) + : Colors.transparent, + ), + padding: EdgeInsets.symmetric(vertical: 9.h), + child: Text( + "周报", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: dateIndex == 1 + ? Colors.white + : Color(0xFF30415B), + ), ), ), - ),)), - Expanded(child: GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: (){ - setState((){ - dateIndex = 3; - }); - }, - child: Container( - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(2), - color: dateIndex == 3 ? Color(0xFF30415B):Colors.transparent, + )), + Expanded( + child: GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + setState(() { + dateIndex = 2; + querySingleSales( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + ""); + queryGoodsSalesList( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + ""); + }); + }, + child: Container( + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(2), + color: dateIndex == 2 + ? Color(0xFF30415B) + : Colors.transparent, + ), + padding: EdgeInsets.symmetric(vertical: 9.h), + child: Text( + "月报", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: dateIndex == 2 + ? Colors.white + : Color(0xFF30415B), + ), + ), ), - padding: EdgeInsets.symmetric(vertical: 9.h), - child: Text( - "自定义", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.medium, - color: dateIndex == 3 ? Colors.white:Color(0xFF30415B), + )), + Expanded( + child: GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + setState(() { + dateIndex = 3; + querySingleSales( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10)); + queryGoodsSalesList( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10)); + }); + }, + child: Container( + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(2), + color: dateIndex == 3 + ? Color(0xFF30415B) + : Colors.transparent, + ), + padding: EdgeInsets.symmetric(vertical: 9.h), + child: Text( + "自定义", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: dateIndex == 3 + ? Colors.white + : Color(0xFF30415B), + ), ), ), - ),)), - ], + )), + ], + ), ), - ), - Align(alignment: Alignment.center, - child: GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: (){ - if(dateIndex == 0){ - Navigator.of(context).pushNamed('/router/day_report_page').then((value) { - setState((){ - selectedDate = value; - }); - }); - } - else if(dateIndex == 1){ - Navigator.of(context).pushNamed('/router/week_report_page').then((value) { - setState((){ - weekDate = value; - }); - }); - } - else if(dateIndex == 2){ - Navigator.of(context).pushNamed('/router/monthly_report_page').then((value) { - setState((){ - monthlyDate = value; - }); - }); - } - else if(dateIndex == 3){ - Navigator.of(context).pushNamed('/router/custom_page').then((value){ - setState((){ - customDate = value; - }); - }); - } - }, - child: Container( - width: 194.w, + Align( alignment: Alignment.center, - padding: EdgeInsets.all(8), - decoration: BoxDecoration( - color: Color(0xFFF6F6F6), - borderRadius: BorderRadius.circular(2), - ), - margin: EdgeInsets.only(bottom:16.h), - child: Row( - children: [ - Expanded(child:Container( - alignment: Alignment.center, - child: Text( - timeDate(), - style: TextStyle( - fontSize: 10.sp, - fontWeight: MyFontWeight.regular, - color: Colors.black, + child: GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + if (dateIndex == 0) { + Navigator.of(context) + .pushNamed('/router/day_report_page') + .then((value) { + setState(() { + selectedDate = value; + querySingleSales( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10)); + queryGoodsSalesList( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10)); + }); + }); + } else if (dateIndex == 1) { + Navigator.of(context) + .pushNamed('/router/week_report_page') + .then((value) { + setState(() { + weekDate = value; + querySingleSales( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(12, 23)); + queryGoodsSalesList( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(12, 23)); + }); + }); + } else if (dateIndex == 2) { + Navigator.of(context) + .pushNamed('/router/monthly_report_page') + .then((value) { + setState(() { + monthlyDate = value; + querySingleSales( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10)); + queryGoodsSalesList( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10)); + }); + }); + } else if (dateIndex == 3) { + Navigator.of(context) + .pushNamed('/router/custom_page') + .then((value) { + setState(() { + customDate = value; + querySingleSales( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(12, 23)); + queryGoodsSalesList( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(12, 23)); + }); + }); + } + }, + child: Container( + width: 194.w, + alignment: Alignment.center, + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + color: Color(0xFFF6F6F6), + borderRadius: BorderRadius.circular(2), + ), + margin: EdgeInsets.only(bottom: 16.h), + child: Row( + children: [ + Expanded( + child: Container( + alignment: Alignment.center, + child: Text( + dateIndex == 2 + ? ((monthlyDateNum.substring(0, 8) == + timeDate().substring(0, 8)) + ? "${timeDate().substring(0, 8)}(当月)" + : timeDate().substring(0, 8)) + : timeDate(), + style: TextStyle( + fontSize: 10.sp, + fontWeight: MyFontWeight.regular, + color: Colors.black, + ), + ), + )), + Image.asset( + "assets/image/bs_calendar_logo.webp", + width: 15, + height: 15, ), - ), - )), - Image.asset( - "assets/image/bs_calendar_logo.webp", - width:15, - height:15, + ], ), - ], + ), ), ), - ),), - Padding(padding:EdgeInsets.only(left:16.w,bottom:15.h), - child:Text( - "商品分析", - style: TextStyle( - fontSize: 18.sp, - fontWeight: MyFontWeight.semi_bold, - color: Colors.black, + Padding( + padding: EdgeInsets.only(left: 16.w, bottom: 15.h), + child: Text( + "商品分析", + style: TextStyle( + fontSize: 18.sp, + fontWeight: MyFontWeight.semi_bold, + color: Colors.black, + ), + )), + goodsTypeRecord(), + Container( + margin: + EdgeInsets.only(top: 14.h, left: 16.w, right: 16.w), + color: Color(0xFFECECEC), + height: 1.h, + width: double.infinity, ), - )), - goodsTypeRecord(), - Container( - margin: EdgeInsets.only(top: 14.h,left:16.w,right: 16.w), - color: Color(0xFFECECEC), - height: 1.h, - width: double.infinity, - ), - singleSalesStatement(), - ], - )), - ),) + singleSalesStatement(), + ], + )), + ), + ) ], ), ); } - String timeDate(){ - if(dateIndex == 0){ - return (selectedDate == "" || selectedDate == null) ? "${dayDate ?? ""}(今日)":(dayDate == DateFormat("yyyy年MM月dd日").format(DateTime.parse(selectedDate)) - ?"${DateFormat("yyyy年MM月dd日").format(DateTime.parse(selectedDate))}(今日)":DateFormat("yyyy年MM月dd日").format(DateTime.parse(selectedDate))); + String timeDate() { + if (dateIndex == 0) { + return (selectedDate == "" || selectedDate == null) + ? "${dayDate ?? ""}(今日)" + : (dayDate == + DateFormat("yyyy年MM月dd日").format(DateTime.parse(selectedDate)) + ? "${DateFormat("yyyy年MM月dd日").format(DateTime.parse(selectedDate))}(今日)" + : DateFormat("yyyy年MM月dd日").format(DateTime.parse(selectedDate))); + } else if (dateIndex == 1) { + return (weekDate == "" || weekDate == null) ? weekDateNum : weekDate; + } else if (dateIndex == 2) { + return (monthlyDate == "" || monthlyDate == null) + ? "${monthlyDateNum ?? ""}" + : (monthlyDateNum == + (DateFormat("yyyy年MM月dd日") + .format(DateTime.parse(monthlyDate))) + ? "${(DateFormat("yyyy年MM月dd日").format(DateTime.parse(monthlyDate)))}" + : DateFormat("yyyy年MM月dd日").format(DateTime.parse(monthlyDate))); + } else if (dateIndex == 3) { + return (customDate == "" || customDate == null) + ? "${customDateNum ?? ""}(今日)" + : customDate; } - else if(dateIndex == 1){ - return (weekDate == "" || weekDate == null) ? weekDateNum : weekDate;} - else if(dateIndex == 2){ - return (monthlyDate == "" || monthlyDate == null) ? "${monthlyDateNum ?? ""}(当月)": - (monthlyDateNum == (DateFormat("yyyy年MM月dd日").format(DateTime.parse(monthlyDate)).substring(0,8))? - "${(DateFormat("yyyy年MM月dd日").format(DateTime.parse(monthlyDate)).substring(0,8))}(当月)" - :DateFormat("yyyy年MM月dd日").format(DateTime.parse(monthlyDate)).substring(0,8)); - } - else if(dateIndex == 3){ - return (customDate == "" || customDate == null) ? "${customDateNum??""}(今日)" : customDate;} } ///商品种类销售数据 - Widget goodsTypeRecord(){ + Widget goodsTypeRecord() { return Column( children: [ - Padding(padding:EdgeInsets.only(left:16.w,bottom: 19.h), - child:Row( + Padding( + padding: EdgeInsets.only(left: 16.w, bottom: 19.h), + child: Row( children: [ Container( width: 4.w, height: 16.h, color: Color(0xFF30415B), - margin: EdgeInsets.only(right:12.w), + margin: EdgeInsets.only(right: 12.w), ), Text( "商品种类销售数据", style: TextStyle( fontSize: 15.sp, fontWeight: MyFontWeight.semi_bold, - color:Color(0xFF0D0D0D), + color: Color(0xFF0D0D0D), ), ), - SizedBox(width:8.w,), + SizedBox( + width: 8.w, + ), Text( "比上周一同时段", style: TextStyle( fontSize: 12.sp, fontWeight: MyFontWeight.regular, - color:Color(0xFF666666), + color: Color(0xFF666666), ), ) ], @@ -334,45 +649,56 @@ class _TradeGoods extends State { children: [ Container( color: Color(0xFFF3F7FF), - padding: EdgeInsets.only(top: 7.h,left: 11.w,right:24.w,bottom: 8.h), + padding: EdgeInsets.only( + top: 7.h, left: 11.w, right: 24.w, bottom: 8.h), child: Row( children: [ - Expanded(child:Text( - "分类", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.medium, - color:Color(0xFF969799), + Expanded( + child: Text( + "分类", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF969799), + ), ), - ),), + ), Text( "销售额", style: TextStyle( fontSize: 12.sp, fontWeight: MyFontWeight.medium, - color:Color(0xFF969799), + color: Color(0xFF969799), ), ), ], ), ), - Container( - height: 183.h, - child: ListView.builder( - padding: EdgeInsets.zero, - itemCount:1, - scrollDirection: Axis.vertical, - shrinkWrap: true, - physics: BouncingScrollPhysics(), - itemBuilder: (context, position) { - return GestureDetector( - onTap: () { - }, - child: goodsTypeItem(), - ); - }, - ), - ) + (goodsTypeSalesList == null || goodsTypeSalesList.length == 0) + ? NoDataView( + src: "assets/image/xiao_fei.webp", + isShowBtn: false, + text: "暂无数据", + fontSize: 16.sp, + margin: EdgeInsets.all(20.h), + ) + : Container( + height: 220.h, + child: ListView.builder( + padding: EdgeInsets.zero, + itemCount: goodsTypeSalesList?.length ?? 0, + scrollDirection: Axis.vertical, + shrinkWrap: true, + physics: BouncingScrollPhysics(), + itemBuilder: (context, position) { + return GestureDetector( + onTap: () {}, + child: goodsTypeItem( + goodsTypeSalesList[position], position), + ); + }, + ), + ) ], ), ), @@ -380,26 +706,28 @@ class _TradeGoods extends State { ); } - Widget goodsTypeItem(){ + Widget goodsTypeItem(GoodsTypeSalesList goodsTypeSalesList, int index) { return Container( - color: Color(0xFFF9FAF8), - padding: EdgeInsets.only(top:8.h,left: 11.w,right:24.w,bottom:7.h), - child:Row( + color: index % 2 == 0 ? Color(0xFFF9FAF8) : Colors.white, + padding: EdgeInsets.only(top: 8.h, left: 11.w, right: 24.w, bottom: 7.h), + child: Row( children: [ - Expanded(child:Text( - "招牌奶", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.medium, - color:Color(0xFF000000), + Expanded( + child: Text( + goodsTypeSalesList?.name ?? "", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF000000), + ), ), - ),), + ), Text( - "3423", + goodsTypeSalesList?.value ?? "", style: TextStyle( fontSize: 12.sp, fontWeight: MyFontWeight.medium, - color:Color(0xFF000000), + color: Color(0xFF000000), ), ), ], @@ -408,35 +736,38 @@ class _TradeGoods extends State { } ///单品销量报表 - Widget singleSalesStatement(){ + Widget singleSalesStatement() { return Container( - padding: EdgeInsets.only(top:23.h,bottom:45.h), + padding: EdgeInsets.only(top: 23.h, bottom: 45.h), child: Column( children: [ - Padding(padding:EdgeInsets.only(left:16.w,bottom: 15.h), - child:Row( + Padding( + padding: EdgeInsets.only(left: 16.w, bottom: 15.h), + child: Row( children: [ Container( width: 4.w, height: 16.h, color: Color(0xFF30415B), - margin: EdgeInsets.only(right:12.w), + margin: EdgeInsets.only(right: 12.w), ), Text( "单品销量报表", style: TextStyle( fontSize: 15.sp, fontWeight: MyFontWeight.semi_bold, - color:Color(0xFF0D0D0D), + color: Color(0xFF0D0D0D), ), ), - SizedBox(width:8.w,), + SizedBox( + width: 8.w, + ), Text( "比上周一同时段", style: TextStyle( fontSize: 12.sp, fontWeight: MyFontWeight.regular, - color:Color(0xFF666666), + color: Color(0xFF666666), ), ) ], @@ -455,73 +786,93 @@ class _TradeGoods extends State { children: [ Container( color: Color(0xFFF3F7FF), - padding: EdgeInsets.only(top: 7.h,left:17.w,bottom: 8.h), + padding: EdgeInsets.only(top: 7.h, left: 17.w, bottom: 8.h), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - Expanded(child:Text( - "分类", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.medium, - color:Color(0xFF969799), + Expanded( + child: Text( + "分类", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF969799), + ), ), - ),flex: 2,), - Expanded(child:Text( - "名称", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.medium, - color:Color(0xFF969799), + flex: 2, + ), + Expanded( + child: Text( + "名称", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF969799), + ), ), - ),flex: 2,), - Expanded(child:Text( - "销售额", - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.medium, - color:Color(0xFF969799), + flex: 2, + ), + Expanded( + child: Text( + "销售额", + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF969799), + ), ), - ),), - Expanded(child:Text( - "单价", - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.medium, - color:Color(0xFF969799), + ), + Expanded( + child: Text( + "单价", + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF969799), + ), ), - ),), - Expanded(child:Text( - "销量", - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.medium, - color:Color(0xFF969799), + ), + Expanded( + child: Text( + "销量", + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF969799), + ), ), - ),), + ), ], ), ), - Container( - height: 203.h, - child: ListView.builder( - padding: EdgeInsets.zero, - itemCount:5, - scrollDirection: Axis.vertical, - shrinkWrap: true, - physics: BouncingScrollPhysics(), - itemBuilder: (context, position) { - return GestureDetector( - onTap: () { - }, - child: singleSalesItem(), - ); - }, - ), - ) + (singleSalesList == null || singleSalesList.length == 0) + ? NoDataView( + src: "assets/image/xiao_fei.webp", + isShowBtn: false, + text: "暂无数据", + fontSize: 16.sp, + margin: EdgeInsets.all(20.h), + ) + : Container( + height: 243.h, + child: ListView.builder( + padding: EdgeInsets.zero, + itemCount: singleSalesList?.length ?? 0, + scrollDirection: Axis.vertical, + shrinkWrap: true, + physics: BouncingScrollPhysics(), + itemBuilder: (context, position) { + return GestureDetector( + onTap: () {}, + child: singleSalesItem( + singleSalesList[position], position), + ); + }, + ), + ) ], ), ), @@ -530,59 +881,71 @@ class _TradeGoods extends State { ); } - Widget singleSalesItem(){ + Widget singleSalesItem(SingleSalesList singleSalesList, int index) { return Container( - color: Color(0xFFF9FAF8), - padding: EdgeInsets.only(top:8.h,left:16.w,bottom:7.h), - child:Row( + color: index % 2 == 0 ? Color(0xFFF9FAF8) : Colors.white, + padding: EdgeInsets.only(top: 8.h, left: 16.w, bottom: 7.h), + child: Row( children: [ - Expanded(child:Text( - "金贵牛肉面", - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.medium, - color:Color(0xFF000000), + Expanded( + child: Text( + singleSalesList?.productGroupName ?? "", + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF000000), + ), ), - ),flex: 2,), - Expanded(child:Text( - "番茄牛肉面", - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.medium, - color:Color(0xFF000000), + flex: 2, + ), + Expanded( + child: Text( + singleSalesList?.productName ?? "", + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF000000), + ), ), - ),flex: 2,), - Expanded(child:Text( - "3423", - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.medium, - color:Color(0xFF000000), + flex: 2, + ), + Expanded( + child: Text( + singleSalesList?.sumPrice ?? "", + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF000000), + ), ), - ),), - Expanded(child:Text( - "113", - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.medium, - color:Color(0xFF000000), + ), + Expanded( + child: Text( + singleSalesList?.sellPrict ?? "", + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF000000), + ), ), - ),), - Expanded(child:Text( - "3423", - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.medium, - color:Color(0xFF000000), + ), + Expanded( + child: Text( + (singleSalesList?.saleNum ?? 0).toString(), + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: Color(0xFF000000), + ), ), - ),), + ), ], ), ); diff --git a/lib/business_system/home/overview/trade_order.dart b/lib/business_system/home/overview/trade_order.dart index 418ca22a..5b85f02c 100644 --- a/lib/business_system/home/overview/trade_order.dart +++ b/lib/business_system/home/overview/trade_order.dart @@ -354,7 +354,7 @@ class _TradeOrder extends State { margin: EdgeInsets.only(right:12.w), ), Text( - "订单趋势", + "订单量趋势", style: TextStyle( fontSize: 15.sp, fontWeight: MyFontWeight.semi_bold, diff --git a/lib/business_system/home/overview/trade_overview_page.dart b/lib/business_system/home/overview/trade_overview_page.dart index a63d4808..8f84d573 100644 --- a/lib/business_system/home/overview/trade_overview_page.dart +++ b/lib/business_system/home/overview/trade_overview_page.dart @@ -6,9 +6,14 @@ import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import '../../../generated/l10n.dart'; import '../../../view_widget/my_tab.dart'; class TradeOverviewPage extends StatefulWidget { + final arguments; + + TradeOverviewPage({this.arguments}); + @override State createState() { return _TradeOverviewPage(); @@ -17,10 +22,12 @@ class TradeOverviewPage extends StatefulWidget { class _TradeOverviewPage extends State with SingleTickerProviderStateMixin{ final RefreshController refreshController = RefreshController(); + String storeId; @override void initState() { super.initState(); + storeId = widget?.arguments["storeId"] ??""; } @override @@ -55,7 +62,7 @@ class _TradeOverviewPage extends State with SingleTickerProvi //指示器与文字等宽 tabs: [ MyTab(text:"总览"), - MyTab(text: "订单"), + MyTab(text: S.of(context).dingdan), MyTab(text: "商品"), ], ), @@ -64,7 +71,7 @@ class _TradeOverviewPage extends State with SingleTickerProvi children: [ TradeSummary(), TradeOrder(), - TradeGoods(),], + TradeGoods(storeId),], ), ), ); diff --git a/lib/business_system/order/request_refund.dart b/lib/business_system/order/request_refund.dart index a07ae6f3..9317b52d 100644 --- a/lib/business_system/order/request_refund.dart +++ b/lib/business_system/order/request_refund.dart @@ -58,7 +58,7 @@ class _RequestRefund extends State { resizeToAvoidBottomInset: false, backgroundColor: Color(0xFFF8F8FA), appBar: MyAppBar( - title: "申请退款", + title: S.of(context).shenqingtuikuan, titleColor: Colors.black, background: Colors.white, leadingColor: Colors.black, diff --git a/lib/main.dart b/lib/main.dart index 1032f910..11d4d355 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -473,11 +473,11 @@ Map routers = { '/router/business_page': (context, {arguments}) => BusinessPage(arguments: arguments), '/router/flow_page': (context, {arguments}) => - FlowPage(), + FlowPage(arguments: arguments), '/router/select_shop': (context, {arguments}) => SelectShop(arguments:arguments), '/router/trade_overview_page': (context, {arguments}) => - TradeOverviewPage(), + TradeOverviewPage(arguments: arguments,), '/router/goods_search_page': (context, {arguments}) => GoodsSearchPage(arguments: arguments), '/router/goods_assort': (context, {arguments}) => diff --git a/lib/retrofit/business_api.dart b/lib/retrofit/business_api.dart index ba598b42..ea803232 100644 --- a/lib/retrofit/business_api.dart +++ b/lib/retrofit/business_api.dart @@ -14,7 +14,10 @@ import 'package:retrofit/retrofit.dart'; import '../utils/flutter_utils.dart'; import 'data/base_data.dart'; +import 'data/day_flow_list.dart'; +import 'data/goods_type_sales_list.dart'; import 'data/popular_sales_list.dart'; +import 'data/single_sales_list.dart'; part 'business_api.g.dart'; @@ -147,4 +150,18 @@ abstract class BusinessApiService { @GET("largeScreenReport/getDayCounts?date={date}") Future> vipCounts( @Path("date") String date); + + ///今日流水/isMonth=0(当月数据),isMonth=1(当日数据) + @GET("dashBoard/order?yearMonth={yearMonth}&isMonth={isMonth}") + Future>> dayFlow( + @Path("yearMonth") String yearMonth, @Path("isMonth") String isMonth); + + ///每日单品销量/单品销量报表 + @POST("audit/salesLeaderboard") + Future>> singleSales(@Body() Map param); + + ///各类商品销售状况统计/商品种类销售数据 + @POST("audit/allKindsSalesStatistics") + Future>> goodsSalesList(@Body() Map param); + } diff --git a/lib/retrofit/business_api.g.dart b/lib/retrofit/business_api.g.dart index 59638941..56114271 100644 --- a/lib/retrofit/business_api.g.dart +++ b/lib/retrofit/business_api.g.dart @@ -134,4 +134,79 @@ class _BusinessApiService implements BusinessApiService { return value; } + @override + Future>> dayFlow(yearMonth,isMonth) async { + ArgumentError.checkNotNull(yearMonth, 'yearMonth'); + ArgumentError.checkNotNull(isMonth, 'isMonth'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + final _result = await _dio.request>( + 'dashBoard/order?yearMonth=$yearMonth&isMonth=$isMonth', + queryParameters: queryParameters, + options: RequestOptions( + method: 'GET', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData>.fromJson( + _result.data, + (json) => (json as List) + .map( + (i) => DayFlowList.fromJson(i as Map)) + .toList()); + return value; + } + + @override + Future>> singleSales(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>( + 'audit/salesLeaderboard', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData>.fromJson( + _result.data, + (json) => (json as List) + .map( + (i) => SingleSalesList.fromJson(i as Map)) + .toList()); + return value; + } + + @override + Future>> goodsSalesList(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>( + 'audit/allKindsSalesStatistics', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData>.fromJson( + _result.data, + (json) => (json as List) + .map( + (i) => GoodsTypeSalesList.fromJson(i as Map)) + .toList()); + return value; + } + } diff --git a/lib/retrofit/data/day_flow_list.dart b/lib/retrofit/data/day_flow_list.dart new file mode 100644 index 00000000..ef959b3b --- /dev/null +++ b/lib/retrofit/data/day_flow_list.dart @@ -0,0 +1,93 @@ +/// localDate : null +/// localDateTime : "2023-09-04 12:18:20" +/// count : 0 +/// amount : "19.00" +/// refundAmount : "0.00" +/// storeName : "屏东剉冰店(烧冷冰)" +/// nickname : null +/// phone : null + +class DayFlowList { + DayFlowList({ + dynamic localDate, + String localDateTime, + num count, + String amount, + String refundAmount, + String storeName, + dynamic nickname, + dynamic phone,}){ + _localDate = localDate; + _localDateTime = localDateTime; + _count = count; + _amount = amount; + _refundAmount = refundAmount; + _storeName = storeName; + _nickname = nickname; + _phone = phone; +} + + DayFlowList.fromJson(dynamic json) { + _localDate = json['localDate']; + _localDateTime = json['localDateTime']; + _count = json['count']; + _amount = json['amount']; + _refundAmount = json['refundAmount']; + _storeName = json['storeName']; + _nickname = json['nickname']; + _phone = json['phone']; + } + dynamic _localDate; + String _localDateTime; + num _count; + String _amount; + String _refundAmount; + String _storeName; + dynamic _nickname; + dynamic _phone; +DayFlowList copyWith({ dynamic localDate, + String localDateTime, + num count, + String amount, + String refundAmount, + String storeName, + dynamic nickname, + dynamic phone, +}) => DayFlowList( localDate: localDate ?? _localDate, + localDateTime: localDateTime ?? _localDateTime, + count: count ?? _count, + amount: amount ?? _amount, + refundAmount: refundAmount ?? _refundAmount, + storeName: storeName ?? _storeName, + nickname: nickname ?? _nickname, + phone: phone ?? _phone, + +); + dynamic get localDate => _localDate; + String get localDateTime => _localDateTime; + num get count => _count; + String get amount => _amount; + String get refundAmount => _refundAmount; + String get storeName => _storeName; + dynamic get nickname => _nickname; + dynamic get phone => _phone; + List detailList; + + + + Map toJson() { + final map = {}; + map['localDate'] = _localDate; + map['localDateTime'] = _localDateTime; + map['count'] = _count; + map['amount'] = _amount; + map['refundAmount'] = _refundAmount; + map['storeName'] = _storeName; + map['nickname'] = _nickname; + map['phone'] = _phone; + return map; + } + + + +} \ No newline at end of file diff --git a/lib/retrofit/data/goods_type_sales_list.dart b/lib/retrofit/data/goods_type_sales_list.dart new file mode 100644 index 00000000..ef6db0db --- /dev/null +++ b/lib/retrofit/data/goods_type_sales_list.dart @@ -0,0 +1,51 @@ +/// name : "筒仔米糕" +/// value : "10.00" +/// sale : "1" +/// percentage : "0.0059" + +class GoodsTypeSalesList { + GoodsTypeSalesList({ + String name, + String value, + String sale, + String percentage,}){ + _name = name; + _value = value; + _sale = sale; + _percentage = percentage; +} + + GoodsTypeSalesList.fromJson(dynamic json) { + _name = json['name']; + _value = json['value']; + _sale = json['sale']; + _percentage = json['percentage']; + } + String _name; + String _value; + String _sale; + String _percentage; +GoodsTypeSalesList copyWith({ String name, + String value, + String sale, + String percentage, +}) => GoodsTypeSalesList( name: name ?? _name, + value: value ?? _value, + sale: sale ?? _sale, + percentage: percentage ?? _percentage, +); + String get name => _name; + String get value => _value; + String get sale => _sale; + String get percentage => _percentage; + + Map toJson() { + final map = {}; + map['name'] = _name; + map['value'] = _value; + map['sale'] = _sale; + map['percentage'] = _percentage; + return map; + } + +} \ No newline at end of file diff --git a/lib/retrofit/data/order_trend.dart b/lib/retrofit/data/order_trend.dart index 0cce029b..53d3389b 100644 --- a/lib/retrofit/data/order_trend.dart +++ b/lib/retrofit/data/order_trend.dart @@ -4,7 +4,7 @@ class OrderTrend { OrderTrend({ String date, - num number,}){ + dynamic number,}){ _date = date; _number = number; } @@ -16,12 +16,12 @@ class OrderTrend { String _date; num _number; OrderTrend copyWith({ String date, - num number, + dynamic number, }) => OrderTrend( date: date ?? _date, number: number ?? _number, ); String get date => _date; - num get number => _number; + dynamic get number => _number; Map toJson() { final map = {}; diff --git a/lib/retrofit/data/single_sales_list.dart b/lib/retrofit/data/single_sales_list.dart new file mode 100644 index 00000000..776baa58 --- /dev/null +++ b/lib/retrofit/data/single_sales_list.dart @@ -0,0 +1,141 @@ +/// productId : null +/// saleNum : 16 +/// productName : "米粉汤" +/// productType : null +/// productGroupName : "米粉汤" +/// sumPrice : "256.00" +/// sellPrict : "16.00" +/// productSkuName : "" +/// productSkuList : null +/// platterLsit : null +/// giveNum : 0 +/// refundNum : 0 +/// productCountPercent : 0.11 +/// productSellPricePercent : 0.11 + +class SingleSalesList { + SingleSalesList({ + dynamic productId, + num saleNum, + String productName, + dynamic productType, + String productGroupName, + String sumPrice, + String sellPrict, + String productSkuName, + dynamic productSkuList, + dynamic platterLsit, + num giveNum, + num refundNum, + num productCountPercent, + num productSellPricePercent,}){ + _productId = productId; + _saleNum = saleNum; + _productName = productName; + _productType = productType; + _productGroupName = productGroupName; + _sumPrice = sumPrice; + _sellPrict = sellPrict; + _productSkuName = productSkuName; + _productSkuList = productSkuList; + _platterLsit = platterLsit; + _giveNum = giveNum; + _refundNum = refundNum; + _productCountPercent = productCountPercent; + _productSellPricePercent = productSellPricePercent; +} + + SingleSalesList.fromJson(dynamic json) { + _productId = json['productId']; + _saleNum = json['saleNum']; + _productName = json['productName']; + _productType = json['productType']; + _productGroupName = json['productGroupName']; + _sumPrice = json['sumPrice']; + _sellPrict = json['sellPrict']; + _productSkuName = json['productSkuName']; + _productSkuList = json['productSkuList']; + _platterLsit = json['platterLsit']; + _giveNum = json['giveNum']; + _refundNum = json['refundNum']; + _productCountPercent = json['productCountPercent']; + _productSellPricePercent = json['productSellPricePercent']; + } + dynamic _productId; + num _saleNum; + String _productName; + dynamic _productType; + String _productGroupName; + String _sumPrice; + String _sellPrict; + String _productSkuName; + dynamic _productSkuList; + dynamic _platterLsit; + num _giveNum; + num _refundNum; + num _productCountPercent; + num _productSellPricePercent; +SingleSalesList copyWith({ dynamic productId, + num saleNum, + String productName, + dynamic productType, + String productGroupName, + String sumPrice, + String sellPrict, + String productSkuName, + dynamic productSkuList, + dynamic platterLsit, + num giveNum, + num refundNum, + num productCountPercent, + num productSellPricePercent, +}) => SingleSalesList( productId: productId ?? _productId, + saleNum: saleNum ?? _saleNum, + productName: productName ?? _productName, + productType: productType ?? _productType, + productGroupName: productGroupName ?? _productGroupName, + sumPrice: sumPrice ?? _sumPrice, + sellPrict: sellPrict ?? _sellPrict, + productSkuName: productSkuName ?? _productSkuName, + productSkuList: productSkuList ?? _productSkuList, + platterLsit: platterLsit ?? _platterLsit, + giveNum: giveNum ?? _giveNum, + refundNum: refundNum ?? _refundNum, + productCountPercent: productCountPercent ?? _productCountPercent, + productSellPricePercent: productSellPricePercent ?? _productSellPricePercent, +); + dynamic get productId => _productId; + num get saleNum => _saleNum; + String get productName => _productName; + dynamic get productType => _productType; + String get productGroupName => _productGroupName; + String get sumPrice => _sumPrice; + String get sellPrict => _sellPrict; + String get productSkuName => _productSkuName; + dynamic get productSkuList => _productSkuList; + dynamic get platterLsit => _platterLsit; + num get giveNum => _giveNum; + num get refundNum => _refundNum; + num get productCountPercent => _productCountPercent; + num get productSellPricePercent => _productSellPricePercent; + + Map toJson() { + final map = {}; + map['productId'] = _productId; + map['saleNum'] = _saleNum; + map['productName'] = _productName; + map['productType'] = _productType; + map['productGroupName'] = _productGroupName; + map['sumPrice'] = _sumPrice; + map['sellPrict'] = _sellPrict; + map['productSkuName'] = _productSkuName; + map['productSkuList'] = _productSkuList; + map['platterLsit'] = _platterLsit; + map['giveNum'] = _giveNum; + map['refundNum'] = _refundNum; + map['productCountPercent'] = _productCountPercent; + map['productSellPricePercent'] = _productSellPricePercent; + return map; + } + +} \ No newline at end of file diff --git a/lib/retrofit/min_api.dart b/lib/retrofit/min_api.dart index c8cf737b..295b20f1 100644 --- a/lib/retrofit/min_api.dart +++ b/lib/retrofit/min_api.dart @@ -27,7 +27,7 @@ import 'data/shopping_home_config.dart'; part 'min_api.g.dart'; -const localBaseUrl = "http://app-api.test.yixinhuixiang.com/app/";///本地 +const localBaseUrl = "http://192.168.10.78:8765/app/";///本地 // const localBaseUrl = "http://pos-test.api.lotus-wallet.com/app/";///测试 const serviceBaseUrl = "https://pos.api.lotus-wallet.com/app/";///线上 diff --git a/lib/retrofit/retrofit_api.dart b/lib/retrofit/retrofit_api.dart index 686a8ffb..42d73803 100644 --- a/lib/retrofit/retrofit_api.dart +++ b/lib/retrofit/retrofit_api.dart @@ -66,7 +66,7 @@ import 'data/wx_pay.dart'; part 'retrofit_api.g.dart'; -const localBaseUrl = "http://platform-api.test.yixinhuixiang.com/app/";///本地 +const localBaseUrl = "http://192.168.10.78:8766/app/";///本地 // const localBaseUrl = "http://platform.test.api.lotus-wallet.com/app/";///测试 const serviceBaseUrl = "https://pos.platform.lotus-wallet.com/app/"; diff --git a/pubspec.lock b/pubspec.lock index cda17e50..9f3eb3cb 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -78,6 +78,20 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.3.1" + charts_common: + dependency: transitive + description: + name: charts_common + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.12.0" + charts_flutter: + dependency: "direct main" + description: + name: charts_flutter + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.12.0" chewie: dependency: transitive description: @@ -419,7 +433,7 @@ packages: name: image_pickers url: "https://pub.flutter-io.cn" source: hosted - version: "2.0.4+1" + version: "2.0.0" intl: dependency: "direct main" description: @@ -865,7 +879,7 @@ packages: name: tobias url: "https://pub.flutter-io.cn" source: hosted - version: "2.4.2" + version: "2.4.1" tpns_flutter_plugin: dependency: "direct main" description: