load->library('session'); $this->load->_model('Model_bhsq','bhsq'); $this->load->_model("Model_shop","shop"); $this->load->_model("Model_typeclass","typeclass"); $this->load->_model("Model_bhccwl","bhccwl"); $this->load->_model("Model_logic_u9tools","logic_u9tools"); $this->load->_model("Model_whlabel","whlabel"); $this->load->_model("Model_goods","goods"); $this->load->_model("Model_settingtest","settingtest"); $this->load->_model("Model_bhdcd","bhdcd"); } //定义方法的调用规则 获取URI第二段值 public function _remap($arg,$arg_array) { if(!isset($_SESSION['api'])){ header('Location: /');exit; } if($arg == 'dyapply')// { $this->_dyapply(); } elseif($arg == 'dyapplyadd')// { $this->_dyapplyadd(); } elseif($arg == 'dyapplyedit')// { $this->_dyapplyedit($arg_array); } elseif($arg == 'dyapplygxzt')// { $this->_dyapplygxzt(); } elseif($arg == 'dyapplyexcel'){ $this->_dyapplyexcel(); } elseif($arg == 'ccwlshlist'){ $this->_ccwlshlist(); } elseif($arg == 'ccwlbhindex'){ $this->_ccwlbhindex(); }elseif($arg == 'dyapplysave'){ $this->_dyapplysave(); }elseif($arg == 'ccwlbhmake'){ $this->_ccwlbhmake(); }elseif($arg == 'ccwlbhedit'){ $this->_ccwlbhedit($arg_array); }elseif($arg == 'ccwleditxzbh'){ $this->_ccwleditxzbh(); }elseif($arg == 'ccwlbhsavexzbh'){ $this->_ccwlbhsavexzbh(); }elseif($arg == 'ccwldelitem'){ $this->_ccwldelitem(); }elseif($arg == 'ccwlbhsave'){ $this->_ccwlbhsave(); }elseif($arg == 'ckbhindex'){ $this->_ckbhindex(); }elseif($arg == 'ckbhedit'){ $this->_ckbhedit($arg_array); }elseif($arg == 'makeu9scd'){ $this->_makeu9scd($arg_array); }elseif($arg == 'showckbh'){ $this->_showckbh($arg_array); }elseif($arg == 'ddscscd'){ $this->_ddscscd(); }elseif($arg == 'ckdcd'){ $this->_ckdcd(); }elseif($arg == 'ckbherprk'){ $this->_ckbherprk($arg_array); }elseif($arg == 'bhdcdsave'){ $this->_bhdcdsave(); } else { $this->_index(); } } private function _index(){ exit('No direct script access allowed 1'); } //备货申请单的列表 private function _dyapply(){ if($this->input->method() === 'post'){ $page = $this->input->post('page',true); $perpage = $this->input->post('perpage',true); $sqr = $this->input->post('sqr',true); $sqr = trim($sqr); $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." "; if(!empty($sqr)){ $where .= " and sqr = ".$sqr." "; } if(!empty($shop_id)){ $where .= " and shop_id = ".$shop_id." "; }else{ $where .= " and shop_id in (".$shop_ids.") "; } if(!empty($plat_id)){ $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,plat_id,title,sku,sqr,sq_num,sq_status,add_time,update_time",$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->getSqStatus(); foreach($list as $k=>$v){ $list[$k]['shop_id'] = isset($shop_list[$v['shop_id']])?$shop_list[$v['shop_id']]:""; $list[$k]['plat_id'] = isset($plat_list[$v['plat_id']])?$plat_list[$v['plat_id']]:""; $list[$k]['sq_status'] = isset($status_list[$v['sq_status']])?$status_list[$v['sq_status']]:""; $list[$k]['add_time'] = date("Y-m-d",$v['add_time']); $str = ""; if($v['sq_status'] == 1 || $v['sq_status'] == 3){ $str .= "
"; } $list[$k]['update_time'] = $str; } $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); $this->_Template('beihuogl_dyapply',$this->data); } } //备货申请单的添加 private function _dyapplyadd(){ if($this->input->method() === 'post'){ $data = $this->input->post(); $time = strtotime(date("Y-m-d"),time()); $info = $this->bhsq->find("real_time >= ".$time,"*",'id desc'); if(empty($info)){ $num = 1; }else{ $arr = explode('-',$info['sb_no']); $num = (int)$arr[2]+1; } $num = str_pad($num, 3, '0', STR_PAD_LEFT); $sb_no = "SQ-".date("ymd")."-".$num; $insert_arr = []; $time = time(); foreach($data['title'] as $k=>$v){ $insert_arr[] = [ 'sb_no'=>$sb_no, 'sku'=>$data['sku'][$k], 'title'=>$data['title'][$k], 'shop_id'=>$data['shop_id'], 'plat_id'=>$data['plat_id'], 'sqr'=>$data['sqr'], 'sq_num'=>$data['sq_num'][$k], 'ccwl_num'=>$data['sq_num'][$k], 'ck_num'=>$data['sq_num'][$k], 'sq_status'=>1, 'remark'=>$data['remark'], 'add_time'=>$time, 'real_time'=>$time, 'update_time'=>$time, ]; } $r =$this->db->insert_batch('bhsq',$insert_arr); if($r){ echo json_encode(['code'=>1,'msg'=>'添加成功']); }else{ echo json_encode(['code'=>-1,'msg'=>'添加失败']); } exit; }else{ $plat_list = $this->typeclass->find_all("classid = 32 and id != 2297","id,title"); $this->data['plat_list'] = $plat_list; $this->_Template('beihuogl_dyapplyadd',$this->data); } } //备货申请单的 修改 private function _dyapplyedit($arg_array){ if($this->input->method() === 'post'){ $data = $this->input->post(); $id = $data['id']; $update_arr = [ 'shop_id'=>$data['shop_id'], 'plat_id'=>$data['plat_id'], 'sqr'=>$data['sqr'], 'sq_num'=>$data['sq_num'], 'ccwl_num'=>$data['sq_num'], 'ck_num'=>$data['sq_num'], 'sku'=>$data['sku'], 'remark'=>$data['remark'], ]; $r = $this->bhsq->save($update_arr,$id); if($r){ echo json_encode(['msg'=>'添加成功','success'=>true]); }else{ echo json_encode(['msg'=>'添加失败','success'=>false]); } exit; }else{ $id = $arg_array[0]; $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; $this->data['info'] = $info; $this->_Template('beihuogl_dyapplyedit',$this->data); } } //备货申请单的 状态申请 如 发布 或者取消 private function _dyapplygxzt(){ if($this->input->method() === 'post'){ $data = $this->input->post(); $id = (int)$data['id']; $type = (int)$data['status']; $update_arr = []; $update_arr['sq_status'] = $type; if($type == 2){ $update_arr['public_time'] = time(); } $r = $this->bhsq->save($update_arr,$id); if($r){ echo json_encode(['msg'=>'修改成功','success'=>true]); }else{ echo json_encode(['msg'=>'修改失败','success'=>false]); } exit; }else{ echo json_encode(['success'=>false,'msg'=>'请求失败']); } } //备货申请单的 private function _dyapplysave(){ if($this->input->method() === 'post'){ $data = $this->input->post(); $id = (int)$data['id']; $val = $this->input->post('val',true); $column = $data['column']; if($column == 'ccwl_num'){ $update_arr = [ 'ccwl_num'=>(int)$val, 'ck_num'=>(int)$val, ]; }elseif($column == 'sku'){ $update_arr = [ 'sku'=>$val, ]; }elseif($column == 'ck_num'){ $update_arr = [ 'ck_num'=>(int)$val, ]; }elseif($column == 'drck'){ $update_arr = [ 'drck'=>(int)$val, ]; }else{ echo json_encode(['msg'=>'修改信息不合规','success'=>false]); exit; } $r = $this->bhsq->save($update_arr,$id); if($r){ echo json_encode(['msg'=>'修改成功','success'=>true]); }else{ echo json_encode(['msg'=>'修改失败','success'=>false]); } exit; }else{ echo json_encode(['success'=>false,'msg'=>'请求失败']); } } private function _dyapplyexcel(){ if($this->input->method() === 'post'){ $data = $this->input->post('list',true); if(empty($data)){ $json_data = $this->input->raw_input_stream; $tmp_data = json_decode($json_data,true); $data = $tmp_data['list']; if(empty($data)){ echo json_encode(['success'=>false,'msg'=>'未获取要保存的数据']); exit; } } $shop_list = $this->shop->find_all("1=1","id,shortname,type"); $shop_list = array_column($shop_list,null,'shortname'); $time = strtotime(date("Y-m-d"),time()); $info = $this->bhsq->find("real_time >= ".$time,"*",'id desc'); if(empty($info)){ $num = 1; }else{ $arr = explode('-',$info['sb_no']); $num = (int)$arr[2]+1; } $time = time(); $num = str_pad($num, 3, '0', STR_PAD_LEFT); $sb_no = "SQ-".date("ymd")."-".$num; $insert_arr = []; $error_list= []; foreach($data as $k=>$v){ $shopshortname = trim($v[4]); $shop_info = isset($shop_list[$shopshortname])?$shop_list[$shopshortname]:[]; if(empty($shop_info)){ $error_list[] = [ 'msg'=>"第".($k+1).'行店铺不存在,请核对表格信息'.$shopshortname, ]; continue; } $num = (int)$v[3]; if(empty($num)){ $error_list[] = [ 'msg'=>"第".($k+1).'行数量不能为空,请核对表格信息', ]; continue; } $tmp_time = trim($v[0]); if (preg_match('/^\d{4}-\d{2}-\d{2}$/', $tmp_time)) { $add_time = strtotime($tmp_time); }else{ $error_list[] = [ 'msg'=>"第".($k+1).'行日期格式不正确,请核对表格信息', ]; continue; } if(empty($v[5])){ $error_list[] = [ 'msg'=>"第".($k+1).'行申请人信息不能为空,请核对表格信息', ]; continue; } if(empty($v[1])){ $error_list[] = [ 'msg'=>"第".($k+1).'行产品信息不能为空,请核对表格信息', ]; continue; } $insert_arr[] = [ 'sb_no'=>$sb_no, 'sku'=>trim($v[2]), 'title'=>trim($v[1]), 'shop_id'=>$shop_info['id'], 'plat_id'=>$shop_info['type'], 'sqr'=>trim($v[5]), 'sq_num'=>$num, 'ccwl_num'=>$num, 'ck_num'=>$num, 'sq_status'=>1, 'remark'=>$v[6], 'add_time'=>$add_time, 'real_time'=>$time, 'update_time'=>$time, ]; } $r =$this->db->insert_batch('bhsq',$insert_arr); if($r){ echo json_encode(['success'=>true,'msg'=>'添加成功','error_list'=>$error_list]); }else{ echo json_encode(['success'=>false,'msg'=>'添加失败','error_list'=>$error_list]); } exit; }else{ echo json_encode(['success'=>true,'msg'=>'请求失败']); exit; } } //仓储物流部的备货申请单的列表 private function _ccwlshlist(){ if($this->input->method() === 'post'){ $page = $this->input->post('page',true); $perpage = $this->input->post('perpage',true); $sqr = $this->input->post('sqr',true); $sqr = trim($sqr); $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 = "sq_status = 2 and ccwl_status = 0 "; $where .= " and add_time >= ".$ktime." and add_time < ".$jtime." "; if(!empty($sqr)){ $where .= " and sqr = ".$sqr." "; } if(!empty($shop_id)){ $where .= " and shop_id = ".$shop_id." "; }else{ $where .= " and shop_id in (".$shop_ids.") "; } if(!empty($plat_id)){ $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,plat_id,title,sku,sqr,sq_num,ccwl_num,add_time,update_time",$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'); foreach($list as $k=>$v){ $list[$k]['shop_id'] = isset($shop_list[$v['shop_id']])?$shop_list[$v['shop_id']]:""; $list[$k]['plat_id'] = isset($plat_list[$v['plat_id']])?$plat_list[$v['plat_id']]:""; $list[$k]['add_time'] = date("Y-m-d",$v['add_time']); $list[$k]['sku'] = $v['sku']." "; $list[$k]['ccwl_num'] = $v['ccwl_num']." "; $list[$k]['update_time'] = "驳回"; } $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); $this->_Template('beihuogl_ccwlshlist',$this->data); } } //仓储物流合成备货单 private function _ccwlbhmake(){ if($this->input->method() === 'post'){ $data = $this->input->post(); $bh_no = $data['bh_no']; $select_id = $data['arr_id']; if(empty($select_id)){ echo json_encode(['success'=>false,'msg'=>'至少选一个呀!!!']); exit; } if(empty($bh_no)){ $tmp_time = strtotime(date("Y-m-d"),time()); $num = $this->bhccwl->find_count("create_time >= ".$tmp_time); $num = $num+1; $num = str_pad($num, 3, '0', STR_PAD_LEFT); $bh_no = "BH-".date("ymd")."-".$num; } $list = $this->bhsq->find_all('id in ('.implode(',',$select_id).')'); foreach($list as $k=>$v){ if(empty($v['sku'])){ echo json_encode(['success'=>false,'msg'=>'提交的数据中有的sku为空,请核对填写信息']); exit; } } $classid = $this->logic_u9tools->getClass(); $typeclass = $this->logic_u9tools->getTypeClass(); foreach($list as $k=>$v){ $whlabel_info = $this->goods->find("sku = '".$v['sku']."'",'sku,features,jm','id desc'); if(empty($whlabel_info)){ $whlabel_info = $this->whlabel->find("sku = '".$v['sku']."'",'sku,features','id desc'); if(empty($whlabel_info)){ echo json_encode(['success'=>false,'msg'=>$v['sku'].'未在进销存浏览那找到对应信息']); exit; } $r = $this->logic_u9tools->getOneU9bmHasGift($whlabel_info['features'],$classid,$typeclass); $this->bhsq->save([ 'jm'=>$r['jm'], 'drck'=>$this->getU9Drck($whlabel_info['features']), 'features'=>$whlabel_info['features'], ],$v['id']); }else{ $this->bhsq->save([ 'jm'=>$whlabel_info['jm'], 'drck'=>$this->getU9Drck($whlabel_info['features']), 'features'=>$whlabel_info['features'], ],$v['id']); } } $this->db->trans_start(); $this->db->where_in('id',$select_id); $this->db->update('bhsq',[ 'bh_no'=>$bh_no, 'sq_status'=>4, 'ccwl_status'=>1, ]); $this->db->select('SUM(ccwl_num) as total_ccwl_num'); $this->db->where_in('id',$select_id); $query = $this->db->get('bhsq'); $result = $query->row(); $total_ccwl_num = $result->total_ccwl_num? $result->total_ccwl_num:0; $time = time(); $this->bhccwl->insert([ 'bh_no'=>$bh_no, 'status'=>0, 'num'=>$total_ccwl_num, 'create_time'=>$time, 'update_time'=>$time, ]); if($this->db->trans_status() === FALSE){ $this->db->trans_rollback(); echo json_encode(['success'=>false,'msg'=>'生成备货单失败']); exit; }else{ $this->db->trans_commit(); echo json_encode(['success'=>true,'msg'=>'生成备货单成功']); exit; } }else{ echo json_encode(['success'=>false,'msg'=>'请求失败']); exit; } } private function getU9Drck($features){ if(stripos($features,'-126-') !== false) { $drck = '12003';//进入发条库 } else if(stripos($features,'-127-') !== false) { $drck = '12004';//进入发块库 } else { $drck = '12006';//其它进入完成库 } return $drck; } //仓储物流部的备货单列表 private function _ccwlbhindex(){ if($this->input->method() === 'post'){ $page = $this->input->post('page',true); $perpage = $this->input->post('perpage',true); $bh_no = $this->input->post('bh_no',true); $status = $this->input->post('status',true); $ktime = $this->input->post('ktime',true); $jtime = $this->input->post('jtime',true); $ktime = strtotime($ktime); $jtime = strtotime($jtime); $where = "create_time >= ".$ktime." and create_time < ".$jtime." "; if(!empty($bh_no)){ $where .= " and bh_no = '".$bh_no."' "; } if($status > -1){ $where .= " and status = ".$status." "; } //数据排序 $order_str = "id desc"; if(empty($page)) { $start = 0; $perpage = 1; } else { $start = ($page - 1)*$perpage; } $list = $this->bhccwl->find_all($where,"id,bh_no,status,create_time,public_time,update_time",$order_str,$start,$perpage); if(empty($list)){ $rows = array('total'=>0,'over'=>1,'pagenum'=>0,'rows'=>([])); echo json_encode($rows);exit; } $status_list = $this->bhccwl->getStatus(); foreach($list as $k=>$v){ $list[$k]['status'] = isset($status_list[$v['status']])?$status_list[$v['status']]:""; $list[$k]['create_time'] = date("Y-m-d",$v['create_time']); $list[$k]['public_time'] = empty($v['public_time'])?"":date("Y-m-d",$v['public_time']); $str = ""; if($v['status'] == 0){ $str .= ""; } $list[$k]['update_time'] = $str; } $total = $this->bhccwl->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{ $this->_Template('beihuogl_ccwlbhindex',$this->data); } } //仓储物流部备货 在编辑页面添加数据 private function _ccwlbhsavexzbh(){ if($this->input->method() === 'post'){ $data = $this->input->post(); $select_id = $data['select_id']; $id = $data['id']; $bh_no = $data['bh_no']; if(empty($select_id)){ echo json_encode(['success'=>false,'msg'=>'至少选一个呀!!!']); exit; } $info = $this->bhccwl->read($id); if(empty($info)){ echo json_encode(['success'=>false,'msg'=>'数据不存在']); exit; } if($info['bh_no'] != $bh_no){ echo json_encode(['success'=>false,'msg'=>'数据信息异常联系技术处理']); exit; } $bh_no = $info['bh_no']; $list = $this->bhsq->find_all('id in ('.implode(',',$select_id).') ' ); foreach($list as $k=>$v){ if(empty($v['sku'])){ echo json_encode(['success'=>false,'msg'=>'提交的数据中有的sku为空,请核对填写信息']); exit; } if(!empty($v['bh_no'])){ echo json_encode(['success'=>false,'msg'=>'提交的数据中有的已经被调用,请联系技术核对']); exit; } } $classid = $this->logic_u9tools->getClass(); $typeclass = $this->logic_u9tools->getTypeClass(); foreach($list as $k=>$v){ $whlabel_info = $this->goods->find("sku = '".$v['sku']."'",'sku,features,jm','id desc'); if(empty($whlabel_info)){ $whlabel_info = $this->whlabel->find("sku = '".$v['sku']."'",'sku,features','id desc'); if(empty($whlabel_info)){ echo json_encode(['success'=>false,'msg'=>$v['sku'].'未在进销存浏览那找到对应信息']); exit; } if(empty($v['jm'])){ $r = $this->logic_u9tools->getOneU9bmHasGift($whlabel_info['features'],$classid,$typeclass); $this->bhsq->save([ 'jm'=>$r['jm'], 'drck'=>$this->getU9Drck($whlabel_info['features']), 'features'=>$whlabel_info['features'], ],$v['id']); } $list[$k]['jm'] = $r['jm']; }else{ $this->bhsq->save([ 'jm'=>$whlabel_info['jm'], 'drck'=>$this->getU9Drck($whlabel_info['features']), 'features'=>$whlabel_info['features'], ],$v['id']); $list[$k]['jm'] = $whlabel_info['jm']; } } $status_list = $this->bhccwl->getStatus(); $info['status_show'] = isset($status_list[$info['status']])?$status_list[$info['status']]:""; $plat_list = $this->typeclass->find_all("classid = 32 and id != 2297","id,title"); $plat_list = array_column($plat_list,'title','id'); $shop_list = $this->shop->find_all("1=1","id,shopname"); $shop_list = array_column($shop_list,'shopname','id'); foreach($list as $k=>$v){ $list[$k]['shop_id'] = isset($shop_list[$v['shop_id']])?$shop_list[$v['shop_id']]:""; $list[$k]['plat_id'] = isset($plat_list[$v['plat_id']])?$plat_list[$v['plat_id']]:""; $list[$k]['public_time'] = date("Y-m-d",$v['public_time']); $list[$k]['bh_no'] = $info['bh_no']; } echo json_encode(['success'=>true,'msg'=>'编辑成功','data'=>$list]);exit; }else{ echo json_encode(['success'=>false,'msg'=>'请求失败']); exit; } } private function _ccwlbhedit($arg_array){ if($this->input->method() === 'post'){ $select_id = $this->input->post('arr_id',true); if(empty($select_id)){ echo json_encode(['success'=>false,'msg'=>'至少选一个呀!!!']); exit; } $id = $this->input->post('id',true); $info = $this->bhccwl->read($id); $bh_no = $info['bh_no']; $this->db->where_in('id',$select_id); $this->db->update('bhsq',[ 'bh_no'=>$bh_no, 'sq_status'=>4, 'ccwl_status'=>1, ]); $this->db->select('SUM(ccwl_num) as total_ccwl_num'); $this->db->where_in('id',$select_id); $query = $this->db->get('bhsq'); $result = $query->row(); $total_ccwl_num = $result->total_ccwl_num? $result->total_ccwl_num:0; $time = time(); $this->bhccwl->save([ 'num'=>$total_ccwl_num, 'update_time'=>$time, ],$info['id']); echo json_encode(['success'=>true,'msg'=>'修改成功']);exit; }else{ $id = $arg_array[0]; $info = $this->bhccwl->find("id = ".$id); $list = $this->bhsq->find_all("bh_no = '".$info['bh_no']."' and sq_status = 4 and ccwl_status = 1"); $status_list = $this->bhccwl->getStatus(); $info['status_show'] = isset($status_list[$info['status']])?$status_list[$info['status']]:""; $plat_list = $this->typeclass->find_all("classid = 32 and id != 2297","id,title"); $plat_list = array_column($plat_list,'title','id'); $shop_list = $this->shop->find_all("1=1","id,shopname"); $shop_list = array_column($shop_list,'shopname','id'); foreach($list as $k=>$v){ $list[$k]['shop_id'] = isset($shop_list[$v['shop_id']])?$shop_list[$v['shop_id']]:""; $list[$k]['plat_id'] = isset($plat_list[$v['plat_id']])?$plat_list[$v['plat_id']]:""; $list[$k]['public_time'] = date("Y-m-d",$v['public_time']); } // $this->data['info'] = $info; $this->data['list'] = $list; $this->data['info'] = $info; $this->_Template('beihuogl_ccwlbhedit',$this->data); } } private function _ccwldelitem(){ if($this->input->method() === 'post'){ $data = $this->input->post(); $id = $data['id']; $bh_no = $data['bh_no']; $info = $this->bhsq->read($id); $ccwl_num = $info['ccwl_num']; if(empty($info)){ echo json_encode(['success'=>false,'msg'=>'数据不存在']);exit; } if(empty($info['bh_no'])){ if($info['sq_status'] == 2 && $info['ccwl_status'] == 0){ echo json_encode(['success'=>true,'msg'=>'删除成功']);exit; }else{ echo json_encode(['success'=>false,'msg'=>'数据信息异常联系技术处理']);exit; } } if($info['bh_no'] != $bh_no){ echo json_encode(['success'=>false,'msg'=>'数据信息异常联系技术处理']);exit; } $ccwl_info = $this->bhccwl->find("bh_no = '".$info['bh_no']."'"); $ccwl_info['num'] = $ccwl_info['num'] - $ccwl_num; $this->db->trans_start(); $this->bhccwl->save([ 'num'=>$ccwl_info['num'], ],$ccwl_info['id']); $this->bhsq->save([ 'sq_status'=>2, 'ccwl_status'=>0, 'bh_no'=>'' ],$id); if($this->db->trans_status() === FALSE){ $this->db->trans_rollback(); echo json_encode(['success'=>false,'msg'=>'删除失败']);exit; }else{ $this->db->trans_commit(); echo json_encode(['success'=>true,'msg'=>'删除成功']);exit; } }else{ echo json_encode(['success'=>false,'msg'=>'请求失败']);exit; } } private function _ccwleditxzbh(){ if($this->input->method() === 'post'){ $data = $this->input->post(); //超过三月没审核的 就不展示了 $time = time() - 60*24*3600; $where = "sq_status = 2 and ccwl_status = 0 and public_time > ".$time." "; if(!empty($data['sqr'])){ $where .= " and sqr = '".$data['sqr']."' "; } if(!empty($data['shop_id'])){ $where .= " and shop_id = ".$data['shop_id']." "; } if(!empty($data['plat_id'])){ $where .= " and plat_id = ".$data['plat_id']." "; } if(!empty($data['sku'])){ $where .= " and sku = '".$data['sku']."' "; } $order_str = "id desc"; $list = $this->bhsq->find_all($where,"*",$order_str,0,20); $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 and id != 2297","id,title"); $plat_list = array_column($plat_list,'title','id'); foreach($list as $k=>$v){ $list[$k]['shop_id'] = isset($shop_list[$v['shop_id']])?$shop_list[$v['shop_id']]:""; $list[$k]['plat_id'] = isset($plat_list[$v['plat_id']])?$plat_list[$v['plat_id']]:""; $list[$k]['public_time'] = date("Y-m-d",$v['public_time']); } if(empty($list)){ echo json_encode(['success'=>false,'msg'=>'查询失败']);exit; }else{ echo json_encode(['success'=>true,'msg'=>'查询成功','data'=>$list]);exit; } }else{ $data = $this->input->get(); $this->data['id'] = $data['id']; $this->data['bh_no'] = $data['bh_no']; $plat_list = $this->typeclass->find_all("classid = 32 and id != 2297","id,title"); $this->data['plat_list'] = $plat_list; $this->_Template('beihuogl_ccwleditxzbh',$this->data); } } private function _ccwlbhsave(){ if($this->input->method() === 'post'){ $data = $this->input->post(); $id = $data['id']; $val = $data['val']; $column = $data['column']; $update_arr = []; if($column == 'status'){ $update_arr = [ 'status'=>(int)$val, 'update_time'=>time(), 'public_time'=>time(), ]; }else{ echo json_encode(['success'=>false,'msg'=>'请求参数未设置']);exit; } $r = $this->bhccwl->save($update_arr,$id); if($r){ echo json_encode(['success'=>true,'msg'=>'修改成功']);exit; }else{ echo json_encode(['success'=>false,'msg'=>'修改失败']);exit; } }else{ echo json_encode(['success'=>false,'msg'=>'请求失败']);exit; } } //仓库的备货单列表 private function _ckbhindex(){ if($this->input->method() === 'post'){ $page = $this->input->post('page',true); $perpage = $this->input->post('perpage',true); $bh_no = $this->input->post('bh_no',true); $status = $this->input->post('status',true); $ktime = $this->input->post('ktime',true); $jtime = $this->input->post('jtime',true); $ktime = strtotime($ktime); $jtime = strtotime($jtime); $where = "public_time >= ".$ktime." and public_time < ".$jtime." and status = 1 "; if(!empty($bh_no)){ $where .= " and bh_no = '".$bh_no."' "; } if($status > -1){ $where .= " and status = ".$status." "; } //数据排序 $order_str = "id desc"; if(empty($page)) { $start = 0; $perpage = 1; } else { $start = ($page - 1)*$perpage; } $list = $this->bhccwl->find_all($where,"id,bh_no,ck_status,public_time,ckpublic_time",$order_str,$start,$perpage); if(empty($list)){ $rows = array('total'=>0,'over'=>1,'pagenum'=>0,'rows'=>([])); echo json_encode($rows);exit; } $status_list = $this->bhccwl->getCkStatus(); foreach($list as $k=>$v){ $list[$k]['bh_no'] = "".$v['bh_no']."
".$v['dcd_no']."