解决支付金额精度丢失问题

pull/1/head
张萌 3 years ago
parent c420e24a13
commit b105260109

@ -123,7 +123,7 @@ class _GoodDetailPageState extends State<GoodDetailPage> {
controller: _refreshController, controller: _refreshController,
onRefresh: () async { onRefresh: () async {
_goodDetail = await SearchFunc.getGoodDetail( _goodDetail = await SearchFunc.getGoodDetail(
widget.goodId, _addressModel?.location); widget.goodId, _addressModel?.id);
// _imageList = await SearchFunc.getGoodDetailImage(widget.goodId); // _imageList = await SearchFunc.getGoodDetailImage(widget.goodId);
if (_goodDetail != GoodDetailModel.fail()) { if (_goodDetail != GoodDetailModel.fail()) {
_onload = false; _onload = false;

@ -7,6 +7,7 @@ import 'package:aku_new_community/utils/network/base_list_model.dart';
import 'package:aku_new_community/utils/network/base_model.dart'; import 'package:aku_new_community/utils/network/base_model.dart';
import 'package:aku_new_community/utils/network/net_util.dart'; import 'package:aku_new_community/utils/network/net_util.dart';
import 'package:aku_new_community/utils/text_utils.dart'; import 'package:aku_new_community/utils/text_utils.dart';
import 'package:bot_toast/bot_toast.dart';
class SearchFunc { class SearchFunc {
/// ///
@ -73,11 +74,15 @@ class SearchFunc {
} }
/// ///
static Future<String> addGoodsCar(int jcookGoodsId) async { static Future<bool> addGoodsCar(int jcookGoodsId) async {
BaseModel model = await NetUtil().post(SAASAPI.market.shopCart.insert, BaseModel model = await NetUtil().get(
params: {'appGoodsPushId': jcookGoodsId}, showMessage: true); SAASAPI.market.shopCart.insert,
if (model.msg == null) return ''; params: {'appGoodsPushId': jcookGoodsId},
return model.msg as String; );
if (!model.success) {
BotToast.showText(text: model.msg);
}
return model.success;
} }
/// ///

@ -9,6 +9,7 @@ import 'package:aku_new_community/pages/life_pay/pay_util.dart';
import 'package:aku_new_community/pages/personal/address/address_list_page.dart'; import 'package:aku_new_community/pages/personal/address/address_list_page.dart';
import 'package:aku_new_community/provider/app_provider.dart'; import 'package:aku_new_community/provider/app_provider.dart';
import 'package:aku_new_community/ui/market/order/order_page.dart'; import 'package:aku_new_community/ui/market/order/order_page.dart';
import 'package:aku_new_community/ui/market/search/search_func.dart';
import 'package:aku_new_community/ui/market/search/settlementGoodsDTO.dart'; import 'package:aku_new_community/ui/market/search/settlementGoodsDTO.dart';
import 'package:aku_new_community/ui/market/shop_car/shop_car_func.dart'; import 'package:aku_new_community/ui/market/shop_car/shop_car_func.dart';
import 'package:aku_new_community/utils/headers.dart'; import 'package:aku_new_community/utils/headers.dart';
@ -18,6 +19,7 @@ import 'package:aku_new_community/widget/bee_scaffold.dart';
import 'package:aku_new_community/widget/buttons/end_button.dart'; import 'package:aku_new_community/widget/buttons/end_button.dart';
import 'package:aku_new_community/widget/others/user_tool.dart'; import 'package:aku_new_community/widget/others/user_tool.dart';
import 'package:bot_toast/bot_toast.dart'; import 'package:bot_toast/bot_toast.dart';
import 'package:common_utils/common_utils.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@ -46,7 +48,7 @@ class _SubmitOrderNormalPageState extends State<SubmitOrderNormalPage> {
List<SettlementGoodsDTO> _goodsList = []; List<SettlementGoodsDTO> _goodsList = [];
AddressModel? _addressModel; AddressModel? _addressModel;
CreateOrderModel? _createOrderModel; CreateOrderModel? _createOrderModel;
double _allPrice = 0; double totalPrice = 0;
@override @override
void initState() { void initState() {
@ -73,11 +75,18 @@ class _SubmitOrderNormalPageState extends State<SubmitOrderNormalPage> {
Future<bool> createOrder( Future<bool> createOrder(
int addressId, List<SettlementGoodsDTO> goodsList) async { int addressId, List<SettlementGoodsDTO> goodsList) async {
try {
for (var item in goodsList) {
await SearchFunc.addGoodsCar(item.appGoodsPushId!);
}
} catch (e) {
print(e.toString());
}
BaseModel model = await NetUtil().post( BaseModel model = await NetUtil().post(
SAASAPI.market.shopCart.settlement, SAASAPI.market.shopCart.settlement,
params: { params: {
'addressId': addressId, 'addressId': addressId,
'settlementGoodsDTOList': goodsList.map((v) => v.toJson()).toList() 'settlementGoodsList': goodsList.map((v) => v.toJson()).toList()
}, },
); );
if (model.data == null) { if (model.data == null) {
@ -149,7 +158,7 @@ class _SubmitOrderNormalPageState extends State<SubmitOrderNormalPage> {
"settlementGoodsDTOList": "settlementGoodsDTOList":
_goodsList.map((v) => v.toJson()).toList(), _goodsList.map((v) => v.toJson()).toList(),
"payType": 10, // "payType": 10, //
"payPrice": _allPrice, "payPrice": totalPrice,
'points': widget.integral, 'points': widget.integral,
}); });
if (baseModel.success) { if (baseModel.success) {
@ -185,7 +194,7 @@ class _SubmitOrderNormalPageState extends State<SubmitOrderNormalPage> {
"settlementGoodsDTOList": "settlementGoodsDTOList":
_goodsList.map((v) => v.toJson()).toList(), _goodsList.map((v) => v.toJson()).toList(),
"payType": 1, // "payType": 1, //
"payPrice": _allPrice, "payPrice": totalPrice,
// 'points': widget.integral, // 'points': widget.integral,
"residentId": UserTool.userProvider.userInfoModel!.id, "residentId": UserTool.userProvider.userInfoModel!.id,
"payname": UserTool.userProvider.userInfoModel!.name, "payname": UserTool.userProvider.userInfoModel!.name,
@ -350,10 +359,11 @@ class _SubmitOrderNormalPageState extends State<SubmitOrderNormalPage> {
} }
int num = int.parse(_controllers.text); int num = int.parse(_controllers.text);
allNum += num; allNum = NumUtil.add(allNum, num).toInt();
allPrice += (widget.goodModel.sellPrice * num); allPrice = NumUtil.add(
allPrice, NumUtil.multiply(widget.goodModel.sellPrice, num));
_allPrice = allPrice + fee; totalPrice = NumUtil.add(allPrice, fee);
return Container( return Container(
padding: padding:
@ -400,7 +410,7 @@ class _SubmitOrderNormalPageState extends State<SubmitOrderNormalPage> {
children: [ children: [
Spacer(), Spacer(),
'应付金额:'.text.size(32.sp).color(Color(0xFF333333)).bold.make(), '应付金额:'.text.size(32.sp).color(Color(0xFF333333)).bold.make(),
'¥${allPrice + fee}' '¥${totalPrice}'
.text .text
.size(32.sp) .size(32.sp)
.color(Color(0xFFE52E2E)) .color(Color(0xFFE52E2E))

@ -124,9 +124,8 @@ class NetUtil {
}) async { }) async {
try { try {
Response res = await _dio!.get(path, queryParameters: params); Response res = await _dio!.get(path, queryParameters: params);
var base = BaseModel.fromJson(res.data); if (res.data['success']) {
if (base.success) { BaseListModel baseListModel = BaseListModel.fromJson(res.data['data']);
BaseListModel baseListModel = BaseListModel.fromJson(base.data);
return baseListModel; return baseListModel;
} else { } else {
return BaseListModel.err(); return BaseListModel.err();

Loading…
Cancel
Save