<?php

class flow_emfkClassModel extends flowModel
{
    const PAYMENT_STATUS = [
        0 => '待审核',
        1 => '未提交',
        2 => '审核中',
        3 => '已付款',
        4 => '已付款 缺发票',
        5 => '已付款 发票已上传',
        7 => '被驳回',
        8 => '已确收',
        9 => '审核失败',
    ];

    protected function flowcheckfinsh($zt)
    {
        m('log')->addlog('电费付款','审核通过');
        $this->sendMess(1,3);
    }

    /**
     * 审核时触发
     * @param $zt 1同意 2拒绝
     * @param $sm
     */
    protected function flowcheckafter($zt, $sm){
        m('log')->addlog('电费付款','未通过');
        $this->updatestatus(5);
        if($zt == 2) $this->sendMess(0,9);
    }

    /**
     * @param int $messType 动作
     * @param int $status 状态
     */
    private function sendMess($messType = 0,$status = 3){
        m('log')->addlog('电费付款','接口动作:'.$messType.'状态:'.$status);

        $url = getconfig('base_url'). 'v2/payment?key=';
        $key = substr(md5(getconfig('openkey').date('Y-m-d')),0,12);
        $url = $url.$key.'&git ='.$messType; //接口地址
        $url .= '&numb='.$this->rs['docnum'];
        $url .= '&status='.$status;
        m('log')->addlog('电费付款','接口返回信息: url '.$url);
        $url .= '&mes='.'';
        $res = curlGet($url);
        m('log')->addlog('电费付款','接口返回信息:' .$res);

    }
}