|
@@ -31,37 +31,60 @@ class queue_logic
|
|
|
$postData['box_position_list'] = $params['box_position_list'];
|
|
|
$postData['delay_time'] = 0;
|
|
|
|
|
|
+ return $this->proc_request($params,'/open_box',$postData);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function LockCabinet($params) {
|
|
|
+ $postData['cabinet_code'] = $params['cabinet_code'];
|
|
|
+ $postData['delay_time'] = $params['delay_time'];
|
|
|
+
|
|
|
+ return $this->proc_request($params,'/lock_cabinet',$postData);
|
|
|
+ }
|
|
|
+ public function UnLockCabinet($params) {
|
|
|
+ $postData['cabinet_code'] = $params['cabinet_code'];
|
|
|
+ $postData['delay_time'] = $params['delay_time'];
|
|
|
+
|
|
|
+ return $this->proc_request($params,'/unlock_cabinet',$postData);
|
|
|
+ }
|
|
|
+ public function ReleaseAlarm($params) {
|
|
|
+ $postData['cabinet_code'] = $params['cabinet_code'];
|
|
|
+ $postData['delay_time'] = $params['delay_time'];
|
|
|
+
|
|
|
+ return $this->proc_request($params,'/release_alarm',$postData);
|
|
|
+ }
|
|
|
+ public function Reboot($params) {
|
|
|
+ $postData['cabinet_code'] = $params['cabinet_code'];
|
|
|
+ $postData['delay_time'] = $params['delay_time'];
|
|
|
+
|
|
|
+ return $this->proc_request($params,'/reboot',$postData);
|
|
|
+ }
|
|
|
+ public function QueryState($params) {
|
|
|
+ $postData['cabinet_code'] = $params['cabinet_code'];
|
|
|
+ $postData['delay_time'] = $params['delay_time'];
|
|
|
+
|
|
|
+ return $this->proc_request($params,'/query_state',$postData);
|
|
|
+ }
|
|
|
+
|
|
|
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
+ private function proc_request($params,$api,$postData)
|
|
|
+ {
|
|
|
$token = $this->login($params['req_url'],$params['key']);
|
|
|
if(empty($token)) {
|
|
|
$ret = ['code'=> 1,'msg' => '柜体服务器错误'];
|
|
|
- $this->sync_return($params['ret_queue'],$params['method'],$ret);
|
|
|
+ $this->sync_result($params['ret_queue'],$params['method'],$ret);
|
|
|
return $ret;
|
|
|
}
|
|
|
- $resp = $this->reqest($params['req_url'] ,'/open_box', $postData,$token);
|
|
|
+ $resp = $this->reqest($params['req_url'] ,$api, $postData,$token);
|
|
|
if(empty($resp)) {
|
|
|
- $ret = ['state'=> 1,'msg' => 'openbox fail.'];
|
|
|
- $this->sync_return($params['ret_queue'],$params['method'],$ret);
|
|
|
+ $ret = ['state'=> 1,'msg' => "{$api} fail."];
|
|
|
+ $this->sync_result($params['ret_queue'],$params['method'],$ret);
|
|
|
return $ret;
|
|
|
}
|
|
|
- $resp = $this->sync_return($params['ret_queue'],$params['method'],$resp);
|
|
|
- return $resp;
|
|
|
- }
|
|
|
-
|
|
|
- public function LockCabinet($params) {
|
|
|
- $box_list[] = $params['box_number'];
|
|
|
- $postData['cabinet_code'] = $params['cabinet_number'];
|
|
|
- $postData['box_position_list'] = $box_list;
|
|
|
- $postData['delay_time'] = 0;
|
|
|
|
|
|
- $token = $this->login($params['req_url'],$params['key']);
|
|
|
- $resp = $this->reqest($params['req_url'] ,'/open_box', $postData,$token);
|
|
|
-
|
|
|
- $this->sync_return($params['ret_queue'],$params['method'],$resp);
|
|
|
+ $resp = $this->sync_result($params['ret_queue'],$params['method'],$resp);
|
|
|
+ return $resp;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- private function sync_return($queue_name,$key,$params){
|
|
|
+ private function sync_result($queue_name, $key, $params){
|
|
|
global $config;
|
|
|
$host = $config['net_queue']['host'];
|
|
|
$port = $config['net_queue']['port'];
|