|
|
@@ -0,0 +1,630 @@
|
|
|
+<?php
|
|
|
+namespace app\admin\controller\user;
|
|
|
+
|
|
|
+use app\common\model\MoneyLog;
|
|
|
+use app\common\model\PaymentModel;
|
|
|
+use app\common\model\RechargeOrderModel;
|
|
|
+use app\common\model\ScoreLog;
|
|
|
+//use app\admin\model\UpgradeLog;
|
|
|
+use app\common\model\ScoreLogModel;
|
|
|
+use app\common\model\User as UserModel;
|
|
|
+use app\common\model\UserData;
|
|
|
+use app\admin\traits\Curd;
|
|
|
+use app\common\constants\AdminConstant;
|
|
|
+use app\common\controller\AdminController;
|
|
|
+use app\common\model\UserMoneyModel;
|
|
|
+use app\common\model\UserteamLogModel;
|
|
|
+use app\Request;
|
|
|
+use EasyAdmin\tool\CommonTool;
|
|
|
+use jianyan\excel\Excel;
|
|
|
+use think\App;
|
|
|
+use think\facade\Db;
|
|
|
+
|
|
|
+
|
|
|
+class Recharge extends AdminController
|
|
|
+{
|
|
|
+
|
|
|
+ public function __construct (App $app)
|
|
|
+ {
|
|
|
+ parent::__construct($app);
|
|
|
+ $this->model = new RechargeOrderModel();
|
|
|
+ }
|
|
|
+
|
|
|
+ protected $sort = [
|
|
|
+ 'order_id' => 'desc',
|
|
|
+ ];
|
|
|
+
|
|
|
+ use Curd;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 充值列表
|
|
|
+ * @return mixed|\think\response\Json
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\DbException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ */
|
|
|
+ public function index ()
|
|
|
+ {
|
|
|
+ if ($this->request->isAjax()) {
|
|
|
+ if (input('selectFields')) {
|
|
|
+ return $this->selectList();
|
|
|
+ }
|
|
|
+ list($page, $limit, $where) = $this->buildTableParames();
|
|
|
+
|
|
|
+// if (($pid = $this->request->param('pid')) !== false && $pid)
|
|
|
+// $where[] = ['pid', '=', $this->request->param('pid', '')];
|
|
|
+
|
|
|
+
|
|
|
+ sr_log(json_encode($where));
|
|
|
+
|
|
|
+ $count = $this->model
|
|
|
+// ->withJoin('userData', 'INNER')
|
|
|
+ ->where($where)
|
|
|
+// ->where($this->user_map)
|
|
|
+ ->count();
|
|
|
+ $list = $this->model
|
|
|
+// ->withJoin('userData', 'INNER')
|
|
|
+ ->where($where)
|
|
|
+// ->where($this->user_map)
|
|
|
+ ->page($page, $limit)
|
|
|
+ ->order($this->sort)
|
|
|
+ ->select();
|
|
|
+
|
|
|
+ $data = [
|
|
|
+ 'code' => 0,
|
|
|
+ 'msg' => Db::getLastSql(),
|
|
|
+ 'count' => $count,
|
|
|
+ 'data' => $list,
|
|
|
+ ];
|
|
|
+ return json($data);
|
|
|
+ }
|
|
|
+ return $this->fetch();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function agree($id){
|
|
|
+ $info = $this->model->where('order_id', $id)->where('status', 3)->find();
|
|
|
+ if (empty($info))
|
|
|
+ $this->error('记录不存在');
|
|
|
+ $user = Db::name('user')->findOrEmpty(['id' => $info['user_id']]);
|
|
|
+ if (empty($user) || $user['status'] != 1)
|
|
|
+ $this->error('用户不存在或已被禁用');
|
|
|
+
|
|
|
+ $paymodel = new PaymentModel();
|
|
|
+// $pay_info = $paymodel->where('remarks', $info['recharge_sn']);
|
|
|
+
|
|
|
+ $nowTime = date('Y-m-d H:i:s', time());
|
|
|
+
|
|
|
+ $info->save(['status'=>2, 'pay_type'=>19,'updated_time' => $nowTime]);
|
|
|
+
|
|
|
+ edit_user_money(12, $info['user_id'], $info['payment']);
|
|
|
+ $this->success('处理成功');
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public function disagree($id){
|
|
|
+ if ($this->request->isPost()){
|
|
|
+ $post = $this->request->post();
|
|
|
+ $row = $this->model->where('order_id', $id)->where('status', 'in', '3')->find();
|
|
|
+ empty($row) && $this->error('取消失败');
|
|
|
+
|
|
|
+ $row->status = 4;
|
|
|
+ $row->error_text = $post['error_text'];
|
|
|
+
|
|
|
+
|
|
|
+ Db::startTrans();
|
|
|
+ try {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $row->save();
|
|
|
+ Db::commit();
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('取消失败'.$e->getMessage());
|
|
|
+ }
|
|
|
+ $this->success('取消成功');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return $this->fetch();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 禁用用户
|
|
|
+ * @param $id
|
|
|
+ */
|
|
|
+ public function forbid ($id)
|
|
|
+ {
|
|
|
+ $user = $this->model->findOrEmpty($id);
|
|
|
+ empty($user) && $this->error('数据不存在');
|
|
|
+ $user['status'] == 0 && $this->error('该用户已被禁用');
|
|
|
+ if ($this->model->where('id', $id)->save(['status' => 0]))
|
|
|
+ $this->success('禁用成功');
|
|
|
+ else
|
|
|
+ $this->error('禁用失败');
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 启用用户
|
|
|
+ * @param $id
|
|
|
+ */
|
|
|
+ public function enable ($id)
|
|
|
+ {
|
|
|
+ $user = $this->model->findOrEmpty($id);
|
|
|
+ empty($user) && $this->error('数据不存在');
|
|
|
+ $user['status'] == 1 && $this->error('该用户已启用');
|
|
|
+ if ($this->model->where('id', $id)->save(['status' => 1]))
|
|
|
+ $this->success('启用成功');
|
|
|
+ else
|
|
|
+ $this->error('启用失败');
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 会员详情
|
|
|
+ * @param Request $request
|
|
|
+ * @param UpgradeLog $upgradeLog
|
|
|
+ * @return mixed
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\DbException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ */
|
|
|
+ public function details (Request $request)
|
|
|
+ {
|
|
|
+ $id = $request->param('id');
|
|
|
+ $info = $this->model
|
|
|
+ ->withJoin('userData', 'INNER')
|
|
|
+ ->where('id', $id)
|
|
|
+ ->find()
|
|
|
+ ->toArray();
|
|
|
+// $upgrade_log = $upgradeLog->where('uid', $id)->order('create_at', 'desc')->select();
|
|
|
+// $this->assign('upgrade_log', $upgrade_log);
|
|
|
+ $this->assign('info', $info);
|
|
|
+ return $this->fetch();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加用户
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
+ public function add ()
|
|
|
+ {
|
|
|
+ if ($this->request->isAjax()) {
|
|
|
+ $post = $this->request->post();
|
|
|
+ $mobile = $this->model->where('mobile', $post['mobile'])->value('id');
|
|
|
+ $mobile && $this->error('该手机号码已被注册');
|
|
|
+ $invite = $this->model->where('code|px_code', $post['code'])->value('id');
|
|
|
+ !$invite && $this->error('邀请人不存在');
|
|
|
+ $this->model->startTrans();
|
|
|
+ try {
|
|
|
+ $insert['mobile'] = $post['mobile'];
|
|
|
+ $insert['reg_ip'] = $this->request->ip();
|
|
|
+ $insert['avatar'] = 'http://images.yxj.hongyun63.com/user/default_avatar.jpg';
|
|
|
+ $insert['code'] = create_invite_code();
|
|
|
+ $insert['px_code'] = create_invite_code();
|
|
|
+ $insert['user_type'] = 2;
|
|
|
+ $rz_money = 1.5 + rand(0, 30) / 100;
|
|
|
+ $this->model->save($insert);
|
|
|
+ $uid = $this->model->id;
|
|
|
+ $user_data = new UserData();
|
|
|
+ $user_data->save(['uid' => $uid, 'rz_money' => $rz_money]); // 保存用户关联信息
|
|
|
+ $this->bindRelation($post['code'], $uid); // 绑定关系
|
|
|
+ $this->model->commit();
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $this->model->rollback();
|
|
|
+ $this->error('添加用户失败');
|
|
|
+ }
|
|
|
+ $this->success('添加成功');
|
|
|
+ }
|
|
|
+ return $this->fetch();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 邀请页面
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
+ public function invite ()
|
|
|
+ {
|
|
|
+ $admin = session('admin');
|
|
|
+ !$admin['user_id'] && $this->error('没有该权限');
|
|
|
+ $user = $this->model->findOrEmpty(['id' => $admin['user_id']]);
|
|
|
+ empty($user) && $this->error('用户信息不存在');
|
|
|
+ $this->assign('user_id', encode($admin['user_id']));
|
|
|
+ return $this->fetch();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 兜底
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
+ public function doudi ()
|
|
|
+ {
|
|
|
+ return 22;
|
|
|
+ if ($this->request->isAjax()) {
|
|
|
+ $post = $this->request->post();
|
|
|
+ $user = $this->model->findOrEmpty(['id' => $post['uid']]);
|
|
|
+ empty($user) && $this->error('用户不存在');
|
|
|
+ $post['active'] <= 0 && $this->error('参数错误');
|
|
|
+ $path = trim_string($user['path'] . ',' . $user['id']);
|
|
|
+ $path_explode = explode(',', $path);
|
|
|
+ $insert = [];
|
|
|
+ foreach ($path_explode as $value) {
|
|
|
+ $insert[] = [
|
|
|
+ 'active' => $post['active'],
|
|
|
+ 'uid' => $value,
|
|
|
+ 'ip' => $this->request->ip(),
|
|
|
+ 'user_admin' => session('?admin.username') ? session('admin.username') : '',
|
|
|
+ 'from_uid' => $post['uid'],
|
|
|
+ 'failure_at' => date('Y-m-d H:i:s', time() + 86400 * 30),
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ $this->model->startTrans();
|
|
|
+ try {
|
|
|
+ $this->model->whereIn('id', $path)->save(['active_set' => ['inc', $post['active']], 'total_number' => ['inc', $post['active']], 'total_number_real' => ['inc', $post['active']], 'total_active' => ['inc', $post['active']]]);
|
|
|
+ ActiveSet::insertAll($insert);
|
|
|
+ $this->model->commit();
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $this->model->rollback();
|
|
|
+ $this->error('失败');
|
|
|
+ }
|
|
|
+ $this->success('成功');
|
|
|
+ }
|
|
|
+ return $this->fetch();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 增加余额
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
+ public function editmoney ()
|
|
|
+ {
|
|
|
+ if ($this->request->isPost()) {
|
|
|
+
|
|
|
+ $post = $this->request->post();
|
|
|
+ $user = $this->model->findOrEmpty(['id' => $post['uid']]);
|
|
|
+ $money = $post['money'];
|
|
|
+ $type = $post['type'];
|
|
|
+ empty($user) && $this->error('用户不存在');
|
|
|
+
|
|
|
+ $this->model->startTrans();
|
|
|
+ try {
|
|
|
+ if ($type == 'more'){
|
|
|
+ edit_user_money(7, $post['uid'], $money);
|
|
|
+ }else {
|
|
|
+ edit_user_money(8, $post['uid'], $money);
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->model->commit();
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $this->model->rollback();
|
|
|
+ $this->error('失败'.$e->getMessage());
|
|
|
+ }
|
|
|
+ $this->success('成功');
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this->fetch();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 末尾奖励
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
+ public function moweiscore ()
|
|
|
+ {
|
|
|
+ if ($this->request->isPost()) {
|
|
|
+ $post = $this->request->post();
|
|
|
+ $user = $this->model->findOrEmpty(['id' => $post['uid']]);
|
|
|
+
|
|
|
+ $money = $post['money'];
|
|
|
+ empty($user) && $this->error('用户不存在');
|
|
|
+
|
|
|
+ $this->model->startTrans();
|
|
|
+ try {
|
|
|
+ edit_user_score(8, $post['uid'], $money);
|
|
|
+ $this->model->commit();
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $this->model->rollback();
|
|
|
+ $this->error('失败'.$e->getMessage());
|
|
|
+ }
|
|
|
+ $this->success('成功');
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this->fetch();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 余额明细
|
|
|
+ * @param MoneyLog $model
|
|
|
+ * @return mixed|\think\response\Json
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\DbException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ */
|
|
|
+ public function moneyLog (UserMoneyModel $model)
|
|
|
+ {
|
|
|
+ if ($this->request->isAjax()) {
|
|
|
+ if (input('selectFields')) {
|
|
|
+ return $this->selectList();
|
|
|
+ }
|
|
|
+ list($page, $limit, $where) = $this->buildTableParames();
|
|
|
+ $where[] = ['uid', '=', $this->request->param('id', '')];
|
|
|
+ $count = $model
|
|
|
+ ->where($where)
|
|
|
+ ->count();
|
|
|
+ $type_conf = config('type.money');
|
|
|
+ $list = $model
|
|
|
+ ->where($where)
|
|
|
+ ->withAttr('type', function ($value, $data) use ($type_conf) {
|
|
|
+ return $type_conf[$value];
|
|
|
+ })
|
|
|
+ ->withAttr('money', function ($value, $data) {
|
|
|
+ if ($data['state'] == 2)
|
|
|
+ $value = '-' . $value;
|
|
|
+ return $value;
|
|
|
+ })
|
|
|
+ ->page($page, $limit)
|
|
|
+ ->order($this->sort)
|
|
|
+ ->select();
|
|
|
+ $data = [
|
|
|
+ 'code' => 0,
|
|
|
+ 'msg' => '',
|
|
|
+ 'count' => $count,
|
|
|
+ 'data' => $list,
|
|
|
+ ];
|
|
|
+ return json($data);
|
|
|
+ }
|
|
|
+ return $this->fetch();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查看上级
|
|
|
+ * @param Request $request
|
|
|
+ * @param UpgradeLog $upgradeLog
|
|
|
+ * @return mixed
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\DbException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ */
|
|
|
+ public function lookpidlevel (Request $request)
|
|
|
+ {
|
|
|
+ if ($this->request->isAjax()) {
|
|
|
+
|
|
|
+// if (($pid = $this->request->param('pid')) !== false && $pid)
|
|
|
+// $where[] = ['pid', '=', $this->request->param('pid', '')];
|
|
|
+ $id = $this->request->param('id');
|
|
|
+ $path = Db::name('user')->where('id', $id)->value('path');
|
|
|
+ $arr = explode(',', $path);
|
|
|
+
|
|
|
+ $ids = $arr;
|
|
|
+ $ids = implode(',',$ids);
|
|
|
+ $order= 'field(id,'.$ids.')';
|
|
|
+// return User::whereIn('id',$ids)->order(Db::raw($order))->select();
|
|
|
+
|
|
|
+ $where = array();
|
|
|
+
|
|
|
+ $where[] = ['uid', 'in', $arr];
|
|
|
+ sr_log($where);
|
|
|
+ $count = $this->model
|
|
|
+ ->withJoin('userData', 'INNER')
|
|
|
+ ->where($where)
|
|
|
+ ->count();
|
|
|
+ $list = $this->model
|
|
|
+ ->withJoin('userData', 'INNER')
|
|
|
+ ->where($where)
|
|
|
+ ->order(Db::raw($order))
|
|
|
+ ->select();
|
|
|
+
|
|
|
+ $data = [
|
|
|
+ 'code' => 0,
|
|
|
+ 'msg' => '成功',
|
|
|
+ 'count' => $count,
|
|
|
+ 'data' => $list,
|
|
|
+ ];
|
|
|
+ return json($data);
|
|
|
+ }
|
|
|
+ return $this->fetch();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 元宝明细
|
|
|
+ * @param CoinLog $model
|
|
|
+ * @return mixed|\think\response\Json
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\DbException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ */
|
|
|
+ public function coinLog (CoinLog $model)
|
|
|
+ {
|
|
|
+ if ($this->request->isAjax()) {
|
|
|
+ if (input('selectFields')) {
|
|
|
+ return $this->selectList();
|
|
|
+ }
|
|
|
+ list($page, $limit, $where) = $this->buildTableParames();
|
|
|
+ $where[] = ['uid', '=', $this->request->param('id', '')];
|
|
|
+ $count = $model
|
|
|
+ ->where($where)
|
|
|
+ ->count();
|
|
|
+ $type_conf = config('type.coin');
|
|
|
+ $list = $model
|
|
|
+ ->where($where)
|
|
|
+ ->withAttr('type', function ($value, $data) use ($type_conf) {
|
|
|
+ return $type_conf[$value];
|
|
|
+ })
|
|
|
+ ->withAttr('coin', function ($value, $data) {
|
|
|
+ if ($data['state'] == 2)
|
|
|
+ $value = '-' . $value;
|
|
|
+ return $value;
|
|
|
+ })
|
|
|
+ ->page($page, $limit)
|
|
|
+ ->order($this->sort)
|
|
|
+ ->select();
|
|
|
+ $data = [
|
|
|
+ 'code' => 0,
|
|
|
+ 'msg' => '',
|
|
|
+ 'count' => $count,
|
|
|
+ 'data' => $list,
|
|
|
+ ];
|
|
|
+ return json($data);
|
|
|
+ }
|
|
|
+ return $this->fetch();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 积分明细
|
|
|
+ * @param ScoreLog $model
|
|
|
+ * @return mixed|\think\response\Json
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\DbException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ */
|
|
|
+ public function scoreLog (ScoreLogModel $model)
|
|
|
+ {
|
|
|
+ if ($this->request->isAjax()) {
|
|
|
+ if (input('selectFields')) {
|
|
|
+ return $this->selectList();
|
|
|
+ }
|
|
|
+ list($page, $limit, $where) = $this->buildTableParames();
|
|
|
+ $where[] = ['uid', '=', $this->request->param('id', '')];
|
|
|
+ $count = $model
|
|
|
+ ->where($where)
|
|
|
+ ->count();
|
|
|
+ $type_conf = config('type.score');
|
|
|
+ $list = $model
|
|
|
+ ->where($where)
|
|
|
+ ->withAttr('type', function ($value, $data) use ($type_conf) {
|
|
|
+ return $type_conf[$value];
|
|
|
+ })
|
|
|
+ ->withAttr('score', function ($value, $data) {
|
|
|
+ if ($data['state'] == 2)
|
|
|
+ $value = '-' . $value;
|
|
|
+ return $value;
|
|
|
+ })
|
|
|
+ ->page($page, $limit)
|
|
|
+ ->order($this->sort)
|
|
|
+ ->select();
|
|
|
+ $data = [
|
|
|
+ 'code' => 0,
|
|
|
+ 'msg' => '',
|
|
|
+ 'count' => $count,
|
|
|
+ 'data' => $list,
|
|
|
+ ];
|
|
|
+ return json($data);
|
|
|
+ }
|
|
|
+ return $this->fetch();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 积分明细
|
|
|
+ * @param ActiveLog $model
|
|
|
+ * @return mixed|\think\response\Json
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\DbException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ */
|
|
|
+ public function activeLog (ActiveLog $model)
|
|
|
+ {
|
|
|
+ if ($this->request->isAjax()) {
|
|
|
+ if (input('selectFields')) {
|
|
|
+ return $this->selectList();
|
|
|
+ }
|
|
|
+ list($page, $limit, $where) = $this->buildTableParames();
|
|
|
+ $where[] = ['uid', '=', $this->request->param('id', '')];
|
|
|
+ $count = $model
|
|
|
+ ->where($where)
|
|
|
+ ->count();
|
|
|
+ $type_conf = config('type.active');
|
|
|
+ $list = $model
|
|
|
+ ->where($where)
|
|
|
+ ->withAttr('type', function ($value, $data) use ($type_conf) {
|
|
|
+ return $type_conf[$value];
|
|
|
+ })
|
|
|
+ ->withAttr('active', function ($value, $data) {
|
|
|
+ if ($data['state'] == 2)
|
|
|
+ $value = '-' . $value;
|
|
|
+ return $value;
|
|
|
+ })
|
|
|
+ ->page($page, $limit)
|
|
|
+ ->order($this->sort)
|
|
|
+ ->select();
|
|
|
+ $data = [
|
|
|
+ 'code' => 0,
|
|
|
+ 'msg' => '',
|
|
|
+ 'count' => $count,
|
|
|
+ 'data' => $list,
|
|
|
+ ];
|
|
|
+ return json($data);
|
|
|
+ }
|
|
|
+ return $this->fetch();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @NodeAnotation(title="导出")
|
|
|
+ */
|
|
|
+ public function export ()
|
|
|
+ {
|
|
|
+ list($page, $limit, $where) = $this->buildTableParames();
|
|
|
+ $tableName = $this->model->getName();
|
|
|
+ $tableName = CommonTool::humpToLine(lcfirst($tableName));
|
|
|
+ $prefix = config('database.connections.mysql.prefix');
|
|
|
+ $dbList = Db::query("show full columns from {$prefix}{$tableName}");
|
|
|
+ $header = [];
|
|
|
+ foreach ($dbList as $vo) {
|
|
|
+ $comment = !empty($vo['Comment']) ? $vo['Comment'] : $vo['Field'];
|
|
|
+ if (!in_array($vo['Field'], $this->noExportFields)) {
|
|
|
+ $header[] = [$comment, $vo['Field']];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $list = $this->model
|
|
|
+ ->where($where)
|
|
|
+ ->withJoin('userData', 'INNER')
|
|
|
+ ->where($where)
|
|
|
+ ->limit(100000)
|
|
|
+ ->order('id', 'desc')
|
|
|
+ ->select()
|
|
|
+ ->toArray();
|
|
|
+ $fileName = time();
|
|
|
+ return Excel::exportData($list, $header, $fileName, 'xlsx');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function teamincome (Request $request)
|
|
|
+ {
|
|
|
+ if ($this->request->isAjax()) {
|
|
|
+
|
|
|
+// if (($pid = $this->request->param('pid')) !== false && $pid)
|
|
|
+// $where[] = ['pid', '=', $this->request->param('pid', '')];
|
|
|
+ $id = $this->request->param('id');
|
|
|
+// $path = Db::name('user')->where('id', $id)->value('path');
|
|
|
+ $where = array();
|
|
|
+ $where[] = ['uid', '=', $id];
|
|
|
+ $where[] = ['type', '=', 3];
|
|
|
+ $count = Db::name('userteam_log')
|
|
|
+// ->withJoin('user', 'INNER')
|
|
|
+ ->where($where)
|
|
|
+ ->count();
|
|
|
+ $list = Db::name('userteam_log')
|
|
|
+// ->withJoin('user', 'INNER')
|
|
|
+ ->where($where)
|
|
|
+ ->order($this->sort)
|
|
|
+ ->select();
|
|
|
+
|
|
|
+
|
|
|
+ $data = [
|
|
|
+ 'code' => 0,
|
|
|
+ 'msg' => '成功',
|
|
|
+ 'count' => $count,
|
|
|
+ 'data' => $list,
|
|
|
+ ];
|
|
|
+ return json($data);
|
|
|
+ }
|
|
|
+ return $this->fetch();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|