FlowBonusList.php 9.7 KB

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