DecLevelList.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. namespace backendApi\modules\v1\models\lists\user;
  3. use backendApi\modules\v1\models\Admin;
  4. use common\helpers\Cache;
  5. use common\libs\dataList\DataListInterface;
  6. use common\models\DecLevelLog;
  7. use common\models\User;
  8. use common\models\UserInfo;
  9. use common\libs\dataList\column\DateTime;
  10. use common\models\UserMove;
  11. use Yii;
  12. class DecLevelList extends \common\libs\dataList\DataList implements DataListInterface
  13. {
  14. /**
  15. * 列表名称
  16. * @return string
  17. */
  18. public function getListName(){
  19. return '会员级别调整列表';
  20. }
  21. /**
  22. * 列表筛选到的数据
  23. */
  24. public function dataHandle()
  25. {
  26. $this->listData = DecLevelLog::lists($this->condition, $this->params, [
  27. 'select' => 'LL.*,
  28. CU.USER_NAME,ADM.ADMIN_NAME',
  29. 'orderBy' => 'LL.CREATED_AT DESC, LL.ID DESC',
  30. 'from' => DecLevelLog::tableName() . ' AS LL',
  31. 'join' => [
  32. ['LEFT JOIN', Admin::tableName() . ' AS ADM', 'LL.ADMIN_ID=ADM.ID'],
  33. ['LEFT JOIN', User::tableName() . ' AS CU', 'LL.USER_ID=CU.ID'],
  34. ],
  35. 'page' => $this->page,
  36. 'pageSize' => $this->pageSize,
  37. ]);
  38. }
  39. /**
  40. * 要展示和导出的所有字段
  41. * @return array
  42. */
  43. public function getColumn(){
  44. $decLevelConfig = Cache::getDecLevelConfig();
  45. if(!$this->columns){
  46. $this->columns = [
  47. 'ID' => null,
  48. 'USER_ID' => null,
  49. 'USER_NAME' => [
  50. 'header' => 'Member Code', // 会员编号
  51. 'headerOther' => ['width' => '150'],
  52. ],
  53. 'FROM_DEC_LV_NAME' => [
  54. 'header' => 'Level Before Modification', // 修改前级别
  55. // 'headerOther' => [
  56. // 'width' => '120',
  57. // ],
  58. 'value' => function($row) use($decLevelConfig) {
  59. return $decLevelConfig[$row['FROM_ID']]['LEVEL_NAME'];
  60. },
  61. 'valueOther' => [
  62. 'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border']
  63. ],
  64. ],
  65. 'TO_DEC_LV_NAME' => [
  66. 'header' => 'Modified Level', // 修改后级别
  67. // 'headerOther' => [
  68. // 'width' => '130',
  69. // ],
  70. 'value' => function($row) use($decLevelConfig) {
  71. return isset($decLevelConfig[$row['TO_ID']])?$decLevelConfig[$row['TO_ID']]['LEVEL_NAME']:'';
  72. },
  73. 'valueOther' => [
  74. 'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border']
  75. ],
  76. ],
  77. 'ADMIN_NAME' => [
  78. 'header' => 'Operation Administrator', // 操作管理员
  79. // 'headerOther' => ['width' => '120'],
  80. ],
  81. 'CREATED_AT' => [
  82. 'header' => 'Creation Time', // 创建时间
  83. 'value' => function($row) {
  84. return (new DateTime([
  85. 'value' => $row['CREATED_AT'],
  86. ]))->result();
  87. },
  88. // 'headerOther' => ['width' => '170'],
  89. ],
  90. ];
  91. }
  92. return $this->columns;
  93. }
  94. /**
  95. * 前台用于筛选的类型集合
  96. * @return mixed
  97. */
  98. public function getFilterTypes()
  99. {
  100. if(!$this->filterTypes){
  101. $this->filterTypes = [
  102. 'USER_NAME'=> ['isUserTable' => false,'name'=> 'Member Code'], // 会员编号
  103. 'CREATED_AT' => ['isUserTable' => false, 'name' => 'Creation Time', 'other' => 'date'], // 会员编号
  104. 'ADMIN_NAME' => ['isUserTable' => false, 'name' => 'Operation Administrator'], // 操作管理员
  105. ];
  106. }
  107. return $this->filterTypes;
  108. }
  109. }