|
@@ -8,8 +8,7 @@ require_once(BASE_HELPER_PATH . '/refill/divert_account.php');
|
|
|
require_once(BASE_HELPER_PATH . '/refill/RefillFactory.php');
|
|
|
require_once(BASE_CORE_PATH . '/framework/function/http.php');
|
|
|
require_once(BASE_HELPER_PATH . '/PHPExcel/PHPExcel.php');
|
|
|
-require_once(BASE_HELPER_PATH . '/task/task_helper.php');
|
|
|
-require_once(BASE_HELPER_RAPI_PATH . "/gdsinopec/RefillOil.php");
|
|
|
+
|
|
|
|
|
|
class vendorControl
|
|
|
{
|
|
@@ -20,9 +19,22 @@ class vendorControl
|
|
|
//中石化电子券token获取
|
|
|
public function token_refreshOp()
|
|
|
{
|
|
|
- $worker = function () : bool {
|
|
|
+ Log::record(__METHOD__,Log::DEBUG);
|
|
|
+ require_once(BASE_HELPER_RAPI_PATH . "/gdsinopec/config.php");
|
|
|
|
|
|
- return true;
|
|
|
+ $worker = function () : bool
|
|
|
+ {
|
|
|
+ $token_req = new refill\gdsinopec\config();
|
|
|
+ [$state, $result] = $token_req->get_access_token();
|
|
|
+ if ($state === false) {
|
|
|
+ Log::record("get token fail msg:$result", Log::ERR);
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ $access_token = $result['access_token'];
|
|
|
+ $expires_in = intval($result['expires_in']);
|
|
|
+ wcache('vendor-cfgs', ['gdsinopec-token' => $access_token,'gdsinopec-time' => time() + $expires_in],'refill-');
|
|
|
+ return true;
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
$next_time = 0;
|
|
@@ -36,13 +48,6 @@ class vendorControl
|
|
|
sleep(1);
|
|
|
}
|
|
|
elseif($worker()) {
|
|
|
- $provider = new refill\gdsinopec\RefillOil([]);
|
|
|
- [$state, $access_token] = $provider->get_access_token();
|
|
|
- if($state === false) {
|
|
|
- Log::record("get token fail msg:{$access_token}",Log::ERR);
|
|
|
- }else{
|
|
|
-
|
|
|
- }
|
|
|
$next_time = time() + $period;
|
|
|
}
|
|
|
else {
|