package com.steering.pss.sale.order;

import CoreFS.SA06.CoreReturnObject;
import CoreFS.SA08.CoreXmlSqlParsersFactory;

import com.steering.comm.converter.CoreConverter;
import com.steering.comm.db.DBCommon;

/**
 * 合同头控件后台
 * @author Admin
 */
public class CopyCtrlOrderHead extends DBCommon {
    /**
     * 查询合同类型
     * @param bigType 合同大类型
     * @return cro
     */
    public CoreReturnObject doQueryOrderType(String bigType) {
        Object[] obj = new Object[] { bigType };
        return this.getDataBySqlID("CopyCtrlOrderHead.ORDERTYPE", obj);
    }

    /**
     * 查询签订地点
     * @return CoreReturnObject 必须返回CoreReturnObject
     */
    public CoreReturnObject doQuerySignSite() {
        return this.getDataBySqlID("CopyCtrlOrderHead.SignSite");
    }

    /**
     * 查询制造商
     * @return CoreReturnObject 必须返回CoreReturnObject
     */
    public CoreReturnObject doQueryMakers() {
        return this.getDataBySqlID("CopyCtrlOrderHead.Makers");
    }

    /**
     * 首次受票单位
     * @return CoreReturnObject 必须返回CoreReturnObject
     */
    public CoreReturnObject doQueryFirstDraweeUint() {
        return this.getDataBySqlID("CopyCtrlOrderHead.FirstDraweeUint");
    }

    /**
     * 计量方式
     * @return CoreReturnObject 必须返回CoreReturnObject
     */
    public CoreReturnObject doQueryPricing() {
        return this.getDataBySqlID("CopyCtrlOrderHead.Pricing");
    }

    /**
     * 订单要求
     * @return CoreReturnObject 必须返回CoreReturnObject
     */
    public CoreReturnObject doQueryOrderRequire() {
        return this.getDataBySqlID("CopyCtrlOrderHead.doQueryOrderRequire");
    }

    /**
     * 币种
     * @return CoreReturnObject 必须返回CoreReturnObject
     */
    public CoreReturnObject doQueryCurrency() {
        return this.getDataBySqlID("CopyCtrlOrderHead.Currency");
    }

    /**
     * 付款方式
     * @return CoreReturnObject 必须返回CoreReturnObject
     */
    public CoreReturnObject doQueryPaymentMethod() {
        return this.getDataBySqlID("CopyCtrlOrderHead.PaymentMethod");
    }

    /**
     * 销售片区
     * @return CoreReturnObject 必须返回CoreReturnObject
     */
    public CoreReturnObject doQuerySalesArea(String orderOrg,String[] arr) {

        String sql = CoreXmlSqlParsersFactory
                .getSql("CopyCtrlOrderHead.SalesArea");
        Object[] params = new Object[] { orderOrg};
        String condition = CoreConverter.toSqlConditionString("DEPARTID",arr);
        sql += condition;
        return this.getData(sql,params);
    }
    
    /**
     * 销售片区
     * @return CoreReturnObject 必须返回CoreReturnObject
     */
    public CoreReturnObject doQuerySalesAreaNoDept(String orderOrg) {

        String sql = CoreXmlSqlParsersFactory
                .getSql("CopyCtrlOrderHead.SalesArea");
        Object[] params = new Object[] { orderOrg};
        return this.getData(sql,params);
    }

    /**
     * 查询贸易类型
     * @param saleOrg
     * @return
     */
    public CoreReturnObject queryTradeType(String saleOrg) {
        String sql = "";
        if (saleOrg.equals("100102")) { // 国贸 1224
            sql = "SELECT BASENAME,BASECODE FROM COM_BASE_INFO WHERE SORTCODE = '1224' AND VALIDFLAG = '1'";
        }
        else {
            sql = "SELECT BASENAME,BASECODE FROM COM_BASE_INFO WHERE SORTCODE = '1223' AND VALIDFLAG = '1'";
        }
        return this.getData(sql);
    }

    /**
     * 加载合同分类
     * @return
     */
    public CoreReturnObject queryOrderClassify() {
        String sql = "SELECT BASENAME,BASECODE FROM COM_BASE_INFO WHERE SORTCODE = '1225' AND VALIDFLAG = '1'";
        return this.getData(sql);
    }
}
