parent
9ccc349b01
commit
ab14b46f30
@ -0,0 +1,49 @@
|
|||||||
|
class UserBenefitMonthDetailModel {
|
||||||
|
int id;
|
||||||
|
int userId;
|
||||||
|
DateTime day;
|
||||||
|
num purchaseAmount;
|
||||||
|
num purchaseCount;
|
||||||
|
num purchaseSalesVolume;
|
||||||
|
num guideAmount;
|
||||||
|
int guideCount;
|
||||||
|
num guideSalesVolume;
|
||||||
|
|
||||||
|
UserBenefitMonthDetailModel(
|
||||||
|
{this.id,
|
||||||
|
this.userId,
|
||||||
|
this.day,
|
||||||
|
this.purchaseAmount,
|
||||||
|
this.purchaseCount,
|
||||||
|
this.purchaseSalesVolume,
|
||||||
|
this.guideAmount,
|
||||||
|
this.guideCount,
|
||||||
|
this.guideSalesVolume});
|
||||||
|
|
||||||
|
UserBenefitMonthDetailModel.fromJson(Map<String, dynamic> json) {
|
||||||
|
id = json['id'];
|
||||||
|
userId = json['userId'];
|
||||||
|
int dayRaw = json['day'];
|
||||||
|
day = DateTime(dayRaw ~/ 10000, dayRaw % 10000 ~/ 100, dayRaw % 100);
|
||||||
|
purchaseAmount = json['purchaseAmount'];
|
||||||
|
purchaseCount = json['purchaseCount'];
|
||||||
|
purchaseSalesVolume = json['purchaseSalesVolume'];
|
||||||
|
guideAmount = json['guideAmount'];
|
||||||
|
guideCount = json['guideCount'];
|
||||||
|
guideSalesVolume = json['guideSalesVolume'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['id'] = this.id;
|
||||||
|
data['userId'] = this.userId;
|
||||||
|
data['day'] = this.day;
|
||||||
|
data['purchaseAmount'] = this.purchaseAmount;
|
||||||
|
data['purchaseCount'] = this.purchaseCount;
|
||||||
|
data['purchaseSalesVolume'] = this.purchaseSalesVolume;
|
||||||
|
data['guideAmount'] = this.guideAmount;
|
||||||
|
data['guideCount'] = this.guideCount;
|
||||||
|
data['guideSalesVolume'] = this.guideSalesVolume;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:recook/pages/user/model/user_benefit_month_detail_model.dart';
|
||||||
|
|
||||||
|
class UserBenefitModelsTest {
|
||||||
|
static runTest() {
|
||||||
|
test('test userBenefit', () {
|
||||||
|
UserBenefitMonthDetailModel userBenefitModel =
|
||||||
|
UserBenefitMonthDetailModel.fromJson({
|
||||||
|
"id": 2,
|
||||||
|
"userId": 6,
|
||||||
|
"day": 20201201, // 年月日
|
||||||
|
"purchaseAmount": 0, // 自购收益
|
||||||
|
"purchaseCount": 0, // 自购单数
|
||||||
|
"purchaseSalesVolume": 0, // 自购销售额
|
||||||
|
"guideAmount": 0, // 导购收益
|
||||||
|
"guideCount": 0, // 导购单数
|
||||||
|
"guideSalesVolume": 0 // 导购销售额
|
||||||
|
});
|
||||||
|
expect(userBenefitModel.day, DateTime(2020, 12, 1));
|
||||||
|
expect(userBenefitModel.id, 2);
|
||||||
|
expect(userBenefitModel.userId, 6);
|
||||||
|
expect(userBenefitModel.purchaseAmount, 0);
|
||||||
|
expect(userBenefitModel.purchaseCount, 0);
|
||||||
|
expect(userBenefitModel.purchaseSalesVolume, 0);
|
||||||
|
expect(userBenefitModel.guideAmount, 0);
|
||||||
|
expect(userBenefitModel.guideCount, 0);
|
||||||
|
expect(userBenefitModel.guideSalesVolume, 0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
import 'model_test/user_benefit_models_test.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
UserBenefitModelsTest.runTest();
|
||||||
|
}
|
@ -1,30 +0,0 @@
|
|||||||
// This is a basic Flutter widget test.
|
|
||||||
//
|
|
||||||
// To perform an interaction with a widget in your test, use the WidgetTester
|
|
||||||
// utility that Flutter provides. For example, you can send tap and scroll
|
|
||||||
// gestures. You can also use WidgetTester to find child widgets in the widget
|
|
||||||
// tree, read text, and verify that the values of widget properties are correct.
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
|
||||||
|
|
||||||
import 'package:recook/main.dart';
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
|
|
||||||
// Build our app and trigger a frame.
|
|
||||||
await tester.pumpWidget(MyApp(null));
|
|
||||||
|
|
||||||
// Verify that our counter starts at 0.
|
|
||||||
expect(find.text('0'), findsOneWidget);
|
|
||||||
expect(find.text('1'), findsNothing);
|
|
||||||
|
|
||||||
// Tap the '+' icon and trigger a frame.
|
|
||||||
await tester.tap(find.byIcon(Icons.add));
|
|
||||||
await tester.pump();
|
|
||||||
|
|
||||||
// Verify that our counter has incremented.
|
|
||||||
expect(find.text('0'), findsNothing);
|
|
||||||
expect(find.text('1'), findsOneWidget);
|
|
||||||
});
|
|
||||||
}
|
|
Loading…
Reference in new issue