瀏覽代碼

统计/进行中工单/下单和入驻提示/师傅工作台提示

liugc 1 年之前
父節點
當前提交
e5b573a88c

+ 12 - 0
app/adminapi/controller/notice/NoticeController.php

@@ -67,4 +67,16 @@ class NoticeController extends BaseAdminController
         }
         return $this->fail(NoticeLogic::getError());
     }
+
+    /**
+     * @notes 获取通知弹框信息
+     */
+    public function getInformation()
+    {
+        $result = NoticeLogic::getInformation($this->adminId);
+        if ($result) {
+            return $this->success('获取成功', $result);
+        }
+        return $this->fail(NoticeLogic::getError());
+    }
 }

+ 9 - 1
app/adminapi/controller/property/PropertyOrderController.php

@@ -17,6 +17,7 @@ namespace app\adminapi\controller\property;
 
 
 use app\adminapi\controller\BaseAdminController;
+use app\adminapi\lists\property\PropertyOrderAnalysis;
 use app\adminapi\lists\property\PropertyOrderLists;
 use app\adminapi\logic\property\PropertyOrderLogic;
 use app\adminapi\validate\property\PropertyOrderValidate;
@@ -138,6 +139,13 @@ class PropertyOrderController extends BaseAdminController
         }
         return $this->fail(PropertyOrderLogic::getError());
     }
-
+    /**
+     * @notes 物业订单数据分析
+     * @return \think\response\Json
+     */
+    public function propertyOrderAnalysis()
+    {
+        return $this->dataLists(new PropertyOrderAnalysis());
+    }
 
 }

+ 1 - 1
app/adminapi/lists/property/PropertyHeadLists.php

@@ -56,7 +56,7 @@ class PropertyHeadLists extends BaseAdminDataLists implements ListsSearchInterfa
     public function lists(): array
     {
         return PropertyHead::where($this->searchWhere)
-            ->field(['id', 'property_name', 'village_name', 'address', 'head_name', 'head_mobile', 'ratio', 'head_bank_card', 'remark', 'user_id', 'all_profit_amount', 'surplus_profit_amount', 'extract_profit_amount'])
+            ->field(['id', 'property_name', 'village_name', 'address', 'head_name', 'head_mobile', 'ratio', 'head_bank_card', 'remark', 'user_id', 'all_profit_amount', 'surplus_profit_amount', 'extract_profit_amount','lon', 'lat'])
             ->limit($this->limitOffset, $this->limitLength)
             ->order(['id' => 'desc'])
             ->select()

+ 96 - 0
app/adminapi/lists/property/PropertyOrderAnalysis.php

@@ -0,0 +1,96 @@
+<?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\property;
+
+
+use app\adminapi\lists\BaseAdminDataLists;
+use app\common\model\property\PropertyHead;
+use app\common\model\property\PropertyOrder;
+use app\common\lists\ListsSearchInterface;
+use app\common\model\property\PropertyUser;
+use app\common\model\works\ServiceWork;
+use think\facade\Db;
+
+
+/**
+ * PropertyOrderAnalysis列表
+ * Class PropertyOrderAnalysis
+ * @package app\adminapi\lists
+ */
+class PropertyOrderAnalysis extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/09/19 14:48
+     */
+    public function setSearch(): array
+    {
+        return [
+        ];
+    }
+    public function queryWhere()
+    {
+        $where = [];
+        return $where;
+    }
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2024/09/19 14:48
+     */
+    public function lists(): array
+    {
+        $workIds = PropertyOrder::where('order_status',3)->column('work_id');
+        if(empty($workIds)){
+            return [];
+        }
+        $startDateTime = strtotime(date('Y-m-01'));
+        if(isset($this->params['start_month']) && $this->params['start_month']){
+            $startDateTime = strtotime($this->params['start_month']);
+        }
+        $endDateTime = strtotime('+1 month', strtotime($startDateTime))-1;
+        // with(['propertyHead'])->
+        $serviceWork = ServiceWork::with(['propertyHead'])->where([['id','in',$workIds],['work_pay_status','=',2],['approval','=',1]])
+            //->where('finished_time','BETWEEN',[$startDateTime,$endDateTime])
+            ->where('finished_time','>',0)
+            ->where('user_id','>',0)
+            ->field(Db::raw('user_id,DATE_FORMAT(FROM_UNIXTIME(finished_time), "%Y-%m") AS month_format,COUNT(id) as month_num, SUM(work_amount) as month_amount'))
+            ->group('user_id,month_format')
+            ->select()->toArray();
+        return $serviceWork;
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2024/09/19 14:48
+     */
+    public function count(): int
+    {
+        return ServiceWork::where($this->searchWhere)->where($this->queryWhere())->count();
+    }
+
+}

+ 4 - 0
app/adminapi/lists/works/ServiceWorkLists.php

@@ -71,6 +71,10 @@ class ServiceWorkLists extends BaseAdminDataLists implements ListsSearchInterfac
             $time = [strtotime($this->params['update_time'][0]), strtotime($this->params['update_time'][1])];
             $where[] = ['update_time', 'between', $time];
         }
+        if(isset($this->params['workid']) && !empty($this->params['workid'])){
+            $where[] = ['master_worker_id', '=', $this->params['workid']];
+            $where[] = ['work_status', 'NOT IN', [7,8,9]];
+        }
         if (isset($this->params['update_time']) && !empty($this->params['goods_category_id'])) {
             $goodsCategoryId = end($this->params['goods_category_id']);
             $goodsCategoryData = GoodsCategory::where(['status'=>1])->order(['pid' => 'asc','weigh' => 'desc', 'id' => 'desc'])

+ 37 - 0
app/adminapi/logic/notice/NoticeLogic.php

@@ -16,7 +16,9 @@ namespace app\adminapi\logic\notice;
 
 use app\common\enum\notice\NoticeEnum;
 use app\common\logic\BaseLogic;
+use app\common\model\master_worker_register\MasterWorkerRegister;
 use app\common\model\notice\NoticeSetting;
+use app\common\model\works\ServiceWork;
 
 /**
  * 通知逻辑层
@@ -222,4 +224,39 @@ class NoticeLogic extends BaseLogic
             throw new \Exception('微信模板消息必填参数:template_id、template_sn、name、tpl、status');
         }
     }
+
+    public static function getInformation($adminId)
+    {
+        try {
+            $noticeInfo = [
+                'confirm_code' => 0,
+                'massage' => '',
+                'to_router' => '',
+            ];
+            if(!in_array($adminId,[1,2])){
+                return $noticeInfo;
+            }
+            // 用户下单待派单
+            $serviceWorkCount = ServiceWork::where('work_status', 0)->where('work_pay_status','>', 0)->count('id');
+            if($serviceWorkCount){
+                $noticeInfo['confirm_code'] = 101;
+                $noticeInfo['massage'] .= '您有'.$serviceWorkCount.'个工单待派单';
+                $noticeInfo['to_router'] = '/works/service_work';
+                return $noticeInfo;
+            }
+            // 师傅入驻待审核
+            $workerRegisterCount = MasterWorkerRegister::where('status', 0)->count('id');
+            if($workerRegisterCount){
+                $noticeInfo['confirm_code'] = 101;
+                $noticeInfo['massage'] .= '您有'.$workerRegisterCount.'个师傅入驻待审核';
+                $noticeInfo['to_router'] = '/worker/master_worker_register';
+                return $noticeInfo;
+            }
+            return $noticeInfo;
+        } catch (\Exception $e) {
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
 }

+ 5 - 0
app/common/model/works/ServiceWork.php

@@ -20,6 +20,7 @@ use app\common\model\BaseModel;
 use app\common\model\goods_category\GoodsCategory;
 use app\common\model\master_worker\MasterWorker;
 use app\common\model\orders\RechargeOrder;
+use app\common\model\property\PropertyHead;
 
 
 /**
@@ -173,5 +174,9 @@ class ServiceWork extends BaseModel
     {
         return !empty($value)?json_decode($value,true):'';
     }
+    public function propertyHead()
+    {
+        return $this->hasOne(PropertyHead::class,'user_id','user_id');
+    }
 
 }

+ 20 - 0
app/workerapi/controller/MasterWorkerMessageController.php

@@ -7,6 +7,9 @@ use app\workerapi\logic\MasterWorkerMessageLogic;
 
 class MasterWorkerMessageController extends BaseApiController
 {
+
+    public array $notNeedLogin = ['orderPrompt'];
+
     /**
      * 统计师傅未读消息数量
      * @return \think\response\Json
@@ -41,4 +44,21 @@ class MasterWorkerMessageController extends BaseApiController
         MasterWorkerMessageLogic::showMsg(request()->all(),$this->userId);
         return $this->success('操作成功', [], 1, 0);
     }
+
+    /**
+     * 师傅接单提示
+     * @return \think\response\Json
+     */
+    public function orderPrompt()
+    {
+        $result = MasterWorkerMessageLogic::orderPrompt($this->userId);
+        if ($result) {
+            $result = ['confirm_code'=>101,'msg'=>'您有新的工单未领取,请点击领取'];
+        }else{
+            $result = ['confirm_code'=>0,'msg'=>'无'];
+        }
+        return $this->success('操作成功', $result, 1, 0);
+    }
+
+
 }

+ 7 - 0
app/workerapi/logic/MasterWorkerMessageLogic.php

@@ -7,6 +7,7 @@ use app\common\model\dict\DictData;
 use app\common\model\dict\DictType;
 use app\common\model\master_worker\MasterWorkerAccountLog;
 use app\common\model\master_worker_message\MasterWorkerMessage;
+use app\common\model\works\ServiceWork;
 use app\common\model\works\ServiceWorkLog;
 
 /**
@@ -120,4 +121,10 @@ class MasterWorkerMessageLogic extends  BaseLogic
         }
         return true;
     }
+
+    public static function orderPrompt($userId)
+    {
+        $count = ServiceWork::where(['master_worker_id'=>$userId,'work_status'=> 1] )->count('id');
+        return $count?:false;
+    }
 }