|
@@ -0,0 +1,157 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace app\admin\controller;
|
|
|
+
|
|
|
+use app\BaseController;
|
|
|
+use think\App;
|
|
|
+use think\facade\Db;
|
|
|
+
|
|
|
+class Check extends BaseController
|
|
|
+{
|
|
|
+public $post = "";
|
|
|
+public function __construct(App $app)
|
|
|
+{
|
|
|
+ parent::__construct($app);
|
|
|
+ $this->post=$this->request->post();
|
|
|
+}
|
|
|
+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 = ['is_del' => 0];
|
|
|
+ $addtime = isset($this->post['addtime']) && $this->post['addtime'] !== "" ? intval($this->post['addtime']) : "";
|
|
|
+ if ($addtime !== "") {
|
|
|
+ $where['check_code'] = $addtime;
|
|
|
+ }
|
|
|
+ $check_code = isset($this->post['check_code']) && $this->post['check_code'] !== "" ? intval($this->post['check_code']) : "";
|
|
|
+ if ($check_code !== "") {
|
|
|
+ $where['check_code'] = $check_code;
|
|
|
+ }
|
|
|
+ $wsm_code = isset($this->post['wsm_code ']) && $this->post['wsm_code '] !== "" ? intval($this->post['wsm_code ']) : "";
|
|
|
+ if ($wsm_code !== "") {
|
|
|
+ $where['wsm_code '] = $wsm_code;
|
|
|
+ }
|
|
|
+ $status= isset($this->post['status ']) && $this->post['status '] !== "" ? intval($this->post['status ']) : "";
|
|
|
+ if ($status !== "") {
|
|
|
+ $where['status '] = $status;
|
|
|
+ }
|
|
|
+ $count = Db::name('good_check')->count();
|
|
|
+ $total = ceil($count / $size);
|
|
|
+ $page = $page >= $total ? $page : $total;
|
|
|
+ $list = Db::name('good_check')->field('apply_id,apply_name,type,addtime')->where($where)->page($page,$size)->select();
|
|
|
+ return app_show(0,"获取成功",['count'=>$count,'list'=>$list]);
|
|
|
+ }
|
|
|
+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,'status'=>0];
|
|
|
+ $count = Db::name('check_item')->count();
|
|
|
+ $total = ceil($count / $size);
|
|
|
+ $page = $page >= $total ? $page : $total;
|
|
|
+ $list = Db::name('check_item')->where($where)->page($page,$size)->select();
|
|
|
+ return app_show(0,"获取成功",['count'=>$count,'list'=>$list]);
|
|
|
+}
|
|
|
+public function create(){
|
|
|
+ $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']) :"";
|
|
|
+ if($type==""){
|
|
|
+ return error_show(1002,"盘点类型不能为空");
|
|
|
+ }
|
|
|
+ $check_code = isset($this->post['check_code']) && $this->post['check_code'] !=="" ? trim($this->post['check_code']) : "";
|
|
|
+ $apply_id = isset($this->post['apply_id']) && $this->post['apply_id'] !=="" ? trim($this->post['apply_id']):"";
|
|
|
+ $apply_name = isset($this->post['apply_name']) && $this->post['apply_name'] !=="" ? trim($this->post['apply_name']):"";
|
|
|
+ $status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status']) :"0";
|
|
|
+ $good_type_code = isset($this->post['good_type_code']) && $this->post['good_type_code'] !=="" ? $this->post['good_type_code']:"";
|
|
|
+ $good_name = isset($this->post['good_name']) && $this->post['good_name'] !=="" ? $this->post['good_name'] : "";
|
|
|
+ $origin_price = isset($this->post['origin_price']) && $this->post['origin_price'] !=="" ? $this->post['origin_price'] :"";
|
|
|
+ $origin_num = isset($this->post['origin_num']) && $this->post['origin_num'] !=="" ? $this->post['origin_num'] :"";
|
|
|
+ $check_num = isset($this->post['check_num']) && $this->post['check_num'] !=="" ? $this->post['check_num'] :"";
|
|
|
+ $diff_num = isset($this->post['diff_num']) && $this->post['diff_num'] !=="" ? $this->post['diff_num'] :"";
|
|
|
+ $remark = isset($this->post['remark']) && $this->post['remark'] !=="" ? $this->post['remark'] :"";
|
|
|
+ $check_time = isset($this->post['check_time']) && $this->post['check_time'] !=="" ? $this->post['startTime']:date("Y-m-d H:i:s");
|
|
|
+ Db::startTrans();
|
|
|
+ try{
|
|
|
+ $data=[
|
|
|
+ "check_code"=>$check_code,
|
|
|
+ "wsm_code"=>$wsm_code,
|
|
|
+ "type"=>$type,
|
|
|
+ "status"=>$status,
|
|
|
+ "apply_id"=>$apply_id,
|
|
|
+ "apply_name"=>$apply_name,
|
|
|
+ "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>0){
|
|
|
+ $dain=[
|
|
|
+ "good_type_code"=>$good_type_code,
|
|
|
+ "good_name"=>$good_name,
|
|
|
+ "status"=>$status,
|
|
|
+ "origin_price" =>$origin_price,
|
|
|
+ "origin_num"=>$origin_num,
|
|
|
+ "check_num"=>$check_num,
|
|
|
+ "diff_num"=>$diff_num,
|
|
|
+ "remark"=>$remark,
|
|
|
+ "check_time"=>$check_time,
|
|
|
+ "is_del"=>0,
|
|
|
+ "addtime"=>date('Y-m-d H:i:s'),
|
|
|
+ "updatetime"=>date("Y-m-d H:i:s")
|
|
|
+ ];
|
|
|
+ $in= Db::name('check_item')->insert($dain);
|
|
|
+ }
|
|
|
+ if($in){
|
|
|
+ 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,"盘点单号不能为空");
|
|
|
+ }
|
|
|
+ $fo = Db::name('good_check')->where(['id'=>$id,'is_del'=>0])->find();
|
|
|
+ if(empty($fo)){
|
|
|
+ return error_show(1002,"未找到盘点编号");
|
|
|
+ }else{
|
|
|
+ return app_show(0,"获取成功",$fo);
|
|
|
+ }
|
|
|
+}
|
|
|
+public function edit(){
|
|
|
+ $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']) :"";
|
|
|
+ if($type==""){
|
|
|
+ return error_show(1002,"盘点类型不能为空");
|
|
|
+ }
|
|
|
+ $good_type_code = isset($this->post['good_type_code']) && $this->post['good_type_code'] !=="" ? trim($this->post['good_type_code']) :"";
|
|
|
+ if($good_type_code==""){
|
|
|
+ return error_show(1002,"商品属性不能为空");
|
|
|
+ }
|
|
|
+ $good_name= isset($this->post['good_name']) && $this->post['good_name'] !=="" ? trim($this->post['good_name']):"";
|
|
|
+ if($good_name==""){
|
|
|
+ return error_show(1002,"商品名称不能为空");
|
|
|
+ }
|
|
|
+ $apply_id = isset($this->post['apply_id']) && $this->post['apply_id'] !=="" ? intval($this->post['apply_id']) :"";
|
|
|
+ $apply_name= isset($this->post['apply_name']) && $this->post['apply_name'] !=="" ? trim($this->post['apply_name']) :"";
|
|
|
+ $status = isset($this->post['status']) && $this->post['status'] !=="" ? trim($this->post['status']) :"";
|
|
|
+
|
|
|
+}
|
|
|
+}
|