| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586 |
- package com.goafanti.order.controller;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.cache.annotation.Cacheable;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.RestController;
- import com.goafanti.common.bo.Result;
- import com.goafanti.common.constant.ErrorConstants;
- import com.goafanti.common.controller.CertifyApiController;
- import com.goafanti.common.model.OrderRefundInvoice;
- import com.goafanti.common.model.TChangeDun;
- import com.goafanti.common.model.TChangeTask;
- import com.goafanti.common.utils.StringUtils;
- import com.goafanti.order.bo.InputNewOrderRefund;
- import com.goafanti.order.bo.InputTChangeTask;
- import com.goafanti.order.bo.NewOrderChangeBo;
- import com.goafanti.order.service.OrderChangeService;
- import java.io.IOException;
- import java.util.List;
- @RestController
- @RequestMapping(value = "/api/admin/orderChange")
- public class OrderChangeApiController extends CertifyApiController {
- @Autowired
- private OrderChangeService orderChangeService;
- /**
- * 新增变更、发起变更
- */
- @RequestMapping(value = "/addOrderChange", method = RequestMethod.POST)
- public Result addOrderChange(NewOrderChangeBo t,String startRemarks){
- Result res = new Result();
- if(null==t.getOrderNo()){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "订单编号"));
- return res;
- }
- if(orderChangeService.checkOderNo(t.getOrderNo())){
- res.getError().add(buildError( "", "订单变更未完成"));
- return res;
- }
- res.setData(orderChangeService.addOrderChange(t,startRemarks));
- return res;
- }
- @RequestMapping(value = "/addChangeTask", method = RequestMethod.POST)
- public Result addChangeTask(TChangeTask t){
- Result res = new Result();
- if(StringUtils.isBlank(t.getCommodityId())){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "项目"));
- return res;
- }
- if(null==t.getCommodityPrice()){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "项目金额"));
- return res;
- }
- if(null==t.getCommodityQuantity()){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "项目数量"));
- return res;
- }
- if(StringUtils.isBlank(t.getOrderNo())){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","订单编号"));
- return res;
- }
- if(null==t.getCid()){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","变更编号"));
- return res;
- }
- res.setData(orderChangeService.addChangeTask(t));
- return res;
- }
- /**
- * 变更项目列表
- * @return
- */
- @RequestMapping(value = "/selectChangeTask", method = RequestMethod.GET)
- public Result selectChangeTask(Integer id){
- Result res = new Result();
- if (null==id) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","变更项目id"));
- return res;
- }
- res.setData(orderChangeService.selectChangeTask(id));
- return res;
- }
- /**
- * 变更催款列表
- * @return
- */
- @RequestMapping(value = "/selectChangeDun", method = RequestMethod.GET)
- public Result selectChangeDun(Integer id){
- Result res = new Result();
- if (null==id) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","变更项目id"));
- return res;
- }
- res.setData(orderChangeService.selectChangeDun(id));
- return res;
- }
- /**
- * 删除变更项目
- * @param t
- * @return
- */
- @RequestMapping(value = "/deleteChangeTask", method = RequestMethod.POST)
- public Result deleteChangeTask(TChangeTask t){
- Result res = new Result();
- if (null==t.getId()) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","变更项目id"));
- return res;
- }
- res.setData(orderChangeService.deleteChangeTask(t.getId()));
- return res;
- }
- /**
- * 修改变更项目
- * @param t
- * @return
- */
- @RequestMapping(value = "/updateChangeTask", method = RequestMethod.POST)
- public Result updateChangeTask(InputTChangeTask t){
- Result res = new Result();
- if (null==t.getId()) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","变更项目id"));
- return res;
- }
- res.setData(orderChangeService.updateChangeTask(t));
- return res;
- }
- /**
- * 修改变更催款
- * @param t
- * @return
- */
- @RequestMapping(value = "/updateChangeDun", method = RequestMethod.POST)
- public Result updateChangeDun(TChangeDun t){
- Result res = new Result();
- if (null==t.getId()) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","变更任务id"));
- return res;
- }
- res.setData(orderChangeService.updateChangeDun(t));
- return res;
- }
- /**
- * 删除变更催款
- * @param t
- * @return
- */
- @RequestMapping(value = "/deleteChangeDun", method = RequestMethod.POST)
- public Result deleteChangeDun(TChangeDun t){
- Result res = new Result();
- if (null==t.getId()) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","变更任务id"));
- return res;
- }
- res.setData(orderChangeService.deleteChangeDun(t.getId()));
- return res;
- }
- @RequestMapping(value = "/addChangeDun", method = RequestMethod.POST)
- public Result addChangeDun(TChangeDun d){
- Result res = new Result();
- if(StringUtils.isBlank(d.getOrderNo())||null==d.getCtid()) {
- res.getError().add(buildError("", "订单编号与项目编号必须指定"));
- return res;
- }
- if(null==d.getProjectType()||null==d.getDunType()) {
- res.getError().add(buildError("", "项目分类和催款分类必须指定"));
- return res;
- }
- res.setData(orderChangeService.addChangeDun(d));
- return res;
- }
- /**
- * 订单查看变更列表
- */
- @RequestMapping(value = "/orderChangeDetails", method = RequestMethod.GET)
- public Result orderChangeDetails(String orderNo){
- Result res = new Result();
- if(null==orderNo){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "订单编号"));
- return res;
- }
- res.setData(orderChangeService.orderChangeDetails( orderNo));
- return res;
- }
- /**
- * 订单查看变更原订单
- */
- @RequestMapping(value = "/orderChangeUsed", method = RequestMethod.GET)
- public Result orderChangeUsed(String orderNo){
- Result res = new Result();
- if(null==orderNo){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "订单编号"));
- return res;
- }
- res.setData(orderChangeService.orderChangeUsed( orderNo));
- return res;
- }
- /**
- * id查看变更详情
- */
- @RequestMapping(value = "/orderChangeDetailsById", method = RequestMethod.GET)
- public Result orderChangeDetailsById(Integer id){
- Result res = new Result();
- if(null==id){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "订单变更编号"));
- return res;
- }
- res.setData(orderChangeService.orderChangeDetailsById( id));
- return res;
- }
- /**
- * 变更修改、修改变更
- * @param changeType 0发起修改 1财务修改
- */
- @RequestMapping(value = "/updateOrderChange", method = RequestMethod.POST)
- public Result orderChangeDetails(NewOrderChangeBo t ,Integer changeType,String startRemarks){
- Result res = new Result();
- if(null==t.getId()){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "订单变更id"));
- return res;
- }
- if (changeType==null) {
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "修改变更类型"));
- return res;
- }
- res.setData(orderChangeService.updateOrderChange(t,changeType,startRemarks));
- return res;
- }
- /**
- * 变更审核
- */
- @RequestMapping(value = "/orderChangeAudit", method = RequestMethod.POST)
- public Result orderChangeAudit(String changeId,String remarks,Integer status,Integer processState,Integer rejectState){
- Result res = new Result();
- if(null==changeId){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "订单编号", "订单编号"));
- return res;
- }
- if(null==status){//2通过 3驳回
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "审核结果", "审核结果"));
- return res;
- }
- if(null==remarks){
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "审核批示", "审核批示"));
- return res;
- }
- res.setData(orderChangeService.pushOrderChangeAudit( changeId, remarks, status, processState,rejectState));
- return res;
- }
- /**
- * 变更日志
- */
- @RequestMapping(value ="/orderChangeLogList",method = RequestMethod.GET)
- public Result orderChangeLogList(String changeId) {
- Result res =new Result();
- if (null==changeId) {
- res.getError().add(buildError("变更id错误", "变更id错误"));
- return res;
- }
- res.data(orderChangeService.selectOrderChangeLogList(changeId));
- return res;
- }
- /**
- * 变更文件上传
- */
- @RequestMapping(value = "/uploadFile", method = RequestMethod.POST)
- public Result uploadRefundOrderFile(HttpServletRequest req,String sign){
- Result res = new Result();
- //order_refund_file
- res.setData(handleFile(res, "/order_change_file/", false, req, sign));
- return res;
- }
- /**
- * 超级无语接口,变更太乱了
- * 首先是草稿然后发起变成审核中,再在流程中走一遍当金额小于2000总裁通过标记为通过,大于2000总裁通过不改变状态,流转到董事长,董事长审核改变
- * 状态为通过,通过状态下为财务退票,退票完成后改状态为上传附件,实际为营销员上传附件,营销员上传完后触发完成变更,状态才变成完成
- * 状态 0草稿 1审核中 2通过 3驳回 4完成 5撤销 6上传附件
- * @param userName
- * @param processState 流程状态 0=营销员,1=营销经理,2=营销管理员,3=技术员,4=技术经理,5=技术总监,6=财务专员,7=财务总监,8=总裁,9=董事长
- * @param timeType
- * @param startTime
- * @param endTime
- * @param salesmanName
- * @param complete
- * @param orderNo
- * @param contractNo
- * @param type
- * @param pageSize
- * @param pageNo
- * @return
- */
- @RequestMapping(value ="/orderChangeList",method = RequestMethod.GET)
- public Result orderChangeList(String userName, Integer processState, Integer timeType, String startTime, String endTime,
- String deps, String salesmanName, Integer complete, String orderNo, String contractNo, Integer type, Integer pageSize, Integer pageNo) {
- Result res =new Result();
- res.data(orderChangeService.selectOrderChangeList( userName, processState, timeType, startTime, endTime,
- deps, salesmanName, complete, orderNo, contractNo, type,pageSize, pageNo));
- return res;
- }
- /**
- * 新增回收发票
- */
- @RequestMapping(value ="/addOrderRefundInvoice",method = RequestMethod.POST)
- public Result addOrderRefundInvoice(OrderRefundInvoice o) {
- Result res =new Result();
- if (o.getAmount()==null) {
- res.getError().add(buildError("金额不能为空", "金额不能为空"));
- return res;
- }
- res.data(orderChangeService.addOrderRefundInvoice(o));
- return res;
- }
- /**
- * 新增回收发票
- */
- @RequestMapping(value ="/getOrderChange",method = RequestMethod.GET)
- public Result getOrderChange(String orderNo) {
- Result res =new Result();
- if (StringUtils.isBlank(orderNo)) {
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "订单编号", "订单编号"));
- return res;
- }
- res.data(orderChangeService.getOrderChange(orderNo));
- return res;
- }
- /**
- * 删除回收发票
- */
- @RequestMapping(value ="/deleteOrderRefundInvoice",method = RequestMethod.POST)
- public Result deleteOrderRefundInvoice(Integer id) {
- Result res =new Result();
- if (id==null) {
- res.getError().add(buildError("id不能为空", "id不能为空"));
- return res;
- }
- res.data(orderChangeService.deleteOrderRefundInvoice(id));
- return res;
- }
- /**
- * 回收发票列表
- */
- @RequestMapping(value ="/listOrderRefundInvoice",method = RequestMethod.GET)
- public Result listOrderRefundInvoice(String orderNo) {
- Result res =new Result();
- if (StringUtils.isBlank(orderNo)) {
- res.getError().add(buildError("订单编号不能为空", "订单编号不能为空"));
- return res;
- }
- res.data(orderChangeService.listOrderRefundInvoice(orderNo));
- return res;
- }
- /**
- * 回收发票列表
- */
- @RequestMapping(value ="/listOrderInvoiceAndBill",method = RequestMethod.GET)
- public Result listOrderInvoiceAndBill(String orderNo) {
- Result res =new Result();
- if (StringUtils.isBlank(orderNo)) {
- res.getError().add(buildError("订单编号不能为空", "订单编号不能为空"));
- return res;
- }
- res.data(orderChangeService.listOrderInvoiceAndBill(orderNo));
- return res;
- }
- /**
- * 完成变更、变更完成
- */
- @RequestMapping(value ="/completeOrderChange",method = RequestMethod.GET)
- public Result completeOrderChange(NewOrderChangeBo nb) {
- Result res =new Result();
- if (StringUtils.isBlank(nb.getOrderNo())||nb.getType()==null) {
- res.getError().add(buildError("订单编号和类型不能为空", "订单编号和类型不能为空"));
- return res;
- }
- if (orderChangeService.checkChangeId(nb.getId())){
- StringBuffer str=new StringBuffer("操作异常");
- str=str.append("[").append(nb.getId()).append("]").append("编号变更已经完成");
- res.getError().add(buildError(str.toString(), str.toString()));
- return res;
- }
- res.data(orderChangeService.pushCompleteOrderChange(nb));
- return res;
- }
- /**
- * 完成变更退票
- */
- @RequestMapping(value ="/completeRefund",method = RequestMethod.GET)
- public Result completeRefund(NewOrderChangeBo nb) {
- Result res =new Result();
- if (nb.getId()==null) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,ErrorConstants.PARAM_EMPTY_ERROR,"变更编号"));
- return res;
- }
- res.data(orderChangeService.pushCompleteRefund(nb));
- return res;
- }
- /**
- * 取消变更
- */
- @RequestMapping(value ="/cancelOrderChange",method = RequestMethod.POST)
- public Result cancelOrderChange(NewOrderChangeBo nb) {
- Result res =new Result();
- if (null==nb.getId()) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "变更编号", "变更编号"));
- return res;
- }
- if (nb.getProcessState()!=0&&(nb.getStatus()!=0 && nb.getStatus()!=3)) {
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "变更流程或状态", "变更流程或状态"));
- return res;
- }
- res.data(orderChangeService.updateCancelOrderChange(nb));
- return res;
- }
- /**
- * 导出变更列表
- *
- * @param response
- * @return
- */
- @RequestMapping(value = "/exportMyChange" , method = RequestMethod.GET)
- public Result exportMyBill(HttpServletResponse response,String userName,Integer processState,Integer timeType,String startTime,String endTime,
- String deps,String salesmanName,Integer complete,String orderNo, String contractNo,Integer type,Integer pageSize, Integer pageNo) {
- Result res=new Result();
- try {
- orderChangeService.exportMyChange(response,userName,processState,timeType,startTime,endTime,deps,salesmanName,complete,
- orderNo,contractNo,type,pageSize,pageNo);
- } catch (IOException e) {
- res.getError().add(buildError("格式不正确"));
- e.printStackTrace();
- return res;
- }
- res.data(1);
- return res;
- }
- /**
- * 变更退款图片文件上传
- */
- @RequestMapping(value = "/uploadRefund", method = RequestMethod.POST)
- public Result uploadRefund(HttpServletRequest req,String sign){
- Result res = new Result();
- //order_refund_file
- res.setData(handleFile(res, "/order_refund/", false, req, sign));
- return res;
- }
- /**
- * 变更附件文件上传
- */
- @RequestMapping(value = "/uploadChangeAttachment", method = RequestMethod.POST)
- public Result uploadChangeAttachment(HttpServletRequest req,String sign){
- Result res = new Result();
- res.setData(handleFile(res, "/order_change_attachment/", false, req, sign));
- return res;
- }
- /**
- * 新增退款信息
- */
- @RequestMapping(value = "/addRefund", method = RequestMethod.POST)
- public Result addRefund(InputNewOrderRefund or){
- Result res = new Result();
- if (or.getRefundAmount()==null) {
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"金额", "金额"));
- return res;
- }
- if (or.getRefundDate()==null) {
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"时间", "时间"));
- return res;
- }
- if (orderChangeService.checkrefund(or)) {
- res.getError().add(buildError("金额与实际收款不符", "金额与实际收款不符"));
- return res;
- }
- res.setData(orderChangeService.addOrderRefund(or));
- return res;
- }
- /**
- * 删除退款信息
- */
- @RequestMapping(value = "/deleteRefund", method = RequestMethod.POST)
- public Result deleteRefund(Integer id){
- Result res = new Result();
- res.setData(orderChangeService.deleteRefund(id));
- return res;
- }
- /**
- * 退款信息列表
- */
- @RequestMapping(value = "/listRefund", method = RequestMethod.GET)
- public Result listRefund(Integer id){
- Result res = new Result();
- res.setData(orderChangeService.listRefund(id));
- return res;
- }
- /**
- * 确认退款
- */
- @RequestMapping(value = "/pushRefund", method = RequestMethod.POST)
- public Result pushRefund(Integer id,String refundUrl){
- Result res = new Result();
- res.setData(orderChangeService.pushRefund(id,refundUrl));
- return res;
- }
- /**
- * 新增会员子项目
- *
- * @return
- */
- @RequestMapping(value = "/addMemberSonProject" ,method = RequestMethod.POST)
- public Result addMemberSonProject(Integer id,String serviceYear,String taskComment){
- Result res = new Result();
- if(id==null||StringUtils.isBlank(serviceYear)){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","参数"));
- return res;
- }
- return res.data(orderChangeService.addMemberSonProject( id, serviceYear, taskComment));
- }
- /**
- * 删除会员子项目
- *
- * @return
- */
- @RequestMapping(value = "/deleteMemberSonProject" ,method = RequestMethod.POST)
- public Result deleteMemberSonProject(Integer id){
- Result res = new Result();
- if(id==null){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","订单编号"));
- return res;
- }
- return res.data(orderChangeService.deleteMemberSonProject( id));
- }
- /**
- * 新增会员子项目
- *
- * @return
- */
- @RequestMapping(value = "/updateMemberSonProject" ,method = RequestMethod.POST)
- public Result updateMemberSonProject(Integer id,String taskComment){
- Result res = new Result();
- if(id==null){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","参数"));
- return res;
- }
- return res.data(orderChangeService.updateMemberSonProject( id,taskComment));
- }
- @RequestMapping(value = "/getChangeProcessName" ,method = RequestMethod.GET)
- public Result getChangeProcessName(Integer id){
- Result res = new Result();
- if(id==null){
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","变更编号"));
- return res;
- }
- return res.data(orderChangeService.gerProcessName( id));
- }
- }
|