| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- <?php
- namespace addons\ReservationService\common\models;
- use addons\Store\common\models\Store;
- use common\enums\StatusEnum;
- use common\models\user\User;
- use Yii;
- /**
- * This is the model class for table "{{%addons_reservation_service_user}}".
- *
- * @property int $id ID
- * @property int $mall_id 商城ID
- * @property int $user_id 用户ID
- * @property int $level 等级
- * @property string $idcard 身份证
- * @property string $idcard_front 身份证正面
- * @property string $idcard_back 身份证反面
- * @property string $address 地址
- * @property string $longitude 经度
- * @property string $latitude 纬度
- * @property string $name 姓名
- * @property string $mobile 手机号
- * @property float $commission 佣金
- * @property float $service_rating 佣金
- * @property string $qualification_certificate 资格证书
- * @property int $status 状态;1正常,0禁用,-1删除
- * @property int $check_status 审核状态:0:待审核;1:已通过;2:未通过
- * @property string $check_remark 审核备注
- * @property string $avatar 审核备注
- * @property string $desc 审核备注
- * @property int $created_at 创建时间
- * @property int $updated_at 更新时间
- * @property int $store_id 更新时间
- * @property int $store_status 更新时间
- * @property int $gender 性别,0保密,1男,2女
- * @property int $age 年龄
- * @property int $is_working 更新时间
- * @property int $order_num 更新时间
- * @property int $store_order_num 更新时间
- * @property float $store_lng 佣金
- * @property float $store_lat 佣金
- * @property float $store_service_rating 门店技师的服务评分
- * @property string $province 省
- * @property string $city 市
- * @property string $district 区
- */
- class ReservationServiceUser extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_reservation_service_user}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'user_id', 'level', 'status', 'check_status', 'created_at', 'updated_at', 'store_id', 'store_status',
- 'gender', 'age', 'is_working', 'order_num', 'store_order_num'], 'integer'],
- [['user_id'], 'required'],
- [['idcard'], 'string', 'max' => 32],
- [['idcard_front', 'idcard_back', 'address', 'check_remark'], 'string', 'max' => 255],
- [['longitude', 'latitude'], 'string', 'max' => 64],
- [['name'], 'string', 'max' => 100],
- [['mobile'], 'string', 'max' => 16],
- [['desc'], 'string', 'max' => 500],
- [['avatar','province','city','district'], 'string', 'max' => 255],
- [['commission', 'service_rating', 'store_lng', 'store_lat','store_service_rating'],'number'],
- [['qualification_certificate'], 'string'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => '商城ID',
- 'user_id' => '用户ID',
- 'level' => '等级',
- 'idcard' => '身份证',
- 'idcard_front' => '身份证正面',
- 'idcard_back' => '身份证反面',
- 'address' => '地址',
- 'longitude' => '经度',
- 'latitude' => '纬度',
- 'name' => '姓名',
- 'mobile' => '手机号',
- 'qualification_certificate' => '资格证书',
- 'status' => '状态;1正常,0禁用,-1删除',
- 'check_status' => '审核状态:0:待审核;1:已通过;2:未通过',
- 'check_remark' => '审核备注',
- 'commission' => '佣金',
- 'created_at' => '创建时间',
- 'updated_at' => '更新时间',
- ];
- }
- public function getUser()
- {
- return $this->hasOne(User::class, ['id' => 'user_id']);
- }
- public function getLevel()
- {
- return $this->hasOne(ReservationServiceLevel::class, ['level' => 'level'])->where(['status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]);
- }
- public function getStore()
- {
- return $this->hasOne(Store::class, ['id' => 'store_id']);
- }
- public static function getDataOne($params = [], $select = '*', $orderBy = 'id desc')
- {
- return self::find()->where($params)->select($select)->orderBy($orderBy)->asArray()->one();
- }
- public static function getDataAll($params = [], $select = '*', $orderBy = 'id desc')
- {
- return self::find()->where($params)->select($select)->orderBy($orderBy)->indexBy('id')->asArray()->all();
- }
- /**
- * @Description: 保存数据
- * @Author: zsan
- * @DateTime 2023-10-09 10:39:20
- * @param array $params
- * @return self|bool
- */
- public static function setData(array $params)
- {
- try {
- if (!empty($params['id'])) {
- $model = self::findOne(['and', ['id' => $params['id'], 'mall_id' => $params['mall_id']], ['<>', 'status', StatusEnum::DELETE]]);
- if (empty($model)) throw new \Exception('技师不存在或已删除');
- } else {
- $model = self::findOne(['user_id' => $params['user_id'], 'mall_id' => $params['mall_id'], 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]);
- if (empty($model)) {
- $model = new self();
- $model->loadDefaultValues();
- $model->mall_id = $params['mall_id'];
- }
- }
- if (!$model->load($params, '') || !$model->save()) {
- throw new \Exception($model->getErrorMessage());
- }
- return $model;
- } catch (\Exception $e) {
- self::$static_error = $e->getMessage();
- return false;
- }
- }
- }
|