FlowWalletList.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <?php
  2. namespace backendApi\modules\v1\models\lists\bonus;
  3. use common\helpers\user\Info;
  4. use common\libs\dataList\column\Price;
  5. use common\libs\dataList\DataListInterface;
  6. use common\libs\dataList\column\DateTime;
  7. use common\models\FlowWallet;
  8. use common\models\User;
  9. use Yii;
  10. class FlowWalletList extends \common\libs\dataList\DataList implements DataListInterface {
  11. /**
  12. * 列表名称
  13. * @return string
  14. */
  15. public function getListName() {
  16. return '现金钱包流水';
  17. }
  18. /**
  19. * 列表筛选到的数据
  20. * @throws \yii\base\Exception
  21. */
  22. public function dataHandle() {
  23. $this->listData = FlowWallet::lists($this->condition, $this->params, [
  24. 'select' => 'FW.*,U.USER_NAME,U.REAL_NAME,U.IS_DEC',
  25. 'orderBy' => 'FW.CREATED_AT DESC,FW.ID DESC',
  26. 'from' => FlowWallet::tableName() . ' AS FW',
  27. 'join' => [
  28. ['LEFT JOIN', User::tableName() . ' AS U', 'FW.USER_ID=U.ID'],
  29. ],
  30. 'page' => $this->page,
  31. 'pageSize' => $this->pageSize,
  32. ]);
  33. // foreach ($this->listData['list'] as $key => $value) {
  34. // $userInfo = Info::baseInfoZh($value['USER_ID']);
  35. // $this->listData['list'][$key] = array_merge($userInfo, $value);
  36. // }
  37. }
  38. /**
  39. * 要展示和导出的所有字段
  40. * @return array
  41. */
  42. public function getColumn() {
  43. if (!$this->columns) {
  44. $this->columns = [
  45. 'ID' => null,
  46. 'CREATED_AT' => [
  47. 'header' => '创建时间',
  48. 'value' => function ($row) {
  49. return (new DateTime([
  50. 'value' => $row['CREATED_AT'],
  51. ]))->result();
  52. },
  53. 'headerOther' => ['width' => '170'],
  54. ],
  55. 'PERIOD_NUM' => '期数',
  56. 'CALC_MONTH' => '结算月',
  57. 'USER_NAME' => [
  58. 'header' => '会员编号',
  59. 'headerOther' => [
  60. 'width' => '150',
  61. ],
  62. 'valueOther' => [
  63. 'tag' => ['type' => 'info', 'size' => 'small', 'class' => 'no-border']
  64. ],
  65. ],
  66. 'REAL_NAME' => [
  67. 'header' => '会员姓名',
  68. 'headerOther' => [
  69. 'width' => '120',
  70. ],
  71. 'valueOther' => [
  72. 'tag' => ['type' => 'success', 'size' => 'small', 'class' => 'no-border']
  73. ],
  74. ],
  75. 'BEFORE_BALANCE' => [
  76. 'header' => '交易前余额',
  77. 'value' => function ($row) {
  78. return (new Price([
  79. 'value' => $row['TOTAL'] - $row['AMOUNT'],
  80. ]))->result();
  81. },
  82. 'headerOther' => [
  83. 'width' => '150',
  84. ],
  85. ],
  86. 'AMOUNT' => [
  87. 'header' => '交易额',
  88. 'value' => function ($row) {
  89. $result = (new Price([
  90. 'value' => $row['AMOUNT'],
  91. ]))->result();
  92. return $row['IS_INCR'] > 0 ? '+' . $result : $result;
  93. },
  94. 'headerOther' => [
  95. 'width' => '150',
  96. 'prop' => 'BONUS',
  97. ],
  98. 'valueOther' => function ($row) {
  99. if ($row['IS_INCR'] > 0) {
  100. $type = 'success';
  101. } elseif ($row['IS_INCR'] == 0) {
  102. $type = 'danger';
  103. } else {
  104. $type = 'info';
  105. }
  106. return [
  107. 'tag' => ['type' => $type, 'size' => 'small']
  108. ];
  109. },
  110. ],
  111. 'TOTAL' => [
  112. 'header' => '交易后余额',
  113. 'value' => function ($row) {
  114. return (new Price([
  115. 'value' => $row['TOTAL'],
  116. ]))->result();
  117. },
  118. 'headerOther' => [
  119. 'width' => '150',
  120. ],
  121. ],
  122. 'ADMIN_NAME' => [
  123. 'header' => '操作人',
  124. 'headerOther' => ['width' => '110'],
  125. ],
  126. 'REMARK' => [
  127. 'header' => '备注',
  128. 'headerOther' => ['width' => '250'],
  129. ],
  130. ];
  131. }
  132. return $this->columns;
  133. }
  134. /**
  135. * 前台用于筛选的类型集合
  136. * @return mixed
  137. */
  138. public function getFilterTypes() {
  139. if (!$this->filterTypes) {
  140. $this->filterTypes = [
  141. 'CREATED_AT' => ['isUserTable' => false, 'name' => '创建时间', 'other' => 'date'],
  142. 'PERIOD_NUM' => ['isUserTable' => false, 'name' => '期数'],
  143. 'CALC_MONTH' => ['isUserTable' => false, 'name' => '结算月', 'other' => 'month'],
  144. 'DEAL_TYPE_NAME' => ['isUserTable' => false, 'name' => '交易类型', 'other' => 'dealTypes'],
  145. 'USER_NAME' => ['isUserTable' => false, 'name' => '会员编号'],
  146. 'REAL_NAME' => ['isUserTable' => false, 'name' => '会员姓名'],
  147. 'LAST_DEC_LV_NAME' => ['isUserTable' => false, 'name' => '会员级别', 'other' => 'decLevel'],
  148. 'LAST_EMP_LV_NAME' => ['isUserTable' => false, 'name' => '聘级', 'other' => 'empLevel'],
  149. 'IS_DEC' => ['isUserTable' => false, 'name' => '是否报单中心', 'other' => 'yesOrNo'],
  150. 'AMOUNT' => ['isUserTable' => false, 'name' => '交易额'],
  151. 'TOTAL' => ['isUserTable' => false, 'name' => '交易后余额'],
  152. 'ADMIN_NAME' => ['isUserTable' => false, 'name' => '操作人'],
  153. 'REMARK' => ['isUserTable' => false, 'name' => '备注'],
  154. ];
  155. }
  156. return $this->filterTypes;
  157. }
  158. }