<?php

namespace app\common\state;

class IntegralState {

    public const SAVE = 1; //保存未提交
    public const SUBMIT = 2; //已提交未审核
    public const VERIFY_PASS = 3; //初审通过
    public const VERIFY_REJECT = 4; //初审驳回
    public const VERIFY_FAIL = 5; //初审失败
    public const REVERIFY_PASS = 6; //复审通过
    public const REVERIFY_REJECT = 7; //复审驳回
    public const REVERIFY_FAIL = 8; //复审失败
    public const ZX_PASS = 21; //征信通过|待公示
    public const ZX_FAIL = 22; //征信失信|审核不通过
    public const ANNOUNCED = 23; //已公示
    public const ANNOUNCED_REVERIFY_PASS = 24; //公示再审核通过|待公布
    public const ANNOUNCED_REVERIFY_FAIL = 25; //公示再审核不通过
    public const PUBLISH_PASS = 26; //公布通过
    public const PUBLISH_FAIL = 27; //公布不通过
    public const SUCCESS = 28; //积分兑现成功

    public static function getStateName($state) {
        switch ($state) {
            case 1:
                return "保存未提交";
            case 2:
                return "待初审";
            case 3:
                return "初审通过";
            case 4:
                return "初审驳回";
            case 5:
                return "初审不通过";
            case 6:
                return "复审通过";
            case 7:
                return "复审驳回";
            case 8:
                return "复审不通过";
            case 21:
                return "待公示";
            case 22:
                return "征信不通过";
            case 23:
                return "已公示";
            case 24:
                return "待公布";
            case 25:
                return "公示审核不通过";
            case 26:
                return "公布通过";
            case 27:
                return "公布不通过";
            case 28:
                return "积分已入账";
        }
    }

    public static function getLogStepName($state) {
        switch ($state) {
            case 3:
            case 4:
            case 5:
                return '<span class="label label-primary">初级审核</span>';
            case 6:
            case 7:
            case 8:
                return '<span class="label label-info">复核</span>';
            case 21:
            case 22:
                return '<span class="label label-info">核查征信</span>';
            case 23:
            case 24:
            case 25:
                return '<span class="label label-info">公示</span>';
            case 26:
            case 27:
                return '<span class="label label-info">公布</span>';
            case 28:
                return '<span class="label label-inverse">发放积分</span>';
            default:
                return "<span class='label'>用户操作</span>";
        }
    }

    public static function getLogStateName($state, $last_state) {
        if (in_array($state, [self::VERIFY_FAIL, self::REVERIFY_FAIL, self::ZX_FAIL, self::ANNOUNCED_REVERIFY_FAIL, self::PUBLISH_FAIL])) {
            return '<span class="label label-danger">审核不通过</span>';
        } else if (in_array($state, [self::VERIFY_PASS, self::REVERIFY_PASS])) {
            return '<span class="label label-primary">审核通过</span>';
        } else if (in_array($state, [self::VERIFY_REJECT, self::REVERIFY_REJECT])) {
            return '<span class="label label-danger">审核驳回</span>';
        } else if (in_array($state, [self::ZX_PASS, self::ANNOUNCED, self::ANNOUNCED_REVERIFY_PASS, self::PUBLISH_PASS, self::SUCCESS])) {
            return '<span class="label label-primary">审核通过</span>';
        } else if (in_array($state, [self::SAVE])) {
            return '<span class="label">保存未提交</span>';
        } else if ($state == 0) {
            return '<span class="label">添加附件</span>';
        } else {
            if ($last_state == self::VERIFY_REJECT && $state == self::SUBMIT) {
                return '<span class="label label-success">待审核（重新提交）</span>';
            } else {
                return '<span class="label label-success">待审核</span>';
            }
        }
    }

    public static function getLogChangeName($state, $last_state = 0) {
        $str = "";
        switch ($state) {
            case self::SAVE:
                if ($last_state == self::VERIFY_REJECT) {
                    $str = '<span class="label label-danger">初审驳回</span>';
                } else {
                    $str = '<span class="label">保存待提交</span>';
                }
                break;
            case self::SUBMIT:
                if ($last_state == self::REVERIFY_REJECT) {
                    $str = '<span class="label label-danger">复审驳回</span>';
                } else {
                    $str = '<span class="label label-success">待初审</span>';
                }
                break;
            case self::VERIFY_PASS:
                $str = '<span class="label label-primary">待复审</span>';
                break;
            case self::VERIFY_FAIL:
                $str = '<span class="label label-danger">初审不通过</span>';
                break;
            case self::REVERIFY_PASS:
                $str = '<span class="label label-success">待核查征信</span>';
                break;
            case self::REVERIFY_FAIL:
                $str = '<span class="label label-danger">复审不通过</span>';
                break;
            case self::ZX_PASS:
                $str = '<span class="label label-success">待公示</span>';
                break;
            case self::ZX_FAIL:
                $str = '<span class="label label-danger">征信不通过</span>';
                break;
            case self::ANNOUNCED:
                $str = '<span class="label label-success">待公示审核</span>';
                break;
            case self::ANNOUNCED_REVERIFY_PASS:
                $str = '<span class="label label-success">待公布</span>';
                break;
            case self::ANNOUNCED_REVERIFY_FAIL:
                $str = '<span class="label label-danger">公示审核不通过</span>';
                break;
            case self::PUBLISH_PASS:
                $str = '<span class="label label-success">积分待入账</span>';
                break;
            case self::PUBLISH_FAIL:
                $str = '<span class="label label-danger">公布不通过</span>';
                break;
            case self::SUCCESS:
                $str = '<span class="label label-primary">积分已入账</span>';
                break;
        }
        return $str;
    }

}
