<?php

class Service_InvtManifiest extends Common_Service
{
    /**
     * @var null
     */
    public static $_modelClass = null;

    /**
     * @return Table_Bank|null
     */
    public static function getModelInstance() {
        if (is_null(self::$_modelClass)) {
            self::$_modelClass = new Table_InvtManifiest();
        }
        return self::$_modelClass;
    }

    /**
     * @param $row
     * @return mixed
     */
    public static function add($row) {
        $model = self::getModelInstance();
        return $model->add($row);
    }


    /**
     * @param $row
     * @param $value
     * @param string $field
     * @return mixed
     */
    public static function update($row, $value, $field = "im_id") {
        $model = self::getModelInstance();
        return $model->update($row, $value, $field);
    }

    /**
     * @param $value
     * @param string $field
     * @return mixed
     */
    public static function delete($value, $field = "im_id") {
        $model = self::getModelInstance();
        return $model->delete($value, $field);
    }

    /**
     * @param $value
     * @param string $field
     * @param string $colums
     * @return mixed
     */
    public static function getByField($value, $field = 'im_id', $colums = "*") {
        $model = self::getModelInstance();
        return $model->getByField($value, $field, $colums);
    }

    /**
     * @return mixed
     */
    public static function getAll() {
        $model = self::getModelInstance();
        return $model->getAll();
    }

    /**
     * @param array $condition
     * @param string $type
     * @param int $pageSize
     * @param int $page
     * @param string $order
     * @return mixed
     */
    public static function getByCondition($condition = array(), $type = '*', $pageSize = 0, $page = 1, $order = "") {
        $model = self::getModelInstance();
        return $model->getByCondition($condition, $type, $pageSize, $page, $order);
    }

    /**
     * @param $val
     * @return array
     */
    public static function validator($val) {
        $validateArr = $error = array();

        return Common_Validator::formValidator($validateArr);
    }

    public static function checkHasGift($id){
        $model = self::getModelInstance();
        return $model->checkHasGift($id);
    }

    public static function getImType(){
        return [
            '1'=>'BBC',
            '2'=>'单创区内互转',
            '3'=>'退货入区',
            // '4'=>'普通备货入区',
        ];
    }
    /**
     * Note:
     * User: Yao
     * Date: 2020/11/14
     * Time: 13:43
     */
    public static function getStatus(){
            return [
                '0'=>'草稿',
                '1'=>'生成核注清单',
                '2'=>'申报中',
                '3'=>'已申报',
                '4'=>'申报完成',
            ];
    }
    /**
     * @param array $params
     * @return array
     */
    public function getFields() {
        $row = array(
            'E0' => 'im_id',
            'E1' => 'im_code',
            'E2' => 'im_add_time',
            'E3' => 'order_count',
            'E4'=>'im_status',
            'E5'=>'im_type',
            'E6' =>'gift_flag',
        );
        return $row;
    }

}