orderlistcomplete
This commit is contained in:
@@ -185,8 +185,6 @@ class AddtocartProvider extends ChangeNotifier {
|
||||
"remarks": remarks
|
||||
};
|
||||
|
||||
|
||||
|
||||
try {
|
||||
var result = await _homeRepo.paymentOrder(data);
|
||||
return result.fold(
|
||||
@@ -211,7 +209,81 @@ class AddtocartProvider extends ChangeNotifier {
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
ispaymentLoader = false;
|
||||
ispaymentLoader = false;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////COD ////////////
|
||||
|
||||
Future<void> paymentCODOrder(
|
||||
BuildContext context,
|
||||
double subtotal,
|
||||
String deliverCharge,
|
||||
double discountPrice,
|
||||
String grandTotal,
|
||||
String couponId,
|
||||
String addressId,
|
||||
) async {
|
||||
ispaymentLoader = true;
|
||||
notifyListeners();
|
||||
var data;
|
||||
if (couponId.isNotEmpty)
|
||||
{
|
||||
data = {
|
||||
{
|
||||
"addressId": addressId,
|
||||
"paymentMethod": "COD",
|
||||
"paymentStatus": "PENDING",
|
||||
"orderStatus": "PENDING",
|
||||
"subtotal": subtotal,
|
||||
"deliveryCharge": deliverCharge,
|
||||
"discount": discountPrice,
|
||||
"grandTotal": grandTotal,
|
||||
"couponId": couponId
|
||||
}
|
||||
};
|
||||
}
|
||||
else {
|
||||
data = {
|
||||
{
|
||||
"addressId": addressId,
|
||||
"paymentMethod": "COD",
|
||||
"paymentStatus": "PENDING",
|
||||
"orderStatus": "PENDING",
|
||||
"subtotal": subtotal,
|
||||
"deliveryCharge": deliverCharge,
|
||||
"discount": discountPrice,
|
||||
"grandTotal": grandTotal,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
var result = await _homeRepo.paymentCODOrder(data);
|
||||
return result.fold(
|
||||
(error) {
|
||||
ispaymentLoader = false;
|
||||
notifyListeners();
|
||||
},
|
||||
(response) {
|
||||
if (response.data!.instrumentResponse!.redirectInfo != null &&
|
||||
response.data!.instrumentResponse!.redirectInfo != '') {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => PaymentWebView(
|
||||
paymentUrl:
|
||||
response.data!.instrumentResponse!.redirectInfo!.url),
|
||||
),
|
||||
);
|
||||
}
|
||||
ispaymentLoader = false;
|
||||
notifyListeners();
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
ispaymentLoader = false;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
38
lib/src/logic/provider/order_provider.dart
Normal file
38
lib/src/logic/provider/order_provider.dart
Normal file
@@ -0,0 +1,38 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:grocery_app/src/core/network_services/service_locator.dart';
|
||||
import 'package:grocery_app/src/data/myOrder.dart';
|
||||
import 'package:grocery_app/src/logic/repo/order_repo.dart';
|
||||
|
||||
class OrderProvider extends ChangeNotifier {
|
||||
final _orderRepo = getIt<OrderRepo>();
|
||||
|
||||
List<Datum> orderList = [];
|
||||
bool isloading = true;
|
||||
|
||||
Future<void> getMyOrder(BuildContext context) async {
|
||||
var data = {};
|
||||
try {
|
||||
var result = await _orderRepo.myOrder(data);
|
||||
|
||||
return result.fold(
|
||||
(error) {
|
||||
isloading = false;
|
||||
|
||||
notifyListeners();
|
||||
},
|
||||
(response) {
|
||||
orderList = response.data!;
|
||||
|
||||
|
||||
isloading = false;
|
||||
notifyListeners();
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
print("sfddsfdfff $e");
|
||||
|
||||
isloading = false;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
}
|
||||
26
lib/src/logic/repo/order_repo.dart
Normal file
26
lib/src/logic/repo/order_repo.dart
Normal file
@@ -0,0 +1,26 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
import 'package:grocery_app/src/core/utils/custom_dio_exception.dart';
|
||||
import 'package:grocery_app/src/core/utils/response_type_def.dart';
|
||||
import 'package:grocery_app/src/data/myOrder.dart';
|
||||
import 'package:grocery_app/src/data/order_paymnet.dart';
|
||||
import 'package:grocery_app/src/logic/services/orderSirvice.dart';
|
||||
|
||||
class OrderRepo {
|
||||
final OrderService _orderService;
|
||||
OrderRepo(this._orderService);
|
||||
|
||||
FutureResult<MyOrder> myOrder(data) async {
|
||||
try {
|
||||
var response = await _orderService.myOrder(data);
|
||||
|
||||
MyOrder productCategory = myOrderFromJson(response.toString());
|
||||
print("ldkjglfdhglkj ${productCategory}");
|
||||
|
||||
return right(productCategory);
|
||||
} on DioException catch (e) {
|
||||
var error = CustomDioExceptions.handleError(e);
|
||||
return left(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -114,6 +114,28 @@ class ProductRepo {
|
||||
}
|
||||
}
|
||||
|
||||
FutureResult<OrderPaymnet> paymentCODOrder(data) async {
|
||||
try {
|
||||
var response = await _productService.paymentCODOrder(data);
|
||||
print("kjdfglkjfdgjklfgkldj${data} ${response} ");
|
||||
|
||||
OrderPaymnet productCategory = orderPaymnetFromJson(response.toString());
|
||||
|
||||
print("lkjdflkjfhgdkhfgkd ");
|
||||
// final String model = response.toString();
|
||||
|
||||
return right(productCategory);
|
||||
} on DioException catch (e) {
|
||||
var error = CustomDioExceptions.handleError(e);
|
||||
return left(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
FutureResult<List<Product>> similarProduct(
|
||||
data, BuildContext context, id) async {
|
||||
try {
|
||||
|
||||
@@ -61,6 +61,15 @@ class ProductService extends ApiService {
|
||||
return response;
|
||||
}
|
||||
|
||||
Future paymentCODOrder(data) async {
|
||||
print("kdjfgkjjkdfgkjdkfgjkdfgj ${data}");
|
||||
var response =
|
||||
await api.post(APIURL.paymentCODOrder, data: jsonEncode(data));
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
Future similarProduct(data, id) async {
|
||||
var response = await api.get(APIURL.similarProduct + id + "/similar",
|
||||
data: jsonEncode(data));
|
||||
|
||||
16
lib/src/logic/services/orderSirvice.dart
Normal file
16
lib/src/logic/services/orderSirvice.dart
Normal file
@@ -0,0 +1,16 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:grocery_app/src/core/constant/api.dart';
|
||||
import 'package:grocery_app/src/core/network_services/api_services.dart';
|
||||
|
||||
class OrderService extends ApiService
|
||||
{
|
||||
|
||||
|
||||
Future myOrder(data) async {
|
||||
var response = await api.get(APIURL.myOrder, data: jsonEncode(data));
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
// import 'dart:convert';
|
||||
// import 'dart:io';
|
||||
|
||||
// import 'package:dio/dio.dart';
|
||||
// import 'package:vendor_app/src/core/constant/api.dart';
|
||||
// import 'package:vendor_app/src/core/network_services/api_services.dart';
|
||||
|
||||
// class ProductService extends ApiService {
|
||||
// // Future createStore(data) async
|
||||
// // {
|
||||
// // var response = await api.get(APIURL.createStore, data: jsonEncode(data));
|
||||
// // return response;
|
||||
// // }
|
||||
|
||||
// Future getProduct(data) async {
|
||||
// var response = await api.get(APIURL.getProduct, data: jsonEncode(data));
|
||||
// return response;
|
||||
// }
|
||||
|
||||
// Future createProduct(data) async {
|
||||
// var response = await api.post(APIURL.getProduct, data: jsonEncode(data));
|
||||
// return response;
|
||||
// }
|
||||
|
||||
// Future deleteProduct(data, id) async {
|
||||
// var response =
|
||||
// await api.delete(APIURL.deleteProduct + id, data: jsonEncode(data));
|
||||
// return response;
|
||||
// }
|
||||
|
||||
// Future updateProduct(data, id) async {
|
||||
// var response =
|
||||
// await api.patch(APIURL.updateProduct + id, data: jsonEncode(data));
|
||||
// return response;
|
||||
// }
|
||||
|
||||
// Future getCategoryByLevel(data) async {
|
||||
// var response =
|
||||
// await api.get(APIURL.getCategoryByLevel, data: jsonEncode(data));
|
||||
// return response;
|
||||
// }
|
||||
|
||||
// // Future uploadImage(data) async
|
||||
// // {
|
||||
// // var response = await api.post(APIURL.uploadImage, data: jsonEncode(data));
|
||||
// // return response;
|
||||
// // }
|
||||
|
||||
// Future<Response> uploadImage(File imageFile,
|
||||
// {Map<String, dynamic>? additionalFields}) async {
|
||||
// const String url = APIURL.uploadImage;
|
||||
// return await api.uploadImage(
|
||||
// url,
|
||||
// imageFile,
|
||||
// additionalFields: additionalFields,
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
Reference in New Issue
Block a user