diff --git a/app/admin/controller/Index.php b/app/admin/controller/Index.php index 9248c37..ea75c50 100644 --- a/app/admin/controller/Index.php +++ b/app/admin/controller/Index.php @@ -44,57 +44,36 @@ class Index extends BaseController public function main() { - $street_id=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->value('street_id'); $street_name=Db::table('fa_geo_street')->where('street_code',$street_id)->value('street_name'); if ($this->adminInfo['group_access']==4){ $urls="http://zhen.lihaink.cn/#/?street_id=$street_id"."&street_name=".$street_name; - return << - 跳转大屏 - - - - -EOT; + View::assign('urls',$urls); + return View('main3'); }elseif($this->adminInfo['group_access']==5){ + $day_price=Db::connect('shop')->table('eb_product_order_log')->where('street_id',$street_id) + ->where('status',1) + ->whereDay('create_time') + ->sum('product_price'); + $day_order=Db::connect('shop')->table('eb_product_order_log')->where('street_id',$street_id) + ->where('status',1) + ->whereDay('create_time') + ->count(); + $Month_price=Db::connect('shop')->table('eb_product_order_log')->where('street_id',$street_id) + ->where('status',1) + ->whereMonth('create_time') + ->sum('product_price'); + $Month_order=Db::connect('shop')->table('eb_product_order_log')->where('street_id',$street_id) + ->where('status',1) + ->whereMonth('create_time') + ->count(); $urls="http://zhenqiye.lihaink.cn/#/?street_id=$street_id"."&street_name=".$street_name; - return << - 跳转大屏 - - - - -EOT; + View::assign('urls',$urls); + View::assign('day_order',$day_order); + View::assign('day_price',$day_price); + View::assign('month_price',$Month_price); + View::assign('month_order',$Month_order); + return View('main2'); } if ($this->adminInfo['id']!=1){ $find = Db::table('fa_szxc_information_useraddress')->where('user_id', $this->adminInfo['user_id'])->find(); diff --git a/app/admin/controller/nk/ArticleCommon.php b/app/admin/controller/nk/ArticleCommon.php new file mode 100644 index 0000000..20a4c17 --- /dev/null +++ b/app/admin/controller/nk/ArticleCommon.php @@ -0,0 +1,263 @@ +adminInfo = get_login_admin(); + // $this->pid = 361; + $this->category_id = 362; + $this->url=[ + '/admin/nk.culturatour/index?category_id='.$this->category_id, + '/admin/nk.culturatour/add', + '/admin/nk.culturatour/edit', + '/admin/nk.culturatour/del', + '/admin/nk.culturatour/read', + ]; + } + + /** + * 文章列表 + */ + function Index(){ + if (request()->isAjax()) { + $params= get_params(); + $params['category_id']=$this->category_id; + + $where = ['category_id'=>$this->category_id]; + $list = Db::table('fa_article')->field('id')->where($where) + ->page(1) + ->limit(1) + ->order('id desc') + ->select(); + (new Article())->index($params); + } + return view('nk/article/index',['url'=>$this->url]); + } + + /** + * 查看文章 【无关联表】 + */ + function Read(){ + $params = get_params(); + (new Article())->read($params); + + return view('nk/article/read',['url'=>$this->url]); + } + + /** + * 添加文章【无关联表】 + */ + function Add(){ + if (request()->isAjax()) { + $params= get_params(); + $params['category_id']=$this->category_id; + // unset($params['amp;']); + (new Article())->add($params); + }else{ + View::assign('editor', get_system_config('other','editor')); + View::assign('url', $this->url); + // 获取用户信息 + $this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select(); + View::assign('users', $this->users); + $street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500']) + ->field('area_id id,area_code code,area_name name') + ->select(); + View::assign('street', $street); + return view('nk/article/add'); + } + } + + /** + * 编辑文章 【无关联表】 + */ + function Edit(){ + $params= get_params(); + (new Article())->edit($params); + return view('nk/article/edit',['url'=>$this->url]); + } + + /** + * 删除文章【无关联表】 + */ + function Del(){ + $params= get_params(); + (new Article())->del($params); + } + + + /** + * 添加文章与关联表数据. + * 【有关联表】 + */ + function addArticle($param, $callback){ + // 检验完整性 + try { + validate(\app\admin\validate\nk\ArticleValidate::class)->check($param); + } catch (ValidateException $e) { + // 验证失败 输出错误信息 + return to_assign(1, $e->getError()); + } + $adds=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->find(); + if($this->adminInfo['position_id'] != 1) { //不是超级管理员 + $param['county']=$adds['area_id']; + $param['township']=$adds['street_id']; + $param['village']=$adds['village_id']; + $param['user_id']=$adds['user_id']; + }else{ + if(empty($param['county'])){ + $param['county']=$adds['area_id']; + } + if(empty($param['township'])){ + $param['township']=$adds['street_id']; + } + if(empty($param['village'])){ + $param['village']=$adds['village_id']; + } + if(empty($param['user_id'])){ + $param['user_id']=$adds['user_id']; + } + } + + $param['view_time']=date('Y-m-d H:i:s'); + if(empty($param['category_type'])){ + $param['category_type'] = 0; + } + if(empty($param['end_time'])){ + $param['end_time'] = date('Y-m-d H:i:s'); + } + + Db::startTrans(); + try{ + // 新建文章 + $aid = Db::table('fa_article')->strict(false)->field(true)->insertGetId($param); + + // 新建文章相关表的信息 + $pid = $callback($aid); + }catch(ExceptionDbException $e){ + Db::rollback(); + return to_assign(1, '操作失败,原因:'.$e->getMessage()); + } + if (!empty($aid) && !empty($pid)) { + Db::commit(); + if(!empty($param['is_vote']) && $param['is_vote']==1){ + $data=['start_time'=>date('Y-m-d H:i:s'),'end_time'=>$param['end_time'],'article_id'=>$aid,'county'=>$adds['area_id'],'township'=>$adds['street_id'],'village'=>$adds['village_id']]; + Db::table('fa_article_vote_side_tables')->insert($data); + } + return to_assign(0,'操作成功',['aid'=>$aid]); + } + + return to_assign(1, '操作失败,原因:'.$aid); + } + + /** + * 1. 获取编辑页展示文章与关联表数据. + * 【有关联表】 + */ + function getEditData($param, $id, $callback){ + + // 获取指定文章 + $detail = Db::table('fa_article')->where('id',$id)->withAttr('lesson', + $callback + )->find(); + + View::assign('editor', get_system_config('other','editor')); + + // 获取此文章的用户信息 + if (!empty($detail)) { + View::assign('detail', $detail); + //获取用户信息 + $this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select(); + View::assign('users', $this->users); + $street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500']) + ->field('area_id id,area_code code,area_name name') + ->select(); + View::assign('street', $street); + } + else{ + throw new \think\exception\HttpException(404, '找不到页面'); + } + } + + /** + * 2. ajax提交编辑更新文章与关联表数据. + * 【有关联表】 + */ + function updateEditData($param, $id, $callback){ + try { + validate(\app\admin\validate\nk\ArticleValidate::class)->check($param); + } catch (ValidateException $e) { + // 验证失败 输出错误信息 + return to_assign(1, $e->getError()); + } + + $adds=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->find(); + if($this->adminInfo['position_id'] == 1) { //是超级管理员 + if(empty($param['county'])){ + $param['county']=$adds['area_id']; + } + if(empty($param['township'])){ + $param['township']=$adds['street_id']; + } + if(empty($param['village'])){ + $param['village']=$adds['village_id']; + } + if(empty($param['user_id'])){ + $param['user_id']=$adds['user_id']; + } + } + + // 更新文章信息 + $res=Db::table('fa_article')->where('id',$id)->strict(false)->field(true)->update($param); + + // 更新文章相关的扩展信息 + $callback($param); + if ($res){ + // 更新文章相关的投票信息 + if(!empty($param['is_vote']) && $param['is_vote']==1){ + Db::table('fa_article_vote_side_tables')->where('article_id',$id)->update(['end_time'=>$param['end_time']]); + } + return to_assign(); + }else{ + return to_assign(1, '操作失败,原因:'.$res); + } + } + + /** + * 文章与关联表删除 + * 【有关联表】 + */ + function delArticle($id, $callback){ + + // 此处同时删除两个表 + Db::startTrans(); + try{ + $res1 = Db::table('fa_article')->where('id',$id)->delete(); + $pid = $callback($id); + }catch (ExceptionDbException $e){ + Db::rollback(); + $res1 = $pid = ''; + return ["code"=>1, "msg"=>'操作失败,原因:'.$e->getMessage()]; + } + if ($res1 && $pid){ + Db::commit(); + return ["code"=>0, "msg"=>'操作成功']; + }else{ + return ["code"=>1, "msg"=>'操作失败,原因:两表一起删除失败[主表:'.$res1.'][联表:'.$pid.']']; + } + } +} \ No newline at end of file diff --git a/app/admin/controller/nk/CulturalArticle.php b/app/admin/controller/nk/CulturalArticle.php new file mode 100644 index 0000000..71b94c8 --- /dev/null +++ b/app/admin/controller/nk/CulturalArticle.php @@ -0,0 +1,21 @@ +category_id = 362; + $this->url=[ + '/admin/nk.cultural_article/index?category_id='.$this->category_id, + '/admin/nk.cultural_article/add', + '/admin/nk.cultural_article/edit', + '/admin/nk.cultural_article/del', + '/admin/nk.cultural_article/read', + ]; + } + +} \ No newline at end of file diff --git a/app/admin/controller/nk/CulturalCard.php b/app/admin/controller/nk/CulturalCard.php new file mode 100644 index 0000000..c94b3f4 --- /dev/null +++ b/app/admin/controller/nk/CulturalCard.php @@ -0,0 +1,21 @@ +category_id = 361; + $this->url=[ + '/admin/nk.cultural_card/index?category_id='.$this->category_id, + '/admin/nk.cultural_card/add', + '/admin/nk.cultural_card/edit', + '/admin/nk.cultural_card/del', + '/admin/nk.cultural_card/read', + ]; + } +} \ No newline at end of file diff --git a/app/admin/controller/nk/CulturalPlay.php b/app/admin/controller/nk/CulturalPlay.php new file mode 100644 index 0000000..6c3ec7b --- /dev/null +++ b/app/admin/controller/nk/CulturalPlay.php @@ -0,0 +1,21 @@ +category_id = 360; + $this->url=[ + '/admin/nk.cultural_play/index?category_id='.$this->category_id, + '/admin/nk.cultural_play/add', + '/admin/nk.cultural_play/edit', + '/admin/nk.cultural_play/del', + '/admin/nk.cultural_play/read', + ]; + } +} \ No newline at end of file diff --git a/app/admin/controller/nk/CulturalStrategy.php b/app/admin/controller/nk/CulturalStrategy.php new file mode 100644 index 0000000..8e34cc6 --- /dev/null +++ b/app/admin/controller/nk/CulturalStrategy.php @@ -0,0 +1,21 @@ +category_id = 364; + $this->url=[ + '/admin/nk.cultural_strategy/index?category_id='.$this->category_id, + '/admin/nk.cultural_strategy/add', + '/admin/nk.cultural_strategy/edit', + '/admin/nk.cultural_strategy/del', + '/admin/nk.cultural_strategy/read', + ]; + } +} \ No newline at end of file diff --git a/app/admin/controller/nk/EducationLive.php b/app/admin/controller/nk/EducationLive.php new file mode 100644 index 0000000..c1489a2 --- /dev/null +++ b/app/admin/controller/nk/EducationLive.php @@ -0,0 +1,171 @@ +adminInfo = get_login_admin(); + $this->category_id = 370; + $this->url=[ + '/admin/nk.education_live/index?category_id='.$this->category_id, + '/admin/nk.education_live/add', + '/admin/nk.education_live/edit', + '/admin/nk.education_live/del', + '/admin/nk.education_live/read', + ]; + } + + /** + * 查看 待完 + */ + function Read() { + $param = get_params(); + $id = isset($param['id']) ? $param['id'] : 0; + $detail = Db::table('fa_article')->where('id',$id)->withAttr('lesson', + function($value, $data)use($id){ + return Db::table(self::ARTICLE_EDUCATION_LIVE)->field('lesson_period,tag_ids as series_num')->where('article_id', $id)->find(); + } + )->find(); + + // !待开发--课程集数\ 学习人数 + // ->withAttr('learner', + // function($value, $data)use($id){ + // return Db::table(self::ARTICLE_EDUCATION_LIVE)->field('lesson_period,tag_ids as num')->where('article_id', $id)->find(); + // } + // ) + // echo '
';print_r($detail);
+        // exit();
+        if (!empty($detail)) {
+            $detail['comment'] = Db::table('fa_article_comment')
+                                ->where('vote_id',$id)
+                                ->withAttr('user_info',function ($value,$data){
+                                    return Db::table('fa_szxc_information_usermsg')->where('user_id',$data['user_id'])->value('name');
+                                })->select();
+            View::assign('detail', $detail);
+            View::assign('admin_id', $this->adminInfo['id']);
+            return view('nk/educationlive/read',['url'=>$this->url]);
+        }else{
+            throw new \think\exception\HttpException(404, '找不到页面');
+        }
+    }
+
+
+    /**
+     * 添加
+     */
+    function Add(){
+        if (request()->isAjax()) {
+            $params= get_params();
+            $params['category_id']=$this->category_id;
+            // unset($params['amp;']);
+            $this->addArticle($params, function($aid)use($params){
+                $params['article_id'] = $aid;
+                return Db::table(self::ARTICLE_EDUCATION_LIVE)->strict(false)->field(true)->insertGetId($params);
+            });
+        }else{
+            View::assign('editor', get_system_config('other','editor'));
+            View::assign('url', $this->url);
+            //        获取用户信息
+            $this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
+            View::assign('users', $this->users);
+            $street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
+                ->field('area_id id,area_code code,area_name name')
+                ->select();
+            View::assign('street', $street);
+            return view('nk/educationlive/add');
+        }
+    }
+
+    /**
+     * 编辑 
+     */
+    function Edit(){
+        $params= get_params();
+        $aid = isset($params['id']) ? $params['id'] : 0;
+        if (request()->isAjax()) {
+            $this->updateEditData($params, $aid, function($param)use($aid){
+                if (!empty($param['tags_id'])){
+                    Db::table(self::ARTICLE_EDUCATION_LIVE)->where('article_id',$aid)->update(['tags_id'=>$param['tags_id']]);
+                }
+            });
+            
+        }else{
+
+            $this->getEditData($params, $aid, function()use($aid){
+                return Db::table(self::ARTICLE_EDUCATION_LIVE)->field('lesson_period,tag_ids as series_num')->where('article_id', $aid)->find();
+            });
+
+        }
+        return view('nk/educationlive/edit',['url'=>$this->url]);
+    }
+
+    /**
+     * 删除
+     */
+    function Del(){
+        $param = get_params();
+        $id = isset($param['id']) ? $param['id'] : 0;
+        // $type = isset($param['type']) ? $param['type'] : 0;
+
+        // 此处同时删除两个表
+        $res = $this->delArticle($id, function($id){
+             $vid = Db::table(self::ARTICLE_EDUCATION_LIVE)->where('article_id', $id)->value('id');
+            if (!empty($vid)) {
+                return Db::table(self::ARTICLE_EDUCATION_LIVE)->where('id', $vid)->delete();
+            }else{
+                return true;
+            }
+        });
+
+        if ($res["code"]==1){
+            return to_assign(1, $res['msg']);
+        }else{
+            return to_assign();
+        }
+    }
+}
\ No newline at end of file
diff --git a/app/admin/controller/nk/HouseDecorationCase.php b/app/admin/controller/nk/HouseDecorationCase.php
new file mode 100644
index 0000000..585c5fb
--- /dev/null
+++ b/app/admin/controller/nk/HouseDecorationCase.php
@@ -0,0 +1,21 @@
+category_id = 371;
+        $this->url=[
+            '/admin/nk.house_decoration_case/index?category_id='.$this->category_id,
+            '/admin/nk.house_decoration_case/add',
+            '/admin/nk.house_decoration_case/edit',
+            '/admin/nk.house_decoration_case/del',
+            '/admin/nk.house_decoration_case/read',
+        ];
+    }
+}
\ No newline at end of file
diff --git a/app/admin/controller/nk/HouseDecorationCompany.php b/app/admin/controller/nk/HouseDecorationCompany.php
new file mode 100644
index 0000000..ae73c25
--- /dev/null
+++ b/app/admin/controller/nk/HouseDecorationCompany.php
@@ -0,0 +1,21 @@
+category_id = 372;
+        $this->url=[
+            '/admin/nk.house_decoration_company/index?category_id='.$this->category_id,
+            '/admin/nk.house_decoration_company/add',
+            '/admin/nk.house_decoration_company/edit',
+            '/admin/nk.house_decoration_company/del',
+            '/admin/nk.house_decoration_company/read',
+        ];
+    }
+}
\ No newline at end of file
diff --git a/app/admin/controller/nk/PublicBenefitActivities.php b/app/admin/controller/nk/PublicBenefitActivities.php
new file mode 100644
index 0000000..7a2fc03
--- /dev/null
+++ b/app/admin/controller/nk/PublicBenefitActivities.php
@@ -0,0 +1,21 @@
+adminInfo = get_login_admin();
+        $this->category_id = 369;
+        $this->url=[
+            '/admin/nk.publicbenefitactivities/index?category_id='.$this->category_id,
+            '/admin/nk.public_benefit_activities/add',
+            '/admin/nk.public_benefit_activities/edit',
+            '/admin/nk.public_benefit_activities/del',
+            '/admin/nk.public_benefit_activities/read',
+        ];
+    }
+}
\ No newline at end of file
diff --git a/app/admin/controller/nk/PublicBenefitEnroll.php b/app/admin/controller/nk/PublicBenefitEnroll.php
new file mode 100644
index 0000000..f8aef46
--- /dev/null
+++ b/app/admin/controller/nk/PublicBenefitEnroll.php
@@ -0,0 +1,198 @@
+adminInfo = get_login_admin();
+        $this->category_id = 368;
+        $this->url=[
+            '/admin/nk.public_benefit_enroll/index?category_id='.$this->category_id,
+            '/admin/nk.public_benefit_enroll/add',
+            '/admin/nk.public_benefit_enroll/edit',
+            '/admin/nk.public_benefit_enroll/del',
+            '/admin/nk.public_benefit_enroll/read',
+        ];
+    }
+
+    /**
+     * 添加
+     */
+    function Add(){
+        if (request()->isAjax()) {
+            $params= get_params();
+            $params['category_id']=$this->category_id;
+            // unset($params['amp;']);
+
+            // 更新文章信息
+            $this->addArticle($params, function($aid)use($params){
+                $params['article_id'] = $aid;
+                // 更新文章相关的报名信息
+                return Db::table(ARTICLE_EDUCATION_LIVE)->strict(false)->field(true)->insertGetId(['article_id'=>$aid,'promoter'=>$params['promoter'],'enrolled_num'=>$params['enrolled_num']]);
+            });
+        }else{
+            View::assign('editor', get_system_config('other','editor'));
+            View::assign('url', $this->url);
+            //        获取用户信息
+            $this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
+            View::assign('users', $this->users);
+            $street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
+                ->field('area_id id,area_code code,area_name name')
+                ->select();
+            View::assign('street', $street);
+            return view('nk/publicbenefitenroll/add');
+        }
+    }
+
+    /**
+     * 查看
+     */
+    function Read(){
+        $param = get_params();
+        $id = isset($param['id']) ? $param['id'] : 0;
+        $detail = Db::table('fa_article')->where('id',$id)->withAttr('enroll', function($value, $data)use($id){
+            return Db::table(self::ARTICLE_PUBLIC_BENEFIT)->field('promoter,enrolled_num')->where('article_id', $id)->find();
+        })->find();
+    
+        if (!empty($detail)) {
+            $detail['comment'] = Db::table('fa_article_comment')
+                                ->where('vote_id',$id)
+                                ->withAttr('user_info',function ($value,$data){
+                                    return Db::table('fa_szxc_information_usermsg')->where('user_id',$data['user_id'])->value('name');
+                                })->select();
+            View::assign('detail', $detail);
+            View::assign('admin_id', $this->adminInfo['id']);
+            return view('nk/publicbenefitenroll/read',['url'=>$this->url]);
+        }else{
+            throw new \think\exception\HttpException(404, '找不到页面');
+        }
+    }
+
+    /**
+     * 公益项目报名修改
+     */
+    function Edit(){
+        $param= get_params();
+        $id = isset($param['id']) ? $param['id'] : 0;
+        if (request()->isAjax()) {
+            try {
+                validate(\app\admin\validate\nk\ArticleValidate::class)->check($param);
+            } catch (ValidateException $e) {
+                // 验证失败 输出错误信息
+                return to_assign(1, $e->getError());
+            }
+
+            $adds=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->find();
+            if($this->adminInfo['position_id'] == 1) { //是超级管理员
+                if(empty($param['county'])){
+                    $param['county']=$adds['area_id'];
+                }
+                if(empty($param['township'])){
+                    $param['township']=$adds['street_id'];
+                }
+                if(empty($param['village'])){
+                    $param['village']=$adds['village_id'];
+                }
+                if(empty($param['user_id'])){
+                    $param['user_id']=$adds['user_id'];
+                }
+            }
+
+            // 更新文章信息
+            $res=Db::table('fa_article')->where('id',$param['id'])->strict(false)->field(true)->update($param);
+            // 更新文章相关的报名信息
+            if (!empty($param['promoter'] || !empty($param['enrolled_num']))){
+                $res = Db::table(self::ARTICLE_PUBLIC_BENEFIT)->where('article_id',$id)->update(['promoter'=>$param['promoter'],'enrolled_num'=>$param['enrolled_num']]);
+            }
+            if ($res){
+                // 更新文章相关的投票信息
+                if(!empty($param['is_vote']) && $param['is_vote']==1){
+                    Db::table('fa_article_vote_side_tables')->where('article_id',$param['id'])->update(['end_time'=>$param['end_time']]);
+                }
+                return to_assign();
+            }else{
+                return to_assign(1, '操作失败,原因:'.$res);
+            }
+        }else{
+            // 获取指定公益项目文章
+            $detail = Db::table('fa_article')->where('id',$id)->withAttr('enroll', function($value, $data)use($id){
+                return Db::table(self::ARTICLE_PUBLIC_BENEFIT)->field('promoter,enrolled_num')->where('article_id', $id)->find();
+            })->find();
+            View::assign('editor', get_system_config('other','editor'));
+
+            // 获取此文章的用户信息
+            if (!empty($detail)) {
+                // echo '
';print_r($detail);
+                View::assign('detail', $detail);
+                //        获取用户信息
+                $this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
+                View::assign('users', $this->users);
+                $street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
+                    ->field('area_id id,area_code code,area_name name')
+                    ->select();
+                View::assign('street', $street);
+            }
+            else{
+                throw new \think\exception\HttpException(404, '找不到页面');
+            }
+        }
+        return view('nk/publicbenefitenroll/edit',['url'=>$this->url]);
+    }
+
+    function Del(){
+        $param = get_params();
+        $id = isset($param['id']) ? $param['id'] : 0;
+        // $type = isset($param['type']) ? $param['type'] : 0;
+
+        // 此处同时删除两个表
+        Db::startTrans();
+        
+        try{
+            $res1 = Db::table('fa_article')->where('id',$id)->delete();
+
+            $pid = Db::table(self::ARTICLE_PUBLIC_BENEFIT)->where('article_id', $id)->value('id');
+
+            if (!empty($pid)) {
+                $res2 = Db::table(self::ARTICLE_PUBLIC_BENEFIT)->where('article_id', $pid)->delete();
+            }else{
+                $pid = true;
+            }
+            
+        }catch (ExceptionDbException $e){
+            Db::rollback();
+            $res1 = $pid = '';
+            return to_assign(1, '操作失败,原因:'.$e->getMessage());
+        }
+        if ($res1 && $pid){
+            Db::commit();
+            return to_assign();
+        }else{
+            return to_assign(1, '操作失败,原因1:'.$res1);
+        }
+    }
+}
\ No newline at end of file
diff --git a/app/admin/controller/nk/common/Article.php b/app/admin/controller/nk/common/Article.php
new file mode 100644
index 0000000..b7e74c2
--- /dev/null
+++ b/app/admin/controller/nk/common/Article.php
@@ -0,0 +1,263 @@
+adminInfo = get_login_admin();
+        // $this->pid = 361;
+        $this->category_id = 362;
+        $this->url=[
+            '/admin/nk.culturatour/index?category_id='.$this->category_id,
+            '/admin/nk.culturatour/add',
+            '/admin/nk.culturatour/edit',
+            '/admin/nk.culturatour/del',
+            '/admin/nk.culturatour/read',
+        ];
+    }
+
+    /**
+     * 文章列表 
+     */
+    function Index(){
+        if (request()->isAjax()) {
+            $params= get_params();
+            $params['category_id']=$this->category_id;
+
+            $where = ['category_id'=>$this->category_id];
+            $list = Db::table('fa_article')->field('id')->where($where)
+            ->page(1)
+            ->limit(1)
+            ->order('id desc')
+            ->select();
+            (new Article())->index($params);
+        }
+        return view('nk/article/index',['url'=>$this->url]);
+    }
+
+    /**
+     * 查看文章 【无关联表】
+     */
+    function Read(){
+        $params = get_params();
+        (new Article())->read($params);
+
+        return view('nk/article/read',['url'=>$this->url]);
+    }
+
+    /**
+     * 添加文章【无关联表】
+     */
+    function Add(){
+        if (request()->isAjax()) {
+            $params= get_params();
+            $params['category_id']=$this->category_id;
+            // unset($params['amp;']);
+            (new Article())->add($params);
+        }else{
+            View::assign('editor', get_system_config('other','editor'));
+            View::assign('url', $this->url);
+            //        获取用户信息
+            $this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
+            View::assign('users', $this->users);
+            $street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
+                ->field('area_id id,area_code code,area_name name')
+                ->select();
+            View::assign('street', $street);
+            return view('nk/article/add');
+        }
+    }
+
+    /**
+     * 编辑文章 【无关联表】
+     */
+    function Edit(){
+        $params= get_params();
+        (new Article())->edit($params);
+        return view('nk/article/edit',['url'=>$this->url]);
+    }
+
+    /**
+     * 删除文章【无关联表】
+     */
+    function Del(){
+        $params= get_params();
+        (new Article())->del($params);
+    }
+
+
+    /**
+     * 添加文章与关联表数据.
+     * 【有关联表】
+     */
+    function addArticle($param, $callback){
+        // 检验完整性
+        try {
+            validate(\app\admin\validate\nk\ArticleValidate::class)->check($param);
+        } catch (ValidateException $e) {
+            // 验证失败 输出错误信息
+            return to_assign(1, $e->getError());
+        }
+        $adds=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->find();
+        if($this->adminInfo['position_id'] != 1) { //不是超级管理员
+            $param['county']=$adds['area_id'];
+            $param['township']=$adds['street_id'];
+            $param['village']=$adds['village_id'];
+            $param['user_id']=$adds['user_id'];
+        }else{
+            if(empty($param['county'])){
+                $param['county']=$adds['area_id'];
+            }
+            if(empty($param['township'])){
+                $param['township']=$adds['street_id'];
+            }
+            if(empty($param['village'])){
+                $param['village']=$adds['village_id'];
+            }
+            if(empty($param['user_id'])){
+                $param['user_id']=$adds['user_id'];
+            }
+        }
+
+        $param['view_time']=date('Y-m-d H:i:s');
+        if(empty($param['category_type'])){
+            $param['category_type'] = 0;
+        }
+        if(empty($param['end_time'])){
+            $param['end_time'] = date('Y-m-d H:i:s');
+        }
+
+        Db::startTrans();
+        try{
+            // 新建文章
+            $aid = Db::table('fa_article')->strict(false)->field(true)->insertGetId($param);
+
+            // 新建文章相关表的信息
+            $pid = $callback($aid);
+        }catch(ExceptionDbException $e){
+            Db::rollback();
+            return to_assign(1, '操作失败,原因:'.$e->getMessage());
+        }
+        if (!empty($aid) && !empty($pid)) {
+            Db::commit();
+            if(!empty($param['is_vote']) && $param['is_vote']==1){
+                $data=['start_time'=>date('Y-m-d H:i:s'),'end_time'=>$param['end_time'],'article_id'=>$aid,'county'=>$adds['area_id'],'township'=>$adds['street_id'],'village'=>$adds['village_id']];
+                Db::table('fa_article_vote_side_tables')->insert($data);
+            }
+            return to_assign(0,'操作成功',['aid'=>$aid]);
+        }
+        
+        return to_assign(1, '操作失败,原因:'.$aid);
+    }
+
+    /**
+     * 1. 获取编辑页展示文章与关联表数据.
+     * 【有关联表】
+     */
+    function getEditData($param, $id, $callback){
+
+        // 获取指定文章
+        $detail = Db::table('fa_article')->where('id',$id)->withAttr('lesson', 
+            $callback
+        )->find();
+
+        View::assign('editor', get_system_config('other','editor'));
+
+        // 获取此文章的用户信息
+        if (!empty($detail)) {
+            View::assign('detail', $detail);
+            //获取用户信息
+            $this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
+            View::assign('users', $this->users);
+            $street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
+                ->field('area_id id,area_code code,area_name name')
+                ->select();
+            View::assign('street', $street);
+        }
+        else{
+            throw new \think\exception\HttpException(404, '找不到页面');
+        }
+    }
+
+    /**
+     * 2. ajax提交编辑更新文章与关联表数据.
+     * 【有关联表】
+     */
+    function updateEditData($param, $id, $callback){
+        try {
+            validate(\app\admin\validate\nk\ArticleValidate::class)->check($param);
+        } catch (ValidateException $e) {
+            // 验证失败 输出错误信息
+            return to_assign(1, $e->getError());
+        }
+
+        $adds=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->find();
+        if($this->adminInfo['position_id'] == 1) { //是超级管理员
+            if(empty($param['county'])){
+                $param['county']=$adds['area_id'];
+            }
+            if(empty($param['township'])){
+                $param['township']=$adds['street_id'];
+            }
+            if(empty($param['village'])){
+                $param['village']=$adds['village_id'];
+            }
+            if(empty($param['user_id'])){
+                $param['user_id']=$adds['user_id'];
+            }
+        }
+
+        // 更新文章信息
+        $res=Db::table('fa_article')->where('id',$id)->strict(false)->field(true)->update($param);
+
+        // 更新文章相关的扩展信息
+        $callback($param);
+        if ($res){
+            // 更新文章相关的投票信息
+            if(!empty($param['is_vote']) && $param['is_vote']==1){
+                Db::table('fa_article_vote_side_tables')->where('article_id',$id)->update(['end_time'=>$param['end_time']]);
+            }
+            return to_assign();
+        }else{
+            return to_assign(1, '操作失败,原因:'.$res);
+        }
+    }
+
+    /**
+     * 文章与关联表删除
+     * 【有关联表】
+     */
+    function delArticle($id, $callback){
+
+        // 此处同时删除两个表
+        Db::startTrans();
+        try{
+            $res1 = Db::table('fa_article')->where('id',$id)->delete();
+            $pid = $callback($id);
+        }catch (ExceptionDbException $e){
+            Db::rollback();
+            $res1 = $pid = '';
+            return ["code"=>1, "msg"=>'操作失败,原因:'.$e->getMessage()];
+        }
+        if ($res1 && $pid){
+            Db::commit();
+            return ["code"=>0, "msg"=>'操作成功'];
+        }else{
+            return ["code"=>1, "msg"=>'操作失败,原因:两表一起删除失败[主表:'.$res1.'][联表:'.$pid.']'];
+        }
+    }
+}
\ No newline at end of file
diff --git a/app/admin/model/StoreProduct.php b/app/admin/model/StoreProduct.php
index 0cbd642..1d6243b 100644
--- a/app/admin/model/StoreProduct.php
+++ b/app/admin/model/StoreProduct.php
@@ -18,7 +18,7 @@ class StoreProduct extends Model
     {
 		$rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit'];
 		$order = empty($param['order']) ? 'product_id desc' : $param['order'];
-        $list = self::where($where)->field('product_id,mer_id,store_name,store_info,keyword,brand_id,cate_id,unit_name,sort,sales,price,cost,ot_price,stock,is_hot,is_benefit,temp_id,spec_type,image,slider_image,once_max_count,once_min_count,integral_rate,integral_total,integral_price_total,labels,delivery_free,type,extend,pay_limit,svip_price_type,svip_price,mer_svip_status,param_temp_id')->order($order)->paginate($rows, false, ['query' => $param]);
+        $list = self::where($where)->order($order)->paginate($rows, false, ['query' => $param]);
 		return $list;
     }
 
diff --git a/app/admin/view/index/main2.html b/app/admin/view/index/main2.html
new file mode 100644
index 0000000..2302dfd
--- /dev/null
+++ b/app/admin/view/index/main2.html
@@ -0,0 +1,104 @@
+{extend name="common/base"/}
+{block name="style"}
+
+{/block}
+
+{block name="body"}
+
+
+
+
+
今日订单金额
+
+
{$day_price}
+ + + + + + + +
+
+
+
+
+
今日订单数
+
+
{$day_order}
+
+
+
+
+
+
当月订单金额
+
+
{$month_price}
+
+
+
+
+
+
当月订单数
+
+
{$month_order}
+
+
+
+
+ + + +
+{/block} + + + +{block name="script"} + + + +{/block} + \ No newline at end of file diff --git a/app/admin/view/index/main3.html b/app/admin/view/index/main3.html new file mode 100644 index 0000000..9fdc189 --- /dev/null +++ b/app/admin/view/index/main3.html @@ -0,0 +1,63 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} + + + + + +{/block} + + + +{block name="script"} + + + +{/block} + \ No newline at end of file diff --git a/app/admin/view/nk/educationlive/add.html b/app/admin/view/nk/educationlive/add.html new file mode 100644 index 0000000..0715b93 --- /dev/null +++ b/app/admin/view/nk/educationlive/add.html @@ -0,0 +1,276 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+

新建文章

+ + + + + + {notempty name="is_vote"} + + + + + {/notempty} + + + + + + + + + + + + + + + + + + + + {if {:session('gougu_admin')['group_access']==1} + + + + + + + + + + + + + + + + + + + + {/if} + + + + + + + + + + +
文章标题*
结束时间* + +
文章摘要 + + 缩略图 +
+ +
+ + +
+
+
课时* + + + 分钟课程数 + +
标签(多选)* +
+
+
+
+
+
区县 +
+
+ +
+
+
街道/镇 +
+
+
+
+
+
村/社区 +
+
+
+
+
+
用户* +
+ +
+
文章内容
+ +
+
+ + +
+
+{/block} + + + +{block name="script"} + + +{/block} + \ No newline at end of file diff --git a/app/admin/view/nk/educationlive/edit.html b/app/admin/view/nk/educationlive/edit.html new file mode 100644 index 0000000..e9233db --- /dev/null +++ b/app/admin/view/nk/educationlive/edit.html @@ -0,0 +1,245 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+

编辑文章表

+ + + + + + {notempty name="is_vote"} + + + + + {/notempty} + + + + + + + + + + + + + {if {:session('gougu_admin')['group_access']==1} + + + + + + + + + + + + + + + + + + + {/if} + + + + + + + +
文章标题*
结束时间* + +
摘要 + + 缩略图 +
+ +
+ + +
+
+
课时{$detail.lesson.lesson_period}学习人数{$detail.lesson.series_num}
区县 +
+
+ +
+
+
街道/镇 +
+
+
+
+
+
村/社区 +
+
+
+
+
+
用户* +
+ +
+
文章内容
+ +
+
+ + + +
+
+{/block} + + + +{block name="script"} + + +{/block} + \ No newline at end of file diff --git a/app/admin/view/nk/educationlive/read.html b/app/admin/view/nk/educationlive/read.html new file mode 100644 index 0000000..4449f11 --- /dev/null +++ b/app/admin/view/nk/educationlive/read.html @@ -0,0 +1,100 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+

文章详情

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + {if in_array($detail.category_id,[149,157,158,148,147,165]) } + + + + + {/if} + + {if in_array($detail.category_id,[149,157,158,148,147,165]) } + + + + + {/if} + + +
文章标题{$detail.title}
创建时间{$detail.view_time}状态 + {eq name="$detail.status" value="1"}正常{/eq} + {eq name="$detail.status" value="0"}下架{/eq} +
文章摘要{$detail.describe}
课时{$detail.lesson.lesson_period}学习人数{$detail.lesson.series_num}
文章内容 + {$detail.content|raw} +
回复内容: + {volist name="$detail.comment" id="vo"} + {$vo.user_info}的回复:{$vo.content}
+ {/volist} +
回复: + +
+ {if in_array($detail.category_id,[149,157,158,148,147,165]) } +
+ + + + +
+ {/if} +
+{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/nk/publicbenefitenroll/add.html b/app/admin/view/nk/publicbenefitenroll/add.html new file mode 100644 index 0000000..c7b106d --- /dev/null +++ b/app/admin/view/nk/publicbenefitenroll/add.html @@ -0,0 +1,234 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+

新建文章

+ + + + + + {notempty name="is_vote"} + + + + + {/notempty} + + + + + + + + + + + + + {if {:session('gougu_admin')['group_access']==1} + + + + + + + + + + + + + + + + + + + + {/if} + + + + + + + + + + +
文章标题*
结束时间* + +
文章摘要 + + 缩略图 +
+ +
+ + +
+
+
发起人* + + 报名人数 + +
区县 +
+
+ +
+
+
街道/镇 +
+
+
+
+
+
村/社区 +
+
+
+
+
+
用户* +
+ +
+
文章内容
+ +
+
+ + +
+
+{/block} + + + +{block name="script"} + + +{/block} + \ No newline at end of file diff --git a/app/admin/view/nk/publicbenefitenroll/edit.html b/app/admin/view/nk/publicbenefitenroll/edit.html new file mode 100644 index 0000000..e6c1ca4 --- /dev/null +++ b/app/admin/view/nk/publicbenefitenroll/edit.html @@ -0,0 +1,253 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+

编辑文章表

+ + + + + + {notempty name="is_vote"} + + + + + {/notempty} + + + + + + + + + + + + + {if {:session('gougu_admin')['group_access']==1} + + + + + + + + + + + + + + + + + + + {/if} + + + + + + + +
文章标题*
结束时间* + +
摘要 + + 缩略图 +
+ +
+ + +
+
+
发起人* + + 报名人数 + +
区县 +
+
+ +
+
+
街道/镇 +
+
+
+
+
+
村/社区 +
+
+
+
+
+
用户* +
+ +
+
文章内容
+ +
+
+ + + +
+
+{/block} + + + +{block name="script"} + + +{/block} + \ No newline at end of file diff --git a/app/admin/view/nk/publicbenefitenroll/read.html b/app/admin/view/nk/publicbenefitenroll/read.html new file mode 100644 index 0000000..bed8184 --- /dev/null +++ b/app/admin/view/nk/publicbenefitenroll/read.html @@ -0,0 +1,105 @@ +{extend name="common/base"/} +{block name="style"} + +{/block} + +{block name="body"} +
+

文章详情

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {if in_array($detail.category_id,[149,157,158,148,147,165]) } + + + + + {/if} + + {if in_array($detail.category_id,[149,157,158,148,147,165]) } + + + + + {/if} + + +
文章标题{$detail.title}
创建时间{$detail.view_time}状态 + {eq name="$detail.status" value="1"}正常{/eq} + {eq name="$detail.status" value="0"}下架{/eq} +
文章摘要{$detail.describe}
发起人{$detail.enroll.promoter}参与人数{$detail.enroll.enrolled_num}
文章内容 + {$detail.content|raw} +
回复内容: + {volist name="$detail.comment" id="vo"} + {$vo.user_info}的回复:{$vo.content}
+ {/volist} +
回复: + +
+ {if in_array($detail.category_id,[149,157,158,148,147,165]) } +
+ + + + +
+ {/if} +
+{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/admin/view/store_product/add.html b/app/admin/view/store_product/add.html index a351cc6..d5368fe 100644 --- a/app/admin/view/store_product/add.html +++ b/app/admin/view/store_product/add.html @@ -68,10 +68,10 @@
+ style=" overflow: hidden;"> @@ -90,7 +90,7 @@
+ style="overflow: hidden;">
diff --git a/app/admin/view/store_product/edit.html b/app/admin/view/store_product/edit.html index 3bbd5c0..2ad9a35 100644 --- a/app/admin/view/store_product/edit.html +++ b/app/admin/view/store_product/edit.html @@ -67,10 +67,10 @@
+ style=" overflow: hidden;"> @@ -85,10 +85,10 @@
+ style=" overflow: hidden;"> {volist name='detail.slider_image_arr' id='vo'} {if $vo}
+ style="overflow: hidden;"> @@ -82,7 +82,7 @@
+ style="overflow: hidden;"> {volist name='detail.slider_image_arr' id='vo'} {if $vo} ['except' => ['WebStrategy','HotParty','PunchCard','Article'] ] + ]; + + protected function getData($cid){ + $where = ['category_id'=>$cid]; + $list = Db::table('fa_article')->where($where) + ->page(1) + ->limit(10) + ->order('id desc') + ->select(); + + return $list; + } + + public function WebStrategy(){ + $data = $this->getData(364); + $this->apiSuccess('ok', ['list' => $data]); + } + + public function HotParty() { + $data = $this->getData(360); + $this->apiSuccess('ok', ['list' => $data]); + } + + public function PunchCard(){ + $data = $this->getData(361); + $this->apiSuccess('ok', ['list' => $data]); + } + + public function Article(){ + $data = $this->getData(362); + $this->apiSuccess('ok', ['list' => $data]); + } + + + + public function index1($search = '', $category_id = 1, $page = 1, $is_time = 0, $category_type = 0) + { + $param = get_params(); + + $screen = $param['screen']??1; + $solve = $param['solve']??1; + $order = $param['order']??1; +// $model = Db::table('fa_article'); + $where = [ + ['status', '=', 1], + ['category_id', '=', $category_id] + ]; + //查询升降序 + if($order==1){ + $orders='desc'; + }else{ + $orders='asc'; + } + if (!$category_id) { + unset($where[1]); + } + //根据个人村id进行查询 + if (JWT_UID) { + $find = Db::table('fa_szxc_information_useraddress')->where('user_id', JWT_UID)->find(); + if ($find) { + if ($find['auth_range']==1){ + $where[] = ['village', '=', $find['village_id']]; + }elseif ($find['auth_range']==2){ + $where[] = ['township', '=', $find['street_id']]; + }elseif ($find['auth_range']==3){ + $where[] = ['county', '=', $find['area_id']]; + } + } + // 登录返回村名和村地址 + $cun_arr['cun_name'] = Db::table('fa_geo_village')->where('village_id', $find['village_id'])->value('village_name'); + $cun_arr['cun_address'] = Db::table('fa_szxc_information_usermsg')->where('user_id', JWT_UID)->value('address_name'); + }else{ + $cun_arr = []; + } + + if(isset($param['street_id']) && !empty($param['street_id'])){ + $where[] = ['township', '=', $param['street_id']]; + } + if(isset($param['village_id']) && !empty($param['village_id'])){ + $where[] = ['village', '=', $param['village_id']]; + } + + //总条数 + $count = Db::table('fa_article')->where($where)->count(); + //当月条数 + $month_count = Db::table('fa_article')->where($where)->whereMonth('view_time')->count(); + if ($search != '') { + $where[] = ['title', 'like', '%' . $search . '%']; + } + if ($category_type != 0) { + $where[] = ['category_type', '=', $category_type]; + } + //判断筛选查询 + if ($screen==2){ + foreach ($where as $key =>$value){ + $where[$key][0] = 'a.'.$value[0]; + } + //查询 + $select = Db::table('fa_article')->where($where)->page($page)->limit(20) + ->alias('a') + ->join(['fa_article_vote_side_tables' => 'avst'],"a.id = avst.article_id and avst.end_time >=".date('Y-m-d')) + ->field('a.id,a.title,a.describe,a.user_id,a.view,a.view_time,a.image,a.end_time,a.is_solve,a.is_vote,a.is_nickname,a.video,a.category_type,avst.end_time as die_time') + ->order('a.id DESC') + ->select()->toArray(); + }else if ($screen==3){ + foreach ($where as $key =>$value){ + $where[$key][0] = 'a.'.$value[0]; + } + //查询 + $select = Db::table('fa_article')->where($where)->page($page)->limit(20) + ->alias('a') + ->join(['fa_article_vote_side_tables' => 'avst'],"a.id = avst.article_id and avst.end_time <=".date('Y-m-d')) + ->field('a.id,a.title,a.describe,a.user_id,a.view,a.view_time,a.image,a.end_time,a.is_solve,a.is_vote,a.is_nickname,a.video,a.category_type,avst.end_time as die_time') + ->order('a.id DESC')->select()->toArray(); + }else{ + //查询是否解决 + if($solve==2){ + $where[] = ['is_solve', '=', 0]; + }else if($solve==3){ + $where[] = ['is_solve', '=', 1]; + } + $select = Db::table('fa_article')->with('user')->where($where)->page($page)->limit(20) + ->field('id,title,user_id,view,view_time,image,end_time,is_solve,is_vote,is_nickname,video,category_type,describe') + ->order('id',$orders)->select()->toArray(); + } + + foreach ($select as $key => $value) { + if ($value['is_nickname'] == 1) { + $select[$key]['nickname'] = "匿名人员"; + $select[$key]['avatar'] = ""; + $select[$key]['user_id'] = 0; + } else { + $select[$key]['nickname'] = Db::table('fa_szxc_information_usermsg')->where('user_id', $value['user_id'])->value('name'); + } + //投票处理 + if ($value['is_vote'] == 1) { + $article_vote = Db::table('fa_article_vote_side_tables')->where('article_id', $value['id'])->find(); + if ($article_vote) { + $data = $article_vote; + $data['agree_percentage'] = 0; + $data['opposition_percentage'] = 0; + $count_vote = $data['agree'] + $data['opposition'] + $data['other']; + if ($count_vote != 0) { + if ($data['agree'] != 0) { + $data['agree_percentage'] = round(($data['agree'] / $count_vote) * 100); + } + if ($data['opposition'] != 0) { + $data['opposition_percentage'] = round(($data['opposition'] / $count_vote) * 100); + } + } + $select[$key]['extend']['vote'] = $data; + } + } else { + $select[$key]['extend'] = []; + } + if ($is_time == 1) { + if ($value['end_time'] < date('Y-m-d H:i:s')) { + if ($value['end_time'] == '0000-00-00 00:00:00') { + $select[$key]['overdue_time'] = '显示错误'; + } else { + if($value['is_solve']==1){ + $select[$key]['overdue_time'] = 0; + }else{ + $cle = time() - strtotime($value['end_time']); + $select[$key]['overdue_time'] = ceil($cle / 3600 / 24); + } + } + } else { + $select[$key]['overdue_time'] = 0; + } + + } + if ($category_id == 165) { + if ($value['category_type'] != 0) { + $find = Db::table('fa_category')->where('id', $value['category_type'])->find(); + $select[$key]['extend']['category_type_name'] = $find ? $find['name'] . ':' : ''; + } else { + $select[$key]['extend']['category_type_name'] = ''; + } + } + + + } + $this->apiSuccess('ok', ['list' => $select, 'cun'=>$cun_arr, 'count' => ['count' => $count, 'month_count' => $month_count]]); + } + + /**首页推荐 + * @param $category_id + * @param $page + */ + public function hot_list($category_id = 0, $page = 1, $county = 0, $township = 0, $village = 0) + { + $where = [ + ['status', '=', 1], + ]; + if (!$category_id) { + unset($where[1]); + } +// 如果登录 + if (JWT_UID) { + $find = Db::table('fa_szxc_information_useraddress')->where('user_id', JWT_UID)->find(); + if ($find) { + if ($find['auth_range']==1){ + $where[] = ['village', '=', $find['village_id']]; + }elseif ($find['auth_range']==2){ + $where[] = ['township', '=', $find['street_id']]; + }elseif ($find['auth_range']==3){ + $where[] = ['county', '=', $find['area_id']]; + } + } + } +// if ($county != 0) { +// $where[] = ['county', '=', $county]; +// } +// if ($township != 0) { +// $where[] = ['township', '=', $township]; +// } +// if ($village != 0) { +// $where[] = ['village', '=', $village]; +// } + if ($category_id == 0) { + $where[] = ['category_id', 'in', [176, 162, 161, 160, 152]]; + $sos = Db::table('fa_article')->where('category_id', 150)->where('status', 1) + ->whereTime('view_time','between', [date("H:i:s",strtotime("-5 minute")), date("H:i:s",strtotime("+5 minute"))]) + ->page($page)->limit(3) + ->withAttr('user_info', function ($value, $data) { + $user = Db::table('fa_user')->where('id', $data['user_id'])->field('nickname,avatar')->find(); + $user['name'] = Db::table('fa_szxc_information_usermsg')->where('user_id', $data['user_id'])->value('name'); + return $user; + }) + ->withAttr('article_comment', function ($value, $data) { + return Db::table('fa_article_comment')->where([['vote_id','=',$data['id']],['status','=',1]])->count(); + }) + ->withAttr('article_type', function ($value, $data) { + return '一键求救'; + }) + ->field('id,title,user_id,view,view_time,image,end_time,is_solve,is_vote,is_nickname,video,category_id,source')->order('id DESC') + ->withAttr('image', function ($value, $data) { + if ($data['image'] != '') { + return explode(',', $data['image']); + } + }) + ->select()->toArray(); + } else { + $where[] = ['category_id', '=', $category_id]; + $sos = []; + } + //查询 + $mapo[] = [['category_id','=','1'],['status','=','1']]; + $select = Db::table('fa_article')->where($where)->whereOr($mapo)->page($page)->limit(20) + ->withAttr('user_info', function ($value, $data) { + $user = Db::table('fa_user')->where('id', $data['user_id'])->field('nickname,avatar')->find(); + $user['name'] = Db::table('fa_szxc_information_usermsg')->where('user_id', $data['user_id'])->value('name'); + return $user; + }) + ->field('id,title,describe,user_id,view,view_time,image,end_time,is_solve,is_vote,is_nickname,video,category_id')->order('id DESC') + ->withAttr('image', function ($value, $data) { + if ($data['image'] != '') { + return explode(',', $data['image']); + } + }) + ->withAttr('article_comment', function ($value, $data) { + return Db::table('fa_article_comment')->where([['vote_id','=',$data['id']],['status','=',1]])->count(); + }) + ->withAttr('article_type', function ($value, $data) { + if($data['category_id'] == 1){ + return '实时信息'; + }elseif($data['category_id'] == 176){ + return '党务公开'; + }elseif($data['category_id'] == 162){ + return '议事大厅'; + }elseif($data['category_id'] == 161){ + return '财务公开'; + }elseif($data['category_id'] == 160){ + return '村务公开'; + }elseif($data['category_id'] == 152){ + return '好人好事'; + }else{ + return ''; + } + }) + ->select()->toArray(); + $personal=Db::table('fa_szxc_personal_news') + ->withAttr('user_info', function ($value, $data) { + $user = Db::table('fa_user')->where('id', $data['user_id'])->field('nickname,avatar')->find(); + $user['name'] = Db::table('fa_szxc_information_usermsg')->where('user_id', $data['user_id'])->value('name'); + return $user; + }) + ->withAttr('image', function ($value, $data) { + if ($data['image'] != '') { + return json_decode($data['image'],true); + } + }) + ->withAttr('article_comment', function ($value, $data) { + return Db::table('fa_szxc_personal_news_comment')->where([['personal_news_id','=',$data['id']],['status','=',1]])->count(); + }) + ->withAttr('article_type', function ($value, $data) { + return Db::table('fa_category')->where('id', $data['category_id'])->value('name'); + }) + ->withAttr('view_time', function ($value, $data) { + return date('Y-m-d H:i:s', $value); + }) + ->field('id,id as personal_news_id,content as title,user_id,view,createtime as view_time,images as image,video,category_id') + ->limit(5)->order('id desc')->page($page)->select()->toArray(); + $i=0; + $personal_count=count($personal); + if ($select && $personal){ + foreach($select as $key=>$value){ + if ($key!=0 &&$key%2==0 &&$i<$personal_count){ + array_splice($select,$key+$i,0,[$personal[$i]]); + ++$i; + } + } + } + $this->apiSuccess('ok', ['list' => array_merge($sos, $select)]); + } + + /**首页分类列表 + * @param $category_id + * @param $page + */ + public function getArticleList($category_id = 0, $page = 1, $type = 1) + { +// $model = Db::table('fa_article'); + $where = [ + ['status', '=', 1], + ]; + //根据个人村id进行查询 + if (JWT_UID) { + $find = Db::table('fa_szxc_information_useraddress')->where('user_id', JWT_UID)->find(); + if ($find) { + if ($find['auth_range']==1){ + $where[] = ['village', '=', $find['village_id']]; + }elseif ($find['auth_range']==2){ + $where[] = ['township', '=', $find['street_id']]; + }elseif ($find['auth_range']==3){ + $where[] = ['county', '=', $find['area_id']]; + } + } + } + if ($type == 1) { + $where[] = ['category_id', 'in', [162, 161, 160, 152]]; + + } else { + $where[] = ['category_id', '=', $category_id]; + } + //查询 + $select = Db::table('fa_article')->where($where)->page($page)->limit(20) + ->field('id,title,user_id,view,view_time,image,end_time,is_solve,is_vote,is_nickname,video,category_id')->order('id DESC') + ->withAttr('image', function ($value, $data) { + if ($data['image'] != '') { + return explode(',', $data['image']); + } + }) + ->withAttr('user_info', function ($value, $data) { + $user = Db::table('fa_user')->where('id', $data['user_id'])->field('nickname,avatar')->find(); + $user['name'] = Db::table('fa_szxc_information_usermsg')->where('user_id', $data['user_id'])->value('name'); + return $user; + }) + ->withAttr('article_comment', function ($value, $data) { + return Db::table('fa_article_comment')->where([['vote_id','=',$data['id']],['status','=',1]])->count(); + }) + ->withAttr('article_type', function ($value, $data) { + if($data['category_id'] == 176){ + return '党务公开'; + }elseif($data['category_id'] == 162){ + return '议事大厅'; + }elseif($data['category_id'] == 161){ + return '财务公开'; + }elseif($data['category_id'] == 160){ + return '村务公开'; + }elseif($data['category_id'] == 152){ + return '好人好事'; + }else{ + return ''; + } + }) + ->select()->toArray(); + return $this->apiSuccess('ok', ['list' => $select]); + } + + /**详情 + * @param $id + * @return null + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function details($id) + { +// 增加阅读数 +// $ip = 'article-details-'.$this->request->ip().'-'.$id; +// $ip_cache = Cache::get($ip); +// if(empty($ip_cache)){ +// Cache::set($ip,$id,3600*24); + $map[] =['id','=', $id]; + Db::table('fa_article')->where($map)->inc('view','1')->update(); +// } + + $where = [ + ['status', '=', 1], + ['id', '=', $id] + ]; + $find = Db::table('fa_article')->where($where) + ->withAttr('user_info', function ($data, $value) { + $find['nickname'] = "匿名人员"; + $find['mobile'] = "匿名状态无法显示"; + $find['gender'] = "匿名状态无法显示"; + $find['avatar'] = ""; + $find['user_id'] = 0; + $find['count'] = 0; + $find['end_count'] = 0; + $find['overdue_count'] = 0; + if ($value['is_nickname'] == 0) { + $user = Db::table('fa_user')->where('id', $value['user_id'])->field('nickname,avatar,mobile')->find(); + if ($user) { + $find = $user; + } + $find['nickname'] = Db::table('fa_szxc_information_usermsg')->where('user_id', $value['user_id'])->value('name'); + } + $config_find = Db::table('fa_config')->where('id', 20)->find(); + //是否查询提案数 + if (in_array($value['category_id'], explode(',', $config_find['value']))) { + //提案总数 + $where = [ + ['category_id', '=', $value['category_id']], + ['user_id', '=', $value['user_id']] + ]; + //处理总数 + $whereTwo = [ + ['category_id', '=', $value['category_id']], + ['user_id', '=', $value['user_id']], + ['is_solve', '=', 1] + ]; + $find['count'] = Db::table('fa_article')->where($where)->count(); + $find['end_count'] = Db::table('fa_article')->where($whereTwo)->count(); + //逾期总数 + $where[] = ['is_solve', '=', 0]; + $find['overdue_count'] = Db::table('fa_article')->where($where)->whereTime('end_time', '<=', date('Y-m-d H:i:s')) + ->count(); + $usermsg = Db::table('fa_szxc_information_usermsg')->where('user_id', $value['user_id'])->field('age,address_name,gender,name')->find(); + if ($value['is_nickname']==1){ + $find['age'] ='匿名状态无法显示'; + $find['address'] = '匿名状态无法显示'; + $find['gender'] = '匿名状态无法显示'; + }else{ + $find['age'] = $usermsg?$usermsg['age']:''; + $find['address'] = $usermsg?$usermsg['address_name']:''; + if ($usermsg){ + $find['gender'] =$usermsg['gender']==1?'男':'女'; + } + $find['nickname'] = $usermsg['name']; + } + $insurance = Db::table('fa_szxc_information_insurance')->where('user_id', $value['user_id'])->field('insurance_type')->find(); + if ($insurance) { + $find['insurance_type'] = $insurance['insurance_type']; + } else { + $find['insurance_type'] = ""; + } + } + return $find; + })->withAttr('category_type_title', function ($data, $value) { + if ($value['category_type'] != 0) { + $find = Db::table('fa_category')->where('id', $value['category_type'])->find(); + return $find['name']; + } + }) + ->find(); + //投票处理 + if ($find['is_vote'] == 1) { + $article_vote = Db::table('fa_article_vote_side_tables')->where('article_id', $find['id'])->find(); + if ($article_vote) { + $data = $article_vote; + $data['agree_percentage'] = 0; + $data['opposition_percentage'] = 0; + $count_vote = $data['agree'] + $data['opposition'] + $data['other']; + if ($count_vote != 0) { + if ($data['agree'] != 0) { + $data['agree_percentage'] = round(($data['agree'] / $count_vote) * 100); + } + if ($data['opposition'] != 0) { + $data['opposition_percentage'] = round(($data['opposition'] / $count_vote) * 100); + } + } + $find['extend']['vote'] = $data; + } + + } else { + $find['extend'] = []; + + } + return $this->apiSuccess('ok', $find); + } + + +} diff --git a/app/api/controller/Education.php b/app/api/controller/Education.php new file mode 100644 index 0000000..f26aa91 --- /dev/null +++ b/app/api/controller/Education.php @@ -0,0 +1,47 @@ + ['except' => ['Index'] ] + ]; + + protected function getData($cid){ + $where = ['category_id'=>$cid]; + $list = Db::table('fa_article')->withAttr('lesson', + function($value, $data){ + return Db::table(self::ARTICLE_EDUCATION_LIVE)->field('lesson_period,tag_ids as series_num')->where('article_id', $data['id'])->find(); + } + ) + ->where($where) + ->page(1) + ->limit(10) + ->order('id desc') + ->select(); + + return $list; + } + + public function Index(){ + $data = $this->getData(370); + $this->apiSuccess('ok', ['list' => $data]); + } + +} diff --git a/app/api/controller/HouseDecoration.php b/app/api/controller/HouseDecoration.php new file mode 100644 index 0000000..63ae3e4 --- /dev/null +++ b/app/api/controller/HouseDecoration.php @@ -0,0 +1,50 @@ + ['except' => ['case','store'] ] + ]; + + protected function getData($cid){ + $where = ['category_id'=>$cid]; + $list = Db::table('fa_article') + // ->withAttr('enroll', + // function($value, $data){ + // return Db::table(self::ARTICLE_PUBLIC_BENEFIT)->field('promoter,enrolled_num')->where('article_id', $data['id'])->find(); + // } + // ) + ->where($where) + ->page(1) + ->limit(10) + ->order('id desc') + ->select(); + + return $list; + } + + public function case(){ + $data = $this->getData(499); + $this->apiSuccess('ok', ['list' => $data]); + } + + public function store(){ + $data = $this->getData(501); + $this->apiSuccess('ok', ['list' => $data]); + } + +} diff --git a/app/api/controller/PublicBenefit.php b/app/api/controller/PublicBenefit.php new file mode 100644 index 0000000..db6ab9b --- /dev/null +++ b/app/api/controller/PublicBenefit.php @@ -0,0 +1,51 @@ + ['except' => ['Enroll','Activites'] ] + ]; + + protected function getData($cid){ + $where = ['category_id'=>$cid]; + $list = Db::table('fa_article')->withAttr('enroll', + function($value, $data){ + return Db::table(self::ARTICLE_PUBLIC_BENEFIT)->field('promoter,enrolled_num')->where('article_id', $data['id'])->find(); + } + ) + ->where($where) + ->page(1) + ->limit(10) + ->order('id desc') + ->select(); + + return $list; + } + + public function Enroll(){ + $data = $this->getData(368); + $this->apiSuccess('ok', ['list' => $data]); + } + + public function Activites(){ + $data = $this->getData(369); + $this->apiSuccess('ok', ['list' => $data]); + } + +} diff --git a/public/nginx.htaccess b/public/nginx.htaccess new file mode 100644 index 0000000..a9942c4 --- /dev/null +++ b/public/nginx.htaccess @@ -0,0 +1,51 @@ +#ļΪNginxα̬ļ PHPCUSTOMٷַhttp://www.phpcustom.com http://www.lccee.com + + + + + +# 301תãԶ޸Ϊ + if ($Host = 'xxx.com'){ + rewrite ^/(.*)$ http://www.phpcustom.com/$1 permanent; + } + + + + + + +#Ϊphpwind9.0α̬,ȥ#Ч +#------------------------------------------------------------------------------------------------ + +# if (-f $request_filename) { +# break; +# } +# if ($request_filename ~* "\.(js|ico|gif|jpe?g|bmp|png|css)$") { +# break; +# } +# if (!-e $request_filename) { +# rewrite . /index.php last; +# } + + + + + +# ThinkPHP V5α̬ʾ ȥ´ǰߵ#żЧ + +#------------------------------------------------------------------------------------------------ +#if (!-e $request_filename) { +# rewrite ^(.*)$ /index.php?s=/$1 last; +# break; +# } + +#------------------------------------------------------------------------------------------------ + + + + + + + + +