const system=require("../../system");
const ServiceBase=require("../sve.base");
var settings=require("../../../config/settings");
class OfflinecompanyService extends ServiceBase{
    constructor(){
        super(ServiceBase.getDaoName(OfflinecompanyService));
    }

    async updateCreate(params){
        params.company_name =params.merchant_name;
        var offlinecompany = await this.dao.findOne({company_name : params.merchant_name});
        if(offlinecompany){
            offlinecompany.contact_man = params.contact_man;
            offlinecompany.contact_mobile = params.contact_mobile;
            offlinecompany.contact_email = params.contact_email;
            offlinecompany.contact_addr = params.contact_addr;
            var updates = await offlinecompany.save();
            if(updates.id > 0){
                return updates;
            }
            return -1;
        }
       var saves = await this.dao.create(params);
       if(saves.id > 0){
            return saves;
       }
        return -1;
    }


    async suggest(name) {
        return await this.dao.suggest(name);
    }
}
module.exports=OfflinecompanyService;
