Przeglądaj źródła

撤消出金功能初步实现

Robin 6 lat temu
rodzic
commit
8e655b8237

+ 23 - 11
normandcrm/service/backend/controllers/WithdrawController.php

@@ -363,24 +363,36 @@ class WithdrawController extends BaseController
     public function actionRevokegold(){
         $id = (int) Yii::$app->request->post('id');
         $mt4_id = (int) Yii::$app->request->post('mt4_id');
-        $res = Withdraw::updateAll(['mt4_status' => 0,'type' => 1], "id = $id");    //更新出金表的状态(不通过,未扣减)
+        $login = Withdraw::findOne($id)['login'];
+        $res = Withdraw::updateAll(['type' => 1], "id = $id");    //更新出金表的状态(不通过,未扣减)
 
         if($res){
-
             //调用mt4的撤销出金接口
-             $api = new Mt4ManagerApi();
-             $result = $api->revokeOrder($mt4_id);
-             if(!$result){
-                 return $this->outJson(1, [], '操作成功');
-             }else{
-                 return $this->outJson(0, [], 'mt4操作失败');
-             }
+            $api = new Mt4ManagerApi();
+            $result = $api->revokeOrder($mt4_id);
+            $result = json_decode($result,true);
+            $tt = print_r($result,true);
+            file_put_contents('mt1.txt',$tt);
+            if(!$result['ret']){
+                $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操作失败');
+            }
 
         }else{
             return $this->outJson(0, [], '更新操作失败');
         }
-
-
     }
 
     

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

@@ -125,6 +125,22 @@ 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 = $config['mt4_pay_port'];                 //获取出入金端口
+        $this->url = "http://{$mt4_pay_ip}:{$mt4_pay_port}/api";
+        return $this->_httpRequest($this->url, $params);
+    }
+
     /**
      * curl 请求
      */