package com.cnd3b.restcontroller.enterprise.webclient.workers;

import com.cnd3b.common.Controller;
import com.cnd3b.common.data.Rows;
import com.cnd3b.common.data.SQLFactory;

import com.alibaba.fastjson.JSONObject;
public class submitedit extends Controller {

    public submitedit(JSONObject content) {
        super(content);
    }

    /**
     * 合伙人提报列表
     *
     * @return
     */
    public String query_submiteditList() {
        /**
         *排序条件设置
         */
        String[] sortfield = {"t1.createdate"};
        String sort = getSort(sortfield, "t1.createdate desc");

        StringBuffer where = new StringBuffer(" 1=1 ");
        if (content.containsKey("where")) {
            JSONObject whereObject = content.getJSONObject("where");
            if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
                where.append(" and(");
                where.append("t1.fname like'%").append(whereObject.getString("condition")).append("%' ");
                where.append("or t2.fname like'%").append(whereObject.getString("condition")).append("%' ");
                where.append("or t1.fphonenumber like'%").append(whereObject.getString("condition")).append("%' ");
                where.append("or t1.fcommunity like'%").append(whereObject.getString("condition")).append("%' ");
                where.append("or t3.fagentname like'%").append(whereObject.getString("condition")).append("%' ");
                where.append("or t3.fagentshortname like'%").append(whereObject.getString("condition")).append("%' ");
                where.append("or t4.fname like'%").append(whereObject.getString("condition")).append("%' ");
                where.append(")");
            }
            if (whereObject.containsKey("fiscooperation") && !"".equals(whereObject.getString("fiscooperation"))) {
                where.append(" and t2.fiscooperation ='").append(whereObject.getString("fiscooperation")).append("' ");
            }
        }
        SQLFactory queryworker = new SQLFactory(this, "合伙人提报列表查询", pageSize, pageNumber, sort);
        queryworker.addParameter("siteid", siteid);
        queryworker.addParameter_SQL("where", where);
        Rows workerrows = dbConnect.runSqlQuery(queryworker.getSQL());

        return getSucReturnObject().setDataByPaging(workerrows).saveToDataPool().preloading(1).toString();
    }
}
