Agent.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <?php
  2. namespace app\admin\model;
  3. use think\Model;
  4. class Agent extends Model
  5. {
  6. // 表名
  7. protected $name = 'user';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'int';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = false;
  13. protected $deleteTime = false;
  14. // 追加属性
  15. protected $append = [
  16. 'yaoqingtime_text',
  17. 'gender_text',
  18. 'idcard_status_text',
  19. 'real_status_text',
  20. 'logintime_text',
  21. 'jointime_text',
  22. 'status_text',
  23. 'hide_is_finishinfo_text',
  24. 'is_active_text',
  25. 'open_match_video_text',
  26. 'open_match_audio_text',
  27. 'jinyantime_text',
  28. 'jinyantype_text',
  29. 'is_shouchong_text'
  30. ];
  31. public function getGenderList()
  32. {
  33. return ['-1' => __('Gender -1'), '1' => __('Gender 1'), '0' => __('Gender 0')];
  34. }
  35. public function getIdcardStatusList()
  36. {
  37. return ['-1' => __('Idcard_status -1'), '0' => __('Idcard_status 0'), '1' => __('Idcard_status 1'), '2' => __('Idcard_status 2')];
  38. }
  39. public function getRealStatusList()
  40. {
  41. return ['-1' => __('Real_status -1'), '0' => __('Real_status 0'), '1' => __('Real_status 1'), '2' => __('Real_status 2')];
  42. }
  43. public function getStatusList()
  44. {
  45. return ['1' => __('Status 1'), '0' => __('Status 0'), '-1' => __('Status -1')];
  46. }
  47. public function getHideIsFinishinfoList()
  48. {
  49. return ['1' => __('Hide_is_finishinfo 1'), '0' => __('Hide_is_finishinfo 0')];
  50. }
  51. public function getIsActiveList()
  52. {
  53. return ['1' => __('Is_active 1'), '0' => __('Is_active 0')];
  54. }
  55. public function getOpenMatchVideoList()
  56. {
  57. return ['1' => __('Open_match_video 1'), '0' => __('Open_match_video 0')];
  58. }
  59. public function getOpenMatchAudioList()
  60. {
  61. return ['1' => __('Open_match_audio 1'), '0' => __('Open_match_audio 0')];
  62. }
  63. public function getJinyantypeList()
  64. {
  65. return ['1' => __('Jinyantype 1'), '2' => __('Jinyantype 2'), '3' => __('Jinyantype 3')];
  66. }
  67. public function getIsShouchongList()
  68. {
  69. return ['0' => __('Is_shouchong 0'), '1' => __('Is_shouchong 1')];
  70. }
  71. public function getYaoqingtimeTextAttr($value, $data)
  72. {
  73. $value = $value ? $value : (isset($data['yaoqingtime']) ? $data['yaoqingtime'] : '');
  74. return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
  75. }
  76. public function getGenderTextAttr($value, $data)
  77. {
  78. $value = $value ? $value : (isset($data['gender']) ? $data['gender'] : '');
  79. $list = $this->getGenderList();
  80. return isset($list[$value]) ? $list[$value] : '';
  81. }
  82. public function getIdcardStatusTextAttr($value, $data)
  83. {
  84. $value = $value ? $value : (isset($data['idcard_status']) ? $data['idcard_status'] : '');
  85. $list = $this->getIdcardStatusList();
  86. return isset($list[$value]) ? $list[$value] : '';
  87. }
  88. public function getRealStatusTextAttr($value, $data)
  89. {
  90. $value = $value ? $value : (isset($data['real_status']) ? $data['real_status'] : '');
  91. $list = $this->getRealStatusList();
  92. return isset($list[$value]) ? $list[$value] : '';
  93. }
  94. public function getLogintimeTextAttr($value, $data)
  95. {
  96. $value = $value ? $value : (isset($data['logintime']) ? $data['logintime'] : '');
  97. return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
  98. }
  99. public function getJointimeTextAttr($value, $data)
  100. {
  101. $value = $value ? $value : (isset($data['jointime']) ? $data['jointime'] : '');
  102. return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
  103. }
  104. public function getStatusTextAttr($value, $data)
  105. {
  106. $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
  107. $list = $this->getStatusList();
  108. return isset($list[$value]) ? $list[$value] : '';
  109. }
  110. public function getHideIsFinishinfoTextAttr($value, $data)
  111. {
  112. $value = $value ? $value : (isset($data['hide_is_finishinfo']) ? $data['hide_is_finishinfo'] : '');
  113. $list = $this->getHideIsFinishinfoList();
  114. return isset($list[$value]) ? $list[$value] : '';
  115. }
  116. public function getIsActiveTextAttr($value, $data)
  117. {
  118. $value = $value ? $value : (isset($data['is_active']) ? $data['is_active'] : '');
  119. $list = $this->getIsActiveList();
  120. return isset($list[$value]) ? $list[$value] : '';
  121. }
  122. public function getOpenMatchVideoTextAttr($value, $data)
  123. {
  124. $value = $value ? $value : (isset($data['open_match_video']) ? $data['open_match_video'] : '');
  125. $list = $this->getOpenMatchVideoList();
  126. return isset($list[$value]) ? $list[$value] : '';
  127. }
  128. public function getOpenMatchAudioTextAttr($value, $data)
  129. {
  130. $value = $value ? $value : (isset($data['open_match_audio']) ? $data['open_match_audio'] : '');
  131. $list = $this->getOpenMatchAudioList();
  132. return isset($list[$value]) ? $list[$value] : '';
  133. }
  134. public function getJinyantimeTextAttr($value, $data)
  135. {
  136. $value = $value ? $value : (isset($data['jinyantime']) ? $data['jinyantime'] : '');
  137. return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
  138. }
  139. public function getJinyantypeTextAttr($value, $data)
  140. {
  141. $value = $value ? $value : (isset($data['jinyantype']) ? $data['jinyantype'] : '');
  142. $list = $this->getJinyantypeList();
  143. return isset($list[$value]) ? $list[$value] : '';
  144. }
  145. public function getIsShouchongTextAttr($value, $data)
  146. {
  147. $value = $value ? $value : (isset($data['is_shouchong']) ? $data['is_shouchong'] : '');
  148. $list = $this->getIsShouchongList();
  149. return isset($list[$value]) ? $list[$value] : '';
  150. }
  151. protected function setYaoqingtimeAttr($value)
  152. {
  153. return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
  154. }
  155. protected function setLogintimeAttr($value)
  156. {
  157. return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
  158. }
  159. protected function setJointimeAttr($value)
  160. {
  161. return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
  162. }
  163. protected function setJinyantimeAttr($value)
  164. {
  165. return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
  166. }
  167. public function usergroup()
  168. {
  169. return $this->belongsTo('UserGroup', 'group_id', 'id', [], 'LEFT')->setEagerlyType(0);
  170. }
  171. public function userwallet()
  172. {
  173. return $this->belongsTo('Userwallet', 'id', 'user_id', [], 'LEFT')->setEagerlyType(0);
  174. }
  175. }