|
@@ -3,6 +3,8 @@
|
|
|
namespace App\Service;
|
|
|
|
|
|
use App\Model\BasicType;
|
|
|
+use App\Model\Depart;
|
|
|
+
|
|
|
/**
|
|
|
* 基础分类设置相关
|
|
|
*/
|
|
@@ -158,4 +160,61 @@ class BasicTypeService extends Service
|
|
|
|
|
|
return $data;
|
|
|
}
|
|
|
+
|
|
|
+ public function maked(){
|
|
|
+ $list = BasicType::where('del_time',0)
|
|
|
+ ->select('title','type','top_depart_id')
|
|
|
+ ->get()->toArray();
|
|
|
+ $basic_type2 = [];
|
|
|
+ $basic_other_type = [];
|
|
|
+ foreach ($list as $value){
|
|
|
+ if($value['top_depart_id'] == 2){
|
|
|
+ if(! in_array($value['type'], [28,23,24,22,8])){
|
|
|
+ $basic_type2[] = $value['title'] . '|' . $value['type'];
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $basic_other_type[$value['top_depart_id']][] = $value['title'] . '|' . $value['type'];
|
|
|
+ }
|
|
|
+ }dd($basic_type2);
|
|
|
+ $depart = Depart::where('del_time',0)
|
|
|
+ ->where('id','<>',2)
|
|
|
+ ->where('parent_id',0)
|
|
|
+// ->whereIn('id',[139,49])
|
|
|
+ ->select('id')
|
|
|
+ ->orderBy('id','asc')
|
|
|
+ ->get()->toArray();
|
|
|
+ $depart = array_column($depart,'id');
|
|
|
+ $insert = [];
|
|
|
+ $time = time();
|
|
|
+ foreach ($depart as $value){
|
|
|
+ if(! empty($basic_other_type[$value])){
|
|
|
+ foreach ($basic_type2 as $val){
|
|
|
+ if(! in_array($val,$basic_other_type[$value])) {
|
|
|
+ $tmp = explode('|',$val);
|
|
|
+ $insert[] = [
|
|
|
+ 'title' => $tmp[0],
|
|
|
+ 'type' => $tmp[1],
|
|
|
+ 'top_depart_id' => $value,
|
|
|
+ 'crt_time' => $time,
|
|
|
+ 'crt_id' => 1
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ foreach ($basic_type2 as $val){
|
|
|
+ $tmp = explode('|',$val);
|
|
|
+ $insert[] = [
|
|
|
+ 'title' => $tmp[0],
|
|
|
+ 'type' => $tmp[1],
|
|
|
+ 'top_depart_id' => $value,
|
|
|
+ 'crt_time' => $time,
|
|
|
+ 'crt_id' => 1
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(! empty($insert)) BasicType::insert($insert);
|
|
|
+ dd('ok');
|
|
|
+ }
|
|
|
}
|