FlowBalanceList.php 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <?php
  2. namespace backendApi\modules\v1\models\lists\bonus;
  3. use common\helpers\Cache;
  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\DealType;
  9. use common\models\FlowWallet;
  10. use common\libs\dataList\column\DateTime;
  11. use Yii;
  12. class FlowBalanceList extends \common\libs\dataList\DataList implements DataListInterface {
  13. /**
  14. * 列表名称
  15. * @return string
  16. */
  17. public function getListName() {
  18. return '会员余额流水';
  19. }
  20. /**
  21. * 列表筛选到的数据
  22. * @throws \yii\base\Exception
  23. */
  24. public function dataHandle() {
  25. $this->listData = FlowWallet::lists($this->condition, $this->params, [
  26. 'select' => 'FW.ORDER_SN,FW.TRANSFER_SN,FW.USER_ID,FW.AMOUNT,FW.TOTAL,FW.IS_INCR,FW.REMARK,FW.PERIOD_NUM,FW.CALC_MONTH,FW.CREATED_AT,
  27. U.USER_NAME,U.REAL_NAME,U.IS_DEC',
  28. 'orderBy' => 'FW.CREATED_AT DESC,FW.SORT DESC',
  29. 'from' => FlowWallet::tableName() . ' AS FW',
  30. 'join' => [
  31. ['INNER JOIN', \common\models\User::tableName() . ' AS U', 'FW.USER_ID=U.ID'],
  32. ],
  33. 'page' => $this->page,
  34. 'pageSize' => $this->pageSize,
  35. ]);
  36. // foreach ($this->listData['list'] as $key => $value) {
  37. // //$userInfo = Info::baseInfoZh($value['USER_ID']);
  38. // //$this->listData['list'][$key] = array_merge($userInfo, $value);
  39. // //$this->listData['list'][$key]['DEAL_TYPE_NAME'] = DealType::getAllTypesForShow()[$value['DEAL_TYPE_ID']]['TYPE_NAME'] ?? '';
  40. // // $this->listData['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_DEC_LV']]['LEVEL_NAME'] ?? '';
  41. // // $this->listData['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_EMP_LV']]['LEVEL_NAME'] ?? '';
  42. // // $this->listData['list'][$key]['LAST_STATUS_NAME'] = \Yii::$app->params['userStatus'][$value['LAST_STATUS']]['label'] ?? '';
  43. // }
  44. }
  45. /**
  46. * 要展示和导出的所有字段
  47. * @return array
  48. */
  49. public function getColumn() {
  50. if (!$this->columns) {
  51. $this->columns = [
  52. // 'ID' => null,
  53. 'CREATED_AT' => [
  54. 'header' => '创建时间',
  55. 'value' => function ($row) {
  56. return (new DateTime([
  57. 'value' => $row['CREATED_AT'],
  58. ]))->result();
  59. },
  60. 'headerOther' => ['width' => '170'],
  61. ],
  62. 'PERIOD_NUM' => '期数',
  63. 'CALC_MONTH' => '结算月',
  64. 'USER_NAME' => [
  65. 'header' => '会员编号',
  66. 'headerOther' => [
  67. 'width' => '150',
  68. ],
  69. 'valueOther' => [
  70. 'tag' => ['type' => 'info', 'size' => 'small', 'class' => 'no-border']
  71. ],
  72. ],
  73. 'REAL_NAME' => [
  74. 'header' => '会员姓名',
  75. 'headerOther' => [
  76. 'width' => '120',
  77. ],
  78. 'valueOther' => [
  79. 'tag' => ['type' => 'success', 'size' => 'small', 'class' => 'no-border']
  80. ],
  81. ],
  82. // 'LAST_DEC_LV_NAME' => [
  83. // 'header' => '会员级别',
  84. // 'headerOther' => [
  85. // 'width' => '110',
  86. // ],
  87. // 'valueOther' => [
  88. // 'tag' => ['type' => 'warning', 'size' => 'small', 'class' => 'no-border']
  89. // ],
  90. // ],
  91. // 'LAST_EMP_LV_NAME' => [
  92. // 'header' => '聘级',
  93. // 'headerOther' => [
  94. // 'width' => '130',
  95. // ],
  96. // 'valueOther' => [
  97. // 'tag' => ['type' => 'warning', 'size' => 'small', 'class' => 'no-border']
  98. // ],
  99. // ],
  100. // 'LAST_STATUS_NAME' => [
  101. // 'header' => '会员状态',
  102. // 'headerOther' => ['width' => '110'],
  103. // ],
  104. // 'SYSTEM_NAME' => [
  105. // 'header' => '体系',
  106. // 'headerOther' => ['width' => '200'],
  107. // ],
  108. 'IS_DEC' => [
  109. 'header' => '是否报单中心',
  110. 'value' => function ($row) {
  111. return (new YesNo([
  112. 'value' => $row['IS_DEC'],
  113. ]))->result();
  114. },
  115. 'headerOther' => function ($row) {
  116. return [
  117. 'width' => '120',
  118. ];
  119. },
  120. 'valueOther' => function ($row) {
  121. return [
  122. 'tag' => ['type' => (isset($row['IS_DEC']) && $row['IS_DEC']) ? 'success' : 'info', 'size' => 'small']
  123. ];
  124. },
  125. ],
  126. 'BEFORE_BALANCE' => [
  127. 'header' => '交易前余额',
  128. 'value' => function ($row) {
  129. return (new Price([
  130. 'value' => $row['TOTAL'] - $row['AMOUNT'],
  131. ]))->result();
  132. },
  133. 'headerOther' => [
  134. 'width' => '150',
  135. ],
  136. ],
  137. 'AMOUNT' => [
  138. 'header' => '交易额',
  139. 'value' => function ($row) {
  140. $result = (new Price([
  141. 'value' => $row['AMOUNT'],
  142. ]))->result();
  143. return $row['IS_INCR'] > 0 ? '+' . $result : $result;
  144. },
  145. 'headerOther' => [
  146. 'width' => '150',
  147. 'prop' => 'BONUS',
  148. ],
  149. 'valueOther' => function ($row) {
  150. if ($row['IS_INCR'] > 0) {
  151. $type = 'success';
  152. } elseif ($row['IS_INCR'] == 0) {
  153. $type = 'danger';
  154. } else {
  155. $type = 'info';
  156. }
  157. return [
  158. 'tag' => ['type' => $type, 'size' => 'small']
  159. ];
  160. },
  161. ],
  162. 'TOTAL' => [
  163. 'header' => '交易后余额',
  164. 'value' => function ($row) {
  165. return (new Price([
  166. 'value' => $row['TOTAL'],
  167. ]))->result();
  168. },
  169. 'headerOther' => [
  170. 'width' => '150',
  171. ],
  172. ],
  173. // 'ADMIN_NAME' => [
  174. // 'header' => '操作人',
  175. // 'headerOther' => ['width' => '110'],
  176. // ],
  177. 'REMARK' => [
  178. 'header' => '备注',
  179. 'headerOther' => ['width' => '250'],
  180. ],
  181. 'TRANSFER_SN' => [
  182. 'header' => '流水号',
  183. 'headerOther' => ['width' => '250'],
  184. ],
  185. 'ORDER_SN' => [
  186. 'header' => '订单号',
  187. 'headerOther' => ['width' => '250'],
  188. ],
  189. ];
  190. }
  191. return $this->columns;
  192. }
  193. /**
  194. * 前台用于筛选的类型集合
  195. * @return mixed
  196. */
  197. public function getFilterTypes() {
  198. if (!$this->filterTypes) {
  199. $this->filterTypes = [
  200. 'CREATED_AT' => ['isUserTable' => false, 'name' => '创建时间', 'other' => 'date'],
  201. 'PERIOD_NUM' => ['isUserTable' => false, 'name' => '期数'],
  202. 'CALC_MONTH' => ['isUserTable' => false, 'name' => '结算月', 'other' => 'month'],
  203. 'DEAL_TYPE_NAME' => ['isUserTable' => false, 'name' => '交易类型', 'other' => 'dealTypes'],
  204. 'USER_NAME' => ['isUserTable' => false, 'name' => '会员编号'],
  205. 'REAL_NAME' => ['isUserTable' => false, 'name' => '会员姓名'],
  206. // 'LAST_DEC_LV_NAME' => ['isUserTable' => false, 'name' => '会员级别', 'other' => 'decLevel'],
  207. // 'LAST_EMP_LV_NAME' => ['isUserTable' => false, 'name' => '聘级', 'other' => 'empLevel'],
  208. // // 'LAST_STATUS_NAME' => ['isUserTable' => false, 'name' => '会员状态', 'other' => 'status'],
  209. // // 'SYSTEM_NAME' => ['isUserTable' => true, 'name' => '体系', 'other' => 'systems'],
  210. // 'IS_DEC' => ['isUserTable' => false, 'name' => '是否报单中心', 'other' => 'yesOrNo'],
  211. // 'DEC_ROLE_NAME' => ['isUserTable' => true, 'name' => '报单中心级别', 'other' => 'decRole'],
  212. // 'IS_DIRECT_SELLER' => ['isUserTable' => true, 'name' => '是否直销员', 'other' => 'yesOrNo'],
  213. 'AMOUNT' => ['isUserTable' => false, 'name' => '交易额'],
  214. 'TOTAL' => ['isUserTable' => false, 'name' => '交易后余额'],
  215. 'ADMIN_NAME' => ['isUserTable' => false, 'name' => '操作人'],
  216. 'REMARK' => ['isUserTable' => false, 'name' => '备注'],
  217. 'TRANSFER_SN' => ['isUserTable' => false, 'name' => '流水号'],
  218. ];
  219. }
  220. return $this->filterTypes;
  221. }
  222. }