Browse Source

把订单查orders_history表的数据改到deals表

Candy 6 năm trước cách đây
mục cha
commit
c71713510b
1 tập tin đã thay đổi với 12 bổ sung13 xóa
  1. 12 13
      thinkphp/application/index/controller/Index.php

+ 12 - 13
thinkphp/application/index/controller/Index.php

@@ -132,37 +132,36 @@ class Index extends controller
             }
 
             //查询开仓信息
-            $openResult = Db::connect("db_con2")->query("SELECT PriceCurrent,TimeSetup FROM mt5_orders_history WHERE PositionID={$data['orderid']} and TimeSetup = (SELECT MIN(TimeSetup) FROM mt5_orders_history WHERE PositionID={$data['orderid']})")[0];
+            $openResult = Db::connect("db_con2")->query("SELECT Price,Time FROM mt5_deals WHERE PositionID={$data['orderid']} and Time = (SELECT MIN(Time) FROM mt5_deals WHERE PositionID={$data['orderid']})")[0];
 
             //通过deals表查询盈利
             $earnings = Db::connect("db_con2")->query("SELECT SUM(Commission) as commission,SUM(Profit) as profit FROM mt5_deals WHERE PositionID={$data['orderid']}")[0];
 
             //查询关仓信息
-            $closeResult = Db::connect("db_con2")->query("SELECT PriceCurrent,TimeDone,Login,PositionID,Symbol,VolumeInitial,PriceTP,PriceSL FROM mt5_orders_history WHERE PositionID={$data['orderid']} and TimeDone = (SELECT MAX(TimeDone) FROM mt5_orders_history WHERE PositionID={$data['orderid']})")[0];
+            $closeResult = Db::connect("db_con2")->query("SELECT Price,Time,Login,PositionID,Symbol,Volume,PriceTP,PriceSL FROM mt5_deals WHERE PositionID={$data['orderid']} and Time = (SELECT MAX(Time) FROM mt5_deals WHERE PositionID={$data['orderid']})")[0];
 
-            //获取订单的所有deal
-            $getDeal =  Db::connect("db_con2")->query("select Deal as 'deal' from mt5_deals  WHERE PositionID = {$data['orderid']}");
+            //获取订单的所有deal,orders
+            $result =  Db::connect("db_con2")->query("select Deal as 'deal',`Order` from mt5_deals  WHERE PositionID = {$data['orderid']}");
 
-            //查询该positionID的所有order
-            $result = Db::connect("db_con2")->query("SELECT `Order` FROM mt5_orders_history WHERE PositionID = {$data['orderid']}");
 
-            $getDeals = array_column($getDeal,'deal');
+
+            $getDeals = array_column($result,'deal');
             $order = array_column($result,'Order');
 
             if($closeResult && $result && $openResult){
 
                 //发送set_current_postion 数据
-                $send = ['orders'=>$order,'from'=>strtotime($openResult['TimeSetup'])-1,'to'=>strtotime($closeResult['TimeDone'])+1,'login'=>$closeResult['Login'],'deals'=>$getDeals];
+                $send = ['orders'=>$order,'from'=>strtotime($openResult['Time'])-1,'to'=>strtotime($closeResult['Time'])+1,'login'=>$closeResult['Login'],'deals'=>$getDeals];
 
                 $data = [
-                    'OPEN_PRICE' => $openResult["PriceCurrent"],
-                    'OPEN_TIME' => $openResult["TimeSetup"],
-                    'CLOSE_TIME' => $closeResult['TimeDone'],
-                    'CLOSE_PRICE' => $closeResult['PriceCurrent'],
+                    'OPEN_PRICE' => $openResult["Price"],
+                    'OPEN_TIME' => $openResult["Time"],
+                    'CLOSE_TIME' => $closeResult['Time'],
+                    'CLOSE_PRICE' => $closeResult['Price'],
                     'LOGIN' => $closeResult['Login'],
                     'TICKET' => $closeResult['PositionID'],
                     'SYMBOL' => $closeResult['Symbol'],
-                    'VOLUME' => $closeResult['VolumeInitial'],
+                    'VOLUME' => $closeResult['Volume'],
                     'TP' => $closeResult['PriceTP'],
                     'SL' =>  $closeResult['PriceSL'],
                     'PROFIT' => $earnings['profit'],