<?php
|
|
namespace app\common\model\plus\region;
|
|
use app\common\model\BaseModel;
|
use app\common\model\plus\region\User as RegionUserModel;
|
use app\common\model\plus\region\Order as RegionOrderModel;
|
use app\common\model\settings\Region;
|
use app\common\enum\plus\region\RegionLevelEnum;
|
|
/**
|
* 股东申请模型
|
*/
|
class Apply extends BaseModel
|
{
|
protected $name = 'region_apply';
|
protected $pk = 'apply_id';
|
|
/**
|
* 追加字段
|
* @var string[]
|
*/
|
protected $append = ['region'];
|
|
/**
|
* 地区名称
|
* @param $value
|
* @param $data
|
* @return array
|
*/
|
public function getRegionAttr($value, $data)
|
{
|
return [
|
'province' => Region::getNameById($data['province_id']),
|
'city' => Region::getNameById($data['city_id']),
|
'area' => $data['area_id'] == 0 ? '' : Region::getNameById($data['area_id']),
|
];
|
}
|
|
/**
|
* 代理类别
|
* @param $value
|
* @return array
|
*/
|
public function getRegionLevelAttr($value)
|
{
|
return ['text' => RegionLevelEnum::data()[$value]['name'], 'value' => $value];
|
}
|
|
/**
|
* 申请状态
|
* @var array
|
*/
|
public $applyStatus = [
|
10 => '待审核',
|
20 => '审核通过',
|
30 => '驳回',
|
];
|
|
/**
|
* 申请时间
|
* @param $value
|
* @return false|string
|
*/
|
public function getApplyTimeAttr($value)
|
{
|
return date('Y-m-d H:i:s', $value);
|
}
|
|
/**
|
* 审核时间
|
* @param $value
|
* @return false|int|string
|
*/
|
public function getAuditTimeAttr($value)
|
{
|
return $value > 0 ? date('Y-m-d H:i:s', $value) : 0;
|
}
|
|
/**
|
* 关联推荐人表
|
* @return \think\model\relation\BelongsTo
|
*/
|
public function referee()
|
{
|
return $this->belongsTo('app\common\model\user\User', 'referee_id')
|
->field(['user_id', 'nickName']);
|
}
|
|
/**
|
* 申请记录详情
|
* @param $where
|
* @return array|\think\Model|null
|
* @throws \think\db\exception\DataNotFoundException
|
* @throws \think\db\exception\DbException
|
* @throws \think\db\exception\ModelNotFoundException
|
*/
|
public static function detail($where)
|
{
|
$filter = is_array($where) ? $where : ['apply_id' => $where];
|
return (new static())->where($filter)->find();
|
}
|
|
/**
|
* 审核状态
|
* @param $value
|
* @return array
|
*/
|
public function getApplyStatusAttr($value)
|
{
|
$method = [10 => '待审核', 20 => '审核通过', '30' => '驳回'];
|
return ['text' => $method[$value], 'value' => $value];
|
}
|
|
/**
|
* 审核方式
|
* @param $value
|
* @return array
|
*/
|
public function getApplyTypeAttr($value)
|
{
|
$method = [10 => '后台审核', 20 => '无需审核'];
|
return ['text' => $method[$value], 'value' => $value];
|
}
|
|
}
|