对接累计收益、年度月收益接口

master
laiiihz 5 years ago
parent c0ce37b0c5
commit da18880042

@ -11,4 +11,10 @@ class UserAPI {
///
String get balanceMonthHistory => '/v2/app/user/balance/month_history';
///
String get accumulate => '/v2/app/user/income/accumulate';
///
String get monthIncome => '/v2/app/user/income/month_income';
}

@ -8,6 +8,8 @@ import 'package:recook/constants/styles.dart';
import 'package:recook/manager/http_manager.dart';
import 'package:recook/manager/user_manager.dart';
import 'package:recook/models/team_income_model.dart';
import 'package:recook/pages/user/functions/user_benefit_func.dart';
import 'package:recook/pages/user/model/user_accumulate_model.dart';
import 'package:recook/pages/user/user_page_sub_income_page.dart';
import 'package:recook/utils/user_level_tool.dart';
import 'package:recook/widgets/alert.dart';
@ -27,15 +29,39 @@ class CumulativeIncomePage extends StatefulWidget {
class _CumulativeIncomePageState extends BaseStoreState<CumulativeIncomePage>
with TickerProviderStateMixin {
//user new api
//
TeamIncomeModel _teamIncomeModel;
bool _noData = false;
String _selectYear;
///
///
UserAccumulateModel _model = UserAccumulateModel.zero();
///
double get _purchase => _model?.data?.purchaseAmount ?? 0;
///
double get _guide => _model?.data?.guideAmount ?? 0;
///
double get _team => _model?.data?.teamAmount ?? 0;
///
double get _recommand => _model?.data?.recommendAmount ?? 0;
///
double get _reward => _model?.data?.rewardAmount ?? 0;
double get _allAmount => _purchase + _guide + _team + _recommand + _reward;
@override
void initState() {
_selectYear = DateTime.now().year.toString();
_getShopIncome();
_getAccumulate();
super.initState();
}
@ -194,10 +220,7 @@ class _CumulativeIncomePageState extends BaseStoreState<CumulativeIncomePage>
alignment: Alignment.centerLeft,
child: _textColumn(
titleText: "累计收益",
infoText: _teamIncomeModel == null
? "0.00"
: _teamIncomeModel.data.accumulateIncome.all
?.toStringAsFixed(2),
infoText: _allAmount.toStringAsFixed(2),
infoFontSize: 24,
),
),
@ -216,18 +239,13 @@ class _CumulativeIncomePageState extends BaseStoreState<CumulativeIncomePage>
_buildGridColumn(
context,
title: '自购收益',
value: _teamIncomeModel
?.data?.accumulateIncome?.selfShopping
?.toStringAsFixed(2) ??
'0.00',
value: _purchase.toStringAsFixed(2),
index: 0,
),
_buildGridColumn(
context,
title: '导购收益',
value: _teamIncomeModel?.data?.accumulateIncome?.share
?.toStringAsFixed(2) ??
'0.00',
value: _guide.toStringAsFixed(2),
index: 1,
),
..._teamIncomeModel?.data?.roleVisable ?? false
@ -235,10 +253,7 @@ class _CumulativeIncomePageState extends BaseStoreState<CumulativeIncomePage>
_buildGridColumn(
context,
title: '团队收益',
value: _teamIncomeModel
?.data?.accumulateIncome?.team
?.toStringAsFixed(2) ??
'0.00',
value: _team.toStringAsFixed(2),
index: 2,
)
]
@ -246,13 +261,13 @@ class _CumulativeIncomePageState extends BaseStoreState<CumulativeIncomePage>
_buildGridColumn(
context,
title: "推荐收益",
value: "0.00X",
value: _recommand.toStringAsFixed(2),
index: 3,
),
_buildGridColumn(
context,
title: "平台奖励",
value: "0.00X",
value: _reward.toStringAsFixed(2),
index: 4,
),
],
@ -646,6 +661,11 @@ class _CumulativeIncomePageState extends BaseStoreState<CumulativeIncomePage>
setState(() {});
}
_getAccumulate() async {
_model = await UserBenefitFunc.accmulate();
setState(() {});
}
_textColumn(
{String titleText = "",
Color titleColor = Colors.black54,
@ -684,25 +704,29 @@ _buildGridColumn(
String value,
int index,
}) {
return CustomImageButton(
return MaterialButton(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
padding: EdgeInsets.zero,
onPressed: () {
_goToNextPage(index, context);
},
child: <Widget>[
[
title.text.color(Color(0xff3a3943)).size(14.sp).make(),
CustomImageButton(
child:
Image.asset(R.ASSETS_SHOP_HELPER_PNG, width: 12.w, height: 12.w),
onPressed: () => _openQuestDialog(index, title, context),
),
].row(),
3.hb,
value.text.color(Color(0xFF333333)).size(20.sp).make(),
].column(
crossAlignment: CrossAxisAlignment.start,
alignment: MainAxisAlignment.center,
child: Align(
child: <Widget>[
[
title.text.color(Color(0xff3a3943)).size(14.sp).make(),
CustomImageButton(
child: Image.asset(R.ASSETS_SHOP_HELPER_PNG,
width: 12.w, height: 12.w),
onPressed: () => _openQuestDialog(index, title, context),
),
].row(),
3.hb,
value.text.color(Color(0xFF333333)).size(20.sp).make(),
].column(
crossAlignment: CrossAxisAlignment.start,
alignment: MainAxisAlignment.center,
),
alignment: Alignment.centerLeft,
),
);
}

@ -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…
Cancel
Save