ztt 9 months ago
parent e706d91c9d
commit dee8e4f863
  1. 20
      app/api/service/statistics/OrderData.php
  2. 31
      app/api/service/statistics/RefundData.php
  3. 31
      app/api/service/statistics/UserData.php

@ -3,9 +3,11 @@
namespace app\api\service\statistics;
use app\api\model\Order;
use app\api\model\user\IdentityOrder;
use app\common\enum\order\OrderStatus;
use app\common\enum\order\OrderStatus as OrderStatusEnum;
use app\common\enum\order\PayStatus as PayStatusEnum;
use app\common\enum\user\IdentityEnum;
use app\common\service\BaseService;
class OrderData extends BaseService
@ -27,15 +29,15 @@ class OrderData extends BaseService
//下单总数
"orderCount" => $this->getPayOrderTotal($startDate, $endDate),
//下单人数
'orderPayUser' => $this->getConsumeUsers($startDate, $endDate),
'orderPayUser' => $this->getConsumeUsers(),
//订单成本金额
'orderCostMoney' => 0,
//预估利益
'orderInterest' => 0,
//付费会员数
'payMemberCount' => 0,
'payMemberCount' => $this->getPayCount(IdentityEnum::MEMBER, $startDate, $endDate),
//付费分销商数
'payDealerCount' => 0
'payDealerCount' => $this->getPayCount(IdentityEnum::DEALER, $startDate, $endDate)
];
}
@ -108,5 +110,17 @@ class OrderData extends BaseService
->count();
}
/**
* 付费会员数
*/
public function getPayCount($order_type, $startDate = null, $endDate = null) : int {
$query = new IdentityOrder();
if(!empty($startDate) && !empty($endDate)) {
$query->where('create_time', '>=', strtotime($startDate))
->where('create_time', '<', strtotime($endDate) + 86400);
}
return $query->where('order_type', '=', $order_type)->count();
}
}

@ -3,6 +3,7 @@
namespace app\api\service\statistics;
use app\api\model\OrderRefund;
use app\common\enum\order\refund\RefundStatus;
use app\common\service\BaseService;
class RefundData extends BaseService
@ -18,8 +19,34 @@ class RefundData extends BaseService
public function getRefundData($startDate = null, $endDate = null): array
{
return [
'refundCount' => 0,
'refundTotalMoney' => 0
'refundCount' => $this->getRefundCount($startDate, $endDate),
'refundTotalMoney' => $this->getRefundTotalMoney($startDate, $endDate)
];
}
/**
* 退款总数
*/
public function getRefundCount($startDate = null, $endDate = null): int
{
$query = $this->refundModel;
if(!empty($startDate) && !empty($endDate)) {
$query->where('create_time', '>=', strtotime($startDate))
->where('create_time', '<', strtotime($endDate) + 86400);
}
return $query->where('status', '=', RefundStatus::COMPLETED)->count();
}
/**
* 退款总金额
*/
public function getRefundTotalMoney($startDate = null, $endDate = null): float {
$query = $this->refundModel;
if(!empty($startDate) && !empty($endDate)) {
$query->where('create_time', '>=', strtotime($startDate))
->where('create_time', '<', strtotime($endDate) + 86400);
}
// 总销售额
return $query->where('status', '=', RefundStatus::COMPLETED)->sum('refund_money');
}
}

@ -2,6 +2,7 @@
namespace app\api\service\statistics;
use app\api\model\GoodsBrowseLog;
use app\api\model\User;
use app\common\service\BaseService;
@ -18,8 +19,36 @@ class UserData extends BaseService
{
return [
'visitorCount' => 0,
'viewCount' => 0,
'viewCount' => $this->getViewCount($startDate, $endDate),
'newUserCount' => 0,
];
}
/**
* 用户访问总数
*/
public function getVisitorCount() {
}
/**
* 用户浏览总数
*/
public function getViewCount($startDate = null, $endDate = null): string
{
$query = new GoodsBrowseLog();
if(!empty($startDate) && !empty($endDate)) {
$query->where('create_time', '>=', strtotime($startDate))
->where('create_time', '<', strtotime($endDate) + 86400);
}
$value = $query->group('user_id')->count();
return number_format($value);
}
/**
* 新用户数量
*/
public function getNewUserCount() {
}
}
Loading…
Cancel
Save