123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace app\common\model\pay;
- use think\Model;
- class Index extends Model
- {
-
-
- // 表名
- protected $name = 'shop_pay';
-
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'integer';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- protected $deleteTime = false;
- // 追加属性
- protected $append = [
- 'paid_time_text',
- 'status_text'
- ];
-
-
- public function getStatusList()
- {
- return ['unpaid' => __('Status unpaid'), 'paid' => __('Status paid'), 'refund' => __('Status refund')];
- }
- public function getPaidTimeTextAttr($value, $data)
- {
- $value = $value ?: ($data['paid_time'] ?? '');
- return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
- }
- public function getStatusTextAttr($value, $data)
- {
- $value = $value ?: ($data['status'] ?? '');
- $list = $this->getStatusList();
- return $list[$value] ?? '';
- }
- protected function setPaidTimeAttr($value)
- {
- return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
- }
- }
|