12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace App\Models\Traits\Lottery;
- /**
- * 记录状态
- *
- */
- trait RecordState
- {
- // 奖品类型
- private $state = ['0'=>[
- 'id' =>0,
- // 类型名称
- 'name' =>'填写地址',
- ],'1'=>[
- 'id' =>1,
- // 类型名称
- 'name' =>'进行中',
- ],'2'=>[
- 'id' =>2,
- // 类型名称
- 'name' =>'待发货',
- ],'3'=>[
- 'id' =>2,
- // 类型名称
- 'name' =>'已发货',
- ],'8'=>[
- 'id' =>8,
- // 类型名称
- 'name' =>'已完成',
- ]];
- /**
- * 状态列表
- *
- */
- public function getRecordStateList(){
- // 返回数据
- return $this->state;
- }
- /**
- * 获取状态值
- *
- * @param int $id 类型ID
- * @param string $field 字段
- *
- */
- public function getRecordState($id,$field=''){
- // 获取数据
- $list = $this->getRecordStateList();
- // 获取交易类型
- $one = isset($list[$id]) ? $list[$id] : [];
- // 如果存在需要的字段
- if( $field ) return isset($one[$field]) ? $one[$field] : null;
- // 返回结果
- return $one;
- }
- }
|