const system=require("../../system");
const Dao=require("../dao.base");
class CalculatepriceDao extends Dao{
  constructor(){
    super(Dao.getModelName(CalculatepriceDao));
  }
  extraWhere(obj,w){
    console.log("extraWhereQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ");
    console.log(obj.codepath);
     if(obj.codepath && obj.codepath!=""){
       if(obj.codepath.indexOf("calculateprice")>0){
          w["user_id"]=obj.uid;
       }
       if(obj.codepath.indexOf("freesubmit")>=0){
          w["user_id"]=obj.uid;
       }
       if(obj.codepath.indexOf("order")>0){
         w["user_id"]=obj.uid;
         w["status"]="1";
       }
       if(obj.codepath.indexOf("order")>0 && obj.codepath.indexOf("allcalctm")>0){
         w["status"]="1";
       }
     }
     return w;
  }

  async findByIds(ids){
    var qc={
        'where': { 'id': {[this.db.Op.in]: ids}}
    };
    var apps=  await this.model.findAndCountAll(qc);
    return apps;
  }
  async findByCodes(codes){
    var qc={
        'where': { 'code': {[this.db.Op.in]: codes}}
    };
    var apps=  await this.model.findAndCountAll(qc);
    return apps;
  }
  async findOneByCode(code){
    return this.model.findOne({"where":{"code":code}});
  }
  async findByOrderNum(orderNum){
    var qc={
        'where': { 'orderNum': orderNum}
    };
    var apps= await this.model.findAndCountAll(qc);
    return apps;
  }
}
module.exports=CalculatepriceDao;
