123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- <?php
- namespace app\common\model\commission;
- use think\Model;
- class Apply extends Model
- {
- protected $name = 'shopro_commission_apply';
-
- // 开启自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
-
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- // 追加属性
- protected $append = [
- 'apply_type_text',
- 'status_text'
- ];
- // 申请类型
- const APPLY_TYPE_PERSONAL = 'personal';
- const APPLY_TYPE_COMPANY = 'company';
- // 申请状态
- const STATUS_PENDING = 'pending';
- const STATUS_APPROVED = 'approved';
- const STATUS_REJECTED = 'rejected';
- public function getApplyTypeList()
- {
- return [
- self::APPLY_TYPE_PERSONAL => '个人申请',
- self::APPLY_TYPE_COMPANY => '企业申请'
- ];
- }
- public function getStatusList()
- {
- return [
- self::STATUS_PENDING => '待审核',
- self::STATUS_APPROVED => '已通过',
- self::STATUS_REJECTED => '已拒绝'
- ];
- }
- public function getApplyTypeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['apply_type']) ? $data['apply_type'] : '');
- $list = $this->getApplyTypeList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getStatusTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
- $list = $this->getStatusList();
- return isset($list[$value]) ? $list[$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');
- }
- }
|