InquiryForBuyerController.java 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. package com.uas.ps.inquiry.controller;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.uas.ps.inquiry.entity.InquiryDetailInfo;
  4. import com.uas.ps.inquiry.entity.InquiryProductInfo;
  5. import com.uas.ps.inquiry.model.PublicInquiryItem;
  6. import com.uas.ps.inquiry.model.PurcInquiry;
  7. import com.uas.ps.inquiry.model.PurcInquiryItemInfo;
  8. import com.uas.ps.inquiry.page.PageInfo;
  9. import com.uas.ps.inquiry.page.SearchFilter;
  10. import com.uas.ps.inquiry.service.InquiryService;
  11. import com.uas.ps.inquiry.service.PublicInquiryService;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.data.domain.Page;
  14. import org.springframework.data.domain.Sort;
  15. import org.springframework.web.bind.annotation.RequestBody;
  16. import org.springframework.web.bind.annotation.RequestMapping;
  17. import org.springframework.web.bind.annotation.RequestMethod;
  18. import org.springframework.web.bind.annotation.RestController;
  19. /**
  20. * 针对买家,对询价的操作
  21. *
  22. * Created by hejq on 2018-01-17.
  23. */
  24. @RequestMapping("/inquiry/buyer")
  25. @RestController
  26. public class InquiryForBuyerController {
  27. @Autowired
  28. private InquiryService inquiryService;
  29. /**
  30. * 作为买家,保存更新公共询价单
  31. *
  32. * @param inquiry 询价信息
  33. * @return
  34. */
  35. @RequestMapping(value = "/save", method = RequestMethod.POST)
  36. public String saveInquiry(@RequestBody PurcInquiry inquiry) throws Exception {
  37. inquiry = inquiryService.saveInquiry(inquiry);
  38. if (null != inquiry.getId()) {
  39. return JSONObject.toJSONString(inquiry);
  40. } else {
  41. throw new Exception("保存失败");
  42. }
  43. }
  44. /**
  45. * 通过明细id对供应商报价进行审核操作
  46. *
  47. * @param id 报价明细id
  48. * @param status 状态
  49. * @return
  50. * @throws Exception
  51. */
  52. @RequestMapping(value = "/decide", method = RequestMethod.POST)
  53. public void decideQuote(Long id, Short status) throws Exception {
  54. inquiryService.decideQuote(id, status);
  55. }
  56. /**
  57. * 客户查询供应商报价详情
  58. *
  59. * @param id 报价主表id
  60. * @param enuu 企业UU
  61. * @return
  62. */
  63. @RequestMapping(value = "/detail", method = RequestMethod.GET)
  64. public InquiryDetailInfo findById(Long id, Long enuu) {
  65. return inquiryService.findById(id, enuu);
  66. }
  67. /**
  68. * 通过企业UU和分页参数获取已发布的询价信息
  69. *
  70. * @param pageInfo 分页参数
  71. * @param searchFilter 过滤条件
  72. * @return
  73. */
  74. @RequestMapping(value = "/inquiryList", method = RequestMethod.GET)
  75. public Page<PurcInquiry> getInquiry(PageInfo pageInfo, SearchFilter searchFilter) {
  76. if (pageInfo.getOffset() == 0) {
  77. pageInfo.setOffset(pageInfo.getPageSize() * (pageInfo.getPageNumber() - 1));
  78. }
  79. Sort sort = new Sort(Sort.Direction.DESC, "date");
  80. if (pageInfo.getPageNumber() == 0) {
  81. pageInfo.setPageNumber(1);
  82. }
  83. if (pageInfo.getPageSize() == 0) {
  84. pageInfo.setPageSize(5);
  85. }
  86. pageInfo.setSort(sort);
  87. if (null != searchFilter.getUserUU()) {
  88. pageInfo.filter("recorderUU", searchFilter.getUserUU());
  89. } else if (null != searchFilter.getEnUU()) {
  90. pageInfo.filter("enUU", searchFilter.getEnUU());
  91. } else {
  92. throw new IllegalAccessError("非法访问");
  93. }
  94. return inquiryService.findByPageInfo(pageInfo, searchFilter);
  95. }
  96. /**
  97. * 通过企业UU和分页参数获取已发布的询价信息
  98. *
  99. * @param pageInfo 分页参数
  100. * @param searchFilter 过滤条件
  101. * @param state 过滤状态
  102. * @param overdue 是否过期 1、过期;0、 未过期
  103. * @return
  104. */
  105. @RequestMapping(value = "/list", method = RequestMethod.GET)
  106. public Page<PurcInquiryItemInfo> getInquiryList(PageInfo pageInfo, SearchFilter searchFilter, String state, Integer overdue) {
  107. Sort sort = new Sort(Sort.Direction.DESC, "date");
  108. if (pageInfo.getOffset() == 0) {
  109. pageInfo.setOffset(pageInfo.getPageSize() * (pageInfo.getPageNumber() - 1));
  110. }
  111. pageInfo.setSort(sort);
  112. if (null != searchFilter.getUserUU()) {
  113. pageInfo.filter("userUU", searchFilter.getUserUU());
  114. } else if (null != searchFilter.getEnUU()) {
  115. pageInfo.filter("inquiry.enUU", searchFilter.getEnUU());
  116. } else {
  117. throw new IllegalAccessError("非法访问");
  118. }
  119. return inquiryService.findTodoByPageInfo(pageInfo, searchFilter, state, overdue);
  120. }
  121. /**
  122. * 针对客户查询单个物料明细的报价情况
  123. *
  124. * @param id 来源id
  125. * @param enuu 当前企业UU
  126. * @return
  127. */
  128. @RequestMapping(value = "/product/detail", method = RequestMethod.GET)
  129. public InquiryProductInfo findInquiryDetailById(Long id, Long enuu) {
  130. return inquiryService.findInquiryDetailById(id, enuu);
  131. }
  132. }