SaasCoupon.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. /**
  3. * 厦门云联储网络科技有限公司
  4. * https://www.baokuaiyun.com
  5. * Copyright (c) 2023 爆块云 All rights reserved.
  6. */
  7. namespace app\models;
  8. use Yii;
  9. use yii\db\ActiveRecord;
  10. use yii\behaviors\TimestampBehavior;
  11. /**
  12. * This is the model class for table "{{%saas_coupon}}".
  13. *
  14. * @property int $id
  15. * @property int $store_id
  16. * @property int $saas_id 用户id
  17. * @property int $coupon_id 优惠券id
  18. * @property int $coupon_auto_send_id 自动发放id
  19. * @property int $begin_time 有效期开始时间
  20. * @property int $end_time 有效期结束时间
  21. * @property int $is_expire 是否已过期:0=未过期,1=已过期
  22. * @property int $is_use 是否已使用:0=未使用,1=已使用
  23. * @property int $is_delete 是否删除
  24. * @property int $created_at 添加时间
  25. * @property int|null $type 领取类型 0--平台发放 1--自动发放 2--领券中心领取
  26. * @property int $integral 兑换支付积分数量
  27. * @property float $price 兑换支付价格
  28. * @property int|null $updated_at 更新时间
  29. * @property int $give_user_id
  30. */
  31. class SaasCoupon extends \yii\db\ActiveRecord
  32. {
  33. /**
  34. * {@inheritdoc}
  35. */
  36. public static function tableName()
  37. {
  38. return '{{%saas_coupon}}';
  39. }
  40. const IS_DELETE_YES = 1;//已删除
  41. const IS_DELETE_NO = 0;//未删除
  42. const IS_USE_NO = 0;//未使用
  43. const IS_USE_YES = 1;//已使用
  44. const IS_EXPIRE_NO = 0;//未过期
  45. const IS_EXPIRE_YES = 1;//已过期
  46. const TYPE_STORE = 0;//平台发放
  47. const TYPE_AUTO = 1;//自动发放
  48. const TYPE_GET = 2;//领券中心领取
  49. public function behaviors()
  50. {
  51. return [
  52. [
  53. 'class' => TimestampBehavior::class,
  54. 'attributes' => [
  55. ActiveRecord::EVENT_BEFORE_INSERT => ['updated_at', 'created_at'],
  56. ActiveRecord::EVENT_BEFORE_UPDATE => 'updated_at'
  57. ]
  58. ]
  59. ];
  60. }
  61. /**
  62. * {@inheritdoc}
  63. */
  64. public function rules()
  65. {
  66. return [
  67. [['store_id', 'saas_id', 'coupon_id'], 'required'],
  68. [['store_id', 'saas_id', 'coupon_id', 'coupon_auto_send_id', 'begin_time', 'end_time', 'is_expire', 'is_use', 'is_delete', 'created_at', 'type', 'integral', 'updated_at', 'give_user_id'], 'integer'],
  69. [['price'], 'number'],
  70. ];
  71. }
  72. /**
  73. * {@inheritdoc}
  74. */
  75. public function attributeLabels()
  76. {
  77. return [
  78. 'id' => 'ID',
  79. 'store_id' => 'Store ID',
  80. 'saas_id' => '用户id',
  81. 'coupon_id' => '优惠券id',
  82. 'coupon_auto_send_id' => '自动发放id',
  83. 'begin_time' => '有效期开始时间',
  84. 'end_time' => '有效期结束时间',
  85. 'is_expire' => '是否已过期:0=未过期,1=已过期',
  86. 'is_use' => '是否已使用:0=未使用,1=已使用',
  87. 'is_delete' => '是否删除',
  88. 'created_at' => '添加时间',
  89. 'type' => '领取类型 0--平台发放 1--自动发放 2--领券中心领取 3--saas福利中心 4--转赠',
  90. 'integral' => '兑换支付积分数量',
  91. 'price' => '兑换支付价格',
  92. 'updated_at' => '更新时间',
  93. ];
  94. }
  95. public function getCoupon()
  96. {
  97. return $this->hasOne(Coupon::className(), ['id' => 'coupon_id']);
  98. }
  99. public function getSaas()
  100. {
  101. return $this->hasOne(SaasUser::className(), ['id'=>'saas_id']);
  102. }
  103. }