Commit be178cf2 authored by Dio Maulana's avatar Dio Maulana

add promo cc mandiri

parent 28c996e2
...@@ -291,16 +291,19 @@ class Api { ...@@ -291,16 +291,19 @@ class Api {
// } // }
static Future<List<FilterMenu>> getMenuAndFilterMenu( static Future<List<FilterMenu>> getMenuAndFilterMenu(
String branchCode, String branchCode,
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,30 +22,32 @@ class Bill { ...@@ -22,30 +22,32 @@ 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,
required this.customerName, required this.customerName,
required this.tableStatus, required this.tableStatus,
required this.orderStatus, required this.orderStatus,
required this.outStandingPay, required this.outStandingPay,
required this.outStandingIndividu, required this.outStandingIndividu,
required this.dateOrder, required this.dateOrder,
this.billDetail = const [], this.billDetail = const [],
this.paymentList = const [], this.paymentList = const [],
required this.invoice, required this.invoice,
required this.totalService, required this.totalService,
required this.totalServiceTax, required this.totalServiceTax,
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.memberInfo = const [] this.isPromotionAllow = "0",
}); // this.memberInfo = const []
});
factory Bill.createBill(Map<String, dynamic> json) { factory Bill.createBill(Map<String, dynamic> json) {
return Bill( return Bill(
...@@ -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);
} }
......
This diff is collapsed.
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