HistoryBonusList.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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' => '150',
  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. 'BONUS' => [
  107. 'header' => 'Member Bonus', // 会员账户余额
  108. 'value' => function ($row) {
  109. return Tool::formatPrice($row['BONUS']);
  110. },
  111. 'headerOther' => function ($row) {
  112. return [
  113. 'width' => '150',
  114. ];
  115. },
  116. 'valueOther' => function ($row) {
  117. return [
  118. 'tag' => ['type' => 'danger', 'size' => 'small', 'class' => 'no-border']
  119. ];
  120. },
  121. ],
  122. 'WITHDRAW' => [
  123. 'header' => 'Withdrawal Amount', // 提现金额
  124. 'value' => function ($row) {
  125. return Tool::formatPrice($row['WITHDRAW']);
  126. },
  127. 'headerOther' => function ($row) {
  128. return [
  129. 'width' => '150',
  130. ];
  131. },
  132. 'valueOther' => function ($row) {
  133. return [
  134. 'tag' => ['type' => 'warning', 'size' => 'small', 'class' => 'no-border']
  135. ];
  136. },
  137. ],
  138. 'WITHDRAW_REAL' => [
  139. 'header' => 'Real Amount', // 实付金额
  140. 'value' => function ($row) {
  141. return Tool::formatPrice($row['WITHDRAW_REAL']);
  142. },
  143. 'headerOther' => function ($row) {
  144. return [
  145. 'width' => '150',
  146. ];
  147. },
  148. 'valueOther' => function ($row) {
  149. return [
  150. 'tag' => ['type' => 'warning', 'size' => 'small', 'class' => 'no-border']
  151. ];
  152. },
  153. ],
  154. 'WITHDRAW_FAIL' => [
  155. 'header' => 'Actual Payment Of Failed Amount', // 实付失败金额
  156. 'value' => function ($row) {
  157. return Tool::formatPrice($row['WITHDRAW_FAIL']);
  158. },
  159. 'headerOther' => function ($row) {
  160. return [
  161. 'width' => '240',
  162. ];
  163. },
  164. 'valueOther' => function ($row) {
  165. return [
  166. 'tag' => ['type' => 'warning', 'size' => 'small', 'class' => 'no-border']
  167. ];
  168. },
  169. ],
  170. 'USER_STATUS_NAME' => [
  171. 'header' => 'Member Status', // 会员状态
  172. 'headerOther' => ['width' => '150'],
  173. ],
  174. 'USER_STATUS_AT' => [
  175. 'header' => 'Member Status Change Time', // 会员状态变更时间
  176. 'value' => function ($row) {
  177. return (new DateTime([
  178. 'value' => $row['USER_STATUS_AT'],
  179. ]))->result();
  180. },
  181. 'headerOther' => ['width' => '210'],
  182. ],
  183. 'PERIOD_AT' => [
  184. 'header' => 'Join Periods', // 加入期数
  185. 'headerOther' => ['width' => '150'],
  186. ],
  187. 'DEC_USER_NAME' => [
  188. 'header' => 'Code Of Distributor', // 所属报单中心编号
  189. 'headerOther' => ['width' => '150'],
  190. ],
  191. 'DEC_REAL_NAME' => [
  192. 'header' => 'Name Of Distributor', // 所属报单中心姓名
  193. 'headerOther' => ['width' => '150'],
  194. ],
  195. 'MOBILE' => [
  196. 'header' => 'Phone Number', // 手机号码
  197. 'value' => function($row) {
  198. return "\t".$row['MOBILE'];
  199. },
  200. 'headerOther' => ['width' => '150'],
  201. ],
  202. 'TEL' => [
  203. 'header' => 'Alternate Phone Number', // 备用手机号码
  204. 'value' => function($row) {
  205. return "\t".$row['TEL'];
  206. },
  207. 'headerOther' => ['width' => '190'],
  208. ],
  209. 'AREA' => [
  210. 'header' => 'Commonly Used Address', // 常用地址
  211. 'value' => function ($row) {
  212. return $row['PROVINCE_NAME'] . $row['CITY_NAME'] . $row['COUNTY_NAME'];
  213. },
  214. 'showValue' => function ($row) {
  215. return '<div class="addr" title=' . $row['PROVINCE_NAME'] . $row['CITY_NAME'] . $row['COUNTY_NAME'] . '>' . $row['PROVINCE_NAME'] . $row['CITY_NAME'] . $row['COUNTY_NAME'] . '</div>';
  216. },
  217. 'headerOther' => [
  218. 'width' => '200'
  219. ],
  220. ],
  221. 'BACKUP_AT' => [
  222. 'header' => 'Backup Time', // 备份时间
  223. 'value' => function ($row) {
  224. return (new DateTime([
  225. 'value' => $row['BACKUP_AT'],
  226. ]))->result();
  227. },
  228. 'headerOther' => ['width' => '190'],
  229. ],
  230. ];
  231. }
  232. return $this->columns;
  233. }
  234. /**
  235. * 前台用于筛选的类型集合
  236. * @return mixed
  237. */
  238. public function getFilterTypes() {
  239. if (!$this->filterTypes) {
  240. $this->filterTypes = [
  241. 'USER_NAME' => ['isUserTable' => false, 'name' => 'Member Code'], // 会员编号
  242. 'REAL_NAME' => ['isUserTable' => false, 'name' => 'Member Name'], // 会员姓名
  243. 'DEC_LV_NAME' => ['isUserTable' => false, 'name' => 'Member Level', 'other' => 'decLevel'], // 会员级别
  244. 'EMP_LV_NAME' => ['isUserTable' => false, 'name' => 'Rank', 'other' => 'empLevel'], // 聘级
  245. 'IS_DEC' => ['isUserTable' => false, 'name' => 'Whether Distributor', 'other' => 'yesOrNo'], // 是否报单中心
  246. 'BONUS' => ['isUserTable' => false, 'name' => 'Member Bonus'], // 会员账户余额
  247. 'WITHDRAW' => ['isUserTable' => false, 'name' => 'Withdrawal Amount'], // 提现金额
  248. 'WITHDRAW_REAL' => ['isUserTable' => false, 'name' => 'Real Amount'], // 实付金额
  249. 'WITHDRAW_FAIL' => ['isUserTable' => false, 'name' => 'Actual Payment Of Failed Amount'], // 实付失败金额
  250. 'USER_STATUS_NAME' => ['isUserTable' => false, 'name' => 'Member Status', 'other' => 'status'], // 会员状态
  251. 'USER_STATUS_AT' => ['isUserTable' => false, 'name' => 'Member Status Change Time', 'other' => 'date'], // 会员状态变更时间
  252. 'PERIOD_AT' => ['isUserTable' => false, 'name' => 'Join Periods'], // 加入期数
  253. 'DEC_USER_NAME' => ['isUserTable' => false, 'name' => 'Code Of Distributor'], // 所属报单中心编号
  254. 'DEC_REAL_NAME' => ['isUserTable' => false, 'name' => 'Name Of Distributor'], // 所属报单中心姓名
  255. 'MOBILE' => ['isUserTable' => false, 'name' => 'Phone Number'], // 手机号码
  256. 'TEL' => ['isUserTable' => false, 'name' => 'Alternate Phone Number'], // 备用手机号码
  257. 'AREA' => ['isUserTable' => false, 'name' => 'Commonly Used Address', 'other' => 'area'], // 常用地址
  258. 'BACKUP_AT' => ['isUserTable' => false, 'name' => 'Backup Time', 'other' => 'date'], // 备份时间
  259. ];
  260. }
  261. return $this->filterTypes;
  262. }
  263. }