diff --git a/admin/application/index/controller/Tasktimer.php b/admin/application/index/controller/Tasktimer.php index cd0f0a6..88cf632 100755 --- a/admin/application/index/controller/Tasktimer.php +++ b/admin/application/index/controller/Tasktimer.php @@ -181,7 +181,7 @@ class Tasktimer extends Controller $birthday_record = Db::table('fa_mattertemplatecategorization') ->alias('m') ->join('fa_mattertemplatecategorizedcontent','fa_mattertemplatecategorizedcontent.mattertemplatecategorization_id = m.id') - ->where('m.firm_id','in',[$value['firm_id'],0]) + ->where('m.firm_id','in',[$value['firm_id'],1]) ->where('m.mattertemplate_id',3) ->order(['m.firm_id'=>'desc','m.id'=>'desc']) ->field('fa_mattertemplatecategorizedcontent.content') diff --git a/superadmin/application/admin/controller/Firm.php b/superadmin/application/admin/controller/Firm.php index 56de036..fa69456 100755 --- a/superadmin/application/admin/controller/Firm.php +++ b/superadmin/application/admin/controller/Firm.php @@ -124,17 +124,20 @@ class Firm extends Backend if (count($firmstoreData) == 0){ return json(['code'=>201,'msg'=>'请先添加门店']); } + //大类 $firmbigcategoryData = Db::table('fa_firmbigcategory')->where('firm_id',1)->select(); foreach ($firmbigcategoryData as $key=>&$val){ unset($val['id']); $val['firm_id'] = $ids; } + //客户来源 $firmcustomeroriginData = Db::table('fa_firmcustomerorigin')->where('firm_id',1)->select(); foreach ($firmcustomeroriginData as $key=>&$val){ unset($val['id']); $val['firm_id'] = $ids; } - $firmdutyData = Db::table('fa_firmduty')->where('firm_id',1)->select(); + //职务 + $firmdutyData = Db::table('fa_firmduty')->where('firm_id',1)->where('firmstore_id',1)->select(); $firmdutyMore = []; foreach ($firmdutyData as $key=>&$val){ $data = []; @@ -145,19 +148,74 @@ class Firm extends Backend $firmdutyMore[] = $data; } } + //标签 + $firmtagsData = Db::table('fa_firmtags')->where('firm_id',1)->select(); + foreach ($firmtagsData as $key=>&$val){ + unset($val['id']); + $val['firm_id'] = $ids; + } + $firmbigcategoryResult = false; $firmcustomerorigiResult = false; $firmdutyResult = false; + $firmtagsResult = false; Db::startTrans(); try { $firmbigcategoryResult = Db::table('fa_firmbigcategory')->insertAll($firmbigcategoryData); $firmcustomerorigiResult = Db::table('fa_firmcustomerorigin')->insertAll($firmcustomeroriginData); $firmdutyResult = Db::table('fa_firmduty')->insertAll($firmdutyMore); + $firmtagsResult = Db::table('fa_firmtags')->insertAll($firmtagsData); + //店铺项目 + $firmstoreprojectsoneData = Db::table('fa_firmstoreprojectsone')->where('firm_id',1)->where('firmstore_id',1)->select(); + foreach ($firmstoreprojectsoneData as $key=>&$val){ + foreach ($firmstoreData as &$v){ + $data = []; + $data['firm_id'] = $ids; + $data['name'] = $val['name']; + $data['firmstore_id'] = $v['id']; + //添加一级店铺项目 + $firmstoreprojectsone_id = Db::table('fa_firmstoreprojectsone')->insertGetId($data); + //查询二级店铺项目 + $firmstoreprojectstwoData = Db::table('fa_firmstoreprojectstwo')->where('firm_id',1) + ->where('firmstore_id',1)->where('firmstoreprojectsone_id',$val['id'])->select(); + foreach ($firmstoreprojectstwoData as &$value){ + $firmstoreprojectstwo_oldid = $value['id']; + unset($value['id']); + $value['firm_id'] = $ids; + $value['firmstore_id'] = $firmstoreprojectsone_id; + //添加二级店铺项目 + $firmstoreprojectstwo_id = Db::table('fa_firmstoreprojectstwo')->insertGetId($value); + //查询事例模块 + $mattertemplatecategorizationData = Db::table('fa_mattertemplatecategorization')->where('firm_id',1) + ->where('firmstoreprojectsone_id',$val['id'])->where('firmstoreprojectstwo_id',$firmstoreprojectstwo_oldid)->find(); + if ($mattertemplatecategorizationData){ + $mtc_id = $mattertemplatecategorizationData['id']; + unset($mattertemplatecategorizationData['id']); + $mattertemplatecategorizationData['firm_id'] = $ids; + $mattertemplatecategorizationData['firmstoreprojectsone_id'] = $firmstoreprojectsone_id; + $mattertemplatecategorizationData['firmstoreprojectstwo_id'] = $firmstoreprojectstwo_id; + $mattertemplatecategorizationData['create_time'] = date('Y-m-d H:i:s'); + $mattertemplatecategorizationData['update_time'] = date('Y-m-d H:i:s'); + $mattertemplatecategorization_id = Db::table('fa_mattertemplatecategorization')->insertGetId($mattertemplatecategorizationData); + //事例模块具体内容 + $fa_mattertemplatecategorizedcontent = Db::table('fa_mattertemplatecategorizedcontent') + ->where('mattertemplatecategorization_id',$mtc_id)->select(); + foreach ($fa_mattertemplatecategorizedcontent as &$values){ + unset($values['id']); + $values['mattertemplatecategorization_id'] = $mattertemplatecategorization_id; + $values['create_time'] = date('Y-m-d H:i:s'); + $values['update_time'] = date('Y-m-d H:i:s'); + } + Db::table('fa_mattertemplatecategorizedcontent')->insertAll($fa_mattertemplatecategorizedcontent); + } + } + } + } Db::commit(); }catch(ValidateException|PDOException|Exception $e){ return json(['code'=>201,'msg'=>$e->getMessage()]); } - if (!$firmbigcategoryResult || !$firmcustomerorigiResult || !$firmdutyResult){ + if (!$firmbigcategoryResult || !$firmcustomerorigiResult || !$firmdutyResult || !$firmtagsResult){ return json(['code'=>201,'msg'=>'导入失败']); } return json(['code'=>200,'msg'=>'导入成功']); diff --git a/superadmin/application/admin/controller/Firmbigcategory.php b/superadmin/application/admin/controller/Firmbigcategory.php index e296c77..50b74ea 100755 --- a/superadmin/application/admin/controller/Firmbigcategory.php +++ b/superadmin/application/admin/controller/Firmbigcategory.php @@ -53,7 +53,8 @@ class Firmbigcategory extends Backend $list = $this->model ->with(['firm']) ->where($where) - ->order($sort, $order) +// ->order($sort, $order) + ->order('firm_id asc,id desc') ->paginate($limit); foreach ($list as $row) { diff --git a/superadmin/application/admin/controller/Firmcustomerorigin.php b/superadmin/application/admin/controller/Firmcustomerorigin.php index 710eafb..2ca9bc2 100755 --- a/superadmin/application/admin/controller/Firmcustomerorigin.php +++ b/superadmin/application/admin/controller/Firmcustomerorigin.php @@ -53,7 +53,8 @@ class Firmcustomerorigin extends Backend $list = $this->model ->with(['firm']) ->where($where) - ->order($sort, $order) +// ->order($sort, $order) + ->order('firm_id asc,id desc') ->paginate($limit); foreach ($list as $row) { diff --git a/superadmin/application/admin/controller/Firmduty.php b/superadmin/application/admin/controller/Firmduty.php index 94c7b39..51076e7 100755 --- a/superadmin/application/admin/controller/Firmduty.php +++ b/superadmin/application/admin/controller/Firmduty.php @@ -53,7 +53,8 @@ class Firmduty extends Backend $list = $this->model ->with(['firm','firmstore']) ->where($where) - ->order($sort, $order) +// ->order($sort, $order) + ->order('firm_id asc,id desc') ->paginate($limit); foreach ($list as $row) { diff --git a/superadmin/application/admin/controller/Firmstoreprojectsone.php b/superadmin/application/admin/controller/Firmstoreprojectsone.php index cc33220..39ffbcc 100755 --- a/superadmin/application/admin/controller/Firmstoreprojectsone.php +++ b/superadmin/application/admin/controller/Firmstoreprojectsone.php @@ -53,7 +53,8 @@ class Firmstoreprojectsone extends Backend $list = $this->model ->with(['firm']) ->where($where) - ->order($sort, $order) +// ->order($sort, $order) + ->order('firm_id asc,id desc') ->paginate($limit); foreach ($list as $row) { diff --git a/superadmin/application/admin/controller/Firmtags.php b/superadmin/application/admin/controller/Firmtags.php index 460d069..1f34141 100755 --- a/superadmin/application/admin/controller/Firmtags.php +++ b/superadmin/application/admin/controller/Firmtags.php @@ -55,14 +55,16 @@ class Firmtags extends Backend list($where, $sort, $order, $offset, $limit) = $this->buildparams(); $list = $this->model - + ->with(['firm']) ->where($where) - ->order($sort, $order) +// ->order($sort, $order) + ->order('firm_id asc,id desc') ->paginate($limit); foreach ($list as $row) { $row->visible(['id','name']); - + $row->visible(['firm']); + $row->getRelation('firm')->visible(['full_name']); } $result = array("total" => $list->total(), "rows" => $list->items()); diff --git a/superadmin/application/admin/controller/Mattertemplatecategorization.php b/superadmin/application/admin/controller/Mattertemplatecategorization.php index ceb8884..5e84855 100644 --- a/superadmin/application/admin/controller/Mattertemplatecategorization.php +++ b/superadmin/application/admin/controller/Mattertemplatecategorization.php @@ -54,7 +54,8 @@ class Mattertemplatecategorization extends Backend $list = $this->model ->with(['mattertemplate','firmstoreprojectsone','firmstoreprojectstwo','firm']) ->where($where) - ->order($sort, $order) +// ->order($sort, $order) + ->order('firm_id asc,id desc') ->paginate($limit); foreach ($list as $row) { diff --git a/superadmin/application/admin/model/Firmtags.php b/superadmin/application/admin/model/Firmtags.php index fc097fe..ec91013 100755 --- a/superadmin/application/admin/model/Firmtags.php +++ b/superadmin/application/admin/model/Firmtags.php @@ -27,11 +27,14 @@ class Firmtags extends Model protected $append = [ ]; - - + public function firm() + { + return $this->belongsTo('Firm', 'firm_id', 'id', [], 'LEFT')->setEagerlyType(0); + } + diff --git a/superadmin/application/admin/view/firmstore/add.html b/superadmin/application/admin/view/firmstore/add.html index 2dbcdb6..5ed6270 100755 --- a/superadmin/application/admin/view/firmstore/add.html +++ b/superadmin/application/admin/view/firmstore/add.html @@ -4,9 +4,8 @@