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.
69 lines
2.4 KiB
69 lines
2.4 KiB
6 months ago
|
<?php
|
||
|
|
||
|
namespace app\store\model\user;
|
||
|
|
||
|
use app\common\model\user\IdentityOrder as IdentityOrderModel;
|
||
|
|
||
|
|
||
|
class IdentityOrder extends IdentityOrderModel
|
||
|
{
|
||
|
/**
|
||
|
* 获取订单列表
|
||
|
* @param array $param
|
||
|
* @return \think\Paginator
|
||
|
*/
|
||
|
public function getList(array $param = []): \think\Paginator
|
||
|
{
|
||
|
// 设置查询条件
|
||
|
$filter = $this->getFilter($param);
|
||
|
|
||
|
// 获取列表数据
|
||
|
$list = $this->alias('order')
|
||
|
->field('order.*')
|
||
|
->where($filter)
|
||
|
->join('user', 'user.user_id = order.user_id')
|
||
|
->order(['order.create_time' => 'desc'])
|
||
|
->paginate($param['pageSize'] ?? 15);
|
||
|
// var_dump($list);
|
||
|
// exit();
|
||
|
//return $list;
|
||
|
// 加载订单的关联数据
|
||
|
return static::preload($list, ['user.avatar']);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 设置查询条件
|
||
|
* @param array $param
|
||
|
* @return array
|
||
|
*/
|
||
|
private function getFilter(array $param): array
|
||
|
{
|
||
|
// 设置默认的检索数据
|
||
|
$params = $this->setQueryDefaultValue($param, [
|
||
|
'user_id' => 0, // 用户ID
|
||
|
'search' => '', // 查询内容
|
||
|
'order_type' => 0, // 充值方式
|
||
|
'pay_method' => "", // 充值方式
|
||
|
'pay_status' => 0, // 支付状态
|
||
|
'betweenTime' => [] // 起止时间
|
||
|
]);
|
||
|
// 检索查询条件
|
||
|
$filter = [];
|
||
|
// 用户ID
|
||
|
$params['user_id'] > 0 && $filter[] = ['order.user_id', '=', $params['user_id']];
|
||
|
// 用户昵称/订单号
|
||
|
!empty($params['search']) && $filter[] = ['order.order_no|user.nick_name', 'like', "%{$params['search']}%"];
|
||
|
!empty($params['pay_method']) && $filter[] = ['order.pay_method', '=', $params['pay_method']];
|
||
|
// 充值方式
|
||
|
$params['order_type'] > 0 && $filter[] = ['order.order_type', '=', (int)$params['order_type']];
|
||
|
// 支付状态
|
||
|
$params['pay_status'] > 0 && $filter[] = ['order.pay_status', '=', (int)$params['pay_status']];
|
||
|
// 起止时间
|
||
|
if (!empty($params['pay_time'])) {
|
||
|
$times = between_time($params['pay_time']);
|
||
|
$filter[] = ['order.pay_time', '>=', $times['start_time']];
|
||
|
$filter[] = ['order.pay_time', '<', $times['end_time'] + 86400];
|
||
|
}
|
||
|
return $filter;
|
||
|
}
|
||
|
}
|