Sku.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. namespace addons\TinyShop\common\models\product;
  3. use addons\TinyShop\common\models\repertory\Stock;
  4. use Yii;
  5. use addons\TinyShop\common\models\repertory\OrderDetail;
  6. /**
  7. * This is the model class for table "{{%addon_tiny_shop_product_sku}}".
  8. *
  9. * @property int $id
  10. * @property int|null $merchant_id 商户id
  11. * @property int|null $product_id 商品编码
  12. * @property string|null $name sku名称
  13. * @property string|null $picture 商品主图
  14. * @property float $price 价格
  15. * @property float $market_price 市场价格
  16. * @property float $cost_price 成本价
  17. * @property int $stock 库存
  18. * @property string|null $sku_no 商品编码
  19. * @property string|null $barcode 商品条码
  20. * @property float|null $weight 商品重量
  21. * @property float|null $volume 商品体积
  22. * @property int|null $sort 排序
  23. * @property string|null $data sku串
  24. * @property int|null $status 状态[-1:删除;0:禁用;1启用]
  25. * @property int|null $created_at 创建时间
  26. * @property int|null $updated_at 更新时间
  27. */
  28. class Sku extends \common\models\base\BaseModel
  29. {
  30. /**
  31. * {@inheritdoc}
  32. */
  33. public static function tableName()
  34. {
  35. return '{{%addon_tiny_shop_product_sku}}';
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. public function rules()
  41. {
  42. return [
  43. [['merchant_id', 'product_id', 'stock', 'sort', 'status', 'created_at', 'updated_at'], 'integer', 'min' => 0],
  44. [['price', 'market_price', 'cost_price', 'weight', 'volume'], 'number', 'min' => 0, 'max' => 9999999],
  45. [['price', 'market_price', 'cost_price', 'weight', 'volume', 'stock'], 'required'],
  46. [['name', 'picture'], 'string', 'max' => 255],
  47. [['sku_no', 'barcode'], 'string', 'max' => 100],
  48. [['data'], 'string', 'max' => 500],
  49. ];
  50. }
  51. /**
  52. * {@inheritdoc}
  53. */
  54. public function attributeLabels()
  55. {
  56. return [
  57. 'id' => 'ID',
  58. 'merchant_id' => '商户id',
  59. 'product_id' => '商品编码',
  60. 'name' => 'sku名称',
  61. 'picture' => '商品主图',
  62. 'price' => '销售价',
  63. 'market_price' => '划线价',
  64. 'cost_price' => '成本价',
  65. 'stock' => '库存',
  66. 'sku_no' => '商品编码',
  67. 'barcode' => '商品条码',
  68. 'weight' => '商品重量',
  69. 'volume' => '商品体积',
  70. 'sort' => '排序',
  71. 'data' => 'sku串',
  72. 'status' => '状态[-1:删除;0:禁用;1启用]',
  73. 'created_at' => '创建时间',
  74. 'updated_at' => '更新时间',
  75. ];
  76. }
  77. /**
  78. * 关联商品
  79. *
  80. * @return \yii\db\ActiveQuery
  81. */
  82. public function getProduct()
  83. {
  84. return $this->hasOne(Product::class, ['id' => 'product_id']);
  85. }
  86. /**
  87. * 关联仓库规格
  88. *
  89. * @return \yii\db\ActiveQuery
  90. */
  91. public function getRepertoryStock()
  92. {
  93. return $this->hasOne(Stock::class, ['sku_id' => 'id']);
  94. }
  95. }
粤ICP备19079148号