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.

103 lines
2.9 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_sku".
  7. *
  8. * @property int $id
  9. * @property int $goods_id 商品id
  10. * @property string $goods_code 商品条码
  11. * @property string $goods_sn 商品唯一货号
  12. * @property string $goods_attr 属性匹配
  13. * @property int $weight 重量
  14. * @property int $length 长度
  15. * @property int $width 宽度
  16. * @property int $height 高度
  17. * @property int $diameter 直径
  18. * @property int $sold_count 已售数量
  19. * @property int $stock 库存
  20. * @property int $market_price 市场价
  21. * @property int $price 销售价
  22. * @property int $model_id 模型id
  23. * @property int $is_sale 该商品是否开放销售,1为是,0为否
  24. * @property int $sort_order 排序
  25. * @property int $is_delete 是否删除,1为已删除
  26. * @property int $created_at 创建时间
  27. * @property int $updated_at 更新时间
  28. */
  29. class GoodsSku extends \yii\db\ActiveRecord
  30. {
  31. /**
  32. * {@inheritdoc}
  33. */
  34. public static function tableName()
  35. {
  36. return 'ats_goods_sku';
  37. }
  38. /**
  39. * {@inheritdoc}
  40. */
  41. public function rules()
  42. {
  43. return [
  44. [['goods_id', 'weight', 'length', 'width', 'height', 'diameter', 'sold_count', 'stock', 'market_price', 'price', 'model_id', 'is_sale', 'sort_order', 'is_delete'], 'integer'],
  45. [['goods_code'], 'string', 'max' => 50],
  46. [['goods_sn', 'goods_attr'], 'string', 'max' => 60],
  47. ];
  48. }
  49. /**
  50. * {@inheritdoc}
  51. */
  52. public function attributeLabels()
  53. {
  54. return [
  55. 'id' => 'id',
  56. 'goods_id' => '商品id',
  57. 'goods_code' => '商品条码',
  58. 'goods_sn' => '商品唯一货号',
  59. 'goods_attr' => '属性匹配',
  60. 'weight' => '重量',
  61. 'length' => '长度',
  62. 'width' => '宽度',
  63. 'height' => '高度',
  64. 'diameter' => '直径',
  65. 'sold_count' => '已售数量',
  66. 'stock' => '库存',
  67. 'market_price' => '市场价',
  68. 'price' => '销售价',
  69. 'model_id' => '模型id',
  70. 'is_sale' => '该商品是否开放销售,1为是,0为否',
  71. 'sort_order' => '排序',
  72. 'is_delete' => '是否删除,1为已删除',
  73. 'created_at' => '创建时间',
  74. 'updated_at' => '更新时间',
  75. ];
  76. }
  77. /**
  78. * @author linyao
  79. * @email 602604991@qq.com
  80. * @created Nov 8, 2019
  81. *
  82. * 行为存储创建时间和更新时间
  83. */
  84. public function behaviors()
  85. {
  86. return [
  87. [
  88. 'class' => TimestampBehavior::className(),
  89. 'createdAtAttribute' => 'created_at',
  90. 'updatedAtAttribute' => 'updated_at',
  91. 'value' => function() {
  92. return time();
  93. },
  94. ],
  95. ];
  96. }
  97. }