Recharorder.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. namespace app\admin\model;
  3. use think\Model;
  4. class Recharorder extends Model
  5. {
  6. // 表名
  7. protected $name = 'rechar_order';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'int';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = 'updatetime';
  13. protected $deleteTime = false;
  14. // 追加属性
  15. protected $append = [
  16. 'purpose_text',
  17. 'status_text',
  18. 'pay_status_text'
  19. ];
  20. public function getPurposeList()
  21. {
  22. return ['1' => __('Purpose 1'), '2' => __('Purpose 2'), '3' => __('Purpose 3')];
  23. }
  24. public function getStatusList()
  25. {
  26. return ['0' => __('Status 0'), '1' => __('Status 1'), '2' => __('Status 2')];
  27. }
  28. public function getPayStatusList()
  29. {
  30. return ['1' => __('Pay_status 1'), '2' => __('Pay_status 2'), '3' => __('Pay_status 3')];
  31. }
  32. public function getPurposeTextAttr($value, $data)
  33. {
  34. $value = $value ? $value : (isset($data['purpose']) ? $data['purpose'] : '');
  35. $list = $this->getPurposeList();
  36. return isset($list[$value]) ? $list[$value] : '';
  37. }
  38. public function getStatusTextAttr($value, $data)
  39. {
  40. $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
  41. $list = $this->getStatusList();
  42. return isset($list[$value]) ? $list[$value] : '';
  43. }
  44. public function getPayStatusTextAttr($value, $data)
  45. {
  46. $value = $value ? $value : (isset($data['pay_status']) ? $data['pay_status'] : '');
  47. $list = $this->getPayStatusList();
  48. return isset($list[$value]) ? $list[$value] : '';
  49. }
  50. public function user()
  51. {
  52. return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
  53. }
  54. public function video()
  55. {
  56. return $this->belongsTo('Video', 'video_id', 'id', [], 'LEFT')->setEagerlyType(0);
  57. }
  58. }