|
@@ -39,7 +39,7 @@ class CodeService extends Service
|
|
|
|
|
|
//发送验证码到手机 TODO
|
|
|
list($status,$msg) = $this->sendCode($code);
|
|
|
- if(! $status) return [false,'发送验证码失败!'];
|
|
|
+ if(! $status) return [false,$msg];
|
|
|
|
|
|
//成功后 缓存code 60s
|
|
|
Cache::add($cacheKey,$code,60);
|
|
@@ -60,9 +60,23 @@ class CodeService extends Service
|
|
|
//获取验证码
|
|
|
$code = $this->createCode();
|
|
|
|
|
|
- //发送验证码到手机 TODO
|
|
|
- list($status,$msg) = $this->sendCode($code);
|
|
|
- if(! $status) return [false,'发送验证码失败!'];
|
|
|
+ //获取金额数据
|
|
|
+ $finance = (new FinanceService())->getData($data['id']);
|
|
|
+ if(empty($finance)) return [false,'未找到出账数据!'];
|
|
|
+
|
|
|
+ $send = [
|
|
|
+ "code"=> $code,
|
|
|
+ "type"=> 2,
|
|
|
+ "account" => $finance['account'],
|
|
|
+ "bankAccount" => $finance['finance_account_name'],
|
|
|
+ "ifsc" => $finance['ifsc'],
|
|
|
+ "amount" => $finance['amount'],
|
|
|
+ ];
|
|
|
+ $send['sign'] = $this->sign($send);
|
|
|
+
|
|
|
+ //发送验证码到
|
|
|
+ list($status,$msg) = $this->sendCode($send);
|
|
|
+ if(! $status) return [false, $msg];
|
|
|
|
|
|
//成功后 缓存code 60s
|
|
|
Cache::add($cacheKey,$code,60);
|
|
@@ -70,8 +84,27 @@ class CodeService extends Service
|
|
|
return [true,''];
|
|
|
}
|
|
|
|
|
|
- //发送验证码 TODO
|
|
|
- public function sendCode($code){
|
|
|
+ //加密
|
|
|
+ public function sign($data){
|
|
|
+ $str = [];
|
|
|
+ sort($data);
|
|
|
+ foreach ($data as $k=>$v){
|
|
|
+ $str[] = $k.'='.$v;
|
|
|
+ }
|
|
|
+
|
|
|
+ $vaild = implode(',',$str).'doTAKtnpiG';
|
|
|
+ return md5($vaild);
|
|
|
+ }
|
|
|
+
|
|
|
+ //发送验证码
|
|
|
+ public function sendCode($send){
|
|
|
+ $url = "https://api2.indiacashpayment.in/sendTelegramCode";
|
|
|
+ $result = $this->curlURL($url,$send);
|
|
|
+
|
|
|
+ if($result['status'] == 201){
|
|
|
+ return [false, $result['msg']];
|
|
|
+ }
|
|
|
+
|
|
|
return [true,''];
|
|
|
}
|
|
|
|
|
@@ -104,9 +137,25 @@ class CodeService extends Service
|
|
|
return [false,'验证码不存在!'];
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ public function curlURL($url,$data){
|
|
|
+ $data = json_encode($data);
|
|
|
+ $header[] = "Content-Type:application/json";
|
|
|
+ $ch=curl_init($url);
|
|
|
+ curl_setopt($ch,CURLOPT_POST,1);
|
|
|
+ curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
|
|
|
+ curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
|
|
|
+ curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
|
|
|
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
|
|
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
|
|
+ $response=curl_exec($ch);
|
|
|
+ file_put_contents('charge.txt',$response.PHP_EOL,8);
|
|
|
+ $response=json_decode($response,true);
|
|
|
+
|
|
|
+ if(curl_errno($ch) ){
|
|
|
+ sc(curl_error($ch));
|
|
|
+ }
|
|
|
+ return $response;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
//------------------暂时用不到下面------------------------//
|