const mongoose = require("mongoose");
const Order = mongoose.model("Orders");
const User = mongoose.model("User");
const WareHouse = mongoose.model("WareHouses");
const supplierCode = mongoose.model("SupplierCode");
const bcrypt = require("bcryptjs");
const BillHistory = mongoose.model("BillHistorys");
const Adminuser = mongoose.model("Adminuser");
const Products = mongoose.model("Products");
const Category = mongoose.model("Category");
const CsvUpload = mongoose.model("CsvUpload");
const Transaction = mongoose.model("Transaction");
const BrowseNodes = mongoose.model("BrowseNodes");
const Orderprioritys = mongoose.model("Orderprioritys");
const CategoryDesc = mongoose.model("CategoryDesc");
const ObjectsToCsv = require("objects-to-csv");
const moment = require("moment-timezone");
const { mongooseConstantValues } = require("../../apps/common/systemConstents");

const {
  updateShopperrPriceAlgo,
  getMsrp,
} = require("../../apps/middlewares/priceAlgo");
const { userValidation } = require("../../validation");

const AWS = require("aws-sdk");
const _ = require("lodash");
var fs = require("fs");
const { Parser } = require("json2csv");

const csv = require("csvtojson");
// const ID = "AKIAVQ3EX433FYE7SGHW";
// const SECRET = "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";
const ID = "AKIAZQ3DPSAOW34EMAWP";
const SECRET = "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";
// const ID = process.env.AWS_ACCESS_KEY_ID;
// const SECRET = process.env.AWS_SECRET_ACCESS_KEY;

const BUCKET_NAME = "test-bucket";
const s3 = new AWS.S3({
  accessKeyId: ID,
  secretAccessKey: SECRET,
  apiVersion: "latest",
});
exports.markProcess = async (req, res) => {
	
  //console.log(req.params.processto);
  let msgmark="";
  if(req.params.processto == 0)
  {
	  msgmark = 'India';
  } else {
	msgmark = 'China';
  }
	  upObj = {
		  chinaProcess: req.params.processto
		};
	  Order.updateOne(
	  { _id: mongoose.Types.ObjectId(req.params.orderid) },
	  { $set: upObj },
	  { upsert: false }
	)
	  .exec()
	  .then((ress) => {
		return res.send({ status: 1, response: `Order mark to ${msgmark} Successfully` });
	  });
};
