PerfMonthList.php 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <?php
  2. namespace backendApi\modules\v1\models\lists\bonus;
  3. use common\helpers\Cache;
  4. use common\helpers\user\Info;
  5. use common\models\PerfMonth;
  6. use common\models\User as modelUser;
  7. use common\libs\dataList\column\Price;
  8. use common\libs\dataList\DataListInterface;
  9. use common\libs\dataList\column\DateTime;
  10. use common\models\UserInfo;
  11. use Yii;
  12. class PerfMonthList extends \common\libs\dataList\DataList implements DataListInterface
  13. {
  14. /**
  15. * 列表名称
  16. * @return string
  17. */
  18. public function getListName(){
  19. return '月业绩列表';
  20. }
  21. /**
  22. * 列表筛选到的数据
  23. * @throws \yii\base\Exception
  24. */
  25. public function dataHandle()
  26. {
  27. $data = PerfMonth::lists($this->condition, $this->params, [
  28. 'select'=>'PM.*, U.USER_NAME, U.REAL_NAME,RU.USER_NAME REC_USER_NAME,RU.REAL_NAME REC_REAL_NAME,',
  29. 'from' => PerfMonth::tableName().' AS PM',
  30. 'join' => [
  31. ['LEFT JOIN', modelUser::tableName() . ' AS U', 'PM.USER_ID=U.ID'],
  32. ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'PM.USER_ID=UI.USER_ID'],
  33. ['LEFT JOIN', modelUser::tableName() . ' AS RU', 'UI.REC_UID=RU.ID'],
  34. ],
  35. 'orderBy' => 'PM.CREATED_AT DESC, PM.ID DESC',
  36. 'page' => $this->page,
  37. 'pageSize' => $this->pageSize,
  38. ]);
  39. if ($data['list']) {
  40. foreach ($data['list'] as $key => $value) {
  41. $data['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_DEC_LV']]['LEVEL_NAME'] ?? '';
  42. $data['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_EMP_LV']]['LEVEL_NAME'] ?? '';
  43. }
  44. }
  45. $this->listData = $data;
  46. }
  47. /**
  48. * 要展示和导出的所有字段
  49. * @return array
  50. */
  51. public function getColumn(){
  52. if(!$this->columns){
  53. $this->columns = [
  54. 'CALC_MONTH' => [
  55. 'header' => '结算月',
  56. 'headerOther' => [
  57. 'width' => '100',
  58. ],
  59. ],
  60. 'USER_NAME' => [
  61. 'header' => '会员编号',
  62. 'headerOther' => [
  63. 'width' => '110',
  64. ],
  65. ],
  66. 'REAL_NAME' => [
  67. 'header' => '会员姓名',
  68. 'headerOther' => [
  69. 'width' => '150',
  70. ],
  71. ],
  72. 'REC_USER_NAME' => [
  73. 'header' => '推荐人编号',
  74. 'headerOther' => [
  75. 'width' => '110',
  76. ],
  77. ],
  78. 'REC_REAL_NAME' => [
  79. 'header' => '推荐人姓名',
  80. 'headerOther' => [
  81. 'width' => '150',
  82. ],
  83. ],
  84. 'LAST_DEC_LV_NAME' => [
  85. 'header' => '结算时会员级别',
  86. 'headerOther' => [
  87. 'width' => '150',
  88. ],
  89. ],
  90. 'LAST_EMP_LV_NAME' => [
  91. 'header' => '结算时会员聘级',
  92. 'headerOther' => [
  93. 'width' => '150',
  94. ],
  95. ],
  96. 'PV_PCS' => [
  97. 'header' => '个人业绩',
  98. 'headerOther' => [
  99. 'width' => '150',
  100. ],
  101. 'value' => function($row) {
  102. return (new Price([
  103. 'value' => $row['PV_PCS'],
  104. ]))->result();
  105. },
  106. ],
  107. 'VIP_PV_1L_ZC' => [
  108. 'header' => '一市场新增报单业绩',
  109. 'headerOther' => [
  110. 'width' => '150',
  111. ],
  112. 'value' => function($row) {
  113. return (new Price([
  114. 'value' => $row['VIP_PV_1L_ZC'],
  115. ]))->result();
  116. },
  117. ],
  118. 'VIP_PV_2L_ZC' => [
  119. 'header' => '二市场新增报单业绩',
  120. 'headerOther' => [
  121. 'width' => '150',
  122. ],
  123. 'value' => function($row) {
  124. return (new Price([
  125. 'value' => $row['VIP_PV_2L_ZC'],
  126. ]))->result();
  127. },
  128. ],
  129. 'VIP_PV_3L_ZC' => [
  130. 'header' => '三市场新增报单业绩',
  131. 'headerOther' => [
  132. 'width' => '150',
  133. ],
  134. 'value' => function($row) {
  135. return (new Price([
  136. 'value' => $row['VIP_PV_3L_ZC'],
  137. ]))->result();
  138. },
  139. ],
  140. 'VIP_SURPLUS_1L_ZC' => [
  141. 'header' => '一市场月剩余报单业绩',
  142. 'headerOther' => [
  143. 'width' => '150',
  144. ],
  145. 'value' => function($row) {
  146. return (new Price([
  147. 'value' => $row['VIP_SURPLUS_1L_ZC'],
  148. ]))->result();
  149. },
  150. ],
  151. 'VIP_SURPLUS_2L_ZC' => [
  152. 'header' => '二市场月剩余报单业绩',
  153. 'headerOther' => [
  154. 'width' => '150',
  155. ],
  156. 'value' => function($row) {
  157. return (new Price([
  158. 'value' => $row['VIP_SURPLUS_2L_ZC'],
  159. ]))->result();
  160. },
  161. ],
  162. 'VIP_SURPLUS_3L_ZC' => [
  163. 'header' => '三市场月剩余报单业绩',
  164. 'headerOther' => [
  165. 'width' => '150',
  166. ],
  167. 'value' => function($row) {
  168. return (new Price([
  169. 'value' => $row['VIP_SURPLUS_3L_ZC'],
  170. ]))->result();
  171. },
  172. ],
  173. 'PV_PSS' => [
  174. 'header' => '月新增团队业绩',
  175. 'headerOther' => [
  176. 'width' => '150',
  177. ],
  178. 'value' => function($row) {
  179. return (new Price([
  180. 'value' => $row['PV_PSS'],
  181. ]))->result();
  182. },
  183. ],
  184. 'PV_PSS_TOTAL' => [
  185. 'header' => '月累计团队业绩',
  186. 'headerOther' => [
  187. 'width' => '150',
  188. ],
  189. 'value' => function($row) {
  190. return (new Price([
  191. 'value' => $row['PV_PSS_TOTAL'],
  192. ]))->result();
  193. },
  194. ],
  195. 'CREATED_AT' => [
  196. 'header' => '创建时间',
  197. 'value' => function($row) {
  198. return (new DateTime([
  199. 'value' => $row['CREATED_AT'],
  200. ]))->result();
  201. },
  202. 'headerOther' => ['width' => '170'],
  203. ],
  204. ];
  205. }
  206. return $this->columns;
  207. }
  208. /**
  209. * 前台用于筛选的类型集合
  210. * @return mixed
  211. */
  212. public function getFilterTypes()
  213. {
  214. if(!$this->filterTypes){
  215. $this->filterTypes = [
  216. 'CALC_MONTH'=> ['isUserTable'=> false, 'name'=> '结算月'],
  217. 'USER_NAME'=> ['isUserTable'=> false, 'name'=> '会员编号'],
  218. 'REC_USER_NAME'=> ['isUserTable'=> false, 'name'=> '推荐人编号'],
  219. 'CREATED_AT'=> ['isUserTable'=> false, 'name'=> '创建时间', 'other'=> 'date'],
  220. ];
  221. }
  222. return $this->filterTypes;
  223. }
  224. }