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.

105 lines
3.0 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_manaul 是否手动
  24. * @property int $weight 重量
  25. */
  26. class GoodsSku extends \yii\db\ActiveRecord
  27. {
  28. //是否手动is_manaul
  29. const IS_MANUAL_YES = 1; //是手动
  30. const IS_MANUAL_NO = 0; //不是手动
  31. //是否删除is_delete
  32. const IS_DELETE_NO = 0;//未删除
  33. const IS_DELETE_YES = 1;//已删除
  34. /**
  35. * {@inheritdoc}
  36. */
  37. public static function tableName()
  38. {
  39. return 'atg_goods_sku';
  40. }
  41. /**
  42. * {@inheritdoc}
  43. */
  44. public function rules()
  45. {
  46. return [
  47. [['goods_id', 'goods_sn'], 'required'],
  48. [['goods_id', 'sold_count', 'stock', 'market_price', 'price', 'model_id', 'is_sale', 'sort_order', 'is_delete', 'is_manaul'], 'integer'],
  49. [['goods_code'], 'string', 'max' => 50],
  50. [['goods_sn', 'goods_attr'], 'string', 'max' => 60],
  51. [['weight'], 'safe']
  52. ];
  53. }
  54. /**
  55. * {@inheritdoc}
  56. */
  57. public function attributeLabels()
  58. {
  59. return [
  60. 'id' => 'id',
  61. 'goods_id' => '商品id',
  62. 'goods_code' => '商品条码',
  63. 'goods_sn' => '商品唯一货号',
  64. 'goods_attr' => '属性匹配',
  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. 'weight' => '重量',
  76. ];
  77. }
  78. /**
  79. * @author linyao
  80. * @email 602604991@qq.com
  81. * @created Nov 8, 2019
  82. *
  83. * 行为存储创建时间和更新时间
  84. */
  85. public function behaviors()
  86. {
  87. return [
  88. [
  89. 'class' => TimestampBehavior::className(),
  90. 'createdAtAttribute' => 'created_at',
  91. 'updatedAtAttribute' => 'updated_at',
  92. 'value' => function() {
  93. return time();
  94. },
  95. ],
  96. ];
  97. }
  98. }