|
@@ -6,6 +6,7 @@ use App\Model\Employee;
|
|
|
use App\Model\Product;
|
|
|
use App\Model\ProductCategory;
|
|
|
use App\Model\ProductInfo;
|
|
|
+use App\Model\ProductInventory;
|
|
|
use App\Model\ProductRange;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
@@ -319,7 +320,7 @@ class ProductService extends Service
|
|
|
return [true,''];
|
|
|
}
|
|
|
|
|
|
- public function productDetail($data){
|
|
|
+ public function productDetail($data,$user){
|
|
|
if($this->isEmpty($data,'id')) return [false,'请选择数据!'];
|
|
|
|
|
|
$customer = Product::where('del_time',0)
|
|
@@ -327,8 +328,11 @@ class ProductService extends Service
|
|
|
->first();
|
|
|
if(empty($customer)) return [false,'产品不存在或已被删除'];
|
|
|
$customer = $customer->toArray();
|
|
|
- $customer['img'] = $customer['file'] = $customer['depart'] = $customer['employee'] = [];
|
|
|
+ $customer['product_inventory'] = [];
|
|
|
+ $inventory = $this->getProductInventory([$data['id']], $user['rule_depart']);
|
|
|
+ if(! empty($inventory)) $customer['product_inventory'] = $inventory;
|
|
|
|
|
|
+ $customer['img'] = $customer['file'] = $customer['depart'] = $customer['employee'] = [];
|
|
|
$customer_info = ProductInfo::where('del_time',0)
|
|
|
->where('product_id',$customer['id'])
|
|
|
->select('id','product_id','file','type')
|
|
@@ -423,4 +427,18 @@ class ProductService extends Service
|
|
|
|
|
|
return $data;
|
|
|
}
|
|
|
+
|
|
|
+ public function getProductInventory($product_id = [],$depart_id = []){
|
|
|
+ if(empty($product_id)) return [];
|
|
|
+
|
|
|
+ $result = ProductInventory::whereIn('product_id',$product_id)
|
|
|
+ ->when(! empty($depart_id), function ($query) use ($depart_id) {
|
|
|
+ return $query->whereIn('depart_id', $depart_id);
|
|
|
+ })
|
|
|
+ ->select('id','product_id','number','depart_id','lock_number')
|
|
|
+ ->get()
|
|
|
+ ->toArray();
|
|
|
+
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
}
|