|
@@ -170,7 +170,7 @@ class DevicesService extends BaseService
|
|
|
// 亮灯处理
|
|
|
unset($deviceNums[0]);
|
|
|
RedisService::set("caches:devices:nums_{$deviceCode}", $deviceNums, rand(10,30));
|
|
|
- $colors = ['黄','红','绿','白'];
|
|
|
+ $colors = ['黄色','红色','绿色','白色'];
|
|
|
shuffle($colors);
|
|
|
$data = [
|
|
|
'CommandType'=> 'OpenLed', // 执行命令方式:OpenLed-开灯,CloseLed-关灯,QuitStatus-查询状态
|
|
@@ -180,17 +180,26 @@ class DevicesService extends BaseService
|
|
|
'Color'=> $colors[0], // 颜色
|
|
|
'OrderNo'=> $orderSn, // 订单号
|
|
|
];
|
|
|
+ $dataStr = [];
|
|
|
+ foreach($data as $k => $v){
|
|
|
+ $dataStr[] = $k.'='.$v;
|
|
|
+ }
|
|
|
|
|
|
// 调用亮灯接口处理
|
|
|
+ $dataStr = implode('&', $dataStr);
|
|
|
+ $headers = ["Content-Type:application/x-www-form-urlencoded; charset=UTF-8"];
|
|
|
$apiUrl = ConfigService::make()->getConfigByCode('gd_api_url').'/LEDControl.ashx';
|
|
|
RedisService::set($errorKey.':request', ['url'=> $apiUrl,'data'=> $data], 3600);
|
|
|
- $result = httpRequest($apiUrl, $data,'post','',3);
|
|
|
+ $result = httpHeaderRequest($apiUrl, $dataStr,'post',$headers,'text');
|
|
|
RedisService::set($errorKey.':result', $result, 3600);
|
|
|
- $code = isset($result['code'])? $result['code'] : '';
|
|
|
|
|
|
// 更新灯状态
|
|
|
- GongdengOrderModel::where('order_sn', $orderSn)->update(['lamp_status'=> 2,'device_num'=> $deviceLampNo,'params'=> json_encode($data, 256)]);
|
|
|
+ if($result == 'True'){
|
|
|
+ GongdengOrderModel::where('order_sn', $orderSn)->update(['lamp_status'=> 2,'device_num'=> $deviceLampNo,'params'=> json_encode($data, 256)]);
|
|
|
+ return true;
|
|
|
+ }else{
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
- return true;
|
|
|
}
|
|
|
}
|