feat: 增加根据条件筛选订单功能

This commit is contained in:
mkm 2024-08-02 17:44:00 +08:00
parent a573f817f5
commit 3745015592

View File

@ -49,18 +49,38 @@ class StoreOrderCartInfoGroupLists extends BaseAdminDataLists implements ListsSe
*/
public function lists(): array
{
$order_arr=StoreOrder::whereDay('create_time')->where(['paid'=>1,'refund_status'=>0])->column('id');
if($this->request->get('start_time')){
$arr[]=['paid','=',1];
$arr[]=['refund_status','=',0];
if($this->request->get('store_id')){
$this->searchWhere[]=['store_id','=',$this->request->get('store_id')];
}
$order_arr=StoreOrder::where($this->searchWhere)->where($arr)->column('id');
}elseif($this->request->get('store_id')){
$arr[]=['paid','=',1];
$arr[]=['refund_status','=',0];
$this->searchWhere[]=['store_id','=',$this->request->get('store_id')];
$order_arr=StoreOrder::where($this->searchWhere)->where($arr)->column('id');
}else{
$order_arr=StoreOrder::whereDay('create_time')->where(['paid'=>1,'refund_status'=>0])->column('id');
}
if(!$order_arr){
return [];
}
$this->order_arr=$order_arr;
$this->searchWhere[]=['oid','in',$order_arr];
if($this->request->get('is_all')){
return StoreOrderCartInfo::where($this->searchWhere)
->field('store_id,product_id,price,total_price,cart_num')
->order('store_id desc')
$query= StoreOrderCartInfo::where($this->searchWhere);
if($this->request->get('store_id')){
$query->field('store_id,product_id,price,SUM(total_price) as total_price,SUM(cart_num) as cart_num')->group('product_id');
}else{
$query->field('store_id,product_id,price,total_price,cart_num');
}
return $query->order('store_id desc')
->limit($this->limitOffset, $this->limitLength)
->select()->each(function ($item) {
->select()
->each(function ($item) {
$find=StoreProduct::where('id',$item['product_id'])->field('image,unit,cate_id,store_name,store_info')->find();
$item['system_store']=SystemStore::where('id',$item['store_id'])->value('name');
if($find){