package com.jeeplus.centerservice.controller.ccpm;

import com.jeeplus.centerservice.dto.SaveInfoDto;
import com.jeeplus.centerservice.service.ccpm.reimbursement.ReimbursementService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/ccpm_reimbursement")
public class ReimbursementController {


    @Resource
    private ReimbursementService reimbursementService;

    /**
     * 根据id查询报销详情
     * @param id
     * @return
     */
    @GetMapping("getReimbursementById")
    public ResponseEntity getReimbursementById(String id, String processDefKey) {
        SaveInfoDto saveInfoDto = reimbursementService.getReimbursementById(id, processDefKey);
        return ResponseEntity.ok (saveInfoDto);
    }

    /**
     * 报销审核
     * @param id
     * @param flag yes 审核通过 no 审核失败
     * @param comment 审批意见
     * @param processDefKey 流程类型
     * @return
     */
    @GetMapping("reimAudit")
    public ResponseEntity reimAudit(String id, String flag, String comment, String processDefKey) {
        Map<String, Object> resultMap = this.reimbursementService.reimAudit(id, flag, comment, processDefKey);
        return ResponseEntity.ok (resultMap);
    }

    /**
     * 开票审核
     * @param id
     * @param flag yes 审核通过 no 审核失败
     * @param comment 审批意见
     * @param processDefKey 流程类型
     * @return
     */
    @GetMapping("invoiceAudit")
    public ResponseEntity invoiceAudit(String id, String flag, String comment, String processDefKey,String jsonData) {
        Map<String, Object> resultMap = this.reimbursementService.invoiceAudit(id, flag, comment, processDefKey,jsonData);
        return ResponseEntity.ok (resultMap);
    }

    /**
     * 报销重新申请
     * @param id
     * @return
     */
    @GetMapping("reimReapply")
    public ResponseEntity reimReapply(String id, String processDefKey) {
        Map<String, Object> resultMap = this.reimbursementService.reimAudit(id, "yes", null, processDefKey);
        return ResponseEntity.ok (resultMap);
    }

    /**
     * 报销申请删除
     * @param id
     * @return
     */
    @GetMapping("deleteReim")
    public ResponseEntity deleteReim(String id) {
        Map<String, Object> resultMap = this.reimbursementService.deleteReim(id);
        return ResponseEntity.ok (resultMap);
    }

    /**
     * 查询发票号是否重复
     */
    @GetMapping("queryByNumber")
    public boolean queryByNumber(String number) {
        boolean data = this.reimbursementService.queryByNumber(number);
        return data;
    }


}
