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.

133 lines
4.2 KiB

  1. <?php
  2. namespace common\models\ars;
  3. use Yii;
  4. use yii\behaviors\TimestampBehavior;
  5. /**
  6. * This is the model class for table "ats_goods".
  7. *
  8. * @property int $id
  9. * @property int $pid 父级id
  10. * @property int $cat_id 后台商品类别id
  11. * @property int $brand_id 品牌id
  12. * @property int $shop_cat_id 前端商品类别id
  13. * @property string $name 商品名称
  14. * @property string $sn 商品唯一货号
  15. * @property string $code 商品货码
  16. * @property int $supplier_id 供应商id
  17. * @property int $weight 重量
  18. * @property int $length 长度
  19. * @property int $width 宽度
  20. * @property int $height 高度
  21. * @property int $diameter 直径
  22. * @property string $unit 单位
  23. * @property int $sold_count 已售数量
  24. * @property int $limit_count 限购数量
  25. * @property int $stock 库存
  26. * @property int $stock_warn 库存警告
  27. * @property int $market_price 市场价
  28. * @property int $price 销售价
  29. * @property string $brief 简介
  30. * @property string $description 详细介绍
  31. * @property int $image 图片id
  32. * @property int $model_id 模型id
  33. * @property int $is_sale 该商品是否开放销售,1为是,0为否
  34. * @property int $sort_order 排序
  35. * @property int $bouns_points 奖励积分
  36. * @property int $experience_points 经验值
  37. * @property int $is_delete 是否删除,1为已删除
  38. * @property int $express_template 配送详情id
  39. * @property int $created_at 创建时间
  40. * @property int $updated_at 更新时间
  41. */
  42. class Goods extends \yii\db\ActiveRecord
  43. {
  44. /**
  45. * {@inheritdoc}
  46. */
  47. public static function tableName()
  48. {
  49. return 'ats_goods';
  50. }
  51. /**
  52. * {@inheritdoc}
  53. */
  54. public function rules()
  55. {
  56. return [
  57. [['pid', 'cat_id', 'brand_id', 'shop_cat_id', 'supplier_id', 'weight', 'length', 'width', 'height', 'diameter', 'sold_count', 'limit_count', 'stock', 'stock_warn', 'market_price', 'price', 'image', 'model_id', 'is_sale', 'sort_order', 'bouns_points', 'experience_points', 'is_delete', 'express_template'], 'integer'],
  58. [['description'], 'string'],
  59. [['name'], 'string', 'max' => 120],
  60. [['sn'], 'string', 'max' => 60],
  61. [['code'], 'string', 'max' => 50],
  62. [['unit'], 'string', 'max' => 16],
  63. [['brief'], 'string', 'max' => 255],
  64. ];
  65. }
  66. /**
  67. * {@inheritdoc}
  68. */
  69. public function attributeLabels()
  70. {
  71. return [
  72. 'id' => 'id',
  73. 'pid' => '父级id',
  74. 'cat_id' => '后台商品类别id',
  75. 'brand_id' => '品牌id',
  76. 'shop_cat_id' => '前端商品类别id',
  77. 'name' => '商品名称',
  78. 'sn' => '商品唯一货号',
  79. 'code' => '商品货码',
  80. 'supplier_id' => '供应商id',
  81. 'weight' => '重量',
  82. 'length' => '长度',
  83. 'width' => '宽度',
  84. 'height' => '高度',
  85. 'diameter' => '直径',
  86. 'unit' => '单位',
  87. 'sold_count' => '已售数量',
  88. 'limit_count' => '限购数量',
  89. 'stock' => '库存',
  90. 'stock_warn' => '库存警告',
  91. 'market_price' => '市场价',
  92. 'price' => '销售价',
  93. 'brief' => '简介',
  94. 'description' => '详细介绍',
  95. 'image' => '图片id',
  96. 'model_id' => '模型id',
  97. 'is_sale' => '该商品是否开放销售,1为是,0为否',
  98. 'sort_order' => '排序',
  99. 'bouns_points' => '奖励积分',
  100. 'experience_points' => '经验值',
  101. 'is_delete' => '是否删除,1为已删除',
  102. 'express_template' => '配送详情id',
  103. 'created_at' => '创建时间',
  104. 'updated_at' => '更新时间',
  105. ];
  106. }
  107. /**
  108. * @author linyao
  109. * @email 602604991@qq.com
  110. * @created Nov 8, 2019
  111. *
  112. * 行为存储创建时间和更新时间
  113. */
  114. public function behaviors()
  115. {
  116. return [
  117. [
  118. 'class' => TimestampBehavior::className(),
  119. 'createdAtAttribute' => 'created_at',
  120. 'updatedAtAttribute' => 'updated_at',
  121. 'value' => function() {
  122. return time();
  123. },
  124. ],
  125. ];
  126. }
  127. }