liufumingren e8605149c0 初始化
2026-08-06 17:04:35 +08:00

109 lines
4.4 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;
/**
* 首页接口
*/
class Warehouse extends Api
{
protected $noNeedLogin = [];
protected $noNeedRight = [];
public function index(){
$WAREHOUSEID = $this->auth->warehouseid;
$page = $this->request->get('page')?$this->request->get('page'):1;
$type = $this->request->get('type')?$this->request->get('type'):1;
$Warehouseerrmodel = new \app\common\model\Warehouseerr;
$list = $Warehouseerrmodel->where(["status"=>0,"type"=>$type,"wareHouseId"=>$WAREHOUSEID])->limit(($page-1)*20,20)->select();
$count = $Warehouseerrmodel->where(["status"=>0,"type"=>$type,"wareHouseId"=>$WAREHOUSEID])->count();
$this->success("获取成功",["list"=>$list,"count"=>$count]);
}
public function item(){
$WAREHOUSEID = $this->auth->warehouseid;
$id = $this->request->get('id')?$this->request->get('id'):0;
$Warehouseerrmodel = new \app\common\model\Warehouseerr;
$item = $Warehouseerrmodel->where(["status"=>0,"wareHouseId"=>$WAREHOUSEID,"id"=>$id])->find();
if($item){
$this->success("获取成功",$item);
}else{
$this->error("工单已处理或者不存在");
}
}
public function post(){
$WAREHOUSEID = $this->auth->warehouseid;
$userid = $this->auth->id;
$params=$this->request->post();
$id = $params['id']?$params['id']:0;
$Warehouseerrmodel = new \app\common\model\Warehouseerr;
$item = $Warehouseerrmodel->where(["status"=>0,"wareHouseId"=>$WAREHOUSEID,"id"=>$id])->find();
if($item){
$item->save(["status"=>1,"performer"=>$userid]);
$this->success("处理完成");
}else{
$this->error("工单已处理或者不存在");
}
}
public function getapplyinfos(){
$params=$this->request->post();
$WAREHOUSEID = $this->auth->warehouseid;
$sn = isset($params['sn'])?$params['sn']:0;
$StorageModel = new \app\common\model\wms\Storage;
$WarehouseModel = new \app\common\model\Warehouse;
$WAREHOUSEconfig = $WarehouseModel->where(['WAREHOUSEID'=>$WAREHOUSEID])->find();
$list = $StorageModel->with(['employees','goods'])
->where(['storage.WAREHOUSEID'=>$WAREHOUSEID,'storage.APPLYSTORAGENUM'=>$sn,'storage.SPACEID'=>$WAREHOUSEconfig['SPACEID']])
->select();
$this->success("入库单详情",$list);
}
public function markapply(){
$params=$this->request->post();
$WAREHOUSEID = $this->auth->warehouseid;
$sn = isset($params['sn'])?$params['sn']:0;
$StorageModel = new \app\common\model\wms\Storage;
$WarehouseModel = new \app\common\model\Warehouse;
$WAREHOUSEconfig = $WarehouseModel->where(['WAREHOUSEID'=>$WAREHOUSEID])->find();
$list = $StorageModel->where(['WAREHOUSEID'=>$WAREHOUSEID,'APPLYSTORAGENUM'=>$sn,'SPACEID'=>$WAREHOUSEconfig['SPACEID']])
->select();
foreach($list as $r){
$WarehouseModel = new \app\common\model\Storage;
$detail = [
'WAREHOUSEID'=>$r['WAREHOUSEID'],
'APPLYSTORAGENUM'=>$r['APPLYSTORAGENUM']
];
$details = $WarehouseModel->where($detail)->find();
if(!$details){
$WarehouseModel->save($detail);
}
}
$this->success("标记成功");
}
public function stockaking_trace_list(){
$WAREHOUSEID = $this->auth->warehouseid;
$ListsModel = new \app\common\model\stockaking\Lists;
$list = $ListsModel->where(["WAREHOUSEID"=>$WAREHOUSEID])->order('id','desc')->select();
$this->success('获取成功',$list);
}
public function create_stockaking(){
$WAREHOUSEID = $this->auth->warehouseid;
$params=$this->request->post();
$title = $params['title'];
$title = $params['type'];
$userid = $this->auth->id;
$ListsModel = new \app\common\model\stockaking\Lists;
$insert = [
"createdtime"=>time(),
"WAREHOUSEID"=>$WAREHOUSEID,
"status"=>0,
"STOREID"=>0,
"title"=>$title
];
}
}