package com.steering.pss.crm.server;

import CoreFS.SA06.CoreReturnObject;
import CoreFS.SA08.CoreXmlSqlParsersFactory;
import CoreFS.SC01.CoreConstantData;
import CoreFS.Util.StringUtils;
import com.steering.comm.db.DBCommon;

import java.util.ArrayList;

public class CrmSlmOrderServer extends DBCommon {

    public CoreReturnObject Query(String orderNo, String startDate, String endDate) {
        String sql = CoreXmlSqlParsersFactory.getSql("CrmSlmOrderServer.Query");
        if (!StringUtils.isEmpty(orderNo)) {
            sql += " AND T.ORDER_NO like '%" + orderNo + "%'";
        }
        if (!StringUtils.isEmpty(startDate) && !StringUtils.isEmpty(endDate)) {
            sql += " AND T.CREATE_TIME BETWEEN to_date('" + startDate + "','yyyy-MM-dd HH24:MI:SS') AND to_date('" + endDate + "','yyyy-MM-dd HH24:MI:SS')";
        }
        sql += " ORDER BY T.CREATE_TIME";
        return this.getData(sql);
    }

    public CoreReturnObject updateIsFlag(ArrayList<ArrayList<Object>> list) {
        ArrayList<String> sqllist = new ArrayList<String>();
        ArrayList<Object[]> params = new ArrayList<Object[]>();
        for (ArrayList<Object> o : list) {
            String sql = CoreXmlSqlParsersFactory
                    .getSql("CrmSlmOrderServer.updateIsFlag");
            Object[] param = o.toArray();
            sqllist.add(sql);
            params.add(param);
        }
        return this.getDao(CoreConstantData.sysbeanstr).ExcuteTransction(sqllist, params);
    }
}
