Itemgroup.java 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. package beans.itemgroup;
  2. import beans.dispatch.Dispatch;
  3. import com.alibaba.fastjson.JSONArray;
  4. import common.BaseClass;
  5. import common.Controller;
  6. import common.YosException;
  7. import common.data.Rows;
  8. import common.data.RowsMap;
  9. import common.data.SQLFactory;
  10. import java.util.ArrayList;
  11. public class Itemgroup extends BaseClass {
  12. /**
  13. * 获取增加商品组语句
  14. * @param controller
  15. * @param itemid
  16. * @param itemname
  17. * @param itemno
  18. * @param tradefields
  19. * @param sa_brandid
  20. * @return
  21. * @throws YosException
  22. */
  23. public static ArrayList<String> createItemGroupSql(Controller controller, long itemid, String itemname, String itemno, JSONArray tradefields, long sa_brandid) throws YosException {
  24. ArrayList<String> sqlList = new ArrayList<>();
  25. long sa_itemgroupid = controller.createTableID("sa_itemgroup");
  26. String tradefield="";
  27. if(tradefields!=null && !tradefields.isEmpty()){
  28. for (Object object:tradefields) {
  29. tradefield = tradefield +(String) object + ",";
  30. }
  31. }
  32. if (!tradefield.equals("")) {
  33. tradefield = tradefield.substring(0, tradefield.length() - 1);
  34. }
  35. SQLFactory sqlAddFactory = new SQLFactory(new Itemgroup(), "商品组新增");
  36. sqlAddFactory.addParameter("sa_itemgroupid", sa_itemgroupid);
  37. sqlAddFactory.addParameter("siteid", controller.siteid);
  38. sqlAddFactory.addParameter("groupname", itemname);
  39. sqlAddFactory.addParameter("itemno", itemno);
  40. sqlAddFactory.addParameter("username", controller.username);
  41. sqlAddFactory.addParameter("groupnum", itemno);
  42. sqlAddFactory.addParameter("tradefield", tradefield);
  43. sqlAddFactory.addParameter("sa_brandid", sa_brandid);
  44. sqlAddFactory.addParameter("sequence", 1);
  45. //System.out.println(sqlAddFactory.getSQL());
  46. sqlList.add(sqlAddFactory.getSQL());
  47. SQLFactory saleFactory = new SQLFactory(new Itemgroup(), "商品组商品明细新增");
  48. saleFactory.addParameter("siteid", controller.siteid);
  49. saleFactory.addParameter("sequence",1);
  50. saleFactory.addParameter("sa_itemgroupmxid", controller.createTableID("sa_itemgroupmx"));
  51. saleFactory.addParameter("itemno", itemno);
  52. saleFactory.addParameter("itemid", itemid);
  53. saleFactory.addParameter("sa_itemgroupid", sa_itemgroupid);
  54. //System.out.println(saleFactory.getSQL());
  55. sqlList.add(saleFactory.getSQL());
  56. return sqlList;
  57. }
  58. /**
  59. * 查询商品组的方案
  60. *
  61. * @param controller
  62. * @param sa_itemgroupids
  63. * @return
  64. * @throws YosException
  65. */
  66. public static RowsMap getItemgroupScemeid(Controller controller, ArrayList<Long> sa_itemgroupids) throws YosException {
  67. SQLFactory sqlFactory = new SQLFactory(new Itemgroup(), "查询商品组对应方案");
  68. sqlFactory.addParameter("siteid", controller.siteid);
  69. sqlFactory.addParameter_in("sa_itemgroupid", sa_itemgroupids);
  70. Rows rows = controller.dbConnect.runSqlQuery(sqlFactory);
  71. return rows.toRowsMap("sa_itemgroupid");
  72. }
  73. }