BalanceAuditList.php 12 KB

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