diff --git a/lib/model/manager/fixed_detail_model.dart b/lib/model/manager/fixed_detail_model.dart deleted file mode 100644 index 3f2b9a6f..00000000 --- a/lib/model/manager/fixed_detail_model.dart +++ /dev/null @@ -1,134 +0,0 @@ -import 'package:aku_community/model/common/img_model.dart'; - -class FixedDetailModel { - AppReportRepairVo? appReportRepairVo; - List? appProcessRecordVo; - Null appMaintenanceResultVo; - AppDispatchListVo? appDispatchListVo; - - FixedDetailModel( - {this.appReportRepairVo, - this.appProcessRecordVo, - this.appMaintenanceResultVo, - this.appDispatchListVo}); - - FixedDetailModel.fromJson(Map json) { - appReportRepairVo = json['appReportRepairVo'] != null - ? new AppReportRepairVo.fromJson(json['appReportRepairVo']) - : null; - if (json['appProcessRecordVo'] != null) { - appProcessRecordVo = []; - json['appProcessRecordVo'].forEach((v) { - appProcessRecordVo!.add(new AppProcessRecordVo.fromJson(v)); - }); - } - appMaintenanceResultVo = json['appMaintenanceResultVo']; - appDispatchListVo = json['appDispatchListVo'] != null - ? new AppDispatchListVo.fromJson(json['appDispatchListVo']) - : null; - } - - Map toJson() { - final Map data = new Map(); - if (this.appReportRepairVo != null) { - data['appReportRepairVo'] = this.appReportRepairVo!.toJson(); - } - if (this.appProcessRecordVo != null) { - data['appProcessRecordVo'] = - this.appProcessRecordVo!.map((v) => v.toJson()).toList(); - } - data['appMaintenanceResultVo'] = this.appMaintenanceResultVo; - if (this.appDispatchListVo != null) { - data['appDispatchListVo'] = this.appDispatchListVo!.toJson(); - } - return data; - } -} - -class AppReportRepairVo { - int? id; - int? type; - int? status; - String? reportDetail; - List? imgUrls; - - AppReportRepairVo( - {this.id, this.type, this.status, this.reportDetail, this.imgUrls}); - - AppReportRepairVo.fromJson(Map json) { - id = json['id']; - type = json['type']; - status = json['status']; - reportDetail = json['reportDetail']; - if (json['imgUrls'] != null) { - imgUrls = []; - json['imgUrls'].forEach((v) { - imgUrls!.add(new ImgModel.fromJson(v)); - }); - } - } - - Map toJson() { - final Map data = new Map(); - data['id'] = this.id; - data['type'] = this.type; - data['status'] = this.status; - data['reportDetail'] = this.reportDetail; - if (this.imgUrls != null) { - data['imgUrls'] = this.imgUrls!.map((v) => v.toJson()).toList(); - } - return data; - } -} - -class AppProcessRecordVo { - String? operationDate; - int? operationType; - - AppProcessRecordVo({this.operationDate, this.operationType}); - - AppProcessRecordVo.fromJson(Map json) { - operationDate = json['operationDate']; - operationType = json['operationType']; - } - - Map toJson() { - final Map data = new Map(); - data['operationDate'] = this.operationDate; - data['operationType'] = this.operationType; - return data; - } -} - -class AppDispatchListVo { - String? code; - String? orderDate; - int? type; - String? operatorName; - String? distributorName; - - AppDispatchListVo( - {this.code, - this.orderDate, - this.type, - this.operatorName, - this.distributorName}); - - AppDispatchListVo.fromJson(Map json) { - code = json['code']; - orderDate = json['orderDate']; - type = json['type']; - operatorName = json['operatorName']; - distributorName = json['distributorName']; - } - - Map toJson() { - final Map data = new Map(); - data['code'] = this.code; - data['orderDate'] = this.orderDate; - data['type'] = this.type; - data['operatorName'] = this.operatorName; - data['distributorName'] = this.distributorName; - return data; - } -} diff --git a/lib/models/manage/fix_report/fix_detail_model.dart b/lib/models/manage/fix_report/fix_detail_model.dart new file mode 100644 index 00000000..0983ab64 --- /dev/null +++ b/lib/models/manage/fix_report/fix_detail_model.dart @@ -0,0 +1,132 @@ +import 'package:equatable/equatable.dart'; +import 'package:json_annotation/json_annotation.dart'; + +import 'package:aku_community/model/common/img_model.dart'; + +part 'fix_detail_model.g.dart'; + +@JsonSerializable() +class FixDetailModel extends Equatable { + final AppReportRepairVo appReportRepairVo; + @JsonKey(includeIfNull: true) + final List appProcessRecordVo; + final AppMaintenanceResultVo? appMaintenanceResultVo; + final AppDispatchListVo? appDispatchListVo; + FixDetailModel({ + required this.appReportRepairVo, + required this.appProcessRecordVo, + this.appMaintenanceResultVo, + required this.appDispatchListVo, + }); + factory FixDetailModel.fromJson(Map json) => + _$FixDetailModelFromJson(json); + @override + List get props => [ + appReportRepairVo, + appProcessRecordVo, + appMaintenanceResultVo, + appDispatchListVo + ]; +} + +@JsonSerializable() +class AppReportRepairVo extends Equatable { + final int id; + final int type; + final int status; + final String reportDetail; + final List imgUrls; + AppReportRepairVo({ + required this.id, + required this.type, + required this.status, + required this.reportDetail, + required this.imgUrls, + }); + + factory AppReportRepairVo.fromJson(Map json) => + _$AppReportRepairVoFromJson(json); + @override + List get props { + return [ + id, + type, + status, + reportDetail, + imgUrls, + ]; + } +} + +@JsonSerializable() +class AppProcessRecordVo extends Equatable { + final String operationDate; + final int operationType; + AppProcessRecordVo({ + required this.operationDate, + required this.operationType, + }); + + factory AppProcessRecordVo.fromJson(Map json) => + _$AppProcessRecordVoFromJson(json); + @override + List get props => [operationDate, operationType]; +} + +@JsonSerializable() +class AppDispatchListVo extends Equatable { + final String code; + final String orderDate; + final int type; + final String operatorName; + final String distributorName; + AppDispatchListVo({ + required this.code, + required this.orderDate, + required this.type, + required this.operatorName, + required this.distributorName, + }); + + factory AppDispatchListVo.fromJson(Map json) => + _$AppDispatchListVoFromJson(json); + @override + List get props { + return [ + code, + orderDate, + type, + operatorName, + distributorName, + ]; + } +} + +@JsonSerializable() +class AppMaintenanceResultVo extends Equatable { + final int id; + final num? laborCost; + final num? materialCost; + final num? totalCost; + final List imgUrls; + AppMaintenanceResultVo({ + required this.id, + this.laborCost, + this.materialCost, + this.totalCost, + required this.imgUrls, + }); + + factory AppMaintenanceResultVo.fromJson(Map json) => + _$AppMaintenanceResultVoFromJson(json); + @override + List get props { + return [ + id, + laborCost, + materialCost, + totalCost, + imgUrls, + ]; + } +} diff --git a/lib/models/manage/fix_report/fix_detail_model.g.dart b/lib/models/manage/fix_report/fix_detail_model.g.dart new file mode 100644 index 00000000..7b5e6a70 --- /dev/null +++ b/lib/models/manage/fix_report/fix_detail_model.g.dart @@ -0,0 +1,67 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'fix_detail_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +FixDetailModel _$FixDetailModelFromJson(Map json) { + return FixDetailModel( + appReportRepairVo: AppReportRepairVo.fromJson( + json['appReportRepairVo'] as Map), + appProcessRecordVo: (json['appProcessRecordVo'] as List) + .map((e) => AppProcessRecordVo.fromJson(e as Map)) + .toList(), + appMaintenanceResultVo: json['appMaintenanceResultVo'] == null + ? null + : AppMaintenanceResultVo.fromJson( + json['appMaintenanceResultVo'] as Map), + appDispatchListVo: json['appDispatchListVo'] == null + ? null + : AppDispatchListVo.fromJson( + json['appDispatchListVo'] as Map), + ); +} + +AppReportRepairVo _$AppReportRepairVoFromJson(Map json) { + return AppReportRepairVo( + id: json['id'] as int, + type: json['type'] as int, + status: json['status'] as int, + reportDetail: json['reportDetail'] as String, + imgUrls: (json['imgUrls'] as List) + .map((e) => ImgModel.fromJson(e as Map)) + .toList(), + ); +} + +AppProcessRecordVo _$AppProcessRecordVoFromJson(Map json) { + return AppProcessRecordVo( + operationDate: json['operationDate'] as String, + operationType: json['operationType'] as int, + ); +} + +AppDispatchListVo _$AppDispatchListVoFromJson(Map json) { + return AppDispatchListVo( + code: json['code'] as String, + orderDate: json['orderDate'] as String, + type: json['type'] as int, + operatorName: json['operatorName'] as String, + distributorName: json['distributorName'] as String, + ); +} + +AppMaintenanceResultVo _$AppMaintenanceResultVoFromJson( + Map json) { + return AppMaintenanceResultVo( + id: json['id'] as int, + laborCost: json['laborCost'] as num?, + materialCost: json['materialCost'] as num?, + totalCost: json['totalCost'] as num?, + imgUrls: (json['imgUrls'] as List) + .map((e) => ImgModel.fromJson(e as Map)) + .toList(), + ); +} diff --git a/lib/pages/manager_func.dart b/lib/pages/manager_func.dart index 3b1211c3..dd87d555 100644 --- a/lib/pages/manager_func.dart +++ b/lib/pages/manager_func.dart @@ -1,10 +1,10 @@ +import 'package:aku_community/models/manage/fix_report/fix_detail_model.dart'; import 'package:bot_toast/bot_toast.dart'; import 'package:dio/dio.dart'; import 'package:flustars/flustars.dart'; import 'package:aku_community/constants/api.dart'; import 'package:aku_community/model/manager/article_QR_code_model.dart'; -import 'package:aku_community/model/manager/fixed_detail_model.dart'; import 'package:aku_community/model/manager/moving_company_model.dart'; import 'package:aku_community/model/manager/questionnaire_detail_model.dart'; import 'package:aku_community/model/manager/quetionnaire_submit_model.dart'; @@ -85,14 +85,14 @@ class ManagerFunc { return baseModel; } - static Future reportRepairFindBYLD(int? id) async { + static Future reportRepairFindBYLD(int? id) async { Response response = await NetUtil().dio!.get( API.manager.reportRepairFindBYLD, queryParameters: { 'repairId': id, }, ); - return FixedDetailModel.fromJson(response.data); + return FixDetailModel.fromJson(response.data); } static Future reportRepairCancel(int? id) async { @@ -129,6 +129,19 @@ class ManagerFunc { return baseModel; } + static Future reportRepairAlipay(int? id,double total) async { + BaseModel baseModel = await NetUtil().post( + API.pay.reportRepairAlipay, + params: { + 'repairId': id, + 'payType':1, + 'payPrice':total, + }, + showMessage: false, + ); + return baseModel; + } + static Future getMovingCompanyTel() async { Response response = await NetUtil().dio!.get( API.manager.getMovingCompanyTel, diff --git a/lib/pages/things_page/widget/fixed_detail_page.dart b/lib/pages/things_page/widget/fixed_detail_page.dart index 53ba5bda..16a75fe4 100644 --- a/lib/pages/things_page/widget/fixed_detail_page.dart +++ b/lib/pages/things_page/widget/fixed_detail_page.dart @@ -1,3 +1,7 @@ +import 'package:aku_community/constants/api.dart'; +import 'package:aku_community/models/manage/fix_report/fix_detail_model.dart'; +import 'package:aku_community/pages/life_pay/pay_finish_page.dart'; +import 'package:aku_community/pages/life_pay/pay_util.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -10,7 +14,6 @@ import 'package:velocity_x/velocity_x.dart'; import 'package:aku_community/base/base_style.dart'; import 'package:aku_community/const/resource.dart'; -import 'package:aku_community/model/manager/fixed_detail_model.dart'; import 'package:aku_community/pages/manager_func.dart'; import 'package:aku_community/pages/things_page/widget/fixed_evaluate_page.dart'; import 'package:aku_community/utils/bee_map.dart'; @@ -40,9 +43,9 @@ class CancelModel { class _FixedDetailPageState extends State { bool _onLoading = true; EasyRefreshController _easyRefreshController = EasyRefreshController(); - FixedDetailModel _model = FixedDetailModel(); + late FixDetailModel _model; bool get showRepairCard => _model.appDispatchListVo != null; - bool get showProcessCard => _model.appProcessRecordVo!.isNotEmpty; + bool get showProcessCard => _model.appProcessRecordVo.isNotEmpty; bool _canComplete(int? state) { switch (state) { @@ -76,7 +79,7 @@ class _FixedDetailPageState extends State { } } - Widget _buildHead(FixedDetailModel model) { + Widget _buildHead(FixDetailModel model) { return Container( decoration: BoxDecoration( color: kForeGroundColor, borderRadius: BorderRadius.circular(8.w)), @@ -100,14 +103,13 @@ class _FixedDetailPageState extends State { borderRadius: BorderRadius.circular(36.w), color: Colors.transparent, ), - child: BeeMap - .fixTag[model.appReportRepairVo!.type!]!.text.black + child: BeeMap.fixTag[model.appReportRepairVo.type]!.text.black .size(20.sp) .make(), ), Spacer(), - BeeMap.fixState[model.appReportRepairVo!.status!]!.text - .color(_getColor(_model.appReportRepairVo!.status)) + BeeMap.fixState[model.appReportRepairVo.status]!.text + .color(_getColor(_model.appReportRepairVo.status)) .size(24.sp) .bold .make() @@ -121,7 +123,7 @@ class _FixedDetailPageState extends State { 24.w.heightBox, Padding( padding: EdgeInsets.symmetric(horizontal: 28.w), - child: model.appReportRepairVo!.reportDetail!.text.black + child: model.appReportRepairVo.reportDetail.text.black .size(28.sp) .maxLines(8) .overflow(TextOverflow.ellipsis) @@ -130,7 +132,7 @@ class _FixedDetailPageState extends State { Padding( padding: EdgeInsets.symmetric(horizontal: 8.w, vertical: 8.w), child: HorizontalImageView( - model.appReportRepairVo!.imgUrls!.map((e) => e.url).toList()), + model.appReportRepairVo.imgUrls.map((e) => e.url).toList()), ) ], ), @@ -141,7 +143,7 @@ class _FixedDetailPageState extends State { return Container(); } - Widget _reparCard(FixedDetailModel model) { + Widget _reparCard(FixDetailModel model) { return Container( padding: EdgeInsets.symmetric(horizontal: 28.w, vertical: 24.w), decoration: BoxDecoration( @@ -159,14 +161,14 @@ class _FixedDetailPageState extends State { children: [ '订单编号'.text.color(ktextSubColor).size(28.sp).make(), Spacer(), - model.appDispatchListVo!.code!.text.black.size(28.sp).make(), + model.appDispatchListVo!.code.text.black.size(28.sp).make(), ], ), Row( children: [ '下单时间'.text.color(ktextSubColor).size(28.sp).make(), Spacer(), - model.appDispatchListVo!.orderDate!.text.black + model.appDispatchListVo!.orderDate.text.black .size(28.sp) .make() ], @@ -175,14 +177,14 @@ class _FixedDetailPageState extends State { children: [ '派单类型'.text.color(ktextSubColor).size(28.sp).make(), Spacer(), - model.appDispatchListVo!.type!.text.black.size(28.sp).make(), + model.appDispatchListVo!.type.text.black.size(28.sp).make(), ], ), Row( children: [ '维修人员'.text.color(ktextSubColor).size(28.sp).make(), Spacer(), - model.appDispatchListVo!.operatorName!.text.black + model.appDispatchListVo!.operatorName.text.black .size(28.sp) .make(), ], @@ -191,7 +193,7 @@ class _FixedDetailPageState extends State { children: [ '分配人'.text.color(ktextSubColor).size(28.sp).make(), Spacer(), - model.appDispatchListVo!.distributorName!.text.black + model.appDispatchListVo!.distributorName.text.black .size(28.sp) .make(), ], @@ -203,7 +205,7 @@ class _FixedDetailPageState extends State { ); } - Widget _buildProcessCard(FixedDetailModel model) { + Widget _buildProcessCard(FixDetailModel model) { return Container( padding: EdgeInsets.symmetric(horizontal: 28.w, vertical: 24.w), decoration: BoxDecoration( @@ -217,16 +219,16 @@ class _FixedDetailPageState extends State { 24.w.heightBox, BeeDivider.horizontal(), 24.w.heightBox, - ...model.appProcessRecordVo! + ...model.appProcessRecordVo .map((e) => Row( children: [ - (BeeMap.processClass[e.operationType ?? 0] ?? '') + (BeeMap.processClass[e.operationType] ?? '') .text .color(ktextSubColor) .size(28.sp) .make(), Spacer(), - e.operationDate!.text.black.size(28.sp).make(), + e.operationDate.text.black.size(28.sp).make(), ], )) .toList() @@ -236,7 +238,7 @@ class _FixedDetailPageState extends State { ); } - Widget _buttons(FixedDetailModel model) { + Widget _buttons(FixDetailModel model) { return Container( width: 228.w * 3, height: 96.w, @@ -252,11 +254,11 @@ class _FixedDetailPageState extends State { materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, onPressed: () async { CancelModel _cancel = - _allowCancel(_model.appReportRepairVo!.status); + _allowCancel(_model.appReportRepairVo.status); if (_cancel.cancel) { BotToast.showLoading(); await ManagerFunc.reportRepairCancel( - _model.appReportRepairVo!.id); + _model.appReportRepairVo.id); BotToast.closeAllLoading(); Get.back(); } else { @@ -390,7 +392,26 @@ class _FixedDetailPageState extends State { } } - Widget _showBottomSheet(FixedDetailModel model) { + Future _payOnAliy() async { + Function cancel = BotToast.showLoading(); + BaseModel baseModel = await ManagerFunc.reportRepairAlipay( + _model.appReportRepairVo.id, + (_model.appMaintenanceResultVo!.totalCost ?? 0).toDouble()); + if ((baseModel.status ?? false) && !baseModel.message.isEmptyOrNull) { + bool result = await PayUtil() + .callAliPay(baseModel.message!, API.pay.reportReapirCheck); + if (result) { + Get.back(); + Get.off(PayFinishPage()); + } + } else { + Get.back(); + BotToast.showText(text: '订单生成失败'); + } + cancel(); + } + + Widget _showBottomSheet(FixDetailModel model) { return BottomSheet( builder: (BuildContext context) { return Container( @@ -423,7 +444,7 @@ class _FixedDetailPageState extends State { children: [ '维修费用总计'.text.black.size(28.sp).isIntrinsic.make(), Spacer(), - '¥300' + '¥${model.appMaintenanceResultVo!.totalCost ?? 0}' .text .color(kDangerColor) .size(42.sp) @@ -437,7 +458,7 @@ class _FixedDetailPageState extends State { children: [ '维修人工费'.text.black.size(28.sp).isIntrinsic.make(), Spacer(), - '¥300' + '¥${model.appMaintenanceResultVo!.laborCost ?? 0}' .text .color(ktextPrimary) .size(32.sp) @@ -451,7 +472,7 @@ class _FixedDetailPageState extends State { children: [ '维修材料费'.text.black.size(28.sp).isIntrinsic.make(), Spacer(), - '¥0' + '¥${model.appMaintenanceResultVo!.materialCost ?? 0}' .text .color(ktextPrimary) .size(32.sp) @@ -472,18 +493,12 @@ class _FixedDetailPageState extends State { disabledColor: kDarkSubColor, disabledTextColor: ktextPrimary.withOpacity(0.8), minWidth: 375.w, - onPressed: _canComplete(_model.appReportRepairVo!.status) + onPressed: _canComplete(_model.appReportRepairVo.status) ? () async { - BaseModel baseModel = - await ManagerFunc.reportRepairComplete( - _model.appReportRepairVo!.id); - if (baseModel.status!) { - Get.back(); - Get.back(); - } + await _payOnAliy(); } : null, - child: '完成维修'.text.size(32.sp).bold.make(), + child: '立即付款'.text.size(32.sp).bold.make(), padding: EdgeInsets.symmetric(vertical: 26.w), materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, elevation: 0, diff --git a/lib/pages/things_page/widget/fixed_evaluate_page.dart b/lib/pages/things_page/widget/fixed_evaluate_page.dart index 1cc39ec7..b17c5f3d 100644 --- a/lib/pages/things_page/widget/fixed_evaluate_page.dart +++ b/lib/pages/things_page/widget/fixed_evaluate_page.dart @@ -1,3 +1,4 @@ +import 'package:aku_community/models/manage/fix_report/fix_detail_model.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -7,14 +8,13 @@ import 'package:get/get.dart'; import 'package:velocity_x/velocity_x.dart'; import 'package:aku_community/base/base_style.dart'; -import 'package:aku_community/model/manager/fixed_detail_model.dart'; import 'package:aku_community/pages/manager_func.dart'; import 'package:aku_community/utils/headers.dart'; import 'package:aku_community/utils/network/base_model.dart'; import 'package:aku_community/widget/bee_scaffold.dart'; class FixedEvaluatePage extends StatefulWidget { - final FixedDetailModel model; + final FixDetailModel model; FixedEvaluatePage(this.model, {Key? key}) : super(key: key); @override @@ -109,7 +109,7 @@ class _FixedEvaluatePageState extends State { BotToast.showText(text: '评价内容不能为空!'); } else { BaseModel baseModel = await ManagerFunc.reportRepairEvaluate( - widget.model.appReportRepairVo!.id, + widget.model.appReportRepairVo.id, _rating, _textEditingController!.text); if (baseModel.status!) {