HistoryBonusList.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  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\HistoryBonus;
  16. use common\models\PerfAudit;
  17. use common\models\ReconsumeAudit;
  18. use common\models\ReconsumePool;
  19. use common\models\DecRole;
  20. use common\models\Region;
  21. use common\models\Transfer;
  22. use common\models\UserInfo;
  23. use common\models\UserSystem;
  24. use common\models\YearHighestEmpLv;
  25. use Yii;
  26. class HistoryBonusList extends \common\libs\dataList\DataList implements DataListInterface {
  27. /**
  28. * 列表名称
  29. * @return string
  30. */
  31. public function getListName() {
  32. return 'Historical bonus balance';//历史奖金余额
  33. }
  34. /**
  35. * 列表筛选到的数据
  36. */
  37. public function dataHandle() {
  38. $this->listData = HistoryBonus::lists($this->condition, $this->params, [
  39. 'orderBy' => 'BACKUP_AT DESC, ID DESC',
  40. 'from' => HistoryBonus::tableName(),
  41. 'page' => $this->page,
  42. 'pageSize' => $this->pageSize,
  43. ]);
  44. $auditStatus = array_column(\Yii::$app->params['userStatus'], null, 'value');
  45. foreach ($this->listData['list'] as $key => $value) {
  46. $this->listData['list'][$key]['USER_STATUS_NAME'] = $auditStatus[$value['USER_STATUS']]['label'];
  47. $this->listData['list'][$key]['DEC_LV_NAME'] = Cache::getDecLevelConfig()[$value['DEC_LV']]['LEVEL_NAME'] ?? '';
  48. $this->listData['list'][$key]['EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['EMP_LV']]['LEVEL_NAME'] ?? '';
  49. $this->listData['list'][$key]['DEC_ROLE_NAME'] = DecRole::getRoleNameId($value['DEC_ROLE_ID']);
  50. $this->listData['list'][$key]['HIGHEST_EMP_LV_NAME'] = Cache::getEmpLevelConfig()[$value['HIGHEST_EMP_LV']]['LEVEL_NAME'] ?? '';
  51. $this->listData['list'][$key]['DEC_DEC_ROLE_NAME'] = DecRole::getRoleNameId($value['DEC_DEC_ROLE_ID']);
  52. $this->listData['list'][$key]['PROVINCE_NAME'] = $value['PROVINCE'] ? Region::getCnName($value['PROVINCE']) : '';
  53. $this->listData['list'][$key]['CITY_NAME'] = $value['CITY'] ? Region::getCnName($value['CITY']) : '';
  54. $this->listData['list'][$key]['COUNTY_NAME'] = $value['COUNTY'] ? Region::getCnName($value['COUNTY']) : '';
  55. $this->listData['list'][$key]['SUB_COM_NAME'] = '';
  56. }
  57. }
  58. /**
  59. * 要展示和导出的所有字段
  60. * @return array
  61. */
  62. public function getColumn() {
  63. if (!$this->columns) {
  64. $this->columns = [
  65. 'ID' => null, // 这种传输方式主要是用于索引,因为过滤后的字段可能没有这种ID,但是一些功能的操作还需要用这种ID去关联,例如前台会员列表中的勾选批量状态管理,这里需要的就是USER_ID
  66. 'USER_NAME' => [
  67. 'header' => 'Member code',//会员编号
  68. 'headerOther' => ['width' => '150'],
  69. ],
  70. 'REAL_NAME' => [
  71. 'header' => 'Member name',//会员姓名
  72. 'headerOther' => [
  73. 'width' => '120',
  74. ],
  75. ],
  76. 'DEC_LV_NAME' => [
  77. 'header' => 'Member level',//会员级别
  78. 'headerOther' => [
  79. 'width' => '150',
  80. ],
  81. ],
  82. 'EMP_LV_NAME' => [
  83. 'header' => 'Rank',//聘级
  84. 'headerOther' => [
  85. 'width' => '150',
  86. ],
  87. ],
  88. 'IS_DEC' => [
  89. 'header' => 'Whether distributor',//是否报单中心
  90. 'value' => function ($row) {
  91. return (new YesNo([
  92. 'value' => $row['IS_DEC'],
  93. ]))->result();
  94. },
  95. 'headerOther' => function ($row) {
  96. return [
  97. 'width' => '120',
  98. ];
  99. },
  100. 'valueOther' => function ($row) {
  101. return [
  102. 'tag' => ['type' => (isset($row['IS_DEC']) && $row['IS_DEC']) ? 'success' : 'info', 'size' => 'small']
  103. ];
  104. },
  105. ],
  106. // 'DEC_ROLE_NAME' => [
  107. // 'header' => '报单中心级别',
  108. // 'headerOther' => [
  109. // 'width' => '150',
  110. // ],
  111. // ],
  112. // 'SYSTEM_NAME' => [
  113. // 'header' => '体系名称',
  114. // 'headerOther' => [
  115. // 'width' => '200',
  116. // ],
  117. // ],
  118. 'BONUS' => [
  119. 'header' => 'Member bonus',//会员账户余额
  120. 'value' => function ($row) {
  121. return Tool::formatPrice($row['BONUS']);
  122. },
  123. 'headerOther' => function ($row) {
  124. return [
  125. 'width' => '150',
  126. ];
  127. },
  128. 'valueOther' => function ($row) {
  129. return [
  130. 'tag' => ['type' => 'danger', 'size' => 'small', 'class' => 'no-border']
  131. ];
  132. },
  133. ],
  134. // 'CF' => [
  135. // 'header' => '车房养老余额',
  136. // 'value' => function ($row) {
  137. // return Tool::formatPrice($row['CF']);
  138. // },
  139. // 'headerOther' => function ($row) {
  140. // return [
  141. // 'width' => '150',
  142. // ];
  143. // },
  144. // 'valueOther' => function ($row) {
  145. // return [
  146. // 'tag' => ['type' => 'danger', 'size' => 'small', 'class' => 'no-border']
  147. // ];
  148. // },
  149. // ],
  150. // 'LX' => [
  151. // 'header' => '领袖分红余额',
  152. // 'value' => function ($row) {
  153. // return Tool::formatPrice($row['LX']);
  154. // },
  155. // 'headerOther' => function ($row) {
  156. // return [
  157. // 'width' => '150',
  158. // ];
  159. // },
  160. // 'valueOther' => function ($row) {
  161. // return [
  162. // 'tag' => ['type' => 'danger', 'size' => 'small', 'class' => 'no-border']
  163. // ];
  164. // },
  165. // ],
  166. 'WITHDRAW' => [
  167. 'header' => 'Withdrawal amount',//提现金额
  168. 'value' => function ($row) {
  169. return Tool::formatPrice($row['WITHDRAW']);
  170. },
  171. 'headerOther' => function ($row) {
  172. return [
  173. 'width' => '150',
  174. ];
  175. },
  176. 'valueOther' => function ($row) {
  177. return [
  178. 'tag' => ['type' => 'warning', 'size' => 'small', 'class' => 'no-border']
  179. ];
  180. },
  181. ],
  182. // 'WITHDRAW_TAX' => [
  183. // 'header' => '个税',
  184. // 'value' => function ($row) {
  185. // return Tool::formatPrice($row['WITHDRAW_TAX']);
  186. // },
  187. // 'headerOther' => function ($row) {
  188. // return [
  189. // 'width' => '150',
  190. // ];
  191. // },
  192. // 'valueOther' => function ($row) {
  193. // return [
  194. // 'tag' => ['type' => 'warning', 'size' => 'small', 'class' => 'no-border']
  195. // ];
  196. // },
  197. // ],
  198. // 'WITHDRAW_DEDUCT' => [
  199. // 'header' => '扣款',
  200. // 'value' => function ($row) {
  201. // return Tool::formatPrice($row['WITHDRAW_DEDUCT']);
  202. // },
  203. // 'headerOther' => function ($row) {
  204. // return [
  205. // 'width' => '150',
  206. // ];
  207. // },
  208. // 'valueOther' => function ($row) {
  209. // return [
  210. // 'tag' => ['type' => 'warning', 'size' => 'small', 'class' => 'no-border']
  211. // ];
  212. // },
  213. // ],
  214. 'WITHDRAW_REAL' => [
  215. 'header' => 'Real amount',//实付金额
  216. 'value' => function ($row) {
  217. return Tool::formatPrice($row['WITHDRAW_REAL']);
  218. },
  219. 'headerOther' => function ($row) {
  220. return [
  221. 'width' => '150',
  222. ];
  223. },
  224. 'valueOther' => function ($row) {
  225. return [
  226. 'tag' => ['type' => 'warning', 'size' => 'small', 'class' => 'no-border']
  227. ];
  228. },
  229. ],
  230. 'WITHDRAW_FAIL' => [
  231. 'header' => 'Actual payment of failed amount',//实付失败金额
  232. 'value' => function ($row) {
  233. return Tool::formatPrice($row['WITHDRAW_FAIL']);
  234. },
  235. 'headerOther' => function ($row) {
  236. return [
  237. 'width' => '150',
  238. ];
  239. },
  240. 'valueOther' => function ($row) {
  241. return [
  242. 'tag' => ['type' => 'warning', 'size' => 'small', 'class' => 'no-border']
  243. ];
  244. },
  245. ],
  246. 'USER_STATUS_NAME' => [
  247. 'header' => 'Member status',//会员状态
  248. 'headerOther' => ['width' => '150'],
  249. ],
  250. 'USER_STATUS_AT' => [
  251. 'header' => 'Member status change time',//会员状态变更时间
  252. 'value' => function ($row) {
  253. return (new DateTime([
  254. 'value' => $row['USER_STATUS_AT'],
  255. ]))->result();
  256. },
  257. 'headerOther' => ['width' => '190'],
  258. ],
  259. // 'HIGHEST_EMP_LV_NAME' => [
  260. // 'header' => '历史最高聘级',
  261. // 'headerOther' => ['width' => '150'],
  262. // ],
  263. 'PERIOD_AT' => [
  264. 'header' => 'Join periods',//加入期数
  265. 'headerOther' => ['width' => '150'],
  266. ],
  267. // 'DEC_DEC_ROLE_NAME' => [
  268. // 'header' => '所属报单中心级别',
  269. // 'headerOther' => ['width' => '150'],
  270. // ],
  271. 'DEC_USER_NAME' => [
  272. 'header' => 'Code of distributor',//所属报单中心编号
  273. 'headerOther' => ['width' => '150'],
  274. ],
  275. 'DEC_REAL_NAME' => [
  276. 'header' => 'Name of distributor',//所属报单中心姓名
  277. 'headerOther' => ['width' => '150'],
  278. ],
  279. 'MOBILE' => [
  280. 'header' => 'Phone Number',//手机号码
  281. 'value' => function($row) {
  282. return "\t".$row['MOBILE'];
  283. },
  284. 'headerOther' => ['width' => '150'],
  285. ],
  286. 'TEL' => [
  287. 'header' => 'Alternate Phone Number',//备用手机号码
  288. 'value' => function($row) {
  289. return "\t".$row['TEL'];
  290. },
  291. 'headerOther' => ['width' => '150'],
  292. ],
  293. 'AREA' => [
  294. 'header' => 'Commonly used address',//常用地址
  295. 'value' => function ($row) {
  296. return $row['PROVINCE_NAME'] . $row['CITY_NAME'] . $row['COUNTY_NAME'];
  297. },
  298. 'showValue' => function ($row) {
  299. return '<div class="addr" title=' . $row['PROVINCE_NAME'] . $row['CITY_NAME'] . $row['COUNTY_NAME'] . '>' . $row['PROVINCE_NAME'] . $row['CITY_NAME'] . $row['COUNTY_NAME'] . '</div>';
  300. },
  301. 'headerOther' => [
  302. 'width' => '200'
  303. ],
  304. ],
  305. // 'SUB_COM_NAME' => [
  306. // 'header' => '所属分公司',
  307. // 'headerOther' => ['width' => '150'],
  308. // ],
  309. // 'IS_DIRECT_SELLER' => [
  310. // 'header' => '是否直销员',
  311. // 'value' => function ($row) {
  312. // return (new YesNo([
  313. // 'value' => $row['IS_DIRECT_SELLER'],
  314. // ]))->result();
  315. // },
  316. // 'headerOther' => function ($row) {
  317. // return [
  318. // 'width' => '120',
  319. // ];
  320. // },
  321. // 'valueOther' => function ($row) {
  322. // return [
  323. // 'tag' => ['type' => (isset($row['IS_DIRECT_SELLER']) && $row['IS_DIRECT_SELLER']) ? 'success' : 'info', 'size' => 'small']
  324. // ];
  325. // },
  326. // ],
  327. 'BACKUP_AT' => [
  328. 'header' => 'Backup time',//备份时间
  329. 'value' => function ($row) {
  330. return (new DateTime([
  331. 'value' => $row['BACKUP_AT'],
  332. ]))->result();
  333. },
  334. 'headerOther' => ['width' => '190'],
  335. ],
  336. ];
  337. }
  338. return $this->columns;
  339. }
  340. /**
  341. * 前台用于筛选的类型集合
  342. * @return mixed
  343. */
  344. public function getFilterTypes() {
  345. if (!$this->filterTypes) {
  346. $this->filterTypes = [
  347. 'USER_NAME' => ['isUserTable' => false, 'name' => 'Member code'],//会员编号
  348. 'REAL_NAME' => ['isUserTable' => false, 'name' => 'Member name'],//会员姓名
  349. 'DEC_LV_NAME' => ['isUserTable' => false, 'name' => 'Member level', 'other' => 'decLevel'],//会员级别
  350. 'EMP_LV_NAME' => ['isUserTable' => false, 'name' => 'Rank', 'other' => 'empLevel'],//聘级
  351. 'IS_DEC' => ['isUserTable' => false, 'name' => 'Whether distributor', 'other' => 'yesOrNo'],//是否报单中心
  352. // 'DEC_ROLE_NAME' => ['isUserTable' => false, 'name' => '报单中心级别', 'other' => 'decRole'],
  353. // 'SYSTEM_NAME' => ['isUserTable' => false, 'name' => '体系名称'],
  354. 'BONUS' => ['isUserTable' => false, 'name' => 'Member Bonus'],// 会员账户余额
  355. // 'CF' => ['isUserTable' => false, 'name' => '车房养老余额'],
  356. // 'LX' => ['isUserTable' => false, 'name' => '领袖分红余额'],
  357. 'WITHDRAW' => ['isUserTable' => false, 'name' => 'Withdrawal amount'],//提现金额
  358. // 'WITHDRAW_TAX' => ['isUserTable' => false, 'name' => '个税'],
  359. // 'WITHDRAW_DEDUCT' => ['isUserTable' => false, 'name' => '扣款'],
  360. 'WITHDRAW_REAL' => ['isUserTable' => false, 'name' => 'Real amount'],//实付金额
  361. 'WITHDRAW_FAIL' => ['isUserTable' => false, 'name' => 'Actual payment of failed amount'],//实付失败金额
  362. 'USER_STATUS_NAME' => ['isUserTable' => false, 'name' => 'Member status', 'other' => 'status'],//会员状态
  363. 'USER_STATUS_AT' => ['isUserTable' => false, 'name' => 'Member status change time', 'other' => 'date'],//会员状态变更时间
  364. // 'HIGHEST_EMP_LV_NAME' => ['isUserTable' => false, 'name' => '历史最高聘级', 'other' => 'empLevel'],
  365. 'PERIOD_AT' => ['isUserTable' => false, 'name' => 'Join periods'],//加入期数
  366. // 'DEC_DEC_ROLE_NAME' => ['isUserTable' => false, 'name' => '所属报单中心级别', 'other' => 'decRole'],
  367. 'DEC_USER_NAME' => ['isUserTable' => false, 'name' => 'Code of distributor'],//所属报单中心编号
  368. 'DEC_REAL_NAME' => ['isUserTable' => false, 'name' => 'Name of distributor'],//所属报单中心姓名
  369. 'MOBILE' => ['isUserTable' => false, 'name' => 'Phone Number'],//手机号码
  370. 'TEL' => ['isUserTable' => false, 'name' => 'Alternate Phone Number'],//备用手机号码
  371. 'AREA' => ['isUserTable' => false, 'name' => 'Commonly Used Address', 'other' => 'area'],//常用地址
  372. // 'SUB_COM_NAME' => ['isUserTable' => false, 'name' => '所属分公司', 'other' => 'subCompany'],
  373. // 'IS_DIRECT_SELLER' => ['isUserTable' => false, 'name' => '是否直销员', 'other' => 'yesOrNo'],
  374. 'BACKUP_AT' => ['isUserTable' => false, 'name' => 'Backup time', 'other' => 'date'],//备份时间
  375. ];
  376. }
  377. return $this->filterTypes;
  378. }
  379. }