|
@@ -29,6 +29,7 @@ use App\Model\SalesOrderInfo;
|
|
use App\Model\SalesOrderProductInfo;
|
|
use App\Model\SalesOrderProductInfo;
|
|
use App\Model\ScheduleInfo;
|
|
use App\Model\ScheduleInfo;
|
|
use App\Model\SeeRange;
|
|
use App\Model\SeeRange;
|
|
|
|
+use App\Model\Setting;
|
|
use App\Model\Storehouse;
|
|
use App\Model\Storehouse;
|
|
use Carbon\Carbon;
|
|
use Carbon\Carbon;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
@@ -44,7 +45,7 @@ use Barryvdh\DomPDF\PDF;
|
|
class ConstructionService extends Service
|
|
class ConstructionService extends Service
|
|
{
|
|
{
|
|
//补录sn码信息
|
|
//补录sn码信息
|
|
- public function constructionEditSn($data,$user){
|
|
|
|
|
|
+ public function constructionEditSn($data,$user){return [false, '补录功能暂时关闭'];
|
|
list($status,$msg) = $this->constructionEditSnRule($data, $user);
|
|
list($status,$msg) = $this->constructionEditSnRule($data, $user);
|
|
if(!$status) return [$status, $msg];
|
|
if(!$status) return [$status, $msg];
|
|
|
|
|
|
@@ -52,7 +53,7 @@ class ConstructionService extends Service
|
|
DB::beginTransaction();
|
|
DB::beginTransaction();
|
|
|
|
|
|
//sn码
|
|
//sn码
|
|
- (new DataSyncToU8Service())->saveSn($data, ProductSnInfo::type_one, time());
|
|
|
|
|
|
+// (new DataSyncToU8Service())->saveSn($data, ProductSnInfo::type_one, time());
|
|
|
|
|
|
DB::commit();
|
|
DB::commit();
|
|
}catch (\Exception $exception){
|
|
}catch (\Exception $exception){
|
|
@@ -72,8 +73,8 @@ class ConstructionService extends Service
|
|
if(empty($data['product'])) return [false, '产品不能为空'];
|
|
if(empty($data['product'])) return [false, '产品不能为空'];
|
|
|
|
|
|
//校验sn码
|
|
//校验sn码
|
|
- list($status, $msg) = (new DataSyncToU8Service())->checkSnConstructionRule($data);
|
|
|
|
- if(! $status) return [false, $msg];
|
|
|
|
|
|
+// list($status, $msg) = (new DataSyncToU8Service())->checkSnConstructionRule($data);
|
|
|
|
+// if(! $status) return [false, $msg];
|
|
|
|
|
|
return [true, ''];
|
|
return [true, ''];
|
|
}
|
|
}
|
|
@@ -262,7 +263,7 @@ class ConstructionService extends Service
|
|
}
|
|
}
|
|
|
|
|
|
//sn码
|
|
//sn码
|
|
- (new DataSyncToU8Service())->saveSn($data, ProductSnInfo::type_one, $time);
|
|
|
|
|
|
+// (new DataSyncToU8Service())->saveSn($data, ProductSnInfo::type_one, $time);
|
|
|
|
|
|
DB::commit();
|
|
DB::commit();
|
|
}catch (\Exception $exception){
|
|
}catch (\Exception $exception){
|
|
@@ -403,7 +404,7 @@ class ConstructionService extends Service
|
|
(new CheckService())->orderInventoryInsert(['order_number' => $data['order_number'], 'is_check_stock' => $data['is_check_stock']]);
|
|
(new CheckService())->orderInventoryInsert(['order_number' => $data['order_number'], 'is_check_stock' => $data['is_check_stock']]);
|
|
|
|
|
|
//sn码
|
|
//sn码
|
|
- (new DataSyncToU8Service())->saveSn($data, ProductSnInfo::type_one, $time);
|
|
|
|
|
|
+// (new DataSyncToU8Service())->saveSn($data, ProductSnInfo::type_one, $time);
|
|
|
|
|
|
DB::commit();
|
|
DB::commit();
|
|
}catch (\Exception $exception){
|
|
}catch (\Exception $exception){
|
|
@@ -440,7 +441,7 @@ class ConstructionService extends Service
|
|
$construction = $construction->toArray();
|
|
$construction = $construction->toArray();
|
|
if($construction['state'] > Construction::STATE_ZERO) return [false,'请确认施工单状态,操作失败'];
|
|
if($construction['state'] > Construction::STATE_ZERO) return [false,'请确认施工单状态,操作失败'];
|
|
|
|
|
|
- $product_save = $this->getSaveDetail($data['id']);
|
|
|
|
|
|
+// $product_save = $this->getSaveDetail($data['id']);
|
|
try {
|
|
try {
|
|
DB::beginTransaction();
|
|
DB::beginTransaction();
|
|
|
|
|
|
@@ -660,6 +661,43 @@ class ConstructionService extends Service
|
|
return [true, $construction];
|
|
return [true, $construction];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public function detailSn($data,$user){
|
|
|
|
+ if(empty($data['id'])) return [false,'请选择数据!'];
|
|
|
|
+
|
|
|
|
+ $p_info = ConstructionProductInfo::where('del_time',0)
|
|
|
|
+ ->where('construction_id',$data['id'])
|
|
|
|
+ ->get()->toArray();
|
|
|
|
+ $basic_price = BasicType::whereIn('id',array_unique(array_column($p_info,'basic_type_id')))->pluck('title','id')->toArray();
|
|
|
|
+ $map = (new ProductService())->getProductDetail(array_column($p_info,'product_id'));
|
|
|
|
+
|
|
|
|
+ $return = [];
|
|
|
|
+ $service = new DataSyncToU8Service();
|
|
|
|
+ foreach ($p_info as $value){
|
|
|
|
+ $tmp = $map[$value['product_id']] ?? [];
|
|
|
|
+ if(empty($tmp['warranty_time'])) continue;
|
|
|
|
+ $bool = $service->forCheck($tmp['product_category']);
|
|
|
|
+ if($bool){//车窗膜不需要
|
|
|
|
+ $value['product_type_for_sn'] = 1;
|
|
|
|
+ }else{
|
|
|
|
+ $bool = $service->forCheck2($tmp['product_category']);
|
|
|
|
+ if($bool){
|
|
|
|
+ $value['product_type_for_sn'] = $value['product_type_for_sn'] = 1;
|
|
|
|
+ }else{
|
|
|
|
+ $value['product_type_for_sn'] = $value['product_type_for_sn'] = 2;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ $value['title'] = $tmp['title'] ?? "";
|
|
|
|
+ $value['code'] = $tmp['code'] ?? "";
|
|
|
|
+ $value['size'] = $tmp['size'] ?? "";
|
|
|
|
+ $value['unit'] = $tmp['unit'] ?? "";
|
|
|
|
+ $value['bar_code'] = $tmp['bar_code'] ?? "";
|
|
|
|
+ $value['basic_type_title'] = $basic_price[$value['basic_type_id']] ?? "";
|
|
|
|
+ $return[] = $value;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return [true, $return];
|
|
|
|
+ }
|
|
|
|
+
|
|
public function constructionCommon($data,$user,$field = []){
|
|
public function constructionCommon($data,$user,$field = []){
|
|
if(empty($field)){
|
|
if(empty($field)){
|
|
$field = ['title','id','model_type','order_number','customer_id','customer_contact_id','install_method','install_position','sales_order_id','construction_fee','construction_time','handover_time','urgency','crt_id','crt_time','mark','state','address1','address2','introduction','service_price','storehouse_id','start_time','end_time','pq_state','day_start_stamp','day_end_stamp','vin_no'];
|
|
$field = ['title','id','model_type','order_number','customer_id','customer_contact_id','install_method','install_position','sales_order_id','construction_fee','construction_time','handover_time','urgency','crt_id','crt_time','mark','state','address1','address2','introduction','service_price','storehouse_id','start_time','end_time','pq_state','day_start_stamp','day_end_stamp','vin_no'];
|
|
@@ -874,9 +912,11 @@ class ConstructionService extends Service
|
|
$product_id[] = $value['product_id'];
|
|
$product_id[] = $value['product_id'];
|
|
}
|
|
}
|
|
|
|
|
|
- //校验sn码
|
|
|
|
- list($status, $msg) = (new DataSyncToU8Service())->checkSnConstructionRule($data);
|
|
|
|
- if(! $status) return [false, $msg];
|
|
|
|
|
|
+// //校验sn码
|
|
|
|
+// if($is_add){
|
|
|
|
+// list($status, $msg) = (new DataSyncToU8Service())->checkSnConstructionRule($data);
|
|
|
|
+// if(! $status) return [false, $msg];
|
|
|
|
+// }
|
|
|
|
|
|
//剩余能施工
|
|
//剩余能施工
|
|
$id = $data['id'] ?? 0;
|
|
$id = $data['id'] ?? 0;
|
|
@@ -1703,7 +1743,7 @@ class ConstructionService extends Service
|
|
|
|
|
|
$send_data = [];
|
|
$send_data = [];
|
|
if($data['type'] == 1){
|
|
if($data['type'] == 1){
|
|
- if($order['state'] != Construction::STATE_TWO) return [false, '请确认施工单单据状态,操作完结失败'];
|
|
|
|
|
|
+ if($order['state'] != Construction::STATE_TWO) return [false, '请确认施工单单据状态,操作失败'];
|
|
$state = Construction::STATE_THREE;
|
|
$state = Construction::STATE_THREE;
|
|
|
|
|
|
//提醒分配人
|
|
//提醒分配人
|
|
@@ -1735,8 +1775,8 @@ class ConstructionService extends Service
|
|
];
|
|
];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }else{
|
|
|
|
- if($order['state'] != Construction::STATE_THREE) return [false, '请确认施工单单据状态,操作待确认失败'];
|
|
|
|
|
|
+ }elseif($data['type'] == 2){
|
|
|
|
+ if($order['state'] != Construction::STATE_THREE) return [false, '请确认施工单单据状态,操作失败'];
|
|
$state = Construction::STATE_FOUR;
|
|
$state = Construction::STATE_FOUR;
|
|
|
|
|
|
//提醒创建人
|
|
//提醒创建人
|
|
@@ -1750,7 +1790,52 @@ class ConstructionService extends Service
|
|
'tmp_data' => [
|
|
'tmp_data' => [
|
|
$order['order_number'],
|
|
$order['order_number'],
|
|
"施工单",
|
|
"施工单",
|
|
- '已完结',
|
|
|
|
|
|
+ '待验车',
|
|
|
|
+ $emp_tmp,
|
|
|
|
+ date('Y-m-d H:i:s'),
|
|
|
|
+ ],
|
|
|
|
+ ];
|
|
|
|
+ }elseif($data['type'] == 3){
|
|
|
|
+ if($order['state'] != Construction::STATE_FOUR) return [false, '请确认施工单单据状态,操作失败'];
|
|
|
|
+ $state = Construction::STATE_FIVE;
|
|
|
|
+
|
|
|
|
+ //提醒创建人
|
|
|
|
+ $emp_tmp = Employee::where('id', $order['crt_id'])->value('emp_name');
|
|
|
|
+ $send_data[] = [
|
|
|
|
+ 'employee_id' => $order['crt_id'],
|
|
|
|
+ 'type' => 2,
|
|
|
|
+ 'state' => 0,
|
|
|
|
+ 'menu_id' => 34,
|
|
|
|
+ 'order_number' => $order['order_number'],
|
|
|
|
+ 'tmp_data' => [
|
|
|
|
+ $order['order_number'],
|
|
|
|
+ "施工单",
|
|
|
|
+ '待交车',
|
|
|
|
+ $emp_tmp,
|
|
|
|
+ date('Y-m-d H:i:s'),
|
|
|
|
+ ],
|
|
|
|
+ ];
|
|
|
|
+ }else{
|
|
|
|
+ list($status, $msg) = $this->checkWarranty($order, $data);
|
|
|
|
+ if(! $status) return [false, $msg];
|
|
|
|
+
|
|
|
|
+ list($status, $msg) = (new TSpaceService())->warrantyAddNew($msg, $data, $user);
|
|
|
|
+ if(! $status) return [false, $msg];
|
|
|
|
+
|
|
|
|
+ $state = Construction::STATE_SIX;
|
|
|
|
+
|
|
|
|
+ //提醒创建人
|
|
|
|
+ $emp_tmp = Employee::where('id', $order['crt_id'])->value('emp_name');
|
|
|
|
+ $send_data[] = [
|
|
|
|
+ 'employee_id' => $order['crt_id'],
|
|
|
|
+ 'type' => 2,
|
|
|
|
+ 'state' => 0,
|
|
|
|
+ 'menu_id' => 34,
|
|
|
|
+ 'order_number' => $order['order_number'],
|
|
|
|
+ 'tmp_data' => [
|
|
|
|
+ $order['order_number'],
|
|
|
|
+ "施工单",
|
|
|
|
+ '已交车',
|
|
$emp_tmp,
|
|
$emp_tmp,
|
|
date('Y-m-d H:i:s'),
|
|
date('Y-m-d H:i:s'),
|
|
],
|
|
],
|
|
@@ -1764,4 +1849,104 @@ class ConstructionService extends Service
|
|
|
|
|
|
return [true, ''];
|
|
return [true, ''];
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public function snListAccording($data,$user){
|
|
|
|
+ if(empty($data['id'])) return [false, 'ID不能为空'];
|
|
|
|
+ $sn_type = (new DataSyncToU8Service())->snListAccordingForOrder($data['id']);
|
|
|
|
+
|
|
|
|
+ return [true, ['sn_type' => $sn_type]];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function checkWarranty($order, &$data){
|
|
|
|
+ if($order['state'] != Construction::STATE_FIVE) return [false, '施工单未处在待交车状态,操作失败'];
|
|
|
|
+ if(empty($order['vin_no'])) return [false, '车架号不能为空'];
|
|
|
|
+ $bool = $this->isValidVin($order['vin_no']);
|
|
|
|
+ if(! $bool) return [false, '车架号错误,请查看原施工单车架号,编辑输入完整车架号'];
|
|
|
|
+ if(empty($order['customer_id'])) return [false, '客户信息不存在'];
|
|
|
|
+ $customer = Customer::where('del_time', 0)->where('id',$order['customer_id'])->first();
|
|
|
|
+ if(empty($customer)) return [false, '客户不存在或已被删除'];
|
|
|
|
+ $customer = $customer->toArray();
|
|
|
|
+ $info = CustomerInfo::where('del_time',0)
|
|
|
|
+ ->where('type',CustomerInfo::type_one)
|
|
|
|
+ ->where('customer_id', $customer['id'])
|
|
|
|
+ ->where('contact_info', "<>", "")
|
|
|
|
+ ->select('contact_info')
|
|
|
|
+ ->first();
|
|
|
|
+ if(empty($info)) return [false, "客户的联系方式不能为空"];
|
|
|
|
+ $info = $info->toArray();
|
|
|
|
+ $customer_info = $info['contact_info'];
|
|
|
|
+ $order['customer_info'] = $customer_info;
|
|
|
|
+ $order['customer_title'] = $customer['title'];
|
|
|
|
+ if(empty($data['product'])) return [false, '产品不能为空'];
|
|
|
|
+ list($status, $msg) = $this->checkSnConstructionRule($data);
|
|
|
|
+ if(! $status) return [false, $msg];
|
|
|
|
+
|
|
|
|
+ return [true, $order];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 校验sn码 施工单
|
|
|
|
+ * @param $data
|
|
|
|
+ * @param false $is_edit 是否补录
|
|
|
|
+ * @return array|string
|
|
|
|
+ */
|
|
|
|
+ public function checkSnConstructionRule(&$data){
|
|
|
|
+ //产品字典
|
|
|
|
+ $map = (new ProductService())->getProductDetail(array_column($data['product'],'product_id'));
|
|
|
|
+
|
|
|
|
+ $code = $sn = [];
|
|
|
|
+ $service = new DataSyncToU8Service();
|
|
|
|
+ foreach ($data['product'] as $key => $value){
|
|
|
|
+ if(empty($value['code'])) return [false, '产品编码不能为空'];
|
|
|
|
+ $code[] = $value['code'];
|
|
|
|
+ //没有sn码信息直接跳过
|
|
|
|
+ if(empty($value['product_sn_info'])) continue;
|
|
|
|
+ //产品
|
|
|
|
+ $tmp = $map[$value['product_id']] ?? [];
|
|
|
|
+ if(empty($tmp['warranty_time'])) return [false, "产品编码:" . $value['code'] . "质保时长(月)暂未设置"];
|
|
|
|
+ $bool = $service->forCheck($tmp['product_category']);
|
|
|
|
+
|
|
|
|
+ $n = 0;
|
|
|
|
+ foreach ($value['product_sn_info'] as $k_s => $sn_val){
|
|
|
|
+ if(empty($sn_val['auto_id'])) return [false, 'AutoID不能为空'];
|
|
|
|
+ if(empty($sn_val['sn'])) return [false, '产品SN不能为空'];
|
|
|
|
+ $value['product_sn_info'][$k_s]['for_update'] = $bool ? 0 : 1;
|
|
|
|
+ $n ++;
|
|
|
|
+ $sn[] = $sn_val['sn'];
|
|
|
|
+ }
|
|
|
|
+ $data['product'][$key]['product_sn_info'] = $value['product_sn_info'];
|
|
|
|
+ //非车窗膜需校验sn码
|
|
|
|
+ if(! $bool && $n > $value['number']) return [false, "产品编码:" . $value['code'] . "选择的sn码数量不能超过产品数量"];
|
|
|
|
+ }
|
|
|
|
+ if(empty($sn)) return [true, ''];
|
|
|
|
+
|
|
|
|
+ //获取在库的sn码信息
|
|
|
|
+ list($status, $msg) = $service->getSnForMap($code, $sn);
|
|
|
|
+ if(! $status) return [false, $msg];
|
|
|
|
+
|
|
|
|
+ //sn码map
|
|
|
|
+ $sn_list = $msg['data'];
|
|
|
|
+ $sn_map = [];
|
|
|
|
+ foreach ($sn_list as $value){
|
|
|
|
+ $key = $value['code'] . $value['sn'];
|
|
|
|
+ $sn_map[$key] = "";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //校验用友
|
|
|
|
+ $submit_info = [];
|
|
|
|
+ foreach ($data['product'] as $value){
|
|
|
|
+ if(empty($value['product_sn_info'])) continue;
|
|
|
|
+ foreach ($value['product_sn_info'] as $sn_val){
|
|
|
|
+ $key = $value['code'] . $sn_val['sn'];
|
|
|
|
+ $submit_info[] = $key;
|
|
|
|
+ if(! isset($sn_map[$key])) return [false, "产品编码:" . $value['code'] . "的产品序列码:" . $sn_val['sn'] . "在用友中不存在"];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //校验sn是否被占用
|
|
|
|
+ list($status, $msg) = $service->snForCheck($code, $sn, $submit_info, $data);
|
|
|
|
+ if(! $status) return [false, $msg];
|
|
|
|
+
|
|
|
|
+ return [true, ''];
|
|
|
|
+ }
|
|
}
|
|
}
|