修改首页订单统计

This commit is contained in:
luofei 2024-06-08 14:17:05 +08:00
parent 4c02524641
commit 7cd251c4ee

View File

@ -18,6 +18,7 @@ namespace app\store\logic;
use app\common\enum\PayEnum;
use app\common\logic\BaseLogic;
use app\common\logic\store_order\StoreOrderLogic;
use app\common\model\store_cash_finance_flow\StoreCashFinanceFlow;
use app\common\model\store_order\StoreOrder;
use app\common\service\ConfigService;
use app\common\service\FileService;
@ -30,13 +31,7 @@ use app\common\service\FileService;
*/
class WorkbenchLogic extends BaseLogic
{
/**
* @notes 工作套
* @param $adminInfo
* @return array
* @author 乔峰
* @date 2021/12/29 15:58
*/
public static function index($params)
{
$data = [];
@ -48,11 +43,17 @@ class WorkbenchLogic extends BaseLogic
throw new \Exception('时间范围不能超过一年');
}
$orderLogic = new StoreOrderLogic();
//订单总金额
$data['order_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTime, $endTime);
//余额支付总金额
$data['balance_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTime, $endTime, ['pay_type' => PayEnum::BALANCE_PAY]);
//线下收银总金额
$data['cashier_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTime, $endTime, ['shipping_type' => 3]);
$data['delivery_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTime, $endTime, ['shipping_type' => 1]);
//现金收银总金额
$data['cash_amount'] = StoreCashFinanceFlow::where('store_id', $params['store_id'])->whereBetweenTime('create_time', $startTime, $endTime)->sum('cash_price');
//核销订单金额
$data['verify_amount'] = $orderLogic->storeOrderSumByDate($params['store_id'], $startTime, $endTime, ['shipping_type' => 2]);
//门店成交用户数
$data['user_number'] = StoreOrder::where('store_id', $params['store_id'])
->where('paid', 1)
->whereBetweenTime('create_time', $startTime, $endTime)
@ -122,6 +123,17 @@ class WorkbenchLogic extends BaseLogic
'user_number' => array_values($userListTmp)
]
];
$data['order_list'] = StoreOrder::with('user')->where('store_id', $params['store_id'])
->where('paid', 1)
->whereBetweenTime('create_time', $startTime, $endTime)
->order('create_time', 'desc')
->limit(10)
->select()->toArray();
$data['pay_type'] = [
['name' => '线上收银订单', 'value' => bcsub($data['order_amount'], bcadd($data['verify_amount'], $data['cash_amount'], 2), 2)],
['name' => '核销订单', 'value' => $data['verify_amount']],
['name' => '现金收银订单', 'value' => $data['cash_amount']],
];
return $data;
}