Commit b2a5378257a693b4d101ef96aa6842a0bf41c103

Authored by wdn127929
1 parent e15b7897

我的OK

@@ -240,5 +240,7 @@ class HttpUrl { @@ -240,5 +240,7 @@ class HttpUrl {
240 "?service=Android.Reserve.NewGetUntreatedMsgList"; //根据不同得消息类型获取对应得消息列表 240 "?service=Android.Reserve.NewGetUntreatedMsgList"; //根据不同得消息类型获取对应得消息列表
241 static const String new_get_message_list = 241 static const String new_get_message_list =
242 "?service=Android.Reserve.NewGetMessageList"; //根据不同得消息类型获取对应得消息列表 242 "?service=Android.Reserve.NewGetMessageList"; //根据不同得消息类型获取对应得消息列表
  243 + static const String get_seller_reserve_total =
  244 + "?service=Android.Reserve.GetSellerReserveTotal"; // 获取商家时间区间内订单数量
243 245
244 } 246 }
@@ -57,6 +57,9 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver { @@ -57,6 +57,9 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver {
57 }); 57 });
58 }); 58 });
59 WidgetsBinding.instance.addPostFrameCallback((_) async { 59 WidgetsBinding.instance.addPostFrameCallback((_) async {
  60 + ///获取商家时间区间内订单数量
  61 + _getSellerReserveTotal();
  62 +
60 ///获取短信余量 63 ///获取短信余量
61 _getSmsInfo(context); 64 _getSmsInfo(context);
62 65
@@ -122,6 +125,11 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver { @@ -122,6 +125,11 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver {
122 await myModel.getMyIntegral(context); 125 await myModel.getMyIntegral(context);
123 } 126 }
124 127
  128 + ///获取商家时间区间内订单数量
  129 + _getSellerReserveTotal() async {
  130 + await myModel.getSellerReserveTotal(context);
  131 + }
  132 +
125 //检查版本更新 133 //检查版本更新
126 checkUpdate() { 134 checkUpdate() {
127 UpdateModelMy updateModel = new UpdateModelMy(); 135 UpdateModelMy updateModel = new UpdateModelMy();
@@ -361,7 +369,7 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver { @@ -361,7 +369,7 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver {
361 Row( 369 Row(
362 children: [ 370 children: [
363 Text( 371 Text(
364 - '3555', 372 + myModel.reserveTotal,
365 style: TextStyle( 373 style: TextStyle(
366 color: MyColours.color_515151, 374 color: MyColours.color_515151,
367 fontSize: ScreenUtil().setSp(40)), 375 fontSize: ScreenUtil().setSp(40)),
@@ -8,12 +8,14 @@ import 'package:one_key/net/dio_util.dart'; @@ -8,12 +8,14 @@ import 'package:one_key/net/dio_util.dart';
8 import 'package:one_key/net/http_url.dart'; 8 import 'package:one_key/net/http_url.dart';
9 import 'package:one_key/provider/SmsModel.dart'; 9 import 'package:one_key/provider/SmsModel.dart';
10 import 'package:one_key/provider/user_model.dart'; 10 import 'package:one_key/provider/user_model.dart';
  11 +import 'package:one_key/utils/time_machine_util.dart';
11 import 'package:one_key/utils/utils.dart'; 12 import 'package:one_key/utils/utils.dart';
12 import 'package:provider/provider.dart'; 13 import 'package:provider/provider.dart';
13 14
14 class MyModel extends ChangeNotifier { 15 class MyModel extends ChangeNotifier {
15 String smsInfo = ''; 16 String smsInfo = '';
16 IntegralSunModel integralSunModel; 17 IntegralSunModel integralSunModel;
  18 + String reserveTotal = '';
17 19
18 /// 短信余量查询及套餐查询接口 20 /// 短信余量查询及套餐查询接口
19 Future<SmsInfoData> getSmsInfo(BuildContext context) async { 21 Future<SmsInfoData> getSmsInfo(BuildContext context) async {
@@ -94,4 +96,44 @@ class MyModel extends ChangeNotifier { @@ -94,4 +96,44 @@ class MyModel extends ChangeNotifier {
94 } 96 }
95 } 97 }
96 } 98 }
  99 +
  100 + /// 获取商家时间区间内订单数量
  101 + getSellerReserveTotal(BuildContext context) async {
  102 + Map<String, String> dateMap = TimeMachineUtil.getMonthDate(0);
  103 + Map<String, String> params = {
  104 + "sid": Provider.of<UserModel>(context, listen: false).user.sellerid,
  105 + "stime":
  106 + ((int.parse(dateMap['startDateStamp']) / 1000).floor()).toString(),
  107 + "etime": ((int.parse(dateMap['endDateStamp']) / 1000).floor()).toString(),
  108 + };
  109 + print(params);
  110 + try {
  111 + BaseResp<dynamic> baseResp = await DioUtil()
  112 + .request<dynamic>(
  113 + context, Method.get, HttpUrl.get_seller_reserve_total,
  114 + data: params, showLoading: false)
  115 + .catchError((error) {
  116 + print(error.toString());
  117 + });
  118 +
  119 + if (baseResp?.code == Constant.status_success) {
  120 + reserveTotal = baseResp.data;
  121 + } else {}
  122 + notifyListeners();
  123 + } catch (error) {
  124 + if (error is MyError) {
  125 + switch (error.type) {
  126 + case 1:
  127 + print('错误');
  128 + break;
  129 + case 2:
  130 + print('超时');
  131 + break;
  132 + default:
  133 + print('错误');
  134 + break;
  135 + }
  136 + }
  137 + }
  138 + }
97 } 139 }
  1 +/*
  2 + * @Description: 假如我可以用程序回到某一年的某一天 我想我现在应该是开着豪车 搂着mm 不是在蹦迪就是在蹦迪的路上😏
  3 + * @Author: Nathan暗黑时代
  4 + * @Date: 2019-09-17 14:00:33
  5 + */
  6 +
  7 +import 'package:common_utils/common_utils.dart';
  8 +
  9 +class TimeMachineUtil {
  10 + /**
  11 + * 获取某一年的第一个月的第一天和最后一个月的最后一天
  12 + */
  13 + static getStartEndYearDate(int iYear) {
  14 + Map mapDate = new Map();
  15 + int yearNow = DateTime.now().year;
  16 + yearNow = yearNow + iYear;
  17 +
  18 + String newStartYear = '$yearNow' + '-' + '01' + '-' + '01';
  19 + String newEndtYear = (yearNow + 1).toString() + '-' + '01' + '-' + '00';
  20 +
  21 + mapDate['startTime'] = DateUtil.formatDate(
  22 + DateTime.fromMillisecondsSinceEpoch(turnTimestamp(newStartYear)),
  23 + format: 'yyyy-MM-dd');
  24 + mapDate['endTime'] = DateUtil.formatDate(
  25 + DateTime.fromMillisecondsSinceEpoch(turnTimestamp(newEndtYear)),
  26 + format: 'yyyy-MM-dd');
  27 +
  28 + mapDate['startStamp'] = turnTimestamp(mapDate['startTime'] + ' 00:00:00');
  29 + mapDate['endStamp'] = turnTimestamp(mapDate['endTime'] + ' 23:59:59');
  30 + print('某一年初和年末:$mapDate');
  31 + }
  32 +
  33 + /**
  34 + * 获得当前日期 未来/过去 第某个月第一天和最后一天时间
  35 + */
  36 + static Map<String, String> getMonthDate(int iMonth) {
  37 + //获取当前日期
  38 + var currentDate = new DateTime.now();
  39 + if (iMonth + currentDate.month > 0) {
  40 + return timeConversion(
  41 + iMonth + currentDate.month, (currentDate.year).toString());
  42 + } else {
  43 + int beforeYear = (iMonth + currentDate.month) ~/ 12;
  44 + String yearNew = (currentDate.year + beforeYear - 1).toString();
  45 + int monthNew = (iMonth + currentDate.month) - beforeYear * 12;
  46 + return timeConversion(12 + monthNew, yearNew);
  47 + }
  48 + }
  49 +
  50 + static Map<String, String> timeConversion(int monthTime, String yearTime) {
  51 + Map<String, String> dateMap = Map();
  52 + dateMap['startDate'] = '$yearTime' +
  53 + '-' +
  54 + (monthTime < 10 ? '0' + monthTime.toString() : '$monthTime') +
  55 + '-' +
  56 + '01';
  57 + //转时间戳再转时间格式 防止出错
  58 + dateMap['startDate'] = DateUtil.formatDate(
  59 + DateTime.fromMillisecondsSinceEpoch(
  60 + turnTimestamp(dateMap['startDate'])),
  61 + format: 'yyyy-MM-dd');
  62 + //某个月结束时间,转时间戳再转
  63 + String endMonth = '$yearTime' +
  64 + '-' +
  65 + ((monthTime + 1) < 10
  66 + ? '0' + (monthTime + 1).toString()
  67 + : (monthTime + 1))
  68 + .toString() +
  69 + '-' +
  70 + '00';
  71 + var endMonthTimeStamp = turnTimestamp(endMonth);
  72 + endMonth = DateUtil.formatDate(
  73 + DateTime.fromMillisecondsSinceEpoch(endMonthTimeStamp),
  74 + format: 'yyyy-MM-dd');
  75 + dateMap['endDate'] = endMonth;
  76 + //这里是为了公司后台接口 需加时间段的时间戳 但不显示在格式化实践中
  77 + dateMap['startDateStamp'] =
  78 + turnTimestamp(dateMap['startDate'] + ' 00:00:00').toString();
  79 + dateMap['endDateStamp'] =
  80 + turnTimestamp(dateMap['endDate'] + ' 23:59:59').toString();
  81 + print('过去未来某个月初月末:$dateMap');
  82 + return dateMap;
  83 + }
  84 +
  85 + /**
  86 + * 转时间戳
  87 + */
  88 + static int turnTimestamp(String timestamp) {
  89 + return DateTime.parse(timestamp).millisecondsSinceEpoch;
  90 + }
  91 +
  92 + /**
  93 + * 当前时间 过去/未来 某个周的周一和周日
  94 + */
  95 + static void getWeeksDate(int weeks) {
  96 + Map<String, String> mapTime = new Map();
  97 + DateTime now = new DateTime.now();
  98 + int weekday = now.weekday; //今天周几
  99 +
  100 + var sunDay = getTimestampLatest(false, 7 - weekday + weeks * 7); //周末
  101 + var monDay = getTimestampLatest(true, -weekday + 1 + weeks * 7); //周一
  102 +
  103 + mapTime['monDay'] =
  104 + DateUtil.formatDate(DateTime.fromMillisecondsSinceEpoch(sunDay),
  105 + // isUtc: true,
  106 + format: 'yyyy-MM-dd'); //周一 时间格式化
  107 + mapTime['sunDay'] = DateUtil.formatDate(
  108 + DateTime.fromMillisecondsSinceEpoch(monDay),
  109 + format: 'yyyy-MM-dd'); //周一 时间格式化
  110 + mapTime['monDayStamp'] = '$monDay'; //周一 时间戳
  111 + mapTime['sunDayStamp'] = '$sunDay'; //周日 时间戳
  112 + print('某个周的周一和周日:$mapTime');
  113 + }
  114 +
  115 + /**
  116 + * phase : 是零点还是23:59:59
  117 + */
  118 + static int getTimestampLatest(bool phase, int day) {
  119 + String newHours;
  120 + DateTime now = new DateTime.now();
  121 + DateTime sixtyDaysFromNow = now.add(new Duration(days: day));
  122 + String formattedDate = DateUtil.formatDate(sixtyDaysFromNow,
  123 + // isUtc: true,
  124 + format: 'yyyy-MM-dd');
  125 + if (phase) {
  126 + newHours = formattedDate + ' 00:00:00';
  127 + } else {
  128 + newHours = formattedDate + ' 23:59:59';
  129 + }
  130 +
  131 + DateTime newDate = DateTime.parse(newHours);
  132 + String newFormattedDate = DateUtil.formatDate(newDate,
  133 + // isUtc: true,
  134 + format: 'yyyy-MM-dd HH:mm:ss');
  135 + int timeStamp = newDate.millisecondsSinceEpoch;
  136 + // print('时间' + newFormattedDate);
  137 + return timeStamp;
  138 + }
  139 +}