|
@@ -13,8 +13,17 @@ use App\Model\ProductInventory;
|
|
use App\Model\ProductRange;
|
|
use App\Model\ProductRange;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ * 产品管理
|
|
|
|
+ */
|
|
class ProductService extends Service
|
|
class ProductService extends Service
|
|
{
|
|
{
|
|
|
|
+ /**
|
|
|
|
+ * 产品分类编辑
|
|
|
|
+ * @param $data
|
|
|
|
+ * @param $user
|
|
|
|
+ * @return array
|
|
|
|
+ */
|
|
public function productCategoryEdit($data,$user){
|
|
public function productCategoryEdit($data,$user){
|
|
list($status,$msg) = $this->productCategoryRule($data,false);
|
|
list($status,$msg) = $this->productCategoryRule($data,false);
|
|
if(!$status) return [$status,$msg];
|
|
if(!$status) return [$status,$msg];
|
|
@@ -27,6 +36,12 @@ class ProductService extends Service
|
|
return [true,''];
|
|
return [true,''];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 产品分类新增
|
|
|
|
+ * @param $data
|
|
|
|
+ * @param $user
|
|
|
|
+ * @return array
|
|
|
|
+ */
|
|
public function productCategoryAdd($data,$user){
|
|
public function productCategoryAdd($data,$user){
|
|
list($status,$msg) = $this->productCategoryRule($data);
|
|
list($status,$msg) = $this->productCategoryRule($data);
|
|
if(!$status) return [$status,$msg];
|
|
if(!$status) return [$status,$msg];
|
|
@@ -36,6 +51,11 @@ class ProductService extends Service
|
|
return [true,''];
|
|
return [true,''];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 产品分类删除
|
|
|
|
+ * @param $data
|
|
|
|
+ * @return array
|
|
|
|
+ */
|
|
public function productCategoryDel($data){
|
|
public function productCategoryDel($data){
|
|
if($this->isEmpty($data,'id')) return [false,'请选择数据!'];
|
|
if($this->isEmpty($data,'id')) return [false,'请选择数据!'];
|
|
|
|
|
|
@@ -60,6 +80,12 @@ class ProductService extends Service
|
|
return [true,''];
|
|
return [true,''];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 产品分类列表
|
|
|
|
+ * @param $data
|
|
|
|
+ * @param $user
|
|
|
|
+ * @return array
|
|
|
|
+ */
|
|
public function productCategoryList($data,$user){
|
|
public function productCategoryList($data,$user){
|
|
$model = ProductCategory::where('del_time',0)
|
|
$model = ProductCategory::where('del_time',0)
|
|
->select('title','id','parent_id')
|
|
->select('title','id','parent_id')
|
|
@@ -71,6 +97,12 @@ class ProductService extends Service
|
|
return [true, $list];
|
|
return [true, $list];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 产品分类参数规则
|
|
|
|
+ * @param $data
|
|
|
|
+ * @param $is_add
|
|
|
|
+ * @return array
|
|
|
|
+ */
|
|
public function productCategoryRule($data, $is_add = true){
|
|
public function productCategoryRule($data, $is_add = true){
|
|
if($this->isEmpty($data,'data')) return [false,'数据不能为空!'];
|
|
if($this->isEmpty($data,'data')) return [false,'数据不能为空!'];
|
|
|
|
|
|
@@ -120,6 +152,12 @@ class ProductService extends Service
|
|
return [true, $data];
|
|
return [true, $data];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 产品编辑
|
|
|
|
+ * @param $data
|
|
|
|
+ * @param $user
|
|
|
|
+ * @return array
|
|
|
|
+ */
|
|
public function productEdit($data,$user){
|
|
public function productEdit($data,$user){
|
|
list($status,$msg) = $this->productRule($data,false);
|
|
list($status,$msg) = $this->productRule($data,false);
|
|
if(!$status) return [$status,$msg];
|
|
if(!$status) return [$status,$msg];
|
|
@@ -224,6 +262,12 @@ class ProductService extends Service
|
|
return [true,''];
|
|
return [true,''];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 产品新增
|
|
|
|
+ * @param $data
|
|
|
|
+ * @param $user
|
|
|
|
+ * @return array
|
|
|
|
+ */
|
|
public function productAdd($data,$user){
|
|
public function productAdd($data,$user){
|
|
list($status,$msg) = $this->productRule($data);
|
|
list($status,$msg) = $this->productRule($data);
|
|
if(!$status) return [$status,$msg];
|
|
if(!$status) return [$status,$msg];
|
|
@@ -318,6 +362,11 @@ class ProductService extends Service
|
|
return [true,''];
|
|
return [true,''];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 产品删除
|
|
|
|
+ * @param $data
|
|
|
|
+ * @return array
|
|
|
|
+ */
|
|
public function productDel($data){
|
|
public function productDel($data){
|
|
if($this->isEmpty($data,'id')) return [false,'请选择数据!'];
|
|
if($this->isEmpty($data,'id')) return [false,'请选择数据!'];
|
|
|
|
|
|
@@ -348,6 +397,12 @@ class ProductService extends Service
|
|
return [true,''];
|
|
return [true,''];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 产品详情
|
|
|
|
+ * @param $data
|
|
|
|
+ * @param $user
|
|
|
|
+ * @return array
|
|
|
|
+ */
|
|
public function productDetail($data,$user){
|
|
public function productDetail($data,$user){
|
|
if($this->isEmpty($data,'id')) return [false,'请选择数据!'];
|
|
if($this->isEmpty($data,'id')) return [false,'请选择数据!'];
|
|
|
|
|
|
@@ -419,6 +474,12 @@ class ProductService extends Service
|
|
return [true, $customer];
|
|
return [true, $customer];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 产品列表
|
|
|
|
+ * @param $data
|
|
|
|
+ * @param $user
|
|
|
|
+ * @return array
|
|
|
|
+ */
|
|
public function productList($data,$user){
|
|
public function productList($data,$user){
|
|
$model = Product::where('del_time',0)
|
|
$model = Product::where('del_time',0)
|
|
->select('title','id','product_category_id','code','size','unit','bar_code','retail_price','cost','depart_price','state','crt_id','crt_time','mark')
|
|
->select('title','id','product_category_id','code','size','unit','bar_code','retail_price','cost','depart_price','state','crt_id','crt_time','mark')
|
|
@@ -445,6 +506,12 @@ class ProductService extends Service
|
|
return [true, $list];
|
|
return [true, $list];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 产品参数规则
|
|
|
|
+ * @param $data
|
|
|
|
+ * @param $is_add
|
|
|
|
+ * @return array
|
|
|
|
+ */
|
|
public function productRule($data, $is_add = true){
|
|
public function productRule($data, $is_add = true){
|
|
if(empty($data['title'])) return [false,'产品名称不能为空'];
|
|
if(empty($data['title'])) return [false,'产品名称不能为空'];
|
|
if(empty($data['product_category_id'])) return [false,'产品分类不能为空'];
|
|
if(empty($data['product_category_id'])) return [false,'产品分类不能为空'];
|
|
@@ -475,6 +542,11 @@ class ProductService extends Service
|
|
return [true, $data];
|
|
return [true, $data];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 拼接数据
|
|
|
|
+ * @param $data
|
|
|
|
+ * @return array
|
|
|
|
+ */
|
|
public function fillData($data){
|
|
public function fillData($data){
|
|
if(empty($data['data'])) return $data;
|
|
if(empty($data['data'])) return $data;
|
|
|
|
|