feat:android统计
This commit is contained in:
1 parent
ab9ea614d5
commit
8fc6be0a69
6 files changed
+195
-26
No files matched your search
@@ -118,4 +118,18 @@ abstract class HardApi {
|
||||
if (res.data == null) return null;
|
||||
return res.data?.map<String>((e) => e.toString()).toList();
|
||||
}
|
||||
|
||||
/// 统计每天、每周、每月、每年的交易人数和次数
|
||||
static Future<List<ServiceChartLatitude>?> chartLatitude(
|
||||
dynamic formData,
|
||||
) async {
|
||||
final res = await HttpManage().dio.get(
|
||||
"/hard/hard-api/ad/chart-latitude",
|
||||
queryParameters: formData,
|
||||
);
|
||||
if (res.data == null) return null;
|
||||
return res.data
|
||||
?.map<ServiceChartLatitude>((e) => ServiceChartLatitude.fromJson(e))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
@@ -316,3 +316,52 @@ class ServiceOpenCardPage extends ServicePageBase {
|
||||
|
||||
Map<String, dynamic> toJson() => _$ServiceOpenCardPageToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
class ServiceChartLatitude {
|
||||
/// 早餐、中餐、晚餐
|
||||
final String? hourType;
|
||||
|
||||
/// 每天的交易量
|
||||
final String? dayCount;
|
||||
|
||||
/// 每天的交易金额
|
||||
final String? dayPrice;
|
||||
|
||||
/// 每周的交易量
|
||||
final String? weekCount;
|
||||
|
||||
/// 每周的交易金额
|
||||
final String? weekPrice;
|
||||
|
||||
/// 每月的交易量
|
||||
final String? monthCount;
|
||||
|
||||
/// 每月的交易金额
|
||||
final String? monthPrice;
|
||||
|
||||
/// 每年的交易量
|
||||
final String? yearCount;
|
||||
|
||||
/// 每年的交易金额
|
||||
final String? yearPrice;
|
||||
|
||||
ServiceChartLatitude({
|
||||
this.hourType,
|
||||
this.dayCount,
|
||||
this.dayPrice,
|
||||
this.weekCount,
|
||||
this.weekPrice,
|
||||
this.monthCount,
|
||||
this.monthPrice,
|
||||
this.yearCount,
|
||||
this.yearPrice,
|
||||
});
|
||||
|
||||
factory ServiceChartLatitude.fromJson(Map<String, dynamic> json) =>
|
||||
_$ServiceChartLatitudeFromJson(
|
||||
json,
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => _$ServiceChartLatitudeToJson(this);
|
||||
}
|
||||
@@ -190,3 +190,31 @@ Map<String, dynamic> _$ServiceOpenCardPageToJson(
|
||||
'total': instance.total,
|
||||
'records': instance.records,
|
||||
};
|
||||
|
||||
ServiceChartLatitude _$ServiceChartLatitudeFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
ServiceChartLatitude(
|
||||
hourType: json['hourType'] as String?,
|
||||
dayCount: json['dayCount'] as String?,
|
||||
dayPrice: json['dayPrice'] as String?,
|
||||
weekCount: json['weekCount'] as String?,
|
||||
weekPrice: json['weekPrice'] as String?,
|
||||
monthCount: json['monthCount'] as String?,
|
||||
monthPrice: json['monthPrice'] as String?,
|
||||
yearCount: json['yearCount'] as String?,
|
||||
yearPrice: json['yearPrice'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$ServiceChartLatitudeToJson(
|
||||
ServiceChartLatitude instance) =>
|
||||
<String, dynamic>{
|
||||
'hourType': instance.hourType,
|
||||
'dayCount': instance.dayCount,
|
||||
'dayPrice': instance.dayPrice,
|
||||
'weekCount': instance.weekCount,
|
||||
'weekPrice': instance.weekPrice,
|
||||
'monthCount': instance.monthCount,
|
||||
'monthPrice': instance.monthPrice,
|
||||
'yearCount': instance.yearCount,
|
||||
'yearPrice': instance.yearPrice,
|
||||
};
|
||||
@@ -334,7 +334,7 @@ mixin OrderMixin {
|
||||
await orderDao.edit(sqlOrderDetail);
|
||||
if (sqlOrderDetail.payPrice != 0) {
|
||||
final price = AppriceTool.fenToYuan(sqlOrderDetail.payPrice);
|
||||
await TtsManage.speak("购买成功总金额$price元");
|
||||
TtsManage.speak("购买成功总金额$price元");
|
||||
}
|
||||
Toast.success(msg: "购买成功");
|
||||
} catch (e, stack) {
|
||||
|
||||
@@ -1,17 +1,26 @@
|
||||
import 'package:get/get.dart';
|
||||
import 'package:pj_supermarket_cloud/common/index.dart';
|
||||
|
||||
class CanteenOrderTotalController extends GetxController {
|
||||
CanteenOrderTotalController();
|
||||
|
||||
final appC = Get.find<AppControl>();
|
||||
|
||||
Rx<SysSetting?> sysSetting = Rx(null);
|
||||
|
||||
Rx<ServiceChartLatitude> morgingChartLatitude = ServiceChartLatitude().obs;
|
||||
Rx<ServiceChartLatitude> noonChartLatitude = ServiceChartLatitude().obs;
|
||||
Rx<ServiceChartLatitude> nightChartLatitude = ServiceChartLatitude().obs;
|
||||
|
||||
_initData() {
|
||||
update(["canteen_order_total"]);
|
||||
}
|
||||
|
||||
void onTap() {}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
void onInit() async {
|
||||
super.onInit();
|
||||
sysSetting.value = await AppSettingTool.getSysSetting();
|
||||
await getChartLatitude();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -24,4 +33,14 @@ class CanteenOrderTotalController extends GetxController {
|
||||
void onClose() {
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
/// 获取统计数据
|
||||
Future<void> getChartLatitude() async {
|
||||
final pa = {"merchantId": sysSetting.value?.serviceMerchantId};
|
||||
final list = await HardApi.chartLatitude(pa);
|
||||
if (list == null) return;
|
||||
morgingChartLatitude.value = list.firstWhere((v) => v.hourType == "1");
|
||||
noonChartLatitude.value = list.firstWhere((v) => v.hourType == "2");
|
||||
nightChartLatitude.value = list.firstWhere((v) => v.hourType == "3");
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:ducafe_ui_core/ducafe_ui_core.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:forui/forui.dart';
|
||||
@@ -12,26 +14,71 @@ class CanteenOrderTotalPage extends GetView<CanteenOrderTotalController> {
|
||||
|
||||
// 主视图
|
||||
Widget _buildView(BuildContext context) {
|
||||
final widht = context.width;
|
||||
return <Widget>[
|
||||
Obx(
|
||||
() => _buildHeaderTotalItem(
|
||||
context,
|
||||
title: "全部交易统计",
|
||||
morgingChartLatitude: controller.morgingChartLatitude.value,
|
||||
noonChartLatitude: controller.noonChartLatitude.value,
|
||||
nightChartLatitude: controller.nightChartLatitude.value,
|
||||
).width(widht * 0.6),
|
||||
),
|
||||
SizedBox(height: 30.h),
|
||||
_buildHeaderTotal(context),
|
||||
_buildCharts(context),
|
||||
].toColumn();
|
||||
].toColumn().marginSymmetric(vertical: 20.w, horizontal: 20.w);
|
||||
}
|
||||
|
||||
// headerTotal
|
||||
Widget _buildHeaderTotal(BuildContext context) {
|
||||
return <Widget>[
|
||||
_buildHeaderTotalItem(context, title: "本日交易统计"),
|
||||
_buildHeaderTotalItem(context, title: "本周交易统计"),
|
||||
_buildHeaderTotalItem(context, title: "本月交易统计"),
|
||||
_buildHeaderTotalItem(context, title: "本年易统计"),
|
||||
].toRow(mainAxisAlignment: MainAxisAlignment.spaceAround);
|
||||
Obx(
|
||||
() => _buildHeaderTotalItem(
|
||||
context,
|
||||
title: "本日交易统计",
|
||||
morgingChartLatitude: controller.morgingChartLatitude.value,
|
||||
noonChartLatitude: controller.noonChartLatitude.value,
|
||||
nightChartLatitude: controller.nightChartLatitude.value,
|
||||
),
|
||||
),
|
||||
Obx(
|
||||
() => _buildHeaderTotalItem(
|
||||
context,
|
||||
title: "本周交易统计",
|
||||
morgingChartLatitude: controller.morgingChartLatitude.value,
|
||||
noonChartLatitude: controller.noonChartLatitude.value,
|
||||
nightChartLatitude: controller.nightChartLatitude.value,
|
||||
),
|
||||
),
|
||||
Obx(
|
||||
() => _buildHeaderTotalItem(
|
||||
context,
|
||||
title: "本月交易统计",
|
||||
morgingChartLatitude: controller.morgingChartLatitude.value,
|
||||
noonChartLatitude: controller.noonChartLatitude.value,
|
||||
nightChartLatitude: controller.nightChartLatitude.value,
|
||||
),
|
||||
),
|
||||
Obx(
|
||||
() => _buildHeaderTotalItem(
|
||||
context,
|
||||
title: "本年易统计",
|
||||
morgingChartLatitude: controller.morgingChartLatitude.value,
|
||||
noonChartLatitude: controller.noonChartLatitude.value,
|
||||
nightChartLatitude: controller.nightChartLatitude.value,
|
||||
),
|
||||
),
|
||||
].toRow(mainAxisAlignment: MainAxisAlignment.spaceBetween);
|
||||
}
|
||||
|
||||
// headerTotalItem
|
||||
Widget _buildHeaderTotalItem(
|
||||
BuildContext context, {
|
||||
required String title,
|
||||
required ServiceChartLatitude morgingChartLatitude,
|
||||
required ServiceChartLatitude noonChartLatitude,
|
||||
required ServiceChartLatitude nightChartLatitude,
|
||||
}) {
|
||||
final theme = FTheme.of(context);
|
||||
return <Widget>[
|
||||
@@ -40,6 +87,18 @@ class CanteenOrderTotalPage extends GetView<CanteenOrderTotalController> {
|
||||
ProductHourType.values
|
||||
.map((v) {
|
||||
if (v.code == "-1") return const SizedBox.shrink();
|
||||
String count = "0";
|
||||
String price = "0";
|
||||
if (v.code == "1") {
|
||||
count = morgingChartLatitude.dayCount ?? "0";
|
||||
price = morgingChartLatitude.dayPrice ?? "0";
|
||||
} else if (v.code == "2") {
|
||||
count = noonChartLatitude.dayCount ?? "0";
|
||||
price = noonChartLatitude.dayPrice ?? "0";
|
||||
} else if (v.code == "3") {
|
||||
count = nightChartLatitude.dayCount ?? "0";
|
||||
price = nightChartLatitude.dayPrice ?? "0";
|
||||
}
|
||||
return <Widget>[
|
||||
FIcon(
|
||||
v.icon,
|
||||
@@ -49,34 +108,34 @@ class CanteenOrderTotalPage extends GetView<CanteenOrderTotalController> {
|
||||
Text(
|
||||
v.title,
|
||||
maxLines: 1,
|
||||
style: theme.typography.xl.copyWith(height: 1),
|
||||
style: theme.typography.lg.copyWith(height: 1),
|
||||
),
|
||||
FDivider(
|
||||
axis: Axis.vertical,
|
||||
style: theme.dividerStyles.verticalStyle.copyWith(
|
||||
color: theme.colorScheme.primary,
|
||||
padding: EdgeInsets.zero,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 5.w),
|
||||
Text(
|
||||
"共用餐",
|
||||
maxLines: 1,
|
||||
style: theme.typography.xl.copyWith(height: 1),
|
||||
style: theme.typography.lg.copyWith(height: 1),
|
||||
),
|
||||
Text(
|
||||
"次",
|
||||
count,
|
||||
maxLines: 1,
|
||||
style: theme.typography.xl.copyWith(height: 1),
|
||||
style: theme.typography.lg.copyWith(
|
||||
height: 1,
|
||||
color: theme.colorScheme.error,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"次,",
|
||||
maxLines: 1,
|
||||
style: theme.typography.lg.copyWith(height: 1),
|
||||
),
|
||||
SizedBox(width: 5.w),
|
||||
Text(
|
||||
"总金额",
|
||||
maxLines: 1,
|
||||
style: theme.typography.xl.copyWith(height: 1),
|
||||
style: theme.typography.lg.copyWith(height: 1),
|
||||
),
|
||||
appPrice(context, price),
|
||||
]
|
||||
.toRow()
|
||||
.toRow(mainAxisAlignment: MainAxisAlignment.center)
|
||||
.paddingSymmetric(horizontal: 10.w, vertical: 5.w)
|
||||
.marginSymmetric(vertical: 10.h)
|
||||
.decorated(
|
||||
|
||||
Reference in new issue
Block a user