WithdrawList.php 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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\libs\dataList\column\DateTime;
  8. use common\libs\dataList\DataListInterface;
  9. use common\models\Countries;
  10. use common\models\OpenBank;
  11. use common\models\User;
  12. use common\models\Withdraw;
  13. class WithdrawList extends \common\libs\dataList\DataList implements DataListInterface {
  14. /**
  15. * 列表名称
  16. * @return string
  17. */
  18. public function getListName() {
  19. return '提现申请列表';
  20. }
  21. /**
  22. * 列表筛选到的数据
  23. */
  24. public function dataHandle() {
  25. $this->listData = Withdraw::lists($this->condition, $this->params, [
  26. 'select' => 'W.*,U.USER_NAME,U.REAL_NAME AS USER_REAL_NAME,U.ID_CARD,U.MOBILE,U.OPEN_BANK,U.BANK_PROVINCE,U.BANK_CITY,U.BANK_COUNTY,U.BANK_ADDRESS,U.BANK_NO,ADM.ADMIN_NAME UPDATE_ADMIN_NAME,ADMA.ADMIN_NAME AUDIT_ADMIN_NAME,CN.NAME COUNTRY_NAME',
  27. 'orderBy' => 'W.CREATED_AT DESC',
  28. 'from' => Withdraw::tableName() . ' AS W',
  29. 'join' => [
  30. ['LEFT JOIN', User::tableName() . ' AS U', 'W.USER_ID=U.ID'],
  31. ['LEFT JOIN', Admin::tableName() . ' AS ADM', 'ADM.ID=W.UPDATE_ADMIN'],
  32. ['LEFT JOIN', Admin::tableName() . ' AS ADMA', 'ADMA.ID=W.AUDIT_ADMIN'],
  33. ['LEFT JOIN', Countries::tableName() . ' AS CN', 'U.COUNTRY_ID=CN.ID'],
  34. ],
  35. 'page' => $this->page,
  36. 'pageSize' => $this->pageSize,
  37. ]);
  38. }
  39. /**
  40. * 要展示和导出的所有字段
  41. * @return array
  42. */
  43. public function getColumn() {
  44. $regionConfig = Cache::getRegionConfig();
  45. if (!$this->columns) {
  46. $this->columns = [
  47. 'ID' => null,
  48. 'SN' => [
  49. 'header' => \Yii::t('ctx', 'modelListFinanceWithdrawSn'), // 提现流水号
  50. 'headerOther' => [
  51. 'width' => '250',
  52. ],
  53. 'valueOther' => function ($row) {
  54. return [
  55. 'tag' => ['type' => 'warning', 'size' => 'small', 'class' => 'no-border']
  56. ];
  57. },
  58. ],
  59. 'WITHDRAW_PERIOD_NUM' => [
  60. 'header' => \Yii::t('ctx', 'modelListFinanceWithdrawPeriod'), // 提现期数
  61. 'headerOther' => ['width' => '150'],
  62. ],
  63. 'CREATED_AT' => [
  64. 'header' => \Yii::t('ctx', 'modelListFinanceWithdrawAt'), // 提现时间
  65. 'value' => function ($row) {
  66. return (new DateTime([
  67. 'value' => $row['CREATED_AT'],
  68. ]))->result();
  69. },
  70. 'headerOther' => ['width' => '190'],
  71. ],
  72. 'PAID_AT' => [
  73. 'header' => \Yii::t('ctx', 'modelListFinancePaidAt'), // 提现时间
  74. 'value' => function ($row) {
  75. return (new DateTime([
  76. 'value' => $row['PAID_AT'],
  77. ]))->result();
  78. },
  79. 'headerOther' => ['width' => '190'],
  80. ],
  81. 'AUDIT_STATUS' => null,
  82. 'AUDIT_STATUS_NAME' => [
  83. 'header' => \Yii::t('ctx', 'modelListFinanceWithdrawState'), // 提现状态
  84. 'headerOther' => ['width' => '150'],
  85. 'value' => function ($row) {
  86. return Withdraw::getStatusName()[$row['AUDIT_STATUS']];
  87. // return Withdraw::STATUS_NAME[$row['AUDIT_STATUS']];
  88. },
  89. ],
  90. 'USER_NAME' => [
  91. 'header' => \Yii::t('ctx', 'modelListFinanceBalanceAuditListUserName'), // 会员编号
  92. 'headerOther' => ['width' => '150'],
  93. ],
  94. 'USER_REAL_NAME' => [
  95. 'header' => \Yii::t('ctx', 'modelListFinanceBalanceAuditListRealName'), // 会员姓名
  96. 'headerOther' => ['width' => '150'],
  97. ],
  98. 'COUNTRY_NAME' => [
  99. 'header' => \Yii::t('ctx', 'modelListFinanceBalanceAuditListCountryName'), // 国家
  100. 'headerOther' => ['width' => '150'],
  101. ],
  102. 'AMOUNT' => [
  103. 'header' => \Yii::t('ctx', 'modelListFinanceWithdrawAmount'), // 提现金额
  104. 'value' => function ($row) {
  105. return Tool::formatPrice($row['AMOUNT']);
  106. },
  107. 'headerOther' => [
  108. 'width' => '150',
  109. ],
  110. 'valueOther' => function ($row) {
  111. return [
  112. 'tag' => ['type' => 'danger', 'size' => 'small', 'class' => 'no-border']
  113. ];
  114. },
  115. ],
  116. 'FEES' => [
  117. 'header' => \Yii::t('ctx', 'modelListFinanceWithdrawFees'), // 手续费
  118. 'headerOther' => ['width' => '150'],
  119. ],
  120. 'REAL_AMOUNT' => [
  121. 'header' => \Yii::t('ctx', 'modelListFinanceWithdrawRealAmount'), // 实际到账金额
  122. 'headerOther' => ['width' => '150'],
  123. ],
  124. 'OPEN_BANK' => [
  125. 'header' => \Yii::t('ctx', 'modelListFinanceWithdrawBank'), // 提现银行
  126. 'headerOther' => ['width' => '150'],
  127. 'value' => function ($row) {
  128. return $row['OPEN_BANK'] ? OpenBank::getCnName($row['OPEN_BANK']) : '';
  129. },
  130. ],
  131. 'BANK_NO' => [
  132. 'header' => \Yii::t('ctx', 'modelListFinanceWithdrawBankNo'),//银行地区
  133. 'headerOther' => ['width' => '190'],
  134. 'value' => function ($row) {
  135. return $row['BANK_NO'].' /';
  136. },
  137. ],
  138. 'MOBILE' => [
  139. 'header' => \Yii::t('ctx', 'modelListFinanceWithdrawMobile'), // 手机号
  140. 'headerOther' => ['width' => '150'],
  141. ],
  142. 'UPDATE_ADMIN_NAME' => [
  143. 'header' => \Yii::t('ctx', 'modelListFinanceWithdrawUpdateAdminName'), // 操作管理员
  144. 'headerOther' => ['width' => '200'],
  145. ],
  146. 'REMARK' => [
  147. 'header' => \Yii::t('ctx', 'modelListFinanceBalanceAuditListRemark'), // 备注
  148. 'headerOther' => [
  149. 'width' => '200',
  150. ],
  151. ],
  152. 'BACK_REMARK' => [
  153. 'header' => \Yii::t('ctx', 'modelListFinanceWithdrawBackRemark'), // 退回备注
  154. 'headerOther' => [
  155. 'width' => '200',
  156. ],
  157. ],
  158. ];
  159. }
  160. return $this->columns;
  161. }
  162. /**
  163. * 前台用于筛选的类型集合
  164. * @return mixed
  165. */
  166. public function getFilterTypes() {
  167. if (!$this->filterTypes) {
  168. $this->filterTypes = [
  169. 'SN' => ['isUserTable' => false, 'name' => \Yii::t('ctx', 'modelListFinanceWithdrawSn')], // 提现流水号
  170. 'USER_NAME' => ['isUserTable' => false, 'name' => \Yii::t('ctx', 'modelListFinanceBalanceAuditListUserName')], // 会员编号
  171. 'WITHDRAW_PERIOD_NUM' => ['isUserTable' => false, 'name' => \Yii::t('ctx', 'modelListFinanceWithdrawPeriod')], // 提现期数
  172. 'CREATED_AT' => ['isUserTable' => false, 'name' => \Yii::t('ctx', 'modelListFinanceWithdrawAt'), 'other' => 'date'], // 申请时间
  173. 'PAID_AT' => ['isUserTable' => false, 'name' => \Yii::t('ctx', 'modelListFinancePaidAt'), 'other' => 'date'], // 付款时间
  174. 'REAL_AMOUNT' => ['isUserTable' => false, 'name' => \Yii::t('ctx', 'modelListFinanceWithdrawRealAmount')], // 实际到账金额
  175. 'USER_REAL_NAME' => ['isUserTable' => false, 'name' => \Yii::t('ctx', 'modelListFinanceBalanceAuditListRealName')],
  176. 'COUNTRY_NAME' => [
  177. 'name'=> \Yii::t('ctx', 'modelListFinanceBalanceAuditListCountryName'),
  178. 'other'=> 'select',
  179. 'selectData'=> self::getCountry()
  180. ],
  181. 'OPEN_BANK' => ['isUserTable' => false, 'name' => \Yii::t('ctx', 'modelListFinanceWithdrawBank'),
  182. 'other'=> 'select',
  183. 'selectData'=> self::getAllOpenBank()],
  184. 'MOBILE' => ['isUserTable' => false, 'name' => \Yii::t('ctx', 'modelListFinanceWithdrawMobile')],
  185. ];
  186. }
  187. return $this->filterTypes;
  188. }
  189. public function getCountry()
  190. {
  191. $countries = Countries::getFromCache();
  192. $data = [];
  193. foreach ($countries as $country) {
  194. $data[] = [
  195. 'id' => $country['ID'],
  196. 'name' => $country['NAME'],
  197. ];
  198. }
  199. return $data;
  200. }
  201. public function getAllOpenBank()
  202. {
  203. $banks = OpenBank::find()->where('1=1')->indexBy('BANK_CODE')->orderBy('CREATED_AT ASC')->asArray()->all();
  204. $data = [];
  205. foreach ($banks as $bank) {
  206. $data[] = [
  207. 'id' => $bank['ID'],
  208. 'name' => $bank['BANK_NAME'],
  209. ];
  210. }
  211. return $data;
  212. }
  213. }