一、open_basedir 不能再写 /tmp(7.4 池子把白名单收紧,Monolog/EasyWeChat 会抛异常)
- addons/shopro/library/Wechat.php:easywechat 日志改到 runtime/easywechat/
- addons/epay/library/Yansongda/Supports/Logger.php:epay 日志默认路径改到 runtime/epay/
- application/admin/library/traits/Backend.php:CSV 导入临时文件改到 runtime/temp/
二、implode 参数反序(7.4 起 E_DEPRECATED,TP5 会抛异常)
- application/api/controller/Datas.php
- application/index/controller/wms/Pda.php
- 另修正 Wms.php 中 1 处(拆分面单提示)
三、null 取下标(7.4 起 "Trying to access array offset on value of type null")
- 覆盖 71 个文件 135 行:find()/value()/json_decode()/redis get 等结果未判空即取下标处,
统一 (\['k'] ?? null) 兜底;foreach 目标用 ?? [];in_array/count 等数组参数用 ?? []
- 涉及 api/*、admin/shopro/*、addons/shopro/*、addons/epay/*、index/wms/* 等
四、嵌套三元未加括号(7.4 弃用)
- application/index/controller/wms/Wms.php getPackingprice 2 处,补括号后与旧版本解析顺序一致
验证:74 个文件、148 行改动,逐行括号/引号配平与 HEAD 一致,未改动 vendor/ 与 thinkphp/;
剩余扫描命中均为写目标、unset、或已被 if(!\){error()} 拦截的假阳性。
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
134 lines
4.8 KiB
PHP
134 lines
4.8 KiB
PHP
<?php
|
|
|
|
namespace app\api\controller;
|
|
|
|
use app\common\controller\Api;
|
|
use app\common\model\User;
|
|
use think\Hook;
|
|
use fast\Random;
|
|
use fast\Http;
|
|
use think\Log;
|
|
|
|
class Prints extends Api
|
|
{
|
|
protected $noNeedLogin = '';
|
|
protected $noNeedRight = '*';
|
|
public function _initialize()
|
|
{
|
|
parent::_initialize();
|
|
$this->redis = new \Redis();
|
|
$this->redis->connect('127.0.0.1', 6379);
|
|
$this->redis->auth('qwe2019@');
|
|
$this->redis->select(11);
|
|
$this->PrintComputerModel = new \app\common\model\wms_new\PrintComputer;
|
|
|
|
|
|
}
|
|
public function getbindInfo(){
|
|
$prams = $this->request->get();
|
|
$query_code = $prams["code"]?$prams["code"]:null;
|
|
|
|
if(!$query_code){
|
|
$this->error("参数错误");
|
|
}
|
|
$code = $this->redis->get("bind:".$query_code);
|
|
if(!$code){
|
|
$this->error("已过期,请重新扫码","bind:".$code);
|
|
}
|
|
|
|
$wms_account_id = $this->auth->wms_account_id;
|
|
$StoreModel = new \app\common\model\wms_new\Store;
|
|
$AccountStoreEmployeModel = new \app\common\model\wms_new\AccountStoreEmploye;
|
|
|
|
$stores = $AccountStoreEmployeModel->alias("AccountStoreEmploye")->field("AccountStoreEmploye.store_id as store_id,store.company_name as company_name")->where(["AccountStoreEmploye.account_id"=>$wms_account_id,"AccountStoreEmploye.deleted_at"=>null,"AccountStoreEmploye.status"=>1,"store.project"=>"warehouse"])->join("wms_store store","store.id = AccountStoreEmploye.store_id")->select();
|
|
//$StoreModel->where()->select();
|
|
$uuid = Random::uuid();
|
|
$code = json_decode($code);
|
|
$code->stores = $stores;
|
|
|
|
$this->redis->set("pbind:".$uuid,json_encode($code),400);
|
|
|
|
$this->success('查询成功',["userid"=>$wms_account_id,"stores"=>$stores,"code"=>$uuid]);
|
|
}
|
|
public function bindPrintComputer(){
|
|
$params = $this->request->post();
|
|
|
|
$code = isset($params["code"]) ? $params["code"] : null;
|
|
$computerName = isset($params["computerName"]) ? $params["computerName"] : null;
|
|
$warehouse_id = isset($params["warehouse_id"]) ? $params["warehouse_id"] : null;
|
|
|
|
// 参数校验
|
|
if(!$code || !$computerName || !$warehouse_id){
|
|
Log::error("绑定打印电脑参数错误");
|
|
$this->error("参数错误");
|
|
}
|
|
|
|
$code_data = $this->redis->get("pbind:".$code);
|
|
if(!$code_data){
|
|
Log::error("绑定码已过期");
|
|
$this->error("已过期,请重新扫码绑定", ["restart"=>1]);
|
|
}
|
|
$code_data = json_decode($code_data, true);
|
|
|
|
// 验证仓库是否在允许列表中
|
|
$inWarehouseList = false;
|
|
foreach(($code_data["stores"] ?? []) as $r){
|
|
if($r["store_id"] == $warehouse_id){
|
|
$inWarehouseList = true;
|
|
break;
|
|
}
|
|
}
|
|
if(!$inWarehouseList){
|
|
Log::error("仓库不在绑定码允许列表中");
|
|
$this->error("参数错误");
|
|
}
|
|
|
|
// 创建打印电脑记录
|
|
$data = $this->PrintComputerModel->create([
|
|
"warehouse_id" => $warehouse_id,
|
|
"name" => $computerName,
|
|
"status" => 0,
|
|
"is_recording" => 0
|
|
]);
|
|
$insert_id = $data->id ?? 0;
|
|
|
|
if(!$insert_id){
|
|
Log::error("打印电脑记录插入失败");
|
|
$this->error("插入失败", $data);
|
|
}
|
|
|
|
// 请求远程服务绑定
|
|
$url = "http://printer.wms.gztbyc.com/auth/bind?timestamp=".time();
|
|
$body = [
|
|
"roomId" => $code_data["uniqueId"],
|
|
"warehouse" => $warehouse_id,
|
|
"computerId" => $insert_id
|
|
];
|
|
$body = http_build_query($body);
|
|
$options = [
|
|
CURLOPT_HTTPHEADER => [
|
|
'Content-Type: application/x-www-form-urlencoded',
|
|
'Accept: application/json'
|
|
]
|
|
];
|
|
Log::error("远程绑定接口请求数据".$body);
|
|
$req = Http::sendRequest($url, $body, 'POST', $options);
|
|
|
|
if($req["ret"]){
|
|
$msg = $req["msg"];
|
|
$msg = json_decode($msg, true);
|
|
if(($msg["status"] ?? null)== "fail"){
|
|
$this->PrintComputerModel->where(["id" => $insert_id])->delete();
|
|
Log::error("远程绑定接口返回失败");
|
|
$this->error($msg["message"]);
|
|
} else {
|
|
Log::info("打印电脑绑定成功");
|
|
$this->success("绑定成功");
|
|
}
|
|
} else {
|
|
$this->PrintComputerModel->where(["id" => $insert_id])->delete();
|
|
Log::error("远程绑定请求失败");
|
|
$this->error("请求失败");
|
|
}
|
|
}
|
|
} |