Browse Source

Update admin order uploading.

Lee Morgan 5 năm trước cách đây
mục cha
commit
65b7d1d616
1 tập tin đã thay đổi với 4 bổ sung2 xóa
  1. 4 2
      controllers/admin.js

+ 4 - 2
controllers/admin.js

@@ -6,6 +6,7 @@ const Transaction = require("../models/transaction.js");
 const helper = require("./helper.js");
 
 const fs = require("fs");
+const ObjectId = require("mongoose").Types.ObjectId;
 
 module.exports = {
     /*
@@ -122,6 +123,7 @@ module.exports = {
                 //Orders
                 let newOrders = [];
                 if(req.files.orders !== undefined){
+                    Order.deleteMany({merchant: req.body.id}).catch((err)=>{});
                     let orderData = fs.readFileSync(req.files.orders.tempFilePath).toString();
                     fs.unlink(req.files.orders.tempFilePath, ()=>{});
                     orderData = orderData.split("\n");
@@ -134,8 +136,8 @@ module.exports = {
                             merchant: merchant._id,
                             name: data[0],
                             date: new Date(data[1]),
-                            taxes: parseFloat(data[2]),
-                            fees: parseFloat(data[3]),
+                            taxes: parseInt(parseFloat(data[2]) * 100),
+                            fees: parseInt(parseFloat(data[3]) * 100),
                             ingredients: []
                         });