|
@@ -173,6 +173,7 @@ class IndexController extends Controller
|
|
|
if (!Admin::isAdministrator() && !Admin::isNormalAdministrator()) {
|
|
|
$area_ids = AdminUser::getAreaIdsByAdminId($admin_id);
|
|
|
$profit_statistics = Statistic::query()
|
|
|
+ ->where(AdminMerchant::getMerchantWhere())
|
|
|
->where('slug', Statistic::SLUG_PROFIT_STATIC)
|
|
|
->where('date', '>', $profit_statistic_date_start)
|
|
|
->where('date', '<', $profit_statistic_date_end)
|
|
@@ -208,6 +209,7 @@ class IndexController extends Controller
|
|
|
|
|
|
// 其他均走下面 按照区域id查询
|
|
|
$profit_statistics = Statistic::query()
|
|
|
+ ->where(AdminMerchant::getMerchantWhere())
|
|
|
->where('slug', Statistic::SLUG_PROFIT_STATIC)
|
|
|
->where('date', '>', $profit_statistic_date_start)
|
|
|
->where('date', '<', $profit_statistic_date_end)
|
|
@@ -244,6 +246,7 @@ class IndexController extends Controller
|
|
|
{
|
|
|
if (empty($days)) return $this->error('缺少参数');
|
|
|
$newOrders = Statistic::query()
|
|
|
+ ->where(AdminMerchant::getMerchantWhere())
|
|
|
->filter($statisticFilter);
|
|
|
|
|
|
$admin_id = Admin::user()->id;
|
|
@@ -427,11 +430,11 @@ class IndexController extends Controller
|
|
|
public function profitChart(Request $request, OrderFilter $orderFilter, RechargeOrderFilter $rechargeOrderFilter, CardRidingOrderFilter $cardRidingOrderFilter, DepositCardOrderFilter $depositCardOrderFilter, StatisticFilter $statisticFilter)
|
|
|
{
|
|
|
$days = $request->get('days') ?? '';
|
|
|
- $ordersChart = $this->profitPolygonalChart($days, $orderFilter, Order::query());
|
|
|
- $ordersDispatchMoneyChart = $this->profitPolygonalChart($days, $orderFilter, Order::query(), 'dispatch_money');
|
|
|
- $rechargeOrdersChart = $this->profitPolygonalChart($days, $rechargeOrderFilter, RechargeOrder::query());
|
|
|
- $cardRidingOrdersChart = $this->profitPolygonalChart($days, $cardRidingOrderFilter, CardRidingOrder::query());
|
|
|
- $depositCardOrdersChart = $this->profitPolygonalChart($days, $depositCardOrderFilter, DepositCardOrder::query());
|
|
|
+ $ordersChart = $this->profitPolygonalChart($days, $orderFilter, Order::query()->where(AdminMerchant::getMerchantWhere()));
|
|
|
+ $ordersDispatchMoneyChart = $this->profitPolygonalChart($days, $orderFilter, Order::query()->where(AdminMerchant::getMerchantWhere()), 'dispatch_money');
|
|
|
+ $rechargeOrdersChart = $this->profitPolygonalChart($days, $rechargeOrderFilter, RechargeOrder::query()->where(AdminMerchant::getMerchantWhere()));
|
|
|
+ $cardRidingOrdersChart = $this->profitPolygonalChart($days, $cardRidingOrderFilter, CardRidingOrder::query()->where(AdminMerchant::getMerchantWhere()));
|
|
|
+ $depositCardOrdersChart = $this->profitPolygonalChart($days, $depositCardOrderFilter, DepositCardOrder::query()->where(AdminMerchant::getMerchantWhere()));
|
|
|
$total = [];
|
|
|
foreach ($ordersChart as $k => $v) {
|
|
|
$total[] = [
|
|
@@ -484,6 +487,7 @@ class IndexController extends Controller
|
|
|
{
|
|
|
|
|
|
$newUsers = User::query()
|
|
|
+ ->where(AdminMerchant::getMerchantWhere())
|
|
|
->filter($userFilter)
|
|
|
->where('is_card_certified', User::CARD_OK);
|
|
|
|
|
@@ -619,6 +623,7 @@ class IndexController extends Controller
|
|
|
public function orderChart($days, $orderFilter, $dispatch_money = false)
|
|
|
{
|
|
|
$newOrders = Order::query()
|
|
|
+ ->where(AdminMerchant::getMerchantWhere())
|
|
|
->filter($orderFilter)
|
|
|
->where('status', Order::STATUS_COMPLETE_ORDER);
|
|
|
if ($dispatch_money) {
|
|
@@ -743,6 +748,7 @@ class IndexController extends Controller
|
|
|
public function dayRentOrderChart($days, $orderRentFilter, $dispatch_money = false)
|
|
|
{
|
|
|
$newOrders = OrderRent::query()
|
|
|
+ ->where(AdminMerchant::getMerchantWhere())
|
|
|
->filter($orderRentFilter)
|
|
|
->where('status', OrderRent::STATUS_COMPLETE_ORDER);
|
|
|
|
|
@@ -869,6 +875,7 @@ class IndexController extends Controller
|
|
|
$days = $request->get('days') ?? '';
|
|
|
if (empty($days)) return $this->error('缺少参数');
|
|
|
$order = Order::query()
|
|
|
+ ->where(AdminMerchant::getMerchantWhere())
|
|
|
->filter($orderFilter)
|
|
|
->where('status', Order::STATUS_COMPLETE_ORDER)
|
|
|
->with(['users']);
|
|
@@ -935,6 +942,7 @@ class IndexController extends Controller
|
|
|
$days = $request->get('days') ?? '';
|
|
|
if (empty($days)) return $this->error('缺少参数');
|
|
|
$order = OrderRent::query()
|
|
|
+ ->where(AdminMerchant::getMerchantWhere())
|
|
|
->filter($orderRentFilter)
|
|
|
->where('status', OrderRent::STATUS_COMPLETE_ORDER)
|
|
|
->with(['users']);
|
|
@@ -998,7 +1006,7 @@ class IndexController extends Controller
|
|
|
*/
|
|
|
public function bikeProfitRanking(BikeFilter $bikeFilter)
|
|
|
{
|
|
|
- $bikes = Bike::query()->filter($bikeFilter);
|
|
|
+ $bikes = Bike::query()->where(AdminMerchant::getMerchantWhere())->filter($bikeFilter);
|
|
|
$admin_id = Admin::user()->id;
|
|
|
|
|
|
if (!Admin::isAdministrator()) {
|
|
@@ -1059,9 +1067,9 @@ class IndexController extends Controller
|
|
|
$yesterday = Carbon::yesterday();
|
|
|
$today = Carbon::today();
|
|
|
|
|
|
- $yesterdayNewUser = User::query();
|
|
|
- $todayNewUser = User::query();
|
|
|
- $total = User::query();
|
|
|
+ $yesterdayNewUser = User::query()->where(AdminMerchant::getMerchantWhere());
|
|
|
+ $todayNewUser = User::query()->where(AdminMerchant::getMerchantWhere());
|
|
|
+ $total = User::query()->where(AdminMerchant::getMerchantWhere());
|
|
|
|
|
|
if (!empty($area_id)) {
|
|
|
$yesterdayNewUser = $yesterdayNewUser->where('register_area_id', $area_id);
|
|
@@ -1154,12 +1162,12 @@ class IndexController extends Controller
|
|
|
$yesterday = Carbon::yesterday();
|
|
|
$today = Carbon::today();
|
|
|
|
|
|
- $yesterdayOrderNum = Order::query();
|
|
|
- $todayOrderNum = Order::query();
|
|
|
- $total = Order::query();
|
|
|
- $yesterdayOrderRentNum = OrderRent::query();
|
|
|
- $todayOrderRentNum = OrderRent::query();
|
|
|
- $totalOrderRent = OrderRent::query();
|
|
|
+ $yesterdayOrderNum = Order::query()->where(AdminMerchant::getMerchantWhere());
|
|
|
+ $todayOrderNum = Order::query()->where(AdminMerchant::getMerchantWhere());
|
|
|
+ $total = Order::query()->where(AdminMerchant::getMerchantWhere());
|
|
|
+ $yesterdayOrderRentNum = OrderRent::query()->where(AdminMerchant::getMerchantWhere());
|
|
|
+ $todayOrderRentNum = OrderRent::query()->where(AdminMerchant::getMerchantWhere());
|
|
|
+ $totalOrderRent = OrderRent::query()->where(AdminMerchant::getMerchantWhere());
|
|
|
|
|
|
if (!empty($area_id)) {
|
|
|
$yesterdayOrderNum = $yesterdayOrderNum->where('area_id', $area_id);
|
|
@@ -1252,9 +1260,9 @@ class IndexController extends Controller
|
|
|
$yesterday = Carbon::yesterday();
|
|
|
$today = Carbon::today();
|
|
|
|
|
|
- $yesterdayProfit = Order::query();
|
|
|
- $todayProfit = Order::query();
|
|
|
- $total = Order::query();
|
|
|
+ $yesterdayProfit = Order::query()->where(AdminMerchant::getMerchantWhere());
|
|
|
+ $todayProfit = Order::query()->where(AdminMerchant::getMerchantWhere());
|
|
|
+ $total = Order::query()->where(AdminMerchant::getMerchantWhere());
|
|
|
|
|
|
if (!empty($area_id)) {
|
|
|
$yesterdayProfit = $yesterdayProfit->where('area_id', $area_id);
|
|
@@ -1372,7 +1380,7 @@ class IndexController extends Controller
|
|
|
->limit(10)
|
|
|
->get()
|
|
|
->toArray();
|
|
|
- $total = UserPhoneDetail::query()->count('id');
|
|
|
+ $total = UserPhoneDetail::query()->where(AdminMerchant::getMerchantWhere())->count('id');
|
|
|
if (!empty($platform)) {
|
|
|
foreach ($platform as &$v) {
|
|
|
// $v['percent'] = round($v['number'] / $total * 100 ,2) .'%';
|
|
@@ -1403,7 +1411,7 @@ class IndexController extends Controller
|
|
|
public function heatMap(OrderFilter $orderFilter)
|
|
|
{
|
|
|
$today = Carbon::today();
|
|
|
- $order = Order::query()->filter($orderFilter)->where('created_at', '>', $today)->get();
|
|
|
+ $order = Order::query()->where(AdminMerchant::getMerchantWhere())->filter($orderFilter)->where('created_at', '>', $today)->get();
|
|
|
$data1 = [];
|
|
|
if (!empty($order)) {
|
|
|
foreach ($order as $v) {
|