package com.sckw.payment.controller.app;

import com.sckw.core.web.response.HttpResult;
import com.sckw.payment.model.constant.LogisticsUnitType;
import com.sckw.payment.model.vo.req.SettlementReq;
import com.sckw.payment.service.KwpSettlementLogisticsService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

/**
 * 结算-物流订单
 *
 * @author Aick Spt
 * @date 2023-07-18 16:34
 */
@Tag(name = "App物流结算管理", description = "提供App端物流订单结算相关操作接口")
@RestController
@RequestMapping("/appKwpSettlementLogistics")
public class AppKwpSettlementLogisticsController {

    @Resource
    private KwpSettlementLogisticsService kwpSettlementLogisticsService;

    //   ========= 运费收款 承运方 =========
    @Operation(summary = "运费收款-物流订单列表", description = "运费收款-物流订单列表（承运方）")
    @PostMapping(path = "pageListCollection")
    public HttpResult pageSelectCollection(@RequestBody @Valid SettlementReq settlementReq) {
        return HttpResult.ok(kwpSettlementLogisticsService.pageSelectCollection(settlementReq));
    }

    @Operation(summary = "运费收款-物流订单各状态列表总数", description = "运费收款-物流订单各状态列表总数（承运方）")
    @PostMapping(path = "getCountListCollection")
    public HttpResult getCountListCollection(@RequestBody @Valid SettlementReq settlementReq) {
        return HttpResult.ok(kwpSettlementLogisticsService.getCountListCollection(settlementReq));
    }

    @Operation(summary = "运费收款-物流订单详情", description = "运费收款-物流订单详情（承运方）")
    @Parameter(name = "id", description = "订单ID", required = true)
    @GetMapping(path = "detailCollection")
    public HttpResult detailCollection(@RequestParam("id") Long id) {
        return HttpResult.ok(kwpSettlementLogisticsService.detailCollection(id));
    }

    /**
     * 承运方 app端
     *
     * @param id 订单ID
     * @return 订单详情
     */
    @Operation(summary = "承运方订单详情", description = "承运方 app端订单详情")
    @Parameter(name = "id", description = "订单ID", required = true)
    @GetMapping("carrierDetail")
    public HttpResult carrierDetail(@RequestParam("id") String id) {
        return HttpResult.ok(kwpSettlementLogisticsService.queryDetail(Long.parseLong(id), LogisticsUnitType.SHIPPER));
    }


    //   ========= 运费付款 托运方 =========
    @Operation(summary = "运费付款-物流订单列表", description = "运费付款-物流订单列表（托运方）")
    @PostMapping(path = "pageListPayment")
    public HttpResult pageSelectPayment(@RequestBody @Valid SettlementReq settlementReq) {
        return HttpResult.ok(kwpSettlementLogisticsService.pageSelectPayment(settlementReq));
    }

    @Operation(summary = "运费付款-物流订单各状态列表总数", description = "运费付款-物流订单各状态列表总数（托运方）")
    @PostMapping(path = "getCountListPayment")
    public HttpResult getCountListPayment(@RequestBody @Valid SettlementReq settlementReq) {
        return HttpResult.ok(kwpSettlementLogisticsService.getCountListPayment(settlementReq));
    }

    @Operation(summary = "物流订单详情", description = "物流订单详情（托运方）")
    @Parameter(name = "id", description = "订单ID", required = true)
    @GetMapping(path = "detailPayment")
    public HttpResult detailPayment(@RequestParam("id") Long id) {
        return HttpResult.ok(kwpSettlementLogisticsService.detailPayment(id));
    }

    /**
     * app端详情
     *
     * @param id 订单ID
     * @return 订单详情
     */
    @Operation(summary = "托运方订单详情", description = "托运方 app端订单详情")
    @Parameter(name = "id", description = "订单ID", required = true)
    @GetMapping("shipperDetail")
    public HttpResult shipperDetail(@RequestParam("id") String id) {
        return HttpResult.ok(kwpSettlementLogisticsService.queryDetail(Long.parseLong(id), LogisticsUnitType.CARRIER));
    }
}