cqpCow hai 1 ano
pai
achega
42a21fc2ba
Modificáronse 2 ficheiros con 8 adicións e 14 borrados
  1. 7 8
      app/Service/ProductService.php
  2. 1 6
      config/excel/product.php

+ 7 - 8
app/Service/ProductService.php

@@ -185,7 +185,7 @@ class ProductService extends Service
             $model->product_category = $data['product_category'] ?? '';
             $model->title = $data['title'];
             $model->code = $data['code'] ?? '';
-            $model->sn_code = $data['sn_code'] ?? '';
+            $model->warranty_time = $data['warranty_time'] ?? 0;
             $model->size = $data['size'] ?? '';
             $model->unit = $data['unit'] ?? 0;
             $model->bar_code = $data['bar_code'] ?? '';
@@ -283,7 +283,7 @@ class ProductService extends Service
             $model->product_category = $data['product_category'] ?? '';
             $model->title = $data['title'];
             $model->code = $data['code'] ?? '';
-            $model->sn_code = $data['sn_code'] ?? '';
+            $model->warranty_time = $data['warranty_time'] ?? 0;
             $model->size = $data['size'] ?? '';
             $model->unit = $data['unit'] ?? 0;
             $model->bar_code = $data['bar_code'] ?? '';
@@ -506,7 +506,7 @@ class ProductService extends Service
     public function productList($data,$user){
         $model = Product::ProductClear($user,$data);
         $model = $model->where('del_time',0)
-            ->select('title','id','product_category_id','code','size','unit','bar_code','retail_price','cost','state','crt_id','crt_time','mark','depart_id','top_depart_id','sn_code')
+            ->select('title','id','product_category_id','code','size','unit','bar_code','retail_price','cost','state','crt_id','crt_time','mark','depart_id','top_depart_id')
             ->orderby('id', 'desc');
 
         if(! empty($data['title'])) $model->where('title', 'LIKE', '%'.$data['title'].'%');
@@ -530,7 +530,7 @@ class ProductService extends Service
         if(! empty($list)) {
             $productList = Product::where('del_time',0)
                 ->whereIn('product_category_id',array_column($list,'id'))
-                ->select('id','product_category_id','title','code','sn_code')
+                ->select('id','product_category_id','title','code')
                 ->get()->toArray();
             $productMap = [];
             foreach ($productList as $value){
@@ -557,7 +557,6 @@ class ProductService extends Service
         if(empty($data['title'])) return [false,'产品名称不能为空'];
         if(empty($data['product_category_id'])) return [false,'产品分类不能为空'];
         if(empty($data['code'])) return [false,'产品编码不能为空'];
-        if(empty($data['sn_code'])) return [false,'产品SN编码不能为空'];
         if(empty($data['cost'])) return [false,'成本不能为空'];
         $res = $this->checkNumber($data['cost']);
         if(! $res) return [false,'成本请输入不超过两位小数并且大于0的数值'];
@@ -588,17 +587,17 @@ class ProductService extends Service
         $top_depart_id = $user['head'] ?? [];
         $top_depart_id = $top_depart_id['id'] ?? 0;
         if($is_add){
-            $bool = Product::whereRaw("(binary code = '{$data['code']}' OR title = '{$data['title']}' OR sn_code = '{$data['sn_code']}') AND (top_depart_id = {$data['top_depart_id']} OR top_depart_id = {$top_depart_id})")
+            $bool = Product::whereRaw("(binary code = '{$data['code']}' OR title = '{$data['title']}') AND (top_depart_id = {$data['top_depart_id']} OR top_depart_id = {$top_depart_id})")
                 ->where('del_time',0)
                 ->exists();
         }else{
             if(empty($data['id'])) return [false,'ID不能为空'];
-            $bool = Product::whereRaw("(binary code = '{$data['code']}' OR title = '{$data['title']}' OR sn_code = '{$data['sn_code']}') AND (top_depart_id = {$data['top_depart_id']} OR top_depart_id = {$top_depart_id})")
+            $bool = Product::whereRaw("(binary code = '{$data['code']}' OR title = '{$data['title']}') AND (top_depart_id = {$data['top_depart_id']} OR top_depart_id = {$top_depart_id})")
                 ->where('id','<>',$data['id'])
                 ->where('del_time',0)
                 ->exists();
         }
-        if($bool) return [false,'产品名称、编码与SN编码不能重复'];
+        if($bool) return [false,'产品名称、编码不能重复'];
 
         return [true, $data];
     }

+ 1 - 6
config/excel/product.php

@@ -20,11 +20,6 @@ return [
             'rule' => '',
             'other_rule' => 'require|unique:Product',
         ],
-        '产品SN编码' => [
-            'key' =>'sn_code',
-            'rule' => '',
-            'other_rule' => 'require|unique:Product',
-        ],
         '规格' => [
             'key' =>'size',
             'rule' =>'',
@@ -64,7 +59,7 @@ return [
     "other_field_func" => "fillInsertProductData",// (特殊)需要填充的其它字段 这里是为了前端组件渲染的数据
     "table" => [
         "Product" => [
-            "field" => ["title","product_category_id","code","size","unit","bar_code","cost","retail_price","crt_id","mark","sn_code","crt_time","depart_id","top_depart_id"],
+            "field" => ["title","product_category_id","code","size","unit","bar_code","cost","retail_price","crt_id","mark","crt_time","depart_id","top_depart_id"],
         ],
         "ProductPriceDetail" => [
             "field_array" => [