sunhao 5 years ago
parent
commit
337631d927

+ 3 - 1
app/Http/Controllers/Admin/TemplateController.php

@@ -196,7 +196,9 @@ class TemplateController extends Controller
196 196
         $id = $request->input('id');
197 197
         #销售筛选
198 198
         //$saler_ids = DB::table('admin_role')->where('role_name', '销售')->lists('user_id');
199
-        $adminList = Admin::select('id', 'realname', 'username')->where('id','>', 1)->get();
199
+        $adminList = Admin::select('id', 'realname', 'username')->where('id','>', 1)->where(function ($query) {
200
+            $query->whereNotNull('qrcode')->where('qrcode', '<>', '');
201
+        })->get();
200 202
         $adminList = json_decode(json_encode($adminList), true);
201 203
         $assign_admin = TemplatesSalers::where('t_id', $id)->where('is_del', 0)->lists('weight', 'admin_id');
202 204
 

+ 4 - 2
app/Http/Controllers/Api/TemplateController.php

@@ -28,10 +28,12 @@ class TemplateController extends Controller {
28 28
         $result = TemplatesSalers::where('t_id', $t_id)->where('is_del', 0)->where('weight','>',0)->orderBy('weight', 'asc')->lists('weight', 'admin_id');
29 29
         $saler_id = null;
30 30
         $rand = 0;
31
+        //获取最大随机值
32
+        $max = array_sum($result) * 10;
31 33
         //随机一个值 
32
-        $rand_re = mt_rand(1, 100);
34
+        $rand_re = mt_rand(1, $max);
33 35
         foreach($result as $k=>$weight){
34
-            $rand += $weight;
36
+            $rand += $weight * 10;
35 37
             if($rand_re <= $rand){
36 38
                 $saler_id = $k;
37 39
                 break;