feat(StoreBranchProductLists): 添加store_id到搜索条件

This commit is contained in:
mkm 2024-09-22 16:10:25 +08:00
parent 3d37bdb594
commit 808dfeec49

View File

@ -36,7 +36,7 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI
public function setSearch(): array
{
return [
'=' => ['product_id', 'cate_id', 'status','bar_code'],
'=' => ['product_id', 'cate_id','store_id', 'status','bar_code'],
'%pipe_like%' => ['store_name_code' => 'store_name|bar_code'],
'%like%' => ['store_name'],
];
@ -88,7 +88,6 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI
}
// //$store_id=18;//酒店商贩
// $store_id=17;//一条龙门店
$this->searchWhere[] = ['store_id', '=', 17];
return StoreBranchProduct::where($this->searchWhere)
->field(['id', 'store_id', 'product_id', 'image', 'store_name', 'store_info', 'cate_id', 'price', 'sales', 'stock', 'unit', 'cost', 'purchase', 'status', 'batch', 'vip_price','bar_code', 'manufacturer_information','total_price'])
->when(!empty($this->adminInfo['store_id']), function ($query) {
@ -110,13 +109,13 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI
$price_div = bcdiv($rose_price, $item['price'], 2);
$rose=bcmul($price_div, 100, 2);
}
$arr=StoreOrderCartInfo::where('product_id', $item['product_id'])->where('store_id', $item['store_id'])->where('is_pay', 1)->where('create_time','>=','1726847999')->group('oid')->column('oid');
$ids=StoreOrder::where('id','in',$arr)->where('paid',1)->where('status','in',[0,1,2,3])->where('refund_status',0)->column('id');
$item['village']=StoreFinanceFlow::where('order_id','in',$ids)->where('financial_type',14)->where('financial_pm',1)->where('status','in',[0,1])->sum('number');
$item['brigade']=StoreFinanceFlow::where('order_id','in',$ids)->where('financial_type',15)->where('financial_pm',1)->where('status','in',[0,1])->sum('number');
$item['loss']=StoreFinanceFlow::where('order_id','in',$ids)->where('financial_type',16)->where('financial_pm',1)->where('status','in',[0,1])->sum('number');
$item['user']=StoreFinanceFlow::where('order_id','in',$ids)->where('financial_type',12)->where('financial_pm',1)->where('status','in',[0,1])->sum('number');
$item['store']=StoreFinanceFlow::where('order_id','in',$ids)->where('financial_type','in',[3,11])->where('status','in',[0,1])->where('financial_pm',1)->sum('number');
// $arr=StoreOrderCartInfo::where('product_id', $item['product_id'])->where('store_id', $item['store_id'])->where('is_pay', 1)->where('create_time','>=','1726847999')->group('oid')->column('oid');
// $ids=StoreOrder::where('id','in',$arr)->where('paid',1)->where('status','in',[0,1,2,3])->where('refund_status',0)->column('id');
// $item['village']=StoreFinanceFlow::where('order_id','in',$ids)->where('financial_type',14)->where('financial_pm',1)->where('status','in',[0,1])->sum('number');
// $item['brigade']=StoreFinanceFlow::where('order_id','in',$ids)->where('financial_type',15)->where('financial_pm',1)->where('status','in',[0,1])->sum('number');
// $item['loss']=StoreFinanceFlow::where('order_id','in',$ids)->where('financial_type',16)->where('financial_pm',1)->where('status','in',[0,1])->sum('number');
// $item['user']=StoreFinanceFlow::where('order_id','in',$ids)->where('financial_type',12)->where('financial_pm',1)->where('status','in',[0,1])->sum('number');
// $item['store']=StoreFinanceFlow::where('order_id','in',$ids)->where('financial_type','in',[3,11])->where('status','in',[0,1])->where('financial_pm',1)->sum('number');
$item['warehouse_product']=WarehouseProduct::where('product_id',$item['product_id'])->where('store_id',$item['store_id'])->where('financial_pm',0)->sum('nums')??0;
$item['rose'] = $rose;
@ -177,11 +176,6 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI
'sales' => '销量',
'rose' => '毛利率',
'purchase' => '供货价',
'village' => '村长利润',
'brigade' => '队长利润',
'user' => '厨师其他会员利润',
'store' => '门店利润',
'loss' => '损耗',
'total_price' => '价值',
];
return $data;