DecLevelList.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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.*, CU.USER_NAME, ADM.ADMIN_NAME',
  28. 'orderBy' => 'LL.CREATED_AT DESC, LL.ID DESC',
  29. 'from' => DecLevelLog::tableName() . ' AS LL',
  30. 'join' => [
  31. ['LEFT JOIN', Admin::tableName() . ' AS ADM', 'LL.ADMIN_ID=ADM.ID'],
  32. ['INNER JOIN', User::tableName() . ' AS CU', 'LL.USER_ID=CU.ID'],
  33. ],
  34. 'page' => $this->page,
  35. 'pageSize' => $this->pageSize,
  36. ]);
  37. }
  38. /**
  39. * 要展示和导出的所有字段
  40. * @return array
  41. */
  42. public function getColumn(){
  43. $decLevelConfig = Cache::getDecLevelConfig();
  44. if(!$this->columns){
  45. $this->columns = [
  46. 'ID' => null,
  47. 'USER_ID' => null,
  48. 'USER_NAME' => [
  49. 'header' => Yii::t('ctx', 'memberCode'),
  50. 'headerOther' => ['minWidth' => '120'],
  51. ],
  52. 'FROM_DEC_LV_NAME' => [
  53. 'header' => Yii::t('ctx', 'levelBeforeModification'),
  54. 'headerOther' => ['minWidth' => '110'],
  55. 'value' => function($row) use($decLevelConfig) {
  56. return $decLevelConfig[$row['FROM_ID']]['LEVEL_NAME'];
  57. },
  58. 'valueOther' => [
  59. 'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border']
  60. ],
  61. ],
  62. 'TO_DEC_LV_NAME' => [
  63. 'header' => Yii::t('ctx', 'modifiedLevel'),
  64. 'headerOther' => ['minWidth' => '120'],
  65. 'value' => function($row) use($decLevelConfig) {
  66. return isset($decLevelConfig[$row['TO_ID']])?$decLevelConfig[$row['TO_ID']]['LEVEL_NAME']:'';
  67. },
  68. 'valueOther' => [
  69. 'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border']
  70. ],
  71. ],
  72. 'ADMIN_NAME' => [
  73. 'header' => Yii::t('ctx', 'operationAdministrator'),
  74. 'headerOther' => ['minWidth' => '100'],
  75. ],
  76. 'CREATED_AT' => [
  77. 'header' => Yii::t('ctx', 'createAt'),
  78. 'value' => function($row) {
  79. return (new DateTime([
  80. 'value' => $row['CREATED_AT'],
  81. ]))->result();
  82. },
  83. 'headerOther' => ['minWidth' => '100'],
  84. ],
  85. ];
  86. }
  87. return $this->columns;
  88. }
  89. /**
  90. * 前台用于筛选的类型集合
  91. * @return mixed
  92. */
  93. public function getFilterTypes()
  94. {
  95. if(!$this->filterTypes){
  96. $this->filterTypes = [
  97. 'USER_NAME'=> ['isUserTable' => false,'name'=> Yii::t('ctx', 'memberCode')],
  98. 'CREATED_AT' => ['isUserTable' => false, 'name' => Yii::t('ctx', 'createAt'), 'other' => 'date'],
  99. 'ADMIN_NAME' => ['isUserTable' => false, 'name' => Yii::t('ctx', 'operationAdministrator')],
  100. ];
  101. }
  102. return $this->filterTypes;
  103. }
  104. }