FlowBonusList.php 9.6 KB

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