FlowBonusList.php 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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' => 'Creation Time', // 创建时间
  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. 'header' => 'Period Number', // 期数
  63. 'headerOther' => [
  64. 'width' => '120',
  65. ],
  66. ],
  67. 'CALC_MONTH' => [
  68. 'header' => 'Bonus Month', // 结算月
  69. 'headerOther' => [
  70. 'width' => '120',
  71. ],
  72. ],
  73. 'DEAL_TYPE_NAME' => [
  74. 'header' => 'Transaction Type', // 交易类型
  75. 'headerOther' => [
  76. 'width' => '150',
  77. ],
  78. ],
  79. 'USER_NAME' => [
  80. 'header' => 'Member Code', // 会员编号
  81. 'headerOther' => [
  82. 'width' => '150',
  83. ],
  84. 'valueOther' => [
  85. 'tag' => ['type' => 'info', 'size' => 'small', 'class' => 'no-border']
  86. ],
  87. ],
  88. 'REAL_NAME' => [
  89. 'header' => 'Member Name', // 会员姓名
  90. 'headerOther' => [
  91. 'width' => '120',
  92. ],
  93. 'valueOther' => [
  94. 'tag' => ['type' => 'success', 'size' => 'small', 'class' => 'no-border']
  95. ],
  96. ],
  97. 'LAST_DEC_LV_NAME' => [
  98. 'header' => 'Member Level', // 会员级别
  99. 'headerOther' => [
  100. 'width' => '110',
  101. ],
  102. 'valueOther' => [
  103. 'tag' => ['type' => 'warning', 'size' => 'small', 'class' => 'no-border']
  104. ],
  105. ],
  106. 'IS_DEC' => [
  107. 'header' => 'Whether Declaration Center', // 是否报单中心
  108. 'value' => function ($row) {
  109. return (new YesNo([
  110. 'value' => $row['IS_DEC'],
  111. ]))->result();
  112. },
  113. 'headerOther' => function ($row) {
  114. return [
  115. 'width' => '200',
  116. ];
  117. },
  118. 'valueOther' => function ($row) {
  119. return [
  120. 'tag' => ['type' => (isset($row['IS_DEC']) && $row['IS_DEC']) ? 'success' : 'info', 'size' => 'small']
  121. ];
  122. },
  123. ],
  124. 'BEFORE_BALANCE' => [
  125. 'header' => 'Balance Before Transaction', // 交易前余额
  126. 'value' => function ($row) {
  127. return (new Price([
  128. 'value' => $row['TOTAL'] - $row['AMOUNT'],
  129. ]))->result();
  130. },
  131. 'headerOther' => [
  132. 'width' => '200',
  133. ],
  134. ],
  135. 'AMOUNT' => [
  136. 'header' => 'Debit/Credit', // 交易额
  137. 'value' => function ($row) {
  138. $result = (new Price([
  139. 'value' => $row['AMOUNT'],
  140. ]))->result();
  141. return $row['IS_INCR'] > 0 ? '+' . $result : $result;
  142. },
  143. 'headerOther' => [
  144. 'width' => '150',
  145. 'prop' => 'BONUS',
  146. ],
  147. 'valueOther' => function ($row) {
  148. if ($row['IS_INCR'] > 0) {
  149. $type = 'success';
  150. } elseif ($row['IS_INCR'] == 0) {
  151. $type = 'danger';
  152. } else {
  153. $type = 'info';
  154. }
  155. return [
  156. 'tag' => ['type' => $type, 'size' => 'small']
  157. ];
  158. },
  159. ],
  160. 'TOTAL' => [
  161. 'header' => 'New Balance', // 交易后余额
  162. 'value' => function ($row) {
  163. return (new Price([
  164. 'value' => $row['TOTAL'],
  165. ]))->result();
  166. },
  167. 'headerOther' => [
  168. 'width' => '150',
  169. ],
  170. ],
  171. 'ADMIN_NAME' => [
  172. 'header' => 'Operator', // 操作人
  173. 'headerOther' => ['width' => '110'],
  174. ],
  175. 'REMARK' => [
  176. 'header' => 'Remark', // 备注
  177. 'headerOther' => ['width' => '250'],
  178. ],
  179. 'TRANSFER_SN' => [
  180. 'header' => 'Serial Number', // 流水号
  181. 'headerOther' => ['width' => '250'],
  182. ],
  183. ];
  184. }
  185. return $this->columns;
  186. }
  187. /**
  188. * 前台用于筛选的类型集合
  189. * @return mixed
  190. */
  191. public function getFilterTypes() {
  192. if (!$this->filterTypes) {
  193. $this->filterTypes = [
  194. 'CREATED_AT' => ['isUserTable' => false, 'name' => 'Creation Time', 'other' => 'date'], // 创建时间
  195. 'PERIOD_NUM' => ['isUserTable' => false, 'name' => 'Period Number'], // 期数
  196. 'CALC_MONTH' => ['isUserTable' => false, 'name' => 'Bonus Month', 'other' => 'month'], // 结算月
  197. 'DEAL_TYPE_NAME' => ['isUserTable' => false, 'name' => 'Transaction Type', 'other' => 'dealTypes'], // 交易类型
  198. 'USER_NAME' => ['isUserTable' => false, 'name' => 'Member Code'], // 会员编号
  199. 'REAL_NAME' => ['isUserTable' => false, 'name' => 'Member Name'], // 会员姓名
  200. 'LAST_DEC_LV_NAME' => ['isUserTable' => false, 'name' => 'Member Level', 'other' => 'decLevel'], // 会员等级
  201. 'LAST_EMP_LV_NAME' => ['isUserTable' => false, 'name' => 'Rank', 'other' => 'empLevel'], // 聘级
  202. 'IS_DEC' => ['isUserTable' => false, 'name' => 'Whether Declaration Center', 'other' => 'yesOrNo'], // 是否报单中心
  203. 'AMOUNT' => ['isUserTable' => false, 'name' => 'Debit/Credit'], // 交易额
  204. 'TOTAL' => ['isUserTable' => false, 'name' => 'New Balance'], // 交易后余额
  205. 'ADMIN_NAME' => ['isUserTable' => false, 'name' => 'Operator'], // 操作人
  206. 'REMARK' => ['isUserTable' => false, 'name' => 'Remark'], // 备注
  207. 'TRANSFER_SN' => ['isUserTable' => false, 'name' => 'Serial Number'], // 流水号
  208. ];
  209. }
  210. return $this->filterTypes;
  211. }
  212. }