OtherPeriodBonusList.php 22 KB

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