Commit b2a5378257a693b4d101ef96aa6842a0bf41c103

Authored by wdn127929
1 parent e15b7897

我的OK

... ... @@ -240,5 +240,7 @@ class HttpUrl {
"?service=Android.Reserve.NewGetUntreatedMsgList"; //根据不同得消息类型获取对应得消息列表
static const String new_get_message_list =
"?service=Android.Reserve.NewGetMessageList"; //根据不同得消息类型获取对应得消息列表
static const String get_seller_reserve_total =
"?service=Android.Reserve.GetSellerReserveTotal"; // 获取商家时间区间内订单数量
}
... ...
... ... @@ -57,6 +57,9 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver {
});
});
WidgetsBinding.instance.addPostFrameCallback((_) async {
///获取商家时间区间内订单数量
_getSellerReserveTotal();
///获取短信余量
_getSmsInfo(context);
... ... @@ -122,6 +125,11 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver {
await myModel.getMyIntegral(context);
}
///获取商家时间区间内订单数量
_getSellerReserveTotal() async {
await myModel.getSellerReserveTotal(context);
}
//检查版本更新
checkUpdate() {
UpdateModelMy updateModel = new UpdateModelMy();
... ... @@ -361,7 +369,7 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver {
Row(
children: [
Text(
'3555',
myModel.reserveTotal,
style: TextStyle(
color: MyColours.color_515151,
fontSize: ScreenUtil().setSp(40)),
... ...
... ... @@ -8,12 +8,14 @@ import 'package:one_key/net/dio_util.dart';
import 'package:one_key/net/http_url.dart';
import 'package:one_key/provider/SmsModel.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/utils/time_machine_util.dart';
import 'package:one_key/utils/utils.dart';
import 'package:provider/provider.dart';
class MyModel extends ChangeNotifier {
String smsInfo = '';
IntegralSunModel integralSunModel;
String reserveTotal = '';
/// 短信余量查询及套餐查询接口
Future<SmsInfoData> getSmsInfo(BuildContext context) async {
... ... @@ -94,4 +96,44 @@ class MyModel extends ChangeNotifier {
}
}
}
/// 获取商家时间区间内订单数量
getSellerReserveTotal(BuildContext context) async {
Map<String, String> dateMap = TimeMachineUtil.getMonthDate(0);
Map<String, String> params = {
"sid": Provider.of<UserModel>(context, listen: false).user.sellerid,
"stime":
((int.parse(dateMap['startDateStamp']) / 1000).floor()).toString(),
"etime": ((int.parse(dateMap['endDateStamp']) / 1000).floor()).toString(),
};
print(params);
try {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(
context, Method.get, HttpUrl.get_seller_reserve_total,
data: params, showLoading: false)
.catchError((error) {
print(error.toString());
});
if (baseResp?.code == Constant.status_success) {
reserveTotal = baseResp.data;
} else {}
notifyListeners();
} catch (error) {
if (error is MyError) {
switch (error.type) {
case 1:
print('错误');
break;
case 2:
print('超时');
break;
default:
print('错误');
break;
}
}
}
}
}
... ...
/*
* @Description: 假如我可以用程序回到某一年的某一天 我想我现在应该是开着豪车 搂着mm 不是在蹦迪就是在蹦迪的路上😏
* @Author: Nathan暗黑时代
* @Date: 2019-09-17 14:00:33
*/
import 'package:common_utils/common_utils.dart';
class TimeMachineUtil {
/**
* 获取某一年的第一个月的第一天和最后一个月的最后一天
*/
static getStartEndYearDate(int iYear) {
Map mapDate = new Map();
int yearNow = DateTime.now().year;
yearNow = yearNow + iYear;
String newStartYear = '$yearNow' + '-' + '01' + '-' + '01';
String newEndtYear = (yearNow + 1).toString() + '-' + '01' + '-' + '00';
mapDate['startTime'] = DateUtil.formatDate(
DateTime.fromMillisecondsSinceEpoch(turnTimestamp(newStartYear)),
format: 'yyyy-MM-dd');
mapDate['endTime'] = DateUtil.formatDate(
DateTime.fromMillisecondsSinceEpoch(turnTimestamp(newEndtYear)),
format: 'yyyy-MM-dd');
mapDate['startStamp'] = turnTimestamp(mapDate['startTime'] + ' 00:00:00');
mapDate['endStamp'] = turnTimestamp(mapDate['endTime'] + ' 23:59:59');
print('某一年初和年末:$mapDate');
}
/**
* 获得当前日期 未来/过去 第某个月第一天和最后一天时间
*/
static Map<String, String> getMonthDate(int iMonth) {
//获取当前日期
var currentDate = new DateTime.now();
if (iMonth + currentDate.month > 0) {
return timeConversion(
iMonth + currentDate.month, (currentDate.year).toString());
} else {
int beforeYear = (iMonth + currentDate.month) ~/ 12;
String yearNew = (currentDate.year + beforeYear - 1).toString();
int monthNew = (iMonth + currentDate.month) - beforeYear * 12;
return timeConversion(12 + monthNew, yearNew);
}
}
static Map<String, String> timeConversion(int monthTime, String yearTime) {
Map<String, String> dateMap = Map();
dateMap['startDate'] = '$yearTime' +
'-' +
(monthTime < 10 ? '0' + monthTime.toString() : '$monthTime') +
'-' +
'01';
//转时间戳再转时间格式 防止出错
dateMap['startDate'] = DateUtil.formatDate(
DateTime.fromMillisecondsSinceEpoch(
turnTimestamp(dateMap['startDate'])),
format: 'yyyy-MM-dd');
//某个月结束时间,转时间戳再转
String endMonth = '$yearTime' +
'-' +
((monthTime + 1) < 10
? '0' + (monthTime + 1).toString()
: (monthTime + 1))
.toString() +
'-' +
'00';
var endMonthTimeStamp = turnTimestamp(endMonth);
endMonth = DateUtil.formatDate(
DateTime.fromMillisecondsSinceEpoch(endMonthTimeStamp),
format: 'yyyy-MM-dd');
dateMap['endDate'] = endMonth;
//这里是为了公司后台接口 需加时间段的时间戳 但不显示在格式化实践中
dateMap['startDateStamp'] =
turnTimestamp(dateMap['startDate'] + ' 00:00:00').toString();
dateMap['endDateStamp'] =
turnTimestamp(dateMap['endDate'] + ' 23:59:59').toString();
print('过去未来某个月初月末:$dateMap');
return dateMap;
}
/**
* 转时间戳
*/
static int turnTimestamp(String timestamp) {
return DateTime.parse(timestamp).millisecondsSinceEpoch;
}
/**
* 当前时间 过去/未来 某个周的周一和周日
*/
static void getWeeksDate(int weeks) {
Map<String, String> mapTime = new Map();
DateTime now = new DateTime.now();
int weekday = now.weekday; //今天周几
var sunDay = getTimestampLatest(false, 7 - weekday + weeks * 7); //周末
var monDay = getTimestampLatest(true, -weekday + 1 + weeks * 7); //周一
mapTime['monDay'] =
DateUtil.formatDate(DateTime.fromMillisecondsSinceEpoch(sunDay),
// isUtc: true,
format: 'yyyy-MM-dd'); //周一 时间格式化
mapTime['sunDay'] = DateUtil.formatDate(
DateTime.fromMillisecondsSinceEpoch(monDay),
format: 'yyyy-MM-dd'); //周一 时间格式化
mapTime['monDayStamp'] = '$monDay'; //周一 时间戳
mapTime['sunDayStamp'] = '$sunDay'; //周日 时间戳
print('某个周的周一和周日:$mapTime');
}
/**
* phase : 是零点还是23:59:59
*/
static int getTimestampLatest(bool phase, int day) {
String newHours;
DateTime now = new DateTime.now();
DateTime sixtyDaysFromNow = now.add(new Duration(days: day));
String formattedDate = DateUtil.formatDate(sixtyDaysFromNow,
// isUtc: true,
format: 'yyyy-MM-dd');
if (phase) {
newHours = formattedDate + ' 00:00:00';
} else {
newHours = formattedDate + ' 23:59:59';
}
DateTime newDate = DateTime.parse(newHours);
String newFormattedDate = DateUtil.formatDate(newDate,
// isUtc: true,
format: 'yyyy-MM-dd HH:mm:ss');
int timeStamp = newDate.millisecondsSinceEpoch;
// print('时间' + newFormattedDate);
return timeStamp;
}
}
... ...