SaasIntegralGoods.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. namespace app\plugins\integral\models;
  8. use app\models\Goods;
  9. use Yii;
  10. use yii\db\ActiveRecord;
  11. use yii\behaviors\TimestampBehavior;
  12. /**
  13. * This is the model class for table "{{%saas_integral_goods}}".
  14. *
  15. * @property int $id
  16. * @property int $store_id
  17. * @property int $goods_id
  18. * @property int $cat_id
  19. * @property int $goods_count
  20. * @property int $detail
  21. * @property string $name
  22. * @property int $integral
  23. * @property int $status
  24. * @property int $user_num
  25. * @property string $attr
  26. * @property int $sales
  27. * @property int $sort
  28. * @property int $is_delete
  29. * @property int|null $created_at 添加时间
  30. * @property int|null $updated_at 更新时间
  31. */
  32. class SaasIntegralGoods extends \yii\db\ActiveRecord
  33. {
  34. /**
  35. * {@inheritdoc}
  36. */
  37. public static function tableName()
  38. {
  39. return '{{%saas_integral_goods}}';
  40. }
  41. // 已删除
  42. const IS_DELETE_YES = 1;
  43. // 未删除
  44. const IS_DELETE_NO = 0;
  45. public function behaviors()
  46. {
  47. return [
  48. [
  49. 'class' => TimestampBehavior::class,
  50. 'attributes' => [
  51. ActiveRecord::EVENT_BEFORE_INSERT => ['updated_at', 'created_at'],
  52. ActiveRecord::EVENT_BEFORE_UPDATE => 'updated_at'
  53. ]
  54. ]
  55. ];
  56. }
  57. /**
  58. * {@inheritdoc}
  59. */
  60. public function rules()
  61. {
  62. return [
  63. [['store_id', 'goods_id'], 'required'],
  64. [['store_id', 'goods_id', 'goods_count', 'sales', 'integral', 'status', 'user_num', 'sort', 'is_delete', 'created_at'], 'integer'],
  65. [['attr', 'name', 'detail'], 'string'],
  66. ];
  67. }
  68. /**
  69. * {@inheritdoc}
  70. */
  71. public function attributeLabels()
  72. {
  73. return [
  74. 'id' => 'ID',
  75. 'store_id' => 'Store ID',
  76. 'goods_id' => '商品id',
  77. 'goods_count' => '商品数量',
  78. 'name' => '商品名称',
  79. 'detail' => '商品详情',
  80. 'integral' => '所需积分',
  81. 'status' => '状态',
  82. 'user_num' => '每个人限制兑换数量',
  83. 'attr' => '详细规格',
  84. 'sales' => '商品虚拟销量',
  85. 'sort' => '排序',
  86. 'is_delete' => '是否删除',
  87. 'created_at' => '添加时间',
  88. 'updated_at' => '更新时间'
  89. ];
  90. }
  91. public static function getGoods($goods_id)
  92. {
  93. return Goods::findOne($goods_id);
  94. }
  95. }