refund and close day release

backend_nfc
suvaissov 2021-01-08 14:52:11 +06:00
parent 48398435e8
commit a1b8223980
5 changed files with 163 additions and 97 deletions

View File

@ -53,7 +53,12 @@ public class CloseDayHandlerImpl implements CloseDayCallbackHandler<Result> {
@Override
public void onTransactionsListReceived(List<Transaction> transactionList, List<CloseDayResponseInfo> list1) {
plugin.getActivity().runOnUiThread(() -> Toast.makeText(plugin.getActivity(), "onTransactionsListReceived - " + transactionList, Toast.LENGTH_SHORT).show());
plugin.getActivity().runOnUiThread(() -> {
AmanDao<String> dao = new AmanDao<>();
dao.setSuccess(true);
this.result.success(gson.toJson(dao));
Toast.makeText(plugin.getActivity(), "На закрытие дня: - " + transactionList, Toast.LENGTH_SHORT).show();
});
}
@Override

View File

@ -56,44 +56,7 @@ class _BankSettingViewState extends State<BankSettingView> {
_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<BankSettingView> {
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),
)
],
),
),

View File

@ -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<AdditionalTab> {
ApiService _api = locator<ApiService>();
NavigatorService _navigator = locator<NavigatorService>();
DialogService _dialog = locator<DialogService>();
final BankService _bankService = locator<BankService>();
DataService _dataService = locator<DataService>();
final GlobalKey<State> _keyLoader = new GlobalKey<State>();
bool isMoneyCheckBusy;
bool isClosePosBusy;
bool closeSmenaBusy;
bool openSmenaBusy;
bool depositBusy;
@ -59,6 +64,7 @@ class _AdditionalTabState extends State<AdditionalTab> {
withdrawalBusy = false;
xReportBusy = false;
updateCatalog = false;
isClosePosBusy = false;
}
void _closeSmena() async {
@ -209,6 +215,70 @@ class _AdditionalTabState extends State<AdditionalTab> {
}
}
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<AdditionalTab> {
verticalSpaceMedium,
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20.0),
child: Center(
child: Column(
children: <Widget>[
Text(
'Денег в кассе:',
style: TextStyle(color: primaryColor, fontSize: 15),
),
SizedBox(
height: 50,
width: double.infinity,
child: StoreConnector<AppState, Money>(
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<Color>(
primaryColor),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
children: [
Icon(Icons.money, color: primaryColor),
Text(
'Денег в кассе:',
style: TextStyle(color: primaryColor, fontSize: 15),
),
],
),
SizedBox(
height: 50,
// width: double.infinity,
child: StoreConnector<AppState, Money>(
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<Color>(
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<AdditionalTab> {
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: 'Х Отчет',

View File

@ -179,7 +179,7 @@ class _PaymentNfcViewState extends State<PaymentNfcView> {
}
setState(() {
status = 3;
status = 9;
isPhoneScaled = false;
});

View File

@ -149,6 +149,17 @@ class _PhoneViewState extends State<PhoneView> {
);
}
if(widget.status == 9){
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(MdiIcons.checkBold, color: greenColor,size: ScreenUtil().setSp(90.0),),
verticalSpaceSmall,
AutoSizeText('Возврат транзакции', style: TextStyle(fontWeight: FontWeight.bold),)
],
);
}
return Container();
}
}