BalanceAuditList.php 12 KB

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