package cn.hmsoft.pay.data.dao;

import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

import cn.hmsoft.jdbc.core.PlatformDaoSupport;
import cn.hmsoft.jdbc.entity.Pager;
import cn.hmsoft.jdbc.entity.QueryOrder;
import cn.hmsoft.pay.data.model.PayMerchantDefine;

@Component
public class PayMerchantDefineDao extends PlatformDaoSupport<PayMerchantDefine> {

	public Pager pageMerchant(Integer start, Integer limit, String query, QueryOrder order) {
		final StringBuilder sql = new StringBuilder();
		sql.append("select * from pay_merchant_define");
		if (StringUtils.isEmpty(query)) {
			return this.pageMapBySql(order, start, limit, sql.toString());
		}
		sql.append(" where (merchant_id like ? merchant_name like ?)");
		String value = this.generateLikeParamter(query);
		return super.pageMapBySql(order, start, limit, sql.toString(), value, value);
	}

	

	public void deleteMerchantChannel(String merchant_id, String channel_id) {
		String sql = "delete from pay_merchant_channel where merchant_id=? and channel_id=?";
		this.updateBySql(sql, merchant_id, channel_id);
	}
}
