📖 File Reader
<?php
namespace app\admin\common;
use app\BaseController;
use think\facade\Db;
use think\facade\Session;
use think\facade\View;
class Common_index extends BaseController
{
/**
* 订单数据统计
* @param $time_month 开始时间
* @param $time_month2 结束时间
*/
static function order_statistics($time_month,$time_month2,$admin_info='')
{
$where = 1;
/*角色权限*/
$admin_role_type = $admin_info["role_type"];
$admin_shop_id = $admin_info["shop_id"];
if($admin_role_type == 2){ //店铺管理员
$where .= " and shop_id = $admin_shop_id";
}
$where .= " and is_chai = 0";
//订单数量
$order_count = db::name("order")->where("add_time >= $time_month and add_time < $time_month2 and $where")->count();
//已付款订单数量
$order_pay_count = db::name("order")->where("add_time >= $time_month and add_time < $time_month2 and state in (1,2,3) and $where")->count();
//待付款订单数量
$order_dpay_count = db::name("order")->where("add_time >= $time_month and add_time < $time_month2 and state in (0,4) and $where")->count();
$data = [
'order_count'=>$order_count,
'order_pay_count'=>$order_pay_count,
'order_dpay_count'=>$order_dpay_count,
];
return $data;
}
}