DdriveRefund.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. namespace app\admin\model;
  3. use think\Model;
  4. class DdriveRefund extends Model
  5. {
  6. // 表名
  7. protected $name = 'ddrive_refund';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = false;
  10. // 定义时间戳字段名
  11. protected $createTime = false;
  12. protected $updateTime = false;
  13. protected $deleteTime = false;
  14. // 追加属性
  15. protected $append = [
  16. 'pay_type_text',
  17. 'check_status_text',
  18. 'apply_time_text',
  19. 'confirm_time_text',
  20. 'success_time_text'
  21. ];
  22. public function getPayTypeList()
  23. {
  24. return ['1' => __('Pay_type 1'), '2' => __('Pay_type 2'), '3' => __('Pay_type 3')];
  25. }
  26. public function getCheckStatusList()
  27. {
  28. return ['0' => __('Check_status 0'), '1' => __('Check_status 1'), '-1' => __('Check_status -1')];
  29. }
  30. public function getPayTypeTextAttr($value, $data)
  31. {
  32. $value = $value ? $value : (isset($data['pay_type']) ? $data['pay_type'] : '');
  33. $list = $this->getPayTypeList();
  34. return isset($list[$value]) ? $list[$value] : '';
  35. }
  36. public function getCheckStatusTextAttr($value, $data)
  37. {
  38. $value = $value ? $value : (isset($data['check_status']) ? $data['check_status'] : '');
  39. $list = $this->getCheckStatusList();
  40. return isset($list[$value]) ? $list[$value] : '';
  41. }
  42. public function getApplyTimeTextAttr($value, $data)
  43. {
  44. $value = $value ? $value : (isset($data['apply_time']) ? $data['apply_time'] : '');
  45. return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
  46. }
  47. public function getConfirmTimeTextAttr($value, $data)
  48. {
  49. $value = $value ? $value : (isset($data['confirm_time']) ? $data['confirm_time'] : '');
  50. return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
  51. }
  52. public function getSuccessTimeTextAttr($value, $data)
  53. {
  54. $value = $value ? $value : (isset($data['success_time']) ? $data['success_time'] : '');
  55. return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
  56. }
  57. protected function setApplyTimeAttr($value)
  58. {
  59. return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
  60. }
  61. protected function setConfirmTimeAttr($value)
  62. {
  63. return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
  64. }
  65. protected function setSuccessTimeAttr($value)
  66. {
  67. return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
  68. }
  69. public function user()
  70. {
  71. return $this->belongsTo('app\admin\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
  72. }
  73. }