liufumingren 7b18287328 fix: 全项目清理 PHP 7.4 升级遗留(open_basedir 临时目录、implode 反序、null 取下标、嵌套三元)
一、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>
2026-10-25 09:47:48 +08:00

115 lines
7.6 KiB
PHP

<?php
namespace app\api\controller;
use app\common\controller\Api;
use app\common\model\User;
use think\Hook;
use fast\Random;
class Produce extends Api
{
protected $noNeedLogin = '';
protected $noNeedRight = '';
public function index(){
$params=$this->request->post();
$storeid=isset($params['storeid'])?$params['storeid']:0;
$where2 = $storeid?'STOREID='.$storeid:'';
//print_r($storeid);
//print_r($where2);die();
$WAREHOUSEID = $this->auth->warehouseid;
$orderModel = new \app\common\model\wms\Order;
try {
$where = 'POSTNUM=\'\'';
$dfp = $orderModel->where($where)->where($where2)->where('cast(CREATIONDATE as signed) >= '.strtotime(date("Y-m-d",strtotime("-30 day")))*1000)->where(['WAREHOUSEID'=>$WAREHOUSEID])->count();
$where = 'PRINTTIMES=0 and POSTFLAG=1';
$ddy = $orderModel->where($where)->where($where2)->where('cast(CREATIONDATE as signed) >= '.strtotime(date("Y-m-d",strtotime("-30 day")))*1000)->where(['WAREHOUSEID'=>$WAREHOUSEID])->count();
$where = 'PRINTTIMES=1 and PICKINGFLAG=0 and OPERATERECORDS not like \'%领料%\' and GRABNUM != \'\'';
$dll = $orderModel->where($where)->where($where2)->where('cast(CREATIONDATE as signed) >= '.strtotime(date("Y-m-d",strtotime("-30 day")))*1000)->where(['WAREHOUSEID'=>$WAREHOUSEID])->count();
$where = 'PICKINGFLAG=0 and OPERATERECORDS like \'%领料%\'';
$djh = $orderModel->where($where)->where($where2)->where('cast(CREATIONDATE as signed) >= '.strtotime(date("Y-m-d",strtotime("-30 day")))*1000)->where(['WAREHOUSEID'=>$WAREHOUSEID])->count();
$where = 'POSTFLAG=1 and OPERATERECORDS not like \'%揽收%\'';
$dls = $orderModel->where($where)->where($where2)->where('cast(CREATIONDATE as signed) >= '.strtotime(date("Y-m-d",strtotime("-30 day")))*1000)->where(['WAREHOUSEID'=>$WAREHOUSEID])->count();
$where = 'POSTFLAG=1 and OPERATERECORDS like \'%揽收%\'';
$yls = $orderModel->where($where)->where($where2)->where('cast(CREATIONDATE as signed) >= '.strtotime(date("Y-m-d",strtotime("-30 day")))*1000)->where(['WAREHOUSEID'=>$WAREHOUSEID])->count();
$where = 'PICKINGFLAG=3 and PLSENDFLAG=0';
$dfh = $orderModel->where($where)->where($where2)->where('cast(CREATIONDATE as signed) >= '.strtotime(date("Y-m-d",strtotime("-30 day")))*1000)->where(['WAREHOUSEID'=>$WAREHOUSEID])->count();
$where = 'PLSENDFLAG=1 and WEIGHT = \'\'';
$dcz = $orderModel->where($where)->where($where2)->where('cast(CREATIONDATE as signed) >= '.strtotime(date("Y-m-d",strtotime("-30 day")))*1000)->where(['WAREHOUSEID'=>$WAREHOUSEID])->count();
$where = 'PLSENDFLAG=1 and OPERATERECORDS not like \'%打包%\'';
$ddb = $orderModel->where($where)->where($where2)->where('cast(CREATIONDATE as signed) >= '.strtotime(date("Y-m-d",strtotime("-30 day")))*1000)->where(['WAREHOUSEID'=>$WAREHOUSEID])->count();
$where = '';
$yjd = $orderModel->where($where)->where($where2)->where('cast(CREATIONDATE as signed) >= '.strtotime(date("Y-m-d",strtotime("-30 day")))*1000)->where(['WAREHOUSEID'=>$WAREHOUSEID])->count();
$where = 'POSTFLAG=1';
$yfp = $orderModel->where($where)->where($where2)->where('cast(CREATIONDATE as signed) >= '.strtotime(date("Y-m-d",strtotime("-30 day")))*1000)->where(['WAREHOUSEID'=>$WAREHOUSEID])->count();
$where = 'PRINTTIMES=1';
$ydy = $orderModel->where($where)->where($where2)->where('cast(CREATIONDATE as signed) >= '.strtotime(date("Y-m-d",strtotime("-30 day")))*1000)->where(['WAREHOUSEID'=>$WAREHOUSEID])->count();
$where = 'OPERATERECORDS like \'%领料%\' or PICKINGFLAG=3';
$yll = $orderModel->where($where)->where($where2)->where('cast(CREATIONDATE as signed) >= '.strtotime(date("Y-m-d",strtotime("-30 day")))*1000)->where(['WAREHOUSEID'=>$WAREHOUSEID])->count();
$where = 'PICKINGFLAG=3';
$yjh = $orderModel->where($where)->where($where2)->where('cast(CREATIONDATE as signed) >= '.strtotime(date("Y-m-d",strtotime("-30 day")))*1000)->where(['WAREHOUSEID'=>$WAREHOUSEID])->count();
$where = 'PLSENDFLAG=1';
$yfh = $orderModel->where($where)->where($where2)->where('cast(CREATIONDATE as signed) >= '.strtotime(date("Y-m-d",strtotime("-30 day")))*1000)->where(['WAREHOUSEID'=>$WAREHOUSEID])->count();
$where = 'WEIGHT <> \'\'';
$ycz = $orderModel->where($where)->where($where2)->where('cast(CREATIONDATE as signed) >= '.strtotime(date("Y-m-d",strtotime("-30 day")))*1000)->where(['WAREHOUSEID'=>$WAREHOUSEID])->count();
$where = 'OPERATERECORDS like \'%打包%\'';
$ydb = $orderModel->where($where)->where($where2)->where('cast(CREATIONDATE as signed) >= '.strtotime(date("Y-m-d",strtotime("-30 day")))*1000)->where(['WAREHOUSEID'=>$WAREHOUSEID])->count();
$where = 'FLAG=1';
$ylj = $orderModel->where($where)->where($where2)->where('cast(CREATIONDATE as signed) >= '.strtotime(date("Y-m-d",strtotime("-30 day")))*1000)->where(['WAREHOUSEID'=>$WAREHOUSEID])->count();
$this->success('获取成功',['dfp'=>$dfp,'ddy'=>$ddy,'dll'=>$dll,'djh'=>$djh,'dfh'=>$dfh,'dcz'=>$dcz,'ddb'=>$ddb,'yjd'=>$yjd,'yfp'=>$yfp,'ydy'=>$ydy,'yll'=>$yll,'yjh'=>$yjh,'yfh'=>$yfh,'ydb'=>$ydb,'ycz'=>$ycz,'ylj'=>$ylj,'dls'=>$dls,'yls'=>$yls]);
} catch (Exception $e) {
$this->error($e);
}
}
public function query(){
$params=$this->request->post();
$WAREHOUSEID = $this->auth->warehouseid;
$orderModel = new \app\common\model\wms\Order;
$Model2 = new \app\common\model\wms\Order;
$query = $orderModel->where(["WAREHOUSEID"=>$WAREHOUSEID])->where($params['query']['wherest'])
->where('cast(CREATIONDATE as signed) >= '.strtotime(date("Y-m-d",strtotime("-30 day")))*1000);
if($params['query']['group']=='GRABNUM'){
$query->group('GRABNUM');
}
Db::startTrans();
try {
$count = $query->count();
$query = $orderModel->where(["WAREHOUSEID"=>$WAREHOUSEID])->where($params['query']['wherest'])
->where('cast(CREATIONDATE as signed) >= '.strtotime(date("Y-m-d",strtotime("-30 day")))*1000);
if($params['query']['group']=='GRABNUM'){
$query->group('GRABNUM');
}
$query->limit($params['query']['pagesize']*($params['query']['page']-1),$params['query']['pagesize']);
$list = $query->select();
foreach($list as $r){
$StoreModel = new \app\common\model\wms\Store;
$store = $StoreModel->where(['STOREID'=>$r['STOREID']])->find();
$r['huozhu'] = ($store['TITLE'] ?? null);
}
Db::commit();
} catch (ValidateException|PDOException|Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
$this->success('查询结果',["list"=>$list,"count"=>$count]);
}
public function stores(){
$WAREHOUSEID = $this->auth->warehouseid;
$StoreModel = new \app\common\model\wms\Warestore;
$list = $StoreModel->with(['employees'])->where(["WAREHOUSEID"=>$WAREHOUSEID])->select();
$this->success("查询结果",$list);
}
public function qrcode(){
$params=$this->request->post();
$type = isset($params['type'])?$params['type']:'';
$lastCode = isset($params['lastCode'])?$params['lastCode']:'';
if($type){
$uuid = Random('uuid');
$this->success('查询结果',["list"=>$list,"count"=>$count]);
}else{
$this->error('未设置类型');
}
}
}