activity.java 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. package com.cnd3b.restcontroller.enterprise.activity;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.cnd3b.common.Controller;
  4. import com.cnd3b.common.D3bException;
  5. import com.cnd3b.common.data.Row;
  6. import com.cnd3b.common.data.Rows;
  7. import com.cnd3b.common.data.RowsMap;
  8. import com.cnd3b.common.data.SQLFactory;
  9. import p2.pao.PaoRemote;
  10. import p2.pao.PaoSetRemote;
  11. import p2.util.P2Exception;
  12. import java.util.Date;
  13. public class activity extends Controller {
  14. public activity(JSONObject content) {
  15. super(content);
  16. }
  17. /**
  18. * 活动列表查询
  19. *
  20. * @return
  21. */
  22. public String query_activityList() {
  23. /**
  24. *排序条件设置
  25. */
  26. String[] sortfield = {"t1.tactivityid desc"};
  27. String sort = getSort(sortfield, "t1.tactivityid desc");
  28. /**
  29. * 过滤条件设置
  30. */
  31. StringBuffer where = new StringBuffer(" 1=1 ");
  32. if (content.containsKey("where")) {
  33. JSONObject whereObject = content.getJSONObject("where");
  34. if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
  35. where.append(" and(");
  36. where.append("t1.ftitle like'%").append(whereObject.getString("condition")).append("%' ");
  37. where.append("or t1.fnotes like'%").append(whereObject.getString("condition")).append("%' ");
  38. where.append(")");
  39. }
  40. }
  41. SQLFactory sqlFactory = new SQLFactory(this, "活动列表查询", pageSize, pageNumber, sort);
  42. sqlFactory.addParameter("siteid", siteid);
  43. sqlFactory.addParameter_SQL("where", where);
  44. Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
  45. return getSucReturnObject().setDataByPaging(rows).saveToDataPool().toString();
  46. }
  47. /**
  48. * 活动新增修改
  49. *
  50. * @return
  51. */
  52. public String insertormodify_activity() throws D3bException, P2Exception {
  53. long tactivityid = content.getLong("tactivityid");
  54. String ftitle = content.getString("ftitle", "tactivity.ftitle", "活动名称");
  55. String fnotes = content.getString("fnotes", "tactivity.fnotes", "活动介绍");
  56. String fshow_url = content.getString("fshow_url", "tactivity.fshow_url", "活动宣传页");
  57. String fstatus = content.getString("fstatus");
  58. Date fbegdate = content.getDate("fbegdate");//开始时间
  59. Date fenddate = content.getDate("fenddate");//结束时间
  60. PaoSetRemote tactivitySet = getP2ServerSystemPaoSet("tactivity", "siteid='" + siteid + "' and tactivityid='" + tactivityid + "'");
  61. PaoRemote tactivity = null;
  62. if (tactivityid <= 0 || tactivitySet.isEmpty()) {
  63. tactivity = tactivitySet.addAtEnd();
  64. tactivity.setValue("siteid", siteid, 11L);//企业ID
  65. tactivity.setValue("createby", username, 11L);//录入人
  66. tactivity.setValue("createdate", sysdate, 11L);//录入时间
  67. } else {
  68. tactivity = tactivitySet.getPao(0);
  69. }
  70. tactivity.setValue("fstatus", fstatus, 11L);
  71. tactivity.setValue("ftitle", ftitle, 11L);
  72. tactivity.setValue("fnotes", fnotes, 11L);
  73. tactivity.setValue("fshow_url", fshow_url, 11L);
  74. tactivity.setValue("fbegdate", fbegdate, 11L);
  75. tactivity.setValue("fenddate", fenddate, 11L);
  76. tactivity.setValue("changedate", sysdate, 11L);
  77. tactivity.setValue("changeby", username, 11L);
  78. content.put("tactivityid", tactivity.getUniqueIDValue());
  79. tactivitySet.save();
  80. return getSucReturnObject().toString();
  81. }
  82. /**
  83. * 活动商户列表查询
  84. *
  85. * @return
  86. */
  87. public String query_activityAgentList() {
  88. long tactivityid = content.getLong("tactivityid");
  89. /**
  90. *排序条件设置
  91. */
  92. String[] sortfield = {"t1.tactivityid"};
  93. String sort = getSort(sortfield, "t1.tactivityid");
  94. /**
  95. * 过滤条件设置
  96. */
  97. StringBuffer where = new StringBuffer(" 1=1 ");
  98. if (content.containsKey("where")) {
  99. JSONObject whereObject = content.getJSONObject("where");
  100. if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
  101. where.append(" and(");
  102. where.append("t2.fagentname like'%").append(whereObject.getString("condition")).append("%' ");
  103. where.append("or t1.fbrand like'%").append(whereObject.getString("condition")).append("%' ");
  104. where.append(")");
  105. }
  106. }
  107. SQLFactory sqlFactory = new SQLFactory(this, "活动商户列表查询", pageSize, pageNumber, sort);
  108. sqlFactory.addParameter("siteid", siteid);
  109. sqlFactory.addParameter("tactivityid", tactivityid);
  110. sqlFactory.addParameter_SQL("where", where);
  111. Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
  112. RowsMap brandlogoRowsMap = getAttachmentUrl("tagents", rows.toArrayList("tagentsid"), "brandlogo");
  113. for (Row row : rows) {
  114. row.put("attinfos", brandlogoRowsMap.get(row.getString("tagentsid")));
  115. }
  116. return getSucReturnObject().setDataByPaging(rows).saveToDataPool().toString();
  117. }
  118. /**
  119. * 活动商户详情查询
  120. *
  121. * @return
  122. */
  123. public String query_activityAgentMain() {
  124. long tactivityid = content.getLong("tactivityid");
  125. long tagentsid = content.getLong("tagentsid");
  126. SQLFactory sqlFactory = new SQLFactory(this, "活动商户详情查询");
  127. sqlFactory.addParameter("siteid", siteid);
  128. sqlFactory.addParameter("tactivityid", tactivityid);
  129. sqlFactory.addParameter("tagentsid", tagentsid);
  130. Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
  131. RowsMap brandlogoRowsMap = getAttachmentUrl("tagents", rows.toArrayList("tagentsid"), "brandlogo");
  132. for (Row row : rows) {
  133. row.put("attinfos", brandlogoRowsMap.get(row.getString("tagentsid")));
  134. }
  135. return getSucReturnObject().setData(rows).saveToDataPool().toString();
  136. }
  137. /**
  138. * 新增活动商户
  139. *
  140. * @return
  141. */
  142. public String insertormodify_activityAgent() throws D3bException, P2Exception {
  143. long tactivityid = content.getLong("tactivityid");
  144. long tagentsid = content.getLong("tagentsid");
  145. String fbrand = content.getString("fbrand", "tactivity_agentmsg.fbrand", "参展品牌");
  146. String fcontact = content.getString("fcontact", "tactivity_agentmsg.fcontact", "活动联系人");
  147. String fintroduction = content.getString("fintroduction", "tactivity_agentmsg.fintroduction", "商户介绍");
  148. String flocation = content.getString("flocation", "tactivity_agentmsg.flocation", "活动位置、展位");
  149. String flocationclass = content.getString("flocationclass", "tactivity_agentmsg.flocationclass", "活动位置、展区分类");
  150. String fphonenumber = content.getString("fphonenumber", "tactivity_agentmsg.fphonenumber", "联系人手机号");
  151. String fstatus = content.getString("fstatus", "tactivity_agentmsg.fstatus", "状态");
  152. PaoSetRemote tactivity_agentmsgSet = getP2ServerSystemPaoSet("tactivity_agentmsg", "siteid='" + siteid + "' and tactivityid='" + tactivityid + "' and tagentsid='" + tagentsid + "'");
  153. PaoRemote tactivity_agentmsg = null;
  154. if (tactivity_agentmsgSet.isEmpty()) {
  155. tactivity_agentmsg = tactivity_agentmsgSet.addAtEnd();
  156. tactivity_agentmsg.setValue("tactivityid", tactivityid, 11L);
  157. tactivity_agentmsg.setValue("tagentsid", tagentsid, 11L);
  158. tactivity_agentmsg.setValue("siteid", siteid, 11L);//企业ID
  159. tactivity_agentmsg.setValue("createby", username, 11L);//录入人
  160. tactivity_agentmsg.setValue("createdate", sysdate, 11L);//录入时间
  161. } else {
  162. tactivity_agentmsg = tactivity_agentmsgSet.getPao(0);
  163. }
  164. tactivity_agentmsg.setValue("fstatus", fstatus, 11L);
  165. tactivity_agentmsg.setValue("fbrand", fbrand, 11L);
  166. tactivity_agentmsg.setValue("fcontact", fcontact, 11L);
  167. tactivity_agentmsg.setValue("fintroduction", fintroduction, 11L);
  168. tactivity_agentmsg.setValue("flocation", flocation, 11L);
  169. tactivity_agentmsg.setValue("flocationclass", flocationclass, 11L);
  170. tactivity_agentmsg.setValue("fphonenumber", fphonenumber, 11L);
  171. tactivity_agentmsg.setValue("changedate", sysdate, 11L);
  172. tactivity_agentmsg.setValue("changeby", username, 11L);
  173. content.put("tactivityid", tactivity_agentmsg.getUniqueIDValue());
  174. tactivity_agentmsgSet.save();
  175. return query_activityAgentMain();
  176. }
  177. /**
  178. * 删除活动商户
  179. *
  180. * @return
  181. */
  182. public String delete_activityAgent() throws D3bException, P2Exception {
  183. long tactivityid = content.getLong("tactivityid");
  184. long tagentsid = content.getLong("tagentsid");
  185. SQLFactory sqlFactory = new SQLFactory(this, "活动商户删除");
  186. sqlFactory.addParameter("siteid", siteid);
  187. sqlFactory.addParameter("tactivityid", tactivityid);
  188. sqlFactory.addParameter("tagentsid", tagentsid);
  189. dbConnect.runSqlUpdate(sqlFactory.getSQL());
  190. return query_activityAgentMain();
  191. }
  192. /**
  193. * 活动商户商品列表查询
  194. *
  195. * @return
  196. */
  197. public String query_activityAgentMain_prodlist() {
  198. long tactivityid = content.getLong("tactivityid");
  199. long tagentsid = content.getLong("tagentsid");
  200. /**
  201. *排序条件设置
  202. */
  203. String[] sortfield = {"t1.tagents_productid desc"};
  204. String sort = getSort(sortfield, "t1.tagents_productid desc");
  205. SQLFactory prodsql = new SQLFactory(this, "活动商户详情查询_活动商品列表", pageSize, pageNumber, sort);
  206. prodsql.addParameter("siteid", siteid);
  207. prodsql.addParameter("tactivityid", tactivityid);
  208. prodsql.addParameter("tagentsid", tagentsid);
  209. Rows prodRows = dbConnect.runSqlQuery(prodsql.getSQL());
  210. RowsMap prodattinfosMap = getAttachmentUrl("tagents_product", prodRows.toArrayList("tagents_productid"));
  211. for (Row prodrow : prodRows) {
  212. prodrow.put("attinfos", prodattinfosMap.get(prodrow.getString("tagents_productid")));
  213. }
  214. return getSucReturnObject().setDataByPaging(prodRows).saveToDataPool().toString();
  215. }
  216. /**
  217. * 新增活动商户商品
  218. *
  219. * @return
  220. */
  221. public String insertormodify_activityAgentProd() throws D3bException, P2Exception {
  222. long tactivityid = content.getLong("tactivityid");
  223. long tagentsid = content.getLong("tagentsid");
  224. long tagents_productid = content.getLong("tagents_productid");
  225. String fintroduction = content.getString("fintroduction", "tactivity_agentproducts.fintroduction", "产品介绍");
  226. PaoSetRemote tactivity_agentproductsSet = getP2ServerSystemPaoSet("tactivity_agentproducts", "siteid='" + siteid + "' and tactivityid='" + tactivityid + "' and tagentsid='" + tagentsid + "' and tagents_productid='" + tagents_productid + "'");
  227. PaoRemote tactivity_agentproducts = null;
  228. if (tactivity_agentproductsSet.isEmpty()) {
  229. tactivity_agentproducts = tactivity_agentproductsSet.addAtEnd();
  230. tactivity_agentproducts.setValue("tactivityid", tactivityid, 11L);
  231. tactivity_agentproducts.setValue("tagentsid", tagentsid, 11L);
  232. tactivity_agentproducts.setValue("tagents_productid", tagents_productid, 11L);
  233. tactivity_agentproducts.setValue("siteid", siteid, 11L);//企业ID
  234. tactivity_agentproducts.setValue("createby", username, 11L);//录入人
  235. tactivity_agentproducts.setValue("createdate", sysdate, 11L);//录入时间
  236. } else {
  237. tactivity_agentproducts = tactivity_agentproductsSet.getPao(0);
  238. }
  239. tactivity_agentproducts.setValue("fintroduction", fintroduction, 11L);
  240. tactivity_agentproducts.setValue("changedate", sysdate, 11L);
  241. tactivity_agentproducts.setValue("changeby", username, 11L);
  242. tactivity_agentproductsSet.save();
  243. return getSucReturnObject().toString();
  244. }
  245. /**
  246. * 活动删除
  247. *
  248. * @return
  249. */
  250. public String delete_activity() {
  251. long tactivityid = content.getLong("tactivityid");
  252. SQLFactory sqlFactory = new SQLFactory(this, "活动删除");
  253. sqlFactory.addParameter("siteid", siteid);
  254. sqlFactory.addParameter("tactivityid", tactivityid);
  255. String status = dbConnect.runSqlUpdate(sqlFactory.getSQL());
  256. if ("true".equalsIgnoreCase(status)) {
  257. return getSucReturnObject().toString();
  258. } else {
  259. return getErrReturnObject().toString();
  260. }
  261. }
  262. }