package com.dk.mdm.controller.mac;

import com.dk.common.model.pojo.PageList;
import com.dk.common.response.ResponseResultVO;
import com.dk.common.service.BaseService;
import com.dk.mdm.model.pojo.mac.RecPay;
import com.dk.mdm.model.query.mac.RecPayQuery;
import com.dk.mdm.model.response.mac.RecPayResponse;
import com.dk.mdm.model.vo.mac.RecPayVO;
import com.dk.mdm.service.mac.PaymentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Api(tags = "收付款单API接口")
@RestController
@RequestMapping("/mac/payment")
public class PaymentController {

    public BaseService<RecPay> getService() {
        return paymentService;
    }

    @Autowired
    private PaymentService paymentService;
    /**
     * @desc : 条件查询
     * @author : 付斌
     * @date : 2023/1/9 10:36
     */
    @ApiOperation(value = "分页、关联、条件查询", notes = "分页、关联、条件查询")
    @PostMapping({"list_by"})
    public ResponseResultVO<PageList<RecPayResponse>> selectPaymentByCond(@RequestBody RecPayQuery recPayQuery) {
        return paymentService.selectPaymentByCond(recPayQuery);
    }

    /**
     * @desc :查询付款明细（货物、付款、附件）
     * @author : 付斌
     * @date : 2024-02-28 13:24
     */
    @PostMapping({"select_rp_info_by_id/{id}"})
    public ResponseResultVO<Map<String, Object>> selectRpInfoById(@PathVariable String id) {
        return paymentService.selectRpInfoById(id);
    }

    /**
     * @desc : 通过ID查询
     * @author : 付斌
     * @date : 2023/1/9 10:41
     */
    @PostMapping({"/{id}"})
    public ResponseResultVO selectById(@PathVariable String id) {
        return paymentService.selectById(id);
    }

    /**
     * @desc : 新建应付付款(付款+冲应付)
     * @author : 付斌
     * @date : 2023/1/9 10:48
     */
    @ApiOperation(value = "新建应付付款", notes = "新建应付付款")
    @PostMapping({"insert_payable_payment"})
    public ResponseResultVO<?> insertPayablePayment(@RequestBody RecPayVO recPayVO) {
        return paymentService.insertPayablePayment(recPayVO);
    }

    /**
     * @desc : 更新应付付款(小编辑)
     * @author : 付斌
     * @date : 2023/1/9 10:48
     */
    @ApiOperation(value = "更新应付付款", notes = "更新应付付款")
    @PostMapping({"update_payable_payment"})
    public ResponseResultVO<?> updatePayablePayment(@RequestBody RecPayVO recPayVO) {
        return paymentService.updatePayablePayment(recPayVO);
    }

    /**
     * @desc : 作废
     * @author : 付斌
     * @date : 2024-03-08 16:36
     */
    @ApiOperation(value = "作废", notes = "作废")
    @PostMapping({"invalid/{id}"})
    public ResponseResultVO<?> invalid(@PathVariable String id) {
        return paymentService.invalid(id);
    }

    /**
     * @desc : 获取应付付款(编辑用)
     * @author : 付斌
     * @date : 2024-03-03 9:28
     */
    @ApiOperation(value = "获取应付付款(编辑用)", notes = "获取应付付款(编辑用)")
    @PostMapping({"get_payable_payment_for_update/{id}"})
    public ResponseResultVO<?> getPayablePaymentForUpdate(@PathVariable String id) {
        return paymentService.getPayablePaymentForUpdate(id);
    }

}
