OrderChangeApiController.java 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. package com.goafanti.order.controller;
  2. import javax.servlet.http.HttpServletRequest;
  3. import javax.servlet.http.HttpServletResponse;
  4. import org.springframework.beans.factory.annotation.Autowired;
  5. import org.springframework.web.bind.annotation.RequestMapping;
  6. import org.springframework.web.bind.annotation.RequestMethod;
  7. import org.springframework.web.bind.annotation.RestController;
  8. import com.goafanti.common.bo.Result;
  9. import com.goafanti.common.constant.ErrorConstants;
  10. import com.goafanti.common.controller.CertifyApiController;
  11. import com.goafanti.common.model.OrderRefundInvoice;
  12. import com.goafanti.common.model.TChangeDun;
  13. import com.goafanti.common.model.TChangeTask;
  14. import com.goafanti.common.utils.StringUtils;
  15. import com.goafanti.order.bo.NewOrderChangeBo;
  16. import com.goafanti.order.service.OrderChangeService;
  17. @RestController
  18. @RequestMapping(value = "/api/admin/orderChange")
  19. public class OrderChangeApiController extends CertifyApiController {
  20. @Autowired
  21. private OrderChangeService orderChangeService;
  22. /**
  23. * 新增变更
  24. */
  25. @RequestMapping(value = "/addOrderChange", method = RequestMethod.POST)
  26. public Result addOrderChange(NewOrderChangeBo t,String startRemarks){
  27. Result res = new Result();
  28. if(null==t.getOrderNo()){
  29. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "订单编号"));
  30. return res;
  31. }
  32. if(orderChangeService.checkOderNo(t.getOrderNo())){
  33. res.getError().add(buildError( "", "订单变更未完成"));
  34. return res;
  35. }
  36. res.setData(orderChangeService.addOrderChange(t,startRemarks));
  37. return res;
  38. }
  39. @RequestMapping(value = "/addChangeTask", method = RequestMethod.POST)
  40. public Result addChangeTask(TChangeTask t){
  41. Result res = new Result();
  42. if(StringUtils.isBlank(t.getCommodityId())){
  43. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "项目"));
  44. return res;
  45. }
  46. if(null==t.getCommodityPrice()){
  47. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "项目金额"));
  48. return res;
  49. }
  50. if(null==t.getCommodityQuantity()){
  51. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "项目数量"));
  52. return res;
  53. }
  54. if(StringUtils.isBlank(t.getOrderNo())){
  55. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","订单编号"));
  56. return res;
  57. }
  58. if(null==t.getCid()){
  59. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","变更编号"));
  60. return res;
  61. }
  62. res.setData(orderChangeService.addChangeTask(t));
  63. return res;
  64. }
  65. /**
  66. * 变更项目列表
  67. * @param t
  68. * @return
  69. */
  70. @RequestMapping(value = "/selectChangeTask", method = RequestMethod.GET)
  71. public Result selectChangeTask(Integer id){
  72. Result res = new Result();
  73. if (null==id) {
  74. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","变更项目id"));
  75. return res;
  76. }
  77. res.setData(orderChangeService.selectChangeTask(id));
  78. return res;
  79. }
  80. /**
  81. * 变更催款列表
  82. * @param t
  83. * @return
  84. */
  85. @RequestMapping(value = "/selectChangeDun", method = RequestMethod.GET)
  86. public Result selectChangeDun(Integer id){
  87. Result res = new Result();
  88. if (null==id) {
  89. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","变更项目id"));
  90. return res;
  91. }
  92. res.setData(orderChangeService.selectChangeDun(id));
  93. return res;
  94. }
  95. /**
  96. * 删除变更项目
  97. * @param t
  98. * @return
  99. */
  100. @RequestMapping(value = "/deleteChangeTask", method = RequestMethod.POST)
  101. public Result deleteChangeTask(TChangeTask t){
  102. Result res = new Result();
  103. if (null==t.getId()) {
  104. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","变更项目id"));
  105. return res;
  106. }
  107. res.setData(orderChangeService.deleteChangeTask(t.getId()));
  108. return res;
  109. }
  110. /**
  111. * 修改变更项目
  112. * @param t
  113. * @return
  114. */
  115. @RequestMapping(value = "/updateChangeTask", method = RequestMethod.POST)
  116. public Result updateChangeTask(TChangeTask t){
  117. Result res = new Result();
  118. if (null==t.getId()) {
  119. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","变更项目id"));
  120. return res;
  121. }
  122. res.setData(orderChangeService.updateChangeTask(t));
  123. return res;
  124. }
  125. /**
  126. * 修改变更催款
  127. * @param t
  128. * @return
  129. */
  130. @RequestMapping(value = "/updateChangeDun", method = RequestMethod.POST)
  131. public Result updateChangeDun(TChangeDun t){
  132. Result res = new Result();
  133. if (null==t.getId()) {
  134. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","变更任务id"));
  135. return res;
  136. }
  137. res.setData(orderChangeService.updateChangeDun(t));
  138. return res;
  139. }
  140. /**
  141. * 删除变更催款
  142. * @param t
  143. * @return
  144. */
  145. @RequestMapping(value = "/deleteChangeDun", method = RequestMethod.POST)
  146. public Result deleteChangeDun(TChangeDun t){
  147. Result res = new Result();
  148. if (null==t.getId()) {
  149. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","变更任务id"));
  150. return res;
  151. }
  152. res.setData(orderChangeService.deleteChangeDun(t.getId()));
  153. return res;
  154. }
  155. @RequestMapping(value = "/addChangeDun", method = RequestMethod.POST)
  156. public Result addChangeDun(TChangeDun d){
  157. Result res = new Result();
  158. if(StringUtils.isBlank(d.getOrderNo())||null==d.getCtid()) {
  159. res.getError().add(buildError("", "订单编号与项目编号必须指定"));
  160. return res;
  161. }
  162. if(null==d.getProjectType()||null==d.getDunType()) {
  163. res.getError().add(buildError("", "项目分类和催款分类必须指定"));
  164. return res;
  165. }
  166. res.setData(orderChangeService.addChangeDun(d));
  167. return res;
  168. }
  169. /**
  170. * 订单查看变更列表
  171. */
  172. @RequestMapping(value = "/orderChangeDetails", method = RequestMethod.GET)
  173. public Result orderChangeDetails(String orderNo){
  174. Result res = new Result();
  175. if(null==orderNo){
  176. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "订单编号"));
  177. return res;
  178. }
  179. res.setData(orderChangeService.orderChangeDetails( orderNo));
  180. return res;
  181. }
  182. /**
  183. * 订单查看变更原订单
  184. */
  185. @RequestMapping(value = "/orderChangeUsed", method = RequestMethod.GET)
  186. public Result orderChangeUsed(String orderNo){
  187. Result res = new Result();
  188. if(null==orderNo){
  189. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "订单编号"));
  190. return res;
  191. }
  192. res.setData(orderChangeService.orderChangeUsed( orderNo));
  193. return res;
  194. }
  195. /**
  196. * id查看变更详情
  197. */
  198. @RequestMapping(value = "/orderChangeDetailsById", method = RequestMethod.GET)
  199. public Result orderChangeDetailsById(Integer id){
  200. Result res = new Result();
  201. if(null==id){
  202. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "订单变更编号"));
  203. return res;
  204. }
  205. res.setData(orderChangeService.orderChangeDetailsById( id));
  206. return res;
  207. }
  208. /**
  209. * 变更修改
  210. */
  211. @RequestMapping(value = "/updateOrderChange", method = RequestMethod.POST)
  212. public Result orderChangeDetails(NewOrderChangeBo t ,Integer changeType,String startRemarks){
  213. Result res = new Result();
  214. if(null==t.getId()){
  215. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "订单变更id"));
  216. return res;
  217. }
  218. if (changeType==null) {
  219. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "修改变更类型"));
  220. return res;
  221. }
  222. res.setData(orderChangeService.updateOrderChange(t,changeType,startRemarks));
  223. return res;
  224. }
  225. /**
  226. * 变更审核
  227. */
  228. @RequestMapping(value = "/orderChangeAudit", method = RequestMethod.POST)
  229. public Result orderChangeAudit(String orderNo,String remarks,Integer status,Integer processState,Integer rejectState){
  230. Result res = new Result();
  231. if(null==orderNo){
  232. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "订单编号", "订单编号"));
  233. return res;
  234. }
  235. if(null==status){//2通过 3驳回
  236. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "审核结果", "审核结果"));
  237. return res;
  238. }
  239. if(null==remarks){
  240. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "审核批示", "审核批示"));
  241. return res;
  242. }
  243. res.setData(orderChangeService.pushOrderChangeAudit( orderNo, remarks, status, processState,rejectState));
  244. return res;
  245. }
  246. /**
  247. * 变更日志
  248. */
  249. @RequestMapping(value ="/orderChangeLogList",method = RequestMethod.GET)
  250. public Result orderChangeLogList(String changeId) {
  251. Result res =new Result();
  252. if (null==changeId) {
  253. res.getError().add(buildError("变更id错误", "变更id错误"));
  254. return res;
  255. }
  256. res.data(orderChangeService.selectOrderChangeLogList(changeId));
  257. return res;
  258. }
  259. /**
  260. * 变更文件上传
  261. */
  262. @RequestMapping(value = "/uploadFile", method = RequestMethod.POST)
  263. public Result uploadRefundOrderFile(HttpServletRequest req,String sign){
  264. Result res = new Result();
  265. //order_refund_file
  266. res.setData(handleFile(res, "/order_change_file/", false, req, sign));
  267. return res;
  268. }
  269. /**
  270. * 变更列表
  271. */
  272. @RequestMapping(value ="/orderChangeList",method = RequestMethod.GET)
  273. public Result orderChangeList(String userName,Integer processState,Integer timeType,String startTime,String endTime,
  274. String depId,String salesmanName,Integer complete,String orderNo, String contractNo,Integer type,Integer pageSize, Integer pageNo) {
  275. Result res =new Result();
  276. res.data(orderChangeService.selectOrderChangeList( userName, processState, timeType, startTime, endTime,
  277. depId, salesmanName, complete, orderNo, contractNo, type,pageSize, pageNo));
  278. return res;
  279. }
  280. /**
  281. * 新增回收发票
  282. */
  283. @RequestMapping(value ="/addOrderRefundInvoice",method = RequestMethod.POST)
  284. public Result addOrderRefundInvoice(OrderRefundInvoice o) {
  285. Result res =new Result();
  286. if (o.getAmount()==null) {
  287. res.getError().add(buildError("金额不能为空", "金额不能为空"));
  288. return res;
  289. }
  290. res.data(orderChangeService.addOrderRefundInvoice(o));
  291. return res;
  292. }
  293. /**
  294. * 新增回收发票
  295. */
  296. @RequestMapping(value ="/getOrderChange",method = RequestMethod.GET)
  297. public Result getOrderChange(String orderNo) {
  298. Result res =new Result();
  299. if (StringUtils.isBlank(orderNo)) {
  300. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "订单编号", "订单编号"));
  301. return res;
  302. }
  303. res.data(orderChangeService.getOrderChange(orderNo));
  304. return res;
  305. }
  306. /**
  307. * 删除回收发票
  308. */
  309. @RequestMapping(value ="/deleteOrderRefundInvoice",method = RequestMethod.POST)
  310. public Result deleteOrderRefundInvoice(Integer id) {
  311. Result res =new Result();
  312. if (id==null) {
  313. res.getError().add(buildError("id不能为空", "id不能为空"));
  314. return res;
  315. }
  316. res.data(orderChangeService.deleteOrderRefundInvoice(id));
  317. return res;
  318. }
  319. /**
  320. * 回收发票列表
  321. */
  322. @RequestMapping(value ="/listOrderRefundInvoice",method = RequestMethod.GET)
  323. public Result listOrderRefundInvoice(String orderNo) {
  324. Result res =new Result();
  325. if (StringUtils.isBlank(orderNo)) {
  326. res.getError().add(buildError("订单编号不能为空", "订单编号不能为空"));
  327. return res;
  328. }
  329. res.data(orderChangeService.listOrderRefundInvoice(orderNo));
  330. return res;
  331. }
  332. /**
  333. * 回收发票列表
  334. */
  335. @RequestMapping(value ="/listOrderInvoiceAndBill",method = RequestMethod.GET)
  336. public Result listOrderInvoiceAndBill(String orderNo) {
  337. Result res =new Result();
  338. if (StringUtils.isBlank(orderNo)) {
  339. res.getError().add(buildError("订单编号不能为空", "订单编号不能为空"));
  340. return res;
  341. }
  342. res.data(orderChangeService.listOrderInvoiceAndBill(orderNo));
  343. return res;
  344. }
  345. /**
  346. * 完成变更
  347. */
  348. @RequestMapping(value ="/completeOrderChange",method = RequestMethod.GET)
  349. public Result completeOrderChange(NewOrderChangeBo nb) {
  350. Result res =new Result();
  351. if (StringUtils.isBlank(nb.getOrderNo())||nb.getType()==null) {
  352. res.getError().add(buildError("订单编号和类型不能为空", "订单编号和类型不能为空"));
  353. return res;
  354. }
  355. res.data(orderChangeService.pushCompleteOrderChange(nb));
  356. return res;
  357. }
  358. /**
  359. * 导出变更列表
  360. *
  361. * @param response
  362. * @return
  363. */
  364. @RequestMapping(value = "/exportMyChange" , method = RequestMethod.GET)
  365. public Result exportMyBill(HttpServletResponse response,String userName,Integer processState,Integer timeType,String startTime,String endTime,
  366. String depId,String salesmanName,Integer complete,String orderNo, String contractNo,Integer type,Integer pageSize, Integer pageNo) {
  367. Result res=new Result();
  368. try {
  369. orderChangeService.exportMyChange( response, userName, processState, timeType, startTime, endTime,
  370. depId, salesmanName, complete, orderNo, contractNo, type, pageSize, pageNo);
  371. } catch (Exception e) {
  372. res.getError().add(buildError("格式不正确"));
  373. e.printStackTrace();
  374. return res;
  375. }
  376. res.data(1);
  377. return res;
  378. }
  379. }