wupengfei 3 years ago
parent
commit
7f034c4c48
2 changed files with 25 additions and 2 deletions
  1. 7 2
      application/api/controller/Qc.php
  2. 18 0
      application/common.php

+ 7 - 2
application/api/controller/Qc.php

@@ -5,8 +5,13 @@ use app\api\controller\WeChart;
 class Qc{
 
     function index(){
-        $we = new WeChart();
-        var_dump($we->getAccessToken());
+        $arr =[
+            'num'=>10,
+            'num'=>50,
+            'num'=>100,
+        ];
+       $res = draw_lottery($arr,'num',3);
+       var_dump($res);
     }
 
 

+ 18 - 0
application/common.php

@@ -264,6 +264,24 @@ function get_delivery($send_no = 'JD0053309649641',$express_code='jd'){
 
 
 
+function draw_lottery ($data = [],$field='',$num = 1)
+{
+    $draw_data = [];
+    foreach ($data as $k=>$v)
+    {
+        if($v[$field] > 0)
+        {
+            for($i=0;$i<=$v[$field];$i++)
+            {
+                $draw_data[] = $k.'_key_'.$i;
+            }
+        }
+
+    }
+    $rand_key = array_rand($draw_data,$num);
+    var_dump($rand_key);die();
+
+}