12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- /**
- * erp相关队列业务脚本
- */
- namespace Jobs\Model\MTopic;
- class MErp
- {
- /**
- * 锁定库存
- * @param string $callback_url 回调地址
- * @param string $callback_params 回调参数
- */
- public function lockStock($params)
- {
- if(!$params){
- echo '参数值有空值'.PHP_EOL;
- return false;
- }
- $callback_url = $params['callback_url'];
- $authorization = $params['token'];
- unset($params['callback_url']);
- unset($params['token']);
- $i = 1;
- do{
- $curl_option = [
- CURLOPT_HTTPHEADER => [
- 'Content-Type:text/plain',
- 'Authorization:'.$authorization,
- ],
- ];
- $result = request($callback_url, json_encode($params['data']), 10, $curl_option);
- if($result['httpcode'] == 200){
- echo '请求业务脚本成功'.PHP_EOL;
- return true;
- }
- $i ++;
- sleep(1);
- }while($result['httpcode'] != 200 && $i <= 3);
- echo '请求业务脚本失败'.PHP_EOL;
- return false;
- }
- }
|