diff --git a/android/app/src/main/java/kz/com/aman/kassa/handler/CloseDayHandlerImpl.java b/android/app/src/main/java/kz/com/aman/kassa/handler/CloseDayHandlerImpl.java index 2e5b65a..53b490a 100644 --- a/android/app/src/main/java/kz/com/aman/kassa/handler/CloseDayHandlerImpl.java +++ b/android/app/src/main/java/kz/com/aman/kassa/handler/CloseDayHandlerImpl.java @@ -53,7 +53,12 @@ public class CloseDayHandlerImpl implements CloseDayCallbackHandler { @Override public void onTransactionsListReceived(List transactionList, List list1) { - plugin.getActivity().runOnUiThread(() -> Toast.makeText(plugin.getActivity(), "onTransactionsListReceived - " + transactionList, Toast.LENGTH_SHORT).show()); + plugin.getActivity().runOnUiThread(() -> { + AmanDao dao = new AmanDao<>(); + dao.setSuccess(true); + this.result.success(gson.toJson(dao)); + Toast.makeText(plugin.getActivity(), "На закрытие дня: - " + transactionList, Toast.LENGTH_SHORT).show(); + }); } @Override diff --git a/lib/views/bank_setting/bank_setting_view.dart b/lib/views/bank_setting/bank_setting_view.dart index 1709fb3..034a744 100644 --- a/lib/views/bank_setting/bank_setting_view.dart +++ b/lib/views/bank_setting/bank_setting_view.dart @@ -56,44 +56,7 @@ class _BankSettingViewState extends State { _dialogService.showDialog(description: 'Данные сохранены'); } - void _closeDay(BuildContext _context) async { - FocusScope.of(_context).unfocus(); - //Инициализация - bool initialized = await _bankService.init(); - if (!initialized) { - return; - } - - - - //Проверка связи - bool connected = await _bankService.connect(); - if (!connected) { - return; - } - //Авторизация - BankState bankState = Redux.store.state.bankState; - AmanDao authDao = await _bankService.auth( - login: bankState.login, password: bankState.password); - if (!authDao.success) { - if (authDao.msg != null) { - _dialogService.showDialog(description: authDao.msg); - } - return; - } - - AmanDao closeDayDao = await _bankService.closeDay(); - - if (!closeDayDao.success) { - if (closeDayDao.msg != null) { - _dialogService.showDialog(description: closeDayDao.msg); - } - return; - } - - _dialogService.showDialog(description: 'Закрытие дня: операция прошла успешно!'); - } @override Widget build(BuildContext context) { @@ -137,17 +100,7 @@ class _BankSettingViewState extends State { padding: const EdgeInsets.symmetric(vertical: 5.0, horizontal: 20.0), ), - verticalSpaceLarge, - RaisedButton( - onPressed: () => this._closeDay(context), - child: Text( - 'Закрыть день', - style: TextStyle(color: whiteColor, fontSize: 25.0), - ), - color: primaryColor, - padding: - const EdgeInsets.symmetric(vertical: 5.0, horizontal: 20.0), - ) + ], ), ), diff --git a/lib/views/home/tabs/AdditionalTab.dart b/lib/views/home/tabs/AdditionalTab.dart index aeeb3d1..9e4aa4e 100644 --- a/lib/views/home/tabs/AdditionalTab.dart +++ b/lib/views/home/tabs/AdditionalTab.dart @@ -1,17 +1,20 @@ import 'package:aman_kassa_flutter/core/entity/Voucher.dart'; import 'package:aman_kassa_flutter/core/locator.dart'; +import 'package:aman_kassa_flutter/core/models/aman_dao.dart'; import 'package:aman_kassa_flutter/core/models/money.dart'; import 'package:aman_kassa_flutter/core/models/response.dart'; import 'package:aman_kassa_flutter/core/models/dialog_models.dart'; import 'package:aman_kassa_flutter/core/models/user.dart'; import 'package:aman_kassa_flutter/core/route_names.dart'; import 'package:aman_kassa_flutter/core/services/ApiService.dart'; +import 'package:aman_kassa_flutter/core/services/BankService.dart'; import 'package:aman_kassa_flutter/core/services/DataService.dart'; import 'package:aman_kassa_flutter/core/services/dialog_service.dart'; import 'package:aman_kassa_flutter/core/services/navigator_service.dart'; import 'package:aman_kassa_flutter/redux/actions/user_actions.dart'; import 'package:aman_kassa_flutter/redux/actions/setting_actions.dart'; import 'package:aman_kassa_flutter/redux/constants/setting_const.dart'; +import 'package:aman_kassa_flutter/redux/state/bank_state.dart'; import 'package:aman_kassa_flutter/redux/state/setting_state.dart'; import 'package:aman_kassa_flutter/redux/store.dart'; import 'package:aman_kassa_flutter/shared/app_colors.dart'; @@ -38,10 +41,12 @@ class _AdditionalTabState extends State { ApiService _api = locator(); NavigatorService _navigator = locator(); DialogService _dialog = locator(); + final BankService _bankService = locator(); DataService _dataService = locator(); final GlobalKey _keyLoader = new GlobalKey(); bool isMoneyCheckBusy; + bool isClosePosBusy; bool closeSmenaBusy; bool openSmenaBusy; bool depositBusy; @@ -59,6 +64,7 @@ class _AdditionalTabState extends State { withdrawalBusy = false; xReportBusy = false; updateCatalog = false; + isClosePosBusy = false; } void _closeSmena() async { @@ -209,6 +215,70 @@ class _AdditionalTabState extends State { } } + void _closeDay() async { + + setState(() { + isClosePosBusy = true; + }); + + int version = await _bankService.version(); + if (version < 24 ) { + setState(() { + isClosePosBusy = false; + }); + _dialog.showDialog(description: 'Функция Tap2Phone доступна c Android версии 7.0'); + return; + } + + //Инициализация + bool initialized = await _bankService.init(); + if (!initialized) { + setState(() { + isClosePosBusy = false; + }); + return; + } + + //Проверка связи + bool connected = await _bankService.connect(); + if (!connected) { + setState(() { + isClosePosBusy = false; + }); + return; + } + //Авторизация + BankState bankState = Redux.store.state.bankState; + AmanDao authDao = await _bankService.auth( + login: bankState.login, password: bankState.password); + if (!authDao.success) { + if (authDao.msg != null) { + _dialog.showDialog(description: authDao.msg); + } + setState(() { + isClosePosBusy = false; + }); + return; + } + + AmanDao closeDayDao = await _bankService.closeDay(); + + if (!closeDayDao.success) { + if (closeDayDao.msg != null) { + _dialog.showDialog(description: closeDayDao.msg); + } + setState(() { + isClosePosBusy = false; + }); + return; + } + + _dialog.showDialog(description: 'Закрытие дня: операция прошла успешно!'); + setState(() { + isClosePosBusy = false; + }); + } + @override Widget build(BuildContext context) { return Container( @@ -256,52 +326,72 @@ class _AdditionalTabState extends State { verticalSpaceMedium, Padding( padding: const EdgeInsets.symmetric(horizontal: 20.0), - child: Center( - child: Column( - children: [ - Text( - 'Денег в кассе:', - style: TextStyle(color: primaryColor, fontSize: 15), - ), - SizedBox( - height: 50, - width: double.infinity, - child: StoreConnector( - converter: (store) => store.state.userState.money, - builder: (_, vm) { - if (vm.loading == true) { - return Center( - child: SizedBox( - width: 30, - height: 30, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: CircularProgressIndicator( - strokeWidth: 2, - valueColor: new AlwaysStoppedAnimation( - primaryColor), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Icon(Icons.money, color: primaryColor), + Text( + 'Денег в кассе:', + style: TextStyle(color: primaryColor, fontSize: 15), + ), + ], + ), + SizedBox( + height: 50, + // width: double.infinity, + child: StoreConnector( + converter: (store) => store.state.userState.money, + builder: (_, vm) { + if (vm.loading == true) { + return Center( + child: SizedBox( + width: 30, + height: 30, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: CircularProgressIndicator( + strokeWidth: 2, + valueColor: + new AlwaysStoppedAnimation( + primaryColor), + ), + ), ), + ); + } + return Center( + child: Text( + vm.total != null + ? '${vm.total} тенге' + : 'нет информации', + style: TextStyle( + color: vm.total != null + ? primaryColor + : Colors.grey.withOpacity(0.5), + fontSize: 25, + fontWeight: FontWeight.bold), ), - ), - ); - } - return Center( - child: Text( - vm.total != null - ? '${vm.total} тенге' - : 'нет информации', - style: TextStyle( - color: vm.total != null - ? primaryColor - : Colors.grey.withOpacity(0.5), - fontSize: 25, - fontWeight: FontWeight.bold), - ), - ); - }), + ); + }), + ), + ], + ), + Container( + child: AmanIconButton( + title: 'Обновить', + onPressed: _checkMoney, + busy: isMoneyCheckBusy, + icon: Icons.replay_circle_filled, + mainColor: primaryColor, + ), ), ], - )), + ), ), verticalSpaceMedium, Wrap( @@ -325,12 +415,19 @@ class _AdditionalTabState extends State { busy: closeSmenaBusy, icon: Icons.lock_outline, ), + // AmanIconButton( + // title: 'Денег в кассе', + // onPressed: _checkMoney, + // busy: isMoneyCheckBusy, + // icon: MdiIcons.walletOutline, + // mainColor: primaryColor, + // ), AmanIconButton( - title: 'Денег в кассе', - onPressed: _checkMoney, - busy: isMoneyCheckBusy, - icon: MdiIcons.walletOutline, - mainColor: primaryColor, + title: 'Закрыть POS', + onPressed: _closeDay, + busy: isClosePosBusy, + icon: Icons.phonelink_lock_outlined, + mainColor: purpleColor, ), AmanIconButton( title: 'Х Отчет', diff --git a/lib/views/payment_nfc/payment_nfc_view.dart b/lib/views/payment_nfc/payment_nfc_view.dart index c0d855e..bb0f020 100644 --- a/lib/views/payment_nfc/payment_nfc_view.dart +++ b/lib/views/payment_nfc/payment_nfc_view.dart @@ -179,7 +179,7 @@ class _PaymentNfcViewState extends State { } setState(() { - status = 3; + status = 9; isPhoneScaled = false; }); diff --git a/lib/views/payment_nfc/widgets/phone_view.dart b/lib/views/payment_nfc/widgets/phone_view.dart index ad99627..76e653c 100644 --- a/lib/views/payment_nfc/widgets/phone_view.dart +++ b/lib/views/payment_nfc/widgets/phone_view.dart @@ -149,6 +149,17 @@ class _PhoneViewState extends State { ); } + if(widget.status == 9){ + return Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon(MdiIcons.checkBold, color: greenColor,size: ScreenUtil().setSp(90.0),), + verticalSpaceSmall, + AutoSizeText('Возврат транзакции', style: TextStyle(fontWeight: FontWeight.bold),) + ], + ); + } + return Container(); } }