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.

98 lines
2.4 KiB

  1. <?php
  2. namespace backend\modules\shop\models\ars;
  3. use Yii;
  4. use yii\behaviors\TimestampBehavior;
  5. use backend\modules\shop\models\ars\Order;
  6. /**
  7. * This is the model class for table "ats_order_goods".
  8. *
  9. * @property int $id
  10. * @property int $order_id 订单id
  11. * @property int $goods_id 商品id
  12. * @property int $goods_img 商品图片
  13. * @property string $goods_name 商品名称
  14. * @property int $goods_count 商品数量
  15. * @property string $sku_value 商品sku
  16. * @property int $price 销售价
  17. * @property int $market_price 市场价
  18. * @property int $updated_at 更新时间
  19. * @property int $created_at 创建时间
  20. * @property int $weight 重量
  21. * @property int $sku_id sku_id
  22. */
  23. class OrderGoods extends \yii\db\ActiveRecord
  24. {
  25. public $lack_number;
  26. /**
  27. * {@inheritdoc}
  28. */
  29. public static function tableName()
  30. {
  31. return 'ats_order_goods';
  32. }
  33. /**
  34. * {@inheritdoc}
  35. */
  36. public function rules()
  37. {
  38. return [
  39. [['order_id', 'goods_id'], 'required'],
  40. [['order_id', 'goods_id', 'goods_img', 'goods_count', 'price', 'market_price', 'weight', 'sku_id'], 'integer'],
  41. [['goods_name', 'sku_value'], 'string', 'max' => 120],
  42. ];
  43. }
  44. /**
  45. * {@inheritdoc}
  46. */
  47. public function attributeLabels()
  48. {
  49. return [
  50. 'id' => 'id',
  51. 'order_id' => '订单id',
  52. 'goods_id' => '商品id',
  53. 'goods_img' => '商品图片',
  54. 'goods_name' => '商品名称',
  55. 'goods_count' => '商品数量',
  56. 'sku_value' => '商品sku',
  57. 'price' => '销售价',
  58. 'market_price' => '市场价',
  59. 'updated_at' => '更新时间',
  60. 'created_at' => '创建时间',
  61. 'weight' => '重量',
  62. 'sku_id' => 'sku_id',
  63. ];
  64. }
  65. /**
  66. * @author linyao
  67. * @email 602604991@qq.com
  68. * @created Nov 8, 2019
  69. *
  70. * 行为存储创建时间和更新时间
  71. */
  72. public function behaviors()
  73. {
  74. return [
  75. [
  76. 'class' => TimestampBehavior::className(),
  77. 'createdAtAttribute' => 'created_at',
  78. 'updatedAtAttribute' => 'updated_at',
  79. 'value' => function() {
  80. return time();
  81. },
  82. ],
  83. ];
  84. }
  85. public function getOrder()
  86. {
  87. return $this->hasOne(Order::className(), ['id' => 'order_id']);
  88. }
  89. }