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 jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

/**
 * 结算-物流订单
 *
 * @author Aick Spt
 * @date 2023-07-18 16:34
 */
@RestController
@RequestMapping("/appKwpSettlementLogistics")
public class AppKwpSettlementLogisticsController {

    @Resource
    private KwpSettlementLogisticsService kwpSettlementLogisticsService;

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

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

    @GetMapping(name = "运费收款-物流订单详情", path = "detailCollection")
    public HttpResult detailCollection(@RequestParam("id") Long id) {
        return HttpResult.ok(kwpSettlementLogisticsService.detailCollection(id));
    }

    /**
     * 承运方 app端
     *
     * @param id
     * @return
     */
    @GetMapping("carrierDetail")
    public HttpResult carrierDetail(@RequestParam("id") String id) {
        return HttpResult.ok(kwpSettlementLogisticsService.queryDetail(Long.parseLong(id), LogisticsUnitType.SHIPPER));
    }


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

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

    @GetMapping(name = "物流订单详情", path = "detailPayment")
    public HttpResult detailPayment(@RequestParam("id") Long id) {
        return HttpResult.ok(kwpSettlementLogisticsService.detailPayment(id));
    }

    /**
     * app端详情
     *
     * @param id
     * @return
     */
    @GetMapping("shipperDetail")
    public HttpResult shipperDetail(@RequestParam("id") String id) {
        return HttpResult.ok(kwpSettlementLogisticsService.queryDetail(Long.parseLong(id), LogisticsUnitType.CARRIER));
    }
}
