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

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