You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
114 lines
2.7 KiB
114 lines
2.7 KiB
<?php
|
|
|
|
namespace app\common\model\wholesaler;
|
|
|
|
use app\common\enum\WholesalerEnum;
|
|
use app\common\model\Region as RegionModel;
|
|
use app\common\model\UploadFile;
|
|
use app\common\model\User;
|
|
use cores\BaseModel;
|
|
use think\db\exception\DataNotFoundException;
|
|
use think\db\exception\DbException;
|
|
use think\db\exception\ModelNotFoundException;
|
|
use think\model\relation\HasOne;
|
|
|
|
class Apply extends BaseModel
|
|
{
|
|
// 定义表名
|
|
protected $name = 'wholesaler_apply';
|
|
|
|
// 定义主键
|
|
protected $pk = 'id';
|
|
|
|
protected $append = ['region', 'status_text'];
|
|
|
|
public static function detail($where, $with = [])
|
|
{
|
|
return static::get($where, $with);
|
|
}
|
|
|
|
public function user(): HasOne
|
|
{
|
|
return $this->hasOne(User::class, 'user_id', 'user_id');
|
|
}
|
|
|
|
/**
|
|
* 身份证正面图片
|
|
* @return HasOne
|
|
*/
|
|
public function cardFrontImg(): HasOne
|
|
{
|
|
return $this->hasOne(UploadFile::class, 'file_id', 'card_front_img_id')
|
|
->bind(['card_front_img' => 'preview_url']);
|
|
}
|
|
|
|
/**
|
|
* 身份证反面图片
|
|
* @return HasOne
|
|
*/
|
|
public function cardBackImg(): HasOne
|
|
{
|
|
return $this->hasOne(UploadFile::class, 'file_id', 'card_back_img_id')
|
|
->bind(['card_back_img' => 'preview_url']);
|
|
}
|
|
|
|
/**
|
|
* 营业执照
|
|
* @return HasOne
|
|
*/
|
|
public function licenseImg(): HasOne
|
|
{
|
|
return $this->hasOne(UploadFile::class, 'file_id', 'license_img_id')
|
|
->bind(['license_img' => 'preview_url']);
|
|
}
|
|
|
|
/**
|
|
* 门头照片
|
|
* @return HasOne
|
|
*/
|
|
public function doorImg(): HasOne
|
|
{
|
|
return $this->hasOne(UploadFile::class, 'file_id', 'door_img_id')
|
|
->bind(['door_img' => 'preview_url']);
|
|
}
|
|
|
|
/**
|
|
* 头像照片
|
|
* @return HasOne
|
|
*/
|
|
public function avatarImg(): HasOne
|
|
{
|
|
return $this->hasOne(UploadFile::class, 'file_id', 'avatar_id')
|
|
->bind(['avatar_img' => 'preview_url']);
|
|
}
|
|
|
|
/**
|
|
* @notes:地区名称
|
|
* @param $value
|
|
* @param $data
|
|
* @return array
|
|
* @throws DataNotFoundException
|
|
* @throws DbException
|
|
* @throws ModelNotFoundException
|
|
* @author: wanghousheng
|
|
*/
|
|
public function getRegionAttr($value, $data): array
|
|
{
|
|
return [
|
|
'province' => RegionModel::getNameById($data['province_id']),
|
|
'city' => RegionModel::getNameById($data['city_id']),
|
|
];
|
|
}
|
|
|
|
public function getStatusTextAttr($value, $data)
|
|
{
|
|
// 状态
|
|
$result = WholesalerEnum::data();
|
|
if (!empty($result[$data['status']]['name'])) {
|
|
return $result[$data['status']]['name'];
|
|
}
|
|
return '未知';
|
|
}
|
|
|
|
|
|
} |