Commit 5a21b9846e1da3d8a29d27f37b6fbd957135b9d1

Authored by wdn127929
1 parent d9803350

交易记录 && 查询 && 详情&& 退款

  1 +/*
  2 + Flutter3.x完全开发手册 https://www.flutterschool.cn/
  3 +*/
  4 +class DiscountOrderInfoModelData {
  5 +/*
  6 +{
  7 + "id": "3",
  8 + "status": "5",
  9 + "activity_id": null,
  10 + "price": "0.01",
  11 + "balance": null,
  12 + "sellerid": "8",
  13 + "openid": "oB-xJ5GoISP77QEx5zvA4F9LU-uc",
  14 + "out_trade_no": "202502241617198",
  15 + "out_refund_no": null,
  16 + "transaction_id": "4200002631202502248048942186",
  17 + "refund_id": "50302602342025022488986516546",
  18 + "re_out_trade_no": null,
  19 + "trade_state": "SUCCESS",
  20 + "trade_state_desc": "支付成功",
  21 + "out_request_no": null,
  22 + "withdraw_id": null,
  23 + "refund_cdate": null,
  24 + "cdate": "1740385039",
  25 + "sellername": "育知烤鸭旗舰店",
  26 + "applyment_sub_mchid": "1605686747",
  27 + "activity_list": [
  28 + "1605686747"
  29 + ]
  30 +}
  31 +*/
  32 +
  33 + String? id;
  34 + String? status;
  35 + String? activityId;
  36 + String? price;
  37 + String? balance;
  38 + String? sellerid;
  39 + String? openid;
  40 + String? outTradeNo;
  41 + String? outRefundNo;
  42 + String? transactionId;
  43 + String? refundId;
  44 + String? reOutTradeNo;
  45 + String? tradeState;
  46 + String? tradeStateDesc;
  47 + String? outRequestNo;
  48 + String? withdrawId;
  49 + String? refundCdate;
  50 + String? cdate;
  51 + String? sellername;
  52 + String? applymentSubMchid;
  53 + List<String?>? activityList;
  54 +
  55 + DiscountOrderInfoModelData({
  56 + this.id,
  57 + this.status,
  58 + this.activityId,
  59 + this.price,
  60 + this.balance,
  61 + this.sellerid,
  62 + this.openid,
  63 + this.outTradeNo,
  64 + this.outRefundNo,
  65 + this.transactionId,
  66 + this.refundId,
  67 + this.reOutTradeNo,
  68 + this.tradeState,
  69 + this.tradeStateDesc,
  70 + this.outRequestNo,
  71 + this.withdrawId,
  72 + this.refundCdate,
  73 + this.cdate,
  74 + this.sellername,
  75 + this.applymentSubMchid,
  76 + this.activityList,
  77 + });
  78 + DiscountOrderInfoModelData.fromJson(Map<String, dynamic> json) {
  79 + id = json['id']?.toString();
  80 + status = json['status']?.toString();
  81 + activityId = json['activity_id']?.toString();
  82 + price = json['price']?.toString();
  83 + balance = json['balance']?.toString();
  84 + sellerid = json['sellerid']?.toString();
  85 + openid = json['openid']?.toString();
  86 + outTradeNo = json['out_trade_no']?.toString();
  87 + outRefundNo = json['out_refund_no']?.toString();
  88 + transactionId = json['transaction_id']?.toString();
  89 + refundId = json['refund_id']?.toString();
  90 + reOutTradeNo = json['re_out_trade_no']?.toString();
  91 + tradeState = json['trade_state']?.toString();
  92 + tradeStateDesc = json['trade_state_desc']?.toString();
  93 + outRequestNo = json['out_request_no']?.toString();
  94 + withdrawId = json['withdraw_id']?.toString();
  95 + refundCdate = json['refund_cdate']?.toString();
  96 + cdate = json['cdate']?.toString();
  97 + sellername = json['sellername']?.toString();
  98 + applymentSubMchid = json['applyment_sub_mchid']?.toString();
  99 + if (json['activity_list'] != null) {
  100 + final v = json['activity_list'];
  101 + final arr0 = <String>[];
  102 + v.forEach((v) {
  103 + arr0.add(v.toString());
  104 + });
  105 + activityList = arr0;
  106 + }
  107 + }
  108 + Map<String, dynamic> toJson() {
  109 + final data = <String, dynamic>{};
  110 + data['id'] = id;
  111 + data['status'] = status;
  112 + data['activity_id'] = activityId;
  113 + data['price'] = price;
  114 + data['balance'] = balance;
  115 + data['sellerid'] = sellerid;
  116 + data['openid'] = openid;
  117 + data['out_trade_no'] = outTradeNo;
  118 + data['out_refund_no'] = outRefundNo;
  119 + data['transaction_id'] = transactionId;
  120 + data['refund_id'] = refundId;
  121 + data['re_out_trade_no'] = reOutTradeNo;
  122 + data['trade_state'] = tradeState;
  123 + data['trade_state_desc'] = tradeStateDesc;
  124 + data['out_request_no'] = outRequestNo;
  125 + data['withdraw_id'] = withdrawId;
  126 + data['refund_cdate'] = refundCdate;
  127 + data['cdate'] = cdate;
  128 + data['sellername'] = sellername;
  129 + data['applyment_sub_mchid'] = applymentSubMchid;
  130 + if (activityList != null) {
  131 + final v = activityList;
  132 + final arr0 = [];
  133 + v!.forEach((v) {
  134 + arr0.add(v);
  135 + });
  136 + data['activity_list'] = arr0;
  137 + }
  138 + return data;
  139 + }
  140 +}
  141 +
  142 +class DiscountOrderInfoModel {
  143 +/*
  144 +{
  145 + "ret": 200,
  146 + "data": {
  147 + "id": "3",
  148 + "status": "5",
  149 + "activity_id": null,
  150 + "price": "0.01",
  151 + "balance": null,
  152 + "sellerid": "8",
  153 + "openid": "oB-xJ5GoISP77QEx5zvA4F9LU-uc",
  154 + "out_trade_no": "202502241617198",
  155 + "out_refund_no": null,
  156 + "transaction_id": "4200002631202502248048942186",
  157 + "refund_id": "50302602342025022488986516546",
  158 + "re_out_trade_no": null,
  159 + "trade_state": "SUCCESS",
  160 + "trade_state_desc": "支付成功",
  161 + "out_request_no": null,
  162 + "withdraw_id": null,
  163 + "refund_cdate": null,
  164 + "cdate": "1740385039",
  165 + "sellername": "育知烤鸭旗舰店",
  166 + "applyment_sub_mchid": "1605686747",
  167 + "activity_list": [
  168 + "1605686747"
  169 + ]
  170 + },
  171 + "msg": ""
  172 +}
  173 +*/
  174 +
  175 + int? ret;
  176 + DiscountOrderInfoModelData? data;
  177 + String? msg;
  178 +
  179 + DiscountOrderInfoModel({
  180 + this.ret,
  181 + this.data,
  182 + this.msg,
  183 + });
  184 + DiscountOrderInfoModel.fromJson(Map< dynamic, dynamic> json) {
  185 + ret = json['ret']?.toInt();
  186 + data = (json['data'] != null) ? DiscountOrderInfoModelData.fromJson(json['data']) : null;
  187 + msg = json['msg']?.toString();
  188 + }
  189 + Map<String, dynamic> toJson() {
  190 + final data = <String, dynamic>{};
  191 + data['ret'] = ret;
  192 + if (data != null) {
  193 + data['data'] = this.data!.toJson();
  194 + }
  195 + data['msg'] = msg;
  196 + return data;
  197 + }
  198 +}
  1 +/*
  2 + Flutter3.x完全开发手册 https://www.flutterschool.cn/
  3 +*/
  4 +class DiscountOrderListModelDataList {
  5 +/*
  6 +{
  7 + "id": "3",
  8 + "status": "5",
  9 + "activity_id": null,
  10 + "price": "0.01",
  11 + "balance": null,
  12 + "sellerid": "8",
  13 + "openid": "oB-xJ5GoISP77QEx5zvA4F9LU-uc",
  14 + "out_trade_no": "202502241617198",
  15 + "out_refund_no": null,
  16 + "transaction_id": "4200002631202502248048942186",
  17 + "refund_id": "50302602342025022488986516546",
  18 + "re_out_trade_no": null,
  19 + "trade_state": "SUCCESS",
  20 + "trade_state_desc": "支付成功",
  21 + "out_request_no": null,
  22 + "withdraw_id": null,
  23 + "refund_cdate": null,
  24 + "cdate": "1740385039"
  25 +}
  26 +*/
  27 +
  28 + String? id;
  29 + String? status;
  30 + String? activityId;
  31 + String? price;
  32 + String? balance;
  33 + String? sellerid;
  34 + String? openid;
  35 + String? outTradeNo;
  36 + String? outRefundNo;
  37 + String? transactionId;
  38 + String? refundId;
  39 + String? reOutTradeNo;
  40 + String? tradeState;
  41 + String? tradeStateDesc;
  42 + String? outRequestNo;
  43 + String? withdrawId;
  44 + String? refundCdate;
  45 + String? cdate;
  46 +
  47 + DiscountOrderListModelDataList({
  48 + this.id,
  49 + this.status,
  50 + this.activityId,
  51 + this.price,
  52 + this.balance,
  53 + this.sellerid,
  54 + this.openid,
  55 + this.outTradeNo,
  56 + this.outRefundNo,
  57 + this.transactionId,
  58 + this.refundId,
  59 + this.reOutTradeNo,
  60 + this.tradeState,
  61 + this.tradeStateDesc,
  62 + this.outRequestNo,
  63 + this.withdrawId,
  64 + this.refundCdate,
  65 + this.cdate,
  66 + });
  67 + DiscountOrderListModelDataList.fromJson(Map<String, dynamic> json) {
  68 + id = json['id']?.toString();
  69 + status = json['status']?.toString();
  70 + activityId = json['activity_id']?.toString();
  71 + price = json['price']?.toString();
  72 + balance = json['balance']?.toString();
  73 + sellerid = json['sellerid']?.toString();
  74 + openid = json['openid']?.toString();
  75 + outTradeNo = json['out_trade_no']?.toString();
  76 + outRefundNo = json['out_refund_no']?.toString();
  77 + transactionId = json['transaction_id']?.toString();
  78 + refundId = json['refund_id']?.toString();
  79 + reOutTradeNo = json['re_out_trade_no']?.toString();
  80 + tradeState = json['trade_state']?.toString();
  81 + tradeStateDesc = json['trade_state_desc']?.toString();
  82 + outRequestNo = json['out_request_no']?.toString();
  83 + withdrawId = json['withdraw_id']?.toString();
  84 + refundCdate = json['refund_cdate']?.toString();
  85 + cdate = json['cdate']?.toString();
  86 + }
  87 + Map<String, dynamic> toJson() {
  88 + final data = <String, dynamic>{};
  89 + data['id'] = id;
  90 + data['status'] = status;
  91 + data['activity_id'] = activityId;
  92 + data['price'] = price;
  93 + data['balance'] = balance;
  94 + data['sellerid'] = sellerid;
  95 + data['openid'] = openid;
  96 + data['out_trade_no'] = outTradeNo;
  97 + data['out_refund_no'] = outRefundNo;
  98 + data['transaction_id'] = transactionId;
  99 + data['refund_id'] = refundId;
  100 + data['re_out_trade_no'] = reOutTradeNo;
  101 + data['trade_state'] = tradeState;
  102 + data['trade_state_desc'] = tradeStateDesc;
  103 + data['out_request_no'] = outRequestNo;
  104 + data['withdraw_id'] = withdrawId;
  105 + data['refund_cdate'] = refundCdate;
  106 + data['cdate'] = cdate;
  107 + return data;
  108 + }
  109 +}
  110 +
  111 +class DiscountOrderListModelData {
  112 +/*
  113 +{
  114 + "date": "2025年02月24日",
  115 + "total": 0.06,
  116 + "refund_total": 0.05,
  117 + "list": [
  118 + {
  119 + "id": "3",
  120 + "status": "5",
  121 + "activity_id": null,
  122 + "price": "0.01",
  123 + "balance": null,
  124 + "sellerid": "8",
  125 + "openid": "oB-xJ5GoISP77QEx5zvA4F9LU-uc",
  126 + "out_trade_no": "202502241617198",
  127 + "out_refund_no": null,
  128 + "transaction_id": "4200002631202502248048942186",
  129 + "refund_id": "50302602342025022488986516546",
  130 + "re_out_trade_no": null,
  131 + "trade_state": "SUCCESS",
  132 + "trade_state_desc": "支付成功",
  133 + "out_request_no": null,
  134 + "withdraw_id": null,
  135 + "refund_cdate": null,
  136 + "cdate": "1740385039"
  137 + }
  138 + ]
  139 +}
  140 +*/
  141 +
  142 + String? date;
  143 + double? total;
  144 + double? refundTotal;
  145 + List<DiscountOrderListModelDataList?>? list;
  146 +
  147 + DiscountOrderListModelData({
  148 + this.date,
  149 + this.total,
  150 + this.refundTotal,
  151 + this.list,
  152 + });
  153 + DiscountOrderListModelData.fromJson(Map<dynamic, dynamic> json) {
  154 + date = json['date']?.toString();
  155 + total = json['total']?.toDouble();
  156 + refundTotal = json['refund_total']?.toDouble();
  157 + if (json['list'] != null) {
  158 + final v = json['list'];
  159 + final arr0 = <DiscountOrderListModelDataList>[];
  160 + v.forEach((v) {
  161 + arr0.add(DiscountOrderListModelDataList.fromJson(v));
  162 + });
  163 + list = arr0;
  164 + }
  165 + }
  166 + Map<String, dynamic> toJson() {
  167 + final data = <String, dynamic>{};
  168 + data['date'] = date;
  169 + data['total'] = total;
  170 + data['refund_total'] = refundTotal;
  171 + if (list != null) {
  172 + final v = list;
  173 + final arr0 = [];
  174 + v!.forEach((v) {
  175 + arr0.add(v!.toJson());
  176 + });
  177 + data['list'] = arr0;
  178 + }
  179 + return data;
  180 + }
  181 +}
  182 +
  183 +class DiscountOrderListModel {
  184 +/*
  185 +{
  186 + "ret": 200,
  187 + "data": [
  188 + {
  189 + "date": "2025年02月24日",
  190 + "total": 0.06,
  191 + "refund_total": 0.05,
  192 + "list": [
  193 + {
  194 + "id": "3",
  195 + "status": "5",
  196 + "activity_id": null,
  197 + "price": "0.01",
  198 + "balance": null,
  199 + "sellerid": "8",
  200 + "openid": "oB-xJ5GoISP77QEx5zvA4F9LU-uc",
  201 + "out_trade_no": "202502241617198",
  202 + "out_refund_no": null,
  203 + "transaction_id": "4200002631202502248048942186",
  204 + "refund_id": "50302602342025022488986516546",
  205 + "re_out_trade_no": null,
  206 + "trade_state": "SUCCESS",
  207 + "trade_state_desc": "支付成功",
  208 + "out_request_no": null,
  209 + "withdraw_id": null,
  210 + "refund_cdate": null,
  211 + "cdate": "1740385039"
  212 + }
  213 + ]
  214 + }
  215 + ],
  216 + "msg": ""
  217 +}
  218 +*/
  219 +
  220 + int? ret;
  221 + List<DiscountOrderListModelData?>? data;
  222 + String? msg;
  223 +
  224 + DiscountOrderListModel({
  225 + this.ret,
  226 + this.data,
  227 + this.msg,
  228 + });
  229 + DiscountOrderListModel.fromJson(Map<dynamic, dynamic> json) {
  230 + ret = json['ret']?.toInt();
  231 + if (json['data'] != null) {
  232 + final v = json['data'];
  233 + final arr0 = <DiscountOrderListModelData>[];
  234 + v.forEach((v) {
  235 + arr0.add(DiscountOrderListModelData.fromJson(v));
  236 + });
  237 + this.data = arr0;
  238 + }
  239 + msg = json['msg']?.toString();
  240 + }
  241 + Map<String, dynamic> toJson() {
  242 + final data = <String, dynamic>{};
  243 + data['ret'] = ret;
  244 + if (this.data != null) {
  245 + final v = this.data;
  246 + final arr0 = [];
  247 + v!.forEach((v) {
  248 + arr0.add(v!.toJson());
  249 + });
  250 + data['data'] = arr0;
  251 + }
  252 + data['msg'] = msg;
  253 + return data;
  254 + }
  255 +}
@@ -602,4 +602,19 @@ class HttpUrl { @@ -602,4 +602,19 @@ class HttpUrl {
602 602
603 static const create_pay_qrcode = 603 static const create_pay_qrcode =
604 "?service=App.Seller.CreatePayQrcode"; // 生成商家收款二维码 604 "?service=App.Seller.CreatePayQrcode"; // 生成商家收款二维码
  605 +
  606 +static const get_discount_orderlist =
  607 + "?service=App.Activity.GetDiscountOrderList"; // 获取交易记录
  608 +
  609 +static const get_discount_order_info =
  610 + "?service=App.Activity.GetDiscountOrderInfo"; // 通过支付订单号或退款订单号获取订单
  611 +
  612 +static const discount_pay_refund_apply=
  613 + "?service=App.PayOnline.DiscountPayRefundApply"; // 优惠支付订单退款
  614 +
  615 +
  616 +
  617 +
  618 +
  619 +
605 } 620 }
  1 +import 'package:common_utils/common_utils.dart';
1 import 'package:flutter/material.dart'; 2 import 'package:flutter/material.dart';
2 import 'package:one_key/utils/dialog_util.dart'; 3 import 'package:one_key/utils/dialog_util.dart';
  4 +import 'package:one_key/utils/utils.dart';
3 import 'package:one_key/widgets/MyDivider.dart'; 5 import 'package:one_key/widgets/MyDivider.dart';
4 import 'package:one_key/widgets/system_app_bar.dart'; 6 import 'package:one_key/widgets/system_app_bar.dart';
5 import 'package:one_key/widgets/v_empty_view.dart'; 7 import 'package:one_key/widgets/v_empty_view.dart';
  8 +import 'package:provider/provider.dart';
6 9
  10 +import '../../../constant/state.dart';
  11 +import '../../../provider/finance_provider.dart';
  12 +import '../../../provider/user_model.dart';
7 import '../../../res/colors.dart'; 13 import '../../../res/colors.dart';
  14 +import '../../../utils/event_bus.dart';
8 import '../../../utils/screen_util.dart'; 15 import '../../../utils/screen_util.dart';
9 import '../../../widgets/h_empty_view.dart'; 16 import '../../../widgets/h_empty_view.dart';
  17 +import '../../../widgets/page_exception.dart';
10 import '../../../widgets/round_button.dart'; 18 import '../../../widgets/round_button.dart';
11 19
12 /** 20 /**
@@ -14,7 +22,10 @@ import '../../../widgets/round_button.dart'; @@ -14,7 +22,10 @@ import '../../../widgets/round_button.dart';
14 */ 22 */
15 23
16 class TransactionRecordDetailPage extends StatefulWidget { 24 class TransactionRecordDetailPage extends StatefulWidget {
17 - const TransactionRecordDetailPage({super.key}); 25 + final String? status;
  26 + final String? id;
  27 +
  28 + const TransactionRecordDetailPage({super.key, this.status, this.id});
18 29
19 @override 30 @override
20 State<TransactionRecordDetailPage> createState() => 31 State<TransactionRecordDetailPage> createState() =>
@@ -23,6 +34,57 @@ class TransactionRecordDetailPage extends StatefulWidget { @@ -23,6 +34,57 @@ class TransactionRecordDetailPage extends StatefulWidget {
23 34
24 class _TransactionRecordDetailPageState 35 class _TransactionRecordDetailPageState
25 extends State<TransactionRecordDetailPage> { 36 extends State<TransactionRecordDetailPage> {
  37 + FinanceProvider? financeProvider;
  38 +
  39 + @override
  40 + void initState() {
  41 + super.initState();
  42 +
  43 + WidgetsBinding.instance.addPostFrameCallback((_) {
  44 + _getDiscountOrderInfo();
  45 + // _getCountCommentLabel(isShowLoading: false);
  46 + });
  47 + }
  48 +
  49 + _getDiscountOrderInfo({bool isShowLoading = false}) async {
  50 + Map<String, String?> params = {
  51 + 'sellerid': Provider.of<UserModel>(context, listen: false).user!.sellerid,
  52 + 'pay_id': widget.id
  53 + };
  54 +
  55 + await financeProvider!
  56 + .getDiscountOrderInfo(context, params, isShowLoading: isShowLoading);
  57 + }
  58 +
  59 + _discountPayRefundApply() async {
  60 + Map<String, String?> params = {
  61 + 'id': financeProvider!.discountOrderInfoModelData!.id!
  62 + };
  63 + dynamic result = await financeProvider!
  64 + .discountPayRefundApply(context, params, isShowLoading: true);
  65 + if (result is bool) {
  66 + if (result) {
  67 + //成功,刷新页面,是否给提示,申请退款成功,请等待退款
  68 + bus.emit("refresh_discount_order_list");
  69 + _getDiscountOrderInfo(isShowLoading: true);
  70 + } else {
  71 + //失败了
  72 + Utils.showToast('发生错误');
  73 + }
  74 + } else if (result is String) {
  75 + DialogUtil.cupertinoAlertDialogOnly(context,
  76 + title: '提示',
  77 + // isBoldContent: true,
  78 + contentColor: MyColours.color_000000,
  79 + content: result);
  80 +
  81 + //余额不足
  82 + // "available_amount": 33, 可用余额和订单需退款金额比较,可用, 不可用
  83 +
  84 + // DialogUtil.cupertinoAlertDialogOnly();
  85 + }
  86 + }
  87 +
26 Widget _item(String title, String subTitle) { 88 Widget _item(String title, String subTitle) {
27 return Container( 89 return Container(
28 padding: EdgeInsets.symmetric(vertical: w(8), horizontal: w(20)), 90 padding: EdgeInsets.symmetric(vertical: w(8), horizontal: w(20)),
@@ -58,46 +120,81 @@ class _TransactionRecordDetailPageState @@ -58,46 +120,81 @@ class _TransactionRecordDetailPageState
58 120
59 @override 121 @override
60 Widget build(BuildContext context) { 122 Widget build(BuildContext context) {
  123 + financeProvider = Provider.of<FinanceProvider>(context, listen: true);
61 return Scaffold( 124 return Scaffold(
62 - appBar: SystemAppBar('交易详情'),  
63 - body: false  
64 - ? SingleChildScrollView(  
65 - child: Column(  
66 - children: [  
67 - VEmptyView(80),  
68 - Text(  
69 - '金额',  
70 - textAlign: TextAlign.center,  
71 - style: TextStyle(  
72 - color: MyColours.color_515151,  
73 - fontWeight: FontWeight.bold,  
74 - fontSize: font(14)),  
75 - ),  
76 - VEmptyView(40),  
77 - Text(  
78 - '¥290.00',  
79 - textAlign: TextAlign.center,  
80 - style: TextStyle(  
81 - color: MyColours.color_515151,  
82 - fontWeight: FontWeight.bold,  
83 - fontSize: font(32)),  
84 - ),  
85 - VEmptyView(60),  
86 - Padding(  
87 - padding: EdgeInsets.symmetric(horizontal: w(20)),  
88 - child: MyDivider(double.infinity, w(0.5))),  
89 - _item('商户简称', '独一处'),  
90 - _item('交易状态', '退款中'),  
91 - _item('时间', '2022-05-01 18:00'),  
92 - _item('收款账户', '原路返回'),  
93 - VEmptyView(8),  
94 - Padding(  
95 - padding: EdgeInsets.symmetric(horizontal: w(20)),  
96 - child: MyDivider(double.infinity, w(0.5))),  
97 - ],  
98 - ),  
99 - )  
100 - : Column( 125 + backgroundColor: MyColours.color_ffffff,
  126 + appBar: SystemAppBar('交易详情'),
  127 + // body: false
  128 + // ? SingleChildScrollView(
  129 + // child: Column(
  130 + // children: [
  131 + // VEmptyView(80),
  132 + // Text(
  133 + // '金额',
  134 + // textAlign: TextAlign.center,
  135 + // style: TextStyle(
  136 + // color: MyColours.color_515151,
  137 + // fontWeight: FontWeight.bold,
  138 + // fontSize: font(14)),
  139 + // ),
  140 + // VEmptyView(40),
  141 + // Text(
  142 + // '¥290.00',
  143 + // textAlign: TextAlign.center,
  144 + // style: TextStyle(
  145 + // color: MyColours.color_515151,
  146 + // fontWeight: FontWeight.bold,
  147 + // fontSize: font(32)),
  148 + // ),
  149 + // VEmptyView(60),
  150 + // Padding(
  151 + // padding: EdgeInsets.symmetric(horizontal: w(20)),
  152 + // child: MyDivider(double.infinity, w(0.5))),
  153 + // _item('商户简称', '独一处'),
  154 + // _item('交易状态', '退款中'),
  155 + // _item('时间', '2022-05-01 18:00'),
  156 + // _item('收款账户', '原路返回'),
  157 + // VEmptyView(8),
  158 + // Padding(
  159 + // padding: EdgeInsets.symmetric(horizontal: w(20)),
  160 + // child: MyDivider(double.infinity, w(0.5))),
  161 + // ],
  162 + // ),
  163 + // )
  164 + // :
  165 + body: Consumer<FinanceProvider>(builder: (context, model, _) {
  166 + if (model.pageStateRecordDetail != PageState.Success) {
  167 + return Expanded(
  168 + child: ExceptionPage(
  169 + pageState: model.pageStateRecordHome,
  170 + callback: () async {
  171 + _getDiscountOrderInfo(isShowLoading: true);
  172 + },
  173 + emptyMsg: "暂时没有交易详情信息哦",
  174 + emptyImg: "empty_search",
  175 + showMsg: "加载中,请稍候...",
  176 + ));
  177 + } else {
  178 + // bool isPay = false;
  179 + // if ((model.discountOrderInfoModelData?.refundId != null &&
  180 + // model.discountOrderInfoModelData?.status == '2') ||
  181 + // model.discountOrderInfoModelData?.status == '4' ||
  182 + // model.discountOrderInfoModelData?.status == '5') {
  183 + // //这笔数据是退款
  184 + // isPay = true;
  185 + // }
  186 + String couponUse = '无';
  187 + if (model.discountOrderInfoModelData!.activityList!.length > 0) {
  188 + for (var element
  189 + in model.discountOrderInfoModelData!.activityList!) {
  190 + couponUse += '¥${element}*1\n';
  191 + }
  192 + }
  193 + if (couponUse.length > 0 && couponUse.endsWith('\n')) {
  194 + couponUse = couponUse.substring(0, couponUse.length - 2);
  195 + }
  196 +
  197 + return Column(
101 children: [ 198 children: [
102 Expanded( 199 Expanded(
103 child: SingleChildScrollView( 200 child: SingleChildScrollView(
@@ -105,7 +202,7 @@ class _TransactionRecordDetailPageState @@ -105,7 +202,7 @@ class _TransactionRecordDetailPageState
105 children: [ 202 children: [
106 VEmptyView(80), 203 VEmptyView(80),
107 Text( 204 Text(
108 - '收入金额', 205 + widget.status == '00' ? '支出金额' : '收入金额',
109 textAlign: TextAlign.center, 206 textAlign: TextAlign.center,
110 style: TextStyle( 207 style: TextStyle(
111 color: MyColours.color_515151, 208 color: MyColours.color_515151,
@@ -114,7 +211,7 @@ class _TransactionRecordDetailPageState @@ -114,7 +211,7 @@ class _TransactionRecordDetailPageState
114 ), 211 ),
115 VEmptyView(40), 212 VEmptyView(40),
116 Text( 213 Text(
117 - '¥290.00', 214 + '¥${model.discountOrderInfoModelData!.price}',
118 textAlign: TextAlign.center, 215 textAlign: TextAlign.center,
119 style: TextStyle( 216 style: TextStyle(
120 color: MyColours.color_515151, 217 color: MyColours.color_515151,
@@ -125,14 +222,54 @@ class _TransactionRecordDetailPageState @@ -125,14 +222,54 @@ class _TransactionRecordDetailPageState
125 Padding( 222 Padding(
126 padding: EdgeInsets.symmetric(horizontal: w(20)), 223 padding: EdgeInsets.symmetric(horizontal: w(20)),
127 child: MyDivider(double.infinity, w(0.5))), 224 child: MyDivider(double.infinity, w(0.5))),
128 - _item('时间', '2022-05-01 18:00'),  
129 - _item('收支类型', '收入'),  
130 - _item('交易名称', '扫码支付'),  
131 - _item('订单金额', '¥350.00'),  
132 - _item('优惠券使用', '¥30.00*1\n¥30.00*1\n¥30.00*1'),  
133 - _item('变更后余额', '3133.60'),  
134 - _item('备注',  
135 - '结算总金额290.00元,包含微信支付手续费。结算总金额290.00元,包含微信支付手续费。结算总金额290.00元,包含微信支付手续费。结算总金额290.00元,包含微信支付手续费。结算总金额290.00元,包含微信支付手续费。'), 225 + _item(
  226 + '时间',
  227 + widget.status == '00'
  228 + ? model.discountOrderInfoModelData?.refundCdate ==
  229 + null
  230 + ? ''
  231 + : model.discountOrderInfoModelData
  232 + ?.refundId ==
  233 + null
  234 + ? ''
  235 + : DateUtil.formatDate(
  236 + DateTime.fromMillisecondsSinceEpoch(
  237 + int.parse(model
  238 + .discountOrderInfoModelData
  239 + ?.refundCdate ??
  240 + '') *
  241 + 1000),
  242 + format: DateFormats.y_mo_d_h_m)
  243 + : DateUtil.formatDate(
  244 + DateTime.fromMillisecondsSinceEpoch(int.parse(
  245 + model.discountOrderInfoModelData?.cdate ?? '') *
  246 + 1000),
  247 + format: DateFormats.y_mo_d_h_m)),
  248 + _item('收支类型', widget.status == '00' ? '支出' : '收入'),
  249 + _item('交易名称', widget.status == '00' ? '退款' : '扫码支付'),
  250 + if (widget.status == '00')
  251 + _item(
  252 + '交易状态',
  253 + model.discountOrderInfoModelData?.status == '4'
  254 + ? '退款中'
  255 + : model.discountOrderInfoModelData?.status ==
  256 + '5'
  257 + ? '退款完成'
  258 + : '退款失败'),
  259 + _item('订单金额',
  260 + '¥${model.discountOrderInfoModelData?.price}'),
  261 + _item('优惠券使用', couponUse),
  262 + _item('变更后余额',
  263 + '${model.discountOrderInfoModelData?.balance ?? '0'}'),
  264 + _item(
  265 + '备注',
  266 + (widget.status == '00' &&
  267 + model.discountOrderInfoModelData?.status !=
  268 + '4' &&
  269 + model.discountOrderInfoModelData?.status !=
  270 + '5')
  271 + ? '失败理由'
  272 + : '结算总金额${model.discountOrderInfoModelData?.price}元,包含微信支付手续费。前往微信支付商家助手小程序可查询更多信息。'),
136 VEmptyView(8), 273 VEmptyView(8),
137 Padding( 274 Padding(
138 padding: EdgeInsets.symmetric(horizontal: w(20)), 275 padding: EdgeInsets.symmetric(horizontal: w(20)),
@@ -140,33 +277,38 @@ class _TransactionRecordDetailPageState @@ -140,33 +277,38 @@ class _TransactionRecordDetailPageState
140 ], 277 ],
141 ), 278 ),
142 )), 279 )),
143 - Container(  
144 - padding: EdgeInsets.only(  
145 - top: w(13), left: w(45), right: w(45), bottom: w(26)),  
146 - child: RoundButton(  
147 - text: '申请退款',  
148 - height: w(43),  
149 - radius: r(5),  
150 - gradientStart: MyColours.color_438E93,  
151 - gradientEnd: MyColours.color_438E93,  
152 - borderColor: MyColours.color_438E93,  
153 - textColor: MyColours.color_ffffff,  
154 - isBold: true,  
155 - fontSize: 32,  
156 - onPressed: () {  
157 - //余额不足  
158 - // "available_amount": 33, 可用余额和订单需退款金额比较,可用, 不可用  
159 -  
160 - // DialogUtil.cupertinoAlertDialogOnly();  
161 -  
162 -  
163 - //余额充足,可申请退款  
164 - // DialogUtil.cupertinoAlertDialog();  
165 - },  
166 - ),  
167 - ) 280 + if (widget.status != '00' &&
  281 + model.discountOrderInfoModelData?.status == '2')
  282 + Container(
  283 + padding: EdgeInsets.only(
  284 + top: w(13), left: w(45), right: w(45), bottom: w(26)),
  285 + child: RoundButton(
  286 + text: '申请退款',
  287 + height: w(43),
  288 + radius: r(5),
  289 + gradientStart: MyColours.color_438E93,
  290 + gradientEnd: MyColours.color_438E93,
  291 + borderColor: MyColours.color_438E93,
  292 + textColor: MyColours.color_ffffff,
  293 + isBold: true,
  294 + fontSize: 32,
  295 + onPressed: () {
  296 + //余额充足,可申请退款
  297 + DialogUtil.cupertinoAlertDialog(context,
  298 + title: '提示',
  299 + content: '退款成功后,退款金额将原路返回到顾客账户,请确认是否退款!',
  300 + lTitle: '取消退款',
  301 + rTitle: '确认退款',
  302 + contentColor: MyColours.color_000000,
  303 + rCallback: () {
  304 + _discountPayRefundApply();
  305 + });
  306 + },
  307 + ),
  308 + )
168 ], 309 ],
169 - ),  
170 - ); 310 + );
  311 + }
  312 + }));
171 } 313 }
172 } 314 }
  1 +import 'package:common_utils/common_utils.dart';
1 import 'package:flutter/material.dart'; 2 import 'package:flutter/material.dart';
2 import 'package:one_key/res/colors.dart'; 3 import 'package:one_key/res/colors.dart';
3 import 'package:one_key/route/navigator_util.dart'; 4 import 'package:one_key/route/navigator_util.dart';
4 import 'package:one_key/utils/utils.dart'; 5 import 'package:one_key/utils/utils.dart';
5 import 'package:one_key/widgets/h_empty_view.dart'; 6 import 'package:one_key/widgets/h_empty_view.dart';
6 import 'package:one_key/widgets/system_app_bar.dart'; 7 import 'package:one_key/widgets/system_app_bar.dart';
  8 +import 'package:provider/provider.dart';
7 9
  10 +import '../../../constant/state.dart';
  11 +import '../../../models/discount_order_model.dart';
  12 +import '../../../provider/finance_provider.dart';
  13 +import '../../../provider/user_model.dart';
  14 +import '../../../utils/event_bus.dart';
8 import '../../../utils/screen_util.dart'; 15 import '../../../utils/screen_util.dart';
  16 +import '../../../widgets/page_exception.dart';
9 17
10 /** 18 /**
11 * 交易记录列表 19 * 交易记录列表
@@ -21,160 +29,305 @@ class TransactionRecordHomePage extends StatefulWidget { @@ -21,160 +29,305 @@ class TransactionRecordHomePage extends StatefulWidget {
21 29
22 class _TransactionRecordHomePageState extends State<TransactionRecordHomePage> { 30 class _TransactionRecordHomePageState extends State<TransactionRecordHomePage> {
23 ScrollController controller = ScrollController(); 31 ScrollController controller = ScrollController();
  32 + FinanceProvider? financeProvider;
  33 +
  34 + @override
  35 + void initState() {
  36 + super.initState();
  37 +
  38 + WidgetsBinding.instance.addPostFrameCallback((_) {
  39 + _getDiscountOrderList();
  40 + // _getCountCommentLabel(isShowLoading: false);
  41 + });
  42 + bus.on("refresh_discount_order_list", (args) {
  43 + // _getReserveDetail(isShowLoading: false);
  44 + _getDiscountOrderList(isShowLoading: false);
  45 + });
  46 + }
  47 +
  48 + @override
  49 + void dispose() {
  50 + super.dispose();
  51 + bus.off("refresh_discount_order_list");
  52 + }
  53 +
  54 + _getDiscountOrderList({bool isShowLoading = false}) async {
  55 + // String from = fromDate + ' 00:00:00';
  56 + // String end = endDate + ' 23:59:59';
  57 + // Map<String, String?> params = {
  58 + // "uid": Provider.of<UserModel>(context, listen: false).user!.openid,
  59 + // "aname": _couponNameEditControl.text.trim(),
  60 + // "desc": _couponRequireEditControl.text.trim(),
  61 + // "stime": fromDate == '点击选择'
  62 + // ? ""
  63 + // : '${(DateUtil.getDateMsByTimeStr(from)! / 1000).floor()}',
  64 + // "etime": endDate == '点击选择'
  65 + // ? ''
  66 + // : '${(DateUtil.getDateMsByTimeStr(end)! / 1000).floor()}',
  67 + DateTime fromDate = DateTime.now().subtract(Duration(days: 5));
  68 + DateTime endDate = DateTime.now();
  69 + String from = '${fromDate.year}' +
  70 + '-' +
  71 + Utils.addZeroNumber(fromDate.month) +
  72 + '-' +
  73 + Utils.addZeroNumber(fromDate.day) +
  74 + ' 00:00:00';
  75 + String end = '${endDate.year}' +
  76 + '-' +
  77 + Utils.addZeroNumber(endDate.month) +
  78 + '-' +
  79 + Utils.addZeroNumber(endDate.day) +
  80 + ' 23:59:59';
  81 +
  82 + Map<String, String?> params = {
  83 + 'sellerid': Provider.of<UserModel>(context, listen: false).user!.sellerid,
  84 + 'stime': '${(DateUtil.getDateMsByTimeStr(from)! / 1000).floor()}',
  85 + 'etime': '${(DateUtil.getDateMsByTimeStr(end)! / 1000).floor()}',
  86 + };
  87 +
  88 + await financeProvider!
  89 + .getDiscountOrderList(context, params, isShowLoading: false);
  90 + }
  91 +
  92 + Widget _tips() {
  93 + return Container(
  94 + width: double.infinity,
  95 + height: w(40),
  96 + color: MyColours.color_4DDBDBDB,
  97 + alignment: Alignment.center,
  98 + child: Text(
  99 + '仅展示近5天的交易信息,如果需要展示更多信息,请使用右上角日期筛选',
  100 + style: TextStyle(color: MyColours.color_999999, fontSize: font(10)),
  101 + ),
  102 + );
  103 + }
  104 +
24 @override 105 @override
25 Widget build(BuildContext context) { 106 Widget build(BuildContext context) {
  107 + financeProvider = Provider.of<FinanceProvider>(context, listen: true);
26 return Scaffold( 108 return Scaffold(
27 - appBar: SystemAppBar('交易记录'),  
28 - body: Column(  
29 - children: [  
30 - Expanded(  
31 - child: ListView.builder(  
32 - itemCount: 10,  
33 - shrinkWrap: true,  
34 - controller: controller,  
35 - itemBuilder: (context, index) {  
36 - return Container(  
37 - child: Column(  
38 - crossAxisAlignment: CrossAxisAlignment.center,  
39 - children: [  
40 - Stack(children: [  
41 - Container(  
42 - width: double.infinity, 109 + backgroundColor: MyColours.color_ffffff,
  110 + appBar: SystemAppBar('交易记录'),
  111 + body: Consumer<FinanceProvider>(builder: (context, model, _) {
  112 + if (model.pageStateRecordHome != PageState.Success) {
  113 + return Column(
  114 + children: [
  115 + Align(
  116 + alignment: Alignment.centerRight,
  117 + child: InkWell(
  118 + onTap: () {
  119 + //跳转筛选页面
  120 + NavigatorUtil.goTransactionRecordSearchPage(context);
  121 + },
  122 + child: Container(
  123 + padding: EdgeInsets.only(
  124 + right: w(20),
  125 + left: w(20),
  126 + top: w(10),
  127 + bottom: w(10)),
  128 + child: Image.asset(
  129 + Utils.getImgPath('calender'),
  130 + width: w(20),
  131 + ),
  132 + )),
  133 + ),
  134 + Expanded(
  135 + child: ExceptionPage(
  136 + pageState: model.pageStateRecordHome,
  137 + callback: () async {
  138 + _getDiscountOrderList(isShowLoading: true);
  139 + },
  140 + emptyMsg: "暂时没有交易记录信息哦",
  141 + emptyImg: "empty_search",
  142 + showMsg: "加载中,请稍候...",
  143 + )),
  144 + _tips()
  145 + ],
  146 + );
  147 + } else {
  148 + return Column(
  149 + children: [
  150 + Expanded(
  151 + child: ListView.builder(
  152 + itemCount: financeProvider!.discountOrderList.length,
  153 + shrinkWrap: true,
  154 + controller: controller,
  155 + itemBuilder: (context, index) {
  156 + DiscountOrderListModelData? listData =
  157 + financeProvider!.discountOrderList[index];
  158 + return Container(
  159 + child: Column(
  160 + crossAxisAlignment: CrossAxisAlignment.center,
  161 + children: [
  162 + Stack(children: [
  163 + Container(
  164 + width: double.infinity,
  165 + alignment: Alignment.center,
43 166
44 - // height: w(40),  
45 - alignment: Alignment.center,  
46 - color: MyColours.color_4DDBDBDB,  
47 - padding: EdgeInsets.symmetric(vertical: w(10)),  
48 - margin: EdgeInsets.only(  
49 - top: index == 0 ? 0 : w(12)),  
50 - child: Wrap(  
51 - runSpacing: w(5),  
52 - crossAxisAlignment: WrapCrossAlignment.center,  
53 - children: [  
54 - Text(  
55 - '2025年2月12日',  
56 - style: TextStyle(  
57 - color: MyColours.color_515151,  
58 - fontSize: font(14)),  
59 - ),  
60 - HEmptyView(16),  
61 - Padding( 167 + // height: w(40),
  168 + color: MyColours.color_4DDBDBDB,
62 padding: EdgeInsets.only( 169 padding: EdgeInsets.only(
63 - right: index == 0 ? w(33) : 0),  
64 - child: Text(  
65 - '收入580.00,支出290.00',  
66 - maxLines: 3,  
67 - overflow: TextOverflow.ellipsis,  
68 - style: TextStyle(  
69 - color: MyColours.color_999999,  
70 - fontSize: font(12)),  
71 - ),  
72 - ),  
73 - ],  
74 - )),  
75 - if (index == 0)  
76 - Positioned(  
77 - top: 0,  
78 - right: 0,  
79 - child: InkWell(  
80 - onTap: () {  
81 - //跳转筛选页面  
82 - NavigatorUtil  
83 - .goTransactionRecordSearchPage(  
84 - context);  
85 - },  
86 - child: Container(  
87 - padding: EdgeInsets.only(  
88 - right: w(20),  
89 - left: w(20),  
90 - top: w(10),  
91 - bottom: w(10)),  
92 - child: Image.asset(  
93 - Utils.getImgPath('calender'),  
94 - width: w(20),  
95 - ),  
96 - )))  
97 - ]),  
98 - ListView.builder(  
99 - itemCount: 5,  
100 - shrinkWrap: true,  
101 - controller: controller,  
102 - itemBuilder: (context, index) {  
103 - return InkWell(  
104 - onTap: () {  
105 - NavigatorUtil  
106 - .goTransactionRecordDetailPage(  
107 - context);  
108 - },  
109 - child: Container(  
110 - height: w(37),  
111 - decoration: BoxDecoration(  
112 - border: Border(  
113 - bottom: BorderSide(  
114 - color: MyColours.color_E7E7E7,  
115 - width: w(0.5)))),  
116 - margin: EdgeInsets.only(  
117 - left: w(20),  
118 - bottom: w(10),  
119 - right: w(20)),  
120 - padding: EdgeInsets.only(top: w(5)),  
121 - child: Row(  
122 - mainAxisAlignment:  
123 - MainAxisAlignment.spaceBetween, 170 + top: index == 0 ? w(10) : w(22),
  171 + bottom: w(10)),
  172 + child: Wrap(
  173 + runSpacing: w(5),
  174 + crossAxisAlignment:
  175 + WrapCrossAlignment.center,
124 children: [ 176 children: [
125 Text( 177 Text(
126 - '收入', 178 + listData!.date ?? '',
127 style: TextStyle( 179 style: TextStyle(
128 color: MyColours.color_515151, 180 color: MyColours.color_515151,
129 - fontWeight: FontWeight.bold,  
130 - fontSize: font(12)), 181 + fontSize: font(14)),
131 ), 182 ),
132 - HEmptyView(8),  
133 - Text(  
134 - '扫码支付',  
135 - style: TextStyle(  
136 - color: MyColours.color_515151,  
137 - fontWeight: FontWeight.bold,  
138 - fontSize: font(12)), 183 + HEmptyView(16),
  184 + Padding(
  185 + padding: EdgeInsets.only(
  186 + right: index == 0 ? w(33) : 0),
  187 + child: Text(
  188 + '收入${listData.total},支出${listData.refundTotal}',
  189 + maxLines: 3,
  190 + overflow: TextOverflow.ellipsis,
  191 + style: TextStyle(
  192 + color: MyColours.color_999999,
  193 + fontSize: font(12)),
  194 + ),
139 ), 195 ),
140 - HEmptyView(70),  
141 - Text(  
142 - '2022-05-01 18:00',  
143 - style: TextStyle(  
144 - color: MyColours.color_515151,  
145 - fontSize: font(10)),  
146 - ),  
147 - HEmptyView(8),  
148 - Expanded(  
149 - child: Text(  
150 - '+290.00',  
151 - textAlign: TextAlign.right,  
152 - style: TextStyle(  
153 - color: MyColours.color_515151,  
154 - fontWeight: FontWeight.bold,  
155 - fontSize: font(18)),  
156 - )),  
157 ], 196 ],
158 - ),  
159 - ));  
160 - })  
161 - ],  
162 - ),  
163 - );  
164 - })),  
165 - Container(  
166 - width: double.infinity,  
167 - height: w(40),  
168 - color: MyColours.color_4DDBDBDB,  
169 - alignment: Alignment.center,  
170 - child: Text(  
171 - '仅展示近5天的交易信息,如果需要展示更多信息,请使用右上角日期筛选',  
172 - style:  
173 - TextStyle(color: MyColours.color_999999, fontSize: font(10)),  
174 - ),  
175 - )  
176 - ],  
177 - ),  
178 - ); 197 + )),
  198 + if (index == 0)
  199 + Positioned(
  200 + top: 0,
  201 + right: 0,
  202 + child: InkWell(
  203 + onTap: () {
  204 + //跳转筛选页面
  205 + NavigatorUtil
  206 + .goTransactionRecordSearchPage(
  207 + context);
  208 + },
  209 + child: Container(
  210 + padding: EdgeInsets.only(
  211 + right: w(20),
  212 + left: w(20),
  213 + top: w(10),
  214 + bottom: w(10)),
  215 + child: Image.asset(
  216 + Utils.getImgPath('calender'),
  217 + width: w(20),
  218 + ),
  219 + )))
  220 + ]),
  221 + ListView.builder(
  222 + itemCount: listData.list?.length,
  223 + shrinkWrap: true,
  224 + controller: controller,
  225 + itemBuilder: (context, index) {
  226 + DiscountOrderListModelDataList? subdata =
  227 + listData.list?[index];
  228 + return InkWell(
  229 + onTap: () {
  230 + NavigatorUtil
  231 + .goTransactionRecordDetailPage(
  232 + context,
  233 + subdata.status,
  234 + subdata.status == '00'
  235 + ? subdata.refundId
  236 + : subdata
  237 + .transactionId);
  238 + },
  239 + child: Container(
  240 + height: w(37),
  241 + decoration: BoxDecoration(
  242 + border: Border(
  243 + bottom: BorderSide(
  244 + color: MyColours
  245 + .color_E7E7E7,
  246 + width: w(0.5)))),
  247 + margin: EdgeInsets.only(
  248 + left: w(20),
  249 + bottom: w(10),
  250 + right: w(20)),
  251 + padding: EdgeInsets.only(top: w(5)),
  252 + child: Row(
  253 + mainAxisAlignment:
  254 + MainAxisAlignment
  255 + .spaceBetween,
  256 + children: [
  257 + Text(
  258 + subdata!.status != '00'
  259 + ? '收入'
  260 + : '支出',
  261 + style: TextStyle(
  262 + color: MyColours
  263 + .color_515151,
  264 + fontWeight:
  265 + FontWeight.bold,
  266 + fontSize: font(12)),
  267 + ),
  268 + HEmptyView(8),
  269 + Text(
  270 + subdata.status != '00'
  271 + ? '扫码支付'
  272 + : '用户退款',
  273 + style: TextStyle(
  274 + color: MyColours
  275 + .color_515151,
  276 + fontWeight:
  277 + FontWeight.bold,
  278 + fontSize: font(12)),
  279 + ),
  280 + HEmptyView(70),
  281 + Text(
  282 + subdata.status != '00'
  283 + ? DateUtil.formatDate(
  284 + DateTime.fromMillisecondsSinceEpoch(
  285 + int.parse(subdata
  286 + .cdate
  287 + .toString()) *
  288 + 1000),
  289 + format: DateFormats
  290 + .y_mo_d_h_m)
  291 + : subdata.refundCdate ==
  292 + null
  293 + ? ''
  294 + : DateUtil.formatDate(
  295 + DateTime.fromMillisecondsSinceEpoch(
  296 + int.parse(subdata.refundCdate.toString()) *
  297 + 1000),
  298 + format: DateFormats
  299 + .y_mo_d_h_m),
  300 + style: TextStyle(
  301 + color: MyColours
  302 + .color_515151,
  303 + fontSize: font(10)),
  304 + ),
  305 + HEmptyView(8),
  306 + Expanded(
  307 + child: Text(
  308 + subdata.status != '00'
  309 + ? '+${subdata.price}'
  310 + : '-${subdata.price}',
  311 + textAlign: TextAlign.right,
  312 + style: TextStyle(
  313 + color: MyColours
  314 + .color_515151,
  315 + fontWeight:
  316 + FontWeight.bold,
  317 + fontSize: font(18)),
  318 + )),
  319 + ],
  320 + ),
  321 + ));
  322 + })
  323 + ],
  324 + ),
  325 + );
  326 + })),
  327 + _tips(),
  328 + ],
  329 + );
  330 + }
  331 + }));
179 } 332 }
180 } 333 }
@@ -3,12 +3,19 @@ import 'package:flutter/material.dart'; @@ -3,12 +3,19 @@ import 'package:flutter/material.dart';
3 import 'package:flutter_picker_plus/picker.dart'; 3 import 'package:flutter_picker_plus/picker.dart';
4 import 'package:flutter_screenutil/flutter_screenutil.dart'; 4 import 'package:flutter_screenutil/flutter_screenutil.dart';
5 import 'package:one_key/widgets/system_app_bar.dart'; 5 import 'package:one_key/widgets/system_app_bar.dart';
  6 +import 'package:provider/provider.dart';
6 7
  8 +import '../../../constant/state.dart';
  9 +import '../../../models/discount_order_model.dart';
  10 +import '../../../provider/finance_provider.dart';
  11 +import '../../../provider/user_model.dart';
7 import '../../../res/colors.dart'; 12 import '../../../res/colors.dart';
  13 +import '../../../route/navigator_util.dart';
8 import '../../../utils/dialog_util.dart'; 14 import '../../../utils/dialog_util.dart';
9 import '../../../utils/screen_util.dart'; 15 import '../../../utils/screen_util.dart';
10 import '../../../utils/utils.dart'; 16 import '../../../utils/utils.dart';
11 import '../../../widgets/h_empty_view.dart'; 17 import '../../../widgets/h_empty_view.dart';
  18 +import '../../../widgets/page_exception.dart';
12 import '../../../widgets/round_button.dart'; 19 import '../../../widgets/round_button.dart';
13 import '../../../widgets/v_empty_view.dart'; 20 import '../../../widgets/v_empty_view.dart';
14 21
@@ -30,6 +37,44 @@ class _TransactionRecordSearchPageState @@ -30,6 +37,44 @@ class _TransactionRecordSearchPageState
30 String fromDate = '选择日期'; 37 String fromDate = '选择日期';
31 String endDate = '选择日期'; 38 String endDate = '选择日期';
32 ScrollController controller = ScrollController(); 39 ScrollController controller = ScrollController();
  40 + FinanceProvider? financeProvider;
  41 +
  42 + @override
  43 + void initState() {
  44 + super.initState();
  45 +
  46 + WidgetsBinding.instance.addPostFrameCallback((_) {
  47 + // _getDiscountOrderList();
  48 + // _getCountCommentLabel(isShowLoading: false);
  49 + });
  50 + }
  51 +
  52 + _getDiscountOrderList({bool isShowLoading = false}) async {
  53 + List<String> start = fromDate.split('-');
  54 +
  55 + String from = '${start[0]}' +
  56 + '-' +
  57 + Utils.addZeroNumber(int.parse(start[1])) +
  58 + '-' +
  59 + Utils.addZeroNumber(int.parse(start[2])) +
  60 + ' 00:00:00';
  61 + List<String> endList = endDate.split('-');
  62 + String end = '${endList[0]}' +
  63 + '-' +
  64 + Utils.addZeroNumber(int.parse(endList[1])) +
  65 + '-' +
  66 + Utils.addZeroNumber(int.parse(endList[2])) +
  67 + ' 23:59:59';
  68 +
  69 + Map<String, String?> params = {
  70 + 'sellerid': Provider.of<UserModel>(context, listen: false).user!.sellerid,
  71 + 'stime': '${(DateUtil.getDateMsByTimeStr(from)! / 1000).floor()}',
  72 + 'etime': '${(DateUtil.getDateMsByTimeStr(end)! / 1000).floor()}',
  73 + };
  74 +
  75 + await financeProvider!.getDiscountOrderList(context, params,
  76 + from: 'search', isShowLoading: isShowLoading);
  77 + }
33 78
34 ///时间选择 79 ///时间选择
35 Widget _select(String title, String hintText, GestureTapCallback onTap) { 80 Widget _select(String title, String hintText, GestureTapCallback onTap) {
@@ -74,166 +119,328 @@ class _TransactionRecordSearchPageState @@ -74,166 +119,328 @@ class _TransactionRecordSearchPageState
74 119
75 @override 120 @override
76 Widget build(BuildContext context) { 121 Widget build(BuildContext context) {
  122 + financeProvider = Provider.of<FinanceProvider>(context, listen: true);
77 return Scaffold( 123 return Scaffold(
78 appBar: SystemAppBar('自定义查询'), 124 appBar: SystemAppBar('自定义查询'),
79 key: scaffoldKey, 125 key: scaffoldKey,
80 body: Column( 126 body: Column(
81 children: [ 127 children: [
82 - Expanded(  
83 - child: SingleChildScrollView(  
84 - controller: controller,  
85 - child: Column(children: [  
86 - Container(  
87 - width: double.infinity,  
88 - height: w(33),  
89 - alignment: Alignment.centerLeft,  
90 - color: MyColours.color_4DDBDBDB,  
91 - padding: EdgeInsets.only(left: w(16)),  
92 - child: Text(  
93 - '查询时间跨度不超过31天',  
94 - style: TextStyle(  
95 - color: MyColours.color_999999, fontSize: font(12)),  
96 - ),  
97 - ),  
98 - _select('开始日期', fromDate, () {  
99 - FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘  
100 - //弹出时间选择器  
101 - // showPickerDateTime(context);  
102 - // showDateSelWidget = true;  
103 - DialogUtil.showPickerDateTime24(  
104 - context,  
105 - scaffoldKey,  
106 - (value) {  
107 - // {'text': picker.adapter.text, 'select': selecteds}  
108 - if (value != null) {  
109 - setState(() {  
110 - print(value);  
111 - fromDate = DateUtil.formatDateStr(value,  
112 - format: DateFormats.y_mo_d);  
113 - });  
114 - }  
115 - // showDateSelWidget = false;  
116 - },  
117 - dateTime: fromDate == '选择日期'  
118 - ? null  
119 - : DateUtil.getDateTime(fromDate),  
120 - pickerDateTimeType: PickerDateTimeType.kYMD,  
121 - onCancel: () {  
122 - // showDateSelWidget = false; 128 + // Container(
  129 + // width: double.infinity,
  130 + // height: w(33),
  131 + // alignment: Alignment.centerLeft,
  132 + // color: MyColours.color_4DDBDBDB,
  133 + // padding: EdgeInsets.only(left: w(16)),
  134 + // child: Text(
  135 + // '查询时间跨度不超过31天',
  136 + // style: TextStyle(
  137 + // color: MyColours.color_999999, fontSize: font(12)),
  138 + // ),
  139 + // ),
  140 + _select('开始日期', fromDate, () {
  141 + FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
  142 + //弹出时间选择器
  143 + // showPickerDateTime(context);
  144 + // showDateSelWidget = true;
  145 + DialogUtil.showPickerDateTime24(
  146 + context,
  147 + scaffoldKey,
  148 + (value) {
  149 + // {'text': picker.adapter.text, 'select': selecteds}
  150 + if (value != null) {
  151 + setState(() {
  152 + print(value);
  153 + fromDate = DateUtil.formatDateStr(value,
  154 + format: DateFormats.y_mo_d);
123 }); 155 });
124 - }),  
125 - Container(  
126 - height: ScreenUtil().setWidth(1),  
127 - color: MyColours.color_E7E7E7,  
128 - ),  
129 - VEmptyView(24),  
130 - _select('结束日期', endDate, () {  
131 - FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘  
132 - //弹出时间选择器  
133 - // showPickerDateTime(context);  
134 - // showDateSelWidget = true;  
135 - DialogUtil.showPickerDateTime24(  
136 - context,  
137 - scaffoldKey,  
138 - (value) {  
139 - // {'text': picker.adapter.text, 'select': selecteds}  
140 - if (value != null) {  
141 - setState(() {  
142 - print(value);  
143 - endDate = DateUtil.formatDateStr(value,  
144 - format: DateFormats.y_mo_d);  
145 - });  
146 - }  
147 - // showDateSelWidget = false;  
148 - },  
149 - dateTime: endDate == '选择日期'  
150 - ? null  
151 - : DateUtil.getDateTime(endDate),  
152 - pickerDateTimeType: PickerDateTimeType.kYMD,  
153 - onCancel: () {  
154 - // showDateSelWidget = false; 156 + }
  157 + // showDateSelWidget = false;
  158 + },
  159 + minValue: DateTime(1987, 1, 1),
  160 + dateTime:
  161 + fromDate == '选择日期' ? null : DateUtil.getDateTime(fromDate),
  162 + pickerDateTimeType: PickerDateTimeType.kYMD,
  163 + onCancel: () {
  164 + // showDateSelWidget = false;
  165 + });
  166 + }),
  167 + Container(
  168 + height: ScreenUtil().setWidth(1),
  169 + color: MyColours.color_E7E7E7,
  170 + ),
  171 + VEmptyView(24),
  172 + _select('结束日期', endDate, () {
  173 + FocusScope.of(context).requestFocus(FocusNode()); //点击空白处隐藏键盘
  174 + //弹出时间选择器
  175 + // showPickerDateTime(context);
  176 + // showDateSelWidget = true;
  177 + DialogUtil.showPickerDateTime24(
  178 + context,
  179 + scaffoldKey,
  180 + (value) {
  181 + // {'text': picker.adapter.text, 'select': selecteds}
  182 + if (value != null) {
  183 + setState(() {
  184 + print(value);
  185 + endDate = DateUtil.formatDateStr(value,
  186 + format: DateFormats.y_mo_d);
155 }); 187 });
156 - }),  
157 - Container(  
158 - height: ScreenUtil().setWidth(1),  
159 - color: MyColours.color_E7E7E7,  
160 - ),  
161 - // VEmptyView(48),  
162 - //结果展示  
163 - Column(  
164 - children: [  
165 - Container(  
166 - width: double.infinity,  
167 - height: w(40),  
168 - alignment: Alignment.center,  
169 - color: MyColours.color_4DDBDBDB,  
170 - child: Text(  
171 - '收入580.00,支出290.00',  
172 - style: TextStyle(  
173 - color: MyColours.color_999999, fontSize: font(12)),  
174 - ),  
175 - ),  
176 - ListView.builder(  
177 - itemCount: 25, 188 + }
  189 + // showDateSelWidget = false;
  190 + },
  191 + minValue: DateTime(1987, 1, 1),
  192 + dateTime:
  193 + endDate == '选择日期' ? null : DateUtil.getDateTime(endDate),
  194 + pickerDateTimeType: PickerDateTimeType.kYMD,
  195 + onCancel: () {
  196 + // showDateSelWidget = false;
  197 + });
  198 + }),
  199 + Container(
  200 + height: ScreenUtil().setWidth(1),
  201 + color: MyColours.color_E7E7E7,
  202 + ),
  203 + Consumer<FinanceProvider>(builder: (context, model, _) {
  204 + if (model.pageStateRecordSearch != PageState.Success) {
  205 + if (model.pageStateRecordSearch == PageState.Loading) {
  206 + return Spacer();
  207 + }
  208 + return Expanded(
  209 + child: ExceptionPage(
  210 + pageState: model.pageStateRecordSearch,
  211 + callback: () async {
  212 + _getDiscountOrderList(isShowLoading: true);
  213 + },
  214 + emptyMsg: "没有交易记录信息哦",
  215 + emptyImg: "empty_search",
  216 + showMsg: "加载中,请稍候...",
  217 + ));
  218 + } else {
  219 + return Expanded(
  220 + child: ListView.builder(
  221 + itemCount: financeProvider!.discountOrderList.length,
178 shrinkWrap: true, 222 shrinkWrap: true,
179 controller: controller, 223 controller: controller,
180 itemBuilder: (context, index) { 224 itemBuilder: (context, index) {
  225 + DiscountOrderListModelData? listData =
  226 + financeProvider!.discountOrderList[index];
181 return Container( 227 return Container(
182 - height: w(37),  
183 - decoration: BoxDecoration(  
184 - border: Border(  
185 - bottom: BorderSide(  
186 - color: MyColours.color_E7E7E7,  
187 - width: w(0.5)))),  
188 - margin: EdgeInsets.only(  
189 - left: w(20), bottom: w(10), right: w(20)),  
190 - padding: EdgeInsets.only(top: w(5)),  
191 - child: Row(  
192 - mainAxisAlignment: MainAxisAlignment.spaceBetween, 228 + child: Column(
  229 + crossAxisAlignment: CrossAxisAlignment.center,
193 children: [ 230 children: [
194 - Text(  
195 - '收入',  
196 - style: TextStyle(  
197 - color: MyColours.color_515151,  
198 - fontWeight: FontWeight.bold,  
199 - fontSize: font(12)),  
200 - ),  
201 - HEmptyView(8),  
202 - Text(  
203 - '扫码支付',  
204 - style: TextStyle(  
205 - color: MyColours.color_515151,  
206 - fontWeight: FontWeight.bold,  
207 - fontSize: font(12)),  
208 - ),  
209 - HEmptyView(70),  
210 - Text(  
211 - '2022-05-01 18:00',  
212 - style: TextStyle(  
213 - color: MyColours.color_515151,  
214 - fontSize: font(10)),  
215 - ),  
216 - HEmptyView(8),  
217 - Expanded(  
218 - child: Text(  
219 - '+290.00',  
220 - textAlign: TextAlign.right,  
221 - style: TextStyle(  
222 - color: MyColours.color_515151,  
223 - fontWeight: FontWeight.bold,  
224 - fontSize: font(18)),  
225 - )), 231 + Container(
  232 + width: double.infinity,
  233 + alignment: Alignment.center,
  234 +
  235 + // height: w(40),
  236 + color: MyColours.color_4DDBDBDB,
  237 + padding: EdgeInsets.only(
  238 + top: index == 0 ? w(10) : w(22),
  239 + bottom: w(10)),
  240 + child: Wrap(
  241 + runSpacing: w(5),
  242 + crossAxisAlignment:
  243 + WrapCrossAlignment.center,
  244 + children: [
  245 + Text(
  246 + listData!.date ?? '',
  247 + style: TextStyle(
  248 + color: MyColours.color_515151,
  249 + fontSize: font(14)),
  250 + ),
  251 + HEmptyView(16),
  252 + Padding(
  253 + padding: EdgeInsets.only(
  254 + right: index == 0 ? w(33) : 0),
  255 + child: Text(
  256 + '收入${listData.total},支出${listData.refundTotal}',
  257 + maxLines: 3,
  258 + overflow: TextOverflow.ellipsis,
  259 + style: TextStyle(
  260 + color: MyColours.color_999999,
  261 + fontSize: font(12)),
  262 + ),
  263 + ),
  264 + ],
  265 + )),
  266 + ListView.builder(
  267 + itemCount: listData.list?.length,
  268 + shrinkWrap: true,
  269 + controller: controller,
  270 + itemBuilder: (context, index) {
  271 + DiscountOrderListModelDataList? subdata =
  272 + listData.list?[index];
  273 + return InkWell(
  274 + onTap: () {
  275 + NavigatorUtil
  276 + .goTransactionRecordDetailPage(
  277 + context,
  278 + subdata.status,
  279 + subdata.status == '00'
  280 + ? subdata.refundId
  281 + : subdata.transactionId);
  282 + },
  283 + child: Container(
  284 + height: w(37),
  285 + decoration: BoxDecoration(
  286 + border: Border(
  287 + bottom: BorderSide(
  288 + color: MyColours
  289 + .color_E7E7E7,
  290 + width: w(0.5)))),
  291 + margin: EdgeInsets.only(
  292 + left: w(20),
  293 + bottom: w(10),
  294 + right: w(20)),
  295 + padding: EdgeInsets.only(top: w(5)),
  296 + child: Row(
  297 + mainAxisAlignment:
  298 + MainAxisAlignment.spaceBetween,
  299 + children: [
  300 + Text(
  301 + subdata!.status != '00'
  302 + ? '收入'
  303 + : '支出',
  304 + style: TextStyle(
  305 + color:
  306 + MyColours.color_515151,
  307 + fontWeight: FontWeight.bold,
  308 + fontSize: font(12)),
  309 + ),
  310 + HEmptyView(8),
  311 + Text(
  312 + subdata.status != '00'
  313 + ? '扫码支付'
  314 + : '用户退款',
  315 + style: TextStyle(
  316 + color:
  317 + MyColours.color_515151,
  318 + fontWeight: FontWeight.bold,
  319 + fontSize: font(12)),
  320 + ),
  321 + HEmptyView(70),
  322 + Text(
  323 + subdata.status != '00'
  324 + ? DateUtil.formatDate(
  325 + DateTime.fromMillisecondsSinceEpoch(
  326 + int.parse(subdata.cdate.toString()) *
  327 + 1000),
  328 + format: DateFormats
  329 + .y_mo_d_h_m)
  330 + : subdata.refundCdate ==
  331 + null
  332 + ? ''
  333 + : DateUtil.formatDate(
  334 + DateTime.fromMillisecondsSinceEpoch(
  335 + int.parse(subdata
  336 + .refundCdate
  337 + .toString()) *
  338 + 1000),
  339 + format: DateFormats
  340 + .y_mo_d_h_m),
  341 + style: TextStyle(
  342 + color:
  343 + MyColours.color_515151,
  344 + fontSize: font(10)),
  345 + ),
  346 + HEmptyView(8),
  347 + Expanded(
  348 + child: Text(
  349 + subdata.status != '00'
  350 + ? '+${subdata.price}'
  351 + : '-${subdata.price}',
  352 + textAlign: TextAlign.right,
  353 + style: TextStyle(
  354 + color:
  355 + MyColours.color_515151,
  356 + fontWeight: FontWeight.bold,
  357 + fontSize: font(18)),
  358 + )),
  359 + ],
  360 + ),
  361 + ));
  362 + })
226 ], 363 ],
227 ), 364 ),
228 ); 365 );
229 - })  
230 - ],  
231 - )  
232 - ]),  
233 - )), 366 + }));
  367 + }
  368 + }),
  369 + // VEmptyView(48),
  370 + //结果展示
  371 + // Column(
  372 + // children: [
  373 + // Container(
  374 + // width: double.infinity,
  375 + // height: w(40),
  376 + // alignment: Alignment.center,
  377 + // color: MyColours.color_4DDBDBDB,
  378 + // child: Text(
  379 + // '收入580.00,支出290.00',
  380 + // style: TextStyle(
  381 + // color: MyColours.color_999999, fontSize: font(12)),
  382 + // ),
  383 + // ),
  384 + // ListView.builder(
  385 + // itemCount: 25,
  386 + // shrinkWrap: true,
  387 + // controller: controller,
  388 + // itemBuilder: (context, index) {
  389 + // return Container(
  390 + // height: w(37),
  391 + // decoration: BoxDecoration(
  392 + // border: Border(
  393 + // bottom: BorderSide(
  394 + // color: MyColours.color_E7E7E7,
  395 + // width: w(0.5)))),
  396 + // margin: EdgeInsets.only(
  397 + // left: w(20), bottom: w(10), right: w(20)),
  398 + // padding: EdgeInsets.only(top: w(5)),
  399 + // child: Row(
  400 + // mainAxisAlignment: MainAxisAlignment.spaceBetween,
  401 + // children: [
  402 + // Text(
  403 + // '收入',
  404 + // style: TextStyle(
  405 + // color: MyColours.color_515151,
  406 + // fontWeight: FontWeight.bold,
  407 + // fontSize: font(12)),
  408 + // ),
  409 + // HEmptyView(8),
  410 + // Text(
  411 + // '扫码支付',
  412 + // style: TextStyle(
  413 + // color: MyColours.color_515151,
  414 + // fontWeight: FontWeight.bold,
  415 + // fontSize: font(12)),
  416 + // ),
  417 + // HEmptyView(70),
  418 + // Text(
  419 + // '2022-05-01 18:00',
  420 + // style: TextStyle(
  421 + // color: MyColours.color_515151,
  422 + // fontSize: font(10)),
  423 + // ),
  424 + // HEmptyView(8),
  425 + // Expanded(
  426 + // child: Text(
  427 + // '+290.00',
  428 + // textAlign: TextAlign.right,
  429 + // style: TextStyle(
  430 + // color: MyColours.color_515151,
  431 + // fontWeight: FontWeight.bold,
  432 + // fontSize: font(18)),
  433 + // )),
  434 + // ],
  435 + // ),
  436 + // );
  437 + // })
  438 + // ],
  439 + // )
  440 +
234 Container( 441 Container(
235 width: double.infinity, 442 width: double.infinity,
236 - padding: EdgeInsets.symmetric(vertical: w(13), horizontal: w(79)), 443 + padding: EdgeInsets.symmetric(vertical: w(13), horizontal: w(20)),
237 child: Row( 444 child: Row(
238 children: [ 445 children: [
239 RoundButton( 446 RoundButton(
@@ -251,6 +458,7 @@ class _TransactionRecordSearchPageState @@ -251,6 +458,7 @@ class _TransactionRecordSearchPageState
251 //导出数据 458 //导出数据
252 }, 459 },
253 ), 460 ),
  461 + HEmptyView(30),
254 Expanded( 462 Expanded(
255 child: RoundButton( 463 child: RoundButton(
256 text: '查询交易记录', 464 text: '查询交易记录',
@@ -264,6 +472,21 @@ class _TransactionRecordSearchPageState @@ -264,6 +472,21 @@ class _TransactionRecordSearchPageState
264 fontSize: 32, 472 fontSize: 32,
265 onPressed: () { 473 onPressed: () {
266 // 查询交易记录 474 // 查询交易记录
  475 + if (fromDate == '选择日期') {
  476 + Utils.showToast('请选择开始日期');
  477 + return;
  478 + }
  479 + if (endDate == '选择日期') {
  480 + Utils.showToast('请选择结束日期');
  481 + return;
  482 + }
  483 + if (DateUtil.getDateTime(endDate)
  484 + .compareTo(DateUtil.getDateTime(fromDate)) <
  485 + 0) {
  486 + Utils.showToast('结束日期不能早于开始日期');
  487 + return;
  488 + }
  489 + _getDiscountOrderList(isShowLoading: true);
267 }, 490 },
268 )), 491 )),
269 ], 492 ],
@@ -5,6 +5,8 @@ import 'package:provider/provider.dart'; @@ -5,6 +5,8 @@ import 'package:provider/provider.dart';
5 import '../constant/constant.dart'; 5 import '../constant/constant.dart';
6 import '../constant/error.dart'; 6 import '../constant/error.dart';
7 import '../constant/state.dart'; 7 import '../constant/state.dart';
  8 +import '../models/discount_order_info_model.dart';
  9 +import '../models/discount_order_model.dart';
8 import '../models/payment_code_model.dart'; 10 import '../models/payment_code_model.dart';
9 import '../net/base_resp.dart'; 11 import '../net/base_resp.dart';
10 import '../net/dio_util.dart'; 12 import '../net/dio_util.dart';
@@ -13,8 +15,13 @@ import '../utils/utils.dart'; @@ -13,8 +15,13 @@ import '../utils/utils.dart';
13 15
14 class FinanceProvider extends ChangeNotifier { 16 class FinanceProvider extends ChangeNotifier {
15 PageState pageState = PageState.Loading; 17 PageState pageState = PageState.Loading;
16 - 18 + PageState pageStateRecordHome = PageState.Loading;
  19 + PageState pageStateRecordSearch = PageState.Loading;
  20 + PageState pageStateRecordDetail = PageState.Loading;
17 String paymentCodeUrl = ''; 21 String paymentCodeUrl = '';
  22 + List<DiscountOrderListModelData?> discountOrderList = [];
  23 +
  24 + DiscountOrderInfoModelData? discountOrderInfoModelData;
18 25
19 ///客户经理获取所创建活动列表 26 ///客户经理获取所创建活动列表
20 Future createPayQrcode(BuildContext context, {isShowLoading = true}) async { 27 Future createPayQrcode(BuildContext context, {isShowLoading = true}) async {
@@ -25,7 +32,7 @@ class FinanceProvider extends ChangeNotifier { @@ -25,7 +32,7 @@ class FinanceProvider extends ChangeNotifier {
25 }; 32 };
26 BaseResp<dynamic> baseResp = await DioUtil().request<dynamic>( 33 BaseResp<dynamic> baseResp = await DioUtil().request<dynamic>(
27 context, Method.post, HttpUrl.create_pay_qrcode, 34 context, Method.post, HttpUrl.create_pay_qrcode,
28 - data: params, showLoading: false); 35 + data: params, showLoading: isShowLoading );
29 if (baseResp.code == Constant.status_success) { 36 if (baseResp.code == Constant.status_success) {
30 if (baseResp.data.isEmpty) { 37 if (baseResp.data.isEmpty) {
31 // if (isShowLoading) { 38 // if (isShowLoading) {
@@ -69,4 +76,176 @@ class FinanceProvider extends ChangeNotifier { @@ -69,4 +76,176 @@ class FinanceProvider extends ChangeNotifier {
69 notifyListeners(); 76 notifyListeners();
70 } 77 }
71 } 78 }
  79 +
  80 + ///获取交易记录列表
  81 + Future getDiscountOrderList(BuildContext context, Map<String, String?> params,
  82 + {String from = 'home', isShowLoading = true}) async {
  83 + PageState pageStateTemp = PageState.Loading;
  84 + try {
  85 + BaseResp<dynamic> baseResp = await DioUtil().request<dynamic>(
  86 + context, Method.post, HttpUrl.get_discount_orderlist,
  87 + data: params, showLoading: isShowLoading );
  88 + if (baseResp.code == Constant.status_success) {
  89 + if (baseResp.data.isEmpty) {
  90 + // if (isShowLoading) {
  91 + pageStateTemp = PageState.Empty;
  92 + // }
  93 + } else {
  94 + // if (isShowLoading) {
  95 + pageStateTemp = PageState.Success;
  96 + // }
  97 + }
  98 + discountOrderList =
  99 + DiscountOrderListModel.fromJson(baseResp.responseData!).data ?? [];
  100 +
  101 + if (discountOrderList.length > 0) {
  102 + for (var element in discountOrderList) {
  103 + if (element?.list != null) {
  104 + List<DiscountOrderListModelDataList?> temp = [];
  105 + for (var elementSub in element!.list!) {
  106 + temp.add(DiscountOrderListModelDataList.fromJson(
  107 + elementSub!.toJson()));
  108 + if ((elementSub.refundId != null && elementSub.status == '2') ||
  109 + elementSub.status == '4' ||
  110 + elementSub.status == '5') {
  111 + //这笔数据是退款
  112 + elementSub.status = '00';
  113 + temp.add(elementSub);
  114 + }
  115 + }
  116 + element.list = temp;
  117 + }
  118 + }
  119 + }
  120 + print(discountOrderList);
  121 + } else {
  122 + if (isShowLoading) {
  123 + pageStateTemp = PageState.ConnectivityError;
  124 + }
  125 + if (baseResp != null) {
  126 + Utils.showToast(baseResp.msg ?? "");
  127 + }
  128 + }
  129 +
  130 + if (from == 'home') {
  131 + pageStateRecordHome = pageStateTemp;
  132 + } else {
  133 + pageStateRecordSearch = pageStateTemp;
  134 + }
  135 + notifyListeners();
  136 + } catch (error) {
  137 + print(error.toString());
  138 +
  139 + if (error is MyError) {
  140 + if (isShowLoading) {
  141 + switch (error.type) {
  142 + case 1:
  143 + pageStateTemp = PageState.ConnectivityError;
  144 + break;
  145 + case 2:
  146 + pageStateTemp = PageState.ConnectivityTimeOut;
  147 + break;
  148 + default:
  149 + pageStateTemp = PageState.ConnectivityError;
  150 + break;
  151 + }
  152 + }
  153 + }
  154 + if (from == 'home') {
  155 + pageStateRecordHome = pageStateTemp;
  156 + } else {
  157 + pageStateRecordSearch = pageStateTemp;
  158 + }
  159 + notifyListeners();
  160 + }
  161 + }
  162 +
  163 + /// 通过支付订单号或退款订单号获取订单
  164 + Future getDiscountOrderInfo(BuildContext context, Map<String, String?> params,
  165 + {isShowLoading = true}) async {
  166 + try {
  167 + BaseResp<dynamic> baseResp = await DioUtil().request<dynamic>(
  168 + context, Method.post, HttpUrl.get_discount_order_info,
  169 + data: params, showLoading: false);
  170 + if (baseResp.code == Constant.status_success) {
  171 + if (baseResp.data.isEmpty) {
  172 + // if (isShowLoading) {
  173 + pageStateRecordDetail = PageState.Empty;
  174 + // }
  175 + } else {
  176 + // if (isShowLoading) {
  177 + pageStateRecordDetail = PageState.Success;
  178 + // }
  179 + }
  180 + discountOrderInfoModelData =
  181 + DiscountOrderInfoModel.fromJson(baseResp.responseData!).data;
  182 + } else {
  183 + if (isShowLoading) {
  184 + pageStateRecordDetail = PageState.ConnectivityError;
  185 + }
  186 + if (baseResp != null) {
  187 + Utils.showToast(baseResp.msg ?? "");
  188 + }
  189 + }
  190 +
  191 + notifyListeners();
  192 + } catch (error) {
  193 + print(error.toString());
  194 +
  195 + if (error is MyError) {
  196 + if (isShowLoading) {
  197 + switch (error.type) {
  198 + case 1:
  199 + pageStateRecordDetail = PageState.ConnectivityError;
  200 + break;
  201 + case 2:
  202 + pageStateRecordDetail = PageState.ConnectivityTimeOut;
  203 + break;
  204 + default:
  205 + pageStateRecordDetail = PageState.ConnectivityError;
  206 + break;
  207 + }
  208 + }
  209 + }
  210 + notifyListeners();
  211 + }
  212 + }
  213 +
  214 + /// 优惠支付订单退款
  215 + Future discountPayRefundApply(
  216 + BuildContext context, Map<String, String?> params,
  217 + {isShowLoading = true}) async {
  218 + try {
  219 + BaseResp<dynamic> baseResp = await DioUtil().request<dynamic>(
  220 + context, Method.post, HttpUrl.discount_pay_refund_apply,
  221 + data: params, showLoading: false);
  222 + if (baseResp.code == Constant.status_success) {
  223 + if (baseResp.data is Map) {
  224 + if (baseResp.data.containKeys('code')) {
  225 + //错误了
  226 + if (baseResp.data['code'] == 'NOT_ENOUGH') {
  227 + return '您的账户余额不足,无法支付本次退款,请往账户中充值后,再进行退款操作!';
  228 + } else {
  229 + return baseResp.data['message'] ?? '未知错误';
  230 + }
  231 + } else {
  232 + //退款成功
  233 + return true;
  234 + }
  235 + }
  236 + } else {
  237 + if (baseResp != null) {
  238 + Utils.showToast(baseResp.msg ?? "");
  239 + }
  240 + notifyListeners();
  241 + return false;
  242 + }
  243 + } catch (error) {
  244 + print(error.toString());
  245 +
  246 + if (error is MyError) {}
  247 + notifyListeners();
  248 + return false;
  249 + }
  250 + }
72 } 251 }
@@ -2388,10 +2388,10 @@ class NavigatorUtil { @@ -2388,10 +2388,10 @@ class NavigatorUtil {
2388 2388
2389 ///交易详情 2389 ///交易详情
2390 static Future<dynamic> goTransactionRecordDetailPage( 2390 static Future<dynamic> goTransactionRecordDetailPage(
2391 - BuildContext context, { 2391 + BuildContext context,String? status,String? id, {
2392 replace = false, 2392 replace = false,
2393 }) { 2393 }) {
2394 - return _navigateTo(context, "${Routes.transaction_record_detail_page}", 2394 + return _navigateTo(context, "${Routes.transaction_record_detail_page}?status=$status&id=$id",
2395 replace: replace); 2395 replace: replace);
2396 } 2396 }
2397 } 2397 }
@@ -4179,7 +4179,8 @@ var transactionRecordSearchPageHandle = new Handler( @@ -4179,7 +4179,8 @@ var transactionRecordSearchPageHandle = new Handler(
4179 4179
4180 var transactionRecordDetailPageHandle = new Handler( 4180 var transactionRecordDetailPageHandle = new Handler(
4181 handlerFunc: (BuildContext? context, Map<String, List<Object>> params) { 4181 handlerFunc: (BuildContext? context, Map<String, List<Object>> params) {
4182 - // String rid = params["rid"].first; 4182 + String id = params["id"]!.first as String;
  4183 + String status= params["status"]!.first as String;
4183 // bool isMine = 4184 // bool isMine =
4184 // FluroConvertUtils.string2bool(params["isMine"]!.first as String); 4185 // FluroConvertUtils.string2bool(params["isMine"]!.first as String);
4185 // CouponSunModel? couponSunModel; 4186 // CouponSunModel? couponSunModel;
@@ -4190,5 +4191,5 @@ var transactionRecordDetailPageHandle = new Handler( @@ -4190,5 +4191,5 @@ var transactionRecordDetailPageHandle = new Handler(
4190 // } 4191 // }
4191 4192
4192 return ChangeNotifierProvider<FinanceProvider>( 4193 return ChangeNotifierProvider<FinanceProvider>(
4193 - create: (_) => FinanceProvider(), child: TransactionRecordDetailPage()); 4194 + create: (_) => FinanceProvider(), child: TransactionRecordDetailPage(status:status,id:id));
4194 }); 4195 });
@@ -5244,7 +5244,7 @@ class DialogUtil { @@ -5244,7 +5244,7 @@ class DialogUtil {
5244 HEmptyView(40), 5244 HEmptyView(40),
5245 Expanded( 5245 Expanded(
5246 child: Text( 5246 child: Text(
5247 - areaName??'', 5247 + areaName ?? '',
5248 maxLines: 1, 5248 maxLines: 1,
5249 textAlign: TextAlign.right, 5249 textAlign: TextAlign.right,
5250 overflow: TextOverflow.ellipsis, 5250 overflow: TextOverflow.ellipsis,
@@ -10491,7 +10491,7 @@ class DialogUtil { @@ -10491,7 +10491,7 @@ class DialogUtil {
10491 style: TextStyle( 10491 style: TextStyle(
10492 fontWeight: 10492 fontWeight:
10493 isBoldContent ? FontWeight.bold : FontWeight.normal, 10493 isBoldContent ? FontWeight.bold : FontWeight.normal,
10494 - fontSize: ScreenUtil().setSp(32), 10494 + fontSize: ScreenUtil().setSp(30),
10495 color: contentColor)), 10495 color: contentColor)),
10496 actions: [ 10496 actions: [
10497 // CupertinoDialogAction( 10497 // CupertinoDialogAction(
@@ -10552,7 +10552,7 @@ class DialogUtil { @@ -10552,7 +10552,7 @@ class DialogUtil {
10552 style: TextStyle( 10552 style: TextStyle(
10553 fontWeight: 10553 fontWeight:
10554 isBoldContent ? FontWeight.bold : FontWeight.normal, 10554 isBoldContent ? FontWeight.bold : FontWeight.normal,
10555 - fontSize: ScreenUtil().setSp(32), 10555 + fontSize: ScreenUtil().setSp(30),
10556 color: contentColor)), 10556 color: contentColor)),
10557 actions: [ 10557 actions: [
10558 if (showlTitle) 10558 if (showlTitle)
@@ -318,8 +318,8 @@ dev_dependencies: @@ -318,8 +318,8 @@ dev_dependencies:
318 318
319 # json_model: ^0.0.2 319 # json_model: ^0.0.2
320 320
321 - build_runner: ^2.3.3  
322 - json_serializable: ^6.6.2 321 + build_runner: ^2.4.14
  322 + json_serializable: ^6.9.4
323 test: ^1.22.0 323 test: ^1.22.0
324 324
325 325