RedPacketRecord.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * 厦门云联储网络科技有限公司
  4. * https://www.baokuaiyun.com
  5. * Copyright (c) 2023 爆块云 All rights reserved.
  6. */
  7. namespace app\models;
  8. use app\constants\OptionSetting;
  9. use app\modules\alliance\models\CurrencyForm;
  10. use app\plugins\scanCodePay\models\Order as ScanCodePayOrder;
  11. use app\plugins\scanCodePay\models\Order as ScanOrder;
  12. use yii\db\ActiveRecord;
  13. use yii\behaviors\TimestampBehavior;
  14. use Yii;
  15. use yii\helpers\Json;
  16. /**
  17. * This is the model class for table "{{%red_packet_record}}".
  18. *
  19. * @property integer $id
  20. * @property integer $user_id
  21. * @property integer $saas_id
  22. * @property integer $currency_id
  23. * @property integer $packet_id
  24. * @property float $amount
  25. * @property integer $store_id
  26. * @property integer $created_at
  27. */
  28. class RedPacketRecord extends \yii\db\ActiveRecord
  29. {
  30. public static function tableName()
  31. {
  32. return '{{%red_packet_record}}';
  33. }
  34. public function behaviors()
  35. {
  36. return [
  37. [
  38. 'class' => TimestampBehavior::class,
  39. 'attributes' => [
  40. ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'],
  41. ]
  42. ]
  43. ];
  44. }
  45. public function rules()
  46. {
  47. return [
  48. [['packet_id', 'user_id', 'amount'], 'required'],
  49. [['packet_id', 'user_id','store_id','id','currency_id','is_receive'], 'integer'],
  50. [['created_at'], 'safe'],
  51. [['amount'], 'number', 'min' => 0.01],
  52. ];
  53. }
  54. public function getPacket()
  55. {
  56. return $this->hasOne(RedPacket::class, ['id' => 'packet_id']);
  57. }
  58. }