This commit is contained in:
mkm 2024-06-18 10:12:40 +08:00
commit 17504629c2

View File

@ -44,23 +44,21 @@ class WorkbenchLogic extends BaseLogic
public static function index($params) public static function index($params)
{ {
$data = []; $data = [];
$startTime = $params['start_time']; $startTimeDefault = date('Y-m-d',time());
$endTime = $params['end_time']; $endTimeDefault =date('Y-m-d', strtotime($startTimeDefault) + 86400);
$endTime = date('Y-m-d', strtotime($endTime) + 86400);
$dateDiff = (new \DateTime($endTime))->diff(new \DateTime($startTime));
$orderLogic = new StoreOrderLogic(); $orderLogic = new StoreOrderLogic();
//订单总金额 //订单总金额
$data['order_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTime, $endTime); $data['order_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTimeDefault, $endTimeDefault);
//余额支付总金额 //余额支付总金额
$data['balance_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTime, $endTime, ['pay_type' => PayEnum::BALANCE_PAY]); $data['balance_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTimeDefault, $endTimeDefault, ['pay_type' => PayEnum::BALANCE_PAY]);
//线下收银总金额 //线下收银总金额
$data['cashier_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTime, $endTime, ['shipping_type' => 3]); $data['cashier_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTimeDefault, $endTimeDefault, ['shipping_type' => 3]);
//现金收银总金额 //现金收银总金额
$data['cash_amount'] = StoreCashFinanceFlow::where('store_id', $params['store_id'])->whereBetweenTime('create_time', $startTime, $endTime)->sum('cash_price'); $data['cash_amount'] = StoreCashFinanceFlow::where('store_id', $params['store_id'])->whereBetweenTime('create_time', $startTimeDefault, $endTimeDefault)->sum('cash_price');
//核销订单金额 //核销订单金额
$data['verify_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTime, $endTime, ['shipping_type' => 2]); $data['verify_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTimeDefault, $endTimeDefault, ['shipping_type' => 2]);
//门店收益金额 //门店收益金额
$data['income_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTime, $endTime, [], 'profit'); $data['income_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTimeDefault, $endTimeDefault, [], 'profit');
//门店收款金额 //门店收款金额
$data['receipt_amount'] = UserRecharge::where([ $data['receipt_amount'] = UserRecharge::where([
'store_id'=>$params['store_id'], 'store_id'=>$params['store_id'],
@ -69,9 +67,14 @@ class WorkbenchLogic extends BaseLogic
//门店成交用户数 //门店成交用户数
$data['user_number'] = StoreOrder::where('store_id', $params['store_id']) $data['user_number'] = StoreOrder::where('store_id', $params['store_id'])
->where('paid', 1) ->where('paid', 1)
->whereBetweenTime('pay_time', $startTime, $endTime) ->whereBetweenTime('pay_time', $startTimeDefault, $endTimeDefault)
->group('uid') ->group('uid')
->count(); ->count();
$startTime = $params['start_time'];
$endTime = $params['end_time'];
$endTime = date('Y-m-d', strtotime($endTime) + 86400);
$dateDiff = (new \DateTime($endTime))->diff(new \DateTime($startTime));
if ($dateDiff->days == 1) { if ($dateDiff->days == 1) {
$group = 'HOUR(pay_time)'; $group = 'HOUR(pay_time)';
$i = 0; $i = 0;