BalanceList.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. <?php
  2. namespace backendApi\modules\v1\models\lists\bonus;
  3. use backendApi\modules\v1\models\Admin;
  4. use common\helpers\user\Info;
  5. use common\libs\dataList\column\Price;
  6. use common\libs\dataList\column\YesNo;
  7. use common\libs\dataList\DataListInterface;
  8. use common\models\User;
  9. use common\models\UserBind;
  10. use common\models\UserBonus;
  11. use common\models\UserInfo;
  12. use common\libs\dataList\column\DateTime;
  13. use common\models\UserWallet;
  14. use common\models\Withdraw;
  15. use Yii;
  16. class BalanceList extends \common\libs\dataList\DataList implements DataListInterface
  17. {
  18. /**
  19. * 列表名称
  20. * @return string
  21. */
  22. public function getListName(){
  23. return '会员奖金余额列表';
  24. }
  25. /**
  26. * 列表筛选到的数据
  27. * @throws \yii\base\Exception
  28. */
  29. public function dataHandle()
  30. {
  31. $this->condition .= ' AND UI.STATUS=1 AND I.LAST_LOGIN_AT>=1620748800';
  32. $this->listData = UserBonus::lists($this->condition, $this->params, [
  33. 'select' => 'UB.*,UI.*,UW.CASH',
  34. 'from' => UserBonus::tableName() . ' AS UB',
  35. 'join' => [
  36. // ['LEFT JOIN', UserInfo::tableName() . ' AS UI', 'UI.USER_ID=UB.USER_ID'],
  37. ['LEFT JOIN', User::tableName() . ' AS UI', 'UI.ID=UB.USER_ID'],
  38. ['LEFT JOIN', UserWallet::tableName() . ' AS UW', 'UW.USER_ID=UB.USER_ID'],
  39. ['LEFT JOIN', UserInfo::tableName() . ' AS I', 'I.USER_ID=UB.USER_ID']
  40. ],
  41. 'orderBy' => 'UB.CREATED_AT ASC, UB.ID ASC',
  42. 'page' => $this->page,
  43. 'pageSize' => $this->pageSize,
  44. ]);
  45. // foreach ($this->listData['list'] as $key => $value) {
  46. // $userInfo = Info::baseInfo($value['USER_ID']);
  47. // $this->listData['list'][$key] = array_merge($value, $userInfo);
  48. // $this->listData['list'][$key]['WITHDRAW_WAIT'] = Withdraw::getWithdrawTotal($value['USER_ID'], Withdraw::STATUS_WAIT_PAID);
  49. // $this->listData['list'][$key]['WITHDRAW_FAIL'] = Withdraw::getWithdrawTotal($value['USER_ID'], Withdraw::STATUS_PAID_FALSE);
  50. // }
  51. //总计
  52. // $sumData = UserBonus::find()->select('SUM(BONUS) AS SUM_BONUS,SUM(CF) AS SUM_CF,SUM(LX) AS SUM_LX')
  53. // ->from(UserBonus::tableName() . ' AS UB')
  54. // ->leftJoin(UserInfo::tableName() . ' AS UI', 'UI.USER_ID=UB.USER_ID')
  55. // ->where('1=1 ' . $this->condition, $this->params)->asArray()->one();
  56. // $sumData['SUM_WITHDRAW_WAIT'] = Withdraw::getAllWithdrawTotal(Withdraw::STATUS_WAIT_PAID);
  57. // $sumData['SUM_WITHDRAW_FAIL'] = Withdraw::getAllWithdrawTotal(Withdraw::STATUS_PAID_FALSE);
  58. // $this->listData['sumData'] = $sumData;
  59. }
  60. /**
  61. * 要展示和导出的所有字段
  62. * @return array
  63. */
  64. public function getColumn(){
  65. if(!$this->columns){
  66. $this->columns = [
  67. 'USER_ID' => null, // 这种传输方式主要是用于索引,因为过滤后的字段可能没有这种ID,但是一些功能的操作还需要用这种ID去关联,例如前台会员列表中的勾选批量状态管理,这里需要的就是USER_ID
  68. 'USER_NAME' => [
  69. 'header' => '会员编号',
  70. 'headerOther' => [
  71. 'width' => '150',
  72. ],
  73. 'valueOther' => [
  74. 'tag'=>['type'=>'info', 'size' => 'small', 'class'=>'no-border']
  75. ],
  76. ],
  77. 'REAL_NAME' => [
  78. 'header' => '会员姓名',
  79. 'headerOther' => [
  80. 'width' => '120',
  81. ],
  82. 'valueOther' => [
  83. 'tag'=>['type'=>'success', 'size' => 'small', 'class'=>'no-border']
  84. ],
  85. ],
  86. // 'DEC_LV_NAME' => [
  87. // 'header' => '会员级别',
  88. // 'headerOther' => [
  89. // 'width' => '110',
  90. // ],
  91. // 'valueOther' => [
  92. // 'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border']
  93. // ],
  94. // ],
  95. // 'EMP_LV_NAME' => [
  96. // 'header' => '聘级',
  97. // 'headerOther' => [
  98. // 'width' => '130',
  99. // ],
  100. // 'valueOther' => [
  101. // 'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border']
  102. // ],
  103. // ],
  104. 'IS_DEC' => [
  105. 'header' => '是否报单中心',
  106. 'value' => function($row) {
  107. return (new YesNo([
  108. 'value' => $row['IS_DEC'],
  109. ]))->result();
  110. },
  111. 'headerOther' => function($row) {
  112. return [
  113. 'width' => '120',
  114. ];
  115. },
  116. 'valueOther' => function($row) {
  117. return [
  118. 'tag'=>['type'=>(isset($row['IS_DEC']) && $row['IS_DEC'] )? 'success' : 'info', 'size' => 'small']
  119. ];
  120. },
  121. ],
  122. // 'DEC_ROLE_NAME' => [
  123. // 'header' => '报单中心级别',
  124. // 'headerOther' => ['width' => '110'],
  125. // ],
  126. // 'SYSTEM_NAME' => [
  127. // 'header' => '体系名称',
  128. // 'headerOther' => ['width' => '150'],
  129. // ],
  130. 'BONUS' => [
  131. 'header' => '会员奖金余额',
  132. 'value' => function($row) {
  133. return (new Price([
  134. 'value' => $row['BONUS'],
  135. ]))->result();
  136. },
  137. 'headerOther' => [
  138. 'width' => '150',
  139. 'prop'=>'BONUS',
  140. ],
  141. 'valueOther' => [
  142. 'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
  143. ],
  144. ],
  145. // 'RECONSUME_POINTS' => [
  146. // 'header' => '会员复消积分',
  147. // 'value' => function($row) {
  148. // return (new Price([
  149. // 'value' => $row['RECONSUME_POINTS'],
  150. // ]))->result();
  151. // },
  152. // 'headerOther' => [
  153. // 'width' => '150',
  154. // 'prop'=>'BONUS',
  155. // ],
  156. // 'valueOther' => [
  157. // 'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
  158. // ],
  159. // ],
  160. 'CASH' => [
  161. 'header' => '会员余额',
  162. 'value' => function($row) {
  163. return (new Price([
  164. 'value' => $row['CASH'],
  165. ]))->result();
  166. },
  167. 'headerOther' => [
  168. 'width' => '150',
  169. 'prop'=>'BONUS',
  170. ],
  171. 'valueOther' => [
  172. 'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
  173. ],
  174. ],
  175. 'EXCHANGE_POINTS' => [
  176. 'header' => '兑换积分',
  177. 'value' => function($row) {
  178. return (new Price([
  179. 'value' => $row['EXCHANGE_POINTS'],
  180. ]))->result();
  181. },
  182. 'headerOther' => [
  183. 'width' => '150',
  184. 'prop'=>'BONUS',
  185. ],
  186. 'valueOther' => [
  187. 'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
  188. ],
  189. ],
  190. // 'CF' => [
  191. // 'header' => '车房养老余额',
  192. // 'value' => function($row) {
  193. // return (new Price([
  194. // 'value' => $row['CF'],
  195. // ]))->result();
  196. // },
  197. // 'headerOther' => [
  198. // 'width' => '150',
  199. // 'prop'=>'CF',
  200. // ],
  201. // 'valueOther' => [
  202. // 'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
  203. // ],
  204. // ],
  205. // 'LX' => [
  206. // 'header' => '领袖分红余额',
  207. // 'value' => function($row) {
  208. // return (new Price([
  209. // 'value' => $row['LX'],
  210. // ]))->result();
  211. // },
  212. // 'headerOther' => [
  213. // 'width' => '150',
  214. // 'prop'=>'LX',
  215. // ],
  216. // 'valueOther' => [
  217. // 'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
  218. // ],
  219. // ],
  220. // 'WITHDRAW_WAIT' => [
  221. // 'header' => '提现金额',
  222. // 'value' => function($row) {
  223. // return (new Price([
  224. // 'value' => $row['WITHDRAW_WAIT'],
  225. // ]))->result();
  226. // },
  227. // 'headerOther' => [
  228. // 'width' => '150',
  229. // 'prop'=>'WITHDRAW_WAIT',
  230. // ],
  231. // 'valueOther' => [
  232. // 'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border'],
  233. // ],
  234. // ],
  235. // 'TAX' => [
  236. // 'header' => '个税',
  237. // 'value' => function($row) {
  238. // return (new Price([
  239. // 'value' => $row['WITHDRAW_WAIT'],
  240. // ]))->result();
  241. // },
  242. // 'headerOther' => [
  243. // 'width' => '150',
  244. // 'prop'=>'TAX',
  245. // ],
  246. // 'valueOther' => [
  247. // 'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border'],
  248. // ],
  249. // ],
  250. // 'DEDUCT' => [
  251. // 'header' => '扣款',
  252. // 'value' => function($row) {
  253. // return (new Price([
  254. // 'value' => $row['WITHDRAW_WAIT'],
  255. // ]))->result();
  256. // },
  257. // 'headerOther' => [
  258. // 'width' => '150',
  259. // 'prop'=>'DEDUCT',
  260. // ],
  261. // 'valueOther' => [
  262. // 'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border'],
  263. // ],
  264. // ],
  265. // 'REAL_PAID' => [
  266. // 'header' => '实付金额',
  267. // 'value' => function($row) {
  268. // return (new Price([
  269. // 'value' => $row['WITHDRAW_WAIT'],
  270. // ]))->result();
  271. // },
  272. // 'headerOther' => [
  273. // 'width' => '150',
  274. // 'prop'=>'REAL_PAID',
  275. // ],
  276. // 'valueOther' => [
  277. // 'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border'],
  278. // ],
  279. // ],
  280. // 'WITHDRAW_FAIL' => [
  281. // 'header' => '实付失败金额',
  282. // 'value' => function($row) {
  283. // return (new Price([
  284. // 'value' => $row['WITHDRAW_FAIL'],
  285. // ]))->result();
  286. // },
  287. // 'headerOther' => [
  288. // 'width' => '150',
  289. // 'prop'=>'WITHDRAW_FAIL',
  290. // ],
  291. // 'valueOther' => [
  292. // 'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border'],
  293. // ],
  294. // ],
  295. // 'STATUS' => [
  296. // 'header' => '会员状态',
  297. // 'value' => function($row){
  298. // return Yii::$app->params['userStatus'][$row['STATUS']]['label'];
  299. // },
  300. // 'headerOther' => ['width' => '110'],
  301. // ],
  302. // 'STATUS_AT' => [
  303. // 'header' => '会员状态变更时间',
  304. // 'value' => function($row) {
  305. // return (new DateTime([
  306. // 'value' => $row['STATUS_AT'],
  307. // ]))->result();
  308. // },
  309. // 'headerOther' => ['width' => '170'],
  310. // ],
  311. // 'HIGHEST_EMP_LV_NAME' => [
  312. // 'header' => '历史最高聘级',
  313. // 'headerOther' => ['width' => '130'],
  314. // ],
  315. 'TOURISM_POINTS' => [
  316. 'header' => '旅游积分',
  317. 'value' => function($row) {
  318. return (new Price([
  319. 'value' => $row['TOURISM_POINTS'],
  320. ]))->result();
  321. },
  322. 'headerOther' => [
  323. 'width' => '150',
  324. 'prop'=>'TOURISM_POINTS',
  325. ],
  326. 'valueOther' => [
  327. 'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
  328. ],
  329. ],
  330. 'GARAGE_POINTS' => [
  331. 'header' => '车房积分',
  332. 'value' => function($row) {
  333. return (new Price([
  334. 'value' => $row['GARAGE_POINTS'],
  335. ]))->result();
  336. },
  337. 'headerOther' => [
  338. 'width' => '150',
  339. 'prop'=>'GARAGE_POINTS',
  340. ],
  341. 'valueOther' => [
  342. 'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
  343. ],
  344. ],
  345. 'PERIOD_AT' => '加入期数',
  346. // 'DEC_DEC_ROLE_NAME' => [
  347. // 'header' => '所属报单中心级别',
  348. // 'headerOther' => ['width' => '150'],
  349. // ],
  350. // 'DEC_USER_NAME' => [
  351. // 'header' => '所属报单中心编号',
  352. // 'headerOther' => ['width' => '150'],
  353. // ],
  354. // 'DEC_REAL_NAME' => [
  355. // 'header' => '所属报单中心姓名',
  356. // 'headerOther' => ['width' => '150'],
  357. // ],
  358. 'MOBILE' => [
  359. 'header' => '手机号码',
  360. 'value' => function($row) {
  361. return "\t".$row['MOBILE'];
  362. },
  363. 'headerOther' => ['width' => '120'],
  364. ],
  365. 'TEL' => [
  366. 'header' => '备用手机号码',
  367. 'value' => function($row) {
  368. return "\t".$row['TEL'];
  369. },
  370. 'headerOther' => ['width' => '120'],
  371. ],
  372. // 'AREA' => [
  373. // 'header' => '常用地址',
  374. // 'value' => function($row) {
  375. // return $row['PROVINCE_NAME'].$row['CITY_NAME'].$row['COUNTY_NAME'];
  376. // },
  377. // 'showValue' => function($row) {
  378. // return '<div class="addr" :title='.$row['PROVINCE_NAME'].$row['CITY_NAME'].$row['COUNTY_NAME'].'>'.$row['PROVINCE_NAME'].$row['CITY_NAME'].$row['COUNTY_NAME'].'</div>';
  379. // },
  380. // 'headerOther' => [
  381. // 'width' => '200'
  382. // ],
  383. // ],
  384. // 'SUB_COM_NAME' => [
  385. // 'header' => '所属分公司',
  386. // 'headerOther' => ['width' => '100'],
  387. // ],
  388. // 'IS_DIRECT_SELLER' => [
  389. // 'header' => '是否直销员',
  390. // 'value' => function($row) {
  391. // return (new YesNo([
  392. // 'value' => $row['IS_DIRECT_SELLER'],
  393. // ]))->result();
  394. // },
  395. // 'headerOther' => function($row) {
  396. // return [
  397. // 'width' => '120',
  398. // ];
  399. // },
  400. // 'valueOther' => function($row) {
  401. // return [
  402. // 'tag'=>['type'=>(isset($row['IS_DIRECT_SELLER']) && $row['IS_DIRECT_SELLER']) ? 'success' : 'info', 'size' => 'small']
  403. // ];
  404. // },
  405. // ],
  406. ];
  407. }
  408. return $this->columns;
  409. }
  410. /**
  411. * 前台用于筛选的类型集合
  412. * @return mixed
  413. */
  414. public function getFilterTypes()
  415. {
  416. if(!$this->filterTypes){
  417. $this->filterTypes = [
  418. 'USER_NAME'=> ['isUserTable'=> false, 'name'=> '会员编号'],
  419. 'REAL_NAME'=> ['isUserTable'=> false, 'name'=> '会员姓名'],
  420. // 'DEC_LV_NAME'=> ['isUserTable'=> true, 'name'=> '会员级别', 'other'=> 'decLevel'],
  421. // 'EMP_LV_NAME'=> ['isUserTable'=> true, 'name'=> '聘级', 'other'=> 'empLevel'],
  422. 'IS_DEC'=> ['isUserTable'=> false, 'name'=> '是否报单中心', 'other'=> 'yesOrNo'],
  423. // 'DEC_ROLE_NAME'=> ['isUserTable'=> true, 'name'=> '报单中心级别', 'other'=> 'decRole'],
  424. // 'SYSTEM_NAME'=> ['isUserTable'=> false, 'name'=> '体系名称', 'other'=> 'systems'],
  425. 'BONUS'=> ['isUserTable'=> false, 'name'=> '会员奖金余额'],
  426. // 'RECONSUME_POINTS'=> ['isUserTable'=> false, 'name'=> '会员复消积分'],
  427. 'CASH'=> ['isUserTable'=> false, 'name'=> '会员余额'],
  428. // 'CF'=> ['isUserTable'=> false, 'name'=> '车房养老余额'],
  429. // 'LX'=> ['isUserTable'=> false, 'name'=> '领袖分红余额'],
  430. // 'STATUS'=> ['isUserTable'=> true, 'name'=> '会员状态', 'other'=> 'status'],
  431. // 'STATUS_AT'=> ['isUserTable'=> true, 'name'=> '会员状态变更时间', 'other'=> 'date'],
  432. // 'HIGHEST_EMP_LV_NAME'=> ['isUserTable'=> false, 'name'=> '历史最高聘级', 'other'=> 'empLevel'],
  433. 'PERIOD_AT'=> ['isUserTable'=> false, 'name'=> '加入期数'],
  434. // 'DEC_DEC_ROLE_NAME'=> ['isUserTable'=> true, 'name'=> '所属报单中心级别', 'other'=> 'decRole'],
  435. // 'DEC_USER_NAME'=> ['isUserTable'=> true, 'name'=> '所属报单中心编号'],
  436. // 'DEC_REAL_NAME'=> ['isUserTable'=> true, 'name'=> '所属报单中心姓名'],
  437. 'MOBILE'=> ['isUserTable'=> false, 'name'=> '手机号码'],
  438. 'TEL'=> ['isUserTable'=> false, 'name'=> '备用手机号码'],
  439. // 'AREA'=> ['isUserTable'=> true, 'name'=> '常用地址', 'other'=> 'area'],
  440. // 'SUB_COM_NAME'=> ['isUserTable'=> true, 'name'=> '所属分公司', 'other'=> 'subCompany'],
  441. // 'IS_DIRECT_SELLER'=> ['isUserTable'=> true, 'name'=> '是否直销员', 'other'=> 'yesOrNo'],
  442. ];
  443. }
  444. return $this->filterTypes;
  445. }
  446. }