const Dao = require("../../dao.base");

class MerchantaccountDao extends Dao {
    constructor() {
        super(Dao.getModelName(MerchantaccountDao));
    }

    async addtomerchantrmb(params) {
        var sql = [];
        sql.push("UPDATE");
        sql.push(this.model.tableName);
        sql.push("SET balance_amount = balance_amount + :amount,");
        sql.push("available_amount = available_amount + :amount");
        sql.push("WHERE merchant_id = :merchant_id");
        return await this.customUpdate(sql.join(" "), params);
    }

    async addordelmerchantrmb(params) {
        var sql = [];
        sql.push("UPDATE");
        sql.push(this.model.tableName);
        sql.push("SET balance_amount = balance_amount - :amount");
        sql.push("WHERE merchant_id = :merchant_id");
        return await this.customUpdate(sql.join(" "), params);
    }

    async addordelavailable(params) {
        var sql = [];
        sql.push("UPDATE");
        sql.push(this.model.tableName);
        sql.push("SET available_amount = available_amount + :amount");
        sql.push("WHERE merchant_id = :merchant_id");
        return await this.customUpdate(sql.join(" "), params);
    }
}

module.exports = MerchantaccountDao;
