parent
c0ce37b0c5
commit
da18880042
@ -1,10 +1,25 @@
|
||||
import 'package:recook/constants/api_v2.dart';
|
||||
import 'package:recook/manager/http_manager.dart';
|
||||
import 'package:recook/pages/user/model/user_accumulate_model.dart';
|
||||
import 'package:recook/pages/user/model/user_benefit_model.dart';
|
||||
import 'package:recook/pages/user/model/user_month_income_model.dart';
|
||||
|
||||
class UserBenefitFunc {
|
||||
static Future<UserBenefitModel> update() async {
|
||||
ResultData result = await HttpManager.post(APIV2.userAPI.userBenefit, {});
|
||||
return UserBenefitModel.fromJson(result.data);
|
||||
}
|
||||
|
||||
static Future<UserAccumulateModel> accmulate() async {
|
||||
ResultData result = await HttpManager.post(APIV2.userAPI.accumulate, {});
|
||||
return UserAccumulateModel.fromJson(result.data);
|
||||
}
|
||||
|
||||
static Future<UserMonthIncomeModel> monthIncome({int month}) async {
|
||||
ResultData result = await HttpManager.post(
|
||||
APIV2.userAPI.monthIncome,
|
||||
{'year': month},
|
||||
);
|
||||
return UserMonthIncomeModel.fromJson(result.data);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,69 @@
|
||||
class UserAccumulateModel {
|
||||
String code;
|
||||
String msg;
|
||||
Data data;
|
||||
|
||||
UserAccumulateModel({this.code, this.msg, this.data});
|
||||
|
||||
UserAccumulateModel.fromJson(Map<String, dynamic> json) {
|
||||
code = json['code'];
|
||||
msg = json['msg'];
|
||||
data = json['data'] != null ? new Data.fromJson(json['data']) : null;
|
||||
}
|
||||
|
||||
UserAccumulateModel.zero() {
|
||||
code = '';
|
||||
msg = '';
|
||||
data = Data.zero();
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['code'] = this.code;
|
||||
data['msg'] = this.msg;
|
||||
if (this.data != null) {
|
||||
data['data'] = this.data.toJson();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Data {
|
||||
double purchaseAmount;
|
||||
double guideAmount;
|
||||
double teamAmount;
|
||||
double recommendAmount;
|
||||
double rewardAmount;
|
||||
|
||||
Data(
|
||||
{this.purchaseAmount,
|
||||
this.guideAmount,
|
||||
this.teamAmount,
|
||||
this.recommendAmount,
|
||||
this.rewardAmount});
|
||||
Data.zero() {
|
||||
this.purchaseAmount = 0;
|
||||
this.guideAmount = 0;
|
||||
this.teamAmount = 0;
|
||||
this.recommendAmount = 0;
|
||||
this.rewardAmount = 0;
|
||||
}
|
||||
|
||||
Data.fromJson(Map<String, dynamic> json) {
|
||||
purchaseAmount = json['purchaseAmount'] + .0;
|
||||
guideAmount = json['guideAmount'] + .0;
|
||||
teamAmount = json['teamAmount'] + .0;
|
||||
recommendAmount = json['recommendAmount'] + .0;
|
||||
rewardAmount = json['rewardAmount'] + .0;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['purchaseAmount'] = this.purchaseAmount;
|
||||
data['guideAmount'] = this.guideAmount;
|
||||
data['teamAmount'] = this.teamAmount;
|
||||
data['recommendAmount'] = this.recommendAmount;
|
||||
data['rewardAmount'] = this.rewardAmount;
|
||||
return data;
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
class UserMonthIncomeModel {
|
||||
int id;
|
||||
int userId;
|
||||
DateTime date;
|
||||
double amount;
|
||||
double purchaseAmount;
|
||||
double guideAmount;
|
||||
bool isSettlement;
|
||||
double teamAmount;
|
||||
double recommendAmount;
|
||||
double rewardAmount;
|
||||
|
||||
UserMonthIncomeModel(
|
||||
{this.id,
|
||||
this.userId,
|
||||
this.date,
|
||||
this.amount,
|
||||
this.purchaseAmount,
|
||||
this.guideAmount,
|
||||
this.isSettlement,
|
||||
this.teamAmount,
|
||||
this.recommendAmount,
|
||||
this.rewardAmount});
|
||||
|
||||
UserMonthIncomeModel.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
userId = json['userId'];
|
||||
date = DateTime(json['date'] ~/ 100, json['date'] % 100);
|
||||
amount = json['amount'] + .0;
|
||||
purchaseAmount = json['purchase_amount'] + .0;
|
||||
guideAmount = json['guide_amount'] + .0;
|
||||
isSettlement = json['isSettlement'] == 1;
|
||||
teamAmount = json['teamAmount'] + .0;
|
||||
recommendAmount = json['recommendAmount'] + .0;
|
||||
rewardAmount = json['rewardAmount'] + .0;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['id'] = this.id;
|
||||
data['userId'] = this.userId;
|
||||
data['date'] = this.date;
|
||||
data['amount'] = this.amount;
|
||||
data['purchase_amount'] = this.purchaseAmount;
|
||||
data['guide_amount'] = this.guideAmount;
|
||||
data['isSettlement'] = this.isSettlement;
|
||||
data['teamAmount'] = this.teamAmount;
|
||||
data['recommendAmount'] = this.recommendAmount;
|
||||
data['rewardAmount'] = this.rewardAmount;
|
||||
return data;
|
||||
}
|
||||
}
|
Loading…
Reference in new issue