aftersalesmag.java 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package restcontroller.webmanage.lsak3.aftersalesmag;
  2. import com.alibaba.fastjson.JSONArray;
  3. import com.alibaba.fastjson.JSONObject;
  4. import common.Controller;
  5. import common.YosException;
  6. import common.annotation.API;
  7. import common.data.Row;
  8. import common.data.Rows;
  9. import restcontroller.R;
  10. import java.util.ArrayList;
  11. public class aftersalesmag extends Controller {
  12. /**
  13. * 构造函数
  14. *
  15. * @param content
  16. */
  17. public aftersalesmag(JSONObject content) throws YosException {
  18. super(content);
  19. }
  20. /**
  21. * 获取DRP返退单
  22. *
  23. * @return
  24. */
  25. @API(title = "获取DRP返退单", apiversion = R.ID20230715093903.v1.class,accesstoken = false)
  26. public String getAftersalesmag() throws YosException{
  27. Rows rows = dbConnect.runSqlQuery("select t2.k3outcode fk3outcode,t1.updatek3flag fupdatek3flag,t1.sa_aftersalesmagid salereturnbillid,t1.billno fbillnum,t1.createby,t1.billdate fdate,t2.agentnum fagentnum,t1.reason fnotes from sa_aftersalesmag t1 inner join sa_agents t2 on t1.sys_enterpriseid=t2.sys_enterpriseid and t1.siteid=t2.siteid where (t1.updatek3flag='0' or t1.updatek3flag='2') and t1.createby !='LSA总0001' and t1.siteid='lsa1986'");
  28. for (Row row : rows) {
  29. String sa_aftersalesmagid = row.getString("sa_aftersalesmagid");
  30. Rows detailRows = dbConnect.runSqlQuery("select t2.k3outcode fk3outcode,t1.st_stockbill_itemsid salereturnbilldeid,t2.itemno fitemno,t1.qty fqty,t1.price fprice,t1.reason fnotes,t4.billno fsaleissuebillno, t3.rowno fsaleissuebillentryid from sa_aftersalesmag_items t1 inner join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid left join st_stockbill_items t3 on t1.st_stockbill_itemsid=t3.st_stockbill_itemsid and t1.siteid=t3.siteid left join st_stockbill t4 on t3.st_stockbillid=t4.st_stockbillid and t3.siteid=t4.siteid where t1.sa_aftersalesmagid='" + sa_aftersalesmagid + "' and t1.siteid='lsa1986'");
  31. row.put("salereturnbilldetil", detailRows.toJsonArray());
  32. }
  33. if(rows.isEmpty()) {
  34. JSONArray array = new JSONArray();
  35. return array.toString();
  36. }
  37. return rows.toJsonArray().toString();
  38. }
  39. /**
  40. * 获取DRP返退单返回成功消息
  41. *
  42. * @return
  43. */
  44. @API(title = "获取DRP返退单返回成功消息", apiversion = R.ID20230715094003.v1.class,accesstoken = false)
  45. public String getAftersalesmagFeedBack() throws YosException{
  46. JSONArray idsarray = content.getJSONArray("ids");
  47. ArrayList<String> sqllist = new ArrayList<>();
  48. for (Object object:idsarray) {
  49. String id = (String) object;
  50. sqllist.add("update sa_aftersalesmag set updatek3flag='1' where siteid='lsa' and sa_aftersalesmagid=" + id);
  51. }
  52. int count =dbConnect.runSqlUpdate(sqllist);
  53. JSONObject returnObject =new JSONObject();
  54. if (count>0) {
  55. returnObject.put("msg", "");
  56. returnObject.put("code", 1);
  57. } else {
  58. returnObject.put("msg", "true");
  59. returnObject.put("code", 0);
  60. }
  61. return returnObject.toString();
  62. }
  63. }