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

/**
 * 结算-线下记录（交易订单结算/物流订单结算）
 *
 * @author Aick Spt
 * @date 2023-07-20 11:42
 */
@RestController
@RequestMapping(name = "结算-线下记录", path = "/kwpSettlementOffline")
public class KwpSettlementOfflineController {

    @Resource
    private KwpSettlementOfflineService kwpSettlementOfflineService;

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

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

    @GetMapping(name = "物流-线下付款(运费收款)记录-详情", path = "detailLogisticsCollection")
    public HttpResult detailLogisticsCollection(@RequestParam("id") Long id) {
        return HttpResult.ok(kwpSettlementOfflineService.detailLogisticsCollection(id));
    }

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


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

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

    /**
     * 销售收款-收款确认-线下付款
     *
     * @param payReq
     * @return
     */
    @PostMapping(name = "销售收款-收款确认-线下付款", path = "confirmTradeCollection")
    public HttpResult confirmTradeCollection(@Valid @RequestBody SettlementOfflinePayReq payReq) {
        payReq.setOrderType(SettlementOrderTypeEnum.TRADE.getStatus());
        return HttpResult.ok(kwpSettlementOfflineService.confirmTradeCollection(payReq));
    }

}
