You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
115 lines
2.8 KiB
115 lines
2.8 KiB
<?php
|
|
|
|
namespace backend\modules\shop\models\ars;
|
|
|
|
use Yii;
|
|
use yii\behaviors\TimestampBehavior;
|
|
|
|
/**
|
|
* This is the model class for table "ats_delivery".
|
|
*
|
|
* @property int $id
|
|
* @property int $order_id 订单id
|
|
* @property string $shipping_name 货流名称
|
|
* @property string $shipping_id 运货单位
|
|
* @property int $type 类型
|
|
* @property string $goods 商品
|
|
* @property int $status 状态
|
|
* @property string $decription 描述
|
|
* @property int $updated_at 更新时间
|
|
* @property int $created_at 创建时间
|
|
*/
|
|
class Delivery extends \yii\db\ActiveRecord
|
|
{
|
|
const TYPE_SHIPMENT_ALL = 1;
|
|
const TYPE_SHIPMENT_PORTION = 2;
|
|
|
|
public $deliveryGoods;
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public static function tableName()
|
|
{
|
|
return 'ats_delivery';
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function rules()
|
|
{
|
|
return [
|
|
[['order_id', 'type', 'status'], 'integer'],
|
|
[['shipping_id'], 'required'],
|
|
[['goods', 'decription'], 'string'],
|
|
[['shipping_name'], 'string', 'max' => 50],
|
|
[['shipping_id'], 'string', 'max' => 10],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function attributeLabels()
|
|
{
|
|
return [
|
|
'id' => 'id',
|
|
'order_id' => '订单id',
|
|
'shipping_name' => '货流名称',
|
|
'shipping_id' => '运货单位',
|
|
'type' => '类型',
|
|
'goods' => '商品',
|
|
'status' => '状态',
|
|
'decription' => '描述',
|
|
'updated_at' => '更新时间',
|
|
'created_at' => '创建时间',
|
|
];
|
|
}
|
|
|
|
|
|
/**
|
|
* @author linyao
|
|
* @email 602604991@qq.com
|
|
* @created Nov 8, 2019
|
|
*
|
|
* 行为存储创建时间和更新时间
|
|
*/
|
|
public function behaviors()
|
|
{
|
|
return [
|
|
[
|
|
'class' => TimestampBehavior::className(),
|
|
'createdAtAttribute' => 'created_at',
|
|
'updatedAtAttribute' => 'updated_at',
|
|
'value' => function() {
|
|
return time();
|
|
},
|
|
],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @param $column
|
|
* @param null $value
|
|
* @return bool
|
|
* 获取各状态数组
|
|
*/
|
|
public static function dropDown($column, $value = null)
|
|
{
|
|
$dropDownList = [
|
|
'type' => [
|
|
self::TYPE_SHIPMENT_ALL => '全部发货',
|
|
self::TYPE_SHIPMENT_PORTION => '部分发货',
|
|
],
|
|
];
|
|
|
|
//根据具体值显示对应的值
|
|
if ($value !== null)
|
|
return array_key_exists($column, $dropDownList) ? $dropDownList[$column][$value] : false;
|
|
//返回关联数组,用户下拉的filter实现
|
|
else
|
|
return array_key_exists($column, $dropDownList) ? $dropDownList[$column] : false;
|
|
}
|
|
|
|
}
|