FlowReconsumePointsList.php 8.5 KB

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