|
@@ -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();
|
|
|
+ }
|
|
|
|
|
|
|
|
|
}
|