Fans.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?php
  2. namespace addons\Wechat\common\models;
  3. use common\models\member\Auth;
  4. use common\models\member\Member;
  5. use common\traits\HasOneMember;
  6. use common\behaviors\MerchantBehavior;
  7. /**
  8. * This is the model class for table "{{%addon_wechat_fans}}".
  9. *
  10. * @property int $id
  11. * @property int|null $merchant_id 商户ID
  12. * @property int|null $store_id 店铺ID
  13. * @property int|null $member_id 用户id
  14. * @property string|null $unionid 唯一公众号ID
  15. * @property string $openid openid
  16. * @property string|null $nickname 昵称
  17. * @property string|null $head_portrait 头像
  18. * @property int|null $follow 是否关注[1:关注;0:取消关注]
  19. * @property int|null $follow_time 关注时间
  20. * @property int|null $unfollow_time 取消关注时间
  21. * @property int|null $group_id 分组id
  22. * @property string|null $tag 标签
  23. * @property string|null $last_longitude 最近经纬度上报
  24. * @property string|null $last_latitude 最近经纬度上报
  25. * @property string|null $last_address 最近经纬度上报地址
  26. * @property int|null $last_updated 最后更新时间
  27. * @property string|null $remark 粉丝备注
  28. * @property string|null $subscribe_scene 关注来源
  29. * @property string|null $qr_scene 二维码扫码场景
  30. * @property string|null $qr_scene_str 二维码扫码场景描述
  31. * @property int|null $status 状态[-1:删除;0:禁用;1启用]
  32. * @property int|null $created_at 添加时间
  33. * @property int|null $updated_at 修改时间
  34. */
  35. class Fans extends \yii\db\ActiveRecord
  36. {
  37. use MerchantBehavior, HasOneMember;
  38. /**
  39. * {@inheritdoc}
  40. */
  41. public static function tableName()
  42. {
  43. return '{{%addon_wechat_fans}}';
  44. }
  45. /**
  46. * {@inheritdoc}
  47. */
  48. public function rules()
  49. {
  50. return [
  51. [
  52. [
  53. 'merchant_id',
  54. 'store_id',
  55. 'member_id',
  56. 'follow',
  57. 'follow_time',
  58. 'unfollow_time',
  59. 'group_id',
  60. 'last_updated',
  61. 'status',
  62. 'created_at',
  63. 'updated_at'
  64. ],
  65. 'integer'
  66. ],
  67. [['tag'], 'safe'],
  68. [['unionid', 'qr_scene_str'], 'string', 'max' => 64],
  69. [['openid', 'nickname', 'subscribe_scene'], 'string', 'max' => 50],
  70. [['head_portrait'], 'string', 'max' => 255],
  71. [['last_longitude', 'last_latitude'], 'string', 'max' => 10],
  72. [['last_address'], 'string', 'max' => 100],
  73. [['remark'], 'string', 'max' => 30],
  74. [['qr_scene'], 'safe'],
  75. ];
  76. }
  77. /**
  78. * {@inheritdoc}
  79. */
  80. public function attributeLabels()
  81. {
  82. return [
  83. 'id' => 'ID',
  84. 'merchant_id' => '商户ID',
  85. 'store_id' => '店铺ID',
  86. 'member_id' => '用户id',
  87. 'unionid' => '唯一公众号ID',
  88. 'openid' => 'openId',
  89. 'nickname' => '昵称',
  90. 'head_portrait' => '头像',
  91. 'follow' => '关注状态', // [1:关注;0:取消关注]
  92. 'follow_time' => '关注时间',
  93. 'unfollow_time' => '取消关注时间',
  94. 'group_id' => '分组id',
  95. 'tag' => '标签',
  96. 'last_longitude' => '最近经纬度上报',
  97. 'last_latitude' => '最近经纬度上报',
  98. 'last_address' => '最近经纬度上报地址',
  99. 'last_updated' => '最后更新时间',
  100. 'remark' => '粉丝备注',
  101. 'subscribe_scene' => '关注来源',
  102. 'qr_scene' => '二维码扫码场景',
  103. 'qr_scene_str' => '二维码扫码场景描述',
  104. 'status' => '状态[-1:删除;0:禁用;1启用]',
  105. 'created_at' => '添加时间',
  106. 'updated_at' => '修改时间',
  107. ];
  108. }
  109. /**
  110. * 关联会员
  111. */
  112. public function getMember()
  113. {
  114. return $this->hasOne(Member::class, ['id' => 'member_id']);
  115. }
  116. /**
  117. * 关联授权
  118. */
  119. public function getAuth()
  120. {
  121. return $this->hasOne(Auth::class, ['oauth_client_user_id' => 'openid']);
  122. }
  123. /**
  124. * 标签关联
  125. *
  126. * @return \yii\db\ActiveQuery
  127. */
  128. public function getTags()
  129. {
  130. return $this->hasMany(FansTagMap::class, ['fans_id' => 'id']);
  131. }
  132. }
粤ICP备19079148号