diff --git a/lib/common/models/database/database_enum_models.dart b/lib/common/models/database/database_enum_models.dart index 8226c9f..2f21c56 100644 --- a/lib/common/models/database/database_enum_models.dart +++ b/lib/common/models/database/database_enum_models.dart @@ -59,10 +59,10 @@ enum OrderStatus implements BaseEnum { TOTAL("-1", "全部", true), CREATE("1", "未付款", true), - OFFLINE_CREATE("2", "离线创建订单(未支付)", false), PAY("5", "已付款", true), - OFFLINE_PAY("6", "本地支付", true), - REFUND("10", "退款", true), + OFFLINE_CREATE("2", "离线(未支付)", true), + OFFLINE_PAY("6", "离线(本地支付)", true), + REFUND("10", "退款", false), CANCEL("20", "已核销", false), ; diff --git a/lib/common/services/database/entity/order_entity.g.dart b/lib/common/services/database/entity/order_entity.g.dart index c40d797..068f677 100644 --- a/lib/common/services/database/entity/order_entity.g.dart +++ b/lib/common/services/database/entity/order_entity.g.dart @@ -71,8 +71,8 @@ const _$OrderTypeEnumMap = { const _$OrderStatusEnumMap = { OrderStatus.TOTAL: 'TOTAL', OrderStatus.CREATE: 'CREATE', - OrderStatus.OFFLINE_CREATE: 'OFFLINE_CREATE', OrderStatus.PAY: 'PAY', + OrderStatus.OFFLINE_CREATE: 'OFFLINE_CREATE', OrderStatus.OFFLINE_PAY: 'OFFLINE_PAY', OrderStatus.REFUND: 'REFUND', OrderStatus.CANCEL: 'CANCEL', diff --git a/lib/common/widgets/order/mixin/order_mixin.dart b/lib/common/widgets/order/mixin/order_mixin.dart index 00b7869..9f34fb5 100644 --- a/lib/common/widgets/order/mixin/order_mixin.dart +++ b/lib/common/widgets/order/mixin/order_mixin.dart @@ -149,6 +149,7 @@ mixin OrderMixin { Future createSqlOrder() async { final orderSourceTypeId = getOrderSourceTypeId(); try { + final isNetwork = appC.isNetwork.value; final order = OrderEntity( uniqueCode: await _getUniqueCode(), serviceUniqueCode: '001', @@ -160,10 +161,10 @@ mixin OrderMixin { walletId: payUser.value?.walletId, orderSourceTypeId: orderSourceTypeId, type: orderType, - status: OrderStatus.OFFLINE_CREATE, + status: isNetwork ? OrderStatus.CREATE : OrderStatus.OFFLINE_CREATE, price: getTotalPrice(), extraPrice: amountMealPrice.value, - payPrice: getTotalPrice() + amountMealPrice.value, + payPrice: 0, productDesc: getProductDesc(), count: getProductCount(), weight: getProductWeight(), @@ -315,9 +316,11 @@ mixin OrderMixin { sqlOrderDetail.status = OrderStatus.PAY; sqlOrderDetail.serviceUniqueCode = data; } else { - sqlOrderDetail.status = OrderStatus.OFFLINE_CREATE; + sqlOrderDetail.status = OrderStatus.OFFLINE_PAY; } // 更新本地订单 + final payPrice = sqlOrderDetail.price + sqlOrderDetail.extraPrice; + sqlOrderDetail.payPrice = payPrice; sqlOrderDetail.payTime = DateTime.now(); await orderDao.edit(sqlOrderDetail); if (sqlOrderDetail.payPrice != 0) { @@ -475,7 +478,6 @@ mixin OrderMixin { required price, }) async { try { - final app = Get.find(); var setting = await AppSettingTool.getCanteenExtraPriceConfig(); final isNetwork = AppNetworkTool.isAutoNetwork(); // 有网络 diff --git a/lib/common/widgets/order/order_common.dart b/lib/common/widgets/order/order_common.dart index 52d4e9d..2183b34 100644 --- a/lib/common/widgets/order/order_common.dart +++ b/lib/common/widgets/order/order_common.dart @@ -11,12 +11,14 @@ Widget orderAllPrice( BuildContext context, { required num totalPrice, required num amountMealPrice, + num? payPrice, String productPrice = "菜品总价", bool visibleProductPrice = true, bool visibleAmountMealPrice = true, bool visibleDivider = true, }) { final theme = FTheme.of(context); + payPrice ??= totalPrice + amountMealPrice; return [ FDivider( style: theme.dividerStyles.verticalStyle.copyWith( @@ -45,7 +47,7 @@ Widget orderAllPrice( ), appPrice( context, - totalPrice + amountMealPrice, + payPrice, ), ].toRow(), FDivider( diff --git a/lib/pages/order_history/controller.dart b/lib/pages/order_history/controller.dart index 3ace7b4..3931a0c 100644 --- a/lib/pages/order_history/controller.dart +++ b/lib/pages/order_history/controller.dart @@ -145,7 +145,7 @@ class OrderHistoryController extends GetxController { .toList(); for (int i = 0; i < tabs.length; i++) { final v = tabs[i]; - final currentTotal = total[v.status.name]; + final currentTotal = total["UNIQUE_${v.status.name}"]; if (currentTotal == null) continue; v.total = currentTotal; } @@ -156,19 +156,19 @@ class OrderHistoryController extends GetxController { Future> _getTotal() async { final appSetting = await AppSettingTool.getSysSetting(); Map map = { - "pay": 0, - "nonePay": 0, - "offlinePay": 0, - "refund": 0, - "total": 0, + "UNIQUE_TOTAL": 0, + "UNIQUE_CREATE": 0, + "UNIQUE_OFFLINE_CREATE": 0, + "UNIQUE_PAY": 0, + "UNIQUE_OFFLINE_PAY": 0, }; String totalSql = """ SELECT - SUM(CASE WHEN status = 'pay' THEN 1 ELSE 0 END) AS pay, - SUM(CASE WHEN status = 'nonePay' THEN 1 ELSE 0 END) AS nonePay, - SUM(CASE WHEN status = 'offlinePay' THEN 1 ELSE 0 END) AS offlinePay, - SUM(CASE WHEN status = 'refund' THEN 1 ELSE 0 END) AS refund, - SUM(CASE WHEN 1 = 1 THEN 1 ELSE 0 END) AS total + SUM(CASE WHEN status = 'CREATE' THEN 1 ELSE 0 END) AS UNIQUE_CREATE, + SUM(CASE WHEN status = 'OFFLINE_CREATE' THEN 1 ELSE 0 END) AS UNIQUE_OFFLINE_CREATE, + SUM(CASE WHEN status = 'PAY' THEN 1 ELSE 0 END) AS UNIQUE_PAY, + SUM(CASE WHEN status = 'OFFLINE_PAY' THEN 1 ELSE 0 END) AS UNIQUE_OFFLINE_PAY, + SUM(CASE WHEN 1 = 1 THEN 1 ELSE 0 END) AS UNIQUE_TOTAL FROM order_record WHERE sysType = ? diff --git a/lib/pages/order_history/view.dart b/lib/pages/order_history/view.dart index eb011da..3fd9e9d 100644 --- a/lib/pages/order_history/view.dart +++ b/lib/pages/order_history/view.dart @@ -43,7 +43,7 @@ class OrderHistoryPage extends GetView { textAlign: TextAlign.center, maxLines: 1, overflow: TextOverflow.ellipsis, - style: theme.typography.xl2.copyWith( + style: theme.typography.base.copyWith( height: 1, color: active ? theme.colorScheme.background @@ -51,7 +51,7 @@ class OrderHistoryPage extends GetView { ), ) .center() - .width(180.w) + .width(200.w) .height(60.h) .decorated( color: active diff --git a/lib/pages/order_history_detail/view.dart b/lib/pages/order_history_detail/view.dart index 71f25fb..a117008 100644 --- a/lib/pages/order_history_detail/view.dart +++ b/lib/pages/order_history_detail/view.dart @@ -136,6 +136,7 @@ class OrderHistoryDetailPage extends GetView { context, totalPrice: controller.detailData.value?.price ?? 0, amountMealPrice: controller.detailData.value?.extraPrice ?? 0, + payPrice: controller.detailData.value?.payPrice, productPrice: "商品总价", ), ].toColumn();