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.

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