OrderChangeApiController.java 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  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. @RestController
  20. @RequestMapping(value = "/api/admin/orderChange")
  21. public class OrderChangeApiController extends CertifyApiController {
  22. @Autowired
  23. private OrderChangeService orderChangeService;
  24. /**
  25. * 新增变更
  26. */
  27. @RequestMapping(value = "/addOrderChange", method = RequestMethod.POST)
  28. public Result addOrderChange(NewOrderChangeBo t,String startRemarks){
  29. Result res = new Result();
  30. if(null==t.getOrderNo()){
  31. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "订单编号"));
  32. return res;
  33. }
  34. if(orderChangeService.checkOderNo(t.getOrderNo())){
  35. res.getError().add(buildError( "", "订单变更未完成"));
  36. return res;
  37. }
  38. res.setData(orderChangeService.addOrderChange(t,startRemarks));
  39. return res;
  40. }
  41. @RequestMapping(value = "/addChangeTask", method = RequestMethod.POST)
  42. public Result addChangeTask(TChangeTask t){
  43. Result res = new Result();
  44. if(StringUtils.isBlank(t.getCommodityId())){
  45. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "项目"));
  46. return res;
  47. }
  48. if(null==t.getCommodityPrice()){
  49. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "项目金额"));
  50. return res;
  51. }
  52. if(null==t.getCommodityQuantity()){
  53. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "项目数量"));
  54. return res;
  55. }
  56. if(StringUtils.isBlank(t.getOrderNo())){
  57. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","订单编号"));
  58. return res;
  59. }
  60. if(null==t.getCid()){
  61. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","变更编号"));
  62. return res;
  63. }
  64. res.setData(orderChangeService.addChangeTask(t));
  65. return res;
  66. }
  67. /**
  68. * 变更项目列表
  69. * @return
  70. */
  71. @RequestMapping(value = "/selectChangeTask", method = RequestMethod.GET)
  72. public Result selectChangeTask(Integer id){
  73. Result res = new Result();
  74. if (null==id) {
  75. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","变更项目id"));
  76. return res;
  77. }
  78. res.setData(orderChangeService.selectChangeTask(id));
  79. return res;
  80. }
  81. /**
  82. * 变更催款列表
  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(InputTChangeTask 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 changeId,String remarks,Integer status,Integer processState,Integer rejectState){
  230. Result res = new Result();
  231. if(null==changeId){
  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( changeId, 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. * 首先是草稿然后发起变成审核中,再在流程中走一遍当金额小于2000总裁通过标记为通过,大于2000总裁通过不改变状态,流转到董事长,董事长审核改变
  273. * 状态为通过,通过状态下为财务退票,退票完成后改状态为上传附件,实际为营销员上传附件,营销员上传完后触发完成变更,状态才变成完成
  274. * 流程状态 0营销员 1营销管理员 2技术员 3技术经理 4技术总监 5财务专员(退单) 6财务总监 7总裁 8董事长
  275. * 状态 0草稿 1审核中 2通过 3驳回 4完成 5撤销 6上传附件
  276. */
  277. @RequestMapping(value ="/orderChangeList",method = RequestMethod.GET)
  278. public Result orderChangeList(String userName,Integer processState,Integer timeType,String startTime,String endTime,
  279. String depId,String salesmanName,Integer complete,String orderNo, String contractNo,Integer type,Integer pageSize, Integer pageNo) {
  280. Result res =new Result();
  281. res.data(orderChangeService.selectOrderChangeList( userName, processState, timeType, startTime, endTime,
  282. depId, salesmanName, complete, orderNo, contractNo, type,pageSize, pageNo));
  283. return res;
  284. }
  285. /**
  286. * 新增回收发票
  287. */
  288. @RequestMapping(value ="/addOrderRefundInvoice",method = RequestMethod.POST)
  289. public Result addOrderRefundInvoice(OrderRefundInvoice o) {
  290. Result res =new Result();
  291. if (o.getAmount()==null) {
  292. res.getError().add(buildError("金额不能为空", "金额不能为空"));
  293. return res;
  294. }
  295. res.data(orderChangeService.addOrderRefundInvoice(o));
  296. return res;
  297. }
  298. /**
  299. * 新增回收发票
  300. */
  301. @RequestMapping(value ="/getOrderChange",method = RequestMethod.GET)
  302. public Result getOrderChange(String orderNo) {
  303. Result res =new Result();
  304. if (StringUtils.isBlank(orderNo)) {
  305. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "订单编号", "订单编号"));
  306. return res;
  307. }
  308. res.data(orderChangeService.getOrderChange(orderNo));
  309. return res;
  310. }
  311. /**
  312. * 删除回收发票
  313. */
  314. @RequestMapping(value ="/deleteOrderRefundInvoice",method = RequestMethod.POST)
  315. public Result deleteOrderRefundInvoice(Integer id) {
  316. Result res =new Result();
  317. if (id==null) {
  318. res.getError().add(buildError("id不能为空", "id不能为空"));
  319. return res;
  320. }
  321. res.data(orderChangeService.deleteOrderRefundInvoice(id));
  322. return res;
  323. }
  324. /**
  325. * 回收发票列表
  326. */
  327. @RequestMapping(value ="/listOrderRefundInvoice",method = RequestMethod.GET)
  328. public Result listOrderRefundInvoice(String orderNo) {
  329. Result res =new Result();
  330. if (StringUtils.isBlank(orderNo)) {
  331. res.getError().add(buildError("订单编号不能为空", "订单编号不能为空"));
  332. return res;
  333. }
  334. res.data(orderChangeService.listOrderRefundInvoice(orderNo));
  335. return res;
  336. }
  337. /**
  338. * 回收发票列表
  339. */
  340. @RequestMapping(value ="/listOrderInvoiceAndBill",method = RequestMethod.GET)
  341. public Result listOrderInvoiceAndBill(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.listOrderInvoiceAndBill(orderNo));
  348. return res;
  349. }
  350. /**
  351. * 完成变更
  352. */
  353. @RequestMapping(value ="/completeOrderChange",method = RequestMethod.GET)
  354. public Result completeOrderChange(NewOrderChangeBo nb) {
  355. Result res =new Result();
  356. if (StringUtils.isBlank(nb.getOrderNo())||nb.getType()==null) {
  357. res.getError().add(buildError("订单编号和类型不能为空", "订单编号和类型不能为空"));
  358. return res;
  359. }
  360. res.data(orderChangeService.pushCompleteOrderChange(nb));
  361. return res;
  362. }
  363. /**
  364. * 完成变更退票
  365. */
  366. @RequestMapping(value ="/completeRefund",method = RequestMethod.GET)
  367. public Result completeRefund(NewOrderChangeBo nb) {
  368. Result res =new Result();
  369. if (nb.getId()==null) {
  370. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,ErrorConstants.PARAM_EMPTY_ERROR,"变更编号"));
  371. return res;
  372. }
  373. res.data(orderChangeService.pushCompleteRefund(nb));
  374. return res;
  375. }
  376. /**
  377. * 取消变更
  378. */
  379. @RequestMapping(value ="/cancelOrderChange",method = RequestMethod.POST)
  380. public Result cancelOrderChange(NewOrderChangeBo nb) {
  381. Result res =new Result();
  382. if (null==nb.getId()) {
  383. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "变更编号", "变更编号"));
  384. return res;
  385. }
  386. if (nb.getProcessState()!=0&&(nb.getStatus()!=0 && nb.getStatus()!=3)) {
  387. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "变更流程或状态", "变更流程或状态"));
  388. return res;
  389. }
  390. res.data(orderChangeService.updateCancelOrderChange(nb));
  391. return res;
  392. }
  393. /**
  394. * 导出变更列表
  395. *
  396. * @param response
  397. * @return
  398. */
  399. @RequestMapping(value = "/exportMyChange" , method = RequestMethod.GET)
  400. public Result exportMyBill(HttpServletResponse response,String userName,Integer processState,Integer timeType,String startTime,String endTime,
  401. String depId,String salesmanName,Integer complete,String orderNo, String contractNo,Integer type,Integer pageSize, Integer pageNo) {
  402. Result res=new Result();
  403. try {
  404. orderChangeService.exportMyChange( response, userName, processState, timeType, startTime, endTime,
  405. depId, salesmanName, complete, orderNo, contractNo, type, pageSize, pageNo);
  406. } catch (Exception e) {
  407. res.getError().add(buildError("格式不正确"));
  408. e.printStackTrace();
  409. return res;
  410. }
  411. res.data(1);
  412. return res;
  413. }
  414. /**
  415. * 变更退款图片文件上传
  416. */
  417. @RequestMapping(value = "/uploadRefund", method = RequestMethod.POST)
  418. public Result uploadRefund(HttpServletRequest req,String sign){
  419. Result res = new Result();
  420. //order_refund_file
  421. res.setData(handleFile(res, "/order_refund/", false, req, sign));
  422. return res;
  423. }
  424. /**
  425. * 变更附件文件上传
  426. */
  427. @RequestMapping(value = "/uploadChangeAttachment", method = RequestMethod.POST)
  428. public Result uploadChangeAttachment(HttpServletRequest req,String sign){
  429. Result res = new Result();
  430. res.setData(handleFile(res, "/order_change_attachment/", false, req, sign));
  431. return res;
  432. }
  433. /**
  434. * 新增退款信息
  435. */
  436. @RequestMapping(value = "/addRefund", method = RequestMethod.POST)
  437. public Result addRefund(InputNewOrderRefund or){
  438. Result res = new Result();
  439. if (or.getRefundAmount()==null) {
  440. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"金额", "金额"));
  441. return res;
  442. }
  443. if (or.getRefundDate()==null) {
  444. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"时间", "时间"));
  445. return res;
  446. }
  447. if (orderChangeService.checkrefund(or)) {
  448. res.getError().add(buildError("金额与实际收款不符", "金额与实际收款不符"));
  449. return res;
  450. }
  451. res.setData(orderChangeService.addOrderRefund(or));
  452. return res;
  453. }
  454. /**
  455. * 删除退款信息
  456. */
  457. @RequestMapping(value = "/deleteRefund", method = RequestMethod.POST)
  458. public Result deleteRefund(Integer id){
  459. Result res = new Result();
  460. res.setData(orderChangeService.deleteRefund(id));
  461. return res;
  462. }
  463. /**
  464. * 退款信息列表
  465. */
  466. @RequestMapping(value = "/listRefund", method = RequestMethod.GET)
  467. public Result listRefund(Integer id){
  468. Result res = new Result();
  469. res.setData(orderChangeService.listRefund(id));
  470. return res;
  471. }
  472. /**
  473. * 确认退款
  474. */
  475. @RequestMapping(value = "/pushRefund", method = RequestMethod.POST)
  476. public Result pushRefund(Integer id,String refundUrl){
  477. Result res = new Result();
  478. res.setData(orderChangeService.pushRefund(id,refundUrl));
  479. return res;
  480. }
  481. }