BalanceAuditList.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <?php
  2. namespace backendApi\modules\v1\models\lists\finance;
  3. use backendApi\modules\v1\models\Admin;
  4. use common\helpers\Cache;
  5. use common\helpers\Tool;
  6. use common\libs\dataList\column\DateTime;
  7. use common\libs\dataList\column\YesNo;
  8. use common\libs\dataList\DataListInterface;
  9. use common\models\BalanceAudit;
  10. use common\models\DealType;
  11. use common\models\User;
  12. use Yii;
  13. class BalanceAuditList 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 = BalanceAudit::lists($this->condition, $this->params, [
  27. 'select' => 'BA.*,U.USER_NAME,U.REAL_NAME,ADMC.ADMIN_NAME CREATE_ADMIN_NAME,ADMU.ADMIN_NAME AUDIT_ADMIN_NAME',
  28. 'orderBy' => 'BA.CREATED_AT DESC, BA.ID DESC',
  29. 'from' => BalanceAudit::tableName() . ' AS BA',
  30. 'join' => [
  31. ['LEFT JOIN', User::tableName() . ' AS U', 'BA.USER_ID=U.ID'],
  32. ['LEFT JOIN', Admin::tableName() . ' AS ADMC', 'BA.UPDATE_ADMIN_ID=ADMC.ID'],
  33. ['LEFT JOIN', Admin::tableName() . ' AS ADMU', 'BA.AUDIT_ADMIN_ID=ADMU.ID'],
  34. ],
  35. 'page' => $this->page,
  36. 'pageSize' => $this->pageSize,
  37. ]);
  38. $auditStatus = array_column(Tool::paramConvert(\Yii::$app->params['auditStatus']), null, 'value');
  39. $dealTypes = DealType::getAllTypesForShow();
  40. foreach ($this->listData['list'] as $key => $value) {
  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_DEC_ROLE_NAME'] = Cache::getDecRoleConfig()[$value['LAST_DEC_ROLE_ID']]['ROLE_NAME'] ?? '';
  44. $this->listData['list'][$key]['TYPE_NAME'] = BalanceAudit::getBalanceAuditType()[$value['TYPE']]['label'] ?? 'Others';
  45. $this->listData['list'][$key]['DEAL_TYPE_NAME'] = $dealTypes[$value['DEAL_TYPE']]['TYPE_NAME'] ?? 'Others';
  46. $this->listData['list'][$key]['AUDIT_STATUS_NAME'] = $auditStatus[$value['AUDIT_STATUS']]['label'] ?? 'Others';
  47. }
  48. $this->listData['dealTypes'] = $dealTypes;
  49. }
  50. /**
  51. * 要展示和导出的所有字段
  52. * @return array
  53. */
  54. public function getColumn() {
  55. if (!$this->columns) {
  56. $this->columns = [
  57. 'ID' => null, // 这种传输方式主要是用于索引,因为过滤后的字段可能没有这种ID,但是一些功能的操作还需要用这种ID去关联,例如前台会员列表中的勾选批量状态管理,这里需要的就是USER_ID
  58. 'AUDIT_STATUS' => null,
  59. 'USER_NAME' => [
  60. 'header' => Yii::t('ctx', 'modelListFinanceBalanceAuditListUserName'), // 会员编号
  61. 'headerOther' => ['width' => '150'],
  62. ],
  63. 'REAL_NAME' => [
  64. 'header' => Yii::t('ctx', 'modelListFinanceBalanceAuditListRealName'), //会员姓名
  65. 'headerOther' => [
  66. 'width' => '120',
  67. ],
  68. ],
  69. 'LAST_DEC_LV_NAME' => [
  70. 'header' => Yii::t('ctx', 'modelListFinanceBalanceAuditListMemberLevel'), // 会员级别
  71. 'headerOther' => [
  72. 'width' => '110',
  73. ],
  74. ],
  75. 'LAST_DEC_ROLE_NAME' => [
  76. 'header' => Yii::t('ctx', 'modelListFinanceBalanceAuditListStockistLevel'), // 报单中心级别
  77. 'headerOther' => [
  78. 'width' => '170',
  79. ],
  80. ],
  81. 'LAST_EMP_LV_NAME' => [
  82. 'header' => Yii::t('ctx', 'modelListFinanceBalanceAuditListEmpLevel'),//聘级
  83. 'headerOther' => [
  84. 'width' => '130',
  85. ],
  86. ],
  87. 'TYPE_NAME' => [
  88. 'header' => Yii::t('ctx', 'modelListFinanceBalanceAuditListTypeName'), // 账户类型
  89. 'headerOther' => [
  90. 'width' => '140',
  91. ],
  92. 'valueOther' => function ($row) {
  93. return [
  94. 'tag' => ['type' => 'warning', 'size' => 'small', 'class' => 'no-border']
  95. ];
  96. },
  97. ],
  98. 'DEAL_TYPE_NAME' => [
  99. 'header' => Yii::t('ctx', 'modelListFinanceBalanceAuditListDealType'), // 交易类型
  100. 'headerOther' => [
  101. 'width' => '200',
  102. ],
  103. 'valueOther' => function ($row) {
  104. return [
  105. 'tag' => ['type' => 'warning', 'size' => 'small', 'class' => 'no-border']
  106. ];
  107. },
  108. ],
  109. 'AMOUNT' => [
  110. 'header' => Yii::t('ctx', 'modelListFinanceBalanceAuditListAmount'), // 调整金额
  111. 'headerOther' => [
  112. 'width' => '150',
  113. ],
  114. 'value' => function ($row) {
  115. return Tool::formatPrice($row['AMOUNT']);
  116. },
  117. 'valueOther' => function ($row) {
  118. return [
  119. 'tag' => ['type' => 'danger', 'size' => 'small', 'class' => 'no-border']
  120. ];
  121. },
  122. ],
  123. 'CREATE_REMARK' => [
  124. 'header' => Yii::t('ctx', 'modelListFinanceBalanceAuditListRemark'), // 备注
  125. 'headerOther' => [
  126. 'width' => '180',
  127. ],
  128. ],
  129. 'REMARK_IS_SHOW' => [
  130. 'header' => Yii::t('ctx', 'modelListFinanceBalanceAuditListRemarkIsShow'), // 前台是否显示备注
  131. 'value' => function ($row) {
  132. return (new YesNo([
  133. 'value' => $row['REMARK_IS_SHOW'],
  134. ]))->result();
  135. },
  136. 'headerOther' => [
  137. 'width' => '160',
  138. ],
  139. ],
  140. 'AUDIT_STATUS_NAME' => [
  141. 'header' => Yii::t('ctx', 'modelListFinanceBalanceAuditListAuditStatusName'), // 审核状态
  142. 'headerOther' => [
  143. 'width' => '100',
  144. ],
  145. 'valueOther' => function ($row) {
  146. return [
  147. 'tag' => ['type' => Tool::statusType($row['AUDIT_STATUS']), 'size' => 'small']
  148. ];
  149. },
  150. ],
  151. 'CREATE_ADMIN_NAME' => [
  152. 'header' => Yii::t('ctx', 'modelListFinanceBalanceAuditListApplicant'), // 申请人
  153. 'headerOther' => [
  154. 'width' => '150',
  155. ],
  156. ],
  157. 'CREATED_AT' => [
  158. 'header' => Yii::t('ctx', 'modelListFinanceBalanceAuditListCreatedAt'), // 申请时间
  159. 'value' => function ($row) {
  160. return (new DateTime([
  161. 'value' => $row['CREATED_AT'],
  162. ]))->result();
  163. },
  164. 'headerOther' => ['width' => '190'],
  165. ],
  166. 'AUDIT_ADMIN_NAME' => [
  167. 'header' => Yii::t('ctx', 'modelListFinanceBalanceAuditListAuditName'), // 审核人
  168. 'headerOther' => [
  169. 'width' => '150',
  170. ],
  171. ],
  172. 'AUDITED_AT' => [
  173. 'header' => Yii::t('ctx', 'modelListFinanceBalanceAuditListAuditTime'), // 审核时间
  174. 'value' => function ($row) {
  175. return (new DateTime([
  176. 'value' => $row['AUDITED_AT'],
  177. ]))->result();
  178. },
  179. 'headerOther' => ['width' => '190'],
  180. ],
  181. ];
  182. }
  183. return $this->columns;
  184. }
  185. /**
  186. * 前台用于筛选的类型集合
  187. * @return mixed
  188. */
  189. public function getFilterTypes() {
  190. if (!$this->filterTypes) {
  191. $this->filterTypes = [
  192. 'USER_NAME' => ['isUserTable' => false, 'name' => Yii::t('ctx', 'modelListFinanceBalanceAuditListUserName')], //会员编号
  193. 'REAL_NAME' => ['isUserTable' => false, 'name' => Yii::t('ctx', 'memberName')], //会员姓名
  194. 'LAST_DEC_LV_NAME' => [
  195. 'isUserTable' => false,
  196. 'name' => Yii::t('ctx', 'modelListFinanceBalanceAuditListMemberLevel'),
  197. 'other' => 'decLevel'
  198. ], // 会员级别
  199. 'LAST_DEC_ROLE_NAME' => [
  200. 'isUserTable' => false,
  201. 'name' => Yii::t('ctx', 'modelListFinanceBalanceAuditListStockistLevel'),
  202. 'other' => 'decRole'
  203. ], // 报单中心级别
  204. 'LAST_EMP_LV_NAME' => [
  205. 'isUserTable' => false,
  206. 'name' => Yii::t('ctx', 'modelListFinanceBalanceAuditListEmpLevel'),
  207. 'other' => 'empLevel'
  208. ], // 聘级
  209. 'TYPE_NAME' => [
  210. 'isUserTable' => false,
  211. 'name' => Yii::t('ctx', 'modelListFinanceBalanceAuditListTypeName'),
  212. 'other' => 'select',
  213. 'selectData' => Tool::formatFilter(BalanceAudit::getBalanceAuditType(), 'name', 'label')
  214. ], // 账户类型
  215. 'DEAL_TYPE_NAME' => [
  216. 'isUserTable' => false,
  217. 'name' => Yii::t('ctx', 'modelListFinanceBalanceAuditListDealType'),
  218. 'other' => 'select',
  219. 'selectData' => Tool::formatFilter(DealType::getAllTypesForShow(), 'ID', 'TYPE_NAME')
  220. ], // 交易类型
  221. 'AMOUNT' => [
  222. 'isUserTable' => false,
  223. 'name' => Yii::t('ctx', 'modelListFinanceBalanceAuditListAmount')
  224. ], // 调整金额
  225. 'CREATE_REMARK' => [
  226. 'isUserTable' => false,
  227. 'name' => Yii::t('ctx', 'modelListFinanceBalanceAuditListRemark')
  228. ], // 备注
  229. 'REMARK_IS_SHOW' => [
  230. 'isUserTable' => false,
  231. 'name' => Yii::t('ctx', 'modelListFinanceBalanceAuditListRemarkIsShow'),
  232. 'other' => 'yesOrNo'
  233. ], // 前台是否显示备注
  234. 'CREATE_ADMIN_NAME' => [
  235. 'isUserTable' => false,
  236. 'name' => Yii::t('ctx', 'modelListFinanceBalanceAuditListApplicant')
  237. ], // 申请人
  238. 'CREATED_AT' => [
  239. 'isUserTable' => false,
  240. 'name' => Yii::t('ctx', 'modelListFinanceBalanceAuditListCreatedAt'),
  241. 'other' => 'date'
  242. ], // 申请时间
  243. 'AUDIT_ADMIN_NAME' => [
  244. 'isUserTable' => false,
  245. 'name' => Yii::t('ctx', 'modelListFinanceBalanceAuditListAuditName')
  246. ], // 审核人
  247. 'AUDITED_AT' => [
  248. 'isUserTable' => false,
  249. 'name' => Yii::t('ctx', 'modelListFinanceBalanceAuditListAuditTime'),
  250. 'other' => 'date'
  251. ], // 审核时间
  252. ];
  253. }
  254. return $this->filterTypes;
  255. }
  256. }