| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- <?php
- namespace addons\DoubleCopy\common\models;
- use common\models\user\User;
- use Yii;
- use yii\db\Exception;
- /**
- * This is the model class for table "{{%addons_double_copy_change_topid}}".
- *
- * @property int $id
- * @property int $change_pos_id qimall_addons_double_copy_change_pos.id
- * @property int $mall_id 商城ID
- * @property int|null $user_id 用户ID
- * @property int|null $old_topid 原topid
- * @property int|null $now_topid 现topid
- * @property int $status 状态[-1:删除;0:禁用;1启用]
- * @property int|null $created_at 创建时间
- * @property int|null $updated_at 更新时间
- */
- class DoubleCopyChangeTopid extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_double_copy_change_topid}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['change_pos_id', 'mall_id', 'user_id', 'old_topid', 'now_topid', 'status', 'created_at', 'updated_at'], 'integer'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'change_pos_id' => 'qimall_addons_double_copy_change_pos.id',
- 'mall_id' => '商城ID',
- 'user_id' => '用户ID',
- 'old_topid' => '原topid',
- 'now_topid' => '现topid',
- 'status' => '状态[-1:删除;0:禁用;1启用]',
- 'created_at' => '创建时间',
- 'updated_at' => '更新时间',
- ];
- }
- /**
- * 关联用户
- * @Author: lun
- * @DateTime: 2023/6/3 0003 15:51
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @return \yii\db\ActiveQuery
- */
- public function getUser()
- {
- return $this->hasOne(User::class, ['id' => 'user_id'])->select('id,nickname,mobile,avatar_url,parent_id');
- }
- /**
- * 换位前用户
- * @Author: lun
- * @DateTime: 2023/6/3 0003 15:51
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @return \yii\db\ActiveQuery
- */
- public function getOldTop()
- {
- return $this->hasOne(User::class, ['id' => 'old_topid'])->select('id,nickname,mobile,avatar_url,parent_id');
- }
- /**
- * 换位后用户
- * @Author: lun
- * @DateTime: 2023/6/3 0003 15:52
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @return \yii\db\ActiveQuery
- */
- public function getNowTop()
- {
- return $this->hasOne(User::class, ['id' => 'now_topid'])->select('id,nickname,mobile,avatar_url,parent_id');
- }
- /**
- * 保存数据
- * @Author: lun
- * @DateTime: 2023/6/2 0002 15:53
- * @Copyright: copyright (c) 2021 广东七件事集团
- * @param $params
- * @return bool
- */
- public static function setData($params)
- {
- try {
- $model = new self();
- $model->loadDefaultValues();
- if (!$model->load($params, '') || !$model->save()) throw new Exception($model->getErrorMessage());
- return true;
- } catch (\Exception $e) {
- self::setStaticError($e->getMessage());
- return false;
- }
- }
- }
|