book_set_time_model.dart
4.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:one_key/constant/constant.dart';
import 'package:one_key/models/get_seller_info_model.dart';
import 'package:one_key/models/seller_info.dart';
import 'package:one_key/models/set_seller_info_model.dart';
import 'package:one_key/net/base_resp.dart';
import 'package:one_key/net/dio_util.dart';
import 'package:one_key/net/http_url.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/utils/utils.dart';
import 'package:provider/provider.dart';
class BookSetTimeModel with ChangeNotifier {
//构造函数,初始化
BookSetTimeModel() {}
///获取某个商家下所有服务员信息 **** 取得某个商家的早市、午市、晚市营业时间
Future<SunSellerInfoModel> getManagersInfo(BuildContext context) async {
UserModel userModel = Provider.of<UserModel>(context, listen: false);
Map<String, String> params = {
"seller_id": userModel.user.sellerid,
"seller_openid": userModel.user.openid
};
BaseResp<Map<String, dynamic>> baseResp = await DioUtil()
.request<Map<String, dynamic>>(context, Method.get, HttpUrl.sellerinfo,
data: params)
.catchError((error) {
print(error.toString());
});
SunSellerInfoModel itemModel;
if (baseResp == null) return itemModel;
if (baseResp.code == Constant.status_success) {
if (int.parse(baseResp.status) != Constant.status_success) {
Utils.showToast(baseResp.msg ?? "");
return itemModel;
}
if (baseResp.responseData['data'] != null) {
itemModel = SellerInfoModel.fromJson(baseResp.responseData).data;
} else {
Utils.showToast(baseResp.msg ?? "");
}
return itemModel;
}
}
///根据商家ID修改商家信息
Future<SetSellerInfoSunModel> setSellerInfoById(
BuildContext context, Map daily) async {
UserModel userModel = Provider.of<UserModel>(context, listen: false);
Map<String, String> params = {
"id": userModel.user.sellerid,
"daily": jsonEncode(daily)
};
BaseResp<Map<String, dynamic>> baseResp = await DioUtil()
.request<Map<String, dynamic>>(
context, Method.get, HttpUrl.set_seller_info,
data: params)
.catchError((error) {
print(error.toString());
});
SetSellerInfoSunModel itemModel;
if (baseResp == null) return itemModel;
if (baseResp.code == Constant.status_success) {
if (int.parse(baseResp.status) != Constant.status_success) {
Utils.showToast(baseResp.msg ?? "");
return itemModel;
}
if (baseResp.responseData['data'] != null) {
itemModel = SetSellerInfoModel.fromJson(baseResp.responseData).data;
} else {
Utils.showToast(baseResp.msg ?? "");
}
return itemModel;
}
}
///根据商家ID获取商家信息
Future<GetSellerInfoSunModel> getSellerById(BuildContext context) async {
UserModel userModel = Provider.of<UserModel>(context, listen: false);
Map<String, String> params = {
"sellerid": userModel.user.sellerid,
};
BaseResp<Map<String, dynamic>> baseResp = await DioUtil()
.request<Map<String, dynamic>>(
context, Method.get, HttpUrl.get_seller_info,
data: params)
.catchError((error) {
print(error.toString());
});
GetSellerInfoSunModel itemModel;
if (baseResp == null) return itemModel;
if (baseResp.code == Constant.status_success) {
if (int.parse(baseResp.status) != Constant.status_success) {
Utils.showToast(baseResp.msg ?? "");
return itemModel;
}
if (baseResp.responseData['data'] != null) {
itemModel = GetSellerInfoModel.fromJson(baseResp.responseData).data;
} else {
Utils.showToast(baseResp.msg ?? "");
}
return itemModel;
}
}
///在线预订配置-接单时间
Future<bool> setReOrderTime(
BuildContext context, String start, String end) async {
UserModel userModel = Provider.of<UserModel>(context, listen: false);
Map<String, dynamic> params = {
"sellerid": int.parse(userModel.user.sellerid),
"start": start,
'end': end
};
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.set_order_time,
data: params)
.catchError((error) {
print(error.toString());
});
if (baseResp == null) return false;
if (baseResp.code == Constant.status_success) {
if (int.parse(baseResp.status) != Constant.status_success) {
Utils.showToast(baseResp.msg ?? "");
return false;
}
if (baseResp.responseData['ret'] == 200) {
// if (baseResp.responseData['data'] == 0) {
return true;
// } else {
// return false;
// }
} else {
Utils.showToast(baseResp.msg ?? "");
return false;
}
}
}
}