package com.dk.mdm.controller.mac;

import com.dk.common.model.pojo.PageList;
import com.dk.common.response.ResponseResultVO;
import com.dk.mdm.model.pojo.mac.RecPay;
import com.dk.common.service.BaseService;
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 io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import io.swagger.annotations.Api;
import com.dk.mdm.service.mac.ReceiptService;

import java.util.Map;

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

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

    @Autowired
    private ReceiptService receiptService;
    /**
     * @desc : 条件查询
     * @author : 付斌
     * @date : 2023/1/9 10:36
     */
    @ApiOperation(value = "分页、关联、条件查询", notes = "分页、关联、条件查询")
    @PostMapping({"list_by"})
    public ResponseResultVO<PageList<RecPayResponse>> selectByCond(@RequestBody RecPayQuery recPayQuery) {
        return receiptService.selectByCond(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 receiptService.selectRpInfoById(id);
    }

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

    /**
     * @desc : 新建客户收款
     * @author : 付斌
     * @date : 2023/1/9 10:48
     */
    @ApiOperation(value = "新建客户收款", notes = "新建客户收款")
    @PostMapping({"insert_receipt"})
    public ResponseResultVO<?> insertReceipt(@RequestBody RecPayVO recPayVO) {
        return receiptService.insertReceipt(recPayVO);
    }

    /**
     * @desc : 新建客户退款
     * @author : 付斌
     * @date : 2023/1/9 10:48
     */
    @ApiOperation(value = "新建客户退款", notes = "新建客户退款")
    @PostMapping({"insert_refund"})
    public ResponseResultVO<?> insertRefund(@RequestBody RecPayVO recPayVO) {
        return receiptService.insertRefund(recPayVO);
    }

    /**
     * @desc : 编辑客户收款/退款
     * @author : 付斌
     * @date : 2023/1/9 10:49
     */
    @ApiOperation(value = "编辑客户收款/退款", notes = "编辑客户收款/退款")
    @PostMapping({"update"})
    public ResponseResultVO<?> update(@RequestBody RecPayVO recPayVO) {
        return receiptService.update(recPayVO);
    }

    /**
     * @desc :查询收款明细（编辑用）
     * @author : 付斌
     * @date : 2024-02-28 13:24
     */
    @ApiOperation(value = "查询收款明细（编辑用）", notes = "查询收款明细（编辑用）")
    @PostMapping({"get_rp_for_update/{id}"})
    public ResponseResultVO<?> getRpForUpdate(@PathVariable String id) {
        return receiptService.getRpForUpdate(id);
    }

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

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

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

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