60 lines
1.7 KiB
PHP
60 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace app\api\logic;
|
|
|
|
use app\common\basics\Logic;
|
|
use app\common\model\billions\Billions;
|
|
|
|
class BillionsLogic extends Logic
|
|
{
|
|
// 获取数据
|
|
public static function lists($page, $size, $state, $user_id)
|
|
{
|
|
$where[] = ['b.user_id', '=', $user_id];
|
|
if ($state == 1) {
|
|
$where[] = ['b.state', '>=', 1];
|
|
} else {
|
|
$where[] = ['b.state', '=', 0];
|
|
}
|
|
|
|
$list = Billions::alias('b')->where($where)
|
|
->join('order o', 'o.id = b.order_id')
|
|
->join('goods g', 'g.id = b.goods_id')
|
|
->join('shop s', 's.id = b.shop_id')
|
|
->field('b.*, o.order_sn, s.name')
|
|
->page($page,$size)->select();
|
|
|
|
$count = Billions::alias('b')->where($where)
|
|
->alias('b')
|
|
->join('order o', 'o.id = b.order_id')
|
|
->join('goods g', 'g.id = b.goods_id')
|
|
->join('shop s', 's.id = b.shop_id')
|
|
->count();
|
|
|
|
// 消费订单笔数
|
|
$historyOrder = Billions::where('user_id', $user_id)->count();
|
|
|
|
// 商家最高补贴
|
|
$highSubsidy = Billions::where('user_id', $user_id)->sum('order_price', false);
|
|
|
|
$more = is_more($count, $page, $size); //是否有下一页
|
|
|
|
$data = [
|
|
'list' => $list,
|
|
'page_no' => $page,
|
|
'page_size' => $size,
|
|
'count' => $count,
|
|
'more' => $more,
|
|
'historyOrder' => $historyOrder,
|
|
'highSubsidy' => $highSubsidy
|
|
];
|
|
return $data;
|
|
}
|
|
|
|
// 获取排名
|
|
public static function getRanking($billions_id){
|
|
$where[] = ['billions_id', '<=', $billions_id];
|
|
$where[] = ['state', '=', 0];
|
|
return Billions::where($where)->count();
|
|
}
|
|
} |