Browse Source

提交备货的相关数据

lvhao 1 day ago
parent
commit
46146038d1
2 changed files with 412 additions and 1 deletions
  1. 205 1
      core/CoreApp/controllers/Beihuogl.php
  2. 207 0
      template/erp/beihuogl_bjindex.html

+ 205 - 1
core/CoreApp/controllers/Beihuogl.php

@@ -115,6 +115,10 @@ class Beihuogl extends Start_Controller {
             $this->_bhcxlistexcel();
         }elseif($arg == 'wlrlpdc'){
             $this->_wlrlpdc();
+        }elseif($arg == 'bjindex'){
+            $this->_bjindex();
+        }elseif($arg == 'bhqzwg'){
+            $this->_bhqzwg();
         }
 		else
 		{
@@ -270,6 +274,7 @@ class Beihuogl extends Start_Controller {
                     'add_time'=>$time,
                     'real_time'=>$time,
                     'update_time'=>$time,
+                    'yqwc_time'=>empty($data['yqwc_time'])?0:strtotime($data['yqwc_time']),
                 ];
             }
             $r =$this->db->insert_batch('bhsq',$insert_arr);
@@ -286,6 +291,122 @@ class Beihuogl extends Start_Controller {
             $this->_Template('beihuogl_dyapplyadd',$this->data);
         }
     }
+    //备货报警列表
+    private function _bjindex(){
+        if($this->input->method() === 'post'){
+            $vip_id = $this->input->post('vip_id',true);
+            $page = $this->input->post('page',true);
+		    $perpage = $this->input->post('perpage',true);
+            $sqr = $this->input->post('sqr',true);
+            $sqr = trim($sqr);
+            $sq_status = $this->input->post('sq_status',true);
+            $shop_id = $this->input->post('shop_id',true);
+            $plat_id = $this->input->post('plat_id',true);
+            $shop_ids = $this->input->post('shop_ids',true);
+            $ktime = $this->input->post('ktime',true);
+            $jtime = $this->input->post('jtime',true);
+            $ktime = strtotime($ktime);
+            $jtime = strtotime($jtime);
+
+            $where = "add_time >= ".$ktime."  and add_time  < ".$jtime." and  is_cx = 0";
+
+            if(!empty($sqr)){
+                $where .= " and sqr = '".$sqr."' ";
+            }
+            if($shop_id > -1){
+                $where .= " and shop_id = ".$shop_id." ";
+            }else{
+                if($vip_id == 1){
+
+                }else{
+                    $where .= " and shop_id in (".$shop_ids.") ";
+                }
+                
+            }
+            if($sq_status > -1){
+               $where .= " and sq_status = ".$sq_status." ";
+            }
+            
+            if($plat_id > -1){
+               $where .= " and plat_id = ".$plat_id." ";
+            }
+            //数据排序
+            $order_str = "id desc";
+            if(empty($page))
+		    {
+                $start = 0;
+		    	$perpage = 1;
+            }
+		    else
+		    {
+                $start = ($page - 1)*$perpage;
+            }
+
+            $list = $this->bhsq->find_all($where,"id,shop_id,title,sqr,ck_num,bj_status,add_time,yqwc_time,zhycjs_time,js_num,sy_num,bh_no,u9sc_no,is_cx",$order_str,$start,$perpage);
+
+            if(empty($list)){
+                $rows = array('total'=>0,'over'=>1,'pagenum'=>0,'rows'=>([]));
+                echo json_encode($rows);exit;
+            }
+            $shop_list = $this->shop->find_all("1=1","id,shopname");
+            $shop_list = array_column($shop_list,'shopname','id');
+            $plat_list = $this->typeclass->find_all("classid = 32","id,title");
+            $plat_list = array_column($plat_list,'title','id');
+            $status_list = $this->bhsq->getBjStatus();
+            foreach($list as $k=>$v){
+                $list[$k]['shop_id'] = isset($shop_list[$v['shop_id']])?$shop_list[$v['shop_id']]:"无";
+               
+                $status_str = isset($status_list[$v['bj_status']])?$status_list[$v['bj_status']]:"";
+                if($v['bj_status'] == 1){
+                    $status_str = "<div style='color: #0000FF;font-weight:bold'>".$status_str."</div>";
+                }else if($v['bj_status'] == 2){
+                    $status_str = "<div style='color: #FF8800;font-weight:bold'>".$status_str."</div>";
+                }else if($v['bj_status'] == 3){
+                    $status_str = "<div style='color: #FF3333;font-weight:bold'>".$status_str."</div>";
+                }elseif($v['bj_status'] == 4){
+                    $status_str = "<div style='color: #008000;font-weight:bold'>".$status_str."</div>";
+                }
+                $list[$k]['bj_status'] = $status_str;
+                $list[$k]['add_time'] = date("Y-m-d",$v['add_time']);
+                $list[$k]['yqwc_time'] = date("Y-m-d",$v['yqwc_time']);
+                $list[$k]['zhycjs_time'] = empty($v['zhycjs_time'])?'': date("Y-m-d",$v['zhycjs_time']);
+                $str =  "<div style='text-align:center;'>";
+                if($v['bj_status']  != 4){
+                   
+                  
+                
+                //    $str .= "<a href='javascript:void(0)' style='margin-right:4px;color: #fff;background-color: #9400D3;padding:4px 10px;border-radius:5px;font-size:15px' data-title='".$v['title']."' data-id='".$v['id']."' data-u9sc_no='".$v['u9sc_no']."' data-bh_no='".$v['bh_no']."' onclick='cx_bhsq(this)'>接收数量</a>";
+                   if($vip_id == 1 && ($v['sy_num'] >= 1)){
+                        $str .= "<a href='javascript:void(0)' style='margin-right:4px;color: #fff;background-color: #DC143C;padding:4px 10px;border-radius:5px;font-size:15px' data-id='".$v['id']."' data-type='0' onclick='bhsq_qzwg(this)'>强制完工</a>";
+                   }
+                   
+                
+                
+                }
+                $str .=  "</div>";
+                $list[$k]['update_time'] = $str;
+                unset($list[$k]['bh_no']);
+                unset($list[$k]['u9sc_no']);
+                unset($list[$k]['is_cx']);
+            }
+            $total = $this->bhsq->find_count($where);
+		    $pagenum = ceil($total/$perpage);
+		    $over = $total-($start+$perpage);
+            $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
+		    echo json_encode($rows);exit;
+        }else{
+            $user = $this->user->get_api($_SESSION['api']);
+            $usersp = explode('|',trim($user['shop'],'|'));
+            $this->data['usersp'] = implode(",",$usersp);
+            $vip_id = 0;
+            if(in_array($user['id'],[10,28])){
+                $vip_id = 1;
+            }
+            $this->data['vip_id'] = $vip_id;
+            $this->data['status_list'] = $this->bhsq->getBjStatus();
+            $this->_Template('beihuogl_bjindex',$this->data);
+        }
+    }
     //备货申请单的 修改
     private function _dyapplyedit($arg_array){
         if($this->input->method() === 'post'){
@@ -301,6 +422,7 @@ class Beihuogl extends Start_Controller {
                 'sku'=>$data['sku'],
                 'remark'=>$data['remark'],
                 'title'=>$data['title'],
+                'yqwc_time'=>empty($data['yqwc_time'])?0:strtotime($data['yqwc_time']),
             ];
             $r = $this->bhsq->save($update_arr,$id);
             if($r){
@@ -314,6 +436,7 @@ class Beihuogl extends Start_Controller {
             $info = $this->bhsq->find("id = ".$id);
             $plat_list = $this->typeclass->find_all("classid = 32 and id != 2297","id,title");
             $this->data['plat_list'] = $plat_list;
+            $info['yqwc_time'] = empty($info['yqwc_time'])?'':date("Y-m-d H:i",$info['yqwc_time']);
             $this->data['info'] = $info;
             $this->_Template('beihuogl_dyapplyedit',$this->data);
         }
@@ -1862,6 +1985,10 @@ class Beihuogl extends Start_Controller {
             $spec_arr = $whlabel_arr = [];
             $time = time();
             $err_list= [];
+
+            $js_arr = [];//可能要接受的信息
+            $jstj_arr_ids = [];//需要更新的调拨订单的id
+
             foreach($list as $k=>$v){
                 if(empty($v['sku'])){
                     $err_list[] = $v['jm']."不存在";
@@ -1879,6 +2006,46 @@ class Beihuogl extends Start_Controller {
                         }
                     }
                 }
+            
+                //获取对应的申请单 用于接收合演
+                if(($v['is_tjjs'] == 0) && !empty($v['features'])){
+                     $check_sq_list = $this->bhsq->find_all("bh_no = '".$v['bh_no']."' and features = '".$v['features']."' and sy_num > 0  ","*","yqwc_time asc");
+                     $total = $v['real_num'];
+                     foreach($check_sq_list as $item){
+                        if($total >= $item['sy_num']){
+                            $js_arr[] = [
+                                'js_num'=>$item['js_num'] + $item['sy_num'],
+                                'id'=>$item['id'],
+                                'sy_num'=>0,
+                                'bj_status'=>4,
+                                'zhycjs_time'=>$time,
+                            ];
+                            $total = $total - $item['sy_num'];
+                        }else{
+                            if($total <= 0){
+                        
+                            }else{
+                                 $js_arr[] = [
+                                    'js_num'=>$item['js_num'] + $total,
+                                    'id'=>$item['id'],
+                                    'sy_num'=>$item['sy_num'] - $total,
+                                    'bj_status'=>$item['bj_status'],
+                                    'zhycjs_time'=>$time,
+                                ];
+                                $total = 0;
+                            }
+                           
+                        }
+                     }
+                     if(!empty($check_sq_list)){
+                        $jstj_arr_ids[] = $v['id'];
+                     }
+                    
+                }
+               
+               
+
+
                 if($v['erp_warehouse'] == '12'){
                     //特殊仓处理方案
                     for($i=0;$i<$v['num'];$i++){
@@ -1934,7 +2101,20 @@ class Beihuogl extends Start_Controller {
              if(!empty($spec_arr)){
                 $this->db->insert_batch('specialstock',$spec_arr);
              }
-            
+             if(!empty($jstj_arr_ids)){
+                $this->db->where_in('id',$jstj_arr_ids);
+                $this->db->update('bhdcd',['is_tjjs'=>1]);
+             }
+             if(!empty($js_arr)){
+                foreach($js_arr as $item){
+                    $tmp_id = $item['id'];
+                    unset($item['id']);
+                    $tmp_arr = $item;
+                    $this->db->where('id',$tmp_id);
+                    $this->db->update('bhsq', $tmp_arr);
+                }
+             }
+             
              $this->db->where('dcd_no',$dcd_no);
              //$this->db->where('drd_no',$drd_no);
              $this->db->update('bhdcd',['status'=>3,'rk_time'=>$time,'is_rk'=>1]);
@@ -2714,4 +2894,28 @@ class Beihuogl extends Start_Controller {
             echo json_encode(['success'=>false,'msg'=>'请求方式错误']);exit;
         }
     }
+
+
+    public function _bhqzwg(){
+        if($this->input->method() == 'post'){
+            $id = $this->input->post('id');
+            if(empty($id)){
+                echo json_encode(['success'=>false,'msg'=>'请求数据异常']);exit;
+            }
+            $info = $this->bhsq->find("id = '".$id."'");
+            if(empty($info)){
+                 echo json_encode(['success'=>false,'msg'=>'检索数据异常']);exit;
+            }
+            if($info['sy_num'] <= 0){
+                echo json_encode(['success'=>false,'msg'=>'此申请已经完成,不可强制完成']);exit;
+            }
+            $this->bhsq->save([
+                'sy_num'=>0,
+                'bj_status'=>4,
+            ],$info['id']);
+             echo json_encode(['success'=>true,'msg'=>'强制完工']);exit;
+        }else{
+            echo json_encode(['success'=>false,'msg'=>'请求方式错误']);exit;
+        }
+    }
 }

File diff suppressed because it is too large
+ 207 - 0
template/erp/beihuogl_bjindex.html