wangsaitao 10 місяців тому
батько
коміт
99961d72ba

+ 15 - 14
application/admin/view/index/indexsub.html

@@ -180,21 +180,22 @@
         </div>
 
         <ul class="nav navbar-top-links navbar-right" style="height: 70px">
-            {empty name="userInfo['head_image']"}
-            <img src="/img/defaulthead.png" class="userhead" style="" alt="">
-            {else /}
-            <img src="{$userInfo['head_image']}" class="userhead"  alt="">
-            {/empty}
+
             <li class="dropdown" style="height: 100%">
-                <!-- {if ($isDispatch == 1)}
-                 <a href="javascript:;" id="goOrder" url="{:url('Index/ordersList')}?mode=0&order_mode=1"  onclick="layer_open_dispatch(this,2)" class="glyphicon glyphicon-bell">
-                     <text id="orderNums">{if condition="$orderNums > 0"}({$orderNums}){/if}</text>
-                 </a>
-                 <a href="javascript:;" class="nn" onclick="offNotice()" id="offNotice" >
-                     <text id="offNoticeBtn">关闭通知</text>
-                 </a>
-                 <input type="hidden" id="offNoticeVal" value="0">
-                 {/if}-->
+             {if ($isDispatch == 1)}
+             <a href="javascript:;" id="goOrder" url="{:url('Index/ordersList')}?mode=0&order_mode=1"  onclick="layer_open_dispatch(this,2)" class="glyphicon glyphicon-bell">
+                 <text id="orderNums">{if condition="$orderNums > 0"}({$orderNums}){/if}</text>
+             </a>
+<!--             <a href="javascript:;" class="nn" onclick="offNotice()" id="offNotice" >-->
+<!--                 <text id="offNoticeBtn">关闭通知</text>-->
+<!--             </a>-->
+<!--             <input type="hidden" id="offNoticeVal" value="0">-->
+             {/if}
+                {empty name="userInfo['head_image']"}
+                <img src="/img/defaulthead.png" class="userhead" style="" alt="">
+                {else /}
+                <img src="{$userInfo['head_image']}" class="userhead"  alt="">
+                {/empty}
                 <a class="dropdown-toggle" data-toggle="dropdown" href="javascript:;" style="color: #284A94;height: 100%;margin-top: 5px">欢迎,{:session('user_auth.real_name')} </a>
                 <ul class="dropdown-menu animated fadeInRight m-t-xs">
                     <li><a class="JmenuItem" href="{:url('User/modifyPass')}" onclick="savePassWord()">修改密码</a></li>

+ 100 - 1
application/index/controller/Index.php

@@ -129,7 +129,7 @@ sql;
         foreach ($titles as $key => $value) {
             $worksheet->setCellValueByColumnAndRow($key+1, 1, $value);
         }
-        
+
         $arr = array('A','B','C','D');
         $styleArray = [
             'font' => [
@@ -463,7 +463,106 @@ sql;
 
     }
 
+    public static function ll($list,$list1,$arr=[]){
+        foreach ($list as $k=>$v){
+            foreach ($list1 as $k1=>$v1){
+                if($v['m1'] < $v1['m2']){
+                    $list[$k]['m1'] = 0;
+                    $list1[$k1]['m2'] = $v1['m2']-$v['m1'];
+                    $arr[] = [
+                        'm1_id'=>$v['id'],
+                        'm2_id'=>$v1['id'],
+                        'm'=>$v['m1'],
+                    ];
+                    unset($list[$k]);
+                    self::ll($list,$list1,$arr);
+                    break ;
+                }else if ($v['m1'] > $v1['m2']){
+                    $list[$k]['m1'] = $v['m1']-$v1['m2'];
+                    $list1[$k1]['m2'] =0;
+                    $arr[] = [
+                        'm1_id'=>$v['id'],
+                        'm2_id'=>$v1['id'],
+                        'm'=>$v1['m2'],
+                    ];
+                    unset($list1[$k1]);
 
+                    self::ll($list,$list1,$arr);
+                    break;
+                }else{
+                    $list[$k]['m1'] = $v['m1']-$v1['m2'];
+                    $list1[$k1]['m2'] =0;
+                    $arr[] = [
+                        'm1_id'=>$v['id'],
+                        'm2_id'=>$v1['id'],
+                        'm'=>$v1['m2'],
+                    ];
+                    unset($list1[$k1]);
+                    unset($list[$k]);
+                    self::ll($list,$list1,$arr);
+                    break ;
+                }
+            }
+
+        }
+        return $arr;
+    }
+    public static function ll1($list,$list1){
+        $arr = [];
+        while (!empty($list) && !empty($list1)){
+            foreach ($list as $k=>$v){
+                foreach ($list1 as $k1=>$v1){
+                    if($v['m1'] < $v1['m2']){
+                        $list[$k]['m1'] = 0;
+                        $list1[$k1]['m2'] = $v1['m2']-$v['m1'];
+                        $arr[] = [
+                            'm1_id'=>$v['id'],
+                            'm2_id'=>$v1['id'],
+                            'm'=>$v['m1'],
+                        ];
+                        unset($list[$k]);
+                    }else if ($v['m1'] > $v1['m2']){
+                        $list[$k]['m1'] = $v['m1']-$v1['m2'];
+                        $list1[$k1]['m2'] =0;
+                        $arr[] = [
+                            'm1_id'=>$v['id'],
+                            'm2_id'=>$v1['id'],
+                            'm'=>$v1['m2'],
+                        ];
+                        unset($list1[$k1]);
+
+                    }else{
+                        $list[$k]['m1'] = $v['m1']-$v1['m2'];
+                        $list1[$k1]['m2'] =0;
+                        $arr[] = [
+                            'm1_id'=>$v['id'],
+                            'm2_id'=>$v1['id'],
+                            'm'=>$v1['m2'],
+                        ];
+                        unset($list1[$k1]);
+                        unset($list[$k]);
+                    }
+                    break;
+                }
+                break;
+            }
+        }
+        return $arr;
+    }
+    public function tx(){
+
+        $list = Db::name('user')
+            ->where('m1','>',0)
+            ->select();
+        $list1 = Db::name('user')
+            ->where('m2','>',0)
+            ->select();
+        $r = self::ll1($list,$list1);
+        echo "<pre/>";
+        print_r(array_sum(array_column($r,'m')));
+        print_r($r);
+        die();
+    }
 
 
 }