DecLevelList.php 4.1 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\Countries;
  7. use common\models\DecLevelLog;
  8. use common\models\User;
  9. use common\models\UserInfo;
  10. use common\libs\dataList\column\DateTime;
  11. use common\models\UserMove;
  12. use Yii;
  13. class DecLevelList extends \common\libs\dataList\DataList implements DataListInterface
  14. {
  15. /**
  16. * 列表名称
  17. * @return string
  18. */
  19. public function getListName(){
  20. return '会员级别调整列表';
  21. }
  22. /**
  23. * 列表筛选到的数据
  24. */
  25. public function dataHandle()
  26. {
  27. $this->listData = DecLevelLog::lists($this->condition, $this->params, [
  28. 'select' => 'LL.*, CU.USER_NAME, ADM.ADMIN_NAME, C.NAME AS COUNTRY',
  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. ['INNER JOIN', User::tableName() . ' AS CU', 'LL.USER_ID=CU.ID'],
  34. ['INNER JOIN', Countries::tableName() . ' AS C', 'CU.COUNTRY_ID=C.ID'],
  35. ],
  36. 'page' => $this->page,
  37. 'pageSize' => $this->pageSize,
  38. ]);
  39. }
  40. /**
  41. * 要展示和导出的所有字段
  42. * @return array
  43. */
  44. public function getColumn(){
  45. $decLevelConfig = Cache::getDecLevelConfig();
  46. if(!$this->columns){
  47. $this->columns = [
  48. 'ID' => null,
  49. 'USER_ID' => null,
  50. 'USER_NAME' => [
  51. 'header' => Yii::t('ctx', 'memberCode'),
  52. 'headerOther' => ['minWidth' => '120'],
  53. ],
  54. 'COUNTRY' => [
  55. 'header' => Yii::t('ctx', 'country'),
  56. ],
  57. 'FROM_DEC_LV_NAME' => [
  58. 'header' => Yii::t('ctx', 'levelBeforeModification'),
  59. 'headerOther' => ['minWidth' => '110'],
  60. 'value' => function($row) use($decLevelConfig) {
  61. return $decLevelConfig[$row['FROM_ID']]['LEVEL_NAME'];
  62. },
  63. 'valueOther' => [
  64. 'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border']
  65. ],
  66. ],
  67. 'TO_DEC_LV_NAME' => [
  68. 'header' => Yii::t('ctx', 'modifiedLevel'),
  69. 'headerOther' => ['minWidth' => '120'],
  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' => Yii::t('ctx', 'operationAdministrator'),
  79. 'headerOther' => ['minWidth' => '100'],
  80. ],
  81. 'CREATED_AT' => [
  82. 'header' => Yii::t('ctx', 'createAt'),
  83. 'value' => function($row) {
  84. return (new DateTime([
  85. 'value' => $row['CREATED_AT'],
  86. ]))->result();
  87. },
  88. 'headerOther' => ['minWidth' => '100'],
  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'=> Yii::t('ctx', 'memberCode')],
  103. 'CREATED_AT' => ['isUserTable' => false, 'name' => Yii::t('ctx', 'createAt'), 'other' => 'date'],
  104. 'ADMIN_NAME' => ['isUserTable' => false, 'name' => Yii::t('ctx', 'operationAdministrator')],
  105. ];
  106. }
  107. return $this->filterTypes;
  108. }
  109. }