Finance.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\admin\v1\finance;
  12. use app\jobs\integral\IntegralJob;
  13. use app\services\user\UserAwardIntegralServices;
  14. use app\services\user\UserBillServices;
  15. use app\services\user\UserBrokerageServices;
  16. use app\services\user\UserMoneyServices;
  17. use think\facade\App;
  18. use app\controller\admin\AuthController;
  19. /**
  20. * Class Finance
  21. * @package app\controller\admin\v1\finance
  22. */
  23. class Finance extends AuthController
  24. {
  25. /**
  26. * Finance constructor.
  27. * @param App $app
  28. * @param UserBillServices $services
  29. */
  30. public function __construct(App $app, UserBillServices $services)
  31. {
  32. parent::__construct($app);
  33. $this->services = $services;
  34. }
  35. /**
  36. * 筛选类型
  37. */
  38. public function bill_type(UserMoneyServices $services)
  39. {
  40. return $this->success($services->bill_type());
  41. }
  42. /**
  43. * 资金记录
  44. */
  45. public function list(UserMoneyServices $services)
  46. {
  47. $where = $this->request->getMore([
  48. ['start_time', ''],
  49. ['end_time', ''],
  50. ['nickname', ''],
  51. ['limit', 20],
  52. ['page', 1],
  53. ['type', ''],
  54. ]);
  55. return $this->success($services->getMoneyList($where));
  56. }
  57. /**
  58. * 用户佣金记录(用户列表)
  59. * @return mixed
  60. */
  61. public function get_commission_list(UserBrokerageServices $services)
  62. {
  63. $where = $this->request->getMore([
  64. ['nickname', ''],
  65. ['price_max', ''],
  66. ['price_min', ''],
  67. ['sum_number', 'normal'],
  68. ['brokerage_price', 'normal'],
  69. ['date', '', '', 'time']
  70. ]);
  71. return $this->success($services->getCommissionList($where));
  72. }
  73. /**
  74. * 佣金详情用户信息
  75. * @param $id
  76. * @return mixed
  77. */
  78. public function user_info(UserBrokerageServices $services, $id)
  79. {
  80. return $this->success($services->user_info((int)$id));
  81. }
  82. /**
  83. * 获取用户佣金列表
  84. * @param UserBrokerageServices $services
  85. * @param string $id
  86. * @return mixed
  87. */
  88. public function getUserBrokeragelist(UserBrokerageServices $services, $id = '')
  89. {
  90. if ($id == '') return $this->fail('缺少参数');
  91. $where = $this->request->getMore([
  92. ['start_time', ''],
  93. ['end_time', ''],
  94. ['nickname', '']
  95. ]);
  96. $where['uid'] = (int)$id;
  97. return $this->success($services->getBrokerageList($where));
  98. }
  99. public function setAwardIntegral(){
  100. return $this->success('ok');
  101. $rate1 = sys_config('action_integral_rate', 3);
  102. $rate2 = sys_config('static_integral_rate', 3);
  103. $service = app()->make(UserAwardIntegralServices::class);
  104. $list = $service->getList(['status' => 0]);
  105. foreach ($list as $v) {
  106. if ($v['type'] == 1) {
  107. $sum_extract = bcmul($rate1, $v['sum_price'], 2);
  108. } else {
  109. $sum_extract = bcmul($rate2, $v['order_price'], 2);
  110. }
  111. if ($sum_extract != $v['extract_sum']) {
  112. $service->update($v['id'], ['extract_sum' => $sum_extract]);
  113. }
  114. }
  115. app()->make(IntegralJob::class)->autoExtract($service->getPrice());
  116. return $this->success('ok');
  117. }
  118. }