package com.openhis.web.paymentmanage.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.core.common.annotation.Anonymous;
import com.core.common.core.domain.R;
import com.openhis.web.paymentmanage.appservice.IChargeBillService;
import com.openhis.web.paymentmanage.dto.ChargeSummaryDto;

import lombok.extern.slf4j.Slf4j;

/**
 * 报表
 *
 * @author SunJQ
 * @date 2025-03-29
 */
@RestController
@RequestMapping("/payment/bill")
@Slf4j
public class ChargeBillController {

    @Autowired
    private IChargeBillService iChargeBillService;

    /**
     * 单次结算账单
     *
     * @param paymentId 付款实体
     */
    @GetMapping("/getDetail")
    public R<?> getDetail(@RequestParam("paymentId") Long paymentId) {
        return R.ok(iChargeBillService.getDetail(paymentId));
    }

    /**
     * 单次结算账单
     *
     * @param paymentId 付款实体
     */
    @GetMapping("/receipt-details-nd")
    @Anonymous
    public R<?> getReceiptDetailsND(@RequestParam("paymentId") Long paymentId) {
        return R.ok(iChargeBillService.getReceiptDetailsND(paymentId));
    }

    /**
     * 日结算账单
     *
     * @param startTime 结算参数
     * @param endTime 结算参数
     * @param entererId 结算参数
     */
    @GetMapping("/getTotal")
    public R<?> getTotal(@RequestParam("startTime") String startTime, @RequestParam("endTime") String endTime,
        @RequestParam("entererId") Long entererId,
        @RequestParam(value = "contractNo", required = false) String contractNo) {
        return R.ok(iChargeBillService.getTotal(startTime, endTime, entererId, contractNo));
    }

    /**
     * 日结算账单(长大版本)
     *
     * @param startTime 结算参数
     * @param endTime 结算参数
     * @param entererId 结算参数
     */
    @GetMapping("/getTotalCcu")
    @Anonymous
    public R<?> getTotalCcu(@RequestParam(value = "startTime") String startTime,
        @RequestParam("endTime") String endTime, @RequestParam(value = "entererId", required = false) Long entererId,
        @RequestParam(value = "contractNo", required = false) String contractNo) {
        return R.ok(iChargeBillService.getTotalCommen(startTime, endTime, entererId, contractNo));
    }

    /**
     * 获取医疗保障金清单（门诊慢病用）
     */
    @PostMapping("/get-med-exp-cov-sum")
    public R<?> getMedicalExpenseCoverageSummary(Long paymentId) {
        return R.ok(iChargeBillService.getMedicalExpenseCoverageSummary(paymentId));
    }

    /**
     * 获取各科室营收信息
     */
    @PostMapping("/charge-summary")
    public R<?> getChargeSummary(@RequestBody ChargeSummaryDto chargeSummaryDto) {
        return R.ok(iChargeBillService.getChargeItemByOrg(chargeSummaryDto));
        // return null;
    }

}
