fix:超市购物卡支付、选择钱包、称重商品小数精度不够的问题
This commit is contained in:
1 parent
3a7ca1e5be
commit
9c82df3617
13 files changed
+61
-35
No files matched your search
@@ -117,7 +117,7 @@ class ServiceWallet {
|
||||
|
||||
/// 是否冻结饭卡
|
||||
@JsonKey(fromJson: JsonTool.stringToBoolean, toJson: JsonTool.booleanToString)
|
||||
bool? walletIsFreeze;
|
||||
bool? isFreeze;
|
||||
|
||||
ServiceWallet({
|
||||
required this.id,
|
||||
@@ -126,7 +126,7 @@ class ServiceWallet {
|
||||
required this.walletTypeId,
|
||||
required this.balance,
|
||||
this.cardNumber,
|
||||
this.walletIsFreeze,
|
||||
this.isFreeze,
|
||||
});
|
||||
|
||||
factory ServiceWallet.fromJson(Map<String, dynamic> json) =>
|
||||
|
||||
@@ -66,8 +66,8 @@ ServiceWallet _$ServiceWalletFromJson(Map<String, dynamic> json) =>
|
||||
userId: json['userId'] as String,
|
||||
walletTypeId: json['walletTypeId'] as String,
|
||||
balance: (json['balance'] as num).toInt(),
|
||||
walletIsFreeze:
|
||||
JsonTool.stringToBoolean(json['walletIsFreeze'] as String),
|
||||
cardNumber: json['cardNumber'] as String?,
|
||||
isFreeze: JsonTool.stringToBoolean(json['isFreeze'] as String),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$ServiceWalletToJson(ServiceWallet instance) =>
|
||||
@@ -77,5 +77,6 @@ Map<String, dynamic> _$ServiceWalletToJson(ServiceWallet instance) =>
|
||||
'userId': instance.userId,
|
||||
'walletTypeId': instance.walletTypeId,
|
||||
'balance': instance.balance,
|
||||
'walletIsFreeze': JsonTool.booleanToString(instance.walletIsFreeze),
|
||||
'cardNumber': instance.cardNumber,
|
||||
'isFreeze': JsonTool.booleanToString(instance.isFreeze),
|
||||
};
|
||||
@@ -49,6 +49,7 @@ enum OrderPayType implements BaseEnum {
|
||||
ALI_SELF_QR_CODE_PAY("11", "支付宝付款码支付"),
|
||||
ZYY("12", "中医院"),
|
||||
RMYY("13", "人民医院"),
|
||||
CSXFK("13", "超市消费卡"),
|
||||
;
|
||||
|
||||
@override
|
||||
@@ -58,6 +59,7 @@ enum OrderPayType implements BaseEnum {
|
||||
|
||||
const OrderPayType(this.code, this.title);
|
||||
|
||||
// 是否是外部人员支付
|
||||
static bool isStrideOrForeign(OrderPayType payType) {
|
||||
return [
|
||||
OrderPayType.STRIDE_DEPT_QR_CODE,
|
||||
|
||||
@@ -132,6 +132,7 @@ const _$OrderPayDisplayTypeEnumMap = {
|
||||
OrderPayDisplayType.cash: 'cash',
|
||||
OrderPayDisplayType.zyy: 'zyy',
|
||||
OrderPayDisplayType.rmyy: 'rmyy',
|
||||
OrderPayDisplayType.csxfk: 'csxfk',
|
||||
};
|
||||
|
||||
UserSetting _$UserSettingFromJson(Map<String, dynamic> json) => UserSetting(
|
||||
|
||||
@@ -7,6 +7,7 @@ enum OrderPayDisplayType implements BaseEnum {
|
||||
cash("4", "现金支付", true, 4),
|
||||
zyy("12", "中医院", true, 5),
|
||||
rmyy("13", "人民医院", true, 6),
|
||||
csxfk("14", "超市消费卡", true, 7),
|
||||
;
|
||||
|
||||
@override
|
||||
@@ -23,6 +24,7 @@ enum OrderPayDisplayType implements BaseEnum {
|
||||
OrderPayDisplayType.cash,
|
||||
OrderPayDisplayType.zyy,
|
||||
OrderPayDisplayType.rmyy,
|
||||
OrderPayDisplayType.csxfk,
|
||||
];
|
||||
|
||||
// 是否为线下支付
|
||||
@@ -32,7 +34,9 @@ enum OrderPayDisplayType implements BaseEnum {
|
||||
|
||||
// 需要选择钱包
|
||||
static const List<OrderPayDisplayType> selectWalletPayTypeList = [
|
||||
OrderPayDisplayType.qrCode,
|
||||
OrderPayDisplayType.face,
|
||||
OrderPayDisplayType.walletCard,
|
||||
];
|
||||
|
||||
// 是否需要选择钱包
|
||||
|
||||
@@ -92,4 +92,5 @@ const _$OrderPayTypeEnumMap = {
|
||||
OrderPayType.ALI_SELF_QR_CODE_PAY: 'ALI_SELF_QR_CODE_PAY',
|
||||
OrderPayType.ZYY: 'ZYY',
|
||||
OrderPayType.RMYY: 'RMYY',
|
||||
OrderPayType.CSXFK: 'CSXFK',
|
||||
};
|
||||
@@ -176,7 +176,7 @@ abstract class SyncProductTool {
|
||||
static Future<void> syncSupermarket() async {
|
||||
final stopwatch = Stopwatch()..start();
|
||||
EasyLoading.show(
|
||||
status: '原创同步数据中...',
|
||||
status: '远程同步数据中...',
|
||||
maskType: EasyLoadingMaskType.black,
|
||||
);
|
||||
try {
|
||||
|
||||
@@ -10,9 +10,9 @@ class Constants {
|
||||
static const pwdEncKey = 'pigxpigxpigxpigx';
|
||||
|
||||
/// 服务 url
|
||||
static const apiUrl = 'https://stgl.pj.gov.cn/api';
|
||||
// static const apiUrl = 'https://stgl.pj.gov.cn/api';
|
||||
|
||||
// static const apiUrl = 'http://192.168.101.174:9999';
|
||||
static const apiUrl = 'http://192.168.101.185:9999';
|
||||
|
||||
/// 静态资源 url
|
||||
static const ossUrl = apiUrl;
|
||||
|
||||
@@ -16,7 +16,11 @@ Widget AppWalletSelector(
|
||||
if (ObjectUtil.isEmpty(list)) {
|
||||
return const SizedBox();
|
||||
}
|
||||
final currentSelector = selector ?? list[0];
|
||||
ServiceWallet? currentSelector = selector;
|
||||
if (currentSelector == null) {
|
||||
currentSelector = list[0];
|
||||
onChange(currentSelector);
|
||||
}
|
||||
final theme = FTheme.of(context);
|
||||
return list
|
||||
.map((v) {
|
||||
@@ -29,7 +33,7 @@ Widget AppWalletSelector(
|
||||
"未知钱包";
|
||||
// 是否选中
|
||||
final isSelect =
|
||||
v.walletTypeUniqueCode == currentSelector.walletTypeUniqueCode;
|
||||
v.walletTypeUniqueCode == currentSelector!.walletTypeUniqueCode;
|
||||
|
||||
return <Widget>[
|
||||
FIcon(
|
||||
|
||||
@@ -315,8 +315,14 @@ mixin OrderMixin {
|
||||
"list": shopList,
|
||||
};
|
||||
if (orderPayType.value != null &&
|
||||
orderPayType.value == OrderPayType.WALLET_QR_CODE) {
|
||||
appSetting.sysType == SysType.CANTEEN &&
|
||||
(orderPayType.value == OrderPayType.WALLET_QR_CODE)) {
|
||||
pa["walletId"] = globalQrCode?.id;
|
||||
} else if (OrderPayDisplayType.isSelectWalletPayType(
|
||||
orderPayDisplayType.value!)) {
|
||||
if (payUser.value?.walletId != null) {
|
||||
pa["walletId"] = payUser.value?.walletId;
|
||||
}
|
||||
}
|
||||
logger.i("|$_tag|创建api订单,下单参数:|${json.encode(pa)}|");
|
||||
try {
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'dart:convert';
|
||||
import 'package:common_utils/common_utils.dart';
|
||||
import 'package:ducafe_ui_core/ducafe_ui_core.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:flutter_subscreen_plugin/flutter_subscreen_plugin.dart';
|
||||
import 'package:forui/forui.dart';
|
||||
@@ -93,6 +94,8 @@ class SelectPayTypeDialogController extends GetxController {
|
||||
orderPayType.value = OrderPayType.ZYY;
|
||||
} else if (payType == OrderPayDisplayType.rmyy) {
|
||||
orderPayType.value = OrderPayType.RMYY;
|
||||
} else if (payType == OrderPayDisplayType.csxfk) {
|
||||
orderPayType.value = OrderPayType.CSXFK;
|
||||
}
|
||||
} else if (payUser.value != null) {
|
||||
if (AppUserTool.isGenerateExternalUser(payUser.value!)) {
|
||||
@@ -134,6 +137,7 @@ class SelectPayTypeDialogController extends GetxController {
|
||||
|
||||
_closeStatus() {
|
||||
payUser.value = null;
|
||||
userWalletList.value = [];
|
||||
isRecognition.value = false;
|
||||
globalQrCode = null;
|
||||
_faceCallbackLock = false;
|
||||
@@ -251,6 +255,7 @@ class SelectPayTypeDialogController extends GetxController {
|
||||
if (payUser.value != null) {
|
||||
await SyncUserTool.storageUser(user: payUser.value!);
|
||||
}
|
||||
await _getWalletList();
|
||||
logger.i("|$_tag|二维码识别|有网络|,用户信息:|${payUser.toJson()}|");
|
||||
} else {
|
||||
if (ObjectUtil.isNotEmpty(serviceCode.extra)) {
|
||||
@@ -324,6 +329,7 @@ class SelectPayTypeDialogController extends GetxController {
|
||||
isRecognition.value = false;
|
||||
orderPayType.value = OrderPayType.WALLET_CARD;
|
||||
orderType = OrderType.BELOW;
|
||||
await _getWalletList();
|
||||
onDiscernUser?.call(payUser.value);
|
||||
break;
|
||||
case SerialCardResStatus.warning:
|
||||
@@ -399,18 +405,6 @@ class SelectPayTypeDialogController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
// **************************************************************************
|
||||
// 线下支付 start
|
||||
// **************************************************************************
|
||||
Future<void> _dispatchWalletScanCode() async {
|
||||
orderPayType.value = OrderPayType.CASH;
|
||||
orderType = OrderType.BELOW;
|
||||
onDiscernUser?.call(payUser.value);
|
||||
}
|
||||
// **************************************************************************
|
||||
// 线下支付 end
|
||||
// **************************************************************************
|
||||
|
||||
// android人脸识别成功回调
|
||||
Future<void> _faceDiscernAfter(FaceStream event) async {
|
||||
try {
|
||||
@@ -490,6 +484,21 @@ class SelectPayTypeDialogController extends GetxController {
|
||||
return success.contains(type);
|
||||
}
|
||||
|
||||
/// 选择钱包
|
||||
void appSelectorChange(ServiceWallet wallet) {
|
||||
currentWallet.value = wallet;
|
||||
// 设置payUser
|
||||
if (payUser.value == null) return;
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||
payUser.value?.walletId = wallet.id;
|
||||
payUser.value?.walletTypeId = wallet.walletTypeId;
|
||||
payUser.value?.walletBalance = wallet.balance;
|
||||
payUser.value?.walletCardNumber = wallet.cardNumber;
|
||||
payUser.value?.walletIsFreeze = wallet.isFreeze;
|
||||
payUser.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
/// 获取用户钱包列表
|
||||
Future<void> _getWalletList() async {
|
||||
// 如果选择了需要选择钱包的支付方式
|
||||
@@ -578,17 +587,7 @@ Future<void> selectPayTypeDialog() async {
|
||||
context,
|
||||
list: payTypeC.userWalletList,
|
||||
selector: payTypeC.currentWallet.value,
|
||||
onChange: (wallet) {
|
||||
payTypeC.currentWallet.value = wallet;
|
||||
// 设置payUser
|
||||
final payUser = payTypeC.payUser.value;
|
||||
if (payUser == null) return;
|
||||
payUser.walletId = wallet.id;
|
||||
payUser.walletTypeId = wallet.walletTypeId;
|
||||
payUser.walletBalance = wallet.balance;
|
||||
payUser.walletCardNumber = wallet.cardNumber;
|
||||
payUser.walletIsFreeze = wallet.walletIsFreeze;
|
||||
},
|
||||
onChange: (wallet) => payTypeC.appSelectorChange(wallet),
|
||||
).width(double.infinity).height(200.h).offstage(
|
||||
offstage:
|
||||
!(payTypeC.appSetting.sysType == SysType.SUPERMARKET &&
|
||||
@@ -761,6 +760,10 @@ Widget selectPayTypeHint(
|
||||
msg = "人民医院支付,请点击支付按钮";
|
||||
icon = FAssets.icons.circleDollarSign;
|
||||
break;
|
||||
case OrderPayDisplayType.csxfk:
|
||||
msg = "超市消费卡支付,请点击支付按钮";
|
||||
icon = FAssets.icons.circleDollarSign;
|
||||
break;
|
||||
}
|
||||
return appEmpty(
|
||||
context,
|
||||
|
||||
@@ -154,7 +154,7 @@ class SteelyardController extends GetxController {
|
||||
widget.value = callbackWidget.value;
|
||||
// 获取价格
|
||||
final productPrice = _getProudctPrice(_product!);
|
||||
final p = (callbackWidget.value * productPrice).ceil();
|
||||
final p = (callbackWidget.value * productPrice).truncate().ceil();
|
||||
price.value = p;
|
||||
logger.i(
|
||||
"|$_tag|重量|${widget.value}|单价|$productPrice|总价|${price.value}|",
|
||||
|
||||
@@ -444,6 +444,10 @@ class SupermarketOrderController extends GetxController with OrderMixin {
|
||||
// 校验支付用户
|
||||
bool _validatePayUser() {
|
||||
bool flag = true;
|
||||
if (orderPayDisplayType.value == null) return false;
|
||||
final isOffline = OrderPayDisplayType.isOffline(orderPayDisplayType.value!);
|
||||
if (isOffline) return true;
|
||||
|
||||
if (ObjectUtil.isEmpty(payUser.value?.walletBalance)) {
|
||||
TtsManage.speak("用户钱包不存在");
|
||||
Toast.error(msg: "校验购物车失败,用户钱包不存在");
|
||||
|
||||
Reference in new issue
Block a user