1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- namespace app\common\model\commission;
- use think\Model;
- class Identity extends Model
- {
- protected $name = 'shop_commission_identity';
-
- // 开启自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
-
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- // 追加属性
- protected $append = [
- 'status_text',
- 'agent_type_text'
- ];
- // 状态
- const STATUS_DISABLED = 0;
- const STATUS_ENABLED = 1;
- // 代理商类型
- const AGENT_TYPE_NORMAL = 'normal';
- const AGENT_TYPE_REGIONAL = 'regional';
- public function getStatusList()
- {
- return [
- self::STATUS_DISABLED => '禁用',
- self::STATUS_ENABLED => '启用'
- ];
- }
- public function getAgentTypeList()
- {
- return [
- self::AGENT_TYPE_NORMAL => '普通代理商',
- self::AGENT_TYPE_REGIONAL => '区域代理商'
- ];
- }
- public function getStatusTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
- $list = $this->getStatusList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getAgentTypeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['agent_type']) ? $data['agent_type'] : '');
- $list = $this->getAgentTypeList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- /**
- * 获取启用的身份列表
- */
- public static function getEnabledList()
- {
- return self::where('status', self::STATUS_ENABLED)
- ->order('weigh asc, id asc')
- ->select();
- }
- }
|