Finance.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. {
  101. // return $this->success('ok');
  102. $rate1 = sys_config('action_integral_rate', 3);
  103. $rate2 = sys_config('static_integral_rate', 3);
  104. $service = app()->make(UserAwardIntegralServices::class);
  105. $list = $service->getList(['status' => 0]);
  106. foreach ($list as $v) {
  107. if ($v['type'] == 1) {
  108. $sum_extract = bcmul($rate1, $v['sum_price'], 2);
  109. } else {
  110. $sum_extract = bcmul($rate2, $v['order_price'], 2);
  111. }
  112. if ($sum_extract != $v['extract_sum']) {
  113. $service->update($v['id'], ['extract_sum' => $sum_extract]);
  114. }
  115. }
  116. // app()->make(IntegralJob::class)->autoExtract($service->getPrice());
  117. return $this->success('ok');
  118. }
  119. public function addLackEdit()
  120. {
  121. $service = app()->make(UserAwardIntegralServices::class);
  122. return $this->success($service->editLack());
  123. }
  124. public function addLake()
  125. {
  126. return $this->success('功能已关闭');
  127. $num = $this->request->post('num', 0);
  128. $pm = $this->request->post('pm', 1);
  129. $mark = $this->request->post('mark', '');
  130. if ($num <= 0) $this->fail('请输入正确的数量');
  131. if (!$pm == 0 && !$pm == 1) $this->fail('请选择操作类型');
  132. if (!$mark) $this->fail('请输入操作原因');
  133. $service = app()->make(UserAwardIntegralServices::class);
  134. $res = $service->addLake(($pm ? $num : -$num), 0, $mark);
  135. if ($res) {
  136. // app()->make(IntegralJob::class)->autoExtract($service->getPrice());
  137. return $this->success('操作完成');
  138. } else {
  139. $this->fail('操作失败');
  140. }
  141. }
  142. }