BalanceAuditList.php 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <?php
  2. namespace backendApi\modules\v1\models\lists\finance;
  3. use backendApi\modules\v1\models\Admin;
  4. use common\helpers\Audit;
  5. use common\helpers\Cache;
  6. use common\helpers\Tool;
  7. use common\helpers\user\Info;
  8. use common\helpers\user\Reconsume;
  9. use common\libs\dataList\column\DateTime;
  10. use common\libs\dataList\column\YesNo;
  11. use common\libs\dataList\DataListInterface;
  12. use common\models\BalanceAudit;
  13. use common\models\DealType;
  14. use common\models\forms\ReconsumeForm;
  15. use common\models\ReconsumeAudit;
  16. use common\models\ReconsumePool;
  17. use common\models\DecRole;
  18. use common\models\User;
  19. use common\models\UserInfo;
  20. use common\models\YearHighestEmpLv;
  21. use Yii;
  22. class BalanceAuditList extends \common\libs\dataList\DataList implements DataListInterface {
  23. /**
  24. * 列表名称
  25. * @return string
  26. */
  27. public function getListName() {
  28. return '会员余额调整列表';
  29. }
  30. /**
  31. * 列表筛选到的数据
  32. * @throws \yii\base\Exception
  33. */
  34. public function dataHandle() {
  35. $this->listData = BalanceAudit::lists($this->condition, $this->params, [
  36. 'select' => 'BA.*,U.USER_NAME,U.REAL_NAME,ADMC.ADMIN_NAME CREATE_ADMIN_NAME,ADMU.ADMIN_NAME AUDIT_ADMIN_NAME',
  37. 'orderBy' => 'BA.CREATED_AT DESC, BA.ID DESC',
  38. 'from' => BalanceAudit::tableName() . ' AS BA',
  39. 'join' => [
  40. ['LEFT JOIN', User::tableName() . ' AS U', 'BA.USER_ID=U.ID'],
  41. ['LEFT JOIN', Admin::tableName() . ' AS ADMC', 'BA.UPDATE_ADMIN_ID=ADMC.ID'],
  42. ['LEFT JOIN', Admin::tableName() . ' AS ADMU', 'BA.AUDIT_ADMIN_ID=ADMU.ID'],
  43. ],
  44. 'page' => $this->page,
  45. 'pageSize' => $this->pageSize,
  46. ]);
  47. $auditStatus = array_column(\Yii::$app->params['auditStatus'], null, 'value');
  48. $dealTypes = DealType::getAllTypesForShow();
  49. foreach ($this->listData['list'] as $key => $value) {
  50. // $userInfo = Info::baseInfoZh($value['USER_ID']);
  51. // $this->listData['list'][$key]['USER_NAME'] = $userInfo['USER_NAME'];
  52. // $this->listData['list'][$key]['REAL_NAME'] = $userInfo['REAL_NAME'];
  53. $this->listData['list'][$key]['LAST_DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['LAST_DEC_LV']]['LEVEL_NAME'] ?? '';
  54. $this->listData['list'][$key]['LAST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['LAST_EMP_LV']]['LEVEL_NAME'] ?? '';
  55. $this->listData['list'][$key]['LAST_DEC_ROLE_NAME'] = DecRole::getRoleNameId($value['LAST_DEC_ROLE_ID']);
  56. $this->listData['list'][$key]['TYPE_NAME'] = BalanceAudit::TYPE[$value['TYPE']]['label'];
  57. $this->listData['list'][$key]['DEAL_TYPE_NAME'] = $dealTypes[$value['DEAL_TYPE']]['TYPE_NAME'];
  58. $this->listData['list'][$key]['AUDIT_STATUS_NAME'] = $auditStatus[$value['AUDIT_STATUS']]['label'];
  59. }
  60. $this->listData['dealTypes'] = $dealTypes;
  61. }
  62. /**
  63. * 要展示和导出的所有字段
  64. * @return array
  65. */
  66. public function getColumn() {
  67. if (!$this->columns) {
  68. $this->columns = [
  69. 'ID' => null, // 这种传输方式主要是用于索引,因为过滤后的字段可能没有这种ID,但是一些功能的操作还需要用这种ID去关联,例如前台会员列表中的勾选批量状态管理,这里需要的就是USER_ID
  70. 'AUDIT_STATUS' => null,
  71. 'USER_NAME' => [
  72. 'header' => '会员编号',
  73. 'headerOther' => ['width' => '150'],
  74. ],
  75. 'REAL_NAME' => [
  76. 'header' => '会员姓名',
  77. 'headerOther' => [
  78. 'width' => '120',
  79. ],
  80. ],
  81. 'LAST_DEC_LV_NAME' => [
  82. 'header' => '会员级别',
  83. 'headerOther' => [
  84. 'width' => '110',
  85. ],
  86. ],
  87. 'LAST_DEC_ROLE_NAME' => [
  88. 'header' => '报单中心级别',
  89. 'headerOther' => [
  90. 'width' => '110',
  91. ],
  92. ],
  93. 'LAST_EMP_LV_NAME' => [
  94. 'header' => '聘级',
  95. 'headerOther' => [
  96. 'width' => '130',
  97. ],
  98. ],
  99. 'TYPE_NAME' => [
  100. 'header' => '账户类型',
  101. 'headerOther' => [
  102. 'width' => '140',
  103. ],
  104. 'valueOther' => function ($row) {
  105. return [
  106. 'tag' => ['type' => 'warning', 'size' => 'small', 'class' => 'no-border']
  107. ];
  108. },
  109. ],
  110. 'DEAL_TYPE_NAME' => [
  111. 'header' => '交易类型',
  112. 'headerOther' => [
  113. 'width' => '200',
  114. ],
  115. 'valueOther' => function ($row) {
  116. return [
  117. 'tag' => ['type' => 'warning', 'size' => 'small', 'class' => 'no-border']
  118. ];
  119. },
  120. ],
  121. 'AMOUNT' => [
  122. 'header' => '调整金额',
  123. 'headerOther' => [
  124. 'width' => '150',
  125. ],
  126. 'value' => function ($row) {
  127. return Tool::formatPrice($row['AMOUNT']);
  128. },
  129. 'valueOther' => function ($row) {
  130. return [
  131. 'tag' => ['type' => 'danger', 'size' => 'small', 'class' => 'no-border']
  132. ];
  133. },
  134. ],
  135. 'CREATE_REMARK' => [
  136. 'header' => '备注',
  137. 'headerOther' => [
  138. 'width' => '180',
  139. ],
  140. ],
  141. 'REMARK_IS_SHOW' => [
  142. 'header' => '前台是否显示备注',
  143. 'value' => function ($row) {
  144. return (new YesNo([
  145. 'value' => $row['REMARK_IS_SHOW'],
  146. ]))->result();
  147. },
  148. 'headerOther' => [
  149. 'width' => '160',
  150. ],
  151. ],
  152. 'AUDIT_STATUS_NAME' => [
  153. 'header' => '审核状态',
  154. 'headerOther' => [
  155. 'width' => '100',
  156. ],
  157. 'valueOther' => function ($row) {
  158. return [
  159. 'tag' => ['type' => Tool::statusType($row['AUDIT_STATUS']), 'size' => 'small']
  160. ];
  161. },
  162. ],
  163. 'CREATE_ADMIN_NAME' => [
  164. 'header' => '申请人',
  165. 'headerOther' => [
  166. 'width' => '150',
  167. ],
  168. ],
  169. 'CREATED_AT' => [
  170. 'header' => '申请时间',
  171. 'value' => function ($row) {
  172. return (new DateTime([
  173. 'value' => $row['CREATED_AT'],
  174. ]))->result();
  175. },
  176. 'headerOther' => ['width' => '190'],
  177. ],
  178. 'AUDIT_ADMIN_NAME' => [
  179. 'header' => '审核人',
  180. 'headerOther' => [
  181. 'width' => '150',
  182. ],
  183. ],
  184. 'AUDITED_AT' => [
  185. 'header' => '审核时间',
  186. 'value' => function ($row) {
  187. return (new DateTime([
  188. 'value' => $row['AUDITED_AT'],
  189. ]))->result();
  190. },
  191. 'headerOther' => ['width' => '190'],
  192. ],
  193. ];
  194. }
  195. return $this->columns;
  196. }
  197. /**
  198. * 前台用于筛选的类型集合
  199. * @return mixed
  200. */
  201. public function getFilterTypes() {
  202. if (!$this->filterTypes) {
  203. $this->filterTypes = [
  204. 'USER_NAME' => ['isUserTable' => false, 'name' => '会员编号'],
  205. 'REAL_NAME' => ['isUserTable' => false, 'name' => '会员姓名'],
  206. 'LAST_DEC_LV_NAME' => ['isUserTable' => false, 'name' => '会员级别', 'other' => 'decLevel'],
  207. 'LAST_DEC_ROLE_NAME' => ['isUserTable' => false, 'name' => '报单中心级别', 'other' => 'decRole'],
  208. 'LAST_EMP_LV_NAME' => ['isUserTable' => false, 'name' => '聘级', 'other' => 'empLevel'],
  209. 'TYPE_NAME' => ['isUserTable' => false, 'name' => '账户类型', 'other' => 'select', 'selectData' => Tool::formatFilter(BalanceAudit::TYPE, 'name', 'label')],
  210. 'DEAL_TYPE_NAME' => ['isUserTable' => false, 'name' => '交易类型', 'other' => 'select', 'selectData' => Tool::formatFilter(DealType::getAllTypesForShow(), 'ID', 'TYPE_NAME')],
  211. 'AMOUNT' => ['isUserTable' => false, 'name' => '调整金额'],
  212. 'CREATE_REMARK' => ['isUserTable' => false, 'name' => '备注'],
  213. 'REMARK_IS_SHOW' => ['isUserTable' => false, 'name' => '前台是否显示备注', 'other' => 'yesOrNo'],
  214. 'CREATE_ADMIN_NAME' => ['isUserTable' => false, 'name' => '申请人'],
  215. 'CREATED_AT' => ['isUserTable' => false, 'name' => '申请时间', 'other' => 'date'],
  216. 'AUDIT_ADMIN_NAME' => ['isUserTable' => false, 'name' => '审核人'],
  217. 'AUDITED_AT' => ['isUserTable' => false, 'name' => '审核时间', 'other' => 'date'],
  218. ];
  219. }
  220. return $this->filterTypes;
  221. }
  222. }