diff --git a/index.html b/index.html index 7d989bd..9fa6e50 100644 --- a/index.html +++ b/index.html @@ -803,7 +803,7 @@ //for cloud apps subAdmins: [], - application: "eCommerce", + application: "eCommerce_test1", vectorClock: {}, appObjects: {}, generalData: {}, @@ -972,7 +972,8 @@
Product Image:
`; t += `Product Selling Price:
`; t += `Product Location:
`; - t += `Items Available :
`; t += `On Sale:
`; t += `UPI Txid: ${bo.payment_to_vendor_txid} Item: ${product_dynamic_info.product_name}: ${bo.buy_order_data.quantity[product_dynamic_info.product_name]} Item: ${product_dynamic_info.product_name}: ${bo.buy_order_data.quantity[product_static_info.product_flo_id]} Total Price: ${bo.buy_order_data.final_price}
`;
@@ -10975,32 +10983,27 @@ Bitcoin.Util = {
const product_details = latest_buy_orders[0].buy_order_data.shopping_list[0].product_info;
const buyer = latest_buy_orders[0].buy_order_data.buyer_flo_id;
let product = product_details.product_dynamic_information.product;
+ let expected_delivery = + new Date() + 24*60*60*1000;
+ let vendor_txid = latest_buy_orders[0].payment_to_vendor_txid;
+ let commodity = ``;
+ let seller_sig = ``;
+ let signed_item = ``;
+ let item_sent = ``;
+ let item_info = ``;
+
if(product_details.product_static_information.product_type==="DIGITAL") {
switch (product) {
case "MOVIE_TICKETS":
- let ticket = `
+ let item_info = `
Buy_Txid: ${buy_txid}
Buyer Id: ${buyer}
Movie: ${product_details.product_dynamic_information.product_name}
- Movie DateTime: ${product_details.product_dynamic_information.movie_datetime}
- `;
-
- let seller_sig = floCrypto.signData(ticket, myPrivKey)
-
- let signed_ticket = ticket+' VendorSignature: '+seller_sig;
-
- let ticket_sent = await floCloudAPI.sendGeneralData(signed_ticket, ecommerce.master_configurations.DATA_TYPE.PURCHASED_ITEMS,
- { receiverID: buyer });
-
- console.log(ticket_sent);
- if(typeof ticket_sent == "object") {
- // add buy_txid to personal records
- // floCloudAPI.sendGeneralData(signed_ticket, ecommerce.master_configurations.DATA_TYPE.PROCESSED_PURCHASED_ITEMS,
- // { receiverID: myFloID });
- }
+ DateTime: ${product_details.product_dynamic_information.movie_datetime}
+ Cashier_To_Seller_TXID: ${vendor_txid}
+ `;
break;
@@ -11010,35 +11013,52 @@ Bitcoin.Util = {
} else if(product_details.product_static_information.product_type==="PHYSICAL") {
+ let delivery_datetime = prompt('Enter expected delivery time: ', expected_delivery);
+
switch (product) {
case "Milko":
- let commodity = `
+ item_info = `
Buy_Txid: ${buy_txid}
Buyer Id: ${buyer}
Product: ${product_details.product_dynamic_information.product_name}
- Movie DateTime: ${product_details.product_dynamic_information.movie_datetime}
+ DateTime: ${product_details.product_dynamic_information.datetime}
+ Expected Delivery: ${delivery_datetime}
+ Cashier_To_Seller_TXID: ${vendor_txid}
`;
- let seller_sig = floCrypto.signData(ticket, myPrivKey)
-
- let signed_ticket = ticket+' VendorSignature: '+seller_sig;
-
- let ticket_sent = await floCloudAPI.sendGeneralData(signed_ticket, ecommerce.master_configurations.DATA_TYPE.PURCHASED_ITEMS,
- { receiverID: buyer });
-
- console.log(ticket_sent);
- if(typeof ticket_sent == "object") {
- // add buy_txid to personal records
- // floCloudAPI.sendGeneralData(signed_ticket, ecommerce.master_configurations.DATA_TYPE.PROCESSED_PURCHASED_ITEMS,
- // { receiverID: myFloID });
- }
break;
-
+
+ case "Pencil":
+ item_info = `
+ Buy_Txid: ${buy_txid}
+ Buyer Id: ${buyer}
+ Product: ${product_details.product_dynamic_information.product_name}
+ DateTime: ${product_details.product_dynamic_information.datetime}
+ Expected Delivery: ${delivery_datetime}
+ Cashier_To_Seller_TXID: ${vendor_txid}
+ `;
+
+ break;
+
default:
break;
+
}
}
+
+ seller_sig = floCrypto.signData(item_info, myPrivKey)
+ signed_item = item_info+' VendorSignature: '+seller_sig;
+
+ // Inform buyer
+ floCloudAPI.sendGeneralData(signed_item, ecommerce.master_configurations.DATA_TYPE.PURCHASED_ITEMS,
+ { receiverID: buyer });
+
+ // Keep a record
+ floCloudAPI.sendGeneralData(latest_buy_orders, ecommerce.master_configurations.DATA_TYPE.PROCESSED_PURCHASED_ITEMS,
+ { receiverID: myFloID });
+
+ showMessage('Item successfully processed (by Seller).');
} catch (error) {
throw new Error(error)
@@ -11080,6 +11100,11 @@ Bitcoin.Util = {
_id);
this.preview_shopping_bill();
+
+
+ // let pay_using_wallet = confirm('Do you want to pay using rupee token?');
+ // console.log(pay_using_wallet);
+ // this.checkout(pay_using_wallet);
} catch (error) {
throw new Error(error)
@@ -11221,6 +11246,7 @@ Bitcoin.Util = {
} catch (error) {
showMessage('Failed to preview shopping list', 'ERROR');
+ this.reset_bucket_list();
throw new Error(error);
}
},
@@ -11277,8 +11303,6 @@ Bitcoin.Util = {
}
console.log(buy_order_object);
- return;
-
if(pay_using_wallet===true) {
const flo_comment = `transfer ${this.final_price} rupee#`;
@@ -11401,8 +11425,7 @@ Bitcoin.Util = {
try {
const myProducts = ecommerce.approved_products_list;
const mySellingProducts = myProducts.filter(f=>
- (f.product_info.product_dynamic_information.onSale===true
- && f.product_info.product_dynamic_information.items_available>0));
+ (f.product_info.product_dynamic_information.onSale===true));
console.table(mySellingProducts);
let t = ``;
for (const product of mySellingProducts) {
@@ -11444,10 +11467,9 @@ Bitcoin.Util = {
},
display_purchased_items: function() {
try {
- const my_purchased_items = floGlobals.generalData[JSON.stringify(
- { application: floGlobals.application,
- type: ecommerce.master_configurations.DATA_TYPE.PURCHASED_ITEMS
- })];
+ const my_purchased_items = floDapps.getNextGeneralData(ecommerce.master_configurations.DATA_TYPE.PURCHASED_ITEMS, "0");
+
+ my_purchased_items.reverse();
const myPurchasedItemsList = document.getElementById('myPurchasedItemsList')
@@ -11476,24 +11498,23 @@ Bitcoin.Util = {
// Start ecommerce in a new city
create_new_city_ecommerce: function() {
- if(typeof ecommerce.master_configurations.SUBJECT!=="string" || ecommerce.master_configurations.SUBJECT.length<2) {
+ if(typeof floGlobals.application!=="string" || floGlobals.application.length<2) {
showMessage('Error: Please provide a subject in master configuration.', 'error');
return false;
}
const flo_ecommerce = {};
- flo_ecommerce[ecommerce.master_configurations.SUBJECT] = {};
// Master configurations should come from here
- flo_ecommerce[ecommerce.master_configurations.SUBJECT].master_configurations = '';
+ flo_ecommerce.master_configurations = '';
- flo_ecommerce[ecommerce.master_configurations.SUBJECT].Orders = {};
- flo_ecommerce[ecommerce.master_configurations.SUBJECT].Orders.buy_orders = {};
+ flo_ecommerce.Orders = {};
+ flo_ecommerce.Orders.buy_orders = {};
// Every approved product is for sale
//flo_ecommerce[cityname].Orders.sell_orders = {};
- flo_ecommerce[ecommerce.master_configurations.SUBJECT].Products = {};
+ flo_ecommerce.Products = {};
// Messages should be in general object
// flo_ecommerce[cityname].Messages = {};
@@ -11502,17 +11523,17 @@ Bitcoin.Util = {
// flo_ecommerce[cityname].Messages["cashier_messages"] = {}
// flo_ecommerce[cityname].Messages["delivery_messages"] = {}
// flo_ecommerce[cityname].Messages["manager_messages"] = {}
- floGlobals.appObjects[ecommerce.master_configurations.SUBJECT] = flo_ecommerce;
+ floGlobals.appObjects[floGlobals.application] = flo_ecommerce;
- floCloudAPI.resetObjectData(ecommerce.master_configurations.SUBJECT);
+ floCloudAPI.resetObjectData(floGlobals.application);
},
// Load ecommerce data relevent to an admin
get_general_data: async function() {
await floCloudAPI.requestGeneralData(ecommerce.master_configurations.DATA_TYPE.SELLING_PRODUCTS,
{ senderIDs:Object.keys(ecommerce.master_configurations.sellers_list) })
- const new_generalData = floGlobals.generalData[JSON.stringify({ application: floGlobals.application, type: ecommerce.master_configurations.DATA_TYPE.SELLING_PRODUCTS })];
-
+ const new_generalData = floDapps.getNextGeneralData(
+ ecommerce.master_configurations.DATA_TYPE.SELLING_PRODUCTS, "0");
for (const new_data of new_generalData) {
if(!Object.keys(ecommerce.master_configurations.sellers_list).includes(new_data.sender)) continue;
@@ -11554,7 +11575,6 @@ Bitcoin.Util = {
for (const elem in ui_data) {
if (ui_data.hasOwnProperty(elem)) {
if(0) t += ``;
-
t += `