Postbackreferral.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. namespace app\admin\model;
  3. use think\Model;
  4. class Postbackreferral extends Model
  5. {
  6. // 表名
  7. protected $table = 'referral';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'int';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = 'updatetime';
  13. // 追加属性
  14. protected $append = [
  15. 'push_text',
  16. 'wx_type_text',
  17. 'type_text',
  18. 'state_text',
  19. 'guide_sex_text'
  20. ];
  21. public function getPushList()
  22. {
  23. return ['0' => __('Push 0'),'1' => __('Push 1')];
  24. }
  25. public function getWxTypeList()
  26. {
  27. return ['1' => __('Wx_type 1'),'2' => __('Wx_type 2')];
  28. }
  29. public function getTypeList()
  30. {
  31. return ['1' => __('Type 1'),'2' => __('Type 2'),'3' => __('Type 3')];
  32. }
  33. public function getStateList()
  34. {
  35. return ['0' => __('State 0'),'1' => __('State 1')];
  36. }
  37. public function getGuideSexList()
  38. {
  39. return ['1' => __('Guide_sex 1'),'2' => __('Guide_sex 2')];
  40. }
  41. public function getPushTextAttr($value, $data)
  42. {
  43. $value = $value ? $value : $data['push'];
  44. $list = $this->getPushList();
  45. return isset($list[$value]) ? $list[$value] : '';
  46. }
  47. public function getWxTypeTextAttr($value, $data)
  48. {
  49. $value = $value ? $value : $data['wx_type'];
  50. $list = $this->getWxTypeList();
  51. return isset($list[$value]) ? $list[$value] : '';
  52. }
  53. public function getTypeTextAttr($value, $data)
  54. {
  55. $value = $value ? $value : $data['type'];
  56. $list = $this->getTypeList();
  57. return isset($list[$value]) ? $list[$value] : '';
  58. }
  59. public function getStateTextAttr($value, $data)
  60. {
  61. $value = $value ? $value : $data['state'];
  62. $list = $this->getStateList();
  63. return isset($list[$value]) ? $list[$value] : '';
  64. }
  65. public function getGuideSexTextAttr($value, $data)
  66. {
  67. $value = $value ? $value : $data['guide_sex'];
  68. $list = $this->getGuideSexList();
  69. return isset($list[$value]) ? $list[$value] : '';
  70. }
  71. }