Commit be178cf2 authored by Dio Maulana's avatar Dio Maulana

add promo cc mandiri

parent 28c996e2
...@@ -295,12 +295,15 @@ class Api { ...@@ -295,12 +295,15 @@ class Api {
String brandCode, String brandCode,
String role, String role,
String cashierName, String cashierName,
String tokenUser) async { String tokenUser,
) async {
String baseUrl = prefs.getString('baseUrl') ?? ''; String baseUrl = prefs.getString('baseUrl') ?? '';
String apiUrl = '${baseUrl}romi/api/v2/byod/get_menu'; String apiUrl = '${baseUrl}romi/api/v2/byod/get_menu';
// List<FilterMenu> filterMenu = []; // List<FilterMenu> filterMenu = [];
List<FilterMenu> filterMenu = []; List<FilterMenu> filterMenu = [];
// List<FilterMenu> filterMenuResult = []; // List<FilterMenu> filterMenuResult = [];
String sessionID = prefs.getString('sessionId') ?? '';
try { try {
Map data = { Map data = {
"branch_code": branchCode, "branch_code": branchCode,
...@@ -308,7 +311,8 @@ class Api { ...@@ -308,7 +311,8 @@ class Api {
"role": role, "role": role,
"cashier_name": cashierName, "cashier_name": cashierName,
"secure_token": tokenUser, "secure_token": tokenUser,
"from": fromByod "from": fromByod,
"session_id": sessionID,
}; };
var bodies = jsonEncode(data); var bodies = jsonEncode(data);
// var apiResult = await http.post(Uri.parse(apiUrl), body: bodies); // var apiResult = await http.post(Uri.parse(apiUrl), body: bodies);
...@@ -828,6 +832,8 @@ class Api { ...@@ -828,6 +832,8 @@ class Api {
"doku_minimum_payment": jsonObject['data'] "doku_minimum_payment": jsonObject['data']
['doku_minimum_payment'], ['doku_minimum_payment'],
"order_date": jsonObject['data']['order_date'], "order_date": jsonObject['data']['order_date'],
"is_allow_promotion":
jsonObject['data']['is_allow_promotion'] ?? "0",
}; };
bill.add(Bill.createBill(i)); bill.add(Bill.createBill(i));
// billDetail.add(BillDetail.createBillDetail(orderDetail[d])); // billDetail.add(BillDetail.createBillDetail(orderDetail[d]));
...@@ -1679,4 +1685,63 @@ class Api { ...@@ -1679,4 +1685,63 @@ class Api {
return feedBack; return feedBack;
} }
} }
static Future<bool> addCancelPromotion(String orderID, bool isAdd) async {
await EasyLoading.show(
status: 'Please wait...',
maskType: EasyLoadingMaskType.none,
);
String baseUrl = prefs.getString('baseUrl') ?? '';
String apiUrl;
if (isAdd) {
apiUrl = "${baseUrl}romi/api/byod/add_promotions";
} else {
apiUrl = "${baseUrl}romi/api/byod/cancel_promotions";
}
String branchCode = prefs.getString('outlet') ?? '';
String brandCode = prefs.getString('brand') ?? '';
String role = prefs.getString('role') ?? 'customer';
String cashierName = prefs.getString('cashier_name') ?? '';
String userName = prefs.getString('userName') ?? '';
try {
Map data = {
"branch_code": branchCode,
"brand_code": brandCode,
"role": role,
"cashier_name": cashierName,
"from": fromByod,
"order_id": orderID,
};
var bodies = jsonEncode(data);
var jsonObject = await httpPost(apiUrl, bodies, 'addPromotion');
if (jsonObject != false) {
if (jsonObject['status'].toString().toLowerCase() == 'ok') {
if (isAdd) {
await prefs.setBool('isPromoActive', true);
EasyLoading.showToast('Promosi aktif');
} else {
await prefs.setBool('isPromoActive', false);
EasyLoading.showToast('Promosi tidak aktif');
}
return true;
} else {
EasyLoading.showToast(jsonObject['msg']);
return false;
}
} else {
EasyLoading.showToast('Something went wrong');
return false;
}
} catch (e) {
if (debug) {
logd('API CLASS ON API.DART, FUNGSI: addPromotion, URL : $apiUrl',
'ERROR CONNECT TO SERVER, ERROR CATCH : $e');
}
EasyLoading.showToast('Cant connect to server');
return false;
}
}
} }
import 'package:flutter/cupertino.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import '../api/api.dart'; import '../api/api.dart';
import '../helper/helper.dart'; import '../helper/helper.dart';
import 'filter_menu.dart';
class BranchExist extends Cubit<String> { class BranchExist extends Cubit<String> {
BranchExist() : super(responseApiWaiting); BranchExist() : super(responseApiWaiting);
...@@ -13,10 +15,20 @@ class BranchExist extends Cubit<String> { ...@@ -13,10 +15,20 @@ class BranchExist extends Cubit<String> {
return apiGetBranch; return apiGetBranch;
} }
void branchExist(String branchCode, String brandCode, String role, void branchExist(BuildContext context, String branchCode, String brandCode,
String cashierName, String sessionId) { String role, String cashierName, String sessionId,
{bool getMenu = false, String token = ''}) {
getBranch(branchCode, brandCode, role, cashierName, sessionId) getBranch(branchCode, brandCode, role, cashierName, sessionId)
.then((value) { .then((value) {
if (getMenu) {
context.read<FilterMenuBloc>().catAndMenu(
branchCode,
brandCode,
role,
cashierName,
token,
);
}
emit(value); emit(value);
}); });
} }
......
...@@ -22,10 +22,11 @@ class Bill { ...@@ -22,10 +22,11 @@ class Bill {
String tableName; String tableName;
bool isFeedBack; bool isFeedBack;
String dokuMinPay; String dokuMinPay;
String isPromotionAllow;
// List<MemberInfo> memberInfo; // List<MemberInfo> memberInfo;
Bill( Bill({
{required this.id, required this.id,
required this.totalSeluruhOrderan, required this.totalSeluruhOrderan,
required this.subTotalSeluruhOrderan, required this.subTotalSeluruhOrderan,
required this.totalPerCustomer, required this.totalPerCustomer,
...@@ -43,7 +44,8 @@ class Bill { ...@@ -43,7 +44,8 @@ class Bill {
required this.discountTotal, required this.discountTotal,
required this.tableName, required this.tableName,
required this.isFeedBack, required this.isFeedBack,
required this.dokuMinPay required this.dokuMinPay,
this.isPromotionAllow = "0",
// this.memberInfo = const [] // this.memberInfo = const []
}); });
...@@ -68,6 +70,7 @@ class Bill { ...@@ -68,6 +70,7 @@ class Bill {
isFeedBack: json['is_feedback'], isFeedBack: json['is_feedback'],
dokuMinPay: json['doku_minimum_payment'], dokuMinPay: json['doku_minimum_payment'],
dateOrder: json['order_date'], dateOrder: json['order_date'],
isPromotionAllow: json['is_allow_promotion'] ?? "0",
// memberInfo: json['member_info'] // memberInfo: json['member_info']
); );
} }
......
...@@ -947,14 +947,13 @@ class _NewHome2State extends State<NewHome2> { ...@@ -947,14 +947,13 @@ class _NewHome2State extends State<NewHome2> {
style: const TextStyle( style: const TextStyle(
fontFamily: 'OpenSans', fontFamily: 'OpenSans',
fontSize: 14, fontSize: 14,
color: textColorModalHeaderNama, color: textColorBlack,
), ),
decoration: const InputDecoration( decoration: const InputDecoration(
labelText: 'Nama panggilan', labelText: 'Nama panggilan',
labelStyle: TextStyle( labelStyle: TextStyle(
fontFamily: 'OpenSans', fontFamily: 'OpenSans',
fontSize: 14, fontSize: 14,
fontWeight: FontWeight.w600,
color: textColorModalHeaderNama, color: textColorModalHeaderNama,
), ),
), ),
......
...@@ -57,17 +57,20 @@ class _SplashState extends State<Splash> { ...@@ -57,17 +57,20 @@ class _SplashState extends State<Splash> {
loadBaseUrl().then((baseUrl) { loadBaseUrl().then((baseUrl) {
prefs.setString('baseUrl', baseUrl); prefs.setString('baseUrl', baseUrl);
context.read<BranchExist>().branchExist( context.read<BranchExist>().branchExist(
context,
widget.param, widget.param,
widget.brand, widget.brand,
widget.role, widget.role,
widget.cashierName, widget.cashierName,
widget.sessionId, widget.sessionId,
getMenu: true,
token: widget.token,
); );
// context.read<CategoryMenu>().catAndMenu(widget.param, widget.brand, // context.read<CategoryMenu>().catAndMenu(widget.param, widget.brand,
// widget.role, widget.cashierName, widget.token); // widget.role, widget.cashierName, widget.token);
context.read<FilterMenuBloc>().catAndMenu(widget.param, widget.brand, // context.read<FilterMenuBloc>().catAndMenu(widget.param, widget.brand,
widget.role, widget.cashierName, widget.token); // widget.role, widget.cashierName, widget.token);
if (widget.token != '') { if (widget.token != '') {
context.read<MemberInfoBloc>().getMemberInfo(widget.token); context.read<MemberInfoBloc>().getMemberInfo(widget.token);
......
...@@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; ...@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import '../../bloc/branch_exist.dart'; import '../../bloc/branch_exist.dart';
import '../../bloc/filter_menu.dart';
import '../../helper/helper.dart'; import '../../helper/helper.dart';
import '../../helper/widget/style.dart'; import '../../helper/widget/style.dart';
import '../../main.dart'; import '../../main.dart';
...@@ -24,6 +25,7 @@ class CustomAppBar extends StatelessWidget { ...@@ -24,6 +25,7 @@ class CustomAppBar extends StatelessWidget {
String role = prefs.getString('role') ?? ''; String role = prefs.getString('role') ?? '';
String cashierName = prefs.getString('cashier_name') ?? ''; String cashierName = prefs.getString('cashier_name') ?? '';
String sessionId = prefs.getString('sessionId') ?? ''; String sessionId = prefs.getString('sessionId') ?? '';
String tokenMember = prefs.getString('token') ?? '';
return Container( return Container(
padding: const EdgeInsets.only( padding: const EdgeInsets.only(
top: 15, top: 15,
...@@ -39,10 +41,22 @@ class CustomAppBar extends StatelessWidget { ...@@ -39,10 +41,22 @@ class CustomAppBar extends StatelessWidget {
GestureDetector( GestureDetector(
onTap: () { onTap: () {
if (!isHistory) { if (!isHistory) {
Navigator.pushReplacement(context, Navigator.pushReplacement(
MaterialPageRoute(builder: (_) => const NewHome2())); context,
MaterialPageRoute(
builder: (_) => const NewHome2(),
),
);
context.read<BranchExist>().branchExist( context.read<BranchExist>().branchExist(
branchCode, brandCode, role, cashierName, sessionId); context,
branchCode,
brandCode,
role,
cashierName,
sessionId,
getMenu: true,
token: tokenMember,
);
} else { } else {
Navigator.pop(context); Navigator.pop(context);
} }
......
...@@ -410,6 +410,7 @@ Mohon menuju kasir untuk meminta bukti pembayaran'''; ...@@ -410,6 +410,7 @@ Mohon menuju kasir untuk meminta bukti pembayaran''';
context context
.read<BranchExist>() .read<BranchExist>()
.branchExist( .branchExist(
context,
branchCode, branchCode,
brandCode, brandCode,
role, role,
...@@ -745,6 +746,7 @@ Mohon menuju kasir untuk meminta bukti pembayaran'''; ...@@ -745,6 +746,7 @@ Mohon menuju kasir untuk meminta bukti pembayaran''';
GestureDetector( GestureDetector(
onTap: () { onTap: () {
context.read<BranchExist>().branchExist( context.read<BranchExist>().branchExist(
context,
branchCode, branchCode,
brandCode, brandCode,
role, role,
...@@ -1249,8 +1251,8 @@ Mohon menuju kasir untuk meminta bukti pembayaran'''; ...@@ -1249,8 +1251,8 @@ Mohon menuju kasir untuk meminta bukti pembayaran''';
if (!widget.isHistory) { if (!widget.isHistory) {
Navigator.pushReplacement(context, Navigator.pushReplacement(context,
MaterialPageRoute(builder: (_) => const NewHome2())); MaterialPageRoute(builder: (_) => const NewHome2()));
context.read<BranchExist>().branchExist( context.read<BranchExist>().branchExist(context, branchCode,
branchCode, brandCode, role, cashierName, sessionId); brandCode, role, cashierName, sessionId);
} else { } else {
Navigator.pop(context); Navigator.pop(context);
} }
......
...@@ -16,6 +16,7 @@ import 'package:uuid/uuid.dart'; ...@@ -16,6 +16,7 @@ import 'package:uuid/uuid.dart';
import '../../api/api.dart'; import '../../api/api.dart';
import '../../bloc/branch_exist.dart'; import '../../bloc/branch_exist.dart';
import '../../bloc/feedback_option.dart'; import '../../bloc/feedback_option.dart';
import '../../bloc/filter_menu.dart';
import '../../bloc/view_bill.dart'; import '../../bloc/view_bill.dart';
import '../../bloc/voucher_list.dart'; import '../../bloc/voucher_list.dart';
import '../../helper/widget/button_dialog.dart'; import '../../helper/widget/button_dialog.dart';
...@@ -362,6 +363,7 @@ class CoreBill extends StatelessWidget { ...@@ -362,6 +363,7 @@ class CoreBill extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
bool isPromotionActive = prefs.getBool('isPromoActive') ?? false;
return BlocBuilder<MemberInfoBloc, MemberInfo>( return BlocBuilder<MemberInfoBloc, MemberInfo>(
builder: (contextMember, memberinfo) { builder: (contextMember, memberinfo) {
int outStandingTopayMember = 0; int outStandingTopayMember = 0;
...@@ -384,6 +386,7 @@ class CoreBill extends StatelessWidget { ...@@ -384,6 +386,7 @@ class CoreBill extends StatelessWidget {
), ),
Expanded( Expanded(
child: SingleChildScrollView( child: SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
...@@ -831,6 +834,24 @@ class CoreBill extends StatelessWidget { ...@@ -831,6 +834,24 @@ class CoreBill extends StatelessWidget {
width: widthScreen, width: widthScreen,
child: Column( child: Column(
children: [ children: [
(dataBill[0].isPromotionAllow == "1" &&
!isPromotionActive &&
memberinfo.id == '')
? GestureDetector(
onTap: () {
Api.addCancelPromotion(dataBill[0].id, true)
.then((value) {
if (value) {
context.read<ViewBillBloc>().getBill();
}
});
},
child: ButtonComponent(
buttonColor: buttonColor,
teksButton: 'Promo CC Mandiri',
),
)
: const SizedBox(),
GestureDetector( GestureDetector(
onTap: () { onTap: () {
if (dataBill[0].tableStatus == tableStatusOpen) { if (dataBill[0].tableStatus == tableStatusOpen) {
...@@ -1099,7 +1120,8 @@ class CoreBill extends StatelessWidget { ...@@ -1099,7 +1120,8 @@ class CoreBill extends StatelessWidget {
), ),
), ),
), ),
(dataBill[0].isFeedBack == false && (!isPromotionActive)
? (dataBill[0].isFeedBack == false &&
dataBill[0].tableStatus == tableStatusOpen) dataBill[0].tableStatus == tableStatusOpen)
? Column( ? Column(
children: [ children: [
...@@ -1112,7 +1134,8 @@ class CoreBill extends StatelessWidget { ...@@ -1112,7 +1134,8 @@ class CoreBill extends StatelessWidget {
tableStatusOpen) { tableStatusOpen) {
onTapCashier(); onTapCashier();
} else { } else {
if (dataBill[0].isFeedBack == false) { if (dataBill[0].isFeedBack ==
false) {
ratingModal( ratingModal(
context, context,
dataBill, dataBill,
...@@ -1122,12 +1145,10 @@ class CoreBill extends StatelessWidget { ...@@ -1122,12 +1145,10 @@ class CoreBill extends StatelessWidget {
} }
} }
}, },
child: ButtonComponent( child: const ButtonComponent(
buttonColor: successColor, buttonColor: successColor,
teksButton: (dataBill[0].tableStatus == teksButton:
tableStatusOpen) 'Tutup Pesanan & Minta Bill',
? 'Tutup Pesanan & Minta Bill'
: 'Beri Penilaian',
) )
// child: Container( // child: Container(
// margin: const EdgeInsets.only(top: 12), // margin: const EdgeInsets.only(top: 12),
...@@ -1150,7 +1171,31 @@ class CoreBill extends StatelessWidget { ...@@ -1150,7 +1171,31 @@ class CoreBill extends StatelessWidget {
), ),
], ],
) )
: const SizedBox(), : const SizedBox()
: Column(
children: [
const SizedBox(
height: 12,
),
GestureDetector(
onTap: () {
Api.addCancelPromotion(
dataBill[0].id,
false,
).then((value) {
if (value) {
context.read<ViewBillBloc>().getBill();
}
});
},
child: ButtonComponent(
buttonColor: cancelColorButton,
teksButton: 'Batalkan Promo CC Mandiri',
teksButtonColor: textColorBlack,
),
),
],
),
const SizedBox( const SizedBox(
height: 5, height: 5,
), ),
...@@ -1304,6 +1349,7 @@ class EmptyBill extends StatelessWidget { ...@@ -1304,6 +1349,7 @@ class EmptyBill extends StatelessWidget {
GestureDetector( GestureDetector(
onTap: () { onTap: () {
context.read<BranchExist>().branchExist( context.read<BranchExist>().branchExist(
context,
branchCode, branchCode,
brandCode, brandCode,
role, role,
...@@ -1313,7 +1359,9 @@ class EmptyBill extends StatelessWidget { ...@@ -1313,7 +1359,9 @@ class EmptyBill extends StatelessWidget {
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (_) => const NewHome2())); builder: (_) => const NewHome2(),
),
);
}, },
child: ButtonComponent( child: ButtonComponent(
buttonColor: buttonColor, buttonColor: buttonColor,
...@@ -1835,6 +1883,12 @@ class AddMoreOrder extends StatelessWidget { ...@@ -1835,6 +1883,12 @@ class AddMoreOrder extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
String branchCode = prefs.getString('outlet') ?? '';
String brandCode = prefs.getString('brand') ?? '';
String role = prefs.getString('role') ?? '';
String cashierName = prefs.getString('cashier_name') ?? '';
String sessionId = prefs.getString('sessionId') ?? '';
String tokenMember = prefs.getString('token') ?? '';
return Container( return Container(
height: 80, height: 80,
...@@ -1863,6 +1917,16 @@ class AddMoreOrder extends StatelessWidget { ...@@ -1863,6 +1917,16 @@ class AddMoreOrder extends StatelessWidget {
), ),
GestureDetector( GestureDetector(
onTap: () { onTap: () {
context.read<BranchExist>().branchExist(
context,
branchCode,
brandCode,
role,
cashierName,
sessionId,
getMenu: true,
token: tokenMember,
);
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment