Просмотр исходного кода

Merge branch 'master' of e.coding.net:zdap/weixiu/weixiu_api into data_rules-m

liugc 1 год назад
Родитель
Сommit
6a3aea4cb7

+ 5 - 0
app/adminapi/lists/master_commission/MasterWorkerCommissionNoticeLists.php

@@ -17,7 +17,9 @@ namespace app\adminapi\lists\master_commission;
 
 use app\adminapi\lists\BaseAdminDataLists;
 use app\common\lists\ListsSearchInterface;
+use app\common\model\master_commission\MasterWorkerCommissionConfig;
 use app\common\model\master_worker\MasterWorker;
+use app\common\model\works\ServiceWorkAllocateWorkerLog;
 use think\facade\Db;
 
 
@@ -67,6 +69,8 @@ class MasterWorkerCommissionNoticeLists extends BaseAdminDataLists implements Li
             $mw_ids = MasterWorker::where([[ 'mw.worker_number','like','%'.$this->params['real_name'].'%']])->column('id');
             $where[] = [ 'n.master_worker_id','in',$mw_ids?:[0]];
         }
+        $mwids = MasterWorkerCommissionConfig::where('voucher_status', 2)->column('master_worker_id');
+        $where[] = [ 'n.master_worker_id','in',$mwids?:[0]];
         return $where;
     }
     /**
@@ -116,6 +120,7 @@ class MasterWorkerCommissionNoticeLists extends BaseAdminDataLists implements Li
             ->select()->toArray();
         foreach ($lists as &$item) {
             $item['labels'] = $item['labels']?array_map(function ($item) { return intval($item); },explode(',',$item['labels'])):'';
+            $item['allocate_num'] = ServiceWorkAllocateWorkerLog::where(['master_worker_id'=>$item['master_worker_id']])->count();
         }
         return $lists;
     }

+ 2 - 0
app/adminapi/lists/master_worker/MasterWorkerServiceOrderLists.php

@@ -5,6 +5,7 @@ use app\adminapi\lists\BaseAdminDataLists;
 use app\common\lists\ListsSearchInterface;
 use app\common\model\goods_category\GoodsCategory;
 use app\common\model\master_worker\MasterWorker;
+use app\common\model\works\ServiceWorkAllocateWorkerLog;
 use think\facade\Db;
 use think\facade\Log;
 
@@ -138,6 +139,7 @@ class MasterWorkerServiceOrderLists extends BaseAdminDataLists implements ListsS
         foreach ($lists as &$item) {
             $item['labels'] = $item['labels']?array_map(function ($item) { return intval($item); },explode(',',$item['labels'])):'';
             $item['category_name'] = $item['category_ids']?implode('、',array_column(get_parent_info($categoryData,explode(',',$item['category_ids'])),'name')):'';
+            $item['allocate_num'] = ServiceWorkAllocateWorkerLog::where(['master_worker_id'=>$item['id']])->count();
         }
         return $lists;
     }

+ 5 - 3
app/adminapi/lists/sale/PropertyHeadAnalysisLists.php

@@ -95,7 +95,7 @@ class PropertyHeadAnalysisLists extends BaseAdminDataLists implements ListsSearc
             ->leftJoin('property_head c', 'a.property_head_id = c.id')
             ->leftJoin('sale d', 'a.sale_id = d.id')
             ->field([
-                'a.property_head_id','c.property_name','c.village_name','c.address','c.head_name','c.head_mobile','d.sale_name',
+                'a.property_head_id','c.property_name','c.village_name','c.address','c.head_name','c.head_mobile','c.ratio','c.remark','d.sale_name',
                 Db::raw("COUNT(a.work_id) AS work_count,SUM(b.work_amount) AS total_sales_amount")
             ])
             ->where('a.sale_type', 'in', [1, 2])
@@ -134,9 +134,11 @@ class PropertyHeadAnalysisLists extends BaseAdminDataLists implements ListsSearc
     public function setExcelComplexFields(): array
     {
         $zh_cn_fields = [
-            '所属代理','所属小区', '所属销售','单数','总金额'
+            '所属代理','所属小区', '所属销售','单数','总金额','分成比例','分成金额'
         ];
-        $data_fields = ['property_name','village_name','sale_name','work_count','total_sales_amount'];
+        $data_fields = ['property_name','village_name','sale_name','work_count','total_sales_amount','ratio',function($row){
+            return bcmul($row['total_sales_amount'], bcdiv($row['ratio'], 100, 4),2);
+        }];
         return [
             'zh_cn_fields' => $zh_cn_fields,
             'data_fields' => $data_fields

+ 7 - 32
app/adminapi/lists/works/ServiceWorkLists.php

@@ -18,7 +18,6 @@ namespace app\adminapi\lists\works;
 use app\adminapi\lists\BaseAdminDataLists;
 use app\common\model\goods_category\GoodsCategory;
 use app\common\model\master_worker\MasterWorker;
-use app\common\model\property\PropertyOrder;
 use app\common\model\works\ServiceWork;
 use app\common\lists\ListsSearchInterface;
 use think\db\Query;
@@ -33,34 +32,7 @@ use think\facade\Log;
 class ServiceWorkLists extends BaseAdminDataLists implements ListsSearchInterface
 {
 
-    /**
-     * 获取数据权限
-     * $this->adminInfo['data_rules']
-     * province city admin_id sale_group_id sale_id  property_head_id
-     */
-    public function queryDataWhere(){
-        $where = [];
-        $data_rules = $this->adminInfo['data_rules'];
-        if (isset($data_rules['province']) && !empty($data_rules['province'])) {
-            $where[] = ['province','in' ,$data_rules['province']];
-        }
-        if (isset($data_rules['city']) && !empty($data_rules['city'])) {
-            $where[] = ['city','in' ,$data_rules['city']];
-        }
-        if (isset($data_rules['sale_group_id']) && !empty($data_rules['sale_group_id'])) {
-            $work_ids = PropertyOrder::where('sale_group_id','in',$data_rules['sale_group_id'])->column('work_id')??[];
-            $where[] = ['id','in' ,$work_ids];
-        }
-        if (isset($data_rules['sale_id']) && !empty($data_rules['sale_id'])) {
-            $work_ids = PropertyOrder::where('sale_id','in',$data_rules['sale_id'])->column('work_id')??[];
-            $where[] = ['id','in' ,$work_ids];
-        }
-        if (isset($data_rules['property_head_id']) && !empty($data_rules['property_head_id'])) {
-            $work_ids = PropertyOrder::where('property_head_id','in',$data_rules['property_head_id'])->column('work_id')??[];
-            $where[] = ['id','in' ,$work_ids];
-        }
-        return $where;
-    }
+
     /**
      * @notes 设置搜索条件
      * @return \string[][]
@@ -136,6 +108,10 @@ class ServiceWorkLists extends BaseAdminDataLists implements ListsSearchInterfac
         }else{
             $where[] = ['work_pay_status','=',$this->params['work_pay_status']];
         }
+
+        if(isset($this->params['property_activity_id']) && !empty($this->params['property_activity_id'])){
+            $where[] = ['property_activity_id','>',0];
+        }
         return $where;
     }
     /**
@@ -168,8 +144,7 @@ class ServiceWorkLists extends BaseAdminDataLists implements ListsSearchInterfac
         ])
             ->where($this->searchWhere)
             ->where($this->queryWhere())
-            ->where($this->queryDataWhere())
-            ->field(['id', 'work_sn', 'real_name', 'mobile', 'address', 'title', 'category_type', 'goods_category_ids', 'goods_category_id', 'base_service_fee', 'service_fee', 'work_status','work_pay_status', 'service_status', 'dispatch_time', 'receive_time', 'appointment_time', 'finished_images', 'finished_time', 'master_worker_id', 'work_amount', 'work_type', 'create_time', 'update_time','lon', 'lat','appoint_approval','refund_approval','finally_door_time'])
+            ->field(['id', 'work_sn', 'real_name', 'mobile', 'address', 'title', 'category_type', 'goods_category_ids', 'goods_category_id', 'base_service_fee', 'service_fee', 'work_status','work_pay_status', 'service_status', 'dispatch_time', 'receive_time', 'appointment_time', 'finished_images', 'finished_time', 'master_worker_id', 'work_amount', 'work_type', 'create_time', 'update_time','lon', 'lat','appoint_approval','refund_approval','finally_door_time','property_activity_id'])
             ->limit($this->limitOffset, $this->limitLength)
             ->order(['id' => 'desc'])
             ->select()
@@ -185,7 +160,7 @@ class ServiceWorkLists extends BaseAdminDataLists implements ListsSearchInterfac
      */
     public function count(): int
     {
-        return ServiceWork::where($this->searchWhere)->where($this->queryWhere())->where($this->queryDataWhere())->count();
+        return ServiceWork::where($this->searchWhere)->where($this->queryWhere())->count();
     }
 
 }

+ 1 - 1
app/api/logic/UserLogic.php

@@ -63,7 +63,7 @@ class UserLogic extends BaseLogic
 
         //查询用户优惠券、权益卡、保修卡、返修工单数量
         $user['coupon_count'] = UserCoupon::where(['user_id' => $userInfo['user_id'] , 'voucher_status'=>0])->where('expire_time','>',time())->where('voucher_count','>',0)->count();
-        $user['equity_count'] = UserEquity::where(['user_id' => $userInfo['user_id']])->where('number','>',0)->count();
+        $user['equity_count'] = UserEquity::where(['user_id' => $userInfo['user_id']])->where('number','>',0)->where('end_time','>=',time())->count();
         $user['effective_count'] = OrderEffectiveLog::where(['user_id' => $userInfo['user_id']])->where('end_effective_time','>',time())->where('effective_num','>',0)->count();
         $user['return_work_count'] = ReturnWork::where(['user_id' => $userInfo['user_id']])->where('return_work_status','<>',2)->count();
         return $user->toArray();