|
|
@@ -6,15 +6,15 @@ import com.cnd3b.common.Controller;
|
|
|
import com.cnd3b.common.D3bException;
|
|
|
import com.cnd3b.common.data.Row;
|
|
|
import com.cnd3b.common.data.Rows;
|
|
|
+import com.cnd3b.common.data.RowsMap;
|
|
|
import com.cnd3b.common.data.SQLFactory;
|
|
|
import com.cnd3b.common.data.db.DataPool;
|
|
|
-import org.omg.CORBA.OBJ_ADAPTER;
|
|
|
+import p2.common.parse.J;
|
|
|
import p2.pao.PaoRemote;
|
|
|
import p2.pao.PaoSetRemote;
|
|
|
import p2.util.P2Exception;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
import java.util.Iterator;
|
|
|
|
|
|
public class tagents extends Controller {
|
|
|
@@ -22,24 +22,45 @@ public class tagents extends Controller {
|
|
|
super(content);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
- * 数据统计
|
|
|
+ * 个人商户列表查询
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- public String query_analysis() {
|
|
|
- SQLFactory sqlFactory = new SQLFactory(this, "经销商账号激活统计");
|
|
|
- sqlFactory.addParameter("siteid", siteid);
|
|
|
- Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
|
|
|
- return getSucReturnObject().setData(rows).saveToDataPool().toString();
|
|
|
+ public String query_singleagentsList() {
|
|
|
+ /**
|
|
|
+ * 过滤条件设置
|
|
|
+ */
|
|
|
+ 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("t2.fname like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t2.fphonenumber like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ SQLFactory singleagentSql = new SQLFactory(this, "个人商户列表查询", pageSize, pageNumber, "t1.tagentsid");
|
|
|
+ singleagentSql.addParameter("siteid", siteid);
|
|
|
+ singleagentSql.addParameter_SQL("where", where);
|
|
|
+ Rows rows = dbConnect.runSqlQuery(singleagentSql.getSQL());
|
|
|
+
|
|
|
+ ArrayList<String> tagentsidlist = dbConnect.runSqlQuery("select tagentsid from tagents_msgchangeapp where ftype='商户认证' and fstatus='申请'").toArrayList("tagentsid");
|
|
|
+ for (Row row : rows) {
|
|
|
+ String tagentsid = row.getString("tagentsid");
|
|
|
+ row.put("fstatus", tagentsidlist.contains(tagentsid) ? "认证中" : "未认证");
|
|
|
+ }
|
|
|
+ return getSucReturnObject().setDataByPaging(rows).setFinalDo(DataPool.defaultdatalife, 1);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 企业档案经销商列表查询
|
|
|
+ * 商户列表查询
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- public String query_enterpriseAgentsList() {
|
|
|
+ public String query_agentsList() {
|
|
|
/**
|
|
|
* 过滤条件设置
|
|
|
*/
|
|
|
@@ -48,53 +69,69 @@ public class tagents extends Controller {
|
|
|
JSONObject whereObject = content.getJSONObject("where");
|
|
|
if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
|
|
|
where.append(" and(");
|
|
|
- where.append("t1.fagentshortname like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
- where.append("or t1.fagentname like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("t1.fagentname like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
where.append("or t1.fphonenumber like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
where.append("or t1.fcontact like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
- where.append("or t1.ftype like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t1.fbrand like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
where.append(")");
|
|
|
}
|
|
|
- if (whereObject.containsKey("faccountstatus")) {
|
|
|
- if ("已付费".equals(whereObject.getString("faccountstatus"))) {
|
|
|
- where.append("and(t4.fenddate >= GETDATE())");
|
|
|
- } else if ("未付费".equals(whereObject.getString("faccountstatus"))) {
|
|
|
- where.append("and(t4.createdate IS null or t4.fenddate < GETDATE())");
|
|
|
- }
|
|
|
- }
|
|
|
- if (whereObject.containsKey("fsaler") && !"".equals(whereObject.getString("fsaler"))) {
|
|
|
- where.append("and(t2.fname='").append(whereObject.getString("fsaler")).append("')");
|
|
|
- }
|
|
|
- if (whereObject.containsKey("ftype") && !"".equals(whereObject.getString("ftype"))) {
|
|
|
- where.append(" and(");
|
|
|
- where.append("t1.ftype like'%").append(whereObject.getString("ftype")).append("%' ");
|
|
|
- where.append(")");
|
|
|
+ }
|
|
|
+ SQLFactory agentsql = new SQLFactory(this, "认证商户列表查询", pageSize, pageNumber, "t1.tagentsid");
|
|
|
+ agentsql.addParameter("siteid", siteid);
|
|
|
+ agentsql.addParameter_SQL("where", where);
|
|
|
+ Rows rows = dbConnect.runSqlQuery(agentsql.getSQL());
|
|
|
+
|
|
|
+ SQLFactory agentchecksql = new SQLFactory(this, "商户认证时间查询");
|
|
|
+ agentchecksql.addParameter("siteid", siteid);
|
|
|
+ agentchecksql.addParameter_in("tagentsid", rows.toArrayList("tagentsid"));
|
|
|
+ RowsMap agentcheckrowsMap = dbConnect.runSqlQuery(agentchecksql.getSQL()).toRowsMap("tagentsid");
|
|
|
+
|
|
|
+ for (Row row : rows) {
|
|
|
+ String tagentsid = row.getString("tagentsid");
|
|
|
+ if (agentcheckrowsMap.containsKey(tagentsid)) {
|
|
|
+ row.put("checkdate", agentcheckrowsMap.get(tagentsid).get(0).getString("checkdate"));
|
|
|
+ } else {
|
|
|
+ row.put("checkdate", row.getString("createdate"));
|
|
|
}
|
|
|
}
|
|
|
- SQLFactory sql = new SQLFactory(this, "经销商列表查询", pageSize, pageNumber, "t1.tagentsid");
|
|
|
- sql.addParameter("siteid", siteid);
|
|
|
- sql.addParameter_SQL("where", where);
|
|
|
- Rows rows = dbConnect.runSqlQuery(sql.getSQL());
|
|
|
+
|
|
|
return getSucReturnObject().setDataByPaging(rows).setFinalDo(DataPool.defaultdatalife, 1);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 企业档案经销商主界面查询
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- public String query_enterpriseAgentsMain() {
|
|
|
+ public String query_agentsMain() {
|
|
|
tagentsid = content.getLong("tagentsid");
|
|
|
- SQLFactory sql = new SQLFactory(this, "经销商主界面查询");
|
|
|
+ SQLFactory sql = new SQLFactory(this, "商户主界面查询");
|
|
|
sql.addParameter("siteid", siteid);
|
|
|
sql.addParameter("tagentsid", tagentsid);
|
|
|
Rows rows = dbConnect.runSqlQuery(sql.getSQL());
|
|
|
for (Row row : rows) {
|
|
|
- SQLFactory prodclass = new SQLFactory(this, "经销商经营类目查询");
|
|
|
+ SQLFactory prodclass = new SQLFactory(this, "商户经营类目列表查询");
|
|
|
prodclass.addParameter("siteid", siteid);
|
|
|
prodclass.addParameter("tagentsid", tagentsid);
|
|
|
Rows prodclassrows = dbConnect.runSqlQuery(prodclass.getSQL());
|
|
|
- row.put("prodclass", prodclassrows);
|
|
|
+ row.put("fprodclassname", prodclassrows);
|
|
|
+ row.put("attinfos", getAttachmentUrl("tagentsid", String.valueOf(tagentsid), "brandlogo"));
|
|
|
+
|
|
|
+ //修改申请查询
|
|
|
+ Rows tagents_msgchangeappRows = dbConnect.runSqlQuery("select fchangemsg,ftype,tagents_msgchangappid from tagents_msgchangeapp where fstatus='申请' and siteid='" + siteid + "' and tagentsid='" + tagentsid + "'");
|
|
|
+ if (tagents_msgchangeappRows.isEmpty()) {
|
|
|
+ row.put("msgchangeapp", "{}");
|
|
|
+ } else {
|
|
|
+ String ftype = tagents_msgchangeappRows.get(0).getString("ftype");
|
|
|
+ String fchangemsg = tagents_msgchangeappRows.get(0).getString("fchangemsg");
|
|
|
+ long tagents_msgchangappid = tagents_msgchangeappRows.get(0).getLong("tagents_msgchangappid");
|
|
|
+ JSONObject msgchangeappObject = new JSONObject();
|
|
|
+ msgchangeappObject.put("ftype", ftype);
|
|
|
+ msgchangeappObject.put("fchangemsg", JSONObject.parseObject(fchangemsg));
|
|
|
+ msgchangeappObject.put("tagents_msgchangappid", tagents_msgchangappid);
|
|
|
+ row.put("msgchangeapp", msgchangeappObject);
|
|
|
+ }
|
|
|
}
|
|
|
return getSucReturnObject().setData(rows).toString();
|
|
|
}
|
|
|
@@ -104,7 +141,7 @@ public class tagents extends Controller {
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- public String modify_enterpriseAgent() throws D3bException, P2Exception {
|
|
|
+ public String modify_agent() throws D3bException, P2Exception {
|
|
|
long tagentsid = content.getLong("tagentsid");//经销商id
|
|
|
/**
|
|
|
* 只有个人才可进行商户认证
|
|
|
@@ -140,11 +177,12 @@ public class tagents extends Controller {
|
|
|
tagents_msgchangeappSet.save();
|
|
|
|
|
|
content.put("tagents_msgchangappid", tagents_msgchangappid);
|
|
|
- check_enterpriseAgent();
|
|
|
+ check_agentmodify();
|
|
|
}
|
|
|
return getSucReturnObject().toString();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 经销商信息修改审核
|
|
|
*
|
|
|
@@ -152,7 +190,7 @@ public class tagents extends Controller {
|
|
|
* @throws D3bException
|
|
|
* @throws P2Exception
|
|
|
*/
|
|
|
- public String check_enterpriseAgent() throws D3bException, P2Exception {
|
|
|
+ public String check_agentmodify() throws D3bException, P2Exception {
|
|
|
long tagents_msgchangappid = content.getLong("tagents_msgchangappid");
|
|
|
Rows rows = dbConnect.runSqlQuery("select ftype,fchangemsg,tagentsid from tagents_msgchangeapp where fstatus='申请'and siteid='" + siteid + "' and tagents_msgchangappid='" + tagents_msgchangappid + "'");
|
|
|
if (rows.isEmpty()) {
|
|
|
@@ -161,37 +199,34 @@ public class tagents extends Controller {
|
|
|
String ftype = rows.get(0).getString("ftype");
|
|
|
String fchangemsg = rows.get(0).getString("fchangemsg");
|
|
|
long tagentsid = rows.get(0).getLong("tagentsid");
|
|
|
-
|
|
|
PaoSetRemote tagentsSet = getP2ServerSystemPaoSet("tagents", "siteid='" + siteid + "' and tagentsid='" + tagentsid + "'");
|
|
|
if (!tagentsSet.isEmpty()) {
|
|
|
PaoRemote tagents = tagentsSet.getPao(0);
|
|
|
- JSONArray changemsgarray = JSONArray.parseArray(fchangemsg);
|
|
|
- for (Object o : changemsgarray) {
|
|
|
- JSONObject changemsgObject = (JSONObject) o;
|
|
|
- Iterator it = changemsgObject.keySet().iterator();
|
|
|
- while (it.hasNext()) {
|
|
|
- String key = (String) it.next();
|
|
|
- if ("saleprodclass".equals(key)) {
|
|
|
- //经营类目修改
|
|
|
- JSONArray saleprodclassArray = changemsgObject.getJSONArray("saleprodclass");
|
|
|
- PaoSetRemote tagents_prodclassSet = tagents.getPaoSet("$tagents_prodclass", "tagents_prodclass", "tagentsid=" + tagentsid);
|
|
|
- tagents_prodclassSet.deleteAll();
|
|
|
- for (Object saleprodclassObject : saleprodclassArray) {
|
|
|
- String fprodclassname = (String) saleprodclassObject;
|
|
|
- PaoRemote saleprodclassPao = tagents_prodclassSet.addAtEnd();
|
|
|
- saleprodclassPao.setValue("tagentsid", tagentsid, 11L);
|
|
|
- saleprodclassPao.setValue("siteid", siteid, 11L);
|
|
|
- saleprodclassPao.setValue("fprodclassname", fprodclassname, 11L);
|
|
|
- }
|
|
|
- } else {
|
|
|
- String value = changemsgObject.getString(key);
|
|
|
- tagents.setValue(key, value, 11L);
|
|
|
+ JSONObject changemsgObject = JSONObject.parseObject(fchangemsg);
|
|
|
+ Iterator it = changemsgObject.keySet().iterator();
|
|
|
+ while (it.hasNext()) {
|
|
|
+ String key = (String) it.next();
|
|
|
+ if ("saleprodclass".equals(key)) {
|
|
|
+ //经营类目修改
|
|
|
+ JSONArray saleprodclassArray = changemsgObject.getJSONArray("saleprodclass");
|
|
|
+ PaoSetRemote tagents_prodclassSet = tagents.getPaoSet("$tagents_prodclass", "tagents_prodclass", "tagentsid=" + tagentsid);
|
|
|
+ tagents_prodclassSet.deleteAll();
|
|
|
+ for (Object saleprodclassObject : saleprodclassArray) {
|
|
|
+ String fprodclassname = (String) saleprodclassObject;
|
|
|
+ PaoRemote saleprodclassPao = tagents_prodclassSet.addAtEnd();
|
|
|
+ saleprodclassPao.setValue("tagentsid", tagentsid, 11L);
|
|
|
+ saleprodclassPao.setValue("siteid", siteid, 11L);
|
|
|
+ saleprodclassPao.setValue("fprodclassname", fprodclassname, 11L);
|
|
|
}
|
|
|
+ } else {
|
|
|
+ String value = changemsgObject.getString(key);
|
|
|
+ tagents.setValue(key, value, 11L);
|
|
|
}
|
|
|
- if (ftype.equals("商户认证")) {
|
|
|
- tagents.setValue("ftype", "普通商户", 11L);
|
|
|
- }
|
|
|
}
|
|
|
+ if (ftype.equals("商户认证")) {
|
|
|
+ tagents.setValue("ftype", "普通商户", 11L);
|
|
|
+ }
|
|
|
+
|
|
|
PaoSetRemote tagents_msgchangeappSet = tagents.getPaoSet("$tagents_msgchangeapp", "tagents_msgchangeapp", "tagents_msgchangappid=" + tagents_msgchangappid);
|
|
|
tagents_msgchangeappSet.getPao(0).setValue("fstatus", "审核", 11L);
|
|
|
tagents_msgchangeappSet.getPao(0).setValue("checkby", username, 11L);
|
|
|
@@ -208,15 +243,35 @@ public class tagents extends Controller {
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- public String delete_enterpriseAgent() {
|
|
|
- SQLFactory sqlFactory = new SQLFactory(this, "经销商档案删除");
|
|
|
+ public String delete_agent() {
|
|
|
+ if (!dbConnect.runSqlQuery("select *from tuserrequestlog where siteid='" + siteid + "' and tagentsid='" + tagentsid + "'").isEmpty()) {
|
|
|
+ return getErrReturnObject().setErrMsg("当前商户已有访问记录,不可删除,建议停用").toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "商户档案删除");
|
|
|
sqlFactory.addParameter("siteid", siteid);
|
|
|
sqlFactory.addParameter("tagentsid", content.getString("tagentsid"));
|
|
|
String result = dbConnect.runSqlUpdate(sqlFactory.getSQL());
|
|
|
if ("true".equals(result)) {
|
|
|
return getSucReturnObject().toString();
|
|
|
} else {
|
|
|
- return getErrReturnObject().setErrMsg(result).toString();
|
|
|
+ return getErrReturnObject().toString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 企业经销商档案启用停用
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String use_agent() {
|
|
|
+ int fisused = content.getInteger("fisused");
|
|
|
+ long tagentsid = content.getLong("tagentsid");
|
|
|
+ String result = dbConnect.runSqlUpdate("update tagents set fisused=" + fisused + " where siteid='" + siteid + "' and tagentsid='" + tagentsid + "'");
|
|
|
+ if ("true".equals(result)) {
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ } else {
|
|
|
+ return getErrReturnObject().toString();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -225,8 +280,8 @@ public class tagents extends Controller {
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- public String query_enterpriseAgentUsers() {
|
|
|
- SQLFactory sql = new SQLFactory(this, "经销商账号列表查询");
|
|
|
+ public String query_agentUsers() {
|
|
|
+ SQLFactory sql = new SQLFactory(this, "商户账号列表查询");
|
|
|
sql.addParameter("siteid", siteid);
|
|
|
sql.addParameter("tagentsid", content.getString("tagentsid"));
|
|
|
Rows rows = dbConnect.runSqlQuery(sql.getSQL());
|