diff --git a/lib/constants/api.dart b/lib/constants/api.dart index b28202ac..94d24ef0 100644 --- a/lib/constants/api.dart +++ b/lib/constants/api.dart @@ -386,6 +386,9 @@ class _Upload { ///上传签名 String get uploadSignName => '/user/upload/uploadLeaseContractSignaturePhoto'; + + ///上传租赁有效(正式)合同pdf + String get uploadFormalContract => '/user/upload/uploadLeaseContractValidPdf'; } class _Message { @@ -452,6 +455,12 @@ class _Pay { ///支付宝支付:报事报修 向支付宝发起订单查询请求 String get reportReapirCheck => '/user/alipay/reportRepairCheckAlipay'; + + ///支付宝支付:app 房屋租赁完成订单支付宝支付(异步通知有可能会有问题) + String get leaseAlipay => '/user/alipay/leaseAlipay'; + + ///支付宝支付:房屋租赁 向支付宝发起订单查询请求 + String get leaseCheckAlipay => '/user/alipay/leaseCheckAlipay'; } class _House { @@ -472,5 +481,7 @@ class _House { ///我的房屋:生成合同 String get generateContract => '/user/myHouse/generateValidContract'; - + + ///我的房屋:提交租赁审核信息 + String get submitFormalContract => '/user/myHouse/submitAudit'; } diff --git a/lib/models/house/lease_detail_model.dart b/lib/models/house/lease_detail_model.dart index c7bed482..2c6eff0a 100644 --- a/lib/models/house/lease_detail_model.dart +++ b/lib/models/house/lease_detail_model.dart @@ -1,6 +1,8 @@ import 'package:equatable/equatable.dart'; import 'package:json_annotation/json_annotation.dart'; + import 'package:aku_community/model/common/img_model.dart'; + part 'lease_detail_model.g.dart'; @JsonSerializable() @@ -13,6 +15,9 @@ class LeaseDetailModel extends Equatable { final String roomName; final int type; final String estateType; + final String estateStructure; + final num constructionArea; + final num indoorArea; final num rentStandard; final num margin; final String leaseDateStart; @@ -38,6 +43,9 @@ class LeaseDetailModel extends Equatable { required this.roomName, required this.type, required this.estateType, + required this.estateStructure, + required this.constructionArea, + required this.indoorArea, required this.rentStandard, required this.margin, required this.leaseDateStart, @@ -87,5 +95,4 @@ class LeaseDetailModel extends Equatable { bankAccount, ]; } - } diff --git a/lib/models/house/lease_detail_model.g.dart b/lib/models/house/lease_detail_model.g.dart index bbf56f40..c96f1bc5 100644 --- a/lib/models/house/lease_detail_model.g.dart +++ b/lib/models/house/lease_detail_model.g.dart @@ -16,6 +16,9 @@ LeaseDetailModel _$LeaseDetailModelFromJson(Map json) { roomName: json['roomName'] as String, type: json['type'] as int, estateType: json['estateType'] as String, + estateStructure: json['estateStructure'] as String, + constructionArea: json['constructionArea'] as num, + indoorArea: json['indoorArea'] as num, rentStandard: json['rentStandard'] as num, margin: json['margin'] as num, leaseDateStart: json['leaseDateStart'] as String, diff --git a/lib/pages/life_pay/pay_util.dart b/lib/pages/life_pay/pay_util.dart index 771c2cc2..499e8aa8 100644 --- a/lib/pages/life_pay/pay_util.dart +++ b/lib/pages/life_pay/pay_util.dart @@ -51,14 +51,14 @@ class PayUtil { String _resultStatus = ''; ///传入订单信息和确认订单请求地址 - Future callAliPay(String order, String path) async { + Future callAliPay(String order, String apiPath) async { Map result = await aliPay(order); _resultStatus = result['resultStatus']; if (_resultStatus == '9000') { String _res = result['result']; PayModel _model = PayModel.fromJson(jsonDecode(_res)); bool _confirmResult = await _confirmPayResult( - path, _model.aliPayTradeAppPayResponse.outTradeNo); + apiPath, _model.aliPayTradeAppPayResponse.outTradeNo); return _confirmResult; } else { resultSatus(_resultStatus); diff --git a/lib/ui/profile/house/contract_pay_page.dart b/lib/ui/profile/house/contract_pay_page.dart index 4c1856eb..1065c20b 100644 --- a/lib/ui/profile/house/contract_pay_page.dart +++ b/lib/ui/profile/house/contract_pay_page.dart @@ -1,5 +1,8 @@ import 'package:aku_community/base/base_style.dart'; +import 'package:aku_community/constants/api.dart'; import 'package:aku_community/pages/life_pay/pay_finish_page.dart'; +import 'package:aku_community/pages/life_pay/pay_util.dart'; +import 'package:aku_community/ui/profile/house/house_func.dart'; import 'package:aku_community/widget/bee_scaffold.dart'; import 'package:aku_community/widget/buttons/bottom_button.dart'; import 'package:aku_community/widget/others/bee_input_row.dart'; @@ -11,7 +14,9 @@ import 'package:velocity_x/velocity_x.dart'; import 'package:aku_community/extensions/widget_list_ext.dart'; class ContractPayPage extends StatefulWidget { - ContractPayPage({Key? key}) : super(key: key); + final int id; + + ContractPayPage({Key? key, required this.id}) : super(key: key); @override _ContractPayPageState createState() => _ContractPayPageState(); @@ -64,8 +69,13 @@ class _ContractPayPageState extends State { ), bottomNavi: BottomButton( child: '点击支付'.text.size(32.sp).bold.color(ktextPrimary).make(), - onPressed: () { - Get.off(() => PayFinishPage()); + onPressed: () async { + String code = await HouseFunc().leaseAlipay(widget.id, 1, 0.01); + bool result = + await PayUtil().callAliPay(code, API.pay.leaseCheckAlipay); + if (result) { + Get.off(() => PayFinishPage()); + } }, ), ); diff --git a/lib/ui/profile/house/contract_preview_page.dart b/lib/ui/profile/house/contract_preview_page.dart index 681dfa5c..245a6ddd 100644 --- a/lib/ui/profile/house/contract_preview_page.dart +++ b/lib/ui/profile/house/contract_preview_page.dart @@ -81,6 +81,7 @@ class _ContractPreviewPageState extends State { .generateContract(widget.id, widget.url, result); Get.off(() => DownLoadContractPage( path: path, + id: widget.id, )); cancel(); } else { diff --git a/lib/ui/profile/house/download_contract_page.dart b/lib/ui/profile/house/download_contract_page.dart index b600fd2e..e65d0f7a 100644 --- a/lib/ui/profile/house/download_contract_page.dart +++ b/lib/ui/profile/house/download_contract_page.dart @@ -11,9 +11,11 @@ import 'package:velocity_x/velocity_x.dart'; class DownLoadContractPage extends StatefulWidget { final String path; + final int id; DownLoadContractPage({ Key? key, required this.path, + required this.id, }) : super(key: key); @override @@ -66,7 +68,9 @@ class _DownLoadContractPageState extends State { elevation: 0, color: kPrimaryColor, onPressed: () { - Get.to(() => UploadContractsPage()); + Get.to(() => UploadContractsPage( + id: widget.id, + )); }, child: '上传文件'.text.size(32.sp).bold.color(ktextPrimary).make(), diff --git a/lib/ui/profile/house/house_func.dart b/lib/ui/profile/house/house_func.dart index e997cc67..6a9ed507 100644 --- a/lib/ui/profile/house/house_func.dart +++ b/lib/ui/profile/house/house_func.dart @@ -96,7 +96,7 @@ class HouseFunc { ///提交个人租赁信息 Future submitLeaseInfo(SubmitModel model) async { BaseModel baseModel = - await NetUtil().get(API.house.submitLeaseInfo, params: { + await NetUtil().post(API.house.submitLeaseInfo, params: { "id": model.id, "emergencyContact": model.emergencyContact, "emergencyContactNumber": model.emergencyContactNumber, @@ -126,7 +126,7 @@ class HouseFunc { } } - ///生成正式合同 + ///生成正式合同(未盖章 Future generateContract(int id, String pUrl, String url) async { BaseModel baseModel = await NetUtil().post(API.house.generateContract, params: { @@ -142,6 +142,43 @@ class HouseFunc { } } + ///上传盖章后正式有效合同 + Future uploadFormalContract(File file) async { + BaseFileModel baseModel = + await NetUtil().upload(API.upload.uploadFormalContract, file); + if (baseModel.status ?? false) { + return baseModel.url!; + } else { + return ''; + } + } + + ///提交盖章后正式有效合同 + Future submitFormalContract(int id, List urls) async { + BaseModel baseModel = + await NetUtil().post(API.house.submitFormalContract, params: { + "id": id, + "leaseContractValidPdfUrl": urls, + }); + return baseModel.status!; + } + + ///支付宝生成订单 + ///支付方式暂时写死为1,只支持支付宝支付 + ///1支付,2微信 3现金 4pos + Future leaseAlipay(int id, int type, double price) async { + BaseModel baseModel = await NetUtil().post(API.pay.leaseAlipay, params: { + "sysLeaseId": id, + "payType": 1, + "payPrice": price, + }); + if (baseModel.status ?? false) { + return baseModel.message!; + } else { + return ''; + } + } + static Map getSex = { '男': 1, '女': 2, diff --git a/lib/ui/profile/house/house_information_check_page.dart b/lib/ui/profile/house/house_information_check_page.dart index 99374b82..4534156e 100644 --- a/lib/ui/profile/house/house_information_check_page.dart +++ b/lib/ui/profile/house/house_information_check_page.dart @@ -46,9 +46,10 @@ class _HouseInformationCheckPageState extends State { _houseHead(), _textTile('认定人才类型', HouseFunc.toType[widget.detailModel.type]!), _textTile('房屋户型', widget.detailModel.estateType), - _textTile('房屋结构', '两房两卫一厅'), - _textTile('建筑面积', '90平米'), - _textTile('使用面积', '78平米'), + _textTile('房屋结构', widget.detailModel.estateStructure), + _textTile( + '建筑面积', widget.detailModel.constructionArea.toStringAsFixed(2)), + _textTile('使用面积', widget.detailModel.indoorArea.toStringAsFixed(2)), _textTile('租赁期限', '${widget.detailModel.leaseDateStart}————${widget.detailModel.leaseDateEnd}'), ].sepWidget(separate: 24.w.heightBox), @@ -59,13 +60,13 @@ class _HouseInformationCheckPageState extends State { try { _submitModel.idCardFrontImgUrl.add(await HouseFunc() .uploadIdCardFront(_submitModel.idCardFrontFile!)); - _submitModel.idCardFrontImgUrl.add(await HouseFunc() + _submitModel.idCardBackImgUrl.add(await HouseFunc() .uploadIdCardBack(_submitModel.idCardBackFile!)); String result = await HouseFunc().submitLeaseInfo(_submitModel); if (result.isNotEmpty) { Get.back(); Get.off(() => ContractPreviewPage( - id: widget.detailModel.id, + id: widget.detailModel.id, url: result, )); } diff --git a/lib/ui/profile/house/lease_house_card.dart b/lib/ui/profile/house/lease_house_card.dart index 3ad69eec..2e51adb0 100644 --- a/lib/ui/profile/house/lease_house_card.dart +++ b/lib/ui/profile/house/lease_house_card.dart @@ -104,7 +104,7 @@ class LeaseHouseCard extends StatelessWidget { CardBottomButton.yellow( text: '上传合同', onPressed: () { - Get.to(() => UploadContractsPage()); + Get.to(() => UploadContractsPage(id: model.id,)); }), CardBottomButton.white( text: '下载合同', @@ -129,7 +129,7 @@ class LeaseHouseCard extends StatelessWidget { CardBottomButton.yellow( text: '重新上传', onPressed: () { - Get.to(() => UploadContractsPage()); + Get.to(() => UploadContractsPage(id: model.id,)); }), CardBottomButton.white( text: '修改信息', @@ -144,7 +144,7 @@ class LeaseHouseCard extends StatelessWidget { CardBottomButton.yellow( text: '去支付', onPressed: () { - Get.to(() => ContractPayPage()); + Get.to(() => ContractPayPage(id: model.id,)); }) ], ); diff --git a/lib/ui/profile/house/supplement_information_page.dart b/lib/ui/profile/house/supplement_information_page.dart index 3f9a3826..7dc69829 100644 --- a/lib/ui/profile/house/supplement_information_page.dart +++ b/lib/ui/profile/house/supplement_information_page.dart @@ -144,12 +144,14 @@ class _SupplementInformationPageState extends State { title: '代缴银行账户', controller: _bankCodeController, hintText: '填写代缴银行账户'), - IdentifyCardPicker.front((file) => () { - _idCardFront = file; - }), - IdentifyCardPicker.back((file) => () { - _idCardBack = file; - }), + IdentifyCardPicker.front((file) { + _idCardFront = file; + setState(() {}); + }), + IdentifyCardPicker.back((file) { + _idCardBack = file; + setState(() {}); + }), ].sepWidget(separate: 24.w.heightBox), ), bottomNavi: BottomButton( diff --git a/lib/ui/profile/house/upload_contracts_page.dart b/lib/ui/profile/house/upload_contracts_page.dart index 241aa4d6..4c66e741 100644 --- a/lib/ui/profile/house/upload_contracts_page.dart +++ b/lib/ui/profile/house/upload_contracts_page.dart @@ -3,10 +3,12 @@ import 'dart:io'; import 'package:aku_community/base/base_style.dart'; import 'package:aku_community/painters/upload_painter.dart'; import 'package:aku_community/ui/profile/house/contract_pay_page.dart'; +import 'package:aku_community/ui/profile/house/house_func.dart'; import 'package:aku_community/widget/bee_scaffold.dart'; import 'package:aku_community/widget/buttons/bottom_button.dart'; import 'package:aku_community/widget/picker/bee_image_picker.dart'; import 'package:aku_community/widget/views/doc_view.dart'; +import 'package:bot_toast/bot_toast.dart'; import 'package:dotted_border/dotted_border.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -17,7 +19,8 @@ import 'package:velocity_x/velocity_x.dart'; import 'package:aku_community/extensions/widget_list_ext.dart'; class UploadContractsPage extends StatefulWidget { - UploadContractsPage({Key? key}) : super(key: key); + final int id; + UploadContractsPage({Key? key, required this.id}) : super(key: key); @override _UploadContractsPageState createState() => _UploadContractsPageState(); @@ -25,6 +28,7 @@ class UploadContractsPage extends StatefulWidget { class _UploadContractsPageState extends State { List _files = []; + List _urls = []; @override Widget build(BuildContext context) { return BeeScaffold( @@ -86,8 +90,19 @@ class _UploadContractsPageState extends State { ], ), bottomNavi: BottomButton( - onPressed: () { - Get.to(() => ContractPayPage()); + onPressed: () async { + Function cancel = BotToast.showLoading(); + await _files.map((e) async { + String result = await HouseFunc().uploadFormalContract(e); + if (result.isNotEmpty) { + _urls.add(result); + } + }); + bool result = + await HouseFunc().submitFormalContract(widget.id, _urls); + if (result) { + Get.to(() => ContractPayPage(id: widget.id,)); + } }, child: '提交审核'.text.size(32.sp).color(ktextPrimary).bold.make()), ); diff --git a/lib/widget/picker/identify_card_picker.dart b/lib/widget/picker/identify_card_picker.dart index b3dff77e..39c31341 100644 --- a/lib/widget/picker/identify_card_picker.dart +++ b/lib/widget/picker/identify_card_picker.dart @@ -51,7 +51,6 @@ class _IdentifyCardPickerState extends State { onTap: () async { _file = await BeeImagePicker.pick(title: '选择身份证照片'); if (_file != null) { - setState(() {}); widget.onChange(_file); } },