OrderController.java 33.4 KB
Newer Older
苗卫卫 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704
package com.boco.nbd.wios.manage.controller;

import cn.hutool.core.lang.Assert;
import com.boco.nbd.cams.core.constant.CamsConstant;
import com.boco.nbd.cams.core.constant.MessageConstant;
import com.boco.nbd.framework.common.ResponseMessage2;
import com.boco.nbd.wios.flow.entity.SecretPhone;
import com.boco.nbd.wios.flow.entity.bo.SapStatisticsBO;
import com.boco.nbd.wios.flow.util.ProcessUtil;
import com.boco.nbd.wios.manage.contants.WiosConstant;
import com.boco.nbd.wios.manage.entity.bo.*;
import com.boco.nbd.wios.manage.entity.common.bo.UploadFile;
import com.boco.nbd.wios.manage.service.impl.OrderService;
import com.boco.nbd.wios.manage.service.impl.SecretPhoneService;
import com.boco.nbd.wios.manage.util.CommonUtils;
import com.ihidea.component.api.v2.BaseResponse;
import com.ihidea.core.support.exception.ServiceException;
import com.ihidea.core.support.session.SessionInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

/**
 * 订单管理接口
 *
 * @author xgl
 * @version [版本号, 2020年9月22日]
 */
@RestController
@RequestMapping("api")
@Api(tags = "订单管理接口")
@ApiIgnore
public class OrderController {

    @Autowired
    private OrderService orderService;

    @Autowired
    private SecretPhoneService spService;

    private static final String OEM_TYPE = "oemType";

    private static final String OEM_ID = "oemId";

    /**
     * 添加订单
     *
     * @param order
     * @return
     */
    @PostMapping(value = "order/add")
    @ApiOperation(value = "添加订单信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "invoiceTimeStr", value = "发票日期", dataType = "String", paramType = "query", required = false),})
    public BaseResponse<Object> add(Order order, String invoiceTimeStr) {
        Assert.notNull(order.getRegionId(), "区域不能为空");
        Assert.notNull(order.getId(), "订单id不能为空");
        Assert.notNull(order.getOemId(), "主机厂id不能为空");

        if (!StringUtils.isEmpty(invoiceTimeStr)) {
            OrderBo orderBo = new OrderBo();
            orderBo.setInvoiceTimeStr(invoiceTimeStr);
            order.setInvoiceTime(orderBo.getInvoiceTime());
        }

        //如果是经销商用户新增订单初始化经销商信息
        SessionInfo sessionInfo = ProcessUtil.getUserInfo();
        if (sessionInfo != null && WiosConstant.OEM_AGENT_TYPE.equals(sessionInfo.getAttribute().get(OEM_TYPE))) {
            order.setOemAgentId(Integer.valueOf(sessionInfo.getAttribute().get(OEM_ID)));
            orderService.add(order);
        }
        return new BaseResponse<>();
    }

    /**
     * 修改订单
     *
     * @param order
     * @return
     */
    @PostMapping(value = "order/update")
    @ApiOperation(value = "修改订单信息")
    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "订单id", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "oemId", value = "经销商id", dataType = "String", paramType = "query", required = false),
            @ApiImplicitParam(name = "outOrderId", value = "安装单号", dataType = "String", paramType = "query", required = false),
            @ApiImplicitParam(name = "userName", value = "车主姓名", dataType = "String", paramType = "query", required = false),
            @ApiImplicitParam(name = "userPhone", value = "车主电话", dataType = "String", paramType = "query", required = false),
            @ApiImplicitParam(name = "regionId", value = "区域id", dataType = "String", paramType = "query", required = false),
            @ApiImplicitParam(name = "wallboxModel", value = "墙盒型号", dataType = "String", paramType = "query", required = false),
            @ApiImplicitParam(name = "itemModel", value = "墙盒设备型号", dataType = "String", paramType = "query", required = false),})
    public BaseResponse<Object> update(Order order, String invoiceTimeStr) {
        Assert.notNull(order.getId(), "订单id不能为空");

        if (!StringUtils.isEmpty(invoiceTimeStr)) {
            OrderBo orderBo = new OrderBo();
            orderBo.setInvoiceTimeStr(invoiceTimeStr);
            order.setInvoiceTime(orderBo.getInvoiceTime());
        }
        orderService.update(order.getId(), order);
        return new BaseResponse<>();
    }

    /**
     * 批量添加订单
     *
     * @param orderJson
     * @return
     */
    @PostMapping(value = "order/batchAdd")
    @ApiOperation(value = "批量添加订单信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "orderJson", value = "订单列表json", dataType = "String", paramType = "query", required = true),})
    public BaseResponse<Object> batchAdd(String orderJson) {
        Assert.notEmpty(orderJson, "参数不能为空");
        orderService.batchAdd(orderJson);
        return new BaseResponse<>();
    }

    /**
     * 派单
     *
     * @param orderId
     * @param supplierId
     * @return
     */
    @PostMapping(value = "order/dispatch")
    @ApiOperation(value = "派单")
    @ApiImplicitParams({@ApiImplicitParam(name = "orderId", value = "订单id", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "supplierId", value = "服务商id", dataType = "int", paramType = "query", required = true),})
    public BaseResponse<Object> dispatch(String orderId, Integer supplierId) {
        if (StringUtils.isEmpty(orderId) || supplierId == null) {
            throw new ServiceException(MessageConstant.MISSING_PARAM);
        }
        orderService.dispatchOrder(orderId, supplierId);
        return new BaseResponse<>();
    }

    /**
     * 查询订单列表
     *
     * @param condition
     * @return
     */
    @GetMapping(value = "order/all")
    @ApiOperation(value = "查询订单列表")
    @ApiImplicitParams({@ApiImplicitParam(name = "page", value = "一页显示数量", dataType = "int", paramType = "query", required = false),
            @ApiImplicitParam(name = "pagecount", value = "页码", dataType = "int", paramType = "query", required = false),
            @ApiImplicitParam(name = "oemId", value = "经销商id", dataType = "int", paramType = "query", required = false),
            @ApiImplicitParam(name = "id", value = "订单号", dataType = "String", paramType = "query", required = false),
            @ApiImplicitParam(name = "outOrderId", value = "第三方订单号", dataType = "String", paramType = "query", required = false),
            @ApiImplicitParam(name = "regionId", value = "区域id", dataType = "int", paramType = "query", required = false),
            @ApiImplicitParam(name = "userName", value = "车主姓名", dataType = "String", paramType = "query", required = false),
            @ApiImplicitParam(name = "userPhone", value = "车主手机号", dataType = "String", paramType = "query", required = false),
            @ApiImplicitParam(name = "oemName", value = "经销商名称", dataType = "String", paramType = "query", required = false),
            @ApiImplicitParam(name = "supplierName", value = "服务商名称", dataType = "String", paramType = "query", required = false),
            @ApiImplicitParam(name = "oemAgentInfo", value = "经销商信息", dataType = "String", paramType = "query", required = false),
            @ApiImplicitParam(name = "wallboxNo", value = "墙盒设备编号", dataType = "String", paramType = "query", required = false),})
    public BaseResponse<List<OrderVo>> getAll(OrderBo condition) {
        return new BaseResponse<>(orderService.getList(condition));
    }

    /**
     * 转派勘察
     *
     * @param orderId
     * @param staffId
     */
    @PostMapping(value = "order/survey")
    @ApiOperation(value = "转派勘察")
    @ApiImplicitParams({@ApiImplicitParam(name = "orderId", value = "订单id", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "staffId", value = "电工id", dataType = "int", paramType = "query", required = true),})
    public BaseResponse<Object> selectStaff(String orderId, Integer staffId) {
        if (StringUtils.isEmpty(orderId) || staffId == null) {
            throw new ServiceException(MessageConstant.MISSING_PARAM);
        }
        orderService.selectStaff(orderId, staffId);
        return new BaseResponse<>();
    }

    /**
     * 更换电工
     *
     * @param orderId
     * @param staffId
     */
    @PostMapping(value = "order/changeStaff")
    @ApiOperation(value = "更换电工")
    @ApiImplicitParams({@ApiImplicitParam(name = "orderId", value = "订单id", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "staffId", value = "电工id", dataType = "int", paramType = "query", required = true),})
    public BaseResponse<Object> updateStaff(String orderId, Integer staffId) {
        if (StringUtils.isEmpty(orderId) || staffId == null) {
            throw new ServiceException(MessageConstant.MISSING_PARAM);
        }
        orderService.updateStaff(orderId, staffId);
        return new BaseResponse<>();
    }

    /**
     * 更换安装服务商
     *
     * @param orderId
     * @param supplierId
     */
    @PostMapping(value = "order/changeSupplier")
    @ApiOperation(value = "更换安装服务商")
    @ApiImplicitParams({@ApiImplicitParam(name = "orderId", value = "订单id", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "supplierId", value = "安装服务商id", dataType = "int", paramType = "query", required = true),})
    public BaseResponse<Object> updateInstallSupplier(String orderId, Integer supplierId) {
        if (StringUtils.isEmpty(orderId) || supplierId == null) {
            throw new ServiceException(MessageConstant.MISSING_PARAM);
        }
        orderService.updateInstallSupplier(orderId, supplierId);
        return new BaseResponse<>();
    }

    /**
     * 更新订单状态
     *
     * @param orderId
     * @param status
     */
    @PostMapping(value = "order/updateStatus")
    @ApiOperation(value = "更新订单状态")
    @ApiImplicitParams({@ApiImplicitParam(name = "orderId", value = "订单id", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "status", value = "订单状态", dataType = "int", paramType = "query", required = true),})
    public BaseResponse<Object> updateStatus(String orderId, Integer status) {
        if (StringUtils.isEmpty(orderId) || status == null) {
            throw new ServiceException(MessageConstant.MISSING_PARAM);
        }
        orderService.updateStatus(orderId, status);
        return new BaseResponse<>();
    }

    @PostMapping(value = "order/addRemark")
    @ApiOperation(value = "添加订单备注")
    @ApiImplicitParams({@ApiImplicitParam(name = "orderId", value = "订单id", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "remark", value = "备注", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "nextTime", value = "下次更新时间", dataType = "String", paramType = "query", required = false),
            @ApiImplicitParam(name = "tag", value = "标签", dataType = "String", paramType = "query", required = false),})
    public BaseResponse<Object> updateSurveyRemark(String orderId, String remark, String nextTime, String tag) {
        if (StringUtils.isEmpty(orderId) || StringUtils.isEmpty(remark)) {
            throw new ServiceException(MessageConstant.MISSING_PARAM);
        }
        orderService.addRemark(orderId, remark, nextTime, tag);
        return new BaseResponse<>();
    }

    @GetMapping(value = "order/getRemark")
    @ApiOperation(value = "查询订单备注")
    @ApiImplicitParams({@ApiImplicitParam(name = "orderId", value = "订单id", dataType = "String", paramType = "query", required = true),})
    public BaseResponse<List<OperateLog>> getRemark(String orderId) {
        if (StringUtils.isEmpty(orderId)) {
            throw new ServiceException(MessageConstant.MISSING_PARAM);
        }
        List<OperateLog> list = orderService.getRemark(orderId);
        return new BaseResponse<>(list);
    }

    /**
     * 关闭订单
     *
     * @param orderId
     * @param closeReason
     */
    @PostMapping(value = "order/close")
    @ApiOperation(value = "关闭订单")
    @ApiImplicitParams({@ApiImplicitParam(name = "orderId", value = "订单id", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "closeReason", value = "关闭原因", dataType = "String", paramType = "query", required = true),})
    public BaseResponse<Object> closeOrder(String orderId, String closeReason) {
        if (StringUtils.isEmpty(orderId) || StringUtils.isEmpty(closeReason)) {
            throw new ServiceException(MessageConstant.MISSING_PARAM);
        }
        orderService.closeOrder(orderId, closeReason);
        return new BaseResponse<>();
    }

    /**
     * 报装
     *
     * @param orderId
     * @param expandStatus
     * @param expandFailReason
     * @param expandFailOperate
     */
    @PostMapping(value = "order/expand")
    @ApiOperation(value = "报装")
    @ApiImplicitParams({@ApiImplicitParam(name = "orderId", value = "订单id", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "expandStatus", value = "报装状态 1:通过 2:不通过", dataType = "int", paramType = "query", required = true),
            @ApiImplicitParam(name = "expandFailReason", value = "报装不通过原因", dataType = "String", paramType = "query", required = false),
            @ApiImplicitParam(name = "expandFailOperate", value = "报装不通过后订单后续操作", dataType = "int", paramType = "query", required = false),})
    public BaseResponse<Object> expand(String orderId, Integer expandStatus, String expandFailReason, Integer expandFailOperate) {
        if (StringUtils.isEmpty(orderId) || expandStatus == null) {
            throw new ServiceException(MessageConstant.MISSING_PARAM);
        }
        orderService.expand(orderId, expandStatus, expandFailReason, expandFailOperate);
        return new BaseResponse<>();
    }

    /**
     * 预约勘察
     *
     * @param orderId
     * @param surveyReserveTime
     * @param surveyClientName
     * @param surveyClientPhone
     * @param surveyCamsPhone
     */
    @PostMapping(value = "order/reserveSurvey")
    @ApiOperation(value = "预约勘察")
    @ApiImplicitParams({@ApiImplicitParam(name = "orderId", value = "订单id", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "surveyReserveTime", value = "预约时间yyyy-MM-dd HH:mm:ss", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "surveyClientName", value = "勘察客户姓名", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "surveyClientPhone", value = "勘察客户手机号", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "surveyCamsPhone", value = "注册CAMS PLUS 手机号", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "surveyReserveRemark", value = "备注", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "surveyReserveStatus", value = "0-预约失败,1:预约成功", dataType = "int", paramType = "query", required = true),
            @ApiImplicitParam(name = "surveyFollowTime", value = "下次跟进时间yyyy-MM-dd HH:mm:ss", dataType = "String", paramType = "query", required = true),})
    public BaseResponse<Object> reserveSurvey(String orderId, String surveyReserveTime, String surveyClientName, String surveyClientPhone,
                                              String surveyCamsPhone, String surveyReserveRemark, int surveyReserveStatus, String surveyFollowTime) {
        Assert.notNull(surveyReserveStatus, "预约状态不能为空");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date = null;
        Date followDate = null;
        if (surveyReserveStatus == 1) {
            try {
                date = sdf.parse(surveyReserveTime);
            } catch (ParseException e) {
                throw new ServiceException("日期格式错误");
            }
        } else {
            try {
                followDate = sdf.parse(surveyFollowTime);
            } catch (ParseException e) {
                throw new ServiceException("日期格式错误");
            }
        }

        orderService.reserveSurvey(orderId, date, surveyClientName, surveyClientPhone, surveyCamsPhone, surveyReserveRemark, surveyReserveStatus, followDate);
        return new BaseResponse<>();
    }

    /**
     * 预约安装
     *
     * @param orderId
     * @param installReserveTime
     * @param installClientName
     * @param installClientPhone
     * @param installCamsPhone
     */
    @PostMapping(value = "order/reserveInstall")
    @ApiOperation(value = "预约安装")
    @ApiImplicitParams({@ApiImplicitParam(name = "orderId", value = "订单id", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "installReserveTime", value = "安装预约时间yyyy-MM-dd HH:mm:ss", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "installClientName", value = "安装客户姓名", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "installClientPhone", value = "安装客户手机号", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "installCamsPhone", value = "注册CAMS PLUS 手机号", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "installReserveRemark", value = "备注", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "installReserveStatus", value = "0-预约失败,1:预约成功", dataType = "int", paramType = "query", required = true),
            @ApiImplicitParam(name = "installFollowTime", value = "下次跟进时间yyyy-MM-dd HH:mm:ss", dataType = "String", paramType = "query", required = true),})
    public BaseResponse<Object> reserveInstall(String orderId, String installReserveTime, String installClientName,
                                               String installClientPhone, String installCamsPhone, String installReserveRemark, int installReserveStatus, String installFollowTime) {
        Assert.notNull(installReserveStatus, "预约状态不能为空");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date = null;
        Date followDate = null;
        if (installReserveStatus == 1) {
            try {
                date = sdf.parse(installReserveTime);
            } catch (ParseException e) {
                throw new ServiceException("日期格式错误");
            }
        } else {
            try {
                followDate = sdf.parse(installFollowTime);
            } catch (ParseException e) {
                throw new ServiceException("日期格式错误");
            }
        }

        orderService.reserveInstall(orderId, date, installClientName, installClientPhone, installCamsPhone, installReserveRemark, installReserveStatus, followDate);
        return new BaseResponse<>();
    }

    /**
     * 勘察完成审批
     *
     * @param orderId
     * @param status
     * @param surveyFinishFailReason
     */
    @PostMapping(value = "order/surveyFinishExamine")
    @ApiOperation(value = "勘察完成审批")
    @ApiImplicitParams({@ApiImplicitParam(name = "orderId", value = "订单id", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "status", value = "状态0:不通过 1:通过", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "surveyFinishFailReason", value = "不通过原因", dataType = "String", paramType = "query", required = false),})
    public BaseResponse<Object> surveyFinishExamine(String orderId, Integer status, String surveyFinishFailReason) {
        if (StringUtils.isEmpty(orderId) || status == null) {
            throw new ServiceException(MessageConstant.MISSING_PARAM);
        }
        orderService.surveyFinishExamine(orderId, status, surveyFinishFailReason);
        return new BaseResponse<>();
    }

    /**
     * 安装变更审批
     *
     * @param orderId
     * @param status
     * @param installChangeFailReason
     */
    @PostMapping(value = "order/installChangeExamine")
    @ApiOperation(value = "安装变更审批")
    @ApiImplicitParams({@ApiImplicitParam(name = "orderId", value = "订单id", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "status", value = "状态0:不通过 1:通过", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "installChangeFailReason", value = "不通过原因", dataType = "String", paramType = "query", required = true),})
    public BaseResponse<Object> installChangeExamine(String orderId, Integer status, String installChangeFailReason) {
        if (StringUtils.isEmpty(orderId) || status == null) {
            throw new ServiceException(MessageConstant.MISSING_PARAM);
        }
        orderService.installChangeExamine(orderId, status, installChangeFailReason);
        return new BaseResponse<>();
    }

    /**
     * 安装完成审批
     *
     * @param orderId
     * @param status
     * @param installFinishFailReason
     */
    @PostMapping(value = "order/installFinishExamine")
    @ApiOperation(value = "安装完成审批")
    @ApiImplicitParams({@ApiImplicitParam(name = "orderId", value = "订单id", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "status", value = "状态0:不通过 1:通过", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "installFinishFailReason", value = "不通过原因", dataType = "String", paramType = "query", required = true),})
    public BaseResponse<Object> installFinishExamine(String orderId, Integer status, String installFinishFailReason) {
        if (StringUtils.isEmpty(orderId) || status == null) {
            throw new ServiceException(MessageConstant.MISSING_PARAM);
        }
        orderService.installFinishExamine(orderId, status, installFinishFailReason);
        return new BaseResponse<>();
    }

    /**
     * 填写预约异常信息
     *
     * @param orderId
     * @param content
     * @return
     */
    @PostMapping(value = "order/reserveException")
    @ApiOperation(value = "填写预约异常信息")
    @ApiImplicitParams({@ApiImplicitParam(name = "orderId", value = "订单id", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "content", value = "内容", dataType = "String", paramType = "query", required = true),})
    public BaseResponse<Object> reserveException(String orderId, String content) {
        Assert.notNull(orderId, "缺少订单号");
        Assert.notNull(content, "缺少内容");
        orderService.reserveException(orderId, content);
        return new BaseResponse<>();
    }

    /**
     * 查询维保订单列表
     *
     * @param condition
     * @return
     */
    @GetMapping(value = "order/warrantyList")
    @ApiOperation(value = "查询维保订单列表")
    @ApiImplicitParams({@ApiImplicitParam(name = "page", value = "一页显示数量", dataType = "int", paramType = "query", required = false),
            @ApiImplicitParam(name = "pagecount", value = "页码", dataType = "int", paramType = "query", required = false),})
    public BaseResponse<List<WarrantyOrder>> getWarrantyAll(WarrantyOrderBo condition) {
        return new BaseResponse<>(orderService.getWarrantyOrders(condition));
    }

    /**
     * 更新车架号
     *
     * @param orderId
     * @param vehicleVin
     * @return
     */
    @PostMapping(value = "order/updateVehicleVin")
    @ApiOperation(value = "更新车架号")
    @ApiImplicitParams({@ApiImplicitParam(name = "orderId", value = "订单id", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "vehicleVin", value = "车架号", dataType = "String", paramType = "query", required = true),})
    public BaseResponse<Object> updateVehicleVin(String orderId, String vehicleVin) {
        if (StringUtils.isEmpty(orderId) || StringUtils.isEmpty(vehicleVin)) {
            throw new ServiceException(MessageConstant.MISSING_PARAM);
        }
        orderService.updateVehicleVin(orderId, vehicleVin);
        return new BaseResponse<>();
    }

    /**
     * 安装变更提交审批
     *
     * @param orderId
     * @param name
     * @param url
     * @return
     */
    @PostMapping(value = "order/installChange")
    @ApiOperation(value = "安装变更提交审批")
    @ApiImplicitParams({@ApiImplicitParam(name = "orderId", value = "订单id", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "name", value = "文件名,多个逗号分割", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "url", value = "文件地址,多个逗号分割", dataType = "String", paramType = "query", required = true),})
    public BaseResponse<Object> installChange(String orderId, String name, String url) {
        if (StringUtils.isEmpty(orderId) || StringUtils.isEmpty(name) || StringUtils.isEmpty(url)) {
            throw new ServiceException(MessageConstant.MISSING_PARAM);
        }
        String[] nameArr = name.split(CamsConstant.COMMA);
        List<String> fileNames = Arrays.asList(nameArr);
        String[] urlArr = url.split(CamsConstant.COMMA);
        List<String> fileUrls = new ArrayList<>();
        for (String s : urlArr) {
            fileUrls.add(CommonUtils.urlHandle(s));
        }
        orderService.installChange(orderId, fileNames, fileUrls);
        return new BaseResponse<>();
    }

    /**
     * 查询订单详情
     *
     * @return
     */
    @GetMapping(value = "order/detail")
    @ApiOperation(value = "查询订单详情")
    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "订单id", dataType = "String", paramType = "query", required = true)})
    public BaseResponse<OrderVo> detail(String id) {
        Assert.notNull(id, WiosConstant.EMPTY_ID);
        return new BaseResponse<>(orderService.getDetail(id));
    }

    /**
     * 查询订单详情
     *
     * @return
     */
    @GetMapping(value = "order/detailInfo")
    @ApiOperation(value = "查询订单详情")
    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "订单id", dataType = "String", paramType = "query", required = true)})
    public ResponseMessage2 detailInfo(String id) {
        Assert.notNull(id, WiosConstant.EMPTY_ID);
        return ResponseMessage2.Success2(orderService.getMapDetail(id));
    }

    /**
     * 订单附件上传
     *
     * @param orderId
     * @param name
     * @param url
     * @return
     */
    @PostMapping(value = "order/attachFilesUpload")
    @ApiOperation(value = "订单附件上传")
    @ApiImplicitParams({@ApiImplicitParam(name = "orderId", value = "订单id", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "name", value = "文件名,多个逗号分割", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "url", value = "文件地址,多个逗号分割", dataType = "String", paramType = "query", required = true),})
    public BaseResponse<Object> attachFilesUpload(String orderId, String name, String url) {
        if (StringUtils.isEmpty(orderId) || StringUtils.isEmpty(name) || StringUtils.isEmpty(url)) {
            throw new ServiceException(MessageConstant.MISSING_PARAM);
        }
        String[] nameArr = name.split(CamsConstant.COMMA);
        List<String> fileNames = Arrays.asList(nameArr);
        String[] urlArr = url.split(CamsConstant.COMMA);
        List<String> fileUrls = new ArrayList<>();
        for (String s : urlArr) {
            fileUrls.add(CommonUtils.urlHandle(s));
        }
        orderService.uploadFile(orderId, fileNames, fileUrls);
        return new BaseResponse<>();
    }

    /**
     * 查询订单附件列表
     *
     * @param id
     * @return
     */
    @GetMapping(value = "order/getFiles")
    @ApiOperation(value = "查询订单附件列表")
    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "订单id", dataType = "String", paramType = "query", required = true)})
    public BaseResponse<List<UploadFile>> getFiles(String id) {
        Assert.notEmpty(id, WiosConstant.EMPTY_ID);
        return new BaseResponse<>(orderService.getFiles(id));
    }

    @PostMapping(value = "order/bindVirtualPhone")
    @ApiOperation(value = "绑定车主手机虚拟号码")
    @ApiImplicitParams({@ApiImplicitParam(name = "orderId", value = "订单id", dataType = "String", paramType = "query", required = true),})
    public BaseResponse<Object> bindVirtualPhone(String orderId) throws Exception {
        if (StringUtils.isEmpty(orderId)) {
            throw new ServiceException(MessageConstant.MISSING_PARAM);
        }
        Order order = orderService.get(orderId);
        if (order != null) {
            spService.bind(order.getUserPhone());
        }
        return new BaseResponse<>();
    }

    @PostMapping(value = "order/unbindVirtualPhone")
    @ApiOperation(value = "解绑车主手机虚拟号码")
    @ApiImplicitParams({@ApiImplicitParam(name = "orderId", value = "订单id", dataType = "String", paramType = "query", required = true),})
    public BaseResponse<Object> unbindVirtualPhone(String orderId) throws Exception {
        if (StringUtils.isEmpty(orderId)) {
            throw new ServiceException(MessageConstant.MISSING_PARAM);
        }
        Order order = orderService.get(orderId);
        if (order != null) {
            spService.unbind(order.getUserPhone());
        }
        return new BaseResponse<>();
    }

    @GetMapping(value = "order/getVirtualPhone")
    @ApiOperation(value = "查询虚拟手机号")
    @ApiImplicitParams({@ApiImplicitParam(name = "phone", value = "手机号", dataType = "String", paramType = "query", required = true)})
    public BaseResponse<SecretPhone> getVirtualPhone(String phone) {
        Assert.notEmpty(phone, "phone不能为空");
        return new BaseResponse<>(spService.get(phone));
    }

    /**
     * @return com.ihidea.component.api.v2.BaseResponse<java.lang.Object>
     * @Description 提供管理员删除订单功能
     * @Param [orderId]
     * @author liwenxiang
     * @date 2021/7/28 10:30
     */
    @PostMapping(value = "order/deleteOrder")
    @ApiOperation(value = "删除订单")
    @ApiImplicitParams({@ApiImplicitParam(name = "orderId", value = "订单号", dataType = "String", paramType = "query", required = true)})
    public BaseResponse<Object> deleteOrder(String orderId){
        orderService.deleteOrder(orderId);
        return new BaseResponse<>();
    }

    /**
     * @Description 手动第一次同步订单到sap
     * @Param [orderId]
     * @author xufengyu
     * @date 2022/2/17 10:30
     */
    @PostMapping(value = "order/pushOrder")
    @ApiOperation(value = "同步订单到sap")
    @ApiImplicitParams({@ApiImplicitParam(name = "orderId", value = "订单号", dataType = "String", paramType = "query", required = true)})
    public ResponseMessage2<SapStatisticsBO> pushOrder(String orderId) {
        return orderService.pushOrder(orderId);
    }



    /**
     * @Description 手动同步订单到sap
     * @Param [orderId]
     * @author xufengyu
     * @date 2022/2/17 10:30
     */
    @PostMapping(value = "order/pushNewOrder")
    @ApiOperation(value = "同步订单到sap")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "orderId", value = "订单号", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "newzbrandid", value = "墙盒品牌ID", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "contractId", value = "合同编号", dataType = "Integer", paramType = "query", required = false),
            @ApiImplicitParam(name = "sapCode", value = "产品编码", dataType = "String", paramType = "query", required = false)
    })
    public BaseResponse<Object> pushOrder(String orderId, String  newzbrandid,Integer contractId,String sapCode){
        orderService.pushNewOrder(orderId, newzbrandid,contractId,sapCode);
        return new BaseResponse<>();
    }

    /**
     * @Description 获取合同编号枚举
     * @Param [orderId]
     * @author xufengyu
     * @date 2022/2/17 10:30
     */
    @PostMapping(value = "order/contractids")
    @ApiOperation(value = "查询合同编号枚举")
    public BaseResponse<Object> getAllContractId(){
        return new BaseResponse<>(orderService.showContracts());
    }

}