// +---------------------------------------------------------------------- namespace app\controller\admin\v1\finance; use app\jobs\integral\IntegralJob; use app\services\user\UserAwardIntegralServices; use app\services\user\UserBillServices; use app\services\user\UserBrokerageServices; use app\services\user\UserMoneyServices; use think\facade\App; use app\controller\admin\AuthController; /** * Class Finance * @package app\controller\admin\v1\finance */ class Finance extends AuthController { /** * Finance constructor. * @param App $app * @param UserBillServices $services */ public function __construct(App $app, UserBillServices $services) { parent::__construct($app); $this->services = $services; } /** * 筛选类型 */ public function bill_type(UserMoneyServices $services) { return $this->success($services->bill_type()); } /** * 资金记录 */ public function list(UserMoneyServices $services) { $where = $this->request->getMore([ ['start_time', ''], ['end_time', ''], ['nickname', ''], ['limit', 20], ['page', 1], ['type', ''], ]); return $this->success($services->getMoneyList($where)); } /** * 用户佣金记录(用户列表) * @return mixed */ public function get_commission_list(UserBrokerageServices $services) { $where = $this->request->getMore([ ['nickname', ''], ['price_max', ''], ['price_min', ''], ['sum_number', 'normal'], ['brokerage_price', 'normal'], ['date', '', '', 'time'] ]); return $this->success($services->getCommissionList($where)); } /** * 佣金详情用户信息 * @param $id * @return mixed */ public function user_info(UserBrokerageServices $services, $id) { return $this->success($services->user_info((int)$id)); } /** * 获取用户佣金列表 * @param UserBrokerageServices $services * @param string $id * @return mixed */ public function getUserBrokeragelist(UserBrokerageServices $services, $id = '') { if ($id == '') return $this->fail('缺少参数'); $where = $this->request->getMore([ ['start_time', ''], ['end_time', ''], ['nickname', ''] ]); $where['uid'] = (int)$id; return $this->success($services->getBrokerageList($where)); } public function setAwardIntegral() { // return $this->success('ok'); $rate1 = sys_config('action_integral_rate', 3); $rate2 = sys_config('static_integral_rate', 3); $service = app()->make(UserAwardIntegralServices::class); $list = $service->getList(['status' => 0]); foreach ($list as $v) { if ($v['type'] == 1) { $sum_extract = bcmul($rate1, $v['sum_price'], 2); } else { $sum_extract = bcmul($rate2, $v['order_price'], 2); } if ($sum_extract != $v['extract_sum']) { $service->update($v['id'], ['extract_sum' => $sum_extract]); } } // app()->make(IntegralJob::class)->autoExtract($service->getPrice()); return $this->success('ok'); } public function addLackEdit() { $service = app()->make(UserAwardIntegralServices::class); return $this->success($service->editLack()); } public function addLake() { return $this->success('功能已关闭'); $num = $this->request->post('num', 0); $pm = $this->request->post('pm', 1); $mark = $this->request->post('mark', ''); if ($num <= 0) $this->fail('请输入正确的数量'); if (!$pm == 0 && !$pm == 1) $this->fail('请选择操作类型'); if (!$mark) $this->fail('请输入操作原因'); $service = app()->make(UserAwardIntegralServices::class); $res = $service->addLake(($pm ? $num : -$num), 0, $mark); if ($res) { // app()->make(IntegralJob::class)->autoExtract($service->getPrice()); return $this->success('操作完成'); } else { $this->fail('操作失败'); } } }