agentscope.java 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. package restcontroller.webmanage.sale.agentscope;
  2. import java.util.HashMap;
  3. import com.alibaba.fastjson2.JSONArray;
  4. import com.alibaba.fastjson2.JSONObject;
  5. import common.Controller;
  6. import common.YosException;
  7. import common.annotation.API;
  8. import common.annotation.CACHEING;
  9. import common.annotation.CACHEING_CLEAN;
  10. import common.annotation.cm;
  11. import common.data.QuerySQL;
  12. import common.data.Rows;
  13. import common.data.SQLFactory;
  14. import restcontroller.R;
  15. @API(title = "经销商省市县明细管理")
  16. public class agentscope extends Controller {
  17. public agentscope(JSONObject arg0) throws YosException {
  18. super(arg0);
  19. // TODO Auto-generated constructor stub
  20. }
  21. @API(title = "经销商省市县明细查询", apiversion = R.ID2025071615124203.v1.class)
  22. @CACHEING
  23. public String query_areascope() throws YosException {
  24. QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_agents_salescope", "sa_agents_salescopeid", "sa_agentsid","province","city","county");
  25. querySQL.setTableAlias("t1");
  26. querySQL.setSiteid(siteid);
  27. querySQL.setWhere("t1.sa_agentsid",content.getString("sa_agentsid"));
  28. querySQL.setPage(pageSize, pageNumber);
  29. Rows rows = querySQL.query();
  30. return getSucReturnObject().setData(rows).toString();
  31. }
  32. @API(title = "经销商省市县新增修改", apiversion = R.ID2025071615130703.v1.class)
  33. @CACHEING_CLEAN(cms = {@cm(clazz = agentscope.class, method = {"query_areascope"})})
  34. public String insertormodify_areascope() throws YosException {
  35. long sa_agentsid = content.getLongValue("sa_agentsid");//区域id
  36. long sa_agents_salescopeid = content.getLongValue("sa_agents_salescopeid");//新增时传0
  37. String province = content.getString("province");
  38. String city = content.getString("city");
  39. String county = content.getString("county");
  40. SQLFactory sqlFactory;
  41. if (sa_agents_salescopeid <= 0 || dbConnect.runSqlQuery("select sa_agents_salescopeid from sa_agents_salescope where sa_agents_salescopeid=" + sa_agents_salescopeid).isEmpty()) {
  42. sa_agents_salescopeid = createTableID("sa_agents_salescope");
  43. sqlFactory = new SQLFactory(this, "经销商省市县新增");
  44. sqlFactory.addParameter("siteid", siteid);
  45. sqlFactory.addParameter("sa_agentsid", sa_agentsid);
  46. sqlFactory.addParameter("sa_agents_salescopeid", sa_agents_salescopeid);
  47. sqlFactory.addParameter("province", province);
  48. sqlFactory.addParameter("city", city);
  49. sqlFactory.addParameter("county", county);
  50. } else {
  51. sqlFactory = new SQLFactory(this, "经销商省市县修改");
  52. sqlFactory.addParameter("siteid", siteid);
  53. sqlFactory.addParameter("sa_agentsid", sa_agentsid);
  54. sqlFactory.addParameter("sa_agents_salescopeid", sa_agents_salescopeid);
  55. sqlFactory.addParameter("province", province);
  56. sqlFactory.addParameter("city", city);
  57. sqlFactory.addParameter("county", county);
  58. }
  59. dbConnect.runSqlUpdate(sqlFactory);
  60. return query_areascope();
  61. }
  62. @API(title = "经销商省市县明细删除", apiversion = R.ID2025071615133603.v1.class)
  63. @CACHEING_CLEAN(cms = {@cm(clazz = agentscope.class, method = {"query_areascope"})})
  64. public String delete_areascope() throws YosException {
  65. long sa_agents_salescopeid = content.getLongValue("sa_agents_salescopeid");
  66. Rows rows=dbConnect.runSqlQuery("select sa_agentsid from sa_agents_salescope where siteid='" + siteid + "' and sa_agents_salescopeid=" + sa_agents_salescopeid);
  67. if(!rows.isEmpty()) {
  68. content.put("sa_agentsid", rows.get(0).getLong("sa_agentsid"));
  69. }else {
  70. content.put("sa_agentsid", 0);
  71. }
  72. dbConnect.runSqlUpdate("delete from sa_agents_salescope where siteid='" + siteid + "' and sa_agents_salescopeid=" + sa_agents_salescopeid);
  73. return getSucReturnObject().toString();
  74. }
  75. }