package com.prolog.rdc.tms.app.controller.web;

import com.prolog.framework.common.message.RestMessage;
import com.prolog.framework.log.aop.annotation.UserLog;
import com.prolog.rdc.tms.app.model.dto.PendingDeliveryTaskQueryDTO;
import com.prolog.rdc.tms.app.model.vo.*;
import com.prolog.rdc.tms.app.service.PendingDeliveryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 *
 *
 * 司机APP-待配送
 *
 * @className :PendingDeliveryController
 * @author :qian.yh
 * @creationTime :2022/07/05
 * @description :
 *
 * @modifier :
 * @modifyTime :
 * @reviseRemarks:
 *
 * @version :1.0.0
 *
 */
@Api(tags = "司机APP-待配送控制层")
@RestController
@RequestMapping("/pending_delivery")
public class PendingDeliveryController {
    @Resource
    private PendingDeliveryService pendingDeliveryService;

    @UserLog("配送任务查询")
    @ApiOperation(value = "配送任务查询", notes = "配送任务查询")
    @PostMapping("/pending_delivery_task_query")
    public RestMessage<List<PendingDeliveryTaskQueryDTO>> pendingDeliveryTaskQuery(@RequestBody PendingDeliveryTaskQueryVO pendingDeliveryTaskQueryVO) {
        try {
            List<PendingDeliveryTaskQueryDTO> dtos = pendingDeliveryService.pendingDeliveryTaskQuery(pendingDeliveryTaskQueryVO);
            return RestMessage.newInstance(true, "查询成功", dtos);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("待送达收货方模式")
    @ApiOperation(value = "待送达收货方模式", notes = "待送达收货方模式")
    @PostMapping("/pending_delivery_task_query_by_consignee")
    public RestMessage<List<PendingDeliveryTaskQueryDTO>> pendingDeliveryTaskQueryGroupByConsignee(@RequestBody @Valid PendingDeliveryTaskQueryVO pendingDeliveryTaskQueryVO) {
        return RestMessage.newInstance(true, "查询成功", pendingDeliveryService.pendingDeliveryTaskQueryGroupByConsignee(pendingDeliveryTaskQueryVO));

    }


    @UserLog("配送签到")
    @ApiOperation(value = "配送签到", notes = "配送签到")
    @PostMapping("/pending_delivery_sign_in")
    public RestMessage<String> pendingDeliverySignIn(@RequestBody PendingDeliverySignInVO pendingDeliverySignInVO) {
        try {
            pendingDeliveryService.pendingDeliverySignIn(pendingDeliverySignInVO);
            return RestMessage.newInstance(true, "配送签到成功", null);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("送达确认")
    @ApiOperation(value = "送达确认", notes = "送达确认")
    @PostMapping("/pending_delivery_confirm")
    public RestMessage<String> pendingDeliveryConfirm(@RequestBody PendingDeliveryConfirmVO pendingDeliveryConfirmVO) {
        try {
            pendingDeliveryService.pendingDeliveryConfirm(pendingDeliveryConfirmVO);
            return RestMessage.newInstance(true, "提货签到成功", null);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("异常上报")
    @ApiOperation(value = "异常上报", notes = "异常上报")
    @PostMapping("/pending_delivery_abnormal_report")
    public RestMessage<String> pendingDeliveryAbnormalReport(@RequestBody PendingDeliveryAbnormalReportVO pendingDeliveryAbnormalReportVO) {
        try {
            pendingDeliveryService.pendingDeliveryAbnormalReport(pendingDeliveryAbnormalReportVO);
            return RestMessage.newInstance(true, "提货签到成功", null);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }

    @UserLog("服务评价")
    @ApiOperation(value = "服务评价", notes = "服务评价")
    @PostMapping("/shipbill_service_evaluation")
    public RestMessage<String> shipbillServiceEvaluation(@RequestBody ShipbillServiceEvaluationVO shipbillServiceEvaluationVO) {
        try {
            pendingDeliveryService.shipbillServiceEvaluation(shipbillServiceEvaluationVO);
            return RestMessage.newInstance(true, "服务评价成功", null);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, e.getMessage(), null);
        }
    }


}