package com.malk.pake.event;

import com.malk.delegate.DDEvent;
import com.malk.pake.service.PkDingProcService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

@Slf4j
@Service
@Primary
public class PkDingEventImpl implements DDEvent {

    @Autowired
    private PkDingProcService pkDingProcService;

    // 费用报销申请CODE
    private static String DING_PROC_FKD_CODE="PROC-66F95835-9E73-45BE-AB3A-36C5D576489D";

    @Override
    public void executeEvent_Task_Finish(String processInstanceId, String processCode, boolean isAgree, String remark) {
        // 审批任务回调执行业务逻辑
    }

    @Override
    public void executeEvent_Task_Start(String processInstanceId, String processCode) {

    }

    @Override
    public void executeEvent_Task_Redirect(String processInstanceId, String processCode) {

    }

    @Override
    public void executeEvent_Instance_Finish(String processInstanceId, String processCode, boolean isAgree, boolean isTerminate, String staffId) {
        // 审批实例回调执行业务逻辑
        log.info("帕科审批任务完成回调，processInstanceId：{},processCode{}",processInstanceId,processCode);
        if(DING_PROC_FKD_CODE.equals(processCode)&&isAgree){
            log.info("进入同步");
            pkDingProcService.syncAmt(processInstanceId);
        }
    }

    @Override
    public void executeEvent_Instance_Start(String processInstanceId, String processCode) {

    }
}
