Browse Source

业务员奖

lizhen_gitee 1 week ago
parent
commit
699e39ce85
1 changed files with 62 additions and 1 deletions
  1. 62 1
      application/api/controller/Demo.php

+ 62 - 1
application/api/controller/Demo.php

@@ -90,7 +90,6 @@ class Demo extends Api
 
 
         //省代,市代,区代 三个代理 都按月发 收益, 放到代理月辅助表
-        //修改agent_month
         $map_agent = [
             'month_date'  => date('Ym'),
             'province_id' => $shop_info['province_id'],
@@ -115,6 +114,68 @@ class Demo extends Api
 
     //业务员奖
     public function yewuyuan(){
+        $user_id = 1;
+
+        //我直推商家的总数量。以后需要冗余到user表
+        $count1 = Db::name('hotel')->where('invite_id',$user_id)->count();
+        $count2 = Db::name('hotel_canteen')->where('invite_id',$user_id)->count();
+        $count3 = Db::name('university_event')->where('invite_id',$user_id)->count();
+        $count4 = Db::name('offline_shop')->where('invite_id',$user_id)->count();
+
+        $invite_count = $count1 + $count2 + $count3 + $count4;
+
+        //我上个月直推商家的总数量
+        $count1_mon = Db::name('hotel')->where('invite_id',$user_id)->whereTime('create_time','last month')->count();
+        $count2_mon = Db::name('hotel_canteen')->where('invite_id',$user_id)->whereTime('create_time','last month')->count();
+        $count3_mon = Db::name('university_event')->where('invite_id',$user_id)->whereTime('create_time','last month')->count();
+        $count4_mon = Db::name('offline_shop')->where('invite_id',$user_id)->whereTime('create_time','last month')->count();
+
+        $invite_count_mon = $count1_mon + $count2_mon + $count3_mon + $count4_mon;
+
+        //我的直推业绩
+        $invite_amount = Db::name('bill')->field('sum(total_amount * back_rate / 100) as back_amount')
+            ->where('shop_invite_id',$user_id)->whereTime('back_time','last month')->where('back_status',2)
+            ->find();
+
+        //我团队业绩
+        $invite_uids = Db::name('user')->where('invite_id',$user_id)->column('id');
+        $invite_amount_tuandui = Db::name('bill')->where('shop_invite_id','IN',$invite_uids)->field('sum(total_amount * back_rate / 100) as back_amount')->find();
+
+
+        //补贴/提成
+        $butie = 0;
+        $ticheng = 0;
+
+        //高级营销经理
+        if($invite_amount_tuandui >= 800000 && $invite_amount >= 70000 && $invite_count >= 10){
+            $butie = 12000;  //补贴
+            $ticheng_rate = 5;
+
+            $ticheng = bcdiv(bcmul($invite_amount,$ticheng_rate,2),100,2); //个人业绩提成
+
+            //公司分红(a%评分,b%业绩加权)
+        }
+
+        //初级营销经理
+        if($invite_amount_tuandui >= 200000 && $invite_amount >= 70000 && $invite_count >= 10){
+            $butie = 7000;
+            $ticheng_rate = 5;
+        }
+
+        //高级营销员
+        if($invite_amount >= 60000 && $invite_count_mon >= 5){
+            $butie = 5000;
+            $ticheng_rate = 5;
+        }
+
+        //初级营销员
+        if($invite_amount >= 30000 && $invite_count_mon >= 3){
+            $butie = 3000;
+            $ticheng_rate = 3;
+        }
+
+
+
 
     }