BalanceList.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  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. // 'CF' => [
  176. // 'header' => '车房养老余额',
  177. // 'value' => function($row) {
  178. // return (new Price([
  179. // 'value' => $row['CF'],
  180. // ]))->result();
  181. // },
  182. // 'headerOther' => [
  183. // 'width' => '150',
  184. // 'prop'=>'CF',
  185. // ],
  186. // 'valueOther' => [
  187. // 'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
  188. // ],
  189. // ],
  190. // 'LX' => [
  191. // 'header' => '领袖分红余额',
  192. // 'value' => function($row) {
  193. // return (new Price([
  194. // 'value' => $row['LX'],
  195. // ]))->result();
  196. // },
  197. // 'headerOther' => [
  198. // 'width' => '150',
  199. // 'prop'=>'LX',
  200. // ],
  201. // 'valueOther' => [
  202. // 'tag'=>['type'=>'danger', 'size' => 'small', 'class'=>'no-border'],
  203. // ],
  204. // ],
  205. // 'WITHDRAW_WAIT' => [
  206. // 'header' => '提现金额',
  207. // 'value' => function($row) {
  208. // return (new Price([
  209. // 'value' => $row['WITHDRAW_WAIT'],
  210. // ]))->result();
  211. // },
  212. // 'headerOther' => [
  213. // 'width' => '150',
  214. // 'prop'=>'WITHDRAW_WAIT',
  215. // ],
  216. // 'valueOther' => [
  217. // 'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border'],
  218. // ],
  219. // ],
  220. // 'TAX' => [
  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'=>'TAX',
  230. // ],
  231. // 'valueOther' => [
  232. // 'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border'],
  233. // ],
  234. // ],
  235. // 'DEDUCT' => [
  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'=>'DEDUCT',
  245. // ],
  246. // 'valueOther' => [
  247. // 'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border'],
  248. // ],
  249. // ],
  250. // 'REAL_PAID' => [
  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'=>'REAL_PAID',
  260. // ],
  261. // 'valueOther' => [
  262. // 'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border'],
  263. // ],
  264. // ],
  265. // 'WITHDRAW_FAIL' => [
  266. // 'header' => '实付失败金额',
  267. // 'value' => function($row) {
  268. // return (new Price([
  269. // 'value' => $row['WITHDRAW_FAIL'],
  270. // ]))->result();
  271. // },
  272. // 'headerOther' => [
  273. // 'width' => '150',
  274. // 'prop'=>'WITHDRAW_FAIL',
  275. // ],
  276. // 'valueOther' => [
  277. // 'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border'],
  278. // ],
  279. // ],
  280. // 'STATUS' => [
  281. // 'header' => '会员状态',
  282. // 'value' => function($row){
  283. // return Yii::$app->params['userStatus'][$row['STATUS']]['label'];
  284. // },
  285. // 'headerOther' => ['width' => '110'],
  286. // ],
  287. // 'STATUS_AT' => [
  288. // 'header' => '会员状态变更时间',
  289. // 'value' => function($row) {
  290. // return (new DateTime([
  291. // 'value' => $row['STATUS_AT'],
  292. // ]))->result();
  293. // },
  294. // 'headerOther' => ['width' => '170'],
  295. // ],
  296. // 'HIGHEST_EMP_LV_NAME' => [
  297. // 'header' => '历史最高聘级',
  298. // 'headerOther' => ['width' => '130'],
  299. // ],
  300. 'PERIOD_AT' => '加入期数',
  301. // 'DEC_DEC_ROLE_NAME' => [
  302. // 'header' => '所属报单中心级别',
  303. // 'headerOther' => ['width' => '150'],
  304. // ],
  305. // 'DEC_USER_NAME' => [
  306. // 'header' => '所属报单中心编号',
  307. // 'headerOther' => ['width' => '150'],
  308. // ],
  309. // 'DEC_REAL_NAME' => [
  310. // 'header' => '所属报单中心姓名',
  311. // 'headerOther' => ['width' => '150'],
  312. // ],
  313. 'MOBILE' => [
  314. 'header' => '手机号码',
  315. 'value' => function($row) {
  316. return "\t".$row['MOBILE'];
  317. },
  318. 'headerOther' => ['width' => '120'],
  319. ],
  320. 'TEL' => [
  321. 'header' => '备用手机号码',
  322. 'value' => function($row) {
  323. return "\t".$row['TEL'];
  324. },
  325. 'headerOther' => ['width' => '120'],
  326. ],
  327. // 'AREA' => [
  328. // 'header' => '常用地址',
  329. // 'value' => function($row) {
  330. // return $row['PROVINCE_NAME'].$row['CITY_NAME'].$row['COUNTY_NAME'];
  331. // },
  332. // 'showValue' => function($row) {
  333. // return '<div class="addr" :title='.$row['PROVINCE_NAME'].$row['CITY_NAME'].$row['COUNTY_NAME'].'>'.$row['PROVINCE_NAME'].$row['CITY_NAME'].$row['COUNTY_NAME'].'</div>';
  334. // },
  335. // 'headerOther' => [
  336. // 'width' => '200'
  337. // ],
  338. // ],
  339. // 'SUB_COM_NAME' => [
  340. // 'header' => '所属分公司',
  341. // 'headerOther' => ['width' => '100'],
  342. // ],
  343. // 'IS_DIRECT_SELLER' => [
  344. // 'header' => '是否直销员',
  345. // 'value' => function($row) {
  346. // return (new YesNo([
  347. // 'value' => $row['IS_DIRECT_SELLER'],
  348. // ]))->result();
  349. // },
  350. // 'headerOther' => function($row) {
  351. // return [
  352. // 'width' => '120',
  353. // ];
  354. // },
  355. // 'valueOther' => function($row) {
  356. // return [
  357. // 'tag'=>['type'=>(isset($row['IS_DIRECT_SELLER']) && $row['IS_DIRECT_SELLER']) ? 'success' : 'info', 'size' => 'small']
  358. // ];
  359. // },
  360. // ],
  361. ];
  362. }
  363. return $this->columns;
  364. }
  365. /**
  366. * 前台用于筛选的类型集合
  367. * @return mixed
  368. */
  369. public function getFilterTypes()
  370. {
  371. if(!$this->filterTypes){
  372. $this->filterTypes = [
  373. 'USER_NAME'=> ['isUserTable'=> false, 'name'=> '会员编号'],
  374. 'REAL_NAME'=> ['isUserTable'=> false, 'name'=> '会员姓名'],
  375. // 'DEC_LV_NAME'=> ['isUserTable'=> true, 'name'=> '会员级别', 'other'=> 'decLevel'],
  376. // 'EMP_LV_NAME'=> ['isUserTable'=> true, 'name'=> '聘级', 'other'=> 'empLevel'],
  377. 'IS_DEC'=> ['isUserTable'=> false, 'name'=> '是否报单中心', 'other'=> 'yesOrNo'],
  378. // 'DEC_ROLE_NAME'=> ['isUserTable'=> true, 'name'=> '报单中心级别', 'other'=> 'decRole'],
  379. // 'SYSTEM_NAME'=> ['isUserTable'=> false, 'name'=> '体系名称', 'other'=> 'systems'],
  380. 'BONUS'=> ['isUserTable'=> false, 'name'=> '会员奖金余额'],
  381. 'RECONSUME_POINTS'=> ['isUserTable'=> false, 'name'=> '会员复消积分'],
  382. 'CASH'=> ['isUserTable'=> false, 'name'=> '会员余额'],
  383. // 'CF'=> ['isUserTable'=> false, 'name'=> '车房养老余额'],
  384. // 'LX'=> ['isUserTable'=> false, 'name'=> '领袖分红余额'],
  385. // 'STATUS'=> ['isUserTable'=> true, 'name'=> '会员状态', 'other'=> 'status'],
  386. // 'STATUS_AT'=> ['isUserTable'=> true, 'name'=> '会员状态变更时间', 'other'=> 'date'],
  387. // 'HIGHEST_EMP_LV_NAME'=> ['isUserTable'=> false, 'name'=> '历史最高聘级', 'other'=> 'empLevel'],
  388. 'PERIOD_AT'=> ['isUserTable'=> false, 'name'=> '加入期数'],
  389. // 'DEC_DEC_ROLE_NAME'=> ['isUserTable'=> true, 'name'=> '所属报单中心级别', 'other'=> 'decRole'],
  390. // 'DEC_USER_NAME'=> ['isUserTable'=> true, 'name'=> '所属报单中心编号'],
  391. // 'DEC_REAL_NAME'=> ['isUserTable'=> true, 'name'=> '所属报单中心姓名'],
  392. 'MOBILE'=> ['isUserTable'=> false, 'name'=> '手机号码'],
  393. 'TEL'=> ['isUserTable'=> false, 'name'=> '备用手机号码'],
  394. // 'AREA'=> ['isUserTable'=> true, 'name'=> '常用地址', 'other'=> 'area'],
  395. // 'SUB_COM_NAME'=> ['isUserTable'=> true, 'name'=> '所属分公司', 'other'=> 'subCompany'],
  396. // 'IS_DIRECT_SELLER'=> ['isUserTable'=> true, 'name'=> '是否直销员', 'other'=> 'yesOrNo'],
  397. ];
  398. }
  399. return $this->filterTypes;
  400. }
  401. }