diff --git a/app/admin/lists/store_branch_product/StoreBranchProductLists.php b/app/admin/lists/store_branch_product/StoreBranchProductLists.php index ac7ed8b9..b51b9c58 100644 --- a/app/admin/lists/store_branch_product/StoreBranchProductLists.php +++ b/app/admin/lists/store_branch_product/StoreBranchProductLists.php @@ -10,13 +10,14 @@ use app\common\model\store_product_unit\StoreProductUnit; use app\common\model\system_store\SystemStore; use app\common\lists\ListsSearchInterface; use app\common\model\store_branch_product\StoreBranchProduct; +use app\common\lists\ListsExcelInterface; /** * 门店商品辅助表 * Class StoreBranchProductLists * @package app\admin\listssystem_store */ -class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchInterface +class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchInterface,ListsExcelInterface { @@ -97,4 +98,42 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI ->count(); } + /** + * @notes 导出文件名 + * @return string + * @author 乔峰 + * @date 2022/11/24 16:17 + */ + public function setFileName(): string + { + if($this->request->get('store_id')){ + $name=SystemStore::where('id',$this->request->get('store_id'))->value('name'); + return $name.'商品列表'; + } + return '门店商品列表'; + } + + + /** + * @notes 导出字段 + * @return string[] + * @author 乔峰 + * @date 2022/11/24 16:17 + */ + public function setExcelFields(): array + { + $data=[ + 'store_name' => '商品名称', + 'store_info' => '规格', + 'unit_name' => '单位', + 'cate_name' => '分类', + 'stock' => '库存', + 'sales' => '销量', + 'purchase'=>'供货价', + 'cost'=>'商户价', + 'vip_price'=>'会员价', + 'price' => '零售价', + ]; + return $data; + } } diff --git a/app/admin/lists/store_product/StoreProductLists.php b/app/admin/lists/store_product/StoreProductLists.php index cb942673..bbbd1082 100644 --- a/app/admin/lists/store_product/StoreProductLists.php +++ b/app/admin/lists/store_product/StoreProductLists.php @@ -7,6 +7,7 @@ use app\admin\lists\BaseAdminDataLists; use app\common\model\cate\Cate; use app\common\model\store_product\StoreProduct; use app\common\lists\ListsSearchInterface; +use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\store_category\StoreCategory; use app\common\model\store_product_unit\StoreProductUnit; use app\common\model\system_store\SystemStore; @@ -65,7 +66,9 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa ->order(['id' => 'desc']) ->select()->each(function ($item) { $item['unit_name'] = StoreProductUnit::where('id', $item['unit'])->value('name'); - $item['stock'] = WarehouseProductStorege::where('product_id', $item['id'])->sum('nums'); + $nums=WarehouseProductStorege::where('product_id', $item['id'])->sum('nums'); + $stock=StoreBranchProduct::where('store_id','<>','4')->where('product_id',$item['id'])->sum('stock'); + $item['stock'] = bcadd($nums,$stock); $item['cate_name'] = StoreCategory::where('id', $item['cate_id'])->value('name'); return $item; })?->toArray(); diff --git a/app/admin/lists/warehouse_product/WarehouseProductLists.php b/app/admin/lists/warehouse_product/WarehouseProductLists.php index ae8afc56..8183d703 100644 --- a/app/admin/lists/warehouse_product/WarehouseProductLists.php +++ b/app/admin/lists/warehouse_product/WarehouseProductLists.php @@ -10,13 +10,14 @@ use app\common\model\auth\Admin; use app\common\model\store_product\StoreProduct; use app\common\model\system_store\SystemStore; use app\common\model\warehouse\Warehouse; +use app\common\lists\ListsExcelInterface; /** * 商品仓储信息列表 * Class WarehouseProductLists * @package app\admin\listswarehouse_product */ -class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInterface +class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInterface,ListsExcelInterface { public $ids; @@ -87,7 +88,9 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt $item->admin_name=''; } if($item->product_id){ - $item->store_name=StoreProduct::where('id',$item->product_id)->value('store_name'); + $find=StoreProduct::where('id',$item->product_id)->field('image,store_name')->find(); + $item->store_name=$find->store_name; + $item->image=$find->image; }else{ $item->store_name=''; } @@ -121,5 +124,58 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt return WarehouseProduct::where($this->searchWhere)->count(); } } + /** + * @notes 导出文件名 + * @return string + * @author 乔峰 + * @date 2022/11/24 16:17 + */ + public function setFileName(): string + { + $financial_pm=$this->request->get('financial_pm'); + if($financial_pm==1){ + return '入库列表'; + } + return '出库列表'; + } + + /** + * @notes 导出字段 + * @return string[] + * @author 乔峰 + * @date 2022/11/24 16:17 + */ + public function setExcelFields(): array + { + $financial_pm=$this->request->get('financial_pm'); + if($financial_pm==1){ + $data=[ + 'admin_name' => '操作人员', + 'warehouse_name' => '仓库', + 'store_name' => '商品名称', + 'financial_pm_name' => '出入库', + 'batch' => '批次', + 'nums' => '数量', + 'manufacture' => '生产日期', + 'expiration_date' => '保质期', + 'purchase' => '采购价', + 'price' => '零售', + 'total_price' => '总价', + 'create_time' => '操作时间', + ]; + }else{ + $data=[ + 'admin_name' => '操作人员', + 'warehouse_name' => '仓库', + 'store_name' => '商品名称', + 'financial_pm_name' => '出入库', + 'system_store_name'=>'门店', + 'nums' => '数量', + 'create_time' => '操作时间', + ]; + } + + return $data; + } } \ No newline at end of file diff --git a/app/admin/lists/warehouse_product_storege/WarehouseProductStoregeLists.php b/app/admin/lists/warehouse_product_storege/WarehouseProductStoregeLists.php index 408ca67d..8de434d2 100644 --- a/app/admin/lists/warehouse_product_storege/WarehouseProductStoregeLists.php +++ b/app/admin/lists/warehouse_product_storege/WarehouseProductStoregeLists.php @@ -30,7 +30,7 @@ class WarehouseProductStoregeLists extends BaseAdminDataLists implements ListsSe public function setSearch(): array { return [ - '=' => ['warehouse_id'], + '=' => ['warehouse_id','product_id'], ]; } diff --git a/app/admin/logic/store_branch_product/StoreBranchProductLogic.php b/app/admin/logic/store_branch_product/StoreBranchProductLogic.php index ce3508e3..f171dc14 100644 --- a/app/admin/logic/store_branch_product/StoreBranchProductLogic.php +++ b/app/admin/logic/store_branch_product/StoreBranchProductLogic.php @@ -51,6 +51,11 @@ class StoreBranchProductLogic extends BaseLogic */ public static function edit(array $params): bool { + $StoreProduct=StoreBranchProduct::where('id', $params['id'])->find(); + if($params['status']==1 &&$StoreProduct['price']==0){ + self::setError('商品价格不能为0,无法上架'); + return false; + } Db::startTrans(); try { $data=[ @@ -60,7 +65,6 @@ class StoreBranchProductLogic extends BaseLogic 'unit'=>$params['unit'], 'status'=>$params['status'], ]; - $StoreProduct=StoreBranchProduct::where('id', $params['id'])->find(); if(isset($params['cate_id'])){ if ($StoreProduct['cate_id'] != $params['cate_id']) { self::store_product_cate_update($params['id'], $StoreProduct['cate_id'], $StoreProduct['store_id']);