386 lines
15 KiB
PHP
Executable File
386 lines
15 KiB
PHP
Executable File
<?php
|
|
|
|
namespace app\admin\controller;
|
|
|
|
use app\common\model\OrderList;
|
|
use app\admin\controller\Base;
|
|
use \think\Request;
|
|
use think\facade\View;
|
|
use app\common\model\User;
|
|
use app\common\model\ProfitMoney;
|
|
use app\common\model\ProfitIntegral;
|
|
use app\common\model\ProfitScore;
|
|
use app\common\model\UserRecharge;
|
|
use app\common\model\ProfitDraw;
|
|
use app\common\model\Order;
|
|
use app\common\model\WxpayLog;
|
|
|
|
class Finance extends Base
|
|
{
|
|
/**
|
|
* 消费排行榜
|
|
*/
|
|
public function record(Request $request)
|
|
{
|
|
$user_id = trim(input('get.user_id'));
|
|
$mobile = trim(input('get.mobile'));
|
|
$addtime = trim(input('get.addtime'));
|
|
$whe = [];
|
|
$whe[] = ['order_type', '<', 5];
|
|
$whe[] = ['status', '=', 1];
|
|
if ($user_id) {
|
|
$user_id = $user_id - 1260;
|
|
$whe[] = ['user_id', '=', $user_id];
|
|
}
|
|
if ($mobile) {
|
|
$mobile = User::field('id')->where('mobile', '=', $mobile)->value('id');
|
|
$whe[] = ['user_id', '=', $mobile];
|
|
}
|
|
if ($addtime) {
|
|
$time = explode(' - ', $addtime);
|
|
$start_time = strtotime($time[0]);
|
|
$end_time = strtotime($time[1]) - 1;
|
|
if ($start_time > $end_time) {
|
|
$this->err('开始时间不能大于结束时间');
|
|
}
|
|
$whe[] = ['addtime', 'BETWEEN', array($start_time, $end_time)];
|
|
}
|
|
$field = "id,user_id,sum(order_total) as order_total,sum(price) as price,sum(use_money) as use_money,sum(use_integral) as use_integral";
|
|
$list = Order::where($whe)
|
|
->field($field)
|
|
->group("user_id")
|
|
->order("order_total desc")
|
|
->paginate(['list_rows' => $this->page, 'query' => request()->param()]);
|
|
$page = $list->render();
|
|
$data = [];
|
|
$data['list'] = $list->toArray()['data'];
|
|
$data['count'] = $list->total();
|
|
$data['page'] = $page;
|
|
foreach ($data['list'] as &$value) {
|
|
$user_info = User::field('nickname,headimg,mobile')->where('id', '=', $value['user_id'])->find();
|
|
if (empty($user_info)) {
|
|
$user_info['nickname'] ='';
|
|
$user_info['headimg'] = '';
|
|
$user_info['mobile'] = '';
|
|
}
|
|
$value['nickname'] = $user_info['nickname'];
|
|
$value['headimg'] = $user_info['headimg'];
|
|
$value['mobile'] = $user_info['mobile'];
|
|
}
|
|
View::assign('list', $data['list']);
|
|
View::assign('count', $data['count']);
|
|
View::assign('page', $data['page']);
|
|
return View::fetch("Finance/record");
|
|
}
|
|
|
|
/**
|
|
* 余额明细
|
|
*/
|
|
public function money_list(Request $request)
|
|
{
|
|
$user_id = trim(input('get.user_id'));
|
|
$mobile = trim(input('get.mobile'));
|
|
$addtime = trim(input('get.addtime'));
|
|
$whe = [];
|
|
if ($user_id) {
|
|
$user_id = $user_id - 1260;
|
|
$whe[] = ['user_id', '=', $user_id];
|
|
}
|
|
if ($mobile) {
|
|
$mobile = User::field('id')->where('mobile', '=', $mobile)->value('id');
|
|
$whe[] = ['user_id', '=', $mobile];
|
|
}
|
|
if ($addtime) {
|
|
$time = explode(' - ', $addtime);
|
|
$start_time = strtotime($time[0]);
|
|
$end_time = strtotime($time[1]) - 1;
|
|
if ($start_time > $end_time) {
|
|
$this->err('开始时间不能大于结束时间');
|
|
}
|
|
$whe[] = ['addtime', 'BETWEEN', array($start_time, $end_time)];
|
|
}
|
|
$data = ProfitMoney::getList($whe, '*', 'id desc', $this->page);
|
|
foreach ($data['list'] as &$value) {
|
|
$user_info = User::field('nickname,headimg,mobile')->where(['id' => $value['user_id']])->find();
|
|
if ($user_info != null) {
|
|
$value['nickname'] = $user_info['nickname'];
|
|
$value['headimg'] = $user_info['headimg'];
|
|
$value['mobile'] = $user_info['mobile'];
|
|
} else {
|
|
$value['nickname'] = '';
|
|
$value['headimg'] = '';
|
|
$value['mobile'] = '';
|
|
}
|
|
}
|
|
View::assign('list', $data['list']);
|
|
View::assign('count', $data['count']);
|
|
View::assign('page', $data['page']);
|
|
return View::fetch("Finance/money_list");
|
|
}
|
|
|
|
|
|
/**
|
|
* 吧唧币明细
|
|
*/
|
|
public function integral_list(Request $request)
|
|
{
|
|
$user_id = trim(input('get.user_id'));
|
|
$mobile = trim(input('get.mobile'));
|
|
$addtime = trim(input('get.addtime'));
|
|
$whe = [];
|
|
if ($user_id) {
|
|
$user_id = $user_id - 1260;
|
|
$whe[] = ['user_id', '=', $user_id];
|
|
}
|
|
if ($mobile) {
|
|
$mobile = User::field('id')->where('mobile', '=', $mobile)->value('id');
|
|
$whe[] = ['user_id', '=', $mobile];
|
|
}
|
|
if ($addtime) {
|
|
$time = explode(' - ', $addtime);
|
|
$start_time = strtotime($time[0]);
|
|
$end_time = strtotime($time[1]) - 1;
|
|
if ($start_time > $end_time) {
|
|
$this->err('开始时间不能大于结束时间');
|
|
}
|
|
$whe[] = ['addtime', 'BETWEEN', array($start_time, $end_time)];
|
|
}
|
|
$data = ProfitIntegral::getList($whe, '*', 'id desc', $this->page);
|
|
foreach ($data['list'] as &$value) {
|
|
$user_info = User::field('nickname,headimg,mobile')->where(['id' => $value['user_id']])->find();
|
|
if (empty($user_info)) {
|
|
$user_info['nickname'] ='';
|
|
$user_info['headimg'] = '';
|
|
$user_info['mobile'] = '';
|
|
}
|
|
$value['nickname'] = $user_info['nickname'];
|
|
$value['headimg'] = $user_info['headimg'];
|
|
$value['mobile'] = $user_info['mobile'];
|
|
}
|
|
View::assign('list', $data['list']);
|
|
View::assign('count', $data['count']);
|
|
View::assign('page', $data['page']);
|
|
return View::fetch("Finance/integral_list");
|
|
}
|
|
|
|
/**
|
|
* 积分明细
|
|
*/
|
|
public function score_list(Request $request)
|
|
{
|
|
$user_id = trim(input('get.user_id'));
|
|
$mobile = trim(input('get.mobile'));
|
|
$addtime = trim(input('get.addtime'));
|
|
$whe = [];
|
|
if ($user_id) {
|
|
$user_id = $user_id - 1260;
|
|
$whe[] = ['user_id', '=', $user_id];
|
|
}
|
|
if ($mobile) {
|
|
$mobile = User::field('id')->where('mobile', '=', $mobile)->value('id');
|
|
$whe[] = ['user_id', '=', $mobile];
|
|
}
|
|
if ($addtime) {
|
|
$time = explode(' - ', $addtime);
|
|
$start_time = strtotime($time[0]);
|
|
$end_time = strtotime($time[1]) - 1;
|
|
if ($start_time > $end_time) {
|
|
$this->err('开始时间不能大于结束时间');
|
|
}
|
|
$whe[] = ['addtime', 'BETWEEN', array($start_time, $end_time)];
|
|
}
|
|
$data = ProfitScore::getList($whe, '*', 'id desc', $this->page);
|
|
foreach ($data['list'] as &$value) {
|
|
$user_info = User::field('nickname,headimg,mobile')->where(['id' => $value['user_id']])->find();
|
|
if (empty($user_info)) {
|
|
$user_info['nickname'] ='';
|
|
$user_info['headimg'] = '';
|
|
$user_info['mobile'] = '';
|
|
}
|
|
$value['nickname'] = $user_info['nickname'];
|
|
$value['headimg'] = $user_info['headimg'];
|
|
$value['mobile'] = $user_info['mobile'];
|
|
}
|
|
View::assign('list', $data['list']);
|
|
View::assign('count', $data['count']);
|
|
View::assign('page', $data['page']);
|
|
return View::fetch("Finance/score_list");
|
|
}
|
|
|
|
/**
|
|
* 抽奖券明细
|
|
*/
|
|
public function draw_list(Request $request)
|
|
{
|
|
$user_id = trim(input('get.user_id'));
|
|
$mobile = trim(input('get.mobile'));
|
|
$addtime = trim(input('get.addtime'));
|
|
$type = trim(input('get.type'));
|
|
$whe = [];
|
|
if ($user_id) {
|
|
$user_id = $user_id - 1260;
|
|
$whe[] = ['user_id', '=', $user_id];
|
|
}
|
|
if ($mobile) {
|
|
$mobile = User::field('id')->where('mobile', '=', $mobile)->value('id');
|
|
$whe[] = ['user_id', '=', $mobile];
|
|
}
|
|
if ($addtime) {
|
|
$time = explode(' - ', $addtime);
|
|
$start_time = strtotime($time[0]);
|
|
$end_time = strtotime($time[1]) - 1;
|
|
if ($start_time > $end_time) {
|
|
$this->err('开始时间不能大于结束时间');
|
|
}
|
|
$whe[] = ['addtime', 'BETWEEN', array($start_time, $end_time)];
|
|
}
|
|
if ($type) {
|
|
$whe[] = ['type', '=', $type];
|
|
}
|
|
$data = ProfitDraw::getList($whe, '*', 'id desc', $this->page);
|
|
foreach ($data['list'] as &$value) {
|
|
$user_info = User::field('nickname,headimg,mobile')->where(['id' => $value['user_id']])->find();
|
|
if (empty($user_info)) {
|
|
$user_info['nickname'] ='';
|
|
$user_info['headimg'] = '';
|
|
$user_info['mobile'] = '';
|
|
}
|
|
$value['nickname'] = $user_info['nickname'];
|
|
$value['headimg'] = $user_info['headimg'];
|
|
$value['mobile'] = $user_info['mobile'];
|
|
$share_info = User::field('nickname,headimg,mobile')->where(['id' => $value['share_uid']])->find();
|
|
if (empty($share_info)) {
|
|
$share_info['nickname'] = '';
|
|
$share_info['headimg'] = '';
|
|
$share_info['mobile'] = '';
|
|
}
|
|
$value['share_nickname'] = $share_info['nickname'];
|
|
$value['share_headimg'] = $share_info['headimg'];
|
|
$value['share_mobile'] = $share_info['mobile'];
|
|
}
|
|
View::assign('list', $data['list']);
|
|
View::assign('count', $data['count']);
|
|
View::assign('page', $data['page']);
|
|
return View::fetch("Finance/draw_list");
|
|
}
|
|
|
|
/**
|
|
* 充值记录
|
|
*/
|
|
public function recharge_list()
|
|
{
|
|
$user_id = trim(input('get.user_id'));
|
|
$mobile = trim(input('get.mobile'));
|
|
$pay_time = trim(input('get.pay_time'));
|
|
$whe = [];
|
|
// $whe[] = ['status', '=', 2];
|
|
if ($user_id) {
|
|
$user_id = $user_id - 1260;
|
|
$whe[] = ['user_id', '=', $user_id];
|
|
}
|
|
if ($mobile) {
|
|
$mobile = User::field('id')->where('mobile', '=', $mobile)->value('id');
|
|
$whe[] = ['user_id', '=', $mobile];
|
|
}
|
|
if ($pay_time) {
|
|
$time = explode(' - ', $pay_time);
|
|
$start_time = strtotime($time[0]);
|
|
$end_time = strtotime($time[1]) - 1;
|
|
if ($start_time > $end_time) {
|
|
$this->err('开始时间不能大于结束时间');
|
|
}
|
|
$whe[] = ['addtime', 'BETWEEN', array($start_time, $end_time)];
|
|
}
|
|
$data = WxpayLog::getList($whe, '*', 'id desc', $this->page);
|
|
$total_money = 0;
|
|
foreach ($data['list'] as &$value) {
|
|
$content = json_decode($value['content'], true);
|
|
|
|
$value['money'] = $content['total_fee'] / 100;
|
|
|
|
$total_money += $value['money'];
|
|
$user_info = User::field('nickname,headimg,mobile')->where(['id' => $value['user_id']])->find();
|
|
if ($user_info != null) {
|
|
$value['nickname'] = $user_info['nickname'];
|
|
$value['headimg'] = $user_info['headimg'];
|
|
$value['mobile'] = $user_info['mobile'];
|
|
} else {
|
|
$value['nickname'] ='';
|
|
$value['headimg'] = '';
|
|
$value['mobile'] = '';
|
|
}
|
|
}
|
|
View::assign('list', $data['list']);
|
|
View::assign('count', $data['count']);
|
|
View::assign('page', $data['page']);
|
|
View::assign('total_money', $total_money);
|
|
return View::fetch("Finance/recharge_list");
|
|
}
|
|
/**
|
|
* 无限令消费统计
|
|
*created by Admin at 2022/12/30 9:14
|
|
*/
|
|
public function infinite_list()
|
|
{
|
|
$user_id = trim(input('get.user_id'));
|
|
$mobile = trim(input('get.mobile'));
|
|
$where = [];
|
|
if ($user_id) {
|
|
$where[] = ['id', '=', $user_id];
|
|
}
|
|
if ($mobile) {
|
|
$mobile = User::field('id')->where('mobile', '=', $mobile)->value('id');
|
|
$where[] = ['user_id', '=', $mobile];
|
|
}
|
|
$pageSize = 15;
|
|
$list = \app\common\model\Goods::where('type', 2)->where($where)
|
|
->paginate(['list_rows' => $pageSize, 'query' => request()->param()]);
|
|
// dd($list);field('user_id,sum(goodslist_money) as goods_money,sum(goodslist_price) as goods_price,(sum(goodslist_price) - sum(goodslist_money)) as price,addtime')
|
|
$goods_price_total = 0;
|
|
$goods_money_total = 0;
|
|
$ks_money_total = 0;
|
|
foreach ($list as $value) {
|
|
$goods_price = OrderList::where('order_type', 2)
|
|
->where('goods_id', $value['id'])
|
|
->count();
|
|
$goods_money = OrderList::where('order_type', 2)
|
|
->where('goods_id', $value['id'])
|
|
->sum('goodslist_money');
|
|
$value['goods_price'] = $goods_price * $value['price'];
|
|
$value['goods_money'] = $goods_money;
|
|
$value['ks_money'] = $value['goods_price'] - $goods_money;
|
|
|
|
$goods_price_total += $value['goods_price'];
|
|
$goods_money_total += $goods_money;
|
|
$ks_money_total += $value['ks_money'];
|
|
}
|
|
$total_money[1]['goods_price_total'] = $goods_price_total;
|
|
$total_money[1]['goods_money_total'] = $goods_money_total;
|
|
$total_money[1]['ks_money_total'] = $ks_money_total;
|
|
|
|
|
|
// $list = OrderList::field('user_id,sum(goodslist_money) as goods_money,sum(goodslist_price) as goods_price,(sum(goodslist_price) - sum(goodslist_money)) as price,addtime')
|
|
// ->where($where)
|
|
// ->where('order_type',2)
|
|
// ->group('user_id')
|
|
// ->paginate(['list_rows' => $pageSize, 'query' => request()->param()]);
|
|
$page = $list->render();
|
|
$data['list'] = $list->toArray()['data'];
|
|
$data['count'] = $list->total();
|
|
$data['last_page'] = $list->toArray()['last_page'];
|
|
$data['page'] = $page;
|
|
// return $data;
|
|
// foreach ($data['list'] as &$value) {
|
|
// $user_info = User::field('nickname,headimg,mobile')->where(['id' => $value['user_id']])->find();
|
|
// $value['nickname'] = $user_info['nickname'];
|
|
// $value['headimg'] = $user_info['headimg'];
|
|
// $value['mobile'] = $user_info['mobile'];
|
|
// }
|
|
View::assign('list', $data['list']);
|
|
View::assign('count', $data['count']);
|
|
View::assign('page', $data['page']);
|
|
View::assign('total_money', $total_money);
|
|
return View::fetch("Finance/infinite_list");
|
|
}
|
|
}
|