一、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>
478 lines
20 KiB
PHP
478 lines
20 KiB
PHP
<?php
|
|
|
|
namespace app\api\controller;
|
|
|
|
use app\common\controller\Api;
|
|
use think\Config;
|
|
use think\Db;
|
|
use think\db\exception\BindParamException;
|
|
use think\db\exception\DataNotFoundException;
|
|
use think\db\exception\ModelNotFoundException;
|
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
|
use PhpOffice\PhpSpreadsheet\IOFactory;
|
|
use app\index\library\Wsdl;
|
|
/**
|
|
* 首页接口
|
|
*/
|
|
class Work extends Api
|
|
{
|
|
protected $noNeedLogin = '';
|
|
protected $noNeedRight = '*';
|
|
public function _initialize()
|
|
{
|
|
parent::_initialize();
|
|
|
|
$this->CkModel = new \app\common\model\wmsorder\Ck;
|
|
$this->PickingModel = new \app\common\model\wmsorder\Picking;
|
|
$this->UserModel = new \app\common\model\User;
|
|
$WarehouseModel = new \app\common\model\Warehouse;
|
|
$this->WAREHOUSEID = $this->auth->warehouseid;
|
|
$this->StockModel = new \app\common\model\wms\Stock;
|
|
$ware = $WarehouseModel->where(["WAREHOUSEID"=>$this->WAREHOUSEID])->find();
|
|
$this->room2id = ($ware["room2"] ?? null);
|
|
$this->operatorID = $ware["operatorID"];
|
|
$this->redis = new \Redis();
|
|
$this->redis->connect('127.0.0.1', 6379);
|
|
$this->redis->auth('qwe2019@');
|
|
$this->redis->select(2);
|
|
}
|
|
public function find_order(){
|
|
$params=$this->request->post();
|
|
$orderID = $params["orderID"];
|
|
$userid = $this->auth->id;
|
|
if($orderID=="lasted"){
|
|
$order = $this->CkModel->where(["OPERATEUSERID"=>$userid,"WAREHOUSEID"=>$this->WAREHOUSEID,"STATUS"=>2])->find();
|
|
}else{
|
|
$order = $this->CkModel->where(["ID"=>$orderID,"WAREHOUSEID"=>$this->WAREHOUSEID])->find();
|
|
}
|
|
if(!$order){
|
|
if($orderID=="lasted"){
|
|
$this->error("扫描发货单二维码开始配货");
|
|
}else{
|
|
$this->error("无记录");
|
|
}
|
|
}
|
|
$OPERATEUSER = "";
|
|
if($order->OPERATEUSERID){
|
|
$user = $this->UserModel->where(["ID"=>$order->OPERATEUSERID])->find();
|
|
if($user){
|
|
$OPERATEUSER = $user->real_name;
|
|
}
|
|
}
|
|
if($order->STATUS>2){
|
|
$this->error("订单由{$OPERATEUSER}配货完成,不可操作");
|
|
}
|
|
if($order->OPERATEUSERID){
|
|
if($order->OPERATEUSERID!=$userid){
|
|
$this->error("该出库单已由{$OPERATEUSER}配货,需要{$OPERATEUSER}解除配货后才能操作");
|
|
}
|
|
}
|
|
$order->OPERATEUSERID = $userid;
|
|
$order->STATUS = 2;
|
|
$order->PICKING_START_TIME = time();
|
|
$order->save();
|
|
$stockList = $this->PickingModel->where(["WMSORDERID"=>$order["ID"]])->order("IDX","ASE")->select();
|
|
foreach ($stockList as $k => $r){
|
|
$stockList[$k]["box_info"] = json_decode($r["box_info"]);
|
|
}
|
|
$order["stocks"] = $stockList;
|
|
|
|
$this->success("获取成功",$order);
|
|
}
|
|
public function update_picking(){
|
|
$userid = $this->auth->id;
|
|
$parmas = $this->request->post();
|
|
$orderID = $parmas["orderID"];
|
|
$order = $this->CkModel->where(["ID"=>$orderID,"WAREHOUSEID"=>$this->WAREHOUSEID,"OPERATEUSERID"=>$userid])->find();
|
|
if(!$order){
|
|
$this->error("上传拣货信息失败");
|
|
}
|
|
$box_info = $parmas["box_info"];
|
|
$stockList = $parmas["stockList"];
|
|
foreach ($stockList as $k => $r){
|
|
$stock = $this->PickingModel->where(["STOCKID"=>$r["STOCKID"],"WMSORDERID"=>$orderID])->find();
|
|
$stock->remask = $r["remask"];
|
|
$stock->is_lock = isset($r["isLock"])?$r["isLock"]:1;
|
|
$stock->box_info = json_encode($box_info[$k]);
|
|
$stock->save();
|
|
}
|
|
return "1";
|
|
}
|
|
public function unbind_order(){
|
|
$userid = $this->auth->id;
|
|
$parmas = $this->request->post();
|
|
$orderID = $parmas["orderID"];
|
|
$order = $this->CkModel->where(["ID"=>$orderID,"WAREHOUSEID"=>$this->WAREHOUSEID,"OPERATEUSERID"=>$userid])->find();
|
|
if(!$order){
|
|
$this->error("解除失败");
|
|
}
|
|
$order->OPERATEUSERID = "";
|
|
$order->STATUS = 1;
|
|
$order->save();
|
|
$this->success("解除成功");
|
|
}
|
|
public function order_fin(){
|
|
$userid = $this->auth->id;
|
|
$parmas = $this->request->post();
|
|
$orderID = $parmas["orderID"];
|
|
$type = $parmas["type"];
|
|
$imgs = isset($parmas["imgs"])?explode(",",$parmas["imgs"]):[];
|
|
$remask = isset($parmas["remask"])?$parmas["remask"]:"";
|
|
$OrderModel = new \app\common\model\wms\Order;
|
|
|
|
$order = $OrderModel->where(["ID"=>$orderID])->find();
|
|
if($order && ($order["PLSENDFLAG"] ?? null)==0){
|
|
$modelUser = new \app\common\model\wms\User;
|
|
$user = $modelUser->where(["userID"=>$this->operatorID])->find();
|
|
$username = $user?$user->username:"";
|
|
$res = Wsdl::webservice([$order->WAREHOUSEID,$order->POSTNUM,$username,""],"sendWmsOrder");
|
|
|
|
}
|
|
switch ($type) {
|
|
case 'picked':
|
|
$order = $this->CkModel->where(["ID"=>$orderID,"WAREHOUSEID"=>$this->WAREHOUSEID,"OPERATEUSERID"=>$userid])->find();
|
|
if(!$order){
|
|
$this->error("配货失败");
|
|
}
|
|
$boxcount = isset($parmas["boxcount"])?$parmas["boxcount"]:0;
|
|
$order->IMGS = implode(",",$imgs);
|
|
$order->REMASK = $remask;
|
|
$order->STATUS = 3;
|
|
$order->boxcount = $boxcount;
|
|
$order->PICKING_TIME = time();
|
|
$order->save();
|
|
$this->notic_store_picked($order);
|
|
$this->success("配货成功");
|
|
break;
|
|
case 'send':
|
|
$order = $this->CkModel->where(["ID"=>$orderID,"WAREHOUSEID"=>$this->WAREHOUSEID])->find();
|
|
if(!$order){
|
|
$this->error("发货失败");
|
|
}
|
|
$tmp_imgs = explode(",",$order->IMGS);
|
|
$order->IMGS = implode(",",array_merge($tmp_imgs,$imgs));
|
|
$order->STATUS = 4;
|
|
$order->SEND_TIME = time();
|
|
$order->CKOPERATEUSERID = $userid;
|
|
$order->save();
|
|
$this->notic_store_sended($order,$imgs);
|
|
$this->success("提货成功");
|
|
break;
|
|
}
|
|
}
|
|
public function waiting_out_order(){
|
|
$userid = $this->auth->id;
|
|
$parmas = $this->request->post();
|
|
$keyword = isset($parmas["keyword"])?$parmas["keyword"]:null;
|
|
$model = $this->CkModel->where(["WAREHOUSEID"=>$this->WAREHOUSEID,"STATUS"=>3]);
|
|
if($keyword){
|
|
$model->where("NAME like '%{$keyword}%' or SOURCEID like '%{$keyword}%' or ID = '{$keyword}' or CARCODE like '%{$keyword}%'");
|
|
}
|
|
$orders = $model->select();
|
|
foreach($orders as $r){
|
|
$r["IMGS"] = explode(",",$r["IMGS"]);
|
|
}
|
|
$this->success("成功",$orders);
|
|
}
|
|
|
|
public function ck_orders(){
|
|
$userid = $this->auth->id;
|
|
$parmas = $this->request->post();
|
|
$keyword = isset($parmas["keyword"])?$parmas["keyword"]:null;
|
|
$where = [];
|
|
if(!$keyword){
|
|
$where = isset($parmas["where"])?$parmas["where"]:[];
|
|
}
|
|
$model = $this->CkModel->field("ID,SOURCEID,NAME,STATUS")->where(["WAREHOUSEID"=>$this->WAREHOUSEID]);
|
|
if($keyword){
|
|
$model->where("NAME like '%{$keyword}%' or SOURCEID like '%{$keyword}%' or ID = '{$keyword}' or CARCODE like '%{$keyword}%' or REMASK like '%{keyword}%'");
|
|
}
|
|
if($where){
|
|
foreach ($where as $k =>$r){
|
|
switch($k){
|
|
case "selectTime":
|
|
$startTime= strtotime($r[0])*1000;
|
|
$endTime = strtotime($r[1])*1000+24*60*60*1000-1;
|
|
$model->where("CREATIONDATE","BETWEEN",[$startTime,$endTime]);
|
|
break;
|
|
case "boxCount":
|
|
if($r){
|
|
$model->where(["boxcount"=>$r]);
|
|
}
|
|
break;
|
|
case "storeid":
|
|
if($r){
|
|
$model->where(["STOREID"=>$r]);
|
|
}
|
|
break;
|
|
case "remask":
|
|
if($r){
|
|
$model->where("REMASK","like","%{$r}%");
|
|
}
|
|
case "STATUS":
|
|
if($r){
|
|
$model->where("STATUS","=","{$r}");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
$page = isset($params["page"])?$params["page"]:1;
|
|
$pagesize = 20;
|
|
$offset = $pagesize*($page-1);
|
|
|
|
$list = $model->paginate($pagesize);
|
|
$orders = $list->items();
|
|
$result = ['rows' => $orders, 'total' => $list->total()];
|
|
$this->success("成功",$result);
|
|
}
|
|
public function get_ckd_order(){
|
|
$userid = $this->auth->id;
|
|
$parmas = $this->request->post();
|
|
$ID = $parmas["orderID"];
|
|
$ORDER = $this->CkModel->alias("order")->field('order.*,user1.real_name as OPERATEUSER,user2.real_name as CKOPERATEUSER')->where(["order.ID"=>$ID])->join("ye4s_user user1","user1.id=order.OPERATEUSERID","left")->join("ye4s_user user2","user2.id=order.CKOPERATEUSERID","left")->find();
|
|
$newOrder_list = [];
|
|
|
|
if($ORDER){
|
|
$order_items = $this->PickingModel->where("WMSORDERID","in",$ORDER["ID"])->select();
|
|
foreach ($order_items as $r){
|
|
if(!array_key_exists($r["WMSORDERID"],$newOrder_list)){
|
|
$newOrder_list[$r["WMSORDERID"]] = [$r];
|
|
}else{
|
|
array_push($newOrder_list[$r["WMSORDERID"]],$r);
|
|
}
|
|
}
|
|
$temp_items = [];
|
|
$goods_count = 0;
|
|
$sku_count = 0;
|
|
foreach ($newOrder_list[$ORDER["ID"]] as $rr){
|
|
array_push($temp_items,"{$rr['NAME']}({$rr['COUNT']})");
|
|
$goods_count+=intval($rr["COUNT"]);
|
|
$sku_count++;
|
|
}
|
|
$items = implode(" ",$temp_items);
|
|
$ORDER["items"] = $items;
|
|
$ORDER["goods_count"] = $goods_count;
|
|
$ORDER["sku_count"] = $sku_count;
|
|
$ORDER['IMGS'] = explode(",",$ORDER['IMGS']);
|
|
$this->success("获取成功",$ORDER);
|
|
}else{
|
|
$this->error("没有找到订单");
|
|
}
|
|
}
|
|
public function ckd_explode_file(){
|
|
|
|
$userid = $this->auth->id;
|
|
$parmas = $this->request->post();
|
|
$keyword = isset($parmas["keyword"])?$parmas["keyword"]:null;
|
|
$where = [];
|
|
if(!$keyword){
|
|
$where = isset($parmas["where"])?$parmas["where"]:[];
|
|
}
|
|
$model = $this->CkModel->where(["WAREHOUSEID"=>$this->WAREHOUSEID]);
|
|
if($keyword){
|
|
$model->where("NAME like '%{$keyword}%' or SOURCEID like '%{$keyword}%' or ID = '{$keyword}' or CARCODE like '%{$keyword}%' or REMASK like '%{keyword}%'");
|
|
}
|
|
if($where){
|
|
foreach ($where as $k =>$r){
|
|
switch($k){
|
|
case "selectTime":
|
|
$startTime= strtotime($r[0])*1000;
|
|
$endTime = strtotime($r[1])*1000+24*60*60*1000-1;
|
|
$model->where("CREATIONDATE","BETWEEN",[$startTime,$endTime]);
|
|
break;
|
|
case "boxCount":
|
|
if($r){
|
|
$model->where(["boxcount"=>$r]);
|
|
}
|
|
break;
|
|
case "storeid":
|
|
if($r){
|
|
$model->where(["STOREID"=>$r]);
|
|
}
|
|
break;
|
|
case "remask":
|
|
if($r){
|
|
$model->where("REMASK","like","%{$r}%");
|
|
}
|
|
case "STATUS":
|
|
if($r){
|
|
$model->where("STATUS","=","{$r}");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
$orders = $model->select();
|
|
$IDS = [];
|
|
foreach ($orders as $r){
|
|
array_push($IDS,$r["ID"]);
|
|
}
|
|
$order_items = $this->PickingModel->where("WMSORDERID","in",$IDS)->select();
|
|
$newOrder_list = [];
|
|
foreach ($order_items as $r){
|
|
if(!array_key_exists($r["WMSORDERID"],$newOrder_list)){
|
|
$newOrder_list[$r["WMSORDERID"]] = [$r];
|
|
}else{
|
|
array_push($newOrder_list[$r["WMSORDERID"]],$r);
|
|
}
|
|
}
|
|
foreach ($orders as $r){
|
|
$items = $newOrder_list[$r["ID"]];
|
|
$temp_items = [];
|
|
$goods_count = 0;
|
|
$sku_count = 0;
|
|
foreach ($newOrder_list[$r["ID"]] as $rr){
|
|
array_push($temp_items,"{$rr['NAME']}({$rr['COUNT']})");
|
|
$goods_count+=intval($rr["COUNT"]);
|
|
$sku_count++;
|
|
}
|
|
$items = implode(" ",$temp_items);
|
|
$r["items"] = $items;
|
|
$r["goods_count"] = $goods_count;
|
|
$r["sku_count"] = $sku_count;
|
|
}
|
|
$spreadsheet = new Spreadsheet();
|
|
$worksheet = $spreadsheet->getActiveSheet();
|
|
$title = 'Sheet1';
|
|
$worksheet->setTitle($title);
|
|
$worksheet->fromArray(
|
|
[
|
|
['外部订单编号','收件人(客户)','省份','辅助列','快递','物流单号','日期','平台单号','自定义店铺','商品明细','SKU','数量','箱数','重量','备货服务费','备注','自定义货主']
|
|
], '', 'A4' );
|
|
$workers = [];
|
|
$worksheet->fromArray(
|
|
[
|
|
['单量']
|
|
], '', 'E2' );
|
|
$worksheet->fromArray(
|
|
[
|
|
['合计运费',''],
|
|
['自提出库费','']
|
|
], '', 'N1' );
|
|
foreach ($orders as $r){
|
|
array_push($workers,[$r['SOURCEID'],$r['NAME'],$r['PROVINCE'],'',$r['POSTNAME'],$r['POSTNUM'],date('Y-m-d', $r['CREATIONDATE']/1000),$r['SOURCEORDERCODE'],$r['STORE_NAME'],$r['items'],$r['sku_count'],$r['goods_count'],$r['boxcount'],'','',$r["REMASK"],$r['STORENAME']]);
|
|
}
|
|
$worksheet->fromArray($workers, '', 'A5' );
|
|
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
|
header('Content-Disposition: attachment;filename=Excel导出.xlsx');
|
|
header('Cache-Control: max-age=0');
|
|
|
|
$write = IOFactory::createWriter($spreadsheet, 'Xlsx');
|
|
$write->save('php://output');
|
|
}
|
|
private function notic_store_picked($order){
|
|
if($order["POSTCODE"]=="p25"){
|
|
return false;
|
|
}
|
|
$orderinfo = "";
|
|
$stockList = $this->PickingModel->where(["WMSORDERID"=>$order["ID"]])->order("IDX","ASE")->select();
|
|
foreach ($stockList as $r){
|
|
$orderinfo .= $r["NAME"].$r["BARCODE"]."数量:".$r["COUNT"]."\n";
|
|
$box_info =json_decode($r["box_info"],true);
|
|
$box_list = [];
|
|
foreach ($box_info as $box){
|
|
array_push($box_list," 箱号:{$box['name']},数量:{$box['count']}X{$box['boxCount']}");
|
|
}
|
|
$orderinfo .= implode("\n",$box_list);
|
|
if($r['remask']){
|
|
$orderinfo .= "\n 备注:{$r['remask']}";
|
|
}
|
|
$orderinfo .= "\n";
|
|
}
|
|
//通知客户配货成功,下单绑定车辆
|
|
$RoomsModel = new \app\common\model\Rooms;
|
|
//$room = $RoomsModel->where(["STOREID"=>$order["STOREID"],"ck"=>1])->find();
|
|
$room_id = "48520911980@chatroom";
|
|
/*if($room){
|
|
$room_id = $room["room_id"];
|
|
}else{
|
|
$room = $RoomsModel->where(["STOREID"=>$order["STOREID"]])->find();
|
|
if($room){
|
|
$room_id = $room["room_id"];
|
|
}
|
|
}*/
|
|
$newcode = mb_substr($order['SOURCEID'], -7);
|
|
$beihuoHour = (time() - ($order['CREATIONDATE']/1000))/3600;
|
|
$beihuoHour = round($beihuoHour, 2);
|
|
if($room_id){
|
|
$msg = $this->toMsg($room_id,"{$newcode}\n{$order['NAME']}\n配货完成\n出库货主名称:{$order['STORENAME']}\n总箱数:{$order['boxcount']}\n备货时长:{$beihuoHour}\n仓库备注:{$order['REMASK']}\n备货负责联系人:{$this->auth->real_name} {$this->auth->mobile}\n发送:{$newcode}提货+车牌号,绑定提货车辆,方便仓库装车");
|
|
$this->redis->select(2);
|
|
$this->redis->lpush("Message",json_encode($msg));
|
|
$IMGS = explode(",",$order["IMGS"]);
|
|
foreach ($IMGS as $r){
|
|
$msg = $this->toMsgImg($room_id,$r);
|
|
$this->redis->lpush("Message",json_encode($msg));
|
|
}
|
|
}else{
|
|
//无绑定群,通知到配货群
|
|
if($this->room2){
|
|
$msg = $this->toMsg($this->room2,"{$newcode}\n{$order['NAME']}\n配货完成\n出库货主名称:{$order['STORENAME']}\n总箱数:{$order['boxcount']}\n备货时长:{$beihuoHour}\n仓库备注:{$order['REMASK']}\n备货负责联系人:{$this->auth->real_name} {$this->auth->mobile}\n发送:{$newcode}提货+车牌号,绑定提货车辆,方便仓库装车\n货主未绑定群,请人工通知");
|
|
$this->redis->select(2);
|
|
$this->redis->lpush("Message",json_encode($msg));
|
|
$IMGS = explode(",",$order["IMGS"]);
|
|
foreach ($IMGS as $r){
|
|
$msg = $this->toMsgImg($this->room2,$r);
|
|
$this->redis->lpush("Message",json_encode($msg));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
private function notic_store_sended($order,$imgs){
|
|
//通知客户提货成功
|
|
$RoomsModel = new \app\common\model\Rooms;
|
|
$room = $RoomsModel->where(["STOREID"=>$order["STOREID"],"ck"=>1])->find();
|
|
$room_id = "48520911980@chatroom";
|
|
/*if($room){
|
|
$room_id = $room["room_id"];
|
|
}else{
|
|
$room = $RoomsModel->where(["STOREID"=>$order["STOREID"]])->find();
|
|
if($room){
|
|
$room_id = $room["room_id"];
|
|
}
|
|
}*/
|
|
$newcode = mb_substr($order['SOURCEID'], -7);
|
|
if($room_id){
|
|
$msg = $this->toMsg($room_id,"{$newcode}\n{$order['NAME']}\n提货完成");
|
|
$this->redis->select(2);
|
|
$this->redis->lpush("Message",json_encode($msg));
|
|
foreach ($imgs as $r){
|
|
$msg = $this->toMsgImg($room_id,$r);
|
|
$this->redis->lpush("Message",json_encode($msg));
|
|
}
|
|
}else{
|
|
//无绑定群,通知到配货群
|
|
if($this->room2){
|
|
$msg = $this->toMsg($this->room2,"{$newcode}\n{$order['NAME']}\n提货完成\n货主未绑定群,请人工通知");
|
|
$this->redis->select(2);
|
|
$this->redis->lpush("Message",json_encode($msg));
|
|
}
|
|
foreach ($imgs as $r){
|
|
$msg = $this->toMsgImg($this->room2,$r);
|
|
$this->redis->lpush("Message",json_encode($msg));
|
|
}
|
|
}
|
|
}
|
|
private function toMsg($to,$text,$atid=""){
|
|
return [
|
|
"method"=>"sendText",
|
|
"wxid"=> $to,
|
|
"msg"=> $text,
|
|
"atid"=> $atid,
|
|
"pid"=> 0
|
|
];
|
|
}
|
|
private function toMsgImg($to,$url){
|
|
return [
|
|
"method"=>"sendImage",
|
|
"wxid"=> $to,
|
|
"img"=> $url,
|
|
"imgType"=> "url",
|
|
"pid"=> 0
|
|
];
|
|
}
|
|
public function get_stock_by_barcode(){
|
|
$parmas = $this->request->post();
|
|
$barcode = $parmas["BARCODE"];
|
|
$stocks = $this->StockModel->field("STOCKID")->where(["WAREHOUSEID"=>$this->WAREHOUSEID])->where("BARCODE","like","%{$barcode}%")->select();
|
|
return json($stocks);
|
|
}
|
|
} |