ShoppingCart.java 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. package restcontroller.sale.shoppingcart;
  2. import beans.datacontrllog.DataContrlLog;
  3. import beans.itemprice.ItemPrice;
  4. import com.alibaba.fastjson.JSONArray;
  5. import com.alibaba.fastjson.JSONObject;
  6. import com.sun.jdi.LongValue;
  7. import common.Controller;
  8. import common.YosException;
  9. import common.annotation.API;
  10. import common.annotation.CACHEING_CLEAN;
  11. import common.data.Row;
  12. import common.data.Rows;
  13. import common.data.RowsMap;
  14. import common.data.SQLFactory;
  15. import restcontroller.R;
  16. import java.io.IOException;
  17. import java.math.BigDecimal;
  18. import java.util.ArrayList;
  19. import java.util.HashMap;
  20. @API(title = "购物车管理")
  21. public class ShoppingCart extends Controller {
  22. /**
  23. * 构造函数
  24. *
  25. * @param content
  26. */
  27. public ShoppingCart(JSONObject content) throws YosException {
  28. super(content);
  29. }
  30. @API(title = "新增或更新", apiversion = R.ID20220924095102.v1.class)
  31. @CACHEING_CLEAN(apiversions = {R.ID20220924095302.class})
  32. public String insertOrUpdate() throws YosException {
  33. Long sa_brandid = content.getLongValue("sa_brandid");
  34. Long itemid = content.getLong("itemid");
  35. BigDecimal qty = content.getBigDecimal("qty");
  36. BigDecimal length = content.getBigDecimal("length");
  37. BigDecimal width = content.getBigDecimal("width");
  38. String itemno = content.getString("itemno");
  39. String tradefield = content.getStringValue("tradefield");
  40. long sa_promotionid = content.getLongValue("sa_promotionid");
  41. long sa_promotion_itemsid = content.getLongValue("sa_promotion_itemsid");
  42. SQLFactory sqlFactory = new SQLFactory(this, "购物车新增");
  43. Long sa_shoppingcartid = 0L;
  44. Rows rows = dbConnect.runSqlQuery("SELECT sa_shoppingcartid FROM sa_shoppingcart WHERE siteid = '" + siteid +
  45. "' AND sa_brandid = " + sa_brandid +
  46. " and length=" + length + " and width=" + width + " AND itemid = " + itemid +
  47. " AND sys_enterpriseid = " + sys_enterpriseid +
  48. " AND tradefield = '" + tradefield +
  49. "' AND itemno = '" + itemno + "' and sa_promotionid=" + sa_promotionid);
  50. if (rows.isNotEmpty()) {
  51. sa_shoppingcartid = rows.get(0).getLong("sa_shoppingcartid");
  52. }
  53. ArrayList<String> sqlList = new ArrayList<>();
  54. if (sa_shoppingcartid <= 0) {
  55. sa_shoppingcartid = createTableID("sa_shoppingcart");
  56. sqlList.add(DataContrlLog.createLog(this, "sa_shoppingcart", sa_shoppingcartid, "新增", "购物车新增" + sa_shoppingcartid).getSQL());
  57. } else {
  58. sqlFactory = new SQLFactory(this, "购物车更新");
  59. sqlList.add(DataContrlLog.createLog(this, "sa_shoppingcart", sa_shoppingcartid, "更新", "购物车更新" + sa_shoppingcartid).getSQL());
  60. }
  61. sqlFactory.addParameter("siteid", siteid);
  62. sqlFactory.addParameter("itemid", itemid);
  63. sqlFactory.addParameter("username", username);
  64. sqlFactory.addParameter("userid", userid);
  65. sqlFactory.addParameter("itemno", itemno);
  66. sqlFactory.addParameter("length", length);
  67. sqlFactory.addParameter("width", width);
  68. sqlFactory.addParameter("sa_promotionid", sa_promotionid);
  69. sqlFactory.addParameter("sa_promotion_itemsid", sa_promotion_itemsid);
  70. sqlFactory.addParameter("tradefield", tradefield);
  71. sqlFactory.addParameter("sa_shoppingcartid", sa_shoppingcartid);
  72. sqlFactory.addParameter("sa_brandid", sa_brandid);
  73. sqlFactory.addParameter("qty", qty);
  74. sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
  75. sqlList.add(sqlFactory.getSQL());
  76. dbConnect.runSqlUpdate(sqlList);
  77. content.put("sa_shoppingcartid", sa_shoppingcartid);
  78. return queryDetail();
  79. }
  80. @API(title = "(批量新增)", apiversion = R.ID20231024110003.v1.class)
  81. @CACHEING_CLEAN(apiversions = {R.ID20220924095302.class})
  82. public String insert() throws YosException {
  83. JSONArray items = content.getJSONArray("items");
  84. ArrayList<String> sqlList = new ArrayList<>();
  85. //System.out.println(111111);
  86. for (Object object : items) {
  87. //System.out.println(object.toString());
  88. JSONObject item = (JSONObject) object;
  89. Long sa_brandid = item.getLongValue("sa_brandid");
  90. Long itemid = item.getLong("itemid");
  91. BigDecimal qty = item.getBigDecimal("qty");
  92. BigDecimal length = item.getBigDecimal("length");
  93. BigDecimal width = item.getBigDecimal("width");
  94. String itemno = item.getString("itemno");
  95. String tradefield = item.getStringValue("tradefield");
  96. long sa_promotionid = item.getLongValue("sa_promotionid");
  97. long sa_promotion_itemsid = item.getLongValue("sa_promotion_itemsid");
  98. SQLFactory sqlFactory = new SQLFactory(this, "购物车新增");
  99. Long sa_shoppingcartid = 0L;
  100. Rows rows = dbConnect.runSqlQuery("SELECT sa_shoppingcartid FROM sa_shoppingcart WHERE siteid = '" + siteid +
  101. "' AND sa_brandid = " + sa_brandid +
  102. " and length=" + length + " and width=" + width + " AND itemid = " + itemid +
  103. " AND sys_enterpriseid = " + sys_enterpriseid +
  104. " AND tradefield = '" + tradefield +
  105. "' AND itemno = '" + itemno + "' and sa_promotionid=" + sa_promotionid);
  106. if (rows.isNotEmpty()) {
  107. sa_shoppingcartid = rows.get(0).getLong("sa_shoppingcartid");
  108. }
  109. if (sa_shoppingcartid <= 0) {
  110. sa_shoppingcartid = createTableID("sa_shoppingcart");
  111. sqlList.add(DataContrlLog.createLog(this, "sa_shoppingcart", sa_shoppingcartid, "新增", "购物车新增" + sa_shoppingcartid).getSQL());
  112. } else {
  113. sqlFactory = new SQLFactory(this, "购物车更新");
  114. sqlList.add(DataContrlLog.createLog(this, "sa_shoppingcart", sa_shoppingcartid, "更新", "购物车更新" + sa_shoppingcartid).getSQL());
  115. }
  116. sqlFactory.addParameter("siteid", siteid);
  117. sqlFactory.addParameter("itemid", itemid);
  118. sqlFactory.addParameter("username", username);
  119. sqlFactory.addParameter("userid", userid);
  120. sqlFactory.addParameter("itemno", itemno);
  121. sqlFactory.addParameter("length", length);
  122. sqlFactory.addParameter("width", width);
  123. sqlFactory.addParameter("sa_promotionid", sa_promotionid);
  124. sqlFactory.addParameter("sa_promotion_itemsid", sa_promotion_itemsid);
  125. sqlFactory.addParameter("tradefield", tradefield);
  126. sqlFactory.addParameter("sa_shoppingcartid", sa_shoppingcartid);
  127. sqlFactory.addParameter("sa_brandid", sa_brandid);
  128. sqlFactory.addParameter("qty", qty);
  129. sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
  130. //System.out.println(sqlFactory.getSQL());
  131. sqlList.add(sqlFactory.getSQL());
  132. }
  133. dbConnect.runSqlUpdate(sqlList);
  134. return getSucReturnObject().toString();
  135. }
  136. @API(title = "更新数量", apiversion = R.ID20220924104302.v1.class)
  137. @CACHEING_CLEAN(apiversions = {R.ID20220924095302.class})
  138. public String updateQty() throws YosException {
  139. Long sa_shoppingcartid = content.getLong("sa_shoppingcartid");
  140. BigDecimal qty = content.getBigDecimalValue("qty", 1);
  141. BigDecimal length = content.getBigDecimalValue("length");
  142. BigDecimal width = content.getBigDecimalValue("width");
  143. ArrayList<String> sqlList = new ArrayList<>();
  144. SQLFactory sqlFactory = new SQLFactory(this, "购物车更新数量");
  145. sqlFactory.addParameter("siteid", siteid);
  146. sqlFactory.addParameter("username", username);
  147. sqlFactory.addParameter("sa_shoppingcartid", sa_shoppingcartid);
  148. sqlFactory.addParameter("qty", qty);
  149. sqlFactory.addParameter("length", length);
  150. sqlFactory.addParameter("width", width);
  151. sqlList.add(sqlFactory.getSQL());
  152. //操作记录
  153. sqlList.add(DataContrlLog.createLog(this, "sa_shoppingcart", sa_shoppingcartid, "更新数量", "更新数量" + qty).getSQL());
  154. dbConnect.runSqlUpdate(sqlList);
  155. content.put("sa_shoppingcartid", sa_shoppingcartid);
  156. return queryDetail();
  157. }
  158. @API(title = "删除", apiversion = R.ID20220924095202.v1.class)
  159. @CACHEING_CLEAN(apiversions = {R.ID20220924095302.class})
  160. public String delete() throws YosException {
  161. JSONArray jsonArray = content.getJSONArray("sa_shoppingcartids");
  162. ArrayList<String> sqlList = new ArrayList<>();
  163. SQLFactory sqlFactory = new SQLFactory(this, "购物车删除");
  164. sqlFactory.addParameter_in("sa_shoppingcartid", jsonArray.toArray());
  165. sqlFactory.addParameter("siteid", siteid);
  166. sqlList.add(sqlFactory.getSQL());
  167. for (Object obj : jsonArray) {
  168. //操作记录
  169. sqlList.add(DataContrlLog.createLog(this, "sa_shoppingcart", Long.valueOf(obj.toString()), "删除", "删除" + obj).getSQL());
  170. }
  171. dbConnect.runSqlUpdate(sqlFactory);
  172. return getSucReturnObject().toString();
  173. }
  174. @API(title = "购物车列表", apiversion = R.ID20220924095302.v1.class)
  175. public String queryList() throws YosException, IOException {
  176. StringBuffer where = new StringBuffer(" 1=1 ");
  177. if (content.containsKey("where")) {
  178. JSONObject whereObject = content.getJSONObject("where");
  179. if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
  180. where.append(" and(");
  181. where.append("t1.itemno like'%").append(whereObject.getString("condition")).append("%' ");
  182. where.append("or t2.brandname like'%").append(whereObject.getString("condition")).append("%' ");
  183. where.append("or t3.itemname like'%").append(whereObject.getString("condition")).append("%' ");
  184. where.append("or t3.model like'%").append(whereObject.getString("condition")).append("%' ");
  185. where.append("or t3.spec like'%").append(whereObject.getString("condition")).append("%' ");
  186. where.append(")");
  187. }
  188. }
  189. boolean isExport = content.getBooleanValue("isExport");
  190. Long istool = content.getLongValue("istool");
  191. SQLFactory sqlFactory = new SQLFactory(this, "购物车列表", pageSize, pageNumber, pageSorting);
  192. if (isExport) {
  193. sqlFactory = new SQLFactory(this, "购物车列表");
  194. }
  195. sqlFactory.addParameter("siteid", siteid);
  196. sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
  197. sqlFactory.addParameter("sa_promotionid", content.getLongValue("sa_promotionid"));
  198. sqlFactory.addParameter("istool", istool);
  199. sqlFactory.addParameter_SQL("where", where);
  200. String sql = sqlFactory.getSQL();
  201. Rows rows = dbConnect.runSqlQuery(sql);
  202. ArrayList<Long> ids = rows.toArrayList("itemid", new ArrayList<>());
  203. //默认商品图片
  204. Rows defaultImageRows = getAttachmentUrl("system", (long) 1, "defaultImage");
  205. //附件
  206. RowsMap attRowsMap = getAttachmentUrl("plm_item", ids);
  207. //商品领域
  208. RowsMap tradefieldRowsMap = beans.Item.Item.getTradefieldRowsMap(this, ids);
  209. Rows promotionItemsRows = dbConnect.runSqlQuery("select * from sa_promotion_items where siteid='" + siteid + "' and sa_promotionid=" + content.getLongValue("sa_promotionid"));
  210. RowsMap promotionItemsRowsMap = promotionItemsRows.toRowsMap("itemid");
  211. Rows sizecustomizedschemes = dbConnect.runSqlQuery("select * from sa_sizecustomizedscheme where siteid='" + siteid + "' ");
  212. RowsMap sizecustomizedschemesRowsMap = sizecustomizedschemes.toRowsMap("sa_sizecustomizedschemeid");
  213. Rows sizeschemedetails = dbConnect.runSqlQuery("select * from sa_sizeschemedetail where siteid='" + siteid + "' ");
  214. RowsMap sizeschemedetailsRowsMap = sizeschemedetails.toRowsMap("sa_sizecustomizedschemeid");
  215. for (Row row : rows) {
  216. if ((attRowsMap.getOrDefault(row.getString("itemid"), new Rows())).isEmpty()) {
  217. row.put("attinfos", defaultImageRows);
  218. } else {
  219. row.put("attinfos", attRowsMap.getOrDefault(row.getString("itemid"), new Rows()));
  220. }
  221. try {
  222. ItemPrice itemPrice = ItemPrice.getItemPrice(this, sys_enterpriseid, row.getLong("itemid"));
  223. row.put("oldprice", istool == 0 ? itemPrice.getContractprice() : itemPrice.getMarketprice());
  224. if (content.getLongValue("sa_promotionid") > 0) {
  225. if (promotionItemsRowsMap.containsKey(row.getString("itemid"))) {
  226. if (promotionItemsRowsMap.get(row.getString("itemid")).isNotEmpty()) {
  227. row.put("orderminqty", promotionItemsRowsMap.get(row.getString("itemid")).get(0).getBigDecimal("orderminqty"));
  228. row.put("orderaddqty", promotionItemsRowsMap.get(row.getString("itemid")).get(0).getBigDecimal("orderaddqty"));
  229. }
  230. }
  231. if (row.getBoolean("iscustomsize") && row.getLong("pricingmetod") == 1) {
  232. row.put("gradeprice", itemPrice.getPromotionPrice(content.getLongValue("sa_promotionid")).multiply(row.getBigDecimal("length").multiply(row.getBigDecimal("width")).divide(new BigDecimal("1000000"), 4, BigDecimal.ROUND_HALF_UP)));
  233. } else {
  234. row.put("gradeprice", itemPrice.getPromotionPrice(content.getLongValue("sa_promotionid")));
  235. }
  236. } else {
  237. if (row.getBoolean("iscustomsize") && row.getLong("pricingmetod") == 1) {
  238. row.put("gradeprice", itemPrice.getContractprice().multiply(row.getBigDecimal("length").multiply(row.getBigDecimal("width")).divide(new BigDecimal("1000000"), 4, BigDecimal.ROUND_HALF_UP)));
  239. } else {
  240. row.put("gradeprice", itemPrice.getContractprice());
  241. }
  242. }
  243. // row.put("gradeprice", istool == 0 ?itemPrice.getContractprice():itemPrice.getMarketprice());
  244. } catch (Exception e) {
  245. e.printStackTrace();
  246. row.put("oldprice", 0);
  247. row.put("gradeprice", 0);
  248. }
  249. row.put("tradefield", tradefieldRowsMap.getOrDefault(row.getString("itemid"), new Rows()));
  250. if (row.getLong("widthschemeid") != 0) {
  251. if (sizecustomizedschemesRowsMap.containsKey(row.getString("widthschemeid"))) {
  252. if (sizecustomizedschemesRowsMap.get(row.getString("widthschemeid")).isNotEmpty()) {
  253. row.put("widthtype", sizecustomizedschemesRowsMap.get(row.getString("widthschemeid")).get(0).getString("type"));
  254. row.put("widthmin", sizecustomizedschemesRowsMap.get(row.getString("widthschemeid")).get(0).getBigDecimal("min"));
  255. row.put("widthmax", sizecustomizedschemesRowsMap.get(row.getString("widthschemeid")).get(0).getBigDecimal("max"));
  256. row.put("widthdecimalplaces", sizecustomizedschemesRowsMap.get(row.getString("widthschemeid")).get(0).getBigDecimal("decimalplaces"));
  257. if (sizeschemedetailsRowsMap.containsKey(row.getString("widthschemeid"))) {
  258. row.put("widthschemedetails", sizeschemedetailsRowsMap.get(row.getString("widthschemeid")));
  259. } else {
  260. row.put("widthschemedetails", new JSONArray());
  261. }
  262. }
  263. }
  264. } else {
  265. row.put("widthschemedetails", new JSONArray());
  266. }
  267. if (row.getLong("lengthschemeid") != 0) {
  268. if (sizecustomizedschemesRowsMap.containsKey(row.getString("lengthschemeid"))) {
  269. if (sizecustomizedschemesRowsMap.get(row.getString("lengthschemeid")).isNotEmpty()) {
  270. row.put("lengthtype", sizecustomizedschemesRowsMap.get(row.getString("lengthschemeid")).get(0).getString("type"));
  271. row.put("lengthmin", sizecustomizedschemesRowsMap.get(row.getString("lengthschemeid")).get(0).getBigDecimal("min"));
  272. row.put("lengthmax", sizecustomizedschemesRowsMap.get(row.getString("lengthschemeid")).get(0).getBigDecimal("max"));
  273. row.put("lengthdecimalplaces", sizecustomizedschemesRowsMap.get(row.getString("lengthschemeid")).get(0).getBigDecimal("decimalplaces"));
  274. if (sizeschemedetailsRowsMap.containsKey(row.getString("lengthschemeid"))) {
  275. row.put("lengthschemedetails", sizeschemedetailsRowsMap.get(row.getString("lengthschemeid")));
  276. } else {
  277. row.put("lengthschemedetails", new JSONArray());
  278. }
  279. }
  280. }
  281. } else {
  282. row.put("lengthschemedetails", new JSONArray());
  283. }
  284. //选项
  285. String materialschemeid = row.getString("materialschemeid");
  286. if (!materialschemeid.equals("0") && sizecustomizedschemesRowsMap.containsKey(materialschemeid) && sizecustomizedschemesRowsMap.get(materialschemeid).isNotEmpty()) {
  287. row.put("type", sizecustomizedschemesRowsMap.get(materialschemeid).get(0).getString("type"));
  288. row.put("min", sizecustomizedschemesRowsMap.get(materialschemeid).get(0).getBigDecimal("min"));
  289. row.put("max", sizecustomizedschemesRowsMap.get(materialschemeid).get(0).getBigDecimal("max"));
  290. row.put("decimalplaces", sizecustomizedschemesRowsMap.get(materialschemeid).get(0).getBigDecimal("decimalplaces"));
  291. if (sizeschemedetailsRowsMap.containsKey(materialschemeid)) {
  292. row.put("materialschemedetails", sizeschemedetailsRowsMap.get(materialschemeid));
  293. } else {
  294. row.put("materialschemedetails", new JSONArray());
  295. }
  296. } else {
  297. row.put("materialschemedetails", new JSONArray());
  298. }
  299. //颜色
  300. String colorschemeid = row.getString("colorschemeid");
  301. if (!colorschemeid.equals("0") && sizecustomizedschemesRowsMap.containsKey(colorschemeid) && sizecustomizedschemesRowsMap.get(colorschemeid).isNotEmpty()) {
  302. row.put("type", sizecustomizedschemesRowsMap.get(colorschemeid).get(0).getString("type"));
  303. row.put("min", sizecustomizedschemesRowsMap.get(colorschemeid).get(0).getBigDecimal("min"));
  304. row.put("max", sizecustomizedschemesRowsMap.get(colorschemeid).get(0).getBigDecimal("max"));
  305. row.put("decimalplaces", sizecustomizedschemesRowsMap.get(colorschemeid).get(0).getBigDecimal("decimalplaces"));
  306. if (sizeschemedetailsRowsMap.containsKey(colorschemeid)) {
  307. row.put("colorsschemedetails", sizeschemedetailsRowsMap.get(colorschemeid));
  308. } else {
  309. row.put("colorsschemedetails", new JSONArray());
  310. }
  311. } else {
  312. row.put("colorsschemedetails", new JSONArray());
  313. }
  314. //工艺
  315. String cheekschemeid = row.getString("cheekschemeid");
  316. if (!cheekschemeid.equals("0") && sizecustomizedschemesRowsMap.containsKey(cheekschemeid) && sizecustomizedschemesRowsMap.get(cheekschemeid).isNotEmpty()) {
  317. row.put("type", sizecustomizedschemesRowsMap.get(cheekschemeid).get(0).getString("type"));
  318. row.put("min", sizecustomizedschemesRowsMap.get(cheekschemeid).get(0).getBigDecimal("min"));
  319. row.put("max", sizecustomizedschemesRowsMap.get(cheekschemeid).get(0).getBigDecimal("max"));
  320. row.put("decimalplaces", sizecustomizedschemesRowsMap.get(cheekschemeid).get(0).getBigDecimal("decimalplaces"));
  321. if (sizeschemedetailsRowsMap.containsKey(cheekschemeid)) {
  322. row.put("cheekschemedetails", sizeschemedetailsRowsMap.get(cheekschemeid));
  323. } else {
  324. row.put("cheekschemedetails", new JSONArray());
  325. }
  326. } else {
  327. row.put("cheekschemedetails", new JSONArray());
  328. }
  329. row.put("isselect", true);
  330. }
  331. // if (isExport) {
  332. // //去除不需要导出项
  333. // String[] removeFieldList = {"sa_shoppingcartid", "sa_brandid", "itemid", "unitgroupname", "orderminqty", "orderaddqty", "orderminqty_auxunit", "orderaddqty_auxunit"};
  334. // for (String key : removeFieldList) {
  335. // rows.getFieldList().remove(key);
  336. // }
  337. //
  338. // Rows uploadRows = uploadExcelToObs("order", "订单商品明细_列表", rows, getTitleMap());
  339. // return getSucReturnObject().setData(uploadRows).toString();
  340. // }
  341. return getSucReturnObject().setData(rows).toString();
  342. }
  343. //返回导出的标题
  344. public HashMap<String, String> getTitleMap() {
  345. HashMap<String, String> titleMap = new HashMap<>();
  346. titleMap.put("qty", "数量");
  347. titleMap.put("itemno", "产品编号");
  348. titleMap.put("tradefield", "领域");
  349. titleMap.put("brandname", "品牌");
  350. titleMap.put("itemname", "产品名称");
  351. titleMap.put("model", "型号");
  352. titleMap.put("spec", "规格尺寸");
  353. titleMap.put("unitname", "主单位");
  354. titleMap.put("auxunitname", "辅助单位");
  355. return titleMap;
  356. }
  357. @API(title = "购物车数量", apiversion = R.ID20220927093202.v1.class)
  358. public String getNum() throws YosException {
  359. Rows rows = dbConnect.runSqlQuery("SELECT COUNT(0) num FROM sa_shoppingcart t1 WHERE t1.sys_enterpriseid=" + sys_enterpriseid + " AND t1.siteid= '" + siteid + "' and t1.sa_promotionid=" + content.getLongValue("sa_promotionid"));
  360. return getSucReturnObject().setData(rows.get(0)).toString();
  361. }
  362. @API(title = "详情", apiversion = R.ID20220924095402.v1.class)
  363. public String queryDetail() throws YosException {
  364. Long sa_shoppingcartid = content.getLong("sa_shoppingcartid");
  365. SQLFactory sqlFactory = new SQLFactory(this, "购物车详情", pageSize, pageNumber, pageSorting);
  366. sqlFactory.addParameter("siteid", siteid);
  367. sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
  368. sqlFactory.addParameter("sa_shoppingcartid", sa_shoppingcartid);
  369. Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
  370. ArrayList<Long> ids = rows.toArrayList("itemid", new ArrayList<>());
  371. //附件
  372. RowsMap attRowsMap = getAttachmentUrl("plm_item", ids);
  373. for (Row row : rows) {
  374. row.put("attinfos", attRowsMap.getOrDefault(row.getString("itemid"), new Rows()));
  375. try {
  376. ItemPrice itemPrice = ItemPrice.getItemPrice(this, sys_enterpriseid, row.getLong("itemid"));
  377. row.put("oldprice", itemPrice.getPrice());
  378. row.put("gradeprice", itemPrice.getGraderateprice());
  379. } catch (Exception e) {
  380. e.printStackTrace();
  381. row.put("oldprice", 0);
  382. row.put("gradeprice", 0);
  383. }
  384. }
  385. return getSucReturnObject().setData(rows.isNotEmpty() ? rows.get(0) : new Row()).toString();
  386. }
  387. }