OrderChangeApiController.java 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  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.InputNewOrderRefund;
  16. import com.goafanti.order.bo.InputTChangeTask;
  17. import com.goafanti.order.bo.NewOrderChangeBo;
  18. import com.goafanti.order.service.OrderChangeService;
  19. import java.io.IOException;
  20. import java.util.List;
  21. @RestController
  22. @RequestMapping(value = "/api/admin/orderChange")
  23. public class OrderChangeApiController extends CertifyApiController {
  24. @Autowired
  25. private OrderChangeService orderChangeService;
  26. /**
  27. * 新增变更
  28. */
  29. @RequestMapping(value = "/addOrderChange", method = RequestMethod.POST)
  30. public Result addOrderChange(NewOrderChangeBo t,String startRemarks){
  31. Result res = new Result();
  32. if(null==t.getOrderNo()){
  33. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "订单编号"));
  34. return res;
  35. }
  36. if(orderChangeService.checkOderNo(t.getOrderNo())){
  37. res.getError().add(buildError( "", "订单变更未完成"));
  38. return res;
  39. }
  40. res.setData(orderChangeService.addOrderChange(t,startRemarks));
  41. return res;
  42. }
  43. @RequestMapping(value = "/addChangeTask", method = RequestMethod.POST)
  44. public Result addChangeTask(TChangeTask t){
  45. Result res = new Result();
  46. if(StringUtils.isBlank(t.getCommodityId())){
  47. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "项目"));
  48. return res;
  49. }
  50. if(null==t.getCommodityPrice()){
  51. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "项目金额"));
  52. return res;
  53. }
  54. if(null==t.getCommodityQuantity()){
  55. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "项目数量"));
  56. return res;
  57. }
  58. if(StringUtils.isBlank(t.getOrderNo())){
  59. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","订单编号"));
  60. return res;
  61. }
  62. if(null==t.getCid()){
  63. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","变更编号"));
  64. return res;
  65. }
  66. res.setData(orderChangeService.addChangeTask(t));
  67. return res;
  68. }
  69. /**
  70. * 变更项目列表
  71. * @return
  72. */
  73. @RequestMapping(value = "/selectChangeTask", method = RequestMethod.GET)
  74. public Result selectChangeTask(Integer id){
  75. Result res = new Result();
  76. if (null==id) {
  77. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","变更项目id"));
  78. return res;
  79. }
  80. res.setData(orderChangeService.selectChangeTask(id));
  81. return res;
  82. }
  83. /**
  84. * 变更催款列表
  85. * @return
  86. */
  87. @RequestMapping(value = "/selectChangeDun", method = RequestMethod.GET)
  88. public Result selectChangeDun(Integer id){
  89. Result res = new Result();
  90. if (null==id) {
  91. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","变更项目id"));
  92. return res;
  93. }
  94. res.setData(orderChangeService.selectChangeDun(id));
  95. return res;
  96. }
  97. /**
  98. * 删除变更项目
  99. * @param t
  100. * @return
  101. */
  102. @RequestMapping(value = "/deleteChangeTask", method = RequestMethod.POST)
  103. public Result deleteChangeTask(TChangeTask t){
  104. Result res = new Result();
  105. if (null==t.getId()) {
  106. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","变更项目id"));
  107. return res;
  108. }
  109. res.setData(orderChangeService.deleteChangeTask(t.getId()));
  110. return res;
  111. }
  112. /**
  113. * 修改变更项目
  114. * @param t
  115. * @return
  116. */
  117. @RequestMapping(value = "/updateChangeTask", method = RequestMethod.POST)
  118. public Result updateChangeTask(InputTChangeTask t){
  119. Result res = new Result();
  120. if (null==t.getId()) {
  121. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","变更项目id"));
  122. return res;
  123. }
  124. res.setData(orderChangeService.updateChangeTask(t));
  125. return res;
  126. }
  127. /**
  128. * 修改变更催款
  129. * @param t
  130. * @return
  131. */
  132. @RequestMapping(value = "/updateChangeDun", method = RequestMethod.POST)
  133. public Result updateChangeDun(TChangeDun t){
  134. Result res = new Result();
  135. if (null==t.getId()) {
  136. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","变更任务id"));
  137. return res;
  138. }
  139. res.setData(orderChangeService.updateChangeDun(t));
  140. return res;
  141. }
  142. /**
  143. * 删除变更催款
  144. * @param t
  145. * @return
  146. */
  147. @RequestMapping(value = "/deleteChangeDun", method = RequestMethod.POST)
  148. public Result deleteChangeDun(TChangeDun t){
  149. Result res = new Result();
  150. if (null==t.getId()) {
  151. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","变更任务id"));
  152. return res;
  153. }
  154. res.setData(orderChangeService.deleteChangeDun(t.getId()));
  155. return res;
  156. }
  157. @RequestMapping(value = "/addChangeDun", method = RequestMethod.POST)
  158. public Result addChangeDun(TChangeDun d){
  159. Result res = new Result();
  160. if(StringUtils.isBlank(d.getOrderNo())||null==d.getCtid()) {
  161. res.getError().add(buildError("", "订单编号与项目编号必须指定"));
  162. return res;
  163. }
  164. if(null==d.getProjectType()||null==d.getDunType()) {
  165. res.getError().add(buildError("", "项目分类和催款分类必须指定"));
  166. return res;
  167. }
  168. res.setData(orderChangeService.addChangeDun(d));
  169. return res;
  170. }
  171. /**
  172. * 订单查看变更列表
  173. */
  174. @RequestMapping(value = "/orderChangeDetails", method = RequestMethod.GET)
  175. public Result orderChangeDetails(String orderNo){
  176. Result res = new Result();
  177. if(null==orderNo){
  178. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "订单编号"));
  179. return res;
  180. }
  181. res.setData(orderChangeService.orderChangeDetails( orderNo));
  182. return res;
  183. }
  184. /**
  185. * 订单查看变更原订单
  186. */
  187. @RequestMapping(value = "/orderChangeUsed", method = RequestMethod.GET)
  188. public Result orderChangeUsed(String orderNo){
  189. Result res = new Result();
  190. if(null==orderNo){
  191. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "订单编号"));
  192. return res;
  193. }
  194. res.setData(orderChangeService.orderChangeUsed( orderNo));
  195. return res;
  196. }
  197. /**
  198. * id查看变更详情
  199. */
  200. @RequestMapping(value = "/orderChangeDetailsById", method = RequestMethod.GET)
  201. public Result orderChangeDetailsById(Integer id){
  202. Result res = new Result();
  203. if(null==id){
  204. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "订单变更编号"));
  205. return res;
  206. }
  207. res.setData(orderChangeService.orderChangeDetailsById( id));
  208. return res;
  209. }
  210. /**
  211. * 变更修改
  212. */
  213. @RequestMapping(value = "/updateOrderChange", method = RequestMethod.POST)
  214. public Result orderChangeDetails(NewOrderChangeBo t ,Integer changeType,String startRemarks){
  215. Result res = new Result();
  216. if(null==t.getId()){
  217. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "订单变更id"));
  218. return res;
  219. }
  220. if (changeType==null) {
  221. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "修改变更类型"));
  222. return res;
  223. }
  224. res.setData(orderChangeService.updateOrderChange(t,changeType,startRemarks));
  225. return res;
  226. }
  227. /**
  228. * 变更审核
  229. */
  230. @RequestMapping(value = "/orderChangeAudit", method = RequestMethod.POST)
  231. public Result orderChangeAudit(String changeId,String remarks,Integer status,Integer processState,Integer rejectState){
  232. Result res = new Result();
  233. if(null==changeId){
  234. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "订单编号", "订单编号"));
  235. return res;
  236. }
  237. if(null==status){//2通过 3驳回
  238. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "审核结果", "审核结果"));
  239. return res;
  240. }
  241. if(null==remarks){
  242. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "审核批示", "审核批示"));
  243. return res;
  244. }
  245. res.setData(orderChangeService.pushOrderChangeAudit( changeId, remarks, status, processState,rejectState));
  246. return res;
  247. }
  248. /**
  249. * 变更日志
  250. */
  251. @RequestMapping(value ="/orderChangeLogList",method = RequestMethod.GET)
  252. public Result orderChangeLogList(String changeId) {
  253. Result res =new Result();
  254. if (null==changeId) {
  255. res.getError().add(buildError("变更id错误", "变更id错误"));
  256. return res;
  257. }
  258. res.data(orderChangeService.selectOrderChangeLogList(changeId));
  259. return res;
  260. }
  261. /**
  262. * 变更文件上传
  263. */
  264. @RequestMapping(value = "/uploadFile", method = RequestMethod.POST)
  265. public Result uploadRefundOrderFile(HttpServletRequest req,String sign){
  266. Result res = new Result();
  267. //order_refund_file
  268. res.setData(handleFile(res, "/order_change_file/", false, req, sign));
  269. return res;
  270. }
  271. /**
  272. * 超级无语接口,变更太乱了
  273. * 首先是草稿然后发起变成审核中,再在流程中走一遍当金额小于2000总裁通过标记为通过,大于2000总裁通过不改变状态,流转到董事长,董事长审核改变
  274. * 状态为通过,通过状态下为财务退票,退票完成后改状态为上传附件,实际为营销员上传附件,营销员上传完后触发完成变更,状态才变成完成
  275. * 状态 0草稿 1审核中 2通过 3驳回 4完成 5撤销 6上传附件
  276. * @param userName
  277. * @param processState 流程状态 0营销员 1营销管理员 2技术员 3技术经理 4技术总监 5财务专员(退单) 6财务总监 7总裁 8董事长
  278. * @param timeType
  279. * @param startTime
  280. * @param endTime
  281. * @param salesmanName
  282. * @param complete
  283. * @param orderNo
  284. * @param contractNo
  285. * @param type
  286. * @param pageSize
  287. * @param pageNo
  288. * @return
  289. */
  290. @RequestMapping(value ="/orderChangeList",method = RequestMethod.GET)
  291. public Result orderChangeList(String userName, Integer processState, Integer timeType, String startTime, String endTime,
  292. String deps, String salesmanName, Integer complete, String orderNo, String contractNo, Integer type, Integer pageSize, Integer pageNo) {
  293. Result res =new Result();
  294. res.data(orderChangeService.selectOrderChangeList( userName, processState, timeType, startTime, endTime,
  295. deps, salesmanName, complete, orderNo, contractNo, type,pageSize, pageNo));
  296. return res;
  297. }
  298. /**
  299. * 新增回收发票
  300. */
  301. @RequestMapping(value ="/addOrderRefundInvoice",method = RequestMethod.POST)
  302. public Result addOrderRefundInvoice(OrderRefundInvoice o) {
  303. Result res =new Result();
  304. if (o.getAmount()==null) {
  305. res.getError().add(buildError("金额不能为空", "金额不能为空"));
  306. return res;
  307. }
  308. res.data(orderChangeService.addOrderRefundInvoice(o));
  309. return res;
  310. }
  311. /**
  312. * 新增回收发票
  313. */
  314. @RequestMapping(value ="/getOrderChange",method = RequestMethod.GET)
  315. public Result getOrderChange(String orderNo) {
  316. Result res =new Result();
  317. if (StringUtils.isBlank(orderNo)) {
  318. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "订单编号", "订单编号"));
  319. return res;
  320. }
  321. res.data(orderChangeService.getOrderChange(orderNo));
  322. return res;
  323. }
  324. /**
  325. * 删除回收发票
  326. */
  327. @RequestMapping(value ="/deleteOrderRefundInvoice",method = RequestMethod.POST)
  328. public Result deleteOrderRefundInvoice(Integer id) {
  329. Result res =new Result();
  330. if (id==null) {
  331. res.getError().add(buildError("id不能为空", "id不能为空"));
  332. return res;
  333. }
  334. res.data(orderChangeService.deleteOrderRefundInvoice(id));
  335. return res;
  336. }
  337. /**
  338. * 回收发票列表
  339. */
  340. @RequestMapping(value ="/listOrderRefundInvoice",method = RequestMethod.GET)
  341. public Result listOrderRefundInvoice(String orderNo) {
  342. Result res =new Result();
  343. if (StringUtils.isBlank(orderNo)) {
  344. res.getError().add(buildError("订单编号不能为空", "订单编号不能为空"));
  345. return res;
  346. }
  347. res.data(orderChangeService.listOrderRefundInvoice(orderNo));
  348. return res;
  349. }
  350. /**
  351. * 回收发票列表
  352. */
  353. @RequestMapping(value ="/listOrderInvoiceAndBill",method = RequestMethod.GET)
  354. public Result listOrderInvoiceAndBill(String orderNo) {
  355. Result res =new Result();
  356. if (StringUtils.isBlank(orderNo)) {
  357. res.getError().add(buildError("订单编号不能为空", "订单编号不能为空"));
  358. return res;
  359. }
  360. res.data(orderChangeService.listOrderInvoiceAndBill(orderNo));
  361. return res;
  362. }
  363. /**
  364. * 完成变更、变更完成
  365. */
  366. @RequestMapping(value ="/completeOrderChange",method = RequestMethod.GET)
  367. public Result completeOrderChange(NewOrderChangeBo nb) {
  368. Result res =new Result();
  369. if (StringUtils.isBlank(nb.getOrderNo())||nb.getType()==null) {
  370. res.getError().add(buildError("订单编号和类型不能为空", "订单编号和类型不能为空"));
  371. return res;
  372. }
  373. if (orderChangeService.checkChangeId(nb.getId())){
  374. StringBuffer str=new StringBuffer("操作异常");
  375. str=str.append("[").append(nb.getId()).append("]").append("编号变更已经完成");
  376. res.getError().add(buildError(str.toString(), str.toString()));
  377. return res;
  378. }
  379. res.data(orderChangeService.pushCompleteOrderChange(nb));
  380. return res;
  381. }
  382. /**
  383. * 完成变更退票
  384. */
  385. @RequestMapping(value ="/completeRefund",method = RequestMethod.GET)
  386. public Result completeRefund(NewOrderChangeBo nb) {
  387. Result res =new Result();
  388. if (nb.getId()==null) {
  389. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,ErrorConstants.PARAM_EMPTY_ERROR,"变更编号"));
  390. return res;
  391. }
  392. res.data(orderChangeService.pushCompleteRefund(nb));
  393. return res;
  394. }
  395. /**
  396. * 取消变更
  397. */
  398. @RequestMapping(value ="/cancelOrderChange",method = RequestMethod.POST)
  399. public Result cancelOrderChange(NewOrderChangeBo nb) {
  400. Result res =new Result();
  401. if (null==nb.getId()) {
  402. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "变更编号", "变更编号"));
  403. return res;
  404. }
  405. if (nb.getProcessState()!=0&&(nb.getStatus()!=0 && nb.getStatus()!=3)) {
  406. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "变更流程或状态", "变更流程或状态"));
  407. return res;
  408. }
  409. res.data(orderChangeService.updateCancelOrderChange(nb));
  410. return res;
  411. }
  412. /**
  413. * 导出变更列表
  414. *
  415. * @param response
  416. * @return
  417. */
  418. @RequestMapping(value = "/exportMyChange" , method = RequestMethod.GET)
  419. public Result exportMyBill(HttpServletResponse response,String userName,Integer processState,Integer timeType,String startTime,String endTime,
  420. String deps,String salesmanName,Integer complete,String orderNo, String contractNo,Integer type,Integer pageSize, Integer pageNo) {
  421. Result res=new Result();
  422. try {
  423. orderChangeService.exportMyChange(response,userName,processState,timeType,startTime,endTime,deps,salesmanName,complete,
  424. orderNo,contractNo,type,pageSize,pageNo);
  425. } catch (IOException e) {
  426. res.getError().add(buildError("格式不正确"));
  427. e.printStackTrace();
  428. return res;
  429. }
  430. res.data(1);
  431. return res;
  432. }
  433. /**
  434. * 变更退款图片文件上传
  435. */
  436. @RequestMapping(value = "/uploadRefund", method = RequestMethod.POST)
  437. public Result uploadRefund(HttpServletRequest req,String sign){
  438. Result res = new Result();
  439. //order_refund_file
  440. res.setData(handleFile(res, "/order_refund/", false, req, sign));
  441. return res;
  442. }
  443. /**
  444. * 变更附件文件上传
  445. */
  446. @RequestMapping(value = "/uploadChangeAttachment", method = RequestMethod.POST)
  447. public Result uploadChangeAttachment(HttpServletRequest req,String sign){
  448. Result res = new Result();
  449. res.setData(handleFile(res, "/order_change_attachment/", false, req, sign));
  450. return res;
  451. }
  452. /**
  453. * 新增退款信息
  454. */
  455. @RequestMapping(value = "/addRefund", method = RequestMethod.POST)
  456. public Result addRefund(InputNewOrderRefund or){
  457. Result res = new Result();
  458. if (or.getRefundAmount()==null) {
  459. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"金额", "金额"));
  460. return res;
  461. }
  462. if (or.getRefundDate()==null) {
  463. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"时间", "时间"));
  464. return res;
  465. }
  466. if (orderChangeService.checkrefund(or)) {
  467. res.getError().add(buildError("金额与实际收款不符", "金额与实际收款不符"));
  468. return res;
  469. }
  470. res.setData(orderChangeService.addOrderRefund(or));
  471. return res;
  472. }
  473. /**
  474. * 删除退款信息
  475. */
  476. @RequestMapping(value = "/deleteRefund", method = RequestMethod.POST)
  477. public Result deleteRefund(Integer id){
  478. Result res = new Result();
  479. res.setData(orderChangeService.deleteRefund(id));
  480. return res;
  481. }
  482. /**
  483. * 退款信息列表
  484. */
  485. @RequestMapping(value = "/listRefund", method = RequestMethod.GET)
  486. public Result listRefund(Integer id){
  487. Result res = new Result();
  488. res.setData(orderChangeService.listRefund(id));
  489. return res;
  490. }
  491. /**
  492. * 确认退款
  493. */
  494. @RequestMapping(value = "/pushRefund", method = RequestMethod.POST)
  495. public Result pushRefund(Integer id,String refundUrl){
  496. Result res = new Result();
  497. res.setData(orderChangeService.pushRefund(id,refundUrl));
  498. return res;
  499. }
  500. }