|
@@ -159,295 +159,270 @@ public function __construct(App $app)
|
|
|
|
|
|
return app_show(0, "获取成功", ["list" => $data, "count" => $count]);
|
|
|
}
|
|
|
-public function list()
|
|
|
-{
|
|
|
- $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) : "1";
|
|
|
- $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) : "10";
|
|
|
- $where = [['a.is_del',"=",0],['b.is_del',"=",0]];
|
|
|
- $start= isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start']:"";
|
|
|
- if ($start !="") {
|
|
|
- // $where["a.addtime"]=Db::raw(">= '{$start}'");
|
|
|
- $where[]=['a.addtime',">=",$start];
|
|
|
- }
|
|
|
- $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] :"";
|
|
|
- if($end !=""){
|
|
|
- // $where["a.addtime"] = Db::raw("<= '{$end}'");
|
|
|
- $where[]=['a.addtime',"<=",$end];
|
|
|
- }
|
|
|
- $check_code = isset($this->post['check_code']) && $this->post['check_code'] !== "" ? trim($this->post['check_code']) : "";
|
|
|
- if ($check_code !== "") {
|
|
|
- // $where['a.check_code'] = Db::raw("like '%$check_code%'");
|
|
|
- $where[]=['a.check_code',"like","%$check_code%"];
|
|
|
- }
|
|
|
- $wsm_code = isset($this->post['wsm_code']) && $this->post['wsm_code'] !== "" ? trim($this->post['wsm_code']) : "";
|
|
|
- if ($wsm_code !== "") {
|
|
|
- // $where['a.wsm_code'] = Db::raw("like '%$wsm_code%'");
|
|
|
- $where[]=['a.wsm_code',"like","%$wsm_code%"];
|
|
|
- }
|
|
|
- $apply_name = isset($this->post['apply_name']) && $this->post['apply_name'] !== "" ? trim($this->post['apply_name']) : "";
|
|
|
- if ($apply_name !== "") {
|
|
|
- // $where['a.apply_name'] = $apply_name;
|
|
|
- $where[]=['a.apply_name',"like","%$apply_name%"];
|
|
|
- }
|
|
|
- $type = isset($this->post['type']) && $this->post['type'] !== "" ? trim($this->post['type']) : "";
|
|
|
- if ($type !== "") {
|
|
|
- // $where['a.type'] = $type;
|
|
|
- $where[]=['a.type',"=",$type];
|
|
|
- }
|
|
|
- $apply_id = isset($this->post['apply_id']) && $this->post['apply_id'] !== "" ? intval($this->post['apply_id']) : "";
|
|
|
- if ($apply_id!== "") {
|
|
|
- // $where['a.apply_id'] = $apply_id;
|
|
|
- $where[]=['a.apply_id',"=",$apply_id];
|
|
|
- }
|
|
|
- $status= isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "";
|
|
|
- if ($status !== "") {
|
|
|
- // $where['a.status '] = $status;
|
|
|
- $where[]=['a.status',"=",$status];
|
|
|
- }
|
|
|
- $companyNo = isset($this->post['companyNo']) && $this->post['companyNo'] !== "" ? trim($this->post['companyNo']) : "";
|
|
|
- if ($companyNo !== "") {
|
|
|
- $condition[]=["a.companyNo ","=",$companyNo ];
|
|
|
- }
|
|
|
- $count = Db::name('good_check')->alias('a')->join("warehouse_info b","a.wsm_code = b.wsm_code","left")
|
|
|
- ->join("supplier v","v.code=b.supplierNo","left")
|
|
|
- ->where($where)->count();
|
|
|
- $total = ceil($count / $size);
|
|
|
- $page = $page <= $total ? $page : $total;
|
|
|
- $list = Db::name('good_check')->alias('a')->join("warehouse_info b","a.wsm_code = b.wsm_code","left")
|
|
|
- ->join("supplier v","v.code=b.supplierNo","left")
|
|
|
- ->field("a.status,a.apply_id,a.apply_name,a.type,a.addtime,a.wsm_code,a.check_code,b.name,a.id,v.name as 'caname',v.code")->where($where)->page($page,$size)->order("a.id desc")->select();
|
|
|
- $data=[];
|
|
|
- foreach ($list as $key=>$value){
|
|
|
- $value['rename'] ='';
|
|
|
- if($value['apply_id']!=0){
|
|
|
- $depart = Db::name("depart_user")->alias("a")->leftJoin("company_item b","a.itemid = b.id")->where(['a.uid'=>$value['apply_id'],'a.is_del'=>0])
|
|
|
- ->column('b.name');
|
|
|
- // var_dump(Db::name("depart_user")->getLastSql());
|
|
|
- $value['rename'] =implode(",",$depart);
|
|
|
- }
|
|
|
- $data[] = $value;
|
|
|
- }
|
|
|
- return app_show(0,"获取成功",['count'=>$count,'list'=>$data]);
|
|
|
+ public function list()
|
|
|
+ {
|
|
|
+ $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) : "1";
|
|
|
+ $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) : "10";
|
|
|
+ $where = [['a.is_del',"=",0],['b.is_del',"=",0]];
|
|
|
+ $start= isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start']:"";
|
|
|
+ if ($start !="") {
|
|
|
+ // $where["a.addtime"]=Db::raw(">= '{$start}'");
|
|
|
+ $where[]=['a.addtime',">=",$start];
|
|
|
+ }
|
|
|
+ $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] :"";
|
|
|
+ if($end !=""){
|
|
|
+ // $where["a.addtime"] = Db::raw("<= '{$end}'");
|
|
|
+ $where[]=['a.addtime',"<=",$end];
|
|
|
+ }
|
|
|
+ $check_code = isset($this->post['check_code']) && $this->post['check_code'] !== "" ? trim($this->post['check_code']) : "";
|
|
|
+ if ($check_code !== "") {
|
|
|
+ // $where['a.check_code'] = Db::raw("like '%$check_code%'");
|
|
|
+ $where[]=['a.check_code',"like","%$check_code%"];
|
|
|
+ }
|
|
|
+ $wsm_code = isset($this->post['wsm_code']) && $this->post['wsm_code'] !== "" ? trim($this->post['wsm_code']) : "";
|
|
|
+ if ($wsm_code !== "") {
|
|
|
+ // $where['a.wsm_code'] = Db::raw("like '%$wsm_code%'");
|
|
|
+ $where[]=['a.wsm_code',"like","%$wsm_code%"];
|
|
|
+ }
|
|
|
+ $apply_name = isset($this->post['apply_name']) && $this->post['apply_name'] !== "" ? trim($this->post['apply_name']) : "";
|
|
|
+ if ($apply_name !== "") {
|
|
|
+ // $where['a.apply_name'] = $apply_name;
|
|
|
+ $where[]=['a.apply_name',"like","%$apply_name%"];
|
|
|
+ }
|
|
|
+ $type = isset($this->post['type']) && $this->post['type'] !== "" ? trim($this->post['type']) : "";
|
|
|
+ if ($type !== "") {
|
|
|
+ // $where['a.type'] = $type;
|
|
|
+ $where[]=['a.type',"=",$type];
|
|
|
+ }
|
|
|
+ $apply_id = isset($this->post['apply_id']) && $this->post['apply_id'] !== "" ? intval($this->post['apply_id']) : "";
|
|
|
+ if ($apply_id!== "") {
|
|
|
+ // $where['a.apply_id'] = $apply_id;
|
|
|
+ $where[]=['a.apply_id',"=",$apply_id];
|
|
|
+ }
|
|
|
+ $status= isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "";
|
|
|
+ if ($status !== "") {
|
|
|
+ // $where['a.status '] = $status;
|
|
|
+ $where[]=['a.status',"=",$status];
|
|
|
+ }
|
|
|
+ $companyNo = isset($this->post['companyNo']) && $this->post['companyNo'] !== "" ? trim($this->post['companyNo']) : "";
|
|
|
+ if ($companyNo !== "") {
|
|
|
+ $condition[]=["a.companyNo ","=",$companyNo ];
|
|
|
+ }
|
|
|
+ $count = Db::name('good_check')->alias('a')->join("warehouse_info b","a.wsm_code = b.wsm_code","left")
|
|
|
+ ->join("supplier v","v.code=b.supplierNo","left")
|
|
|
+ ->where($where)->count();
|
|
|
+ $total = ceil($count / $size);
|
|
|
+ $page = $page <= $total ? $page : $total;
|
|
|
+ $list = Db::name('good_check')->alias('a')->join("warehouse_info b","a.wsm_code = b.wsm_code","left")
|
|
|
+ ->join("supplier v","v.code=b.supplierNo","left")
|
|
|
+ ->field("a.status,a.apply_id,a.apply_name,a.type,a.addtime,a.wsm_code,a.check_code,b.name,a.id,v.name as 'caname',v.code")->where($where)->page($page,$size)->order("a.id desc")->select();
|
|
|
+ $data=[];
|
|
|
+ foreach ($list as $key=>$value){
|
|
|
+ $value['rename'] ='';
|
|
|
+ if($value['apply_id']!=0){
|
|
|
+ $depart = Db::name("depart_user")->alias("a")->leftJoin("company_item b","a.itemid = b.id")->where(['a.uid'=>$value['apply_id'],'a.is_del'=>0])
|
|
|
+ ->column('b.name');
|
|
|
+ // var_dump(Db::name("depart_user")->getLastSql());
|
|
|
+ $value['rename'] =implode(",",$depart);
|
|
|
+ }
|
|
|
+ $data[] = $value;
|
|
|
+ }
|
|
|
+ return app_show(0,"获取成功",['count'=>$count,'list'=>$data]);
|
|
|
|
|
|
- }
|
|
|
-public function goodlist(){
|
|
|
- $page = isset($this->post['page']) && $this->post['page'] !=="" ? intval($this->post['page']) :"1";
|
|
|
- $size = isset($this->post['size']) && $this->post['size'] !=="" ? intval($this->post['size']) :"10";
|
|
|
- $where = ['is_del'=>0];
|
|
|
- $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) :"";
|
|
|
- if($id==""){
|
|
|
- return error_show(1002,"参数id不能为空");
|
|
|
- }
|
|
|
- $fo = Db::name('good_check')->alias('a')->join('warehouse_info b',"b.wsm_code=a.wsm_code","left")
|
|
|
- ->join('supplier c',"c.code=b.supplierNo","left")->field("c.name,c.code,a.*")
|
|
|
- ->where(['a.id'=>$id,'a.is_del'=>0])->find();
|
|
|
- if(empty($fo)){
|
|
|
- return error_show(1003,"未找到盘点信息");
|
|
|
- }
|
|
|
- if ($fo['check_code'] !== "") {
|
|
|
- $where['check_code'] = $fo['check_code'];
|
|
|
- }
|
|
|
- $count = Db::name('check_item')->where($where)->count();
|
|
|
- $total = ceil($count / $size);
|
|
|
- $page = $page >= $total ? $total: $page;
|
|
|
- $list = Db::name('check_item')->where($where)->page($page,$size)->select();
|
|
|
- return app_show(0,"获取成功",['count'=>$count,'list'=>$list]);
|
|
|
-}
|
|
|
-public function create(){
|
|
|
- $token =isset($this->post['token']) && $this->post['token'] !=="" ? trim($this->post['token']) :"";
|
|
|
+ }
|
|
|
+ public function goodlist(){
|
|
|
+ $page = isset($this->post['page']) && $this->post['page'] !=="" ? intval($this->post['page']) :"1";
|
|
|
+ $size = isset($this->post['size']) && $this->post['size'] !=="" ? intval($this->post['size']) :"10";
|
|
|
+ $where = ['is_del'=>0];
|
|
|
+ $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) :"";
|
|
|
+ if($id==""){
|
|
|
+ return error_show(1002,"参数id不能为空");
|
|
|
+ }
|
|
|
+ $fo = Db::name('good_check')->alias('a')->join('warehouse_info b',"b.wsm_code=a.wsm_code","left")
|
|
|
+ ->join('supplier c',"c.code=b.supplierNo","left")->field("c.name,c.code,a.*")
|
|
|
+ ->where(['a.id'=>$id,'a.is_del'=>0])->find();
|
|
|
+ if(empty($fo)){
|
|
|
+ return error_show(1003,"未找到盘点信息");
|
|
|
+ }
|
|
|
+ if ($fo['check_code'] !== "") {
|
|
|
+ $where['check_code'] = $fo['check_code'];
|
|
|
+ }
|
|
|
+ $count = Db::name('check_item')->where($where)->count();
|
|
|
+ $total = ceil($count / $size);
|
|
|
+ $page = $page >= $total ? $total: $page;
|
|
|
+ $list = Db::name('check_item')->where($where)->page($page,$size)->select();
|
|
|
+ return app_show(0,"获取成功",['count'=>$count,'list'=>$list]);
|
|
|
+ }
|
|
|
+ public function create(){
|
|
|
+ $token =isset($this->post['token']) && $this->post['token'] !=="" ? trim($this->post['token']) :"";
|
|
|
|
|
|
- $wsm_code = isset($this->post['wsm_code']) && $this->post['wsm_code'] !=="" ? trim($this->post['wsm_code']):"";
|
|
|
- if($wsm_code==""){
|
|
|
- return error_show(1002,"盘点仓库编号不能为空");
|
|
|
- }
|
|
|
- $type = isset($this->post['type']) && $this->post['type'] !=="" ? intval($this->post['type']) :"";
|
|
|
- if($type==""){
|
|
|
- return error_show(1002,"盘点类型不能为空");
|
|
|
- }
|
|
|
- $companyNo = isset($this->post['companyNo']) && $this->post['companyNo'] !=="" ? trim($this->post['companyNo']) :"";
|
|
|
- if($companyNo==""){
|
|
|
- return error_show(1002,"参数companyNo不能为空");
|
|
|
- }
|
|
|
- $company =Db::name("business")->where(['companyNo'=>$companyNo,"is_del"=>0])->find();
|
|
|
- if($company==false){
|
|
|
- return error_show(1002,"未找到业务公司");
|
|
|
- }
|
|
|
- $check_code = makeNo("CK");
|
|
|
- $apply_id=GetUserInfo($token);
|
|
|
- if(empty($apply_id)||$apply_id['code']!=0){
|
|
|
- return error_show(1002,"申请人数据不存在");
|
|
|
- }
|
|
|
- $rm= isset($apply_id["data"]['id']) ? $apply_id["data"]['id'] : "";
|
|
|
- $ri= isset($apply_id["data"]['nickname']) ? $apply_id["data"]['nickname'] : "";
|
|
|
- $status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status']) :"0";
|
|
|
- $remark = isset($this->post['remark']) && $this->post['remark'] !=="" ? intval($this->post['remark']) :"";
|
|
|
- Db::startTrans();
|
|
|
- try{
|
|
|
- $data=[
|
|
|
- "check_code"=>$check_code,
|
|
|
- "wsm_code"=>$wsm_code,
|
|
|
- "type"=>$type,
|
|
|
- "status"=>$status,
|
|
|
- "companyNo"=>$companyNo,
|
|
|
- "remark"=>$remark,
|
|
|
- "apply_id"=>$rm,
|
|
|
- "apply_name"=>$ri,
|
|
|
- "is_del"=>0,
|
|
|
- "addtime"=>date('Y-m-d H:i:s'),
|
|
|
- "updatetime"=>date("Y-m-d H:i:s")
|
|
|
- ];
|
|
|
- $da= Db::name('good_check')->insert($data,true);
|
|
|
-// $dio=[];
|
|
|
-// if($da>0){
|
|
|
-// foreach ($dain as $value){
|
|
|
-// $st=Db::name("good_type")->alias("b")->join("good a","a.good_code = b.good_code","left")
|
|
|
-// ->join("good_stock c","c.good_type_code = b.type_code","left")->where(['c.wsm_code'=>$wsm_code,'good_type_code'=>$value['type_code'],'b.is_del'=>0,'a.is_del'=>0])->where("c.is_del=0 or c.is_del is null")
|
|
|
-// ->field("b.type_code,a.good_name,c.wsm_code,c.wait_in_stock,c.wait_out_stock,c.usable_stock,c.good_type_code,a.original_price")->find();
|
|
|
-//
|
|
|
-// $temp=[];
|
|
|
-// $temp['good_name']=$st['good_name'];
|
|
|
-// $temp['origin_price']=$st['original_price'];
|
|
|
-// $temp['good_type_code']=$st['good_type_code'];
|
|
|
-// $temp['origin_num']=$st['usable_stock'];
|
|
|
-// $temp['check_num']=0;
|
|
|
-// $temp['diff_num']=0;
|
|
|
-// $temp['status']=0;
|
|
|
-// $temp['remark']="";
|
|
|
-// $temp['is_del']=0;
|
|
|
-// $temp['check_time']=date('Y-m-d H:i:s');
|
|
|
-// $temp['check_code']=$check_code;
|
|
|
-// $temp['addtime']=date("Y-m-d H:i:s");
|
|
|
-// $temp['updatetime']=date("Y-m-d H:i:s");
|
|
|
-// $dio[] =$temp;
|
|
|
-// }
|
|
|
-// $in= Db::name('check_item')->insertAll($dio);
|
|
|
-// }
|
|
|
- if($da){
|
|
|
- $orde = ["order_code"=>$check_code,"status"=>$data['status'],"action_remark"=>'',"action_type"=>"create"];
|
|
|
- ActionLog::logAdd($this->post['token'],$orde,'PDD',$data['status'],$orde);
|
|
|
- $process=["order_code"=>$check_code,"order_id"=>$da,"order_status"=>$data['status'],"order_type"=>'PDD',"before_status"=>$data['status']];
|
|
|
- ProcessOrder::AddProcess($this->post['token'],$process);
|
|
|
- Db::commit();
|
|
|
- return error_show(0,"盘点创建成功");
|
|
|
- }else{
|
|
|
- Db::rollback();
|
|
|
- return error_show(1002,"创建失败");
|
|
|
- }
|
|
|
- }catch (\Exception $e){
|
|
|
- Db::rollback();
|
|
|
- return error_show(1005,$e->getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
-public function info(){
|
|
|
- $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) :"";
|
|
|
- if($id==""){
|
|
|
- return error_show(1002,"参数id不能为空");
|
|
|
- }
|
|
|
- $fo = Db::name('good_check')->alias('a')->join('warehouse_info b',"b.wsm_code=a.wsm_code","left")
|
|
|
- ->join('supplier c',"c.code=b.supplierNo","left")->field("c.name,c.code,a.*")
|
|
|
- ->where(['a.id'=>$id,'a.is_del'=>0])->find();
|
|
|
- if(empty($fo)){
|
|
|
- return error_show(1003,"未找到盘点信息");
|
|
|
- }
|
|
|
- $fi = Db::name('check_item')->where(['check_code'=>$fo['check_code'],'is_del'=>0])->select();
|
|
|
- $fo['item']=$fi;
|
|
|
- if(empty($fo)){
|
|
|
- return error_show(1002,"未找到盘点编号");
|
|
|
- }else{
|
|
|
- return app_show(0,"获取成功",$fo);
|
|
|
- }
|
|
|
-}
|
|
|
-public function edit()
|
|
|
-{
|
|
|
- $token =isset($this->post['token']) && $this->post['token'] !=="" ? trim($this->post['token']) :"";
|
|
|
- $id = isset($this->post['id']) && $this->post['id'] !== "" ? intval($this->post['id']) : "";
|
|
|
- $eid = Db::name('good_check')->where(['id' => $id, 'is_del' => 0])->find();
|
|
|
- if ($eid ==="") {
|
|
|
- return error_show(1002, "未找到盘点编号信息");
|
|
|
- }
|
|
|
- $wsm_code = isset($this->post['wsm_code']) && $this->post['wsm_code'] !== "" ? trim($this->post['wsm_code']) : "";
|
|
|
- if ($wsm_code == "") {
|
|
|
- return error_show(1002, "盘点仓库不能为空");
|
|
|
- }
|
|
|
- $type = isset($this->post['type']) && $this->post['type'] !== "" ? trim($this->post['type']) : "";
|
|
|
- $remark = isset($this->post['remark']) && $this->post['remark'] !== "" ? trim($this->post['remark']) : "";
|
|
|
- if ($type == "") {
|
|
|
- return error_show(1002, "盘点类型不能为空");
|
|
|
- }
|
|
|
- $apply_id=GetUserInfo($token);
|
|
|
- if(empty($apply_id)||$apply_id['code']!=0){
|
|
|
- return error_show(1002,"申请人数据不存在");
|
|
|
- }
|
|
|
- $rm= isset($apply_id["data"]['id']) ? $apply_id["data"]['id'] : "";
|
|
|
- $ri= isset($apply_id["data"]['nickname']) ? $apply_id["data"]['nickname'] : "";
|
|
|
-// $dain=isset($this->post['good']) && $this->post['good'] !=="" ? $this->post['good']:"";
|
|
|
-// if($type==2){
|
|
|
-// // var_dump($dain);
|
|
|
-// if($dain==""||empty($dain)){
|
|
|
-// return error_show(1002,"商品不能为空");
|
|
|
-// }
|
|
|
-// }else{
|
|
|
-// if($type==1) {
|
|
|
-//
|
|
|
-// $dain= Db::name("good_type")->alias("b")->join("good a","a.good_code = b.good_code","left")
|
|
|
-// ->join("good_stock c","c.good_type_code = b.type_code","left")->where(['c.wsm_code'=>$wsm_code,'b.is_del'=>0,'a.is_del'=>0])->where("c.is_del=0 or c.is_del is null")
|
|
|
-// ->field("b.type_code,a.good_name")->select();
|
|
|
-// //var_dump($dain);
|
|
|
-// }
|
|
|
-// if($dain==""){
|
|
|
-// return error_show(1003,"商品不能为空");
|
|
|
-// }
|
|
|
-// }
|
|
|
- Db::startTrans();
|
|
|
- try {
|
|
|
- $var = [
|
|
|
- "wsm_code" => $wsm_code,
|
|
|
- "type" => $type,
|
|
|
- "apply_id" => $rm,
|
|
|
- "apply_name" => $ri,
|
|
|
- "remark" => $remark,
|
|
|
- "updatetime" => date("Y-m-d H:i:s")
|
|
|
- ];
|
|
|
- $up = Db::name('good_check')->where(['id'=>$id,'is_del' => 0])->save($var);
|
|
|
-// $dn =[];
|
|
|
-// if($up>0){
|
|
|
-// foreach ($dain as $value){
|
|
|
-// $st=Db::name("good_type")->alias("b")->join("good a","a.good_code = b.good_code","left")
|
|
|
-// ->join("good_stock c","c.good_type_code = b.type_code","left")->where(['c.wsm_code'=>$wsm_code,'good_type_code'=>$value['type_code'],'b.is_del'=>0,'a.is_del'=>0])->where("c.is_del=0 or c.is_del is null")
|
|
|
-// ->field("b.type_code,a.good_name,c.wsm_code,c.wait_in_stock,c.wait_out_stock,c.usable_stock,c.good_type_code,a.original_price")->find();
|
|
|
-// $temp=[];
|
|
|
-// $temp['good_name']=$st['good_name'];
|
|
|
-// $temp['origin_price']=$st['original_price'];
|
|
|
-// $temp['good_type_code']=$st['good_type_code'];
|
|
|
-// $temp['origin_num']=$st['usable_stock'];
|
|
|
-// $temp['check_num']=0;
|
|
|
-// $temp['diff_num']=0;
|
|
|
-// $temp['status']=0;
|
|
|
-// $temp['remark']="";
|
|
|
-// $temp['is_del']=0;
|
|
|
-// $temp['check_time']=date('Y-m-d H:i:s');
|
|
|
-// $temp['check_code']=$eid['check_code'];
|
|
|
-// $temp['addtime']=date("Y-m-d H:i:s");
|
|
|
-// $temp['updatetime']=date("Y-m-d H:i:s");
|
|
|
-// $dn[] =$temp;
|
|
|
-// }
|
|
|
-// $np = Db::name('check_item')->where(['check_code'=>$eid['check_code'],'is_del'=>0])->update(['is_del'=>1,'updatetime'=>date('Y-m-d H:i:s')]);
|
|
|
-// $io = db::name('check_item')->insertAll($up);
|
|
|
- // var_dump(Db::name('check_item')->getLastSql());
|
|
|
- if ($up) {
|
|
|
- $orde = ["order_code"=>$eid['check_code'],"status"=>$eid['status'],"action_remark"=>'',"action_type"=>"edit"];
|
|
|
- ActionLog::logAdd($this->post['token'],$orde,'qrd',$eid['status'],$orde);
|
|
|
- Db::commit();
|
|
|
- return error_show(0, "盘点更新成功");
|
|
|
- }
|
|
|
+ $wsm_code = isset($this->post['wsm_code']) && $this->post['wsm_code'] !=="" ? trim($this->post['wsm_code']):"";
|
|
|
+ if($wsm_code==""){
|
|
|
+ return error_show(1002,"盘点仓库编号不能为空");
|
|
|
+ }
|
|
|
+ $type = isset($this->post['type']) && $this->post['type'] !=="" ? intval($this->post['type']) :"";
|
|
|
+ if($type==""){
|
|
|
+ return error_show(1002,"盘点类型不能为空");
|
|
|
+ }
|
|
|
+ $companyNo = isset($this->post['companyNo']) && $this->post['companyNo'] !=="" ? trim($this->post['companyNo']) :"";
|
|
|
+ if($companyNo==""){
|
|
|
+ return error_show(1002,"参数companyNo不能为空");
|
|
|
+ }
|
|
|
+ $company =Db::name("business")->where(['companyNo'=>$companyNo,"is_del"=>0])->find();
|
|
|
+ if($company==false){
|
|
|
+ return error_show(1002,"未找到业务公司");
|
|
|
+ }
|
|
|
+ $check_code = makeNo("CK");
|
|
|
+ $apply_id=GetUserInfo($token);
|
|
|
+ if(empty($apply_id)||$apply_id['code']!=0){
|
|
|
+ return error_show(1002,"申请人数据不存在");
|
|
|
+ }
|
|
|
+ $rm= isset($apply_id["data"]['id']) ? $apply_id["data"]['id'] : "";
|
|
|
+ $ri= isset($apply_id["data"]['nickname']) ? $apply_id["data"]['nickname'] : "";
|
|
|
+ $status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status']) :"0";
|
|
|
+ $remark = isset($this->post['remark']) && $this->post['remark'] !=="" ? intval($this->post['remark']) :"";
|
|
|
+ Db::startTrans();
|
|
|
+ try{
|
|
|
+ $data=[
|
|
|
+ "check_code"=>$check_code,
|
|
|
+ "wsm_code"=>$wsm_code,
|
|
|
+ "type"=>$type,
|
|
|
+ "status"=>$status,
|
|
|
+ "companyNo"=>$companyNo,
|
|
|
+ "remark"=>$remark,
|
|
|
+ "apply_id"=>$rm,
|
|
|
+ "apply_name"=>$ri,
|
|
|
+ "is_del"=>0,
|
|
|
+ "addtime"=>date('Y-m-d H:i:s'),
|
|
|
+ "updatetime"=>date("Y-m-d H:i:s")
|
|
|
+ ];
|
|
|
+ $da= Db::name('good_check')->insert($data,true);
|
|
|
+ if($da){
|
|
|
+ $orde = ["order_code"=>$check_code,"status"=>$data['status'],"action_remark"=>'',"action_type"=>"create"];
|
|
|
+ ActionLog::logAdd($this->post['token'],$orde,'PDD',$data['status'],$orde);
|
|
|
+ $process=["order_code"=>$check_code,"order_id"=>$da,"order_status"=>$data['status'],"order_type"=>'PDD',"before_status"=>$data['status']];
|
|
|
+ ProcessOrder::AddProcess($this->post['token'],$process);
|
|
|
+ Db::commit();
|
|
|
+ return error_show(0,"盘点创建成功");
|
|
|
+ }else{
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1002,"创建失败");
|
|
|
+ }
|
|
|
+ }catch (\Exception $e){
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1005,$e->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public function info(){
|
|
|
+ $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) :"";
|
|
|
+ if($id==""){
|
|
|
+ return error_show(1002,"参数id不能为空");
|
|
|
+ }
|
|
|
+ $fo = Db::name('good_check')->alias('a')->join('warehouse_info b',"b.wsm_code=a.wsm_code","left")
|
|
|
+ ->join('supplier c',"c.code=b.supplierNo","left")->field("c.name,c.code,a.*")
|
|
|
+ ->where(['a.id'=>$id,'a.is_del'=>0])->find();
|
|
|
+ if(empty($fo)){
|
|
|
+ return error_show(1003,"未找到盘点信息");
|
|
|
+ }
|
|
|
+ $fi = Db::name('check_item')->where(['check_code'=>$fo['check_code'],'is_del'=>0])->select();
|
|
|
+ $fo['item']=$fi;
|
|
|
+ if(empty($fo)){
|
|
|
+ return error_show(1002,"未找到盘点编号");
|
|
|
+ }else{
|
|
|
+ return app_show(0,"获取成功",$fo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public function edit()
|
|
|
+ {
|
|
|
+ $token =isset($this->post['token']) && $this->post['token'] !=="" ? trim($this->post['token']) :"";
|
|
|
+ $id = isset($this->post['id']) && $this->post['id'] !== "" ? intval($this->post['id']) : "";
|
|
|
+ $eid = Db::name('good_check')->where(['id' => $id, 'is_del' => 0])->find();
|
|
|
+ if ($eid ==="") {
|
|
|
+ return error_show(1002, "未找到盘点编号信息");
|
|
|
+ }
|
|
|
+ $wsm_code = isset($this->post['wsm_code']) && $this->post['wsm_code'] !== "" ? trim($this->post['wsm_code']) : "";
|
|
|
+ if ($wsm_code == "") {
|
|
|
+ return error_show(1002, "盘点仓库不能为空");
|
|
|
+ }
|
|
|
+ $type = isset($this->post['type']) && $this->post['type'] !== "" ? trim($this->post['type']) : "";
|
|
|
+ $remark = isset($this->post['remark']) && $this->post['remark'] !== "" ? trim($this->post['remark']) : "";
|
|
|
+ if ($type == "") {
|
|
|
+ return error_show(1002, "盘点类型不能为空");
|
|
|
+ }
|
|
|
+ $apply_id=GetUserInfo($token);
|
|
|
+ if(empty($apply_id)||$apply_id['code']!=0){
|
|
|
+ return error_show(1002,"申请人数据不存在");
|
|
|
+ }
|
|
|
+ $rm= isset($apply_id["data"]['id']) ? $apply_id["data"]['id'] : "";
|
|
|
+ $ri= isset($apply_id["data"]['nickname']) ? $apply_id["data"]['nickname'] : "";
|
|
|
+ // $dain=isset($this->post['good']) && $this->post['good'] !=="" ? $this->post['good']:"";
|
|
|
+ // if($type==2){
|
|
|
+ // // var_dump($dain);
|
|
|
+ // if($dain==""||empty($dain)){
|
|
|
+ // return error_show(1002,"商品不能为空");
|
|
|
+ // }
|
|
|
+ // }else{
|
|
|
+ // if($type==1) {
|
|
|
+ //
|
|
|
+ // $dain= Db::name("good_type")->alias("b")->join("good a","a.good_code = b.good_code","left")
|
|
|
+ // ->join("good_stock c","c.good_type_code = b.type_code","left")->where(['c.wsm_code'=>$wsm_code,'b.is_del'=>0,'a.is_del'=>0])->where("c.is_del=0 or c.is_del is null")
|
|
|
+ // ->field("b.type_code,a.good_name")->select();
|
|
|
+ // //var_dump($dain);
|
|
|
+ // }
|
|
|
+ // if($dain==""){
|
|
|
+ // return error_show(1003,"商品不能为空");
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ Db::startTrans();
|
|
|
+ try {
|
|
|
+ $var = [
|
|
|
+ "wsm_code" => $wsm_code,
|
|
|
+ "type" => $type,
|
|
|
+ "apply_id" => $rm,
|
|
|
+ "apply_name" => $ri,
|
|
|
+ "remark" => $remark,
|
|
|
+ "updatetime" => date("Y-m-d H:i:s")
|
|
|
+ ];
|
|
|
+ $up = Db::name('good_check')->where(['id'=>$id,'is_del' => 0])->save($var);
|
|
|
+ // $dn =[];
|
|
|
+ // if($up>0){
|
|
|
+ // foreach ($dain as $value){
|
|
|
+ // $st=Db::name("good_type")->alias("b")->join("good a","a.good_code = b.good_code","left")
|
|
|
+ // ->join("good_stock c","c.good_type_code = b.type_code","left")->where(['c.wsm_code'=>$wsm_code,'good_type_code'=>$value['type_code'],'b.is_del'=>0,'a.is_del'=>0])->where("c.is_del=0 or c.is_del is null")
|
|
|
+ // ->field("b.type_code,a.good_name,c.wsm_code,c.wait_in_stock,c.wait_out_stock,c.usable_stock,c.good_type_code,a.original_price")->find();
|
|
|
+ // $temp=[];
|
|
|
+ // $temp['good_name']=$st['good_name'];
|
|
|
+ // $temp['origin_price']=$st['original_price'];
|
|
|
+ // $temp['good_type_code']=$st['good_type_code'];
|
|
|
+ // $temp['origin_num']=$st['usable_stock'];
|
|
|
+ // $temp['check_num']=0;
|
|
|
+ // $temp['diff_num']=0;
|
|
|
+ // $temp['status']=0;
|
|
|
+ // $temp['remark']="";
|
|
|
+ // $temp['is_del']=0;
|
|
|
+ // $temp['check_time']=date('Y-m-d H:i:s');
|
|
|
+ // $temp['check_code']=$eid['check_code'];
|
|
|
+ // $temp['addtime']=date("Y-m-d H:i:s");
|
|
|
+ // $temp['updatetime']=date("Y-m-d H:i:s");
|
|
|
+ // $dn[] =$temp;
|
|
|
+ // }
|
|
|
+ // $np = Db::name('check_item')->where(['check_code'=>$eid['check_code'],'is_del'=>0])->update(['is_del'=>1,'updatetime'=>date('Y-m-d H:i:s')]);
|
|
|
+ // $io = db::name('check_item')->insertAll($up);
|
|
|
+ // var_dump(Db::name('check_item')->getLastSql());
|
|
|
+ if ($up) {
|
|
|
+ $orde = ["order_code"=>$eid['check_code'],"status"=>$eid['status'],"action_remark"=>'',"action_type"=>"edit"];
|
|
|
+ ActionLog::logAdd($this->post['token'],$orde,'qrd',$eid['status'],$orde);
|
|
|
+ Db::commit();
|
|
|
+ return error_show(0, "盘点更新成功");
|
|
|
+ }
|
|
|
|
|
|
- Db::rollback();
|
|
|
- return error_show(1003,"盘点更新失败");
|
|
|
- } catch (\Exception $e) {
|
|
|
- Db::rollback();
|
|
|
- return error_show(1005, $e->getMessage());
|
|
|
- }
|
|
|
-}
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1003,"盘点更新失败");
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1005, $e->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* @return \think\response\Json|void
|