FlowExchangePointsList.php 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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\libs\dataList\column\DateTime;
  10. use common\models\FlowExchangePoints;
  11. use Yii;
  12. class FlowExchangePointsList 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 = FlowExchangePoints::lists($this->condition, $this->params, [
  26. 'orderBy' => 'CREATED_AT DESC, ID DESC',
  27. 'page' => $this->page,
  28. 'pageSize' => $this->pageSize,
  29. ]);
  30. foreach ($this->listData['list'] as $key => $value) {
  31. $userInfo = Info::baseInfoZh($value['USER_ID']);
  32. $this->listData['list'][$key] = array_merge($userInfo, $value);
  33. $this->listData['list'][$key]['DEAL_TYPE_NAME'] = DealType::getAllTypesForShow()[$value['DEAL_TYPE_ID']]['TYPE_NAME'] ?? '';
  34. $this->listData['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_DEC_LV']]['LEVEL_NAME'] ?? '';
  35. $this->listData['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_EMP_LV']]['LEVEL_NAME'] ?? '';
  36. $this->listData['list'][$key]['LAST_STATUS_NAME'] = \Yii::$app->params['userStatus'][$value['LAST_STATUS']]['label'] ?? '';
  37. }
  38. }
  39. /**
  40. * 要展示和导出的所有字段
  41. * @return array
  42. */
  43. public function getColumn() {
  44. if (!$this->columns) {
  45. $this->columns = [
  46. 'ID' => null,
  47. 'CREATED_AT' => [
  48. 'header' => '创建时间',
  49. 'value' => function ($row) {
  50. return (new DateTime([
  51. 'value' => $row['CREATED_AT'],
  52. ]))->result();
  53. },
  54. 'headerOther' => ['width' => '170'],
  55. ],
  56. 'PERIOD_NUM' => '期数',
  57. 'CALC_MONTH' => '结算月',
  58. 'DEAL_TYPE_NAME' => [
  59. 'header' => '交易类型',
  60. 'headerOther' => [
  61. 'width' => '150',
  62. ],
  63. ],
  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. 'IS_DEC' => [
  101. 'header' => '是否报单中心',
  102. 'value' => function ($row) {
  103. return (new YesNo([
  104. 'value' => $row['IS_DEC'],
  105. ]))->result();
  106. },
  107. 'headerOther' => function ($row) {
  108. return [
  109. 'width' => '120',
  110. ];
  111. },
  112. 'valueOther' => function ($row) {
  113. return [
  114. 'tag' => ['type' => (isset($row['IS_DEC']) && $row['IS_DEC']) ? 'success' : 'info', 'size' => 'small']
  115. ];
  116. },
  117. ],
  118. 'BEFORE_BALANCE' => [
  119. 'header' => '交易前余额',
  120. 'value' => function ($row) {
  121. return (new Price([
  122. 'value' => $row['TOTAL'] - $row['AMOUNT'],
  123. ]))->result();
  124. },
  125. 'headerOther' => [
  126. 'width' => '150',
  127. ],
  128. ],
  129. 'AMOUNT' => [
  130. 'header' => '交易额',
  131. 'value' => function ($row) {
  132. $result = (new Price([
  133. 'value' => $row['AMOUNT'],
  134. ]))->result();
  135. return $row['IS_INCR'] > 0 ? '+' . $result : $result;
  136. },
  137. 'headerOther' => [
  138. 'width' => '150',
  139. 'prop' => 'BONUS',
  140. ],
  141. 'valueOther' => function ($row) {
  142. if ($row['IS_INCR'] > 0) {
  143. $type = 'success';
  144. } elseif ($row['IS_INCR'] == 0) {
  145. $type = 'danger';
  146. } else {
  147. $type = 'info';
  148. }
  149. return [
  150. 'tag' => ['type' => $type, 'size' => 'small']
  151. ];
  152. },
  153. ],
  154. 'TOTAL' => [
  155. 'header' => '交易后余额',
  156. 'value' => function ($row) {
  157. return (new Price([
  158. 'value' => $row['TOTAL'],
  159. ]))->result();
  160. },
  161. 'headerOther' => [
  162. 'width' => '150',
  163. ],
  164. ],
  165. 'ADMIN_NAME' => [
  166. 'header' => '操作人',
  167. 'headerOther' => ['width' => '110'],
  168. ],
  169. 'REMARK' => [
  170. 'header' => '备注',
  171. 'headerOther' => ['width' => '250'],
  172. ],
  173. 'ORDER_SN' => [
  174. 'header' => '订单号',
  175. 'headerOther' => ['width' => '250'],
  176. ],
  177. ];
  178. }
  179. return $this->columns;
  180. }
  181. /**
  182. * 前台用于筛选的类型集合
  183. * @return mixed
  184. */
  185. public function getFilterTypes() {
  186. if (!$this->filterTypes) {
  187. $this->filterTypes = [
  188. 'CREATED_AT' => ['isUserTable' => false, 'name' => '创建时间', 'other' => 'date'],
  189. 'PERIOD_NUM' => ['isUserTable' => false, 'name' => '期数'],
  190. 'CALC_MONTH' => ['isUserTable' => false, 'name' => '结算月', 'other' => 'month'],
  191. 'DEAL_TYPE_NAME' => ['isUserTable' => false, 'name' => '交易类型', 'other' => 'dealTypes'],
  192. 'USER_NAME' => ['isUserTable' => true, 'name' => '会员编号'],
  193. 'REAL_NAME' => ['isUserTable' => true, 'name' => '会员姓名'],
  194. 'LAST_DEC_LV_NAME' => ['isUserTable' => false, 'name' => '会员级别', 'other' => 'decLevel'],
  195. 'LAST_EMP_LV_NAME' => ['isUserTable' => false, 'name' => '聘级', 'other' => 'empLevel'],
  196. 'IS_DEC' => ['isUserTable' => true, 'name' => '是否报单中心', 'other' => 'yesOrNo'],
  197. 'AMOUNT' => ['isUserTable' => false, 'name' => '交易额'],
  198. 'TOTAL' => ['isUserTable' => false, 'name' => '交易后余额'],
  199. 'ADMIN_NAME' => ['isUserTable' => false, 'name' => '操作人'],
  200. 'REMARK' => ['isUserTable' => false, 'name' => '备注'],
  201. ];
  202. }
  203. return $this->filterTypes;
  204. }
  205. }