OrderChangeApiController.java 19 KB

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