|
|
@@ -0,0 +1,255 @@
|
|
|
+package com.cnd3b.restcontroller.enterprise.activity;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+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 p2.pao.PaoRemote;
|
|
|
+import p2.pao.PaoSetRemote;
|
|
|
+import p2.util.P2Exception;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
+
|
|
|
+public class activity extends Controller {
|
|
|
+ public activity(JSONObject content) {
|
|
|
+ super(content);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 活动列表查询
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String query_activityList() {
|
|
|
+ /**
|
|
|
+ *排序条件设置
|
|
|
+ */
|
|
|
+ String[] sortfield = {"t1.tactivityid desc"};
|
|
|
+ String sort = getSort(sortfield, "t1.tactivityid 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.ftitle like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t1.fnotes like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "活动列表查询", pageSize, pageNumber, sort);
|
|
|
+ sqlFactory.addParameter("siteid", siteid);
|
|
|
+ sqlFactory.addParameter_SQL("where", where);
|
|
|
+
|
|
|
+ Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
|
|
|
+ return getSucReturnObject().setDataByPaging(rows).saveToDataPool().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 活动新增修改
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String insertormodify_activity() throws D3bException, P2Exception {
|
|
|
+ long tactivityid = content.getLong("tactivityid");
|
|
|
+ String ftitle = content.getString("ftitle", "tactivity.ftitle", "活动名称");
|
|
|
+ String fnotes = content.getString("fnotes", "tactivity.fnotes", "活动介绍");
|
|
|
+ String fshow_url = content.getString("fshow_url", "tactivity.fshow_url", "活动宣传页");
|
|
|
+ String fstatus = content.getString("fstatus");
|
|
|
+ Date fbegdate = content.getDate("fbegdate");//开始时间
|
|
|
+ Date fenddate = content.getDate("fenddate");//结束时间
|
|
|
+
|
|
|
+ PaoSetRemote tactivitySet = getP2ServerSystemPaoSet("tactivity", "siteid='" + siteid + "' and tactivityid='" + tactivityid + "'");
|
|
|
+ PaoRemote tactivity = null;
|
|
|
+ if (tactivityid <= 0 || tactivitySet.isEmpty()) {
|
|
|
+ tactivity = tactivitySet.addAtEnd();
|
|
|
+ tactivity.setValue("siteid", siteid, 11L);//企业ID
|
|
|
+ tactivity.setValue("createby", username, 11L);//录入人
|
|
|
+ tactivity.setValue("createdate", sysdate, 11L);//录入时间
|
|
|
+ } else {
|
|
|
+ tactivity = tactivitySet.getPao(0);
|
|
|
+ }
|
|
|
+ tactivity.setValue("fstatus", fstatus, 11L);
|
|
|
+ tactivity.setValue("ftitle", ftitle, 11L);
|
|
|
+ tactivity.setValue("fnotes", fnotes, 11L);
|
|
|
+ tactivity.setValue("fshow_url", fshow_url, 11L);
|
|
|
+ tactivity.setValue("fbegdate", fbegdate, 11L);
|
|
|
+ tactivity.setValue("fenddate", fenddate, 11L);
|
|
|
+ tactivity.setValue("changedate", sysdate, 11L);
|
|
|
+ tactivity.setValue("changeby", username, 11L);
|
|
|
+
|
|
|
+ content.put("tactivityid", tactivity.getUniqueIDValue());
|
|
|
+ tactivitySet.save();
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 活动商户列表查询
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String query_activityAgentList() {
|
|
|
+ long tactivityid = content.getLong("tactivityid");
|
|
|
+
|
|
|
+ /**
|
|
|
+ *排序条件设置
|
|
|
+ */
|
|
|
+ String[] sortfield = {"t1.tactivityid"};
|
|
|
+ String sort = getSort(sortfield, "t1.tactivityid");
|
|
|
+ /**
|
|
|
+ * 过滤条件设置
|
|
|
+ */
|
|
|
+ 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.fagentname like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t1.fbrand like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "活动商户列表查询", pageSize, pageNumber, sort);
|
|
|
+ sqlFactory.addParameter("siteid", siteid);
|
|
|
+ sqlFactory.addParameter("tactivityid", tactivityid);
|
|
|
+ sqlFactory.addParameter_SQL("where", where);
|
|
|
+
|
|
|
+ Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
|
|
|
+ RowsMap brandlogoRowsMap = getAttachmentUrl("tagents", rows.toArrayList("tagentsid"), "brandlogo");
|
|
|
+ for (Row row : rows) {
|
|
|
+ row.put("attinfos", brandlogoRowsMap.get(row.getString("tagentsid")));
|
|
|
+ }
|
|
|
+ return getSucReturnObject().setDataByPaging(rows).saveToDataPool().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 活动商户详情查询
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String query_activityAgentMain() {
|
|
|
+ long tactivityid = content.getLong("tactivityid");
|
|
|
+ long tagentsid = content.getLong("tagentsid");
|
|
|
+
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "活动商户详情查询");
|
|
|
+ sqlFactory.addParameter("siteid", siteid);
|
|
|
+ sqlFactory.addParameter("tactivityid", tactivityid);
|
|
|
+ sqlFactory.addParameter("tagentsid", tagentsid);
|
|
|
+ Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
|
|
|
+ RowsMap brandlogoRowsMap = getAttachmentUrl("tagents", rows.toArrayList("tagentsid"), "brandlogo");
|
|
|
+ for (Row row : rows) {
|
|
|
+ row.put("attinfos", brandlogoRowsMap.get(row.getString("tagentsid")));
|
|
|
+ }
|
|
|
+ return getSucReturnObject().setData(rows).saveToDataPool().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增活动商户
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String insertormodify_activityAgent() throws D3bException, P2Exception {
|
|
|
+ long tactivityid = content.getLong("tactivityid");
|
|
|
+ long tagentsid = content.getLong("tagentsid");
|
|
|
+
|
|
|
+ String fbrand = content.getString("fbrand", "tactivity_agentmsg.fbrand", "参展品牌");
|
|
|
+ String fcontact = content.getString("fcontact", "tactivity_agentmsg.fcontact", "活动联系人");
|
|
|
+ String fintroduction = content.getString("fintroduction", "tactivity_agentmsg.fintroduction", "商户介绍");
|
|
|
+ String flocation = content.getString("flocation", "tactivity_agentmsg.flocation", "活动位置、展位");
|
|
|
+ String flocationclass = content.getString("flocationclass", "tactivity_agentmsg.flocationclass", "活动位置、展区分类");
|
|
|
+ String fphonenumber = content.getString("fphonenumber", "tactivity_agentmsg.fphonenumber", "联系人手机号");
|
|
|
+ String fstatus = content.getString("fstatus", "tactivity_agentmsg.fstatus", "状态");
|
|
|
+
|
|
|
+
|
|
|
+ PaoSetRemote tactivity_agentmsgSet = getP2ServerSystemPaoSet("tactivity_agentmsg", "siteid='" + siteid + "' and tactivityid='" + tactivityid + "' and tagentsid='" + tagentsid + "'");
|
|
|
+ PaoRemote tactivity_agentmsg = null;
|
|
|
+ if (tactivity_agentmsgSet.isEmpty()) {
|
|
|
+ tactivity_agentmsg = tactivity_agentmsgSet.addAtEnd();
|
|
|
+ tactivity_agentmsg.setValue("tactivityid", tactivityid, 11L);
|
|
|
+ tactivity_agentmsg.setValue("tagentsid", tagentsid, 11L);
|
|
|
+ tactivity_agentmsg.setValue("siteid", siteid, 11L);//企业ID
|
|
|
+ tactivity_agentmsg.setValue("createby", username, 11L);//录入人
|
|
|
+ tactivity_agentmsg.setValue("createdate", sysdate, 11L);//录入时间
|
|
|
+ } else {
|
|
|
+ tactivity_agentmsg = tactivity_agentmsgSet.getPao(0);
|
|
|
+ }
|
|
|
+ tactivity_agentmsg.setValue("fstatus", fstatus, 11L);
|
|
|
+ tactivity_agentmsg.setValue("fbrand", fbrand, 11L);
|
|
|
+ tactivity_agentmsg.setValue("fcontact", fcontact, 11L);
|
|
|
+ tactivity_agentmsg.setValue("fintroduction", fintroduction, 11L);
|
|
|
+ tactivity_agentmsg.setValue("flocation", flocation, 11L);
|
|
|
+ tactivity_agentmsg.setValue("flocationclass", flocationclass, 11L);
|
|
|
+ tactivity_agentmsg.setValue("fphonenumber", fphonenumber, 11L);
|
|
|
+ tactivity_agentmsg.setValue("changedate", sysdate, 11L);
|
|
|
+ tactivity_agentmsg.setValue("changeby", username, 11L);
|
|
|
+
|
|
|
+ content.put("tactivityid", tactivity_agentmsg.getUniqueIDValue());
|
|
|
+ tactivity_agentmsgSet.save();
|
|
|
+
|
|
|
+ return query_activityAgentMain();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 活动商户商品列表查询
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String query_activityAgentMain_prodlist() {
|
|
|
+ long tactivityid = content.getLong("tactivityid");
|
|
|
+ long tagentsid = content.getLong("tagentsid");
|
|
|
+ /**
|
|
|
+ *排序条件设置
|
|
|
+ */
|
|
|
+ String[] sortfield = {"t1.tagents_productid desc"};
|
|
|
+ String sort = getSort(sortfield, "t1.tagents_productid desc");
|
|
|
+
|
|
|
+ SQLFactory prodsql = new SQLFactory(this, "活动商户详情查询_活动商品列表", pageSize, pageNumber, sort);
|
|
|
+ prodsql.addParameter("siteid", siteid);
|
|
|
+ prodsql.addParameter("tactivityid", tactivityid);
|
|
|
+ prodsql.addParameter("tagentsid", tagentsid);
|
|
|
+ Rows prodRows = dbConnect.runSqlQuery(prodsql.getSQL());
|
|
|
+ RowsMap prodattinfosMap = getAttachmentUrl("tagents_product", prodRows.toArrayList("tagents_productid"));
|
|
|
+
|
|
|
+ for (Row prodrow : prodRows) {
|
|
|
+ prodrow.put("attinfos", prodattinfosMap.get(prodrow.getString("tagents_productid")));
|
|
|
+ }
|
|
|
+ return getSucReturnObject().setDataByPaging(prodRows).saveToDataPool().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增活动商户商品
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String insertormodify_activityAgentProd() throws D3bException, P2Exception {
|
|
|
+ long tactivityid = content.getLong("tactivityid");
|
|
|
+ long tagentsid = content.getLong("tagentsid");
|
|
|
+ long tagents_productid = content.getLong("tagents_productid");
|
|
|
+
|
|
|
+ String fintroduction = content.getString("fintroduction", "tactivity_agentproducts.fintroduction", "产品介绍");
|
|
|
+
|
|
|
+ PaoSetRemote tactivity_agentproductsSet = getP2ServerSystemPaoSet("tactivity_agentproducts", "siteid='" + siteid + "' and tactivityid='" + tactivityid + "' and tagentsid='" + tagentsid + "' and tagents_productid='" + tagents_productid + "'");
|
|
|
+ PaoRemote tactivity_agentproducts = null;
|
|
|
+ if (tactivity_agentproductsSet.isEmpty()) {
|
|
|
+ tactivity_agentproducts = tactivity_agentproductsSet.addAtEnd();
|
|
|
+ tactivity_agentproducts.setValue("tactivityid", tactivityid, 11L);
|
|
|
+ tactivity_agentproducts.setValue("tagentsid", tagentsid, 11L);
|
|
|
+ tactivity_agentproducts.setValue("tagents_productid", tagents_productid, 11L);
|
|
|
+ tactivity_agentproducts.setValue("siteid", siteid, 11L);//企业ID
|
|
|
+ tactivity_agentproducts.setValue("createby", username, 11L);//录入人
|
|
|
+ tactivity_agentproducts.setValue("createdate", sysdate, 11L);//录入时间
|
|
|
+ } else {
|
|
|
+ tactivity_agentproducts = tactivity_agentproductsSet.getPao(0);
|
|
|
+ }
|
|
|
+ tactivity_agentproducts.setValue("fintroduction", fintroduction, 11L);
|
|
|
+ tactivity_agentproducts.setValue("changedate", sysdate, 11L);
|
|
|
+ tactivity_agentproducts.setValue("changeby", username, 11L);
|
|
|
+ tactivity_agentproductsSet.save();
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+}
|