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.

107 lines
3.1 KiB

  1. <?php
  2. namespace backend\modules\goods\models\ars;
  3. use Yii;
  4. use yii\behaviors\TimestampBehavior;
  5. /**
  6. * This is the model class for table "atg_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 $sold_count 已售数量
  14. * @property int $stock 库存
  15. * @property int $market_price 市场价
  16. * @property int $price 销售价
  17. * @property int $model_id 模型id
  18. * @property int $is_sale 该商品是否开放销售,1为是,0为否
  19. * @property int $sort_order 排序
  20. * @property int $is_delete 是否删除,1为已删除
  21. * @property int $created_at 创建时间
  22. * @property int $updated_at 更新时间
  23. * @property int $is_manual 是否手动
  24. * @property int $weight 重量
  25. * @property int $sku_image sku图片id
  26. */
  27. class GoodsSku extends \yii\db\ActiveRecord
  28. {
  29. //是否手动is_manual
  30. const IS_MANUAL_YES = 1; //是手动
  31. const IS_MANUAL_NO = 0; //不是手动
  32. //是否删除is_delete
  33. const IS_DELETE_NO = 0;//未删除
  34. const IS_DELETE_YES = 1;//已删除
  35. /**
  36. * {@inheritdoc}
  37. */
  38. public static function tableName()
  39. {
  40. return 'atg_goods_sku';
  41. }
  42. /**
  43. * {@inheritdoc}
  44. */
  45. public function rules()
  46. {
  47. return [
  48. [['goods_id', 'goods_sn'], 'required'],
  49. [['goods_id', 'sold_count', 'stock', 'market_price', 'price', 'model_id', 'is_sale', 'sort_order', 'is_delete', 'is_manual', 'sku_image'], 'integer'],
  50. [['goods_code'], 'string', 'max' => 50],
  51. [['goods_sn', 'goods_attr'], 'string', 'max' => 60],
  52. [['weight'], 'safe']
  53. ];
  54. }
  55. /**
  56. * {@inheritdoc}
  57. */
  58. public function attributeLabels()
  59. {
  60. return [
  61. 'id' => 'id',
  62. 'goods_id' => '商品id',
  63. 'goods_code' => '商品条码',
  64. 'goods_sn' => '商品唯一货号',
  65. 'goods_attr' => '属性匹配',
  66. 'sold_count' => '已售数量',
  67. 'stock' => '库存',
  68. 'market_price' => '市场价',
  69. 'price' => '销售价',
  70. 'model_id' => '模型id',
  71. 'is_sale' => '该商品是否开放销售,1为是,0为否',
  72. 'sort_order' => '排序',
  73. 'is_delete' => '是否删除,1为已删除',
  74. 'created_at' => '创建时间',
  75. 'updated_at' => '更新时间',
  76. 'weight' => '重量',
  77. 'sku_image' => 'sku图片id',
  78. ];
  79. }
  80. /**
  81. * @author linyao
  82. * @email 602604991@qq.com
  83. * @created Nov 8, 2019
  84. *
  85. * 行为存储创建时间和更新时间
  86. */
  87. public function behaviors()
  88. {
  89. return [
  90. [
  91. 'class' => TimestampBehavior::className(),
  92. 'createdAtAttribute' => 'created_at',
  93. 'updatedAtAttribute' => 'updated_at',
  94. 'value' => function() {
  95. return time();
  96. },
  97. ],
  98. ];
  99. }
  100. }