|
@@ -6,8 +6,10 @@ define('BASE_ROOT_PATH',str_replace('/application/index/controller','',dirname(_
|
|
|
require_once(BASE_ROOT_PATH . '/extend/queue.php');
|
|
|
require_once(BASE_ROOT_PATH . '/extend/queue.logic.php');
|
|
|
|
|
|
+use app\index\model\BoxActionModel;
|
|
|
use app\index\model\CabinetModel;
|
|
|
use app\index\model\BoxModel;
|
|
|
+use app\index\model\OrderModel;
|
|
|
use think\Session;
|
|
|
use QueueClient;
|
|
|
use QueueServer;
|
|
@@ -20,6 +22,12 @@ class Cabinet extends Base
|
|
|
*/
|
|
|
public function check_fcode(){
|
|
|
$code = input('param.code');
|
|
|
+ $OrderModel = new OrderModel();
|
|
|
+ $result = $OrderModel->check_fcode($code);
|
|
|
+ if($result['code'] != 1){
|
|
|
+ return json(json_error_exception('1009'));
|
|
|
+ }
|
|
|
+ json_success($result['data']);
|
|
|
}
|
|
|
/**
|
|
|
* 自提柜向服务器上报
|
|
@@ -37,6 +45,12 @@ class Cabinet extends Base
|
|
|
$trunk = input('param.trunk');
|
|
|
$cabinet = input('param.cabinet');
|
|
|
$state = input('param.state');
|
|
|
+
|
|
|
+ $result = $this->change_status($cabinet , $trunk , $state);
|
|
|
+ if($result['code'] != 1){
|
|
|
+ return json(json_error_exception('1006'));
|
|
|
+ }
|
|
|
+ json_success('');
|
|
|
}
|
|
|
/**
|
|
|
* 自提柜批量生产
|
|
@@ -79,9 +93,12 @@ class Cabinet extends Base
|
|
|
|
|
|
$content = $this->wait_ret($sid,'lredis',6379);
|
|
|
|
|
|
+ if($content['value'] == 'ok'){
|
|
|
+ $this->box_action_record($cabinet_number , $box_number , 1);
|
|
|
+ }
|
|
|
}
|
|
|
/**
|
|
|
- * 开启箱门
|
|
|
+ * 关闭箱门
|
|
|
*/
|
|
|
public function close_box()
|
|
|
{
|
|
@@ -98,7 +115,9 @@ class Cabinet extends Base
|
|
|
$this->push_queue('access_wait_close','close_box',$params);
|
|
|
|
|
|
$content = $this->wait_ret($sid,'lredis',6379);
|
|
|
-
|
|
|
+ if($content['value'] == 'ok'){
|
|
|
+ $this->box_action_record($cabinet_number , $box_number , 2);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private function testSend($queue_name,$value) {
|
|
@@ -155,19 +174,38 @@ class Cabinet extends Base
|
|
|
}
|
|
|
$where['cabinet_number'] = $cabinet_number;
|
|
|
$where['box_number'] = $box_number;
|
|
|
- $update['status'] = $status;
|
|
|
+ $update['box_status'] = $status;
|
|
|
return $BoxModel->editData($where,$update);
|
|
|
}
|
|
|
+ public function test(){
|
|
|
+ $cabinet_number = input('param.cabinet_number');
|
|
|
+ $box_number = input('param.box_number');
|
|
|
+ $order_sn = input('param.order_sn');
|
|
|
+ $result = $this->box_bind_order($cabinet_number , $box_number , $order_sn);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 自提柜箱子绑定订单号
|
|
|
*/
|
|
|
private function box_bind_order($cabinet_number , $box_number , $order_sn){
|
|
|
$where['cabinet_number'] = $cabinet_number;
|
|
|
$where['box_number'] = $box_number;
|
|
|
- $update['enter_time'] = date('Y-m-d H:i:s');
|
|
|
$update['order_sn'] = $order_sn;
|
|
|
+ $update['box_status'] = 2;
|
|
|
|
|
|
$BoxModel = new BoxModel();
|
|
|
return $BoxModel->editData($where,$update);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 记录箱子开启/关闭
|
|
|
+ */
|
|
|
+ private function box_action_record($cabinet_number , $box_number , $type){
|
|
|
+ $BoxActionModel = new BoxActionModel();
|
|
|
+ $params['cabinet_number'] = $cabinet_number;
|
|
|
+ $params['box_number'] = $box_number;
|
|
|
+ $params['type'] = $type;
|
|
|
+ $params['datetime'] = date("Y-m-d H:i:s");
|
|
|
+ $BoxActionModel->save($params);
|
|
|
+ }
|
|
|
}
|