FlowReconsumePointsList.php 8.3 KB

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