<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Vendor\SoftApi; use Illuminate\Support\Facades\Log; use Illuminate\Support\Str; use ModStart\Core\Input\Request; use ModStart\Core\Input\Response; use ModStart\Core\Util\CurlUtil; use ModStart\Core\Util\SignUtil; class SoftApi { static $API_BASE = null; private $appId; private $appSecret; private $debug = false; public function __construct($SEb7x, $cC5Py = null) { goto Uv6F4; Uv6F4: self::$API_BASE = 'https://api.' . __BASE_SITE__ . '/open_api'; goto iRFp1; iRFp1: if (Str::contains(Request::domainUrl(), 'api.de' . 'mo.so' . 'ft.host')) { self::$API_BASE = Request::domainUrl() . '/open_api'; } goto f25Ge; ft0lt: $this->appSecret = $cC5Py; goto le_1P; f25Ge: $this->appId = $SEb7x; goto ft0lt; le_1P: } public function signCheck($OzAEo) { goto ud5h7; g3d4P: $aCaPt = SignUtil::common($OzAEo, $this->appSecret); goto OYHvp; ut1AY: $aVGuE = $OzAEo['sign']; goto ZNcmA; ZNcmA: unset($OzAEo['sign']); goto g3d4P; z4qYF: if ($OzAEo['timestamp'] < time() - 1800 || $OzAEo['timestamp'] > time() + 1800) { return false; } goto ut1AY; OYHvp: if ($aVGuE != $aCaPt) { return false; } goto D3Pph; b_DQt: if ($OzAEo['app_id'] != $this->appId) { return false; } goto z4qYF; ud5h7: if (empty($OzAEo['sign']) || empty($OzAEo['timestamp']) || empty($OzAEo['app_id'])) { return false; } goto b_DQt; D3Pph: return true; goto tyIGb; tyIGb: } public static function instance($SEb7x, $cC5Py = null) { goto AV5jW; oPeee: return $nZPMk[$SEb7x]; goto RU6vu; a6bZr: if (!isset($nZPMk[$SEb7x])) { $nZPMk[$SEb7x] = new self($SEb7x, $cC5Py); } goto oPeee; AV5jW: static $nZPMk = array(); goto a6bZr; RU6vu: } public function setDebug($XFWP7) { $this->debug = $XFWP7; } private function request($RVHaC, $OzAEo = array()) { goto uhFIB; L5eFm: return CurlUtil::postJSONBody(self::$API_BASE . $RVHaC, $OzAEo); goto CGIVA; F4qSF: if ($this->appSecret) { $OzAEo['timestamp'] = time(); $OzAEo['sign'] = SignUtil::common($OzAEo, $this->appSecret); } goto z5vp9; uhFIB: $OzAEo['app_id'] = $this->appId; goto F4qSF; z5vp9: if ($this->debug) { Log::debug('SoftAPI -> ' . self::$API_BASE . $RVHaC . ' -> ' . json_encode($OzAEo)); } goto L5eFm; CGIVA: } public function ping() { goto qB51A; Uq_ur: return Response::generate(0, 'ok'); goto LcwXR; nrZV2: if ($yvBIN['code']) { return Response::generate(-1, 'PING失败'); } goto Uq_ur; qB51A: $yvBIN = $this->request('/ping'); goto nrZV2; LcwXR: } public function payOfflineCreate($AanJe, $BIbHM, $YLCit, $yqSG5) { return $this->request('/pay_offline/create', array('biz_sn' => $AanJe, 'money' => $BIbHM, 'notify_url' => $YLCit, 'return_url' => $yqSG5)); } public function captchaVerify($qGuBo, $bM44E, $I3SIX, $wwsNp, $XMeWw) { return $this->request('/captcha/verify', array('action' => $qGuBo, 'key' => $bM44E, 'data' => $I3SIX, 'runtime' => $wwsNp, 'types' => $XMeWw)); } public function captchaValidate($bM44E) { return $this->request('/captcha/validate', array('key' => $bM44E)); } public function smsSend($fFmiT, $bGSqa, $lz8OT = array()) { goto lLbD2; gggAl: return $this->request('/sms/send', array_merge(array('phone' => $fFmiT, 'template_id' => $bGSqa), $aTKlo)); goto L9uTv; MG8ZF: foreach ($lz8OT as $l0ek5 => $vuqB0) { $aTKlo["param_{$l0ek5}"] = $vuqB0; } goto gggAl; lLbD2: $aTKlo = array(); goto MG8ZF; L9uTv: } public function audioConvert($G6ONv, $Lcunu, $MmZff) { goto AzEga; U__F1: $aTKlo['to'] = $Lcunu; goto dj4HQ; AzEga: $aTKlo = array(); goto IY2j4; IY2j4: $aTKlo['from'] = $G6ONv; goto U__F1; dj4HQ: $aTKlo['content'] = $MmZff; goto Pm0iF; Pm0iF: return $this->request('/audio_convert', $aTKlo); goto tqeTV; tqeTV: } public function asr($aA2dJ, $MmZff) { goto v8l4E; v8l4E: $aTKlo = array(); goto yGSwY; GdWNQ: $aTKlo['content'] = $MmZff; goto wh7x6; yGSwY: $aTKlo['type'] = $aA2dJ; goto GdWNQ; wh7x6: return $this->request('/asr', $aTKlo); goto gaz7m; gaz7m: } public function express($aA2dJ, $l7iM0) { goto nox8w; HJ48u: $aTKlo['type'] = $aA2dJ; goto F5fib; F5fib: $aTKlo['no'] = $l7iM0; goto JRc1p; JRc1p: return $this->request('/express', $aTKlo); goto O5c2g; nox8w: $aTKlo = array(); goto HJ48u; O5c2g: } }