package com.leromro.core.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotBlank;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.leromro.common.core.domain.entity.SysUser;
import com.leromro.core.domain.dto.AddPaymentRecordDTO;
import com.leromro.core.domain.dto.WithdrawPaymentDTO;
import com.leromro.core.facade.VolunteerPaymentRecordsFacade;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.leromro.common.core.domain.R;
import org.hibernate.validator.constraints.Range;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.leromro.common.annotation.Log;
import com.leromro.common.core.controller.BaseController;
import com.leromro.common.core.domain.AjaxResult;
import com.leromro.common.enums.BusinessType;
import com.leromro.core.domain.VolunteerPaymentRecords;
import com.leromro.core.service.IVolunteerPaymentRecordsService;
import com.leromro.common.utils.poi.ExcelUtil;
import com.leromro.common.core.page.TableDataInfo;

/**
 * 志愿者打款单记录Controller
 * 
 * @author ruoyi
 * @date 2025-05-15
 */
@RestController
@Api(tags = "志愿者打款单记录")
@RequestMapping("/core/volunteer/payment")
public class VolunteerPaymentRecordsController extends BaseController
{
    @Autowired
    private IVolunteerPaymentRecordsService volunteerPaymentRecordsService;

    @Autowired
    private VolunteerPaymentRecordsFacade  volunteerPaymentRecordsFacade;


    /**
     * 创建志愿者打款单
     */
    @ApiOperation(value = "创建志愿者打款单",notes = "传入打款方式和选中的id名称逗号拼接")
    @PostMapping
    public R addPaymentRecord(@RequestBody AddPaymentRecordDTO dto)
    {
        return volunteerPaymentRecordsService.addPaymentRecord(dto);
    }

    /**
     * 查询志愿者打款单记录列表
     */
    @ApiOperation("查询志愿者打款单记录列表")
    @GetMapping("/list")
    public TableDataInfo<VolunteerPaymentRecords> list(VolunteerPaymentRecords volunteerPaymentRecords)
    {
        startPage();
        List<VolunteerPaymentRecords> list = volunteerPaymentRecordsService.selectVolunteerPaymentRecordsList(volunteerPaymentRecords);
        return getDataTable(list);
    }

//    /**
//     * 获取志愿者打款单记录详细信息
//     */
//    @ApiOperation("获取志愿者打款单记录详细信息")
//    @GetMapping(value = "/{volunteerPaymentRecordsId}")
//    public R<VolunteerPaymentRecords> getInfo(@PathVariable("volunteerPaymentRecordsId") Long volunteerPaymentRecordsId)
//    {
//        return R.ok(volunteerPaymentRecordsService.selectVolunteerPaymentRecordsByVolunteerPaymentRecordsId(volunteerPaymentRecordsId));
//    }


    /**
     * 打款单验证
     * @param dto
     * @return
     */
    @PostMapping({"/payoutCheck"})
    @ApiOperation(value = "打款单验证", notes = "传入打款单id，，和打款验证密码", produces = "application/json")
    public R payoutCheck(@RequestBody WithdrawPaymentDTO dto) {
        if (ObjectUtil.isNull(dto.getVolunteerPaymentRecordsId())) {
            return R.fail(-1, "打款的记录表id不能为空");
        }
        if (StrUtil.isBlank(dto.getPayPassword())) {
            return R.fail(-1, "打款验证密码不能为空");
        }
        return volunteerPaymentRecordsFacade.payoutCheck(dto);
    }



}
