HappinessThirdUser.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. namespace addons\Happiness\common\models;
  3. use common\enums\StatusEnum;
  4. use Yii;
  5. /**
  6. * This is the model class for table "qimall_addons_happiness_third_user".
  7. *
  8. * @property int $id
  9. * @property int $user_id 用户ID
  10. * @property int $uid 积分平台用户ID
  11. * @property int $mall_id 商城ID
  12. * @property int $type 第三方平台类型:1 养老金平台 2 积分平台
  13. * @property string $id_no 身份证号
  14. * @property string $id_img 身份证正面图片
  15. * @property string $id_back_img 身份证反面图片
  16. * @property int $is_real 是否需要实名,0 为未实名 1为已实名
  17. * @property string $user_name 用户姓名
  18. * @property int $status 状态:0 禁用 1正常
  19. * @property int $created_at
  20. * @property int $updated_at
  21. */
  22. class HappinessThirdUser extends \common\models\base\BaseActiveRecord
  23. {
  24. /**
  25. * {@inheritdoc}
  26. */
  27. public static function tableName()
  28. {
  29. return 'qimall_addons_happiness_third_user';
  30. }
  31. /**
  32. * {@inheritdoc}
  33. */
  34. public function rules()
  35. {
  36. return [
  37. [['user_id', 'uid', 'mall_id', 'type', 'is_real', 'status', 'created_at', 'updated_at'], 'integer'],
  38. [['id_no', 'id_img', 'id_back_img','user_name'], 'string', 'max' => 255],
  39. ];
  40. }
  41. /**
  42. * {@inheritdoc}
  43. */
  44. public function attributeLabels()
  45. {
  46. return [
  47. 'id' => 'ID',
  48. 'user_id' => 'User ID',
  49. 'uid' => 'Uid',
  50. 'mall_id' => 'Mall ID',
  51. 'type' => 'Type',
  52. 'id_no' => 'Id No',
  53. 'id_img' => 'Id Img',
  54. 'id_back_img' => 'Id Back Img',
  55. 'is_real' => 'Is Real',
  56. 'status' => 'Status',
  57. 'created_at' => 'Created At',
  58. 'updated_at' => 'Updated At',
  59. ];
  60. }
  61. public function getUser()
  62. {
  63. return $this->hasOne(User::class, ['id' => 'user_id']);
  64. }
  65. public static function setData($params)
  66. {
  67. try {
  68. if(isset($params['id']) && !empty($params['id']))
  69. $model = self::findOne($params['id']);
  70. elseif(isset($params['user_id']) && !empty($params['type']))
  71. $model = self::findOne(['user_id' => $params['user_id'], 'type' => $params['type']]);
  72. if (!$model) {
  73. $model = new self();
  74. $model->loadDefaultValues();
  75. }
  76. if (!$model->load($params, '') || !$model->save()) {
  77. throw new \Exception($model->getErrorMessage());
  78. }
  79. return $model;
  80. } catch (\Exception $e) {
  81. self::$static_error = $e->getMessage();
  82. return false;
  83. }
  84. }
  85. }