初始化项目

This commit is contained in:
2026-09-01 22:15:50 +08:00
commit b5a26a8848
11217 changed files with 1710987 additions and 0 deletions
@@ -0,0 +1,97 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\store\model\merchant;
use app\common\model\merchant\MerchantOrder as MerchantOrderModel;
/**
* 代理商订单
* Class MerchantOrder
* @package app\store\model\merchant
*/
class MerchantOrder extends MerchantOrderModel
{
/**
* 获取余额变动明细列表
* @param array $param
* @return \think\Paginator
*/
public function getList(array $param = [])
{
// 设置查询条件
$filter = $this->getFilter($param);
// 获取列表数据
return $this->with(['user.avatar', 'goods.images.file', 'merchant'])
->alias('order')
->field('order.*')
->where($filter)
->leftJoin('user', 'user.user_id = order.user_id')
->order(['order.create_time' => 'desc'])
->paginate(15);
}
/**
* 设置查询条件
* @param array $param
* @return array
*/
private function getFilter(array $param): array
{
// 设置默认的检索数据
$params = $this->setQueryDefaultValue($param, [
'merchant_id' => 0, // 用户ID
'search' => '', // 用户昵称
'betweenTime' => [] // 起止时间
]);
// 检索查询条件
$filter = [];
// 用户ID
$params['merchant_id'] > 0 && $filter[] = ['order.merchant_id', '=', $params['merchant_id']];
// 用户昵称
!empty($params['search']) && $filter[] = ['user.mobile', 'like', "%{$params['search']}%"];
// 起止时间
if (!empty($params['betweenTime'])) {
$times = between_time($params['betweenTime']);
$filter[] = ['order.create_time', '>=', $times['start_time']];
$filter[] = ['order.create_time', '<', $times['end_time'] + 86400];
}
return $filter;
}
/**
* 获取某天的总销售额
* @param null $startDate
* @param null $endDate
* @param array $merchant
* @return float
*/
public function getOrderTotalPrice($startDate = null, $endDate = null,$merchant=[]): float
{
// 查询对象
$query = $this->getNewQuery();
$filter = [];
// 设置查询条件
if (!is_null($startDate) && !is_null($endDate)) {
$filter[] = ['create_time', '>=', strtotime($startDate)];
$filter[] = ['create_time', '<', strtotime($endDate) + 86400];
}
if(!empty($merchant)) {
$filter[] = ['merchant_id', '=', $merchant['merchant_id']];
}
// 总销售额
return $query->where('order_status', '=', 30)
->where($filter)
->sum('order_price');
}
}