Commit 3aff39314a8cca9e1d694398e36da8003de2052f

Authored by wdn127929
1 parent 53ca7332

支付返券

@@ -20,19 +20,19 @@ if (flutterRoot == null) { @@ -20,19 +20,19 @@ if (flutterRoot == null) {
20 20
21 21
22 22
23 -def flutterVersionCode = "550" 23 +def flutterVersionCode = "552"
24 if (flutterVersionCode == null) { 24 if (flutterVersionCode == null) {
25 - flutterVersionCode = '550' 25 + flutterVersionCode = '552'
26 26
27 27
28 28
29 } 29 }
30 30
31 31
32 -def flutterVersionName = "5.5.0" 32 +def flutterVersionName = "5.5.2"
33 33
34 if (flutterVersionName == null) { 34 if (flutterVersionName == null) {
35 - flutterVersionName = '5.5.0' 35 + flutterVersionName = '5.5.2'
36 36
37 } 37 }
38 38
@@ -603,18 +603,18 @@ class HttpUrl { @@ -603,18 +603,18 @@ class HttpUrl {
603 static const create_pay_qrcode = 603 static const create_pay_qrcode =
604 "?service=App.Seller.CreatePayQrcode"; // 生成商家收款二维码 604 "?service=App.Seller.CreatePayQrcode"; // 生成商家收款二维码
605 605
606 -static const get_discount_orderlist = 606 + static const get_discount_orderlist =
607 "?service=App.Activity.GetDiscountOrderList"; // 获取交易记录 607 "?service=App.Activity.GetDiscountOrderList"; // 获取交易记录
608 608
609 -static const get_discount_order_info = 609 + static const get_discount_order_info =
610 "?service=App.Activity.GetDiscountOrderInfo"; // 通过支付订单号或退款订单号获取订单 610 "?service=App.Activity.GetDiscountOrderInfo"; // 通过支付订单号或退款订单号获取订单
611 611
612 -static const discount_pay_refund_apply= 612 + static const discount_pay_refund_apply =
613 "?service=App.PayOnline.DiscountPayRefundApply"; // 优惠支付订单退款 613 "?service=App.PayOnline.DiscountPayRefundApply"; // 优惠支付订单退款
614 -  
615 -  
616 -  
617 - 614 + static const set_activity_config =
  615 + "?service=App.Activity.SetActivityConfig"; // 获取商家券赠送规则配置
  616 + static const get_activity_config =
  617 + "?service=App.Activity.GetActivityConfig"; // 获取商家券赠送规则配置
618 618
619 619
620 } 620 }
@@ -71,9 +71,9 @@ class _FinanceManageHomePageState extends State<FinanceManageHomePage> { @@ -71,9 +71,9 @@ class _FinanceManageHomePageState extends State<FinanceManageHomePage> {
71 // NavigatorUtil.goEnterpriseInformationUploadPage(context); 71 // NavigatorUtil.goEnterpriseInformationUploadPage(context);
72 // }), 72 // }),
73 // _item('微信商户账户开通结果查询', () {}), 73 // _item('微信商户账户开通结果查询', () {}),
74 - // _item('支付返券', () {  
75 - // NavigatorUtil.goPaymentGiftPage(context);  
76 - // }), 74 + _item('支付返券', () {
  75 + NavigatorUtil.goPaymentGiftPage(context);
  76 + }),
77 _item('门店收款码', () { 77 _item('门店收款码', () {
78 NavigatorUtil.goPaymentCodePage(context); 78 NavigatorUtil.goPaymentCodePage(context);
79 }), 79 }),
  1 +import 'dart:convert';
  2 +
1 import 'package:common_utils/common_utils.dart'; 3 import 'package:common_utils/common_utils.dart';
2 import 'package:flutter/material.dart'; 4 import 'package:flutter/material.dart';
3 import 'package:flutter/services.dart'; 5 import 'package:flutter/services.dart';
4 import 'package:flutter_picker_plus/picker.dart'; 6 import 'package:flutter_picker_plus/picker.dart';
5 import 'package:flutter_screenutil/flutter_screenutil.dart'; 7 import 'package:flutter_screenutil/flutter_screenutil.dart';
  8 +import 'package:one_key/provider/user_model.dart';
6 import 'package:one_key/res/colors.dart'; 9 import 'package:one_key/res/colors.dart';
7 import 'package:one_key/widgets/h_empty_view.dart'; 10 import 'package:one_key/widgets/h_empty_view.dart';
8 import 'package:one_key/widgets/system_app_bar.dart'; 11 import 'package:one_key/widgets/system_app_bar.dart';
@@ -29,7 +32,6 @@ class PaymentGiftPage extends StatefulWidget { @@ -29,7 +32,6 @@ class PaymentGiftPage extends StatefulWidget {
29 32
30 class _PaymentGiftPageState extends State<PaymentGiftPage> { 33 class _PaymentGiftPageState extends State<PaymentGiftPage> {
31 bool fullReduction = true; 34 bool fullReduction = true;
32 - bool ladderReduction = false;  
33 35
34 String fromDateFull = '选择日期'; 36 String fromDateFull = '选择日期';
35 String endDateFull = '选择日期'; 37 String endDateFull = '选择日期';
@@ -46,6 +48,117 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { @@ -46,6 +48,117 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> {
46 List coupons = ['1', '2', '3']; 48 List coupons = ['1', '2', '3'];
47 List ladders = ['1', '2', '3']; 49 List ladders = ['1', '2', '3'];
48 List<CouponSunModel>? couponSelectFree = []; 50 List<CouponSunModel>? couponSelectFree = [];
  51 + bool rule = true;
  52 +
  53 + @override
  54 + void initState() {
  55 + super.initState();
  56 +
  57 + WidgetsBinding.instance.addPostFrameCallback((_) {
  58 + // _getCountCommentLabel(isShowLoading: false);
  59 + });
  60 + // bus.on("refresh_discount_order_list", (args) {
  61 + // // _getReserveDetail(isShowLoading: false);
  62 + // _getDiscountOrderList(isShowLoading: false);
  63 + // });
  64 + }
  65 +
  66 + _setActivityConfig() async {
  67 + Map<String, String>? fullReductionData;
  68 + if (fullReduction) {
  69 + if (fromDateFull == '选择日期') {
  70 + Utils.showToast('请选择满减返券活动的开始时间!');
  71 + return;
  72 + }
  73 + if (endDateFull == '选择日期') {
  74 + Utils.showToast('请选择满减返券活动的结束时间!');
  75 + return;
  76 + }
  77 + if (fullC.text.trim().length == '0') {
  78 + Utils.showToast('请输入门槛金额!');
  79 + return;
  80 + }
  81 + if (couponSelectFree == null || couponSelectFree!.length == 0) {
  82 + Utils.showToast('请选择优惠券!');
  83 + return;
  84 + }
  85 + List<Map> couponsData = [];
  86 + couponSelectFree!.forEach((e) {
  87 + Map<String, String> coupon = {'id': e.id!, 'name': e.aname!};
  88 + couponsData.add(coupon);
  89 + });
  90 + String fromfull = fromDateFull + ' 00:00:00';
  91 + String endfull = endDateFull + ' 23:59:59';
  92 + String sfull =
  93 + '${(DateUtil.getDateMsByTimeStr(fromfull)! / 1000).floor()}';
  94 + String efull =
  95 + '${(DateUtil.getDateMsByTimeStr(endfull)! / 1000).floor()}';
  96 +
  97 + String ruleString = rule ? '1' : '0'; //发放规则
  98 +
  99 + fullReductionData = {
  100 + 'stime': sfull,
  101 + 'etime': efull,
  102 + 'price': fullC.text,
  103 + 'coupons': jsonEncode(couponsData),
  104 + 'rule': ruleString
  105 + };
  106 + } else {
  107 + //阶梯返券
  108 + if (fromDateLadder == '选择日期') {
  109 + Utils.showToast('请选择阶梯返券活动的开始时间!');
  110 + return;
  111 + }
  112 + if (endDateLadder == '选择日期') {
  113 + Utils.showToast('请选择阶梯返券活动的结束时间!');
  114 + return;
  115 + }
  116 + if (fullC.text.trim().length == '0') {
  117 + Utils.showToast('请输入门槛金额!');
  118 + return;
  119 + }
  120 + // if (couponSelectFree == null || couponSelectFree!.length == 0) {
  121 + // Utils.showToast('请选择优惠券!');
  122 + // return;
  123 + // }
  124 +
  125 + List<Map<String, String>> stairsData = [];
  126 + stairsData.add(
  127 + {
  128 + 'price': '100',
  129 + 'coupons':
  130 + "[{\"id\":\"1059\",\"name\":\"150-20\"},{\"id\":\"1058\",\"name\":\"100-30\"},{\"id\":\"1057\",\"name\":\"100-30\"},{\"id\":\"1056\",\"name\":\"150-20\"},{\"id\":\"1055\",\"name\":\"100-30\"}]",
  131 + },
  132 + );
  133 + stairsData.add(
  134 + {
  135 + 'price': '100',
  136 + 'coupons':
  137 + "[{\"id\":\"1059\",\"name\":\"150-20\"},{\"id\":\"1058\",\"name\":\"100-30\"},{\"id\":\"1057\",\"name\":\"100-30\"},{\"id\":\"1056\",\"name\":\"150-20\"},{\"id\":\"1055\",\"name\":\"100-30\"}]",
  138 + },
  139 + );
  140 + stairsData.add(
  141 + {
  142 + 'price': '100',
  143 + 'coupons':
  144 + "[{\"id\":\"1059\",\"name\":\"150-20\"},{\"id\":\"1058\",\"name\":\"100-30\"},{\"id\":\"1057\",\"name\":\"100-30\"},{\"id\":\"1056\",\"name\":\"150-20\"},{\"id\":\"1055\",\"name\":\"100-30\"}]",
  145 + },
  146 + );
  147 + }
  148 +
  149 + Map<String, String?> pramas = {
  150 + 'sellerid':
  151 + Provider.of<UserModel>(context, listen: false).user!.sellerid!,
  152 +
  153 + 'full_reduction': fullReduction ? '1' : '0',
  154 +
  155 + 'stairs': !fullReduction ? '1' : '0',
  156 + 'full_reduction_data':
  157 + fullReductionData == null ? null : jsonEncode(fullReductionData)
  158 +// 'stairs_data':
  159 + };
  160 + await financeProvider!.setActivityConfig(context, pramas);
  161 + }
49 162
50 ///是否立即启用 163 ///是否立即启用
51 Widget _canUse( 164 Widget _canUse(
@@ -365,6 +478,17 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { @@ -365,6 +478,17 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> {
365 (value) { 478 (value) {
366 // {'text': picker.adapter.text, 'select': selecteds} 479 // {'text': picker.adapter.text, 'select': selecteds}
367 if (value != null) { 480 if (value != null) {
  481 + if (endDateFull != '选择日期') {
  482 + if (DateUtil.getDateTime(endDateFull).compareTo(
  483 + DateUtil.getDateTime(DateUtil.formatDateStr(
  484 + value,
  485 + format: DateFormats.y_mo_d))) <
  486 + 0) {
  487 + Utils.showToast('满减返券的活动开始时间不能迟于活动结束时间');
  488 + return;
  489 + }
  490 + }
  491 +
368 setState(() { 492 setState(() {
369 print(value); 493 print(value);
370 fromDateFull = DateUtil.formatDateStr(value, 494 fromDateFull = DateUtil.formatDateStr(value,
@@ -393,6 +517,17 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { @@ -393,6 +517,17 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> {
393 (value) { 517 (value) {
394 // {'text': picker.adapter.text, 'select': selecteds} 518 // {'text': picker.adapter.text, 'select': selecteds}
395 if (value != null) { 519 if (value != null) {
  520 + if (fromDateFull != '选择日期') {
  521 + if (DateUtil.getDateTime(DateUtil.formatDateStr(
  522 + value,
  523 + format: DateFormats.y_mo_d))
  524 + .compareTo(
  525 + DateUtil.getDateTime(fromDateFull)) <
  526 + 0) {
  527 + Utils.showToast('满减返券的活动结束时间不能早于活动开始时间');
  528 + return;
  529 + }
  530 + }
396 setState(() { 531 setState(() {
397 print(value); 532 print(value);
398 endDateFull = DateUtil.formatDateStr(value, 533 endDateFull = DateUtil.formatDateStr(value,
@@ -455,46 +590,66 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { @@ -455,46 +590,66 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> {
455 color: MyColours.color_515151, fontSize: font(14)), 590 color: MyColours.color_515151, fontSize: font(14)),
456 ), 591 ),
457 Spacer(), 592 Spacer(),
458 - Container(  
459 - // width: w(100),  
460 - // height: w(30),  
461 - padding: EdgeInsets.symmetric(  
462 - horizontal: w(10), vertical: w(5)),  
463 - decoration: BoxDecoration(  
464 - color: MyColours.color_438E93,  
465 - borderRadius: BorderRadius.only(  
466 - topLeft: Radius.circular(r(5)),  
467 - bottomLeft: Radius.circular(r(5)))),  
468 - child: Text(  
469 - '每满门槛均发放',  
470 - style: TextStyle(  
471 - color: MyColours.color_ffffff,  
472 - fontSize: font(14)),  
473 - ),  
474 - ),  
475 - Container(  
476 - padding: EdgeInsets.symmetric(  
477 - horizontal: w(10), vertical: w(5)),  
478 - decoration: BoxDecoration(  
479 - color: MyColours.color_DBDBDB,  
480 - borderRadius: BorderRadius.only(  
481 - topRight: Radius.circular(r(5)),  
482 - bottomRight: Radius.circular(r(5)))),  
483 - child: Text(  
484 - '仅发放一次',  
485 - style: TextStyle(  
486 - color: MyColours.color_438E93,  
487 - fontSize: font(14)),  
488 - ),  
489 - ) 593 + InkWell(
  594 + onTap: () {
  595 + setState(() {
  596 + rule = !rule;
  597 + });
  598 + },
  599 + child: Container(
  600 + // width: w(100),
  601 + // height: w(30),
  602 + padding: EdgeInsets.symmetric(
  603 + horizontal: w(10), vertical: w(5)),
  604 + decoration: BoxDecoration(
  605 + color: rule
  606 + ? MyColours.color_438E93
  607 + : MyColours.color_DBDBDB,
  608 + borderRadius: BorderRadius.only(
  609 + topLeft: Radius.circular(r(5)),
  610 + bottomLeft: Radius.circular(r(5)))),
  611 + child: Text(
  612 + '每满门槛均发放',
  613 + style: TextStyle(
  614 + color: rule
  615 + ? MyColours.color_ffffff
  616 + : MyColours.color_438E93,
  617 + fontSize: font(14)),
  618 + ),
  619 + )),
  620 + InkWell(
  621 + onTap: () {
  622 + setState(() {
  623 + rule = !rule;
  624 + });
  625 + },
  626 + child: Container(
  627 + padding: EdgeInsets.symmetric(
  628 + horizontal: w(10), vertical: w(5)),
  629 + decoration: BoxDecoration(
  630 + color: !rule
  631 + ? MyColours.color_438E93
  632 + : MyColours.color_DBDBDB,
  633 + borderRadius: BorderRadius.only(
  634 + topRight: Radius.circular(r(5)),
  635 + bottomRight: Radius.circular(r(5)))),
  636 + child: Text(
  637 + '仅发放一次',
  638 + style: TextStyle(
  639 + color: !rule
  640 + ? MyColours.color_ffffff
  641 + : MyColours.color_438E93,
  642 + fontSize: font(14)),
  643 + ),
  644 + ))
490 ], 645 ],
491 ), 646 ),
492 ), 647 ),
493 VEmptyView(22), 648 VEmptyView(22),
494 - _canUse('开通实际支付阶梯返券【提客单】', ladderReduction, () { 649 + _canUse('开通实际支付阶梯返券【提客单】', !fullReduction, () {
495 // 650 //
496 setState(() { 651 setState(() {
497 - ladderReduction = !ladderReduction; 652 + fullReduction = !fullReduction;
498 }); 653 });
499 }), 654 }),
500 _select('活动开始于', fromDateLadder, () { 655 _select('活动开始于', fromDateLadder, () {
@@ -601,7 +756,10 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> { @@ -601,7 +756,10 @@ class _PaymentGiftPageState extends State<PaymentGiftPage> {
601 textColor: MyColours.color_ffffff, 756 textColor: MyColours.color_ffffff,
602 isBold: true, 757 isBold: true,
603 fontSize: 32, 758 fontSize: 32,
604 - onPressed: () {}, 759 + onPressed: () {
  760 + // 调用接口
  761 + _setActivityConfig();
  762 + },
605 ), 763 ),
606 ) 764 )
607 ], 765 ],
@@ -77,6 +77,124 @@ class FinanceProvider extends ChangeNotifier { @@ -77,6 +77,124 @@ class FinanceProvider extends ChangeNotifier {
77 } 77 }
78 } 78 }
79 79
  80 + // 商家券赠送规则配置
  81 + Future<bool> setActivityConfig(
  82 + BuildContext context, Map<String, String?> params,
  83 + {bool showLoading = true, bool needToast = true}) async {
  84 + try {
  85 + BaseResp<dynamic> baseResp = await DioUtil().request<dynamic>(
  86 + context, Method.post, HttpUrl.set_activity_config,
  87 + data: params, showLoading: showLoading);
  88 + if (baseResp.code == Constant.status_success) {
  89 + if (baseResp.data == 0 || baseResp.data == 1) {
  90 + if (needToast) {
  91 + Utils.showToast('设置成功');
  92 + }
  93 + return true;
  94 + } else {
  95 + if (needToast) {
  96 + Utils.showToast('设置失败,请重试');
  97 + }
  98 + }
  99 + } else {
  100 + if (needToast) {
  101 + Utils.showToast(baseResp.msg ?? '设置失败,请重试');
  102 + }
  103 + }
  104 + return false;
  105 + } catch (error) {
  106 + print(error.toString());
  107 + if (needToast) {
  108 + Utils.showToast('设置失败,请重试');
  109 + }
  110 +
  111 + return false;
  112 + }
  113 + }
  114 +
  115 + ///获取商家券赠送规则配置 还没做--------待使用----------
  116 + // Future getActivityConfig(BuildContext context, Map<String, String?> params,
  117 + // {isShowLoading = true}) async {
  118 + // PageState pageStateTemp = PageState.Loading;
  119 + // try {
  120 + // BaseResp<dynamic> baseResp = await DioUtil().request<dynamic>(
  121 + // context, Method.post, HttpUrl.get_activity_config,
  122 + // data: params, showLoading: isShowLoading);
  123 + // if (baseResp.code == Constant.status_success) {
  124 + // if (baseResp.data.isEmpty) {
  125 + // // if (isShowLoading) {
  126 + // pageStateTemp = PageState.Empty;
  127 + // // }
  128 + // } else {
  129 + // // if (isShowLoading) {
  130 + // pageStateTemp = PageState.Success;
  131 + // // }
  132 + // }
  133 + // discountOrderList =
  134 + // DiscountOrderListModel.fromJson(baseResp.responseData!).data ?? [];
  135 +
  136 + // if (discountOrderList.length > 0) {
  137 + // for (var element in discountOrderList) {
  138 + // if (element?.list != null) {
  139 + // List<DiscountOrderListModelDataList?> temp = [];
  140 + // for (var elementSub in element!.list!) {
  141 + // temp.add(DiscountOrderListModelDataList.fromJson(
  142 + // elementSub!.toJson()));
  143 + // if ((elementSub.refundId != null && elementSub.status == '2') ||
  144 + // elementSub.status == '4' ||
  145 + // elementSub.status == '5') {
  146 + // //这笔数据是退款
  147 + // elementSub.status = '00';
  148 + // temp.add(elementSub);
  149 + // }
  150 + // }
  151 + // element.list = temp;
  152 + // }
  153 + // }
  154 + // }
  155 + // print(discountOrderList);
  156 + // } else {
  157 + // if (isShowLoading) {
  158 + // pageStateTemp = PageState.ConnectivityError;
  159 + // }
  160 + // if (baseResp != null) {
  161 + // Utils.showToast(baseResp.msg ?? "");
  162 + // }
  163 + // }
  164 +
  165 + // if (from == 'home') {
  166 + // pageStateRecordHome = pageStateTemp;
  167 + // } else {
  168 + // pageStateRecordSearch = pageStateTemp;
  169 + // }
  170 + // notifyListeners();
  171 + // } catch (error) {
  172 + // print(error.toString());
  173 +
  174 + // if (error is MyError) {
  175 + // if (isShowLoading) {
  176 + // switch (error.type) {
  177 + // case 1:
  178 + // pageStateTemp = PageState.ConnectivityError;
  179 + // break;
  180 + // case 2:
  181 + // pageStateTemp = PageState.ConnectivityTimeOut;
  182 + // break;
  183 + // default:
  184 + // pageStateTemp = PageState.ConnectivityError;
  185 + // break;
  186 + // }
  187 + // }
  188 + // }
  189 + // if (from == 'home') {
  190 + // pageStateRecordHome = pageStateTemp;
  191 + // } else {
  192 + // pageStateRecordSearch = pageStateTemp;
  193 + // }
  194 + // notifyListeners();
  195 + // }
  196 + // }
  197 +
80 ///获取交易记录列表 198 ///获取交易记录列表
81 Future getDiscountOrderList(BuildContext context, Map<String, String?> params, 199 Future getDiscountOrderList(BuildContext context, Map<String, String?> params,
82 {String from = 'home', isShowLoading = true}) async { 200 {String from = 'home', isShowLoading = true}) async {