117 lines
3.4 KiB
PHP
117 lines
3.4 KiB
PHP
<?php
|
|
|
|
namespace app\admin\logic\finance;
|
|
|
|
use app\common\basics\Logic;
|
|
use app\common\model\billions\Billions;
|
|
use app\common\model\goods\Goods;
|
|
use app\common\model\order\Order;
|
|
use app\common\model\RechargeOrder;
|
|
use app\common\model\shop\Shop;
|
|
use app\common\model\UserBillionsRechargeBalance;
|
|
use app\common\server\UrlServer;
|
|
|
|
class BillionsLogic extends Logic
|
|
{
|
|
static protected $status_str = [
|
|
'0'=>'未补满',
|
|
'1'=>'手动结束',
|
|
'2'=>'自动结束',
|
|
'3'=>'强制结束'
|
|
];
|
|
|
|
static protected $shop_type = [
|
|
'1'=>'商品订单',
|
|
'2'=>'充值订单',
|
|
'3'=>'返充',
|
|
'4'=>'本地生活支付'
|
|
];
|
|
public static function lists($get)
|
|
{
|
|
$where = [];
|
|
if (!empty($get['search_key']) && !empty($get['keyword'])) {
|
|
$keyword = $get['keyword'];
|
|
if ($get['search_key'] == 'nickname') {
|
|
$where[] = ['u.nickname', 'like', '%' . $keyword . '%'];
|
|
}
|
|
}
|
|
|
|
if (isset($get['state']) && $get['state'] != '') {
|
|
$where[] = ['b.state', '=', $get['state']];
|
|
}
|
|
|
|
$lists = Billions::alias('b')
|
|
->join('user u', 'b.user_id = u.id')
|
|
->where($where)
|
|
->order('billions_id', 'desc')
|
|
->group('user_id')
|
|
->field('b.*, u.id, u.nickname, u.avatar,u.sn')
|
|
->paginate([
|
|
'page' => $get['page'] ?? 1,
|
|
'list_rows' => $get['limit'] ?? 10,
|
|
'var_page' => 'page'
|
|
])->toArray();
|
|
|
|
|
|
foreach ($lists['data'] as &$v) {
|
|
$v['avatar'] = UrlServer::getFileUrl($v['avatar']);
|
|
$v['price_all'] = Billions::where('user_id',$v['user_id'])->sum('order_price');
|
|
$v['subsidy_all'] = Billions::where('user_id',$v['user_id'])->sum('subsidy_price');
|
|
}
|
|
|
|
return ['count' => $lists['total'],'lists' => $lists['data']];
|
|
}
|
|
|
|
|
|
public static function userList($get){
|
|
|
|
$where = [];
|
|
if (isset($get['start_time']) && $get['start_time'] && isset($get['end_time']) && $get['end_time']) {
|
|
$where[] = ['dtime', 'between', [$get['start_time'], $get['end_time']]];
|
|
}
|
|
if (isset($get['order_type']) && $get['order_type'] != '') {
|
|
$where[] = ['type', '=', $get['order_type']];
|
|
}
|
|
if (isset($get['state']) && $get['state'] != '') {
|
|
$where[] = ['state', '=', $get['state']];
|
|
}
|
|
|
|
|
|
$lists = Billions::where('user_id',$get['user_id'])
|
|
->field('*')
|
|
->where($where)
|
|
->paginate([
|
|
'page' => $get['page'] ?? 1,
|
|
'list_rows' => $get['limit'] ?? 10,
|
|
'var_page' => 'page'
|
|
])
|
|
->toArray();
|
|
|
|
foreach ($lists['data'] as &$item){
|
|
|
|
$item['state'] = self::$status_str[$item['state']];
|
|
$item['type'] = self::$shop_type[$item['type']];
|
|
}
|
|
|
|
return ['count' => $lists['total'],'lists' => $lists['data']];
|
|
|
|
|
|
}
|
|
|
|
public static function summary(){
|
|
|
|
$un_price = Billions::where('state',0)->sum('subsidy_price');
|
|
$art_price = Billions::where('state',1)->sum('subsidy_price');
|
|
$auto_price = Billions::where('state',2)->sum('subsidy_price');
|
|
|
|
return [
|
|
'un_price'=>$un_price,
|
|
'art_price'=>$art_price,
|
|
'auto_price'=>$auto_price
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
} |