|
@@ -6,7 +6,9 @@ use App\Model\Construction;
|
|
|
use App\Model\ConstructionInfo;
|
|
|
use App\Model\Customer;
|
|
|
use App\Model\CustomerInfo;
|
|
|
+use App\Model\Depart;
|
|
|
use App\Model\Employee;
|
|
|
+use App\Model\EmployeeDepartPermission;
|
|
|
use App\Model\OrderOperation;
|
|
|
use App\Model\SalesOrder;
|
|
|
use App\Model\SalesOrderInfo;
|
|
@@ -242,6 +244,11 @@ class DeleteService extends Service
|
|
|
if(! is_array($data['fp_top_depart_id'])) $fp_top_depart_id = [$data['fp_top_depart_id']];
|
|
|
else $fp_top_depart_id = $data['fp_top_depart_id'];
|
|
|
|
|
|
+ $man = $data['man'] ?? [];
|
|
|
+ $list = Depart::where('del_time',0)->select('id','parent_id')->get()->toArray();
|
|
|
+ list($status,$msg) = $this->checkRule($man, $fp_top_depart_id, $list);
|
|
|
+ if(! $status) return [false, $msg];
|
|
|
+
|
|
|
$insert = [];
|
|
|
foreach ($data_id as $id){
|
|
|
foreach ($fp_top_depart_id as $value){
|
|
@@ -414,6 +421,11 @@ class DeleteService extends Service
|
|
|
if(! is_array($data['fp_top_depart_id'])) $fp_top_depart_id = [$data['fp_top_depart_id']];
|
|
|
else $fp_top_depart_id = $data['fp_top_depart_id'];
|
|
|
|
|
|
+ $man = $data['man'] ?? [];
|
|
|
+ $list = Depart::where('del_time',0)->select('id','parent_id')->get()->toArray();
|
|
|
+ list($status,$msg) = $this->checkRule($man, $fp_top_depart_id, $list);
|
|
|
+ if(! $status) return [false, $msg];
|
|
|
+
|
|
|
$insert = [];
|
|
|
foreach ($data_id as $id){
|
|
|
foreach ($fp_top_depart_id as $value){
|
|
@@ -432,6 +444,39 @@ class DeleteService extends Service
|
|
|
return [true, ''];
|
|
|
}
|
|
|
|
|
|
+ public function checkRule($man_id = [], $top_depart_id = [], $depart_list){
|
|
|
+ $depart = EmployeeDepartPermission::whereIn('employee_id', $man_id)
|
|
|
+ ->select('employee_id','depart_id')
|
|
|
+ ->get()->toArray();
|
|
|
+
|
|
|
+ $depart_has = [];
|
|
|
+ foreach ($depart as $value){
|
|
|
+ $p = $this->findTopLevelId($depart_list, $value['depart_id']);
|
|
|
+ if($p > 0) $depart_has[$value['employee_id']][] = $p;
|
|
|
+ }
|
|
|
+ if(empty($depart_has)) return [false, '无相关信息能获取到门店数据,校验失败'];
|
|
|
+
|
|
|
+ if(count($depart_has) == 1){
|
|
|
+ $intersection = array_values($depart_has);
|
|
|
+ $intersection = $intersection[0];
|
|
|
+ }else{
|
|
|
+ // 提取所有的子数组
|
|
|
+ $subArrays = array_map(function($item) {
|
|
|
+ return $item;
|
|
|
+ }, $depart_has);
|
|
|
+
|
|
|
+ // 使用 array_intersect 计算交集
|
|
|
+ $intersection = call_user_func_array('array_intersect', $subArrays);
|
|
|
+ if(empty($intersection)) return [false, '非法数据,请刷新网页重新操作'];
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach ($top_depart_id as $value){
|
|
|
+ if(! in_array($value, $intersection)) return [false, '非法数据,请刷新网页重新操作'];
|
|
|
+ }
|
|
|
+
|
|
|
+ return [true, ''];
|
|
|
+ }
|
|
|
+
|
|
|
public function pq($data,$user){
|
|
|
list($status,$msg) = $this->pqRule($data,$user);
|
|
|
if(! $status) return [false,$msg];
|