1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace app\admin\model\pay;
- use think\Model;
- use traits\model\SoftDelete;
- use app\common\Enum\StatusEnum;
- use app\common\Enum\PayEnum;
- class Config extends Model
- {
- use SoftDelete;
-
- // 表名
- protected $name = 'shop_pay_config';
-
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'integer';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- protected $deleteTime = 'deletetime';
- // 追加属性
- protected $append = [
- 'status_text',
- 'type_text'
- ];
- public function getTypeTextAttr($value, $data)
- {
- return PayEnum::getPayMethodList()[$data['type']] ?? '';
- }
- // public function getTypeAttr($value, $data)
- // {
- // return PayEnum::getPayMethodList()[$value] ?? '';
- // }
-
- public function getStatusList()
- {
- return StatusEnum::getMap();
- }
- public function getParamsAttr($value, $data)
- {
- if(empty($value)){
- return [];
- }
- return json_decode($value, true);
- }
- public function getStatusTextAttr($value, $data)
- {
- $value = $value ?: ($data['status'] ?? '');
- $list = $this->getStatusList();
- return $list[$value] ?? '';
- }
- }
|