OtherPeriodBonusList.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  1. <?php
  2. namespace backendApi\modules\v1\models\lists\bonus;
  3. use backendApi\modules\v1\models\Admin;
  4. use common\helpers\Cache;
  5. use common\helpers\Tool;
  6. use common\helpers\user\Info;
  7. use common\libs\dataList\column\Price;
  8. use common\libs\dataList\column\YesNo;
  9. use common\libs\dataList\DataListInterface;
  10. use common\models\CalcBonus;
  11. use common\models\PerfOrder;
  12. use common\models\Period;
  13. use common\models\Region;
  14. use common\models\User as modelUser;
  15. use common\models\UserBind;
  16. use common\models\UserBonus;
  17. use common\models\UserInfo;
  18. use common\libs\dataList\column\DateTime;
  19. use common\models\UserPerf;
  20. use common\models\UserSystem;
  21. use common\models\Withdraw;
  22. use Yii;
  23. class OtherPeriodBonusList extends \common\libs\dataList\DataList implements DataListInterface
  24. {
  25. /**
  26. * 列表名称
  27. * @return string
  28. */
  29. public function getListName(){
  30. return '往期奖金列表';
  31. }
  32. /**
  33. * 列表筛选到的数据
  34. * @throws \yii\base\Exception
  35. */
  36. public function dataHandle()
  37. {
  38. $yearMonth = $this->others['yearMonth'];
  39. $this->listData = CalcBonus::lists($this->condition, $this->params, [
  40. //'select'=>'CB.*, UP.SURPLUS_1L AS UP_SURPLUS_1L, UP.SURPLUS_2L AS UP_SURPLUS_2L, UP.SURPLUS_3L AS UP_SURPLUS_3L,UI.CON_UID,UI.REC_UID',
  41. 'select'=>'CB.*,UI.CON_UID,UI.REC_UID',
  42. 'from' => CalcBonus::tableName().' AS CB',
  43. 'join' => [
  44. //['LEFT JOIN', UserPerf::tableName() . ' AS UP', 'CB.USER_ID=UP.USER_ID'],
  45. ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'CB.USER_ID=UI.USER_ID'],
  46. ],
  47. 'yearMonth' => $yearMonth,
  48. 'orderBy' => 'CB.CREATED_AT DESC, CB.ID DESC',
  49. 'page' => $this->page,
  50. 'pageSize' => $this->pageSize,
  51. ]);
  52. unset($yearMonth);
  53. if ($this->listData['list']) {
  54. foreach ($this->listData['list'] as $key => $value) {
  55. $this->listData['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_DEC_LV']]['LEVEL_NAME'];
  56. $this->listData['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_EMP_LV']]['LEVEL_NAME'];
  57. $this->listData['list'][$key]['LAST_STATUS_NAME'] = Tool::paramConvert(Yii::$app->params['userStatus'])[$value['LAST_STATUS']]['label'];
  58. $this->listData['list'][$key]['LAST_REC_USER_NAME'] = Info::getUserNameByUserId($value['REC_UID']);
  59. $this->listData['list'][$key]['LAST_REC_REAL_NAME'] = Info::getUserRealNameByUserId($value['REC_UID']);
  60. $this->listData['list'][$key]['LAST_CON_USER_NAME'] = Info::getUserNameByUserId($value['CON_UID']);
  61. $this->listData['list'][$key]['LAST_CON_REAL_NAME'] = Info::getUserRealNameByUserId($value['CON_UID']);
  62. }
  63. }
  64. }
  65. /**
  66. * 要展示和导出的所有字段
  67. * @return array
  68. */
  69. public function getColumn(){
  70. if(!$this->columns){
  71. $this->columns = [
  72. 'ID' => null,
  73. 'PERIOD_NUM' => [
  74. 'header' => '结算期数',
  75. 'headerOther' => [
  76. 'width' => '150',
  77. ],
  78. 'valueOther' => [
  79. 'tag'=>['type'=>'', 'size' => 'small', 'class'=>'no-border'],
  80. ],
  81. ],
  82. 'CALCULATED_AT' => [
  83. 'header' => '结算时间',
  84. 'value' => function($row) {
  85. return (new DateTime([
  86. 'value' => $row['CALCULATED_AT'],
  87. ]))->result();
  88. },
  89. 'headerOther' => ['width' => '170'],
  90. ],
  91. 'LAST_USER_NAME' => [
  92. 'header' => '会员编号',
  93. 'headerOther' => [
  94. 'width' => '150',
  95. ],
  96. 'valueOther' => [
  97. 'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border']
  98. ],
  99. ],
  100. 'LAST_REAL_NAME' => [
  101. 'header' => '会员姓名',
  102. 'headerOther' => [
  103. 'width' => '120',
  104. ],
  105. 'valueOther' => [
  106. 'tag'=>['type'=>'success', 'size' => 'small', 'class'=>'no-border']
  107. ],
  108. ],
  109. 'LAST_DEC_LV_NAME' => [
  110. 'header' => '结算时会员级别',
  111. 'headerOther' => [
  112. 'width' => '120',
  113. ],
  114. ],
  115. 'LAST_EMP_LV_NAME' => [
  116. 'header' => '结算时会员聘级',
  117. 'headerOther' => [
  118. 'width' => '140',
  119. ],
  120. ],
  121. 'LAST_MOBILE' => [
  122. 'header' => '手机号码',
  123. 'headerOther' => [
  124. 'width' => '120',
  125. ],
  126. ],
  127. 'LAST_PERIOD_AT' => [
  128. 'header' => '加入期数',
  129. 'headerOther' => [
  130. 'width' => '100',
  131. ],
  132. ],
  133. 'LAST_CREATED_AT' => [
  134. 'header' => '加入时间',
  135. 'value' => function($row) {
  136. return (new DateTime([
  137. 'value' => $row['LAST_CREATED_AT'],
  138. ]))->result();
  139. },
  140. 'headerOther' => ['width' => '170'],
  141. ],
  142. 'LAST_REC_USER_NAME' => [
  143. 'header' => '开拓者编号',
  144. 'headerOther' => [
  145. 'width' => '150',
  146. ],
  147. ],
  148. 'LAST_REC_REAL_NAME' => [
  149. 'header' => '开拓者姓名',
  150. 'headerOther' => [
  151. 'width' => '100',
  152. ],
  153. ],
  154. 'LAST_CON_USER_NAME' => [
  155. 'header' => '上级编号',
  156. 'headerOther' => [
  157. 'width' => '150',
  158. ],
  159. ],
  160. 'LAST_CON_REAL_NAME' => [
  161. 'header' => '上级姓名',
  162. 'headerOther' => [
  163. 'width' => '100',
  164. ],
  165. ],
  166. 'PV_1L' => [
  167. 'header' => '一市场新增业绩',
  168. 'value' => function($row) {
  169. return (new Price([
  170. 'value' => $row['PV_1L'],
  171. ]))->result();
  172. },
  173. 'headerOther' => [
  174. 'width' => '120',
  175. 'prop'=>'PV_1L',
  176. ],
  177. ],
  178. 'SURPLUS_1L' => [
  179. 'header' => '一市场结余业绩',
  180. 'value' => function($row) {
  181. return (new Price([
  182. 'value' => $row['SURPLUS_1L'],
  183. ]))->result();
  184. },
  185. 'headerOther' => [
  186. 'width' => '120',
  187. 'prop'=>'SURPLUS_1L',
  188. ],
  189. ],
  190. 'PV_2L' => [
  191. 'header' => '二市场新增业绩',
  192. 'value' => function($row) {
  193. return (new Price([
  194. 'value' => $row['PV_2L'],
  195. ]))->result();
  196. },
  197. 'headerOther' => [
  198. 'width' => '120',
  199. 'prop'=>'PV_2L',
  200. ],
  201. ],
  202. 'SURPLUS_2L' => [
  203. 'header' => '二市场结余业绩',
  204. 'value' => function($row) {
  205. return (new Price([
  206. 'value' => $row['SURPLUS_2L'],
  207. ]))->result();
  208. },
  209. 'headerOther' => [
  210. 'width' => '120',
  211. 'prop'=>'SURPLUS_2L',
  212. ],
  213. ],
  214. // 'UP_SURPLUS_2L' => [
  215. // 'header' => '当前二市场结余业绩',
  216. // 'value' => function($row) {
  217. // return (new Price([
  218. // 'value' => $row['UP_SURPLUS_2L'],
  219. // ]))->result();
  220. // },
  221. // 'headerOther' => [
  222. // 'width' => '120',
  223. // 'prop'=>'UP_SURPLUS_2L',
  224. // ],
  225. // ],
  226. 'PV_3L' => [
  227. 'header' => '三市场新增业绩',
  228. 'value' => function($row) {
  229. return (new Price([
  230. 'value' => $row['PV_3L'],
  231. ]))->result();
  232. },
  233. 'headerOther' => [
  234. 'width' => '120',
  235. 'prop'=>'PV_3L',
  236. ],
  237. ],
  238. 'SURPLUS_3L' => [
  239. 'header' => '三市场结余业绩',
  240. 'value' => function($row) {
  241. return (new Price([
  242. 'value' => $row['SURPLUS_3L'],
  243. ]))->result();
  244. },
  245. 'headerOther' => [
  246. 'width' => '120',
  247. 'prop'=>'SURPLUS_3L',
  248. ],
  249. ],
  250. // 'UP_SURPLUS_3L' => [
  251. // 'header' => '当前三市场结余业绩',
  252. // 'value' => function($row) {
  253. // return (new Price([
  254. // 'value' => $row['UP_SURPLUS_3L'],
  255. // ]))->result();
  256. // },
  257. // 'headerOther' => [
  258. // 'width' => '120',
  259. // 'prop'=>'UP_SURPLUS_3L',
  260. // ],
  261. // ],
  262. 'BONUS_BD' => [
  263. 'header' => '服务奖',
  264. 'value' => function($row) {
  265. return (new Price([
  266. 'value' => $row['BONUS_BD'],
  267. ]))->result();
  268. },
  269. 'headerOther' => [
  270. 'width' => '120',
  271. 'prop'=>'BONUS_BD',
  272. ],
  273. ],
  274. 'ORI_BONUS_BD' => [
  275. 'header' => '服务奖原金额',
  276. 'value' => function($row) {
  277. return (new Price([
  278. 'value' => $row['ORI_BONUS_BD'],
  279. ]))->result();
  280. },
  281. 'headerOther' => [
  282. 'width' => '120',
  283. 'prop'=>'ORI_BONUS_BD',
  284. ],
  285. ],
  286. 'BONUS_TG' => [
  287. 'header' => '推广奖',
  288. 'value' => function($row) {
  289. return (new Price([
  290. 'value' => $row['BONUS_TG'],
  291. ]))->result();
  292. },
  293. 'headerOther' => [
  294. 'width' => '120',
  295. 'prop'=>'BONUS_TG',
  296. ],
  297. ],
  298. 'ORI_BONUS_TG' => [
  299. 'header' => '推广奖原金额',
  300. 'value' => function($row) {
  301. return (new Price([
  302. 'value' => $row['ORI_BONUS_TG'],
  303. ]))->result();
  304. },
  305. 'headerOther' => [
  306. 'width' => '120',
  307. 'prop'=>'ORI_BONUS_TG',
  308. ],
  309. ],
  310. 'BONUS_XF' => [
  311. 'header' => '消费奖',
  312. 'value' => function($row) {
  313. return (new Price([
  314. 'value' => $row['BONUS_XF'],
  315. ]))->result();
  316. },
  317. 'headerOther' => [
  318. 'width' => '120',
  319. 'prop'=>'BONUS_XF',
  320. ],
  321. ],
  322. 'ORI_BONUS_XF' => [
  323. 'header' => '消费奖原金额',
  324. 'value' => function($row) {
  325. return (new Price([
  326. 'value' => $row['ORI_BONUS_XF'],
  327. ]))->result();
  328. },
  329. 'headerOther' => [
  330. 'width' => '120',
  331. 'prop'=>'ORI_BONUS_XF',
  332. ],
  333. ],
  334. 'BONUS_YJ' => [
  335. 'header' => '业绩奖',
  336. 'value' => function($row) {
  337. return (new Price([
  338. 'value' => $row['BONUS_YJ'],
  339. ]))->result();
  340. },
  341. 'headerOther' => [
  342. 'width' => '120',
  343. 'prop'=>'BONUS_YJ',
  344. ],
  345. ],
  346. 'ORI_BONUS_YJ' => [
  347. 'header' => '业绩奖原金额',
  348. 'value' => function($row) {
  349. return (new Price([
  350. 'value' => $row['ORI_BONUS_YJ'],
  351. ]))->result();
  352. },
  353. 'headerOther' => [
  354. 'width' => '120',
  355. 'prop'=>'ORI_BONUS_YJ',
  356. ],
  357. ],
  358. 'BONUS_GX' => [
  359. 'header' => '共享奖',
  360. 'value' => function($row) {
  361. return (new Price([
  362. 'value' => $row['BONUS_GX'],
  363. ]))->result();
  364. },
  365. 'headerOther' => [
  366. 'width' => '120',
  367. 'prop'=>'BONUS_GX',
  368. ],
  369. ],
  370. 'ORI_BONUS_GX' => [
  371. 'header' => '共享奖原金额',
  372. 'value' => function($row) {
  373. return (new Price([
  374. 'value' => $row['ORI_BONUS_GX'],
  375. ]))->result();
  376. },
  377. 'headerOther' => [
  378. 'width' => '120',
  379. 'prop'=>'ORI_BONUS_GX',
  380. ],
  381. ],
  382. 'BONUS_GL' => [
  383. 'header' => '管理奖',
  384. 'value' => function($row) {
  385. return (new Price([
  386. 'value' => $row['BONUS_GL'],
  387. ]))->result();
  388. },
  389. 'headerOther' => [
  390. 'width' => '120',
  391. 'prop'=>'BONUS_GL',
  392. ],
  393. ],
  394. 'ORI_BONUS_GL' => [
  395. 'header' => '管理奖原金额',
  396. 'value' => function($row) {
  397. return (new Price([
  398. 'value' => $row['ORI_BONUS_GL'],
  399. ]))->result();
  400. },
  401. 'headerOther' => [
  402. 'width' => '120',
  403. 'prop'=>'ORI_BONUS_GL',
  404. ],
  405. ],
  406. 'BONUS_QY' => [
  407. 'header' => '团队奖',
  408. 'value' => function($row) {
  409. return (new Price([
  410. 'value' => $row['BONUS_QY'],
  411. ]))->result();
  412. },
  413. 'headerOther' => [
  414. 'width' => '120',
  415. 'prop'=>'BONUS_QY',
  416. ],
  417. ],
  418. 'ORI_BONUS_QY' => [
  419. 'header' => '团队奖原金额',
  420. 'value' => function($row) {
  421. return (new Price([
  422. 'value' => $row['ORI_BONUS_QY'],
  423. ]))->result();
  424. },
  425. 'headerOther' => [
  426. 'width' => '120',
  427. 'prop'=>'ORI_BONUS_QY',
  428. ],
  429. ],
  430. 'ORI_BONUS_QY_BD' => [
  431. 'header' => '报单团队奖原金额',
  432. 'value' => function($row) {
  433. return (new Price([
  434. 'value' => $row['ORI_BONUS_QY_BD'],
  435. ]))->result();
  436. },
  437. 'headerOther' => [
  438. 'width' => '120',
  439. 'prop'=>'ORI_BONUS_QY_BD',
  440. ],
  441. ],
  442. 'BONUS_YC' => [
  443. 'header' => '荣衔奖',
  444. 'value' => function($row) {
  445. return (new Price([
  446. 'value' => $row['BONUS_YC'],
  447. ]))->result();
  448. },
  449. 'headerOther' => [
  450. 'width' => '120',
  451. 'prop'=>'BONUS_YC',
  452. ],
  453. ],
  454. 'ORI_BONUS_YC' => [
  455. 'header' => '荣衔奖原金额',
  456. 'value' => function($row) {
  457. return (new Price([
  458. 'value' => $row['ORI_BONUS_YC'],
  459. ]))->result();
  460. },
  461. 'headerOther' => [
  462. 'width' => '120',
  463. 'prop'=>'ORI_BONUS_YC',
  464. ],
  465. ],
  466. 'BONUS_TOTAL' => [
  467. 'header' => '总奖金',
  468. 'value' => function($row) {
  469. return (new Price([
  470. 'value' => $row['BONUS_TOTAL'],
  471. ]))->result();
  472. },
  473. 'headerOther' => [
  474. 'width' => '120',
  475. 'prop'=>'BONUS_TOTAL',
  476. ],
  477. ],
  478. 'BONUS_INCOME' => [
  479. 'header' => '总收入',
  480. 'value' => function($row) {
  481. return (new Price([
  482. 'value' => $row['BONUS_INCOME'],
  483. ]))->result();
  484. },
  485. 'headerOther' => [
  486. 'width' => '120',
  487. 'prop'=>'BONUS_INCOME',
  488. ],
  489. ],
  490. 'ORI_BONUS_STANDARD' => [
  491. 'header' => '团队成长奖',
  492. 'value' => function($row) {
  493. return (new Price([
  494. 'value' => $row['ORI_BONUS_STANDARD'],
  495. ]))->result();
  496. },
  497. 'headerOther' => [
  498. 'width' => '120',
  499. 'prop'=>'ORI_BONUS_STANDARD',
  500. ],
  501. ],
  502. 'CALC_MONTH' => [
  503. 'header' => '结算月',
  504. 'headerOther' => [
  505. 'width' => '100',
  506. ],
  507. ],
  508. ];
  509. }
  510. return $this->columns;
  511. }
  512. /**
  513. * 前台用于筛选的类型集合
  514. * @return mixed
  515. */
  516. public function getFilterTypes()
  517. {
  518. if(!$this->filterTypes){
  519. $this->filterTypes = [
  520. 'LAST_USER_NAME'=> ['isUserTable'=> false, 'name'=> '会员编号'],
  521. 'LAST_REAL_NAME'=> ['isUserTable'=> false, 'name'=> '会员姓名'],
  522. 'LAST_DEC_LV_NAME'=> ['isUserTable'=> false, 'name'=> '结算时会员级别', 'other'=> 'decLevel'],
  523. 'LAST_EMP_LV_NAME'=> ['isUserTable'=> false, 'name'=> '结算时会员聘级', 'other'=> 'empLevel'],
  524. 'LAST_MOBILE'=> ['isUserTable'=> false, 'name'=> '手机号'],
  525. 'LAST_PERIOD_AT'=> ['isUserTable'=> false, 'name'=> '加入期数'],
  526. 'LAST_CREATED_AT'=> ['isUserTable'=> false, 'name'=> '加入时间', 'other'=> 'date'],
  527. 'LAST_REC_USER_NAME'=> ['isUserTable'=> false, 'name'=> '开拓者编号'],
  528. 'LAST_REC_REAL_NAME'=> ['isUserTable'=> false, 'name'=> '开拓者姓名'],
  529. 'LAST_CON_USER_NAME'=> ['isUserTable'=> false, 'name'=> '上级编号'],
  530. 'LAST_CON_REAL_NAME'=> ['isUserTable'=> false, 'name'=> '上级姓名'],
  531. 'PV_1L'=> ['isUserTable'=> false, 'name'=> '一市场新增业绩'],
  532. 'SURPLUS_1L'=> ['isUserTable'=> false, 'name'=> '一市场结余业绩'],
  533. 'PV_2L'=> ['isUserTable'=> false, 'name'=> '二市场新增业绩'],
  534. 'SURPLUS_2L'=> ['isUserTable'=> false, 'name'=> '二市场结余业绩'],
  535. 'PV_3L'=> ['isUserTable'=> false, 'name'=> '三市场新增业绩'],
  536. 'SURPLUS_3L'=> ['isUserTable'=> false, 'name'=> '三市场结余业绩'],
  537. 'BONUS_BD'=> ['isUserTable'=> false, 'name'=> '服务奖'],
  538. 'BONUS_TG'=> ['isUserTable'=> false, 'name'=> '推广奖'],
  539. 'BONUS_XF'=> ['isUserTable'=> false, 'name'=> '消费奖'],
  540. 'BONUS_YJ'=> ['isUserTable'=> false, 'name'=> '业绩奖'],
  541. 'BONUS_GX'=> ['isUserTable'=> false, 'name'=> '共享奖'],
  542. 'BONUS_GL'=> ['isUserTable'=> false, 'name'=> '管理奖'],
  543. 'BONUS_QY'=> ['isUserTable'=> false, 'name'=> '团队奖'],
  544. 'BONUS_YC'=> ['isUserTable'=> false, 'name'=> '荣衔奖'],
  545. 'ORI_BONUS_STANDARD'=> ['isUserTable'=> false, 'name'=> '团队成长奖'],
  546. 'CALC_MONTH'=> ['isUserTable'=> false, 'name'=> '结算月'],
  547. ];
  548. }
  549. return $this->filterTypes;
  550. }
  551. }