|
@@ -18,34 +18,33 @@ class Allot extends BaseController
|
|
|
$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];
|
|
|
- $allot_code = isset($this->post['allot_code']) && $this->post['allot_code'] !== "" ? intval($this->post['allot_code']) : "";
|
|
|
+ $allot_code = isset($this->post['allot_code']) && $this->post['allot_code'] !== "" ? trim($this->post['allot_code']) : "";
|
|
|
if ($allot_code !== "") {
|
|
|
$where['allot_code'] = $allot_code;
|
|
|
}
|
|
|
- $wsm_out = isset($this->post['wsm_out']) && $this->post['wsm_out'] !== "" ? intval($this->post['wsm_out']) : "";
|
|
|
+ $wsm_out = isset($this->post['wsm_out']) && $this->post['wsm_out'] !== "" ? trim($this->post['wsm_out']) : "";
|
|
|
if ($wsm_out !== "") {
|
|
|
$where['wsm_out'] = $wsm_out;
|
|
|
}
|
|
|
- $wsm_in = isset($this->post['wsm_in']) && $this->post['wsm_in'] !== "" ? intval($this->post['wsm_in']) : "";
|
|
|
+ $wsm_in = isset($this->post['wsm_in']) && $this->post['wsm_in'] !== "" ? trim($this->post['wsm_in']) : "";
|
|
|
if ($wsm_in !== "") {
|
|
|
$where['wsm_in'] = $wsm_in;
|
|
|
}
|
|
|
- $addtime = isset($this->post['addtime']) && $this->post['addtime'] !== "" ? intval($this->post['addtime']) : "";
|
|
|
- if ($addtime !== "") {
|
|
|
- $where['addtime'] = $addtime;
|
|
|
+ $start= isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start']:"";
|
|
|
+ if ($start !="") {
|
|
|
+ $where = ["addtime"=>Db::raw(">= '{$start}'")];
|
|
|
}
|
|
|
- $count = Db::name('allot_stock')->count();
|
|
|
+ $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] :"";
|
|
|
+ if($end !=""){
|
|
|
+ $where = ["addtime"=>Db::raw("<= '{$end}'")];
|
|
|
+ }
|
|
|
+ $count = Db::name('allot_stock')->where($where)->count();
|
|
|
$total = ceil($count/$size);
|
|
|
$page = $page >= $total ? $total : $page;
|
|
|
$list = Db::name('allot_stock')->where($where)->page($page,$size)->select();
|
|
|
+ // var_dump(Db::name('allot_stock')->getLastSql());
|
|
|
return app_show(0,"获取成功",['count'=>$count,'list'=>$list]);
|
|
|
}
|
|
|
- // $good_name= isset($this->post['good_name']) && $this->post['good_name'] !=="" ? trim($this->post['good_name']) :"";
|
|
|
-// $allot_code = isset($this->post['allot_code']) && $this->post['allot_code'] !=="" ? trim($this->post['allot_code']) :"";
|
|
|
-// $usable_num = isset($this->post['usable_num']) && $this->post['usable_num'] !=="" ? intval($this->post['allot_code']) :"0";
|
|
|
-// $error_num = isset($this->post['error_num']) && $this->post['error_num'] !=="" ? intval($this->post['error_num']) :"0";
|
|
|
-// $error_remark = isset($this->post['error_remark']) && $this->post['error_remark'] !=="" ? trim($this->post['error_remark']) :"";
|
|
|
-// $stock_num = isset($this->post['stock_num']) && $this->post['error_num'] !=="" ? intval($this->post['error_num']) : "0";
|
|
|
public function create(){
|
|
|
$token =isset($this->post['token']) && $this->post['token'] !=="" ? trim($this->post['token']) :"";
|
|
|
$wsm_out = isset($this->post['wsm_out']) && $this->post['wsm_out'] !=="" ? trim($this->post['wsm_out']) :"";
|
|
@@ -56,10 +55,10 @@ class Allot extends BaseController
|
|
|
if($wsm_in==""){
|
|
|
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_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,"商品属性不能为空");
|
|
|
+// }
|
|
|
$allot_code=makeNo("XK");
|
|
|
// $allot_code = isset($this->post['allot_code']) && $this->post['allot_code'] !=="" ? trim($this->post['allot_code']) :"";
|
|
|
// if($allot_code==""){
|
|
@@ -106,8 +105,11 @@ class Allot extends BaseController
|
|
|
if($pd>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(['wsm_code' => $wsm_out, '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,a.unit,c.wsm_code,c.usable_stock,c.good_type_code,c.wait_out_stock,c.wait_in_stock")->find();
|
|
|
+ ->join("good_stock c", "c.good_type_code = b.type_code", "left")
|
|
|
+ ->join("warehouse_info v","v.wsm_code=c.wsm_code","left")
|
|
|
+ ->join("supplier n","n.code=v.supplierNo","left")
|
|
|
+ ->where(['c.wsm_code' => $wsm_out, '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,a.unit,c.wsm_code,c.usable_stock,c.good_type_code,c.wait_out_stock,c.wait_in_stock,n.name,n.code")->find();
|
|
|
if (empty($st)) {
|
|
|
Db::rollback();
|
|
|
return error_show(1003, "商品不能为空");
|
|
@@ -169,6 +171,14 @@ class Allot extends BaseController
|
|
|
if($allot_code==""){
|
|
|
return error_show(1002,"调拨单编号不能为空");
|
|
|
}
|
|
|
+ $post_name = isset($this->post['post_name']) && $this->post['post_name'] !=="" ? trim($this->post['post_name']) :"";
|
|
|
+ if($post_name==""){
|
|
|
+ return error_show(1002,"物流公司不能为空");
|
|
|
+ }
|
|
|
+ $post_code = isset($this->post['post_code']) && $this->post['post_code'] !=="" ? trim($this->post['post_code']) :"";
|
|
|
+ if($post_code==""){
|
|
|
+ return error_show(1002,"物流单号不能为空");
|
|
|
+ }
|
|
|
$apply_id =GetUserInfo($token);
|
|
|
if(empty($apply_id)||$apply_id['code']!=0){
|
|
|
return error_show(1002,"申请人数据不存在");
|
|
@@ -203,6 +213,8 @@ class Allot extends BaseController
|
|
|
"wsm_out"=>$wsm_out,
|
|
|
"wsm_in"=>$wsm_in,
|
|
|
"post_fee"=>$post_fee,
|
|
|
+ "post_name"=>$post_name,
|
|
|
+ "post_code"=>$post_code,
|
|
|
"status"=>$status,
|
|
|
"updatetime"=>date('Y-m-d H:i:s'),
|
|
|
];
|
|
@@ -260,4 +272,28 @@ class Allot extends BaseController
|
|
|
return error_show(1002,"删除失败");
|
|
|
}
|
|
|
}
|
|
|
+ public function status(){
|
|
|
+ $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) :"" ;
|
|
|
+ if($id==""){
|
|
|
+ return error_show(1002,"调拨编号不能为空");
|
|
|
+ }
|
|
|
+ $remark = isset($this->post['remark']) && $this->post['remark'] !=="" ? trim($this->post['remark']) :"";
|
|
|
+ $status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status']) :"";
|
|
|
+ if($status===""){
|
|
|
+ return error_show(1002,"审核状态不能为空");
|
|
|
+ }
|
|
|
+ $st = Db::name('allot_stock')->where(['id'=>$id,"is_del"=>0])->find();
|
|
|
+ if(empty($st)){
|
|
|
+ return error_show(1002,"调拨信息未找到");
|
|
|
+ }
|
|
|
+ $st['remark']=$remark;
|
|
|
+ $st['status']=$status;
|
|
|
+ $st['updatetime']= date('Y-m-d H:i:s');
|
|
|
+ $sv = Db::name('allot_stock')->save($st);
|
|
|
+ if($sv){
|
|
|
+ return error_show(0,"状态更新成功");
|
|
|
+ }else{
|
|
|
+ return error_show(1002,"状态更新失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|