浏览代码

工程师工单

whitefang 1 年之前
父节点
当前提交
d02dfca35f
共有 1 个文件被更改,包括 18 次插入20 次删除
  1. 18 20
      app/api/lists/recharge/ServiceOrderLists.php

+ 18 - 20
app/api/lists/recharge/ServiceOrderLists.php

@@ -28,8 +28,17 @@ use app\common\model\works\ServiceWork;
 class ServiceOrderLists extends BaseApiDataLists
 class ServiceOrderLists extends BaseApiDataLists
 {
 {
     protected $count = 0;
     protected $count = 0;
-    public function queryWhere()
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public function lists(): array
     {
     {
+
         $where = [];
         $where = [];
         $service_status = $this->params['service_status'];
         $service_status = $this->params['service_status'];
         $work_ids = ServiceWork::where(['user_id' => $this->userId])->where(function ($query) use($service_status) {
         $work_ids = ServiceWork::where(['user_id' => $this->userId])->where(function ($query) use($service_status) {
@@ -37,28 +46,18 @@ class ServiceOrderLists extends BaseApiDataLists
                 $query->where(['service_status' => $service_status]);
                 $query->where(['service_status' => $service_status]);
             }
             }
         })->column('id');
         })->column('id');
-        $where['work_id'] = ['in', !empty($work_ids)?implode(',',$work_ids):9999999];
         if($service_status != 'all'){
         if($service_status != 'all'){
             $where['pay_status'] = 1;
             $where['pay_status'] = 1;
         }
         }
-        return $where;
-    }
+        $work_ids = !empty($work_ids)?implode(',',$work_ids):'999999';
 
 
-    /**
-     * @notes 获取列表
-     * @return array
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     */
-    public function lists(): array
-    {
         $lists = RechargeOrder::with(['order_goods'=>function ($query) {
         $lists = RechargeOrder::with(['order_goods'=>function ($query) {
             $query->visible(['goods_name','goods_image','goods_number','good_unit']);
             $query->visible(['goods_name','goods_image','goods_number','good_unit']);
         },'service_work'=>function ($query) {
         },'service_work'=>function ($query) {
             $query->visible(['service_status','work_status','user_confirm_status'])->append(['service_status_text','work_status_text','user_confirm_status_text']);
             $query->visible(['service_status','work_status','user_confirm_status'])->append(['service_status_text','work_status_text','user_confirm_status_text']);
         }])
         }])
-            ->where($this->queryWhere())
+            ->where($where)
+            ->whereIn('work_id',$work_ids)
             ->visible(['id','sn','order_total','order_amount','pay_status','create_time'])
             ->visible(['id','sn','order_total','order_amount','pay_status','create_time'])
             ->where([
             ->where([
                 'order_type' => 0,
                 'order_type' => 0,
@@ -69,16 +68,15 @@ class ServiceOrderLists extends BaseApiDataLists
             ->order('id', 'desc')
             ->order('id', 'desc')
             ->select()->each(function ($item) {
             ->select()->each(function ($item) {
                 //用户按钮状态显示
                 //用户按钮状态显示
-
             })
             })
             ->toArray();
             ->toArray();
 
 
-
-
         $this->count = RechargeOrder::where([
         $this->count = RechargeOrder::where([
-            'order_type' => 0,
-            'user_id' => $this->userId,
-        ])
+                'order_type' => 0,
+                'user_id' => $this->userId,
+            ])
+            ->where($where)
+            ->whereIn('work_id',$work_ids)
             ->group('work_id')
             ->group('work_id')
             ->count();
             ->count();