Bladeren bron

add - 质保金限制师傅派单

liugc 1 jaar geleden
bovenliggende
commit
d15fccbd0c

+ 108 - 0
app/adminapi/controller/master_worker/MasterWorkerRuleController.php

@@ -0,0 +1,108 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+
+namespace app\adminapi\controller\master_worker;
+
+
+use app\adminapi\controller\BaseAdminController;
+use app\adminapi\lists\master_worker\MasterWorkerRuleLists;
+use app\adminapi\logic\master_worker\MasterWorkerRuleLogic;
+use app\adminapi\validate\master_worker\MasterWorkerRuleValidate;
+
+
+/**
+ * MasterWorkerRule控制器
+ * Class MasterWorkerRuleController
+ * @package app\adminapi\controller
+ */
+class MasterWorkerRuleController extends BaseAdminController
+{
+
+
+    /**
+     * @notes 获取列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/09/28 15:31
+     */
+    public function lists()
+    {
+        return $this->dataLists(new MasterWorkerRuleLists());
+    }
+
+
+    /**
+     * @notes 添加
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/09/28 15:31
+     */
+    public function add()
+    {
+        $params = (new MasterWorkerRuleValidate())->post()->goCheck('add');
+        $result = MasterWorkerRuleLogic::add($params);
+        if (true === $result) {
+            return $this->success('添加成功', [], 1, 1);
+        }
+        return $this->fail(MasterWorkerRuleLogic::getError());
+    }
+
+
+    /**
+     * @notes 编辑
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/09/28 15:31
+     */
+    public function edit()
+    {
+        $params = (new MasterWorkerRuleValidate())->post()->goCheck('edit');
+        $result = MasterWorkerRuleLogic::edit($params);
+        if (true === $result) {
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(MasterWorkerRuleLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/09/28 15:31
+     */
+    public function delete()
+    {
+        $params = (new MasterWorkerRuleValidate())->post()->goCheck('delete');
+        MasterWorkerRuleLogic::delete($params);
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/09/28 15:31
+     */
+    public function detail()
+    {
+        $params = (new MasterWorkerRuleValidate())->goCheck('detail');
+        $result = MasterWorkerRuleLogic::detail($params);
+        return $this->data($result);
+    }
+
+
+}

+ 35 - 100
app/adminapi/lists/master_worker/MasterWorkerLists.php

@@ -16,10 +16,12 @@ namespace app\adminapi\lists\master_worker;
 
 
 use app\adminapi\lists\BaseAdminDataLists;
+use app\adminapi\service\DistributeLeafletsService;
 use app\common\model\master_worker\MasterWorker;
 use app\common\lists\ListsSearchInterface;
 use app\common\model\works\ServiceWork;
 use think\db\Query;
+use think\facade\Log;
 
 /**
  * MasterWorker列表
@@ -29,6 +31,8 @@ use think\db\Query;
 class MasterWorkerLists extends BaseAdminDataLists implements ListsSearchInterface
 {
     public $count = 0;
+    public $lon = 0;
+    public $lat = 0;
 
     /**
      * @notes 设置搜索条件
@@ -57,11 +61,21 @@ class MasterWorkerLists extends BaseAdminDataLists implements ListsSearchInterfa
             $where[] = ['mwr.maintain_exp_type', '=', $this->params['worker_exp_type']];
         }
         if(isset($this->params['min_work_number']) && is_numeric($this->params['min_work_number'])){
-            $where[] =[ 'work_total','>=',$this->params['min_work_number']];
+            $where[] =[ 'mw.work_total','>=',$this->params['min_work_number']];
         }
         if(isset($this->params['max_work_number']) && is_numeric($this->params['max_work_number'])){
-            $where[] =[ 'work_total','work_total <= ',$this->params['max_work_number']];
+            $where[] =[ 'mw.work_total','<= ',$this->params['max_work_number']];
         }
+        $goods_category_id = 0;
+        if(isset($this->params['order_id']) && $this->params['order_id']){
+            $lon_lat = (ServiceWork::where('id',$this->params['order_id'])->column("lon,lat,goods_category_id"))[0];
+            $this->lon = $lon_lat['lon'];
+            $this->lat = $lon_lat['lat'];
+            $goods_category_id = $lon_lat['goods_category_id'];
+        }
+        $ids = DistributeLeafletsService::getIntersection($this->lon, $this->lat,$goods_category_id);
+        $where[] = [ 'mw.id','IN',$ids];
+        Log::debug('MasterWorker-where:'.json_encode($where));
         return $where;
     }
     /**
@@ -75,59 +89,22 @@ class MasterWorkerLists extends BaseAdminDataLists implements ListsSearchInterfa
      */
     public function lists(): array
     {
-        $customer_lon = 0;
-        $customer_lat = 0;
-        $goods_category_id = 0;
-        if(isset($this->params['order_id']) && $this->params['order_id']){
-            $lon_lat = (ServiceWork::where('id',$this->params['order_id'])->column("lon,lat,goods_category_id"))[0];
-            $customer_lon = $lon_lat['lon'];
-            $customer_lat = $lon_lat['lat'];
-            $goods_category_id = $lon_lat['goods_category_id'];
-
-            // whereFindInSet('category_ids',$goods_category_id)->
-        }
-        // 无人在0,0坐标上
-        if($customer_lon && $customer_lat){
-            // 查出所有的师傅 -> 计算距离 -> 按距离排序 -> 分页
-            $allList = MasterWorker::alias('mw')->join('master_worker_register mwr', 'mwr.worker_id = mw.id');
-            if($goods_category_id) $allList->whereFindInSet('mw.category_ids',$goods_category_id);
-            $allList = $allList->where($this->searchWhere)
-                ->where($this->queryWhere())
-                ->field([
-                    'mw.*',
-                    'mwr.maintain_exp_type',
-                    'mwr.other_exp_type',
-                ])
-                //->limit($this->limitOffset, $this->limitLength)
-                ->order(['mw.id' => 'desc'])
-                ->select()
-                ->toArray();
-
-            $allList = array_column($allList, null, 'id');
-            $mastersDistances = $this->mastersDistance($allList,$customer_lon,$customer_lat);
-            $list = $this->limitPage($allList,$mastersDistances,$this->params['page_no']??1,$this->params['page_size']??10);
-            $this->count = count($allList);
-        }else{
-            $list = MasterWorker::alias('mw')->join('master_worker_register mwr', 'mwr.worker_id = mw.id');
-            if($goods_category_id) $list->whereFindInSet('mw.category_ids',$goods_category_id);
-            $list = $list->where($this->searchWhere)
-                ->where($this->queryWhere())
-                ->field([
-                    'mw.*',
-                    'mwr.maintain_exp_type',
-                    'mwr.other_exp_type',
-                ])
-                ->limit($this->limitOffset, $this->limitLength)
-                ->order(['mw.id' => 'desc'])
-                ->select()
-                ->toArray();
-            $this->count = MasterWorker::alias('mw')
-                ->join('master_worker_register mwr', 'mwr.worker_id = mw.id');
-            if($goods_category_id) $this->count->whereFindInSet('mw.category_ids',$goods_category_id);
-            $this->count = $this->count->field([
-                    'mw.*'])
-                ->where($this->searchWhere)->where($this->queryWhere())
-                ->count();
+        $list = MasterWorker::alias('mw')
+            ->join('master_worker_register mwr', 'mwr.worker_id = mw.id')
+            ->where($this->searchWhere)
+            ->where($this->queryWhere())
+            ->field([
+                'mw.*',
+                'mwr.maintain_exp_type',
+                'mwr.other_exp_type',
+            ])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['mw.id' => 'desc'])
+            ->select()
+            ->toArray();
+        $distances = DistributeLeafletsService::locationIds($this->lon, $this->lat,0,array_keys(array_column($list, 'distance','id')));
+        foreach ($list as &$item){
+            $item['user_distance'] = $distances[$item['id']]??0;
         }
         return $list;
     }
@@ -141,54 +118,12 @@ class MasterWorkerLists extends BaseAdminDataLists implements ListsSearchInterfa
      */
     public function count(): int
     {
-        /*return MasterWorker::alias('mw')
+        return MasterWorker::alias('mw')
             ->join('master_worker_register mwr', 'mwr.worker_id = mw.id')
             ->field([
                 'mw.*'])
             ->where($this->searchWhere)->where($this->queryWhere())
-            ->count();*/
-        return $this->count;
+            ->count();
+        //return $this->count;
     }
-
-
-    private function limitPage($allList,$data,$page,$itemsPerPage)
-    {
-        $startIndex = (($page??1) - 1) * $itemsPerPage;
-        $currentPageData = array_slice($data, $startIndex, $itemsPerPage, true);
-        $lon_lat_masters = [];
-        foreach ($currentPageData as $key => $value){
-            $lon_lat_masters[$key] = $allList[$key];
-            $lon_lat_masters[$key]['user_distance'] = number_format($value,2);
-        }
-        return $lon_lat_masters?array_values($lon_lat_masters):[];
-    }
-    private function mastersDistance($masters,$customer_lon,$customer_lat)
-    {
-        $nearbyMasters = [];
-        foreach ($masters as $master) {
-            $distance = $this->haversineDistance($customer_lat, $customer_lon, $master['lat'], $master['lon']);
-            $nearbyMasters[$master['id']] = $distance;
-            /*if ($distance <= 10000) { // 距离小于或等于10公里
-                $nearbyMasters[] = $master;
-            }*/
-        }
-        asort($nearbyMasters);
-        return $nearbyMasters;
-    }
-    private function haversineDistance($lat1, $lon1, $lat2, $lon2) {
-        $lat1 = deg2rad($lat1);
-        $lon1 = deg2rad($lon1);
-        $lat2 = deg2rad($lat2);
-        $lon2 = deg2rad($lon2);
-
-        $dlon = $lon2 - $lon1;
-        $dlat = $lat2 - $lat1;
-        $a = sin($dlat / 2)**2 + cos($lat1) * cos($lat2) * sin($dlon / 2)**2;
-        $c = 2 * asin(sqrt($a));
-        $r = 6371; // 地球平均半径,单位为公里
-        $distance = $c * $r;
-
-        return $distance;
-    }
-
 }

+ 78 - 0
app/adminapi/lists/master_worker/MasterWorkerRuleLists.php

@@ -0,0 +1,78 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\adminapi\lists\master_worker;
+
+
+use app\adminapi\lists\BaseAdminDataLists;
+use app\common\model\master_worker\MasterWorkerRule;
+use app\common\lists\ListsSearchInterface;
+
+
+/**
+ * MasterWorkerRule列表
+ * Class MasterWorkerRuleLists
+ * @package app\adminapi\lists
+ */
+class MasterWorkerRuleLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/09/28 15:31
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['rule_name', 'description', 'sort'],
+
+        ];
+    }
+
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2024/09/28 15:31
+     */
+    public function lists(): array
+    {
+        return MasterWorkerRule::where($this->searchWhere)
+            ->field(['id', 'rule_name', 'description', 'sort'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2024/09/28 15:31
+     */
+    public function count(): int
+    {
+        return MasterWorkerRule::where($this->searchWhere)->count();
+    }
+
+}

+ 110 - 0
app/adminapi/logic/master_worker/MasterWorkerRuleLogic.php

@@ -0,0 +1,110 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\adminapi\logic\master_worker;
+
+
+use app\common\model\master_worker\MasterWorkerRule;
+use app\common\logic\BaseLogic;
+use think\facade\Db;
+
+
+/**
+ * MasterWorkerRule逻辑
+ * Class MasterWorkerRuleLogic
+ * @package app\adminapi\logic
+ */
+class MasterWorkerRuleLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/09/28 15:31
+     */
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            MasterWorkerRule::create([
+                'rule_name' => $params['rule_name'],
+                'description' => $params['description'],
+                'sort' => $params['sort'],
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 编辑
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/09/28 15:31
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            MasterWorkerRule::where('id', $params['id'])->update([
+                'rule_name' => $params['rule_name'],
+                'description' => $params['description'],
+                'sort' => $params['sort'],
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 删除
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/09/28 15:31
+     */
+    public static function delete(array $params): bool
+    {
+        return MasterWorkerRule::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2024/09/28 15:31
+     */
+    public static function detail($params): array
+    {
+        return MasterWorkerRule::findOrEmpty($params['id'])->toArray();
+    }
+}

+ 108 - 0
app/adminapi/service/DistributeLeafletsService.php

@@ -0,0 +1,108 @@
+<?php
+namespace app\adminapi\service;
+
+use app\common\model\master_worker\MasterWorker;
+use app\common\model\master_worker\MasterWorkerRule;
+use DateInterval;
+use DateTime;
+
+/**
+ * 分销leaflets服务
+ */
+class DistributeLeafletsService
+{
+
+    public static function locationIds($lon, $lat,$resType=0,$ids = [])
+    {
+        $where = [];
+        if(!empty($ids)) $where[] = ['id','IN',$ids];
+        // 查出所有的师傅 -> 计算距离 -> 按距离排序 -> 分页
+        $allList = MasterWorker::where($where)->select()->toArray();
+        if(!empty($lon) && !empty($lat)){
+            $mastersDistances = self::mastersDistance($allList,$lon,$lat);
+        }else{
+            $mastersDistances = array_column($allList, 'distance','id');
+        }
+        // id => distance
+        if(empty($resType))
+            return $mastersDistances;
+        else
+            return array_keys($mastersDistances);
+    }
+    public static function goodsCategoryIds($goods_category_id)
+    {
+        if($goods_category_id){
+            return MasterWorker::whereFindInSet('category_ids',$goods_category_id)->column('id');
+        }else{
+            return MasterWorker::column('id');
+        }
+    }
+    public static function protectionPeriodIds()
+    {
+        $ruleInfo = MasterWorkerRule::where('id',1)->findOrEmpty()->toArray();
+        //$ruleInfo['description']
+        $createTime = time() - (86400 * ($ruleInfo['description']??0));
+        return MasterWorker::where([
+            ['create_time','>=',$createTime],
+            ['is_disable','=',0],
+            ['work_status','=',0]
+        ])->column('id');
+    }
+    public static function availableAmountIds()
+    {
+        $protectionRuleInfo = MasterWorkerRule::where('id',1)->findOrEmpty()->toArray();
+        $ruleInfo = MasterWorkerRule::where('id',2)->findOrEmpty()->toArray();
+        //$protectionRuleInfo['description']
+        //$ruleInfo['description']
+        $createTime = time() - (86400 * ($protectionRuleInfo['description']??0));
+        return MasterWorker::where([
+            ['create_time','<',$createTime],
+            ['earnest_money_usable','>=',(float)$ruleInfo['description']??0],
+            ['is_disable','=',0],
+            ['work_status','=',0]
+        ])->column('id');
+    }
+    public static function getIntersection($lon, $lat,$goods_category_id)
+    {
+        //self::protectionPeriodIds();
+        //self::availableAmountIds();
+        $mergeIds = array_merge(self::protectionPeriodIds(),self::availableAmountIds());
+
+        //self::locationIds($lon, $lat,1);
+        //self::goodsCategoryIds($goods_category_id);
+        $intersectIds = array_intersect(self::locationIds($lon, $lat,1),self::goodsCategoryIds($goods_category_id));
+
+        $result=array_intersect($mergeIds,$intersectIds);
+        return array_values($result);
+    }
+    private static function mastersDistance($masters,$customer_lon,$customer_lat,$radius = 0)
+    {
+        $masters = array_column($masters, null, 'id');
+        $nearbyMasters = [];
+        foreach ($masters as $master) {
+            $distance = self::haversineDistance($customer_lat, $customer_lon, $master['lat'], $master['lon']);
+            if ($radius>0) { // 距离小于或等于10公里
+                ($distance <= $radius) && $nearbyMasters[$master['id']] = $distance;
+            }else{
+                $nearbyMasters[$master['id']] = $distance;
+            }
+        }
+        asort($nearbyMasters);
+        return $nearbyMasters;
+    }
+    private static function haversineDistance($lat1, $lon1, $lat2, $lon2) {
+        $lat1 = deg2rad($lat1);
+        $lon1 = deg2rad($lon1);
+        $lat2 = deg2rad($lat2);
+        $lon2 = deg2rad($lon2);
+
+        $dlon = $lon2 - $lon1;
+        $dlat = $lat2 - $lat1;
+        $a = sin($dlat / 2)**2 + cos($lat1) * cos($lat2) * sin($dlon / 2)**2;
+        $c = 2 * asin(sqrt($a));
+        $r = 6371; // 地球平均半径,单位为公里
+        $distance = $c * $r;
+
+        return $distance;
+    }
+}

+ 98 - 0
app/adminapi/validate/master_worker/MasterWorkerRuleValidate.php

@@ -0,0 +1,98 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\adminapi\validate\master_worker;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * MasterWorkerRule验证器
+ * Class MasterWorkerRuleValidate
+ * @package app\adminapi\validate
+ */
+class MasterWorkerRuleValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'rule_name' => 'require',
+
+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'rule_name' => '规则名称',
+
+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return MasterWorkerRuleValidate
+     * @author likeadmin
+     * @date 2024/09/28 15:31
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['rule_name']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return MasterWorkerRuleValidate
+     * @author likeadmin
+     * @date 2024/09/28 15:31
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','rule_name']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return MasterWorkerRuleValidate
+     * @author likeadmin
+     * @date 2024/09/28 15:31
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return MasterWorkerRuleValidate
+     * @author likeadmin
+     * @date 2024/09/28 15:31
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 34 - 0
app/common/model/master_worker/MasterWorkerRule.php

@@ -0,0 +1,34 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\common\model\master_worker;
+
+
+use app\common\model\BaseModel;
+
+
+
+/**
+ * MasterWorkerRule模型
+ * Class MasterWorkerRule
+ * @package app\common\model
+ */
+class MasterWorkerRule extends BaseModel
+{
+    
+    protected $name = 'master_worker_rule';
+    
+
+    
+}

+ 1 - 1
config/database.php

@@ -52,7 +52,7 @@ return [
             // 是否需要断线重连
             'break_reconnect' => false,
             // 监听SQL
-            'trigger_sql'     => false,
+            'trigger_sql'     => env('database.trigger_sql', false),
             // 开启字段缓存
             'fields_cache'    => false,
         ],