zxhxx 3 лет назад
Родитель
Сommit
7bccf9eef8
2 измененных файлов с 37 добавлено и 11 удалено
  1. 17 2
      app/admin/controller/Index.php
  2. 20 9
      app/models/store/StoreGp.php

+ 17 - 2
app/admin/controller/Index.php

@@ -4,6 +4,7 @@ namespace app\admin\controller;
 
 use app\models\store\StoreGp;
 use app\models\store\StoreOrder;
+use app\models\user\UserBill;
 use FormBuilder\Json;
 use think\facade\Config;
 use app\admin\model\order\StoreOrder as StoreOrderModel;//订单
@@ -602,8 +603,22 @@ class Index extends AuthController
     }
     public function test()
     {
-        $order = StoreOrder::find(2);
-        StoreGp::createGp($order);
+        /*
+        $order = StoreOrder::find(423);
+        StoreGp::createGp(['data'=>$order]);*/
+        $list = StoreGp::where('cts',3)->where('send',0)->select()->toArray();
+        foreach ($list as $v)
+        {
+            $p_user = \app\models\user\User::find($v['uid']);
+            $sp_brokeragePrice1 = 3000;
+            $gp_balance = bcadd($p_user['gp_now_money'], $sp_brokeragePrice1, 2);
+            $mark = "满3个加报单余额3000元,订单号:" . 0;
+            $res = UserBill::income('满3个报单余额', $p_user['uid'], 'now_money', 'brokerage', $sp_brokeragePrice1,0, $gp_balance, $mark, 1);
+            User::where('uid', $p_user['uid'])->inc('gp_now_money', $sp_brokeragePrice1)->update();
+            StoreGp::where('no', $v['no'])->update(['send'=>1]);
+        }
+        echo 'ok';
+
     }
 }
 

+ 20 - 9
app/models/store/StoreGp.php

@@ -21,7 +21,8 @@ class StoreGp extends BaseModel
         try {
             $no = intval(self::value('max(no)') ?: 0) + 1;
             $rs = self::getpath($no);
-            list($p_no, $no_path,$gp_id) = [$rs['p_no'],$rs['no_path'],$rs['gp_id']];
+            list($p_no, $no_path,$gp_id,$send,$gpinfo) = [$rs['p_no'],$rs['no_path'],$rs['gp_id'],$rs['send'],$rs['info']];
+            @file_put_contents("job.txt","\r\n".json_encode($rs),8);
             $order_id = $order['id'];
             $add_time = time();
             $price = $order['total_price'];
@@ -36,7 +37,16 @@ class StoreGp extends BaseModel
             $spuser = User::where('uid',$user['spread_uid'])->find();
             User::where('uid',$order['uid'])->update(['cycle_time'=>strtotime("+31 day")]);
             User::where('uid',$spuser['uid'])->update(['cycle_time'=>strtotime("+31 day")]);
-
+            if($send==1)
+            {
+                $p_user = User::find($gpinfo['uid']);
+                $sp_brokeragePrice1 = 3000;
+                $gp_balance = bcadd($p_user['gp_now_money'], $sp_brokeragePrice1, 2);
+                $mark = "公排号:" . $no . "满3个加报单余额3000元,订单号:" . $order['order_id'];
+                $res = UserBill::income('满3个报单余额', $p_user['uid'], 'now_money', 'brokerage', $sp_brokeragePrice1, $order['id'], $gp_balance, $mark, 1);
+                User::where('uid', $p_user['uid'])->inc('gp_now_money', $sp_brokeragePrice1)->update();
+                self::where('no', $p_no)->update(['send'=>1]);
+            }
             $p_no_cts =  self::where('no', $gp_id)->value('team_cts');
             if ($p_no_cts>0 && $p_no_cts % 3 == 0) {
                 $info = self::where('no', $gp_id)->find();
@@ -48,11 +58,7 @@ class StoreGp extends BaseModel
                             $balance = bcadd($sp_userInfo['brokerage_price'], $sp_brokeragePrice, 2);
                             $mark = "公排号:" . $no . "满3个拥金3000元,订单号:" . $order['order_id'];
                             $res = UserBill::income('满3个拥金', $sp_userInfo['uid'], 'now_money', 'brokerage', $sp_brokeragePrice, $order['id'], $balance, $mark, 1);
-                            $sp_brokeragePrice1 = 3000;
-                            $gp_balance = bcadd($sp_userInfo['gp_now_money'], $sp_brokeragePrice1, 2);
-                            $mark = "公排号:" . $no . "满3个加报单余额3000元,订单号:" . $order['order_id'];
-                            $res = UserBill::income('满3个报单余额', $sp_userInfo['uid'], 'now_money', 'brokerage', $sp_brokeragePrice1, $order['id'], $gp_balance, $mark, 1);
-                            User::where('uid', $sp_userInfo['uid'])->inc('brokerage_price', $sp_brokeragePrice)->inc('gp_now_money', $sp_brokeragePrice1)->update();
+                            User::where('uid', $sp_userInfo['uid'])->inc('brokerage_price', $sp_brokeragePrice)->update();
                             break;
                         case 6:
                         case 9:
@@ -119,7 +125,7 @@ class StoreGp extends BaseModel
      */
     private static function getpath($no)
     {
-        $no_path = [];$p_no=0;
+        $no_path = [];$p_no=0;$send = 0;$info = null;
         if($no==1) {
             $no_path[] =1;
             $gp_id = 1;
@@ -131,9 +137,14 @@ class StoreGp extends BaseModel
             $p_no = $min['no'];
             $no_path = explode(",",$min['no_path']);
             $no_path[] = $no;
+            if($min['cts']==2)
+            {
+                $send = 1;
+            }
+            $info = $min;
         }
         $no_path = join(",",$no_path);
-        return compact('p_no','no_path','gp_id');
+        return compact('p_no','no_path','gp_id','send','info');
 
     }
 }