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)
{
$data = [];
$startTime = $params['start_time'];
$endTime = $params['end_time'];
$endTime = date('Y-m-d', strtotime($endTime) + 86400);
$dateDiff = (new \DateTime($endTime))->diff(new \DateTime($startTime));
$startTimeDefault = date('Y-m-d',time());
$endTimeDefault =date('Y-m-d', strtotime($startTimeDefault) + 86400);
$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([
'store_id'=>$params['store_id'],
@ -69,9 +67,14 @@ class WorkbenchLogic extends BaseLogic
//门店成交用户数
$data['user_number'] = StoreOrder::where('store_id', $params['store_id'])
->where('paid', 1)
->whereBetweenTime('pay_time', $startTime, $endTime)
->whereBetweenTime('pay_time', $startTimeDefault, $endTimeDefault)
->group('uid')
->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) {
$group = 'HOUR(pay_time)';
$i = 0;