You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
yanzong/app/api/service/statistics/CommissionData.php

49 lines
2.0 KiB

<?php
namespace app\api\service\statistics;
use app\api\model\dealer\Order;
use app\common\library\helper;
use app\common\service\BaseService;
class CommissionData extends BaseService
{
protected Order $dealerOrderModel;
public function initialize()
{
parent::initialize(); // TODO: Change the autogenerated stub
$this->dealerOrderModel = new Order();
}
public function getCommissionData($startDate = null, $endDate = null): array
{
return [
'settleTotalMoney' => $this->getSettTotalMoney($startDate, $endDate),
'noSettleTotalMoney' => $this->getNoSettleTotalMoney($startDate, $endDate)
];
}
public function getSettTotalMoney($startDate = null, $endDate = null) {
$filter = [];
if (!is_null($startDate) && !is_null($endDate)) {
$filter[] = ['create_time', '>=', strtotime($startDate)];
$filter[] = ['create_time', '<', strtotime($endDate) + 86400];
}
$first = $this->dealerOrderModel->where($filter)->where('is_settled','=', 1)->sum('first_money');
$two = $this->dealerOrderModel->where($filter)->where('is_settled','=', 1)->sum('second_money');
$three = $this->dealerOrderModel->where($filter)->where('is_settled','=', 1)->sum('third_money');
return helper::number2($first + $two + $three);
}
public function getNoSettleTotalMoney($startDate = null, $endDate = null) {
$filter = [];
if (!is_null($startDate) && !is_null($endDate)) {
$filter[] = ['create_time', '>=', strtotime($startDate)];
$filter[] = ['create_time', '<', strtotime($endDate) + 86400];
}
$first = $this->dealerOrderModel->where($filter)->where('is_settled','=', 0)->sum('first_money');
$two = $this->dealerOrderModel->where($filter)->where('is_settled','=', 0)->sum('second_money');
$three = $this->dealerOrderModel->where($filter)->where('is_settled','=', 0)->sum('third_money');
return helper::number2($first + $two + $three);
}
}