OrderChangeApiController.java 17 KB

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