package cn.iocoder.yudao.module.system.controller.admin.yk;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.system.controller.admin.yk.vo.YKPaymentRecordConfirmVO;
import cn.iocoder.yudao.module.system.controller.admin.yk.vo.YkElderlyPaymentRecordPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.yk.vo.YkElderlyPaymentRecordPageRespVO;
import cn.iocoder.yudao.module.system.controller.admin.yk.vo.YkElderlyPaymentRecordSaveReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.yk.YkElderlyPaymentRecordDO;
import cn.iocoder.yudao.module.system.service.yk.YkElderlyPaymentRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

import org.springframework.validation.annotation.Validated;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import javax.annotation.security.PermitAll;
import javax.validation.*;
import javax.validation.constraints.NotEmpty;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

import java.util.List;




@Tag(name = "管理后台 - 颐康长者收款记录信息")
@RestController
@Validated
public class YkElderlyPaymentRecordController {

    @Resource
    private YkElderlyPaymentRecordService elderlyPaymentRecordService;

    @PostMapping("/ykCenter/proceeds/add")
    @Operation(summary = "创建颐康长者收款记录信息")
    public CommonResult<Long> createElderlyPaymentRecord(@Valid @RequestBody YkElderlyPaymentRecordSaveReqVO createReqVO) {
        return success(elderlyPaymentRecordService.createElderlyPaymentRecord(createReqVO));
    }

    @PutMapping("/ykCenter/proceeds/update")
    @Operation(summary = "更新颐康长者收款记录信息")
    public CommonResult<Boolean> updateElderlyPaymentRecord(@Valid @RequestBody YkElderlyPaymentRecordSaveReqVO updateReqVO) {
        elderlyPaymentRecordService.updateElderlyPaymentRecord(updateReqVO);
        return success(true);
    }

    @DeleteMapping("/ykCenter/proceeds/delete")
    @Operation(summary = "删除颐康长者收款记录信息")
    @Parameter(name = "id", description = "编号", required = true)
    public CommonResult<Boolean> deleteElderlyPaymentRecord(@RequestParam("id") Long id) {
        elderlyPaymentRecordService.deleteElderlyPaymentRecord(id);
        return success(true);
    }

    @GetMapping("/ykCenter/proceeds/get")
    @Operation(summary = "获得颐康长者收款记录信息")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<YkElderlyPaymentRecordDO> getElderlyPaymentRecord(@RequestParam("id") Long id) {
        YkElderlyPaymentRecordDO elderlyPaymentRecord = elderlyPaymentRecordService.getElderlyPaymentRecord(id);
        return success(elderlyPaymentRecord);
    }

    @GetMapping("/ykCenter/proceeds/list")
    @Operation(summary = "获得颐康长者收款记录信息分页（包含统计信息）")
    public CommonResult<YkElderlyPaymentRecordPageRespVO> getElderlyPaymentRecordPage(@Valid YkElderlyPaymentRecordPageReqVO pageReqVO) {
        YkElderlyPaymentRecordPageRespVO result = elderlyPaymentRecordService.getElderlyPaymentRecordPageWithStats(pageReqVO);
        return success(result);
    }

    @DeleteMapping("/ykCenter/proceeds/batch-delete")
    @Operation(summary = "批量删除收款记录")
    public CommonResult<Boolean> batchDeleteElderlyPaymentRecord(@RequestBody @NotEmpty(message = "ID列表不能为空") List<Long> ids) {
        elderlyPaymentRecordService.batchDeleteElderlyPaymentRecord(ids);
        return success(true);
    }

    @PostMapping("/ykCenter/proceeds/paymentRecordConfirmChangeRecord")
    @Operation(summary = "颐康中心收款信息确认交易变动接口")
    @PermitAll
    public CommonResult<String> paymentRecordConfirmChangeRecord(@Valid @RequestBody YKPaymentRecordConfirmVO createReqVO) {
        return success(elderlyPaymentRecordService.paymentRecordConfirmChangeRecord(createReqVO));
    }

//    @GetMapping("/export-excel")
//    @Operation(summary = "导出颐康长者收款记录信息 Excel")
//    @PreAuthorize("@ss.hasPermission('yk:elderly-payment-record:export')")
//    @ApiAccessLog(operateType = EXPORT)
//    public void exportElderlyPaymentRecordExcel(@Valid YkElderlyPaymentRecordPageReqVO pageReqVO,
//                                                HttpServletResponse response) throws IOException {
//        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
//        List<YkElderlyPaymentRecordDO> list = elderlyPaymentRecordService.getElderlyPaymentRecordPage(pageReqVO).getList();
//        // 导出 Excel
//        ExcelUtils.write(response, "颐康长者收款记录信息.xls", "数据", ElderlyPaymentRecordRespVO.class,
//                BeanUtils.toBean(list, ElderlyPaymentRecordRespVO.class));
//    }

}