Orderrefund.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. namespace app\admin\model;
  3. use think\Model;
  4. class Orderrefund extends Model
  5. {
  6. // 表名
  7. protected $table = 'order_refund';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'integer';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = 'updatetime';
  13. protected $deleteTime = false;
  14. // 追加属性
  15. protected $append = [
  16. 'order_table_text',
  17. 'try_createtime_text',
  18. 'slot_starttime_text',
  19. 'paytype_text',
  20. 'status_text',
  21. 'audittime_text'
  22. ];
  23. public function getOrderTableList()
  24. {
  25. return ['1' => __('Order_table 1'), '2' => __('Order_table 2')];
  26. }
  27. public function getPaytypeList()
  28. {
  29. return ['1' => __('Paytype 1'), '2' => __('Paytype 2')];
  30. }
  31. public function getStatusList()
  32. {
  33. return ['0' => __('Status 0'), '1' => __('Status 1'), '2' => __('Status 2')];
  34. }
  35. public function getOrderTableTextAttr($value, $data)
  36. {
  37. $value = $value ? $value : (isset($data['order_table']) ? $data['order_table'] : '');
  38. $list = $this->getOrderTableList();
  39. return isset($list[$value]) ? $list[$value] : '';
  40. }
  41. public function getTryCreatetimeTextAttr($value, $data)
  42. {
  43. $value = $value ? $value : (isset($data['try_createtime']) ? $data['try_createtime'] : '');
  44. return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
  45. }
  46. public function getSlotStarttimeTextAttr($value, $data)
  47. {
  48. $value = $value ? $value : (isset($data['slot_starttime']) ? $data['slot_starttime'] : '');
  49. return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
  50. }
  51. public function getPaytypeTextAttr($value, $data)
  52. {
  53. $value = $value ? $value : (isset($data['paytype']) ? $data['paytype'] : '');
  54. $list = $this->getPaytypeList();
  55. return isset($list[$value]) ? $list[$value] : '';
  56. }
  57. public function getStatusTextAttr($value, $data)
  58. {
  59. $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
  60. $list = $this->getStatusList();
  61. return isset($list[$value]) ? $list[$value] : '';
  62. }
  63. public function getAudittimeTextAttr($value, $data)
  64. {
  65. $value = $value ? $value : (isset($data['audittime']) ? $data['audittime'] : '');
  66. return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
  67. }
  68. protected function setTryCreatetimeAttr($value)
  69. {
  70. return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
  71. }
  72. protected function setSlotStarttimeAttr($value)
  73. {
  74. return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
  75. }
  76. protected function setAudittimeAttr($value)
  77. {
  78. return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
  79. }
  80. public function user()
  81. {
  82. return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
  83. }
  84. }