123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- <?php
- namespace app\common\model\commission;
- use app\common\Enum\AgentType;
- use app\common\Enum\ApplyType;
- use app\common\Enum\ApplyStatus;
- use think\Model;
- class Apply extends Model
- {
- protected $name = 'shop_commission_apply';
-
- // 开启自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
-
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- // 追加属性
- protected $append = [
- 'apply_type_text',
- 'agent_type_text',
- 'status_text'
- ];
- // 申请类型(使用枚举类常量)
- const APPLY_TYPE_PERSONAL = ApplyType::PERSONAL;
- const APPLY_TYPE_COMPANY = ApplyType::COMPANY;
- // 代理商类型(使用枚举类常量)
- const AGENT_TYPE_NORMAL = AgentType::NORMAL;
- const AGENT_TYPE_PROVINCE = AgentType::PROVINCE;
- const AGENT_TYPE_CITY = AgentType::CITY;
- const AGENT_TYPE_DISTRICT = AgentType::DISTRICT;
- // 申请状态(使用枚举类常量)
- const STATUS_PENDING = ApplyStatus::PENDING;
- const STATUS_APPROVED = ApplyStatus::APPROVED;
- const STATUS_REJECTED = ApplyStatus::REJECTED;
- public function getApplyTypeList()
- {
- return ApplyType::getAll();
- }
- public function getAgentTypeList()
- {
- return AgentType::getAll();
- }
- public function getStatusList()
- {
- return ApplyStatus::getAll();
- }
- public function getApplyTypeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['apply_type']) ? $data['apply_type'] : '');
- return ApplyType::getTypeText($value);
- }
- public function getAgentTypeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['agent_type']) ? $data['agent_type'] : '');
- return AgentType::getTypeText($value);
- }
- public function getStatusTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
- return ApplyStatus::getStatusText($value);
- }
- /**
- * 关联用户模型
- */
- public function user()
- {
- return $this->belongsTo('app\common\model\User', 'user_id', 'id', [], 'LEFT');
- }
- /**
- * 关联代理商身份
- */
- public function identity()
- {
- return $this->belongsTo('app\common\model\commission\Identity', 'agent_identity_id', 'id', [], 'LEFT');
- }
- /**
- * 关联省份
- */
- public function province()
- {
- return $this->belongsTo('app\common\model\Area', 'province_id', 'id', [], 'LEFT');
- }
- /**
- * 关联城市
- */
- public function city()
- {
- return $this->belongsTo('app\common\model\Area', 'city_id', 'id', [], 'LEFT');
- }
- /**
- * 关联区域
- */
- public function district()
- {
- return $this->belongsTo('app\common\model\Area', 'district_id', 'id', [], 'LEFT');
- }
- /**
- * 关联审核管理员
- */
- public function admin()
- {
- return $this->belongsTo('app\admin\model\Admin', 'admin_id', 'id', [], 'LEFT');
- }
- }
|