OrderChangeApiController.java 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  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.AFTConstants;
  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.enums.ProcessStatus;
  20. import com.goafanti.order.service.OrderChangeService;
  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. * @param t
  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. * @param t
  87. * @return
  88. */
  89. @RequestMapping(value = "/selectChangeDun", method = RequestMethod.GET)
  90. public Result selectChangeDun(Integer id){
  91. Result res = new Result();
  92. if (null==id) {
  93. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","变更项目id"));
  94. return res;
  95. }
  96. res.setData(orderChangeService.selectChangeDun(id));
  97. return res;
  98. }
  99. /**
  100. * 删除变更项目
  101. * @param t
  102. * @return
  103. */
  104. @RequestMapping(value = "/deleteChangeTask", method = RequestMethod.POST)
  105. public Result deleteChangeTask(TChangeTask t){
  106. Result res = new Result();
  107. if (null==t.getId()) {
  108. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","变更项目id"));
  109. return res;
  110. }
  111. res.setData(orderChangeService.deleteChangeTask(t.getId()));
  112. return res;
  113. }
  114. /**
  115. * 修改变更项目
  116. * @param t
  117. * @return
  118. */
  119. @RequestMapping(value = "/updateChangeTask", method = RequestMethod.POST)
  120. public Result updateChangeTask(InputTChangeTask t){
  121. Result res = new Result();
  122. if (null==t.getId()) {
  123. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","变更项目id"));
  124. return res;
  125. }
  126. res.setData(orderChangeService.updateChangeTask(t));
  127. return res;
  128. }
  129. /**
  130. * 修改变更催款
  131. * @param t
  132. * @return
  133. */
  134. @RequestMapping(value = "/updateChangeDun", method = RequestMethod.POST)
  135. public Result updateChangeDun(TChangeDun t){
  136. Result res = new Result();
  137. if (null==t.getId()) {
  138. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","变更任务id"));
  139. return res;
  140. }
  141. res.setData(orderChangeService.updateChangeDun(t));
  142. return res;
  143. }
  144. /**
  145. * 删除变更催款
  146. * @param t
  147. * @return
  148. */
  149. @RequestMapping(value = "/deleteChangeDun", method = RequestMethod.POST)
  150. public Result deleteChangeDun(TChangeDun t){
  151. Result res = new Result();
  152. if (null==t.getId()) {
  153. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","变更任务id"));
  154. return res;
  155. }
  156. res.setData(orderChangeService.deleteChangeDun(t.getId()));
  157. return res;
  158. }
  159. @RequestMapping(value = "/addChangeDun", method = RequestMethod.POST)
  160. public Result addChangeDun(TChangeDun d){
  161. Result res = new Result();
  162. if(StringUtils.isBlank(d.getOrderNo())||null==d.getCtid()) {
  163. res.getError().add(buildError("", "订单编号与项目编号必须指定"));
  164. return res;
  165. }
  166. if(null==d.getProjectType()||null==d.getDunType()) {
  167. res.getError().add(buildError("", "项目分类和催款分类必须指定"));
  168. return res;
  169. }
  170. res.setData(orderChangeService.addChangeDun(d));
  171. return res;
  172. }
  173. /**
  174. * 订单查看变更列表
  175. */
  176. @RequestMapping(value = "/orderChangeDetails", method = RequestMethod.GET)
  177. public Result orderChangeDetails(String orderNo){
  178. Result res = new Result();
  179. if(null==orderNo){
  180. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "订单编号"));
  181. return res;
  182. }
  183. res.setData(orderChangeService.orderChangeDetails( orderNo));
  184. return res;
  185. }
  186. /**
  187. * 订单查看变更原订单
  188. */
  189. @RequestMapping(value = "/orderChangeUsed", method = RequestMethod.GET)
  190. public Result orderChangeUsed(String orderNo){
  191. Result res = new Result();
  192. if(null==orderNo){
  193. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "订单编号"));
  194. return res;
  195. }
  196. res.setData(orderChangeService.orderChangeUsed( orderNo));
  197. return res;
  198. }
  199. /**
  200. * id查看变更详情
  201. */
  202. @RequestMapping(value = "/orderChangeDetailsById", method = RequestMethod.GET)
  203. public Result orderChangeDetailsById(Integer id){
  204. Result res = new Result();
  205. if(null==id){
  206. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "订单变更编号"));
  207. return res;
  208. }
  209. res.setData(orderChangeService.orderChangeDetailsById( id));
  210. return res;
  211. }
  212. /**
  213. * 变更修改
  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. */
  276. @RequestMapping(value ="/orderChangeList",method = RequestMethod.GET)
  277. public Result orderChangeList(String userName,Integer processState,Integer timeType,String startTime,String endTime,
  278. String depId,String salesmanName,Integer complete,String orderNo, String contractNo,Integer type,Integer pageSize, Integer pageNo) {
  279. Result res =new Result();
  280. res.data(orderChangeService.selectOrderChangeList( userName, processState, timeType, startTime, endTime,
  281. depId, salesmanName, complete, orderNo, contractNo, type,pageSize, pageNo));
  282. return res;
  283. }
  284. /**
  285. * 新增回收发票
  286. */
  287. @RequestMapping(value ="/addOrderRefundInvoice",method = RequestMethod.POST)
  288. public Result addOrderRefundInvoice(OrderRefundInvoice o) {
  289. Result res =new Result();
  290. if (o.getAmount()==null) {
  291. res.getError().add(buildError("金额不能为空", "金额不能为空"));
  292. return res;
  293. }
  294. res.data(orderChangeService.addOrderRefundInvoice(o));
  295. return res;
  296. }
  297. /**
  298. * 新增回收发票
  299. */
  300. @RequestMapping(value ="/getOrderChange",method = RequestMethod.GET)
  301. public Result getOrderChange(String orderNo) {
  302. Result res =new Result();
  303. if (StringUtils.isBlank(orderNo)) {
  304. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "订单编号", "订单编号"));
  305. return res;
  306. }
  307. res.data(orderChangeService.getOrderChange(orderNo));
  308. return res;
  309. }
  310. /**
  311. * 删除回收发票
  312. */
  313. @RequestMapping(value ="/deleteOrderRefundInvoice",method = RequestMethod.POST)
  314. public Result deleteOrderRefundInvoice(Integer id) {
  315. Result res =new Result();
  316. if (id==null) {
  317. res.getError().add(buildError("id不能为空", "id不能为空"));
  318. return res;
  319. }
  320. res.data(orderChangeService.deleteOrderRefundInvoice(id));
  321. return res;
  322. }
  323. /**
  324. * 回收发票列表
  325. */
  326. @RequestMapping(value ="/listOrderRefundInvoice",method = RequestMethod.GET)
  327. public Result listOrderRefundInvoice(String orderNo) {
  328. Result res =new Result();
  329. if (StringUtils.isBlank(orderNo)) {
  330. res.getError().add(buildError("订单编号不能为空", "订单编号不能为空"));
  331. return res;
  332. }
  333. res.data(orderChangeService.listOrderRefundInvoice(orderNo));
  334. return res;
  335. }
  336. /**
  337. * 回收发票列表
  338. */
  339. @RequestMapping(value ="/listOrderInvoiceAndBill",method = RequestMethod.GET)
  340. public Result listOrderInvoiceAndBill(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.listOrderInvoiceAndBill(orderNo));
  347. return res;
  348. }
  349. /**
  350. * 完成变更
  351. */
  352. @RequestMapping(value ="/completeOrderChange",method = RequestMethod.GET)
  353. public Result completeOrderChange(NewOrderChangeBo nb) {
  354. Result res =new Result();
  355. if (StringUtils.isBlank(nb.getOrderNo())||nb.getType()==null) {
  356. res.getError().add(buildError("订单编号和类型不能为空", "订单编号和类型不能为空"));
  357. return res;
  358. }
  359. res.data(orderChangeService.pushCompleteOrderChange(nb));
  360. return res;
  361. }
  362. /**
  363. * 取消变更
  364. */
  365. @RequestMapping(value ="/cancelOrderChange",method = RequestMethod.POST)
  366. public Result cancelOrderChange(NewOrderChangeBo nb) {
  367. Result res =new Result();
  368. if (null==nb.getId()) {
  369. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "变更编号", "变更编号"));
  370. return res;
  371. }
  372. if (nb.getProcessState()!=0&&(nb.getStatus()!=0 && nb.getStatus()!=3)) {
  373. res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "变更流程或状态", "变更流程或状态"));
  374. return res;
  375. }
  376. res.data(orderChangeService.updateCancelOrderChange(nb));
  377. return res;
  378. }
  379. /**
  380. * 导出变更列表
  381. *
  382. * @param response
  383. * @return
  384. */
  385. @RequestMapping(value = "/exportMyChange" , method = RequestMethod.GET)
  386. public Result exportMyBill(HttpServletResponse response,String userName,Integer processState,Integer timeType,String startTime,String endTime,
  387. String depId,String salesmanName,Integer complete,String orderNo, String contractNo,Integer type,Integer pageSize, Integer pageNo) {
  388. Result res=new Result();
  389. try {
  390. orderChangeService.exportMyChange( response, userName, processState, timeType, startTime, endTime,
  391. depId, salesmanName, complete, orderNo, contractNo, type, pageSize, pageNo);
  392. } catch (Exception e) {
  393. res.getError().add(buildError("格式不正确"));
  394. e.printStackTrace();
  395. return res;
  396. }
  397. res.data(1);
  398. return res;
  399. }
  400. /**
  401. * 变更退款图片文件上传
  402. */
  403. @RequestMapping(value = "/uploadRefund", method = RequestMethod.POST)
  404. public Result uploadRefund(HttpServletRequest req,String sign){
  405. Result res = new Result();
  406. //order_refund_file
  407. res.setData(handleFile(res, "/order_refund/", false, req, sign));
  408. return res;
  409. }
  410. /**
  411. * 新增退款信息
  412. */
  413. @RequestMapping(value = "/addRefund", method = RequestMethod.POST)
  414. public Result addRefund(InputNewOrderRefund or){
  415. Result res = new Result();
  416. if (or.getRefundAmount()==null) {
  417. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"金额", "金额"));
  418. return res;
  419. }
  420. if (or.getRefundDate()==null) {
  421. res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"时间", "时间"));
  422. return res;
  423. }
  424. if (orderChangeService.checkrefund(or)) {
  425. res.getError().add(buildError("金额与实际收款不符", "金额与实际收款不符"));
  426. return res;
  427. }
  428. res.setData(orderChangeService.addOrderRefund(or));
  429. return res;
  430. }
  431. /**
  432. * 删除退款信息
  433. */
  434. @RequestMapping(value = "/deleteRefund", method = RequestMethod.POST)
  435. public Result deleteRefund(Integer id){
  436. Result res = new Result();
  437. res.setData(orderChangeService.deleteRefund(id));
  438. return res;
  439. }
  440. /**
  441. * 退款信息列表
  442. */
  443. @RequestMapping(value = "/listRefund", method = RequestMethod.GET)
  444. public Result listRefund(Integer id){
  445. Result res = new Result();
  446. res.setData(orderChangeService.listRefund(id));
  447. return res;
  448. }
  449. /**
  450. * 确认退款
  451. */
  452. @RequestMapping(value = "/pushRefund", method = RequestMethod.POST)
  453. public Result pushRefund(Integer id,String refundUrl){
  454. Result res = new Result();
  455. res.setData(orderChangeService.pushRefund(id,refundUrl));
  456. return res;
  457. }
  458. }