初始化项目
This commit is contained in:
@@ -0,0 +1,131 @@
|
||||
<?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\partners;
|
||||
|
||||
use app\common\model\partners\Order as OrderModel;
|
||||
|
||||
/**
|
||||
* 合作商订单
|
||||
* Class Order
|
||||
* @package app\store\model\partners
|
||||
*/
|
||||
class Order extends OrderModel
|
||||
{
|
||||
/**
|
||||
* 获取余额变动明细列表
|
||||
* @param array $param
|
||||
* @return mixed
|
||||
*/
|
||||
public function getList(array $param = [])
|
||||
{
|
||||
// 设置查询条件
|
||||
$filter = $this->getFilter($param);
|
||||
// 先查询总金额
|
||||
$totalPayPrice = $this->with(['goods.images.file', 'partners'])
|
||||
->alias('order')
|
||||
->field('order.*')
|
||||
->where($filter)
|
||||
->sum('order.total_pay_price');
|
||||
// 获取列表数据
|
||||
$list = $this->with(['goods.images.file', 'partners'])
|
||||
->alias('order')
|
||||
->field('order.*')
|
||||
->where($filter)
|
||||
->order(['order.create_time' => 'desc'])
|
||||
->paginate(15);
|
||||
// 获取数据列表
|
||||
return [
|
||||
'list' => $list,
|
||||
'total_money' => $totalPayPrice,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置查询条件
|
||||
* @param array $param
|
||||
* @return array
|
||||
*/
|
||||
private function getFilter(array $param): array
|
||||
{
|
||||
// 设置默认的检索数据
|
||||
$params = $this->setQueryDefaultValue($param, [
|
||||
'partners_id' => 0, // 合作商ID
|
||||
'search' => '', // 用户昵称
|
||||
'goods_no' => '', // 商品编码
|
||||
'oil_status' => -1, // 分油状态
|
||||
'use_status' => -1, // 使用状态
|
||||
'betweenTime' => [] // 起止时间
|
||||
]);
|
||||
// 检索查询条件
|
||||
$filter = [];
|
||||
// 合作商ID
|
||||
$params['partners_id'] > 0 && $filter[] = ['order.partners_id', '=', $params['partners_id']];
|
||||
// 用户昵称
|
||||
!empty($params['search']) && $filter[] = ['order.mobile', 'like', "%{$params['search']}%"];
|
||||
// 商品编码
|
||||
!empty($params['goods_no']) && $filter[] = ['order.goods_no', 'like', "%{$params['goods_no']}%"];
|
||||
// 分油状态
|
||||
$params['oil_status'] > -1 && $filter[] = ['oil_status', '=', (int)$params['oil_status']];
|
||||
// 使用状态
|
||||
$params['use_status'] > -1 && $filter[] = ['use_status', '=', (int)$params['use_status']];
|
||||
// 起止时间
|
||||
if (!empty($params['betweenTime'])) {
|
||||
$times = between_time($params['betweenTime']);
|
||||
$filter[] = ['order.create_time', '>=', strtotime(date('Y-m-d',$times['start_time']))];
|
||||
$filter[] = ['order.create_time', '<', strtotime(date('Y-m-d',$times['end_time'])) + 86400];
|
||||
}
|
||||
return $filter;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全部记录
|
||||
* @param array $param
|
||||
* @return \think\Collection
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getAll(array $param = [])
|
||||
{
|
||||
return $this->where($param)
|
||||
->order(['order_id' => 'asc'])
|
||||
->select();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取某天的总销售额
|
||||
* @param null $startDate
|
||||
* @param null $endDate
|
||||
* @param array $partners
|
||||
* @return float
|
||||
*/
|
||||
public function getOrderTotalPrice($startDate = null, $endDate = null,$partners=[]): 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($partners)) {
|
||||
$filter[] = ['partners_id', '=', $partners['partners_id']];
|
||||
}
|
||||
// 总销售额
|
||||
return $query->where('oil_status_zsy', '=', 2)
|
||||
->where($filter)
|
||||
->sum('total_price');
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user