|
@@ -22,6 +22,7 @@ use App\Model\ProductAdjustment;
|
|
|
use App\Model\ProductAdjustmentSub;
|
|
|
use App\Model\ProductCategory;
|
|
|
use App\Model\ProductInventorySet;
|
|
|
+use App\Model\ProductItemCodeMessage;
|
|
|
use App\Model\ProductPriceDetail;
|
|
|
use App\Model\SalesOrder;
|
|
|
use App\Model\SalesOrderInfo;
|
|
@@ -869,7 +870,7 @@ class ImportService extends Service
|
|
|
}
|
|
|
|
|
|
$array = array_values($array);
|
|
|
- $insert = $insert2 = $update = $update2 = [];
|
|
|
+ $insert = $insert2 = $insert_detail = $update = $update2 = $update_detail = [];
|
|
|
foreach ($array as $value){
|
|
|
if(isset($product_array[$value['1']])){
|
|
|
$pro_tmp = $product_array[$value['1']] ?? [];
|
|
@@ -899,6 +900,7 @@ class ImportService extends Service
|
|
|
$tmp['build_fee'] = $value['9'] ?? 0;
|
|
|
$tmp['item_code'] = $value['10'] ?? "";
|
|
|
$tmp['warranty_time'] = $value['11'] ?? 0;
|
|
|
+ $tmp['product_item_code_title'] = $value['12'] ?? "";
|
|
|
foreach ($map as $m => $v){
|
|
|
if($value[$v['col']]){
|
|
|
if(! is_numeric($value[$v['col']])) return [false,$v['name'] . ': 请输入数字且最多两位小数'];
|
|
@@ -928,10 +930,31 @@ class ImportService extends Service
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //规格
|
|
|
+ if($tmp['size'] == "") unset($tmp['size']);
|
|
|
+ //单位
|
|
|
+ if($tmp['unit'] == "") unset($tmp['unit']);
|
|
|
+ //条码
|
|
|
+ if($tmp['bar_code'] == "") unset($tmp['bar_code']);
|
|
|
+ //成本
|
|
|
+ if($tmp['cost'] == "") unset($tmp['cost']);
|
|
|
+ //零售
|
|
|
+ if($tmp['retail_price'] == "") unset($tmp['retail_price']);
|
|
|
+ //产品属性
|
|
|
+ if($tmp['product_attribute'] == "") unset($tmp['product_attribute']);
|
|
|
//安装费
|
|
|
if($tmp['build_fee'] == "") unset($tmp['build_fee']);
|
|
|
//商品编码
|
|
|
-// if($tmp['item_code'] == "") unset($tmp['item_code']);
|
|
|
+ if($tmp['item_code'] == "") unset($tmp['item_code']);
|
|
|
+
|
|
|
+ if(! empty($tmp['item_code']) && $tmp['product_item_code_title'] != "" && ! isset($update_detail[$tmp['item_code']])) $update_detail[$tmp['item_code']] = [
|
|
|
+ 'item_code' => $tmp['item_code'],
|
|
|
+ 'title' => $tmp['product_item_code_title']
|
|
|
+ ];
|
|
|
+ unset($tmp['product_item_code_title']);
|
|
|
+
|
|
|
+ //质保年月
|
|
|
+ if($tmp['warranty_time'] == "") unset($tmp['warranty_time']);
|
|
|
|
|
|
//产品主表
|
|
|
$update[$product_id] = $tmp;
|
|
@@ -954,6 +977,12 @@ class ImportService extends Service
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if(! empty($tmp['item_code']) && $tmp['product_item_code_title'] != "" && ! isset($insert_detail[$tmp['item_code']])) $insert_detail[$tmp['item_code']] = [
|
|
|
+ 'item_code' => $tmp['item_code'],
|
|
|
+ 'title' => $tmp['product_item_code_title']
|
|
|
+ ];
|
|
|
+ unset($tmp['product_item_code_title']);
|
|
|
+
|
|
|
//产品主表
|
|
|
$insert[$tmp['code']] = $tmp;
|
|
|
}
|
|
@@ -977,6 +1006,7 @@ class ImportService extends Service
|
|
|
}
|
|
|
ProductPriceDetail::insert($insert_detail);
|
|
|
}
|
|
|
+ if(! empty($insert_detail)) ProductItemCodeMessage::insert(array_values($insert_detail));
|
|
|
}
|
|
|
|
|
|
//编辑
|
|
@@ -989,9 +1019,18 @@ class ImportService extends Service
|
|
|
if(! empty($update2)){
|
|
|
$product_id_array = array_keys($update);
|
|
|
ProductPriceDetail::whereIn('product_id',$product_id_array)
|
|
|
+ ->where('del_time',0)
|
|
|
->update(['del_time' => $time]);
|
|
|
ProductPriceDetail::insert($update2);
|
|
|
}
|
|
|
+
|
|
|
+ if(! empty($update_detail)) {
|
|
|
+ $item_code = array_keys($update_detail);
|
|
|
+ ProductItemCodeMessage::where('del_time',0)
|
|
|
+ ->whereIn('item_code',$item_code)
|
|
|
+ ->update(['del_time' => $time]);
|
|
|
+ ProductItemCodeMessage::insert(array_values($update_detail));
|
|
|
+ }
|
|
|
}
|
|
|
DB::commit();
|
|
|
}catch (\Exception $e){
|