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

10 months ago
<?php
namespace app\api\service\statistics;
10 months ago
use app\api\model\dealer\Order;
10 months ago
use app\common\library\helper;
10 months ago
use app\common\service\BaseService;
class CommissionData extends BaseService
{
10 months ago
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
10 months ago
{
return [
10 months ago
'settleTotalMoney' => $this->getSettTotalMoney($startDate, $endDate),
'noSettleTotalMoney' => $this->getNoSettleTotalMoney($startDate, $endDate)
10 months ago
];
}
10 months ago
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);
}
10 months ago
}