<?php
class Service_ShipBatchOrderProduct extends Common_Service
{
    /**
     * @var null
     */
    public static $_modelClass = null;

    /**
     * @return Table_ShipBatchDetail|null
     */
    public static function getModelInstance()
    {
        if (is_null(self::$_modelClass)) {
            self::$_modelClass = new Table_ShipBatchOrderProduct();
        }
        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 = "sbmbh_id")
    {
        $model = self::getModelInstance();
        return $model->update($row, $value, $field);
    }

    /**
     * @param $value
     * @param string $field
     * @return mixed
     */
    public static function delete($value, $field = "sbd_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 = 'sbd_id', $colums = "*")
    {
        $model = self::getModelInstance();
        return $model->getByField($value, $field, $colums);
    }

    /**
     * @return mixed
     */
    public static function getAll()
    {
        $model = self::getModelInstance();
        return $model->getAll();
    }
    
    /**
     * 统计数量和重量
     * @author solar
     * @param string $sb_code
     * @return array
     */
    public static function stat($sb_code) {
    	$model = self::getModelInstance();
    	return $model->stat($sb_code);
    }
    
    /**
     * 计算毛重
     * @author solar
     * @param string $sb_code
     * @return float
     */
    public static function sumGrossWeight($sb_code) {
    	$model = self::getModelInstance();
    	return $model->sumGrossWeight($sb_code);
    }
    
    /**
     * 计算净重
     * @author solar
     * @param string $sb_code
     * @return float
     */
    public static function sumNetWeight($sb_code) {
    	$model = self::getModelInstance();
    	return $model->sumNetWeight($sb_code);
    }
    
    public static function sumLawWeight($sb_code) {
    	$model = self::getModelInstance();
    	return $model->sumLawWeight($sb_code);
    }
    
    public static function countHscodeNum($sb_code) {
    	$model = self::getModelInstance();
    	return $model->countHscodeNum($sb_code);
    }

    /**
     * @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);
    }


    /**
     * @param array $params
     * @return array
     */
    public  function getFields()
    {
        $row = array(
        
              'E0'=>'sbop_id',
              'E1'=>'sb_code',
              'E2'=>'order_code',
              'E3'=>'product_id',
              'E4'=>'product_barcode',
              'E5'=>'op_quantity',
        	  'E6'=>'product_weight',
        	  'E7'=>'pu_code_law',
        	  'E8'=>'hum_quantity_law',
        	  'E9'=>'pu_code_second',
        	  'E10'=>'hum_quantity_second',
        	  'E11'=>'hs_goods_name',
        	  'E12'=>'hs_code',
        	  'E13'=>'hem_detail',
        	  'E14'=>'pu_code',        		
        	  'E15'=>'goods_id',
        	  'E16'=>'op_id'		
        );
        return $row;
    }

}