| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249 |
- <?php
- namespace common\helpers;
- use common\lib\Mt4Api;
- use common\lib\Mt4Deposit;
- use Yii;
- use yii\httpclient\Client;
- class MtKit
- {
- /**
- * 获取MT4分组
- * @return array
- */
- public static function getGroups()
- {
- $result = [];
- $client = new Client();
- // http://192.168.1.100:9090/MtService/getGroups
- $response = $client->get(Yii::$app->params['mtHttpServerUrl'] . "/MtService/getGroups")->send();
- if ($response->getIsOk()) {
- $content = $response->getContent();
- $jsonArr = @json_decode($content, true);
- foreach ((array)$jsonArr as $key => $row) {
- $result[] = isset($row['Name']) ? trim($row['Name']) : '';
- }
- } else {
- Yii::warning($response->getContent(), __CLASS__);
- }
- return $result;
- }
- /**
- * 入金
- * @param int $login
- * @param float $balance
- * @param string $comment
- * @return bool
- */
- public static function deposit($login, $balance, $comment)
- {
- $mt4 = new Mt4Deposit();
- $result = $mt4->deposit($login, $balance, $comment);
- if ($result['errCode'] == 0) {
- return true;
- }
- /*
- $client = new Client();
- $data = [
- 'login' => $login,
- 'balance' => $balance,
- 'comment' => $comment,
- ];
- // http://192.168.1.100:9090/MtService/deposit?login=Int32&balance=Double&comment=String
- $response = $client->get(Yii::$app->params['mtHttpServerUrl'] . "/MtService/deposit", $data)->send();
- if ($response->getIsOk()) {
- $content = $response->getContent();
- $jsonArr = @json_decode($content, true);
- if ($jsonArr['Ret'] == 0) {
- return true;
- }
- }
- Yii::warning($response->getContent(), __CLASS__);
- */
- return false;
- }
- /**
- * 出金
- * @param int $login
- * @param float $balance
- * @param string $comment
- * @return bool
- */
- public static function withdrawal($login, $balance, $comment)
- {
- $mt4 = new Mt4Deposit();
- $result = $mt4->withdraw($login, $balance, $comment);
- if ($result['errCode'] == 0) {
- return true;
- }
- /*
- $client = new Client();
- $data = [
- 'login' => $login,
- 'balance' => $balance,
- 'comment' => $comment,
- ];
- // http://192.168.1.100:9090/MtService/withdrawal?login=Int32&balance=Double&comment=String
- $response = $client->get(Yii::$app->params['mtHttpServerUrl'] . "/MtService/withdrawal", $data)->send();
- if ($response->getIsOk()) {
- $content = $response->getContent();
- $jsonArr = @json_decode($content, true);
- if ($jsonArr['Ret'] == 0) {
- return true;
- }
- }
- Yii::warning($response->getContent(), __CLASS__);
- */
- return false;
- }
- /**
- * 真实账户开户
- * @param int $login
- * @param string $password
- * @param string $passwordInvestor
- * @param string $passwordPhone
- * @param string $name
- * @param int $group
- * @param string $email
- * @param string $phone
- * @param int $leverage
- * @param string $country
- * @param int $state
- * @param string $city
- * @param string $address
- * @param string $zipCode
- * @param int $id
- * @param int $agentAccount
- * @return bool|int
- */
- public static function openUser($login, $password, $passwordInvestor, $passwordPhone, $name, $group, $email,
- $phone, $leverage, $country, $state, $city, $address, $zipCode, $id, $agentAccount)
- {
- /*
- $data = [
- 'LOGIN' => $login,
- 'PASSWORD' => $password,
- 'INVESTOR' => $passwordInvestor,
- 'PHONE_PASSWORD' => $passwordPhone,
- 'NAME' => $name,
- 'GROUP' => $group,
- 'EMAIL' => $email,
- 'PHONE' => $phone,
- 'LEVERAGE' => $leverage,
- 'COUNTRY' => $country,
- 'STATE' => $state,
- 'CITY' => $city,
- 'ADDRESS' => $address,
- 'ZIPCODE' => $zipCode,
- 'ID' => $id,
- 'AGENT_ACCOUNT' => $agentAccount,
- ];
- $api = new Mt4Api();
- $result = $api->addAccount($data, 1);
- if ($result['Ret'] == 0) {
- return trim($result['Obj']['Login']);
- } else {
- Yii::warning(json_encode($result), __CLASS__);
- }
- */
- $data = [
- 'login' => $login,
- 'password' => $password,
- 'passwordInvestor' => $passwordInvestor,
- 'passwordPhone' => $passwordPhone,
- 'name' => $name,
- 'group' => $group,
- 'email' => $email,
- 'phone' => $phone,
- 'leverage' => $leverage,
- 'country' => $country,
- 'state' => $state,
- 'city' => $city,
- 'address' => $address,
- 'zipCode' => $zipCode,
- 'id' => $id,
- 'agentAccount' => $agentAccount,
- ];
- $client = new Client();
- $response = $client->get(Yii::$app->params['mtHttpServerUrl'] . "/MtService/openUser", $data)->send();
- Yii::warning($response->getContent(), __CLASS__);
- if ($response->getIsOk()) {
- $content = $response->getContent();
- $jsonArr = @json_decode($content, true);
- if ($jsonArr['Ret'] == 0) {
- return trim($jsonArr['Obj']['Login']);
- } else {
- return 0;
- }
- }
- return false;
- }
- /**
- * 模拟账户开户
- * @param null $login
- * @param string $password
- * @param string $passwordInvestor
- * @param string $passwordPhone
- * @param string $name
- * @param null $group
- * @param string $email
- * @param string $phone
- * @param null $leverage
- * @param null $country
- * @param null $state
- * @param null $city
- * @param null $address
- * @param null $zipCode
- * @param null $id
- * @param null $agentAccount
- * @return bool|int|string
- */
- public static function openUserDemo($login = null, $password, $passwordInvestor, $passwordPhone, $name, $group = null,
- $email, $phone, $leverage = null, $country = null, $state = null, $city = null,
- $address = null, $zipCode = null, $id = null, $agentAccount = null)
- {
- /*
- $data = [
- 'PASSWORD' => $password,
- 'INVESTOR' => $passwordInvestor,
- 'PHONE_PASSWORD' => $passwordPhone,
- 'NAME' => $name,
- 'EMAIL' => $email,
- 'PHONE' => $phone,
- ];
- $api = new Mt4Api();
- $result = $api->addAccount($data, 0);
- if ($result['Ret'] == 0) {
- return $result['Obj']['Login'];
- } else {
- Yii::warning(json_encode($result), __CLASS__);
- }
- */
- $data = [
- 'password' => $password,
- 'investor' => $passwordInvestor,
- 'phone_password' => $passwordPhone,
- 'username' => $name,
- 'email' => $email,
- 'phone' => $phone,
- ];
- $client = new Client();
- $response = $client->get("http://live.taikong88.com/index/index/openDemo", $data)->send();
- if ($response->getIsOk()) {
- $content = $response->getContent();
- $jsonArr = @json_decode($content, true);
- if ($jsonArr['Ret'] == 0) {
- return trim($jsonArr['Obj']['Login']);
- } else {
- return 0;
- }
- }
- Yii::warning($response->getContent(), __CLASS__);
- return false;
- }
- }
|