package com.sckw.payment.controller;

import com.sckw.core.web.response.HttpResult;
import com.sckw.payment.model.constant.SettlementOrderTypeEnum;
import com.sckw.payment.model.constant.SettlementWalletPayTypeEnum;
import com.sckw.payment.model.vo.req.OfflinePaymentReq;
import com.sckw.payment.model.vo.req.SettlementOfflinePayReq;
import com.sckw.payment.model.vo.req.SettlementOfflineReq;
import com.sckw.payment.service.KwpSettlementOfflineService;
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-20 11:42
 */
@Tag(name = "线下结算管理", description = "提供线下结算记录相关操作接口")
@RestController
@RequestMapping(path = "/kwpSettlementOffline")
public class KwpSettlementOfflineController {

    @Resource
    private KwpSettlementOfflineService kwpSettlementOfflineService;

    //  =========  运费收款  =========

    @Operation(summary = "物流-线下付款(运费收款)记录-列表", description = "查询物流订单线下付款(运费收款)记录列表")
    @PostMapping(path = "pageListLogisticsCollection")
    public HttpResult pageListLogisticsCollection(@RequestBody @Valid SettlementOfflineReq settlementOfflineReq) {
        settlementOfflineReq.setOrderType(SettlementOrderTypeEnum.LOGISTICS.getStatus());
        return HttpResult.ok(kwpSettlementOfflineService.pageListLogisticsCollection(settlementOfflineReq));
    }

    @Operation(summary = "物流-线下付款(运费收款)记录-详情", description = "查询物流订单线下付款(运费收款)记录详情")
    @Parameter(name = "id", description = "记录ID", required = true)
    @GetMapping(path = "detailLogisticsCollection")
    public HttpResult detailLogisticsCollection(@RequestParam("id") Long id) {
        return HttpResult.ok(kwpSettlementOfflineService.detailLogisticsCollection(id));
    }

    @Operation(summary = "物流-线下付款(运费收款)记录-新增", description = "新增物流订单线下付款(运费收款)记录")
    @PostMapping(path = "confirmLogisticsCollection")
    public HttpResult confirmLogisticsCollection(@RequestBody @Valid OfflinePaymentReq offlinePaymentReq) {
        offlinePaymentReq.setOrderType(SettlementOrderTypeEnum.LOGISTICS.getStatus());
        return HttpResult.ok(kwpSettlementOfflineService.confirmLogisticsCollection(offlinePaymentReq));
    }


    //  =========  销售收款  =========

    /**
     * 销售方-线下付款记录
     *
     * @param settlementOfflineReq 查询参数
     * @return 付款记录列表
     */
    @Operation(summary = "交易-线下付款(销售收款)记录-列表", description = "查询交易订单线下付款(销售收款)记录列表")
    @GetMapping(path = "pageListTrade")
    public HttpResult pageListTradeCollection(@Valid SettlementOfflineReq settlementOfflineReq) {
        settlementOfflineReq.setOrderType(SettlementOrderTypeEnum.TRADE.getStatus());
        return HttpResult.ok(kwpSettlementOfflineService.pageListTradeCollection(settlementOfflineReq));
    }

    /**
     * 销售收款-收款确认-线下付款
     *
     * @param payReq 付款参数
     * @return 操作结果
     */
    @Operation(summary = "销售收款-收款确认-线下付款", description = "销售收款-收款确认-线下付款")
    @PostMapping(path = "confirmTradeCollection")
    public HttpResult confirmTradeCollection(@Valid @RequestBody SettlementOfflinePayReq payReq) {
        payReq.setOrderType(SettlementOrderTypeEnum.TRADE.getStatus());
        return HttpResult.ok(kwpSettlementOfflineService.confirmTradeCollection(payReq));
    }

}