package com.cnd3b.restcontroller.enterprise.salerclient.mainpage.action.agentcheck;

import com.alibaba.fastjson.JSONArray;
import com.cnd3b.common.Controller;
import com.cnd3b.common.data.Rows;
import com.cnd3b.common.data.RowsMap;
import com.cnd3b.common.data.SQLFactory;
import com.alibaba.fastjson.JSONObject;

public class agentcheck extends Controller {
    public agentcheck(JSONObject content) {
        super(content);
    }

    public String query_agentlastinputdays() {
        SQLFactory sqlFactory = new SQLFactory(this, "经销商未录入天数查询");
        sqlFactory.addParameter("siteid", siteid);

        sqlFactory.addParameter_in("fsaleruserid", getSubUsers());
        Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
        RowsMap rowsmap = rows.toRowsMap("fsalername");
        JSONArray array = new JSONArray();
        for (String fsalername : rowsmap.keySet()) {
            JSONObject object = new JSONObject();
            object.put("fsalername", fsalername);
            object.put("agents", rowsmap.get(fsalername));
            array.add(object);
        }
        return getSucReturnObject().setData(array).saveToDataPool().toString();
    }
}
