| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
- namespace addons\Happiness\common\models;
- use common\enums\StatusEnum;
- use Yii;
- /**
- * This is the model class for table "qimall_addons_happiness_third_user".
- *
- * @property int $id
- * @property int $user_id 用户ID
- * @property int $uid 积分平台用户ID
- * @property int $mall_id 商城ID
- * @property int $type 第三方平台类型:1 养老金平台 2 积分平台
- * @property string $id_no 身份证号
- * @property string $id_img 身份证正面图片
- * @property string $id_back_img 身份证反面图片
- * @property int $is_real 是否需要实名,0 为未实名 1为已实名
- * @property string $user_name 用户姓名
- * @property int $status 状态:0 禁用 1正常
- * @property int $created_at
- * @property int $updated_at
- */
- class HappinessThirdUser extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return 'qimall_addons_happiness_third_user';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['user_id', 'uid', 'mall_id', 'type', 'is_real', 'status', 'created_at', 'updated_at'], 'integer'],
- [['id_no', 'id_img', 'id_back_img','user_name'], 'string', 'max' => 255],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'user_id' => 'User ID',
- 'uid' => 'Uid',
- 'mall_id' => 'Mall ID',
- 'type' => 'Type',
- 'id_no' => 'Id No',
- 'id_img' => 'Id Img',
- 'id_back_img' => 'Id Back Img',
- 'is_real' => 'Is Real',
- 'status' => 'Status',
- 'created_at' => 'Created At',
- 'updated_at' => 'Updated At',
- ];
- }
- public function getUser()
- {
- return $this->hasOne(User::class, ['id' => 'user_id']);
- }
- public static function setData($params)
- {
- try {
- if(isset($params['id']) && !empty($params['id']))
- $model = self::findOne($params['id']);
- elseif(isset($params['user_id']) && !empty($params['type']))
- $model = self::findOne(['user_id' => $params['user_id'], 'type' => $params['type']]);
- if (!$model) {
- $model = new self();
- $model->loadDefaultValues();
- }
- if (!$model->load($params, '') || !$model->save()) {
- throw new \Exception($model->getErrorMessage());
- }
- return $model;
- } catch (\Exception $e) {
- self::$static_error = $e->getMessage();
- return false;
- }
- }
- }
|