Bläddra i källkod

撤消出金完善

Robin 6 år sedan
förälder
incheckning
19697575fe

+ 14 - 8
normandcrm/service/backend/controllers/WithdrawController.php

@@ -365,20 +365,28 @@ class WithdrawController extends BaseController
     public function actionRevokegold(){
         $id = (int) Yii::$app->request->post('id');
         $mt4_id = (int) Yii::$app->request->post('mt4_id');
+        $login = Withdraw::findOne($id)['login'];
         $res = Withdraw::updateAll(['type' => 1], "id = $id");    //更新出金表的状态(不通过,未扣减)
 
         if($res){
             //调用mt4的撤销出金接口
              $api = new Mt4ManagerApi();
              $result = $api->revokeOrder($mt4_id);
-             $tt = print_r($result,true);
              $result = json_decode($result,true);
-
-             file_put_contents('mt4_witt.txt',$tt);
+             $tt = print_r($result,true);
+             file_put_contents('mt1.txt',$tt);
              if(!$result['ret']){
-                 $res1 = Withdraw::updateAll(['mt4_status' => 0], "id = $id");    //更新出金表的状态(mt4未扣减)
-                 if($res1){
-                     return $this->outJson(1, [], '操作成功');
+                 $result2 = $api->fixbalance($login);
+                 $res2 = json_decode($result2,true);
+                 $tt = print_r($res2,true);
+                 file_put_contents('mt2.txt',$tt);
+                 if(!$res2['ret']){
+                     $res3 = Withdraw::updateAll(['mt4_status' => 0], "id = $id");    //更新出金表的状态(mt4未扣减)
+                     if($res3){
+                         return $this->outJson(1, [], '操作成功');
+                     }else{
+                         return $this->outJson(0, [], 'fixbalance失败');
+                     }
                  }
              }else{
                  return $this->outJson(0, [], 'mt4操作失败');
@@ -387,8 +395,6 @@ class WithdrawController extends BaseController
         }else{
             return $this->outJson(0, [], '更新操作失败');
         }
-
-
     }
 
     

+ 13 - 0
normandcrm/service/common/lib/Mt4ManagerApi.php

@@ -123,6 +123,19 @@ class Mt4ManagerApi
         return $this->_httpRequest($this->url, $params);
     }
 
+    public function fixbalance($login)
+    {
+        $params = array(
+            'cmd' => 'balancefix',
+            '$logins' => trim($login),
+        );
+        $config = Config::findOne(1);                   //获取到配置文件
+        $mt4_pay_ip = $config['mt4_pay_ip'];                     //获取mt4出入金ip
+        $mt4_pay_port = 10001;                 //获取出入金端口
+        $this->url = "http://{$mt4_pay_ip}:{$mt4_pay_port}/api";
+        return $this->_httpRequest($this->url, $params);
+    }
+
     /**
      * curl 请求
      */