Browse Source

从bill任务写入到代理月辅助

lizhen_gitee 1 week ago
parent
commit
5f73565651
1 changed files with 23 additions and 11 deletions
  1. 23 11
      application/api/controller/Demo.php

+ 23 - 11
application/api/controller/Demo.php

@@ -72,11 +72,9 @@ class Demo extends Api
         $shangwu_amount = bcdiv(bcmul($amount,$shangwu_rate,2),100,2);
 
         $shop_info = (new \app\common\business\PaymentBusiness)->getShopInfo($table_name,$shop_id);
-        if($shop_info){
-            //发钱
-            if($shop_info['invite_id'] && $shangwu_amount > 0){
+        if($shop_info && $shop_info['invite_id'] && $shangwu_amount > 0){
+            //发钱给 $shop_info['invite_id']
 
-            }
         }
 
         //锁客 发给消费者的上级 收益
@@ -84,20 +82,34 @@ class Demo extends Api
         $suoke_amount = bcdiv(bcmul($amount,$suoke_rate,2),100,2);
 
         $suoke_invite_id = Db::name('user')->where('id',$user_id)->value('invite_id');
-        //发钱给 $suoke_invite_id
         if($suoke_invite_id && $suoke_amount > 0){
-
+            //发钱给 $suoke_invite_id
         }
 
         //网体 业务员逻辑 按月发 收益
 
 
-        //省代,市代,区代 三个代理 都按月发 收益
+        //省代,市代,区代 三个代理 都按月发 收益, 放到代理月辅助表
         //修改agent_month
-
-
-
-
+        $map_agent = [
+            'month_date'  => date('Ym'),
+            'province_id' => $shop_info['province_id'],
+            'city_id'     => $shop_info['city_id'],
+            'district_id' => $shop_info['district_id'],
+        ];
+        $agent_month = Db::name('agent_month')->where($map_agent)->order('id asc')->find();
+        if(empty($agent_month)){
+            $map_agent['back_amount'] = $amount;
+            $map_agent['updatetime']  = time();
+            $map_agent['status']      = 0;
+
+            Db::name('agent_month')->insertGetId($map_agent);
+        }else{
+            Db::name('agent_month')->where('id',$agent_month['id'])->update([
+                'updatetime'  => time(),
+                'back_amount' => bcadd($agent_month['back_amount'],$amount,2)
+            ]);
+        }
 
     }