FlowBonusList.php 11 KB

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