update: optimize commission calculation

This commit is contained in:
tokumeikoi 2022-02-07 15:35:40 +08:00
parent 9dc44c0e1d
commit 1d5a493ef1
4 changed files with 18 additions and 3 deletions

View File

@ -56,9 +56,9 @@ class V2boardStatistics extends Command
->whereNotIn('status', [0, 2]); ->whereNotIn('status', [0, 2]);
$orderCount = $builder->count(); $orderCount = $builder->count();
$orderAmount = $builder->sum('total_amount'); $orderAmount = $builder->sum('total_amount');
$builder = $builder->where('commission_balance', '!=', 0); $builder = $builder->where('actual_commission_balance', '!=', 0);
$commissionCount = $builder->count(); $commissionCount = $builder->count();
$commissionAmount = $builder->sum('commission_balance'); $commissionAmount = $builder->sum('actual_commission_balance');
$data = [ $data = [
'order_count' => $orderCount, 'order_count' => $orderCount,
'order_amount' => $orderAmount, 'order_amount' => $orderAmount,

View File

@ -5,6 +5,7 @@ namespace App\Http\Controllers\Admin;
use App\Http\Requests\Admin\OrderAssign; use App\Http\Requests\Admin\OrderAssign;
use App\Http\Requests\Admin\OrderUpdate; use App\Http\Requests\Admin\OrderUpdate;
use App\Http\Requests\Admin\OrderFetch; use App\Http\Requests\Admin\OrderFetch;
use App\Models\CommissionLog;
use App\Services\OrderService; use App\Services\OrderService;
use App\Services\UserService; use App\Services\UserService;
use App\Utils\Helper; use App\Utils\Helper;
@ -36,6 +37,19 @@ class OrderController extends Controller
} }
} }
public function detail(Request $request)
{
$order = Order::find($request->input('id'));
if (!$order) abort(500, '订单不存在');
$order['commission_log'] = CommissionLog::where('trade_no', $order->trade_no)->get();
if ($order->surplus_order_ids) {
$order['surplus_orders'] = Order::whereIn('id', $order->surplus_order_ids)->get();
}
return response([
'data' => $order
]);
}
public function fetch(OrderFetch $request) public function fetch(OrderFetch $request)
{ {
$current = $request->input('current') ? $request->input('current') : 1; $current = $request->input('current') ? $request->input('current') : 1;

View File

@ -68,6 +68,7 @@ class AdminRoute
$router->post('/order/assign', 'Admin\\OrderController@assign'); $router->post('/order/assign', 'Admin\\OrderController@assign');
$router->post('/order/paid', 'Admin\\OrderController@paid'); $router->post('/order/paid', 'Admin\\OrderController@paid');
$router->post('/order/cancel', 'Admin\\OrderController@cancel'); $router->post('/order/cancel', 'Admin\\OrderController@cancel');
$router->post('/order/detail', 'Admin\\OrderController@detail');
// User // User
$router->get ('/user/fetch', 'Admin\\UserController@fetch'); $router->get ('/user/fetch', 'Admin\\UserController@fetch');
$router->post('/user/update', 'Admin\\UserController@update'); $router->post('/user/update', 'Admin\\UserController@update');

File diff suppressed because one or more lines are too long