where("id=".I('post.bachid'))->save($info)){ $session_config=I('session.ly_admin_');//获取登陆的session值 $uid = $session_config['user_auth']['uid']; $large = M('qcode_large'); $small = M('qcode_small'); $l_flow = M('reset_flow'); $s_flow = M('qcode_liushui'); $bach_info = $bach->where('id='.I('post.bachid'))->field('id,matter_id,matter_type,supplier_code,matter_no,manufacture_date,print_date,bach_num')->find(); $largeNum = $large->where('bach_id='.I('post.bachid'))->count(); $smallNum = $small->where('bach_id='.I('post.bachid'))->count(); $l_map['userid'] = $uid; $l_map['product_id'] = $bach_info['matter_id']; $l_map['bach_num'] = $bach_info['bach_num']; $large_flow = $l_flow->where($l_map)->find(); $new_l_flow = $large_flow['l_flow'] - $largeNum;//删除后恢复的大件流水号 $l_flow->where($l_map)->setField('l_flow',$new_l_flow);//操作更新 $onlycode = '9092'.intTochar($bach_info['matter_type'],2).intTochar($bach_info['supplier_code'],12).intTochar($bach_info['matter_no'],20).$bach_info['manufacture_date'].$bach_info['print_date']; $s_map['user_id'] = $uid; $s_map['onlycode'] = $onlycode; $small_flow = $s_flow->where($s_map)->find(); $new_s_flow = $small_flow['last_num'] - $smallNum;//删除后恢复的小件流水号 $s_flow->where($s_map)->setField('last_num',$new_s_flow); $data['success']=true; $data['message']="删除成功"; $this->ajaxReturn($data); }else{ $data['error']=false; $data['message']="删除失败"; $this->ajaxReturn($data); } } public function QcodeCompanyDel(){ //产品删除 if(IS_POST){ if(empty($_POST)){ $this->error('请至少选择一个选项'); }else{ $bar = D('QcodeCompany'); $id = implode(',',$_POST['ids']); $return = $bar->DelQcodeCompany($id); if($return){ $this->success('删除成功', U('Company')); }else{ $this->error('删除失败'); } } }else{ $id = $_GET['id']; $bar = D('QcodeCompany'); $return = $bar->DelQcodeCompany($id); if($return){ $this->success('删除成功', U('Company')); }else{ $this->error('删除失败'); } } } public function QcodeCompanyAdd(){//生产厂商的添加和修改 if (IS_POST ) { $bar_object = D('QcodeCompany'); $data= $bar_object->create(); if ($data) { if(I('post.id')){//有id是修改 if ($bar_object->save($data)) { $this->success('修改成功', U('Company')); } else { $this->error('修改失败'); } }else {//不存在id,新增 if ($bar_object->add($data)) { $this->success('新增成功', U('Company')); } else { $this->error('新增失败'); } } } else { $this->error($bar_object->getError()); } } else { //使用FormBuilder快速建立表单页面。 $builder = new \Common\Builder\FormBuilder(); $builder->setMetaTitle('编辑厂商') //设置页面标题 ->setPostUrl(U('QcodeCompanyAdd')) //设置表单提交地址 ->addFormItem('id', 'hidden', 'ID', 'ID') ->addFormItem('company_name', 'text', '名称', '请输入供应商名称') ->addFormItem('company_code','num', '供应商编码', '请输入供应商唯一编码') ->addFormItem('postcode','num', '邮政编码', '邮政编码') ->addFormItem('phone','num', '联系电话', '请输入联系电话') ->addFormItem('company_addres','text', '地址', '请输入供应商地址') ->setFormData(D('QcodeCompany')->find(I('get.id'))) ->display(); } } public function Company(){//生产厂商列表 // 搜索 $keyword = I('keyword', '', 'string'); $condition = array('like', '%' . $keyword . '%'); $map['company_name|company_code'] = array(//查询条件数组 $condition, $condition, '_multi' => true, ); $p = !empty($_GET["p"]) ? $_GET['p'] : 1; $product_object = D('qcode_company'); $data_list= $product_object ->page($p, 15) ->where($map) ->order('id asc') ->select(); $page = new Page( $product_object->where($map)->count(), 50 ); // 使用Builder快速建立列表页面。 $builder = new \Common\Builder\ListBuilder(); $builder->setMetaTitle('生产厂商管理') // 设置页面标题 ->addTopButton('addnew',['href'=>U(MODULE_NAME . '/' . CONTROLLER_NAME . '/QcodeCompanyAdd')]) // 添加新增按钮 ->addTopButton('delete',['href'=>U(MODULE_NAME . '/' . CONTROLLER_NAME . '/QcodeCommanyDel')]) // 添加删除按钮 ->setSearch( '请输入供应商名称或者供应商编码', U('Company')//重新进入到Productile页面; ) ->addTableColumn('id', 'ID') ->addTableColumn('company_name', '名称') ->addTableColumn('company_code', '厂商编码') ->addTableColumn('postcode', '邮政编码') ->addTableColumn('phone', '联系电话') ->addTableColumn('company_addres', '地址') /*->addTableColumn('title', '自定义')*/ ->addTableColumn('right_button', '操作', 'btn') ->setTableDataList($data_list) // 数据列表 ->setTableDataPage($page) // 数据列表分页 ->addRightButton('edit',['href'=>U(MODULE_NAME . '/' . CONTROLLER_NAME . '/QcodeCompanyAdd',array( 'id' => '__data_id__', ))]) // 添加编辑按钮 ->addRightButton('delete',['href'=>U(MODULE_NAME . '/' . CONTROLLER_NAME . '/QcodeCompanyDel',array( 'id' => '__data_id__', ))]) // 添加删除按钮 ->display(); } public function Dama(){//打码统计页面 $this->display(); } public function damacount(){//打码统计详情页面 $session_config=I('session.ly_admin_'); $uid = $session_config['user_auth']['uid']; $user = M('admin_user'); $user_info = $user->where('id='.$uid)->find(); $product_id = explode(',',$user_info['product_id']); $map['id'] = array('in',$product_id); $product = M('qcode_product'); $list = $product->where($map)->field('id,product_name')->select(); $db=M('qcode_bach'); $large = M('qcode_large'); $small = M('qcode_small'); $where['userid'] = $uid; $where['bach_status'] = 0; $damalist=$db->where($where) ->field('id') ->select(); $damalist = array_column($damalist,'id'); if ($damalist){ $option['bach_id'] = array('in',$damalist); } $option['userid'] = $uid; $largeNum = $large->where($option)->count(); $smallNum = $small->where($option)->count(); $total = $largeNum + $smallNum; $this->assign('list',$list); $this->assign('total',$total); $this->display(); } public function DamaCountApi(){//打码量统计产品列表 $page=$_GET['page']; $damalist['pagesize']=$_GET['rows']?$_GET['rows']:10; $pagenum=($page-1)* $damalist['pagesize'];//当前页码 if($pagenum<0){ $pagenum=0; } $map = array(); if (!empty($_GET['sqrcd'])){ $map['bach_num'] = $_GET['sqrcd']; } if ($_GET['sysCdNm'] > 0){ $map['matter_id'] = $_GET['sysCdNm']; } $session_config=I('session.ly_admin_'); $uid = $session_config['user_auth']['uid']; $map['userid'] = $uid; if($_GET['startDate']){//有开始日期 $statrtime=strtotime($_GET['startDate']); $endtime=strtotime($_GET['endDate']); $map['creat_time']=array(array('egt',$statrtime),array('elt',$endtime),'AND'); } $map['bach_status'] = 0;//未删除批次 $db=M('qcode_bach'); $damalist['rows']=$db->where($map) ->field('id,bach_num,matter_no,matter_name,matter_size') ->order( "id desc") ->limit($pagenum,$damalist['pagesize']) ->select(); $largeNum = M('qcode_large'); $smallNum = M('qcode_small'); foreach ($damalist['rows'] as $key=>$value){ $damalist['rows'][$key]['largeTotal'] = $largeNum->where('bach_id='.$value['id'])->count(); $damalist['rows'][$key]['smallTotal'] = $smallNum->where('bach_id='.$value['id'])->count(); } $count = $db->where($map)->count(); $damalist['pagesize']=$_GET['rows']?$_GET['rows']:10;//每页显示的记录数 $damalist['total']=$count;//总的记录数 echo json_encode($damalist); } public function QcodeProductDel(){//产品删除 if(IS_POST){ if(empty($_POST)){ $this->error('请至少选择一个选项'); }else{ $bar = D('QcodeProduct'); $id = implode(',',$_POST['ids']); $return = $bar->DelQcodeProduct($id); if($return){ $this->success('删除成功', U('Product')); }else{ $this->error('删除失败'); } } }else{ $id = $_GET['id']; $bar = D('QcodeProduct'); $return = $bar->DelQcodeProduct($id); if($return){ $this->success('删除成功', U('Product')); }else{ $this->error('删除失败'); } } } public function QcodeProductAdd(){//产品添加或者是修改 if (IS_POST ) { $bar_object = D('QcodeProduct'); $data= $bar_object->create(); if ($data) { if(I('post.id')){//有id是修改 if ($bar_object->save($data)) { $this->success('修改成功', U('Product')); } else { $this->error('修改失败'); } }else {//不存在id,新增 if ($bar_object->add($data)) { $this->success('新增成功', U('Product')); } else { $this->error('新增失败'); } } } else { $this->error($bar_object->getError()); } } else { //使用FormBuilder快速建立表单页面。 $builder = new \Common\Builder\FormBuilder(); $builder->setMetaTitle('编辑产品') //设置页面标题 ->setPostUrl(U('QcodeProductAdd')) //设置表单提交地址 ->addFormItem('id', 'hidden', 'ID', 'ID') ->addFormItem('product_name', 'text', '名称', '请输入名称') ->addFormItem('product_code', 'text', '编码', '请输入编码') ->addFormItem('product_size','text', '规格', '规格单位为毫米') ->addFormItem('product_num','text', '产品批次', '产品批次') ->addFormItem('temple','text', '产品代号', '产品代号') ->setFormData(D('QcodeProduct')->find(I('get.id'))) ->display(); } } public function product(){//产品列表 // 搜索 $session_config=I('session.ly_admin_'); $keyword = I('keyword', '', 'string'); $condition = array('like', '%' . $keyword . '%'); $map['product_name|product_code'] = array(//查询条件数组 $condition, $condition, '_multi' => true, ); $classification = I('classification', '', 'string'); if ($classification != '03'){ $map['product_code'] = array('like','%'.$classification.'%'); } $uid = $session_config['user_auth']['uid']; $user = M('admin_user'); $user_product = $user->where('id='.$uid)->field('product_id')->find(); $user_product = explode(',',$user_product['product_id']); $map['id'] = array('not in',$user_product); $map['id'] = array('gt',27); $p = !empty($_GET["p"]) ? $_GET['p'] : 1; $product_object = D('qcode_product'); $count = $product_object->where($map)->count();// 查询满足要求的总记录数 $Page = new \Think\Page($count,25);// 实例化分页类 传入总记录数和每页显示的记录数 $show = $Page->show();// 分页显示输出 $data_list= $product_object->page($p.',10')->where($map)->order('id asc')->select();//所有未选中产品列表 //辅料存货分类 $qcode_classification = M('qcode_classification'); $product_classification = $qcode_classification->where('status=1')->order('id asc')->select(); //已选择产品列表 $where['id'] = array('in',$user_product); $list= $product_object->where($where)->order('id asc')->select(); $this->assign('search',$keyword); $this->assign('classification',$classification); $this->assign('product_classification',$product_classification); $this->assign('user_product',$user_product); $this->assign('list',$data_list); $this->assign('data',$list); $this->assign('page',$show); $this->display('product'); } //更新用户生产产品 public function updateProduct(){ if (IS_POST){ $session_config=I('session.ly_admin_'); $uid = $session_config['user_auth']['uid']; $user = M('admin_user'); $user_data = $user->where('id='.$uid)->field('product_id')->find(); $user_product = $user_data['product_id']; $id = I('post.id'); $ids = explode(',',$id); if(I('post.status')=="1"){//增加产品 $new_product = array(); if (!isset($user_product)){//第一次增加 $data['product_id'] = $id; }else{ $user_product = explode(',',$user_product); $new_product = array_unique(array_merge($ids,$user_product)); sort($new_product); $new_product_str = implode(',',$new_product); $data['product_id'] =$new_product_str; } $res = $user->where('id='.$uid)->save($data); $this->ajaxReturn(['status'=>1,'msg'=>'更新成功']); }else{//删除产品 $data['product_id'] = $id; $res = $user->where('id='.$uid)->save($data); $this->ajaxReturn(['status'=>1,'msg'=>'更新成功']); } } } public function Productajax(){//动态调用产品或者供应商相关信息 if(I('get.type')=="product"){//产品列表 $condition['userid']=I('get.userid'); $condition['product_id']=I('get.id'); $l_flow=M('reset_flow')->field('l_flow,bach_num')->where($condition)->find(); $model=M('qcode_product'); $field='product_size,product_num,product_name,id,temple,product_code'; $product=$model->field($field)->where('id='.I('get.id'))->select(); $product['l_flow']=$l_flow['l_flow']+1; $product['bach_num']=$l_flow['bach_num']?($l_flow['bach_num']+1):(date('Y',time())."00000"+1); $this->ajaxReturn($product); } if(I('get.type')=="company"){//供应商列表 $model=M('admin_user'); $field='nickname,postcode,mobile,company_address,id,printer_code'; $company=$model->field($field)->where('id='.I('get.id'))->select(); $this->ajaxReturn($company) ; } } public function AddPrint(){//保存待打印的产品记录 //var_dump(I('post.')); $data=I('post.'); if(!empty($data)) {//提交的数据不为空 $data['company_info']=I('post.company_address')." ".I('post.postname')." ".I('post.phone'); $data['bd_num']=0;//保存就默认为0; $data['lable_type']=I('post.label_type'); M('qcode_print')->add($data);//保存数据 $this->success('保存成功','index.php?s=/Admin/Qcode/large'); }else{ $this->error('保存失败'); // $this->ajaxReturn(['status'=>1,'msg'=>'删除成功']); /* $this->error['errno'] = "添加数据失败"; $this->success($this->error['errno'], '',100);*/ } } public function Large(){ /*var_dump(THINK_VERSION); die();*/ $companylist=M('qcode_company')->field('company_name,postcode,phone,company_addres,company_code,id')->select(); $productlist=M('qcode_product')->field('product_name,id,product_size,product_num,temple,product_code')->select(); $this->assign('companylist',$companylist); $this->assign('productlist',$productlist); $this->display(); } public function Print_ewm(){//生成二维码 $time=time(); if($_GET['temple']==1){//使用新模板 $fixedheadcode = "90";//固定的头部编码2位; if ($_GET['label_type'] == 1) {//大件标签 $type = "92"; $big_num="095";//大件含有小件数量 $big_liushui=$_GET['big_liushui'];//大件流水号 $big_weight=$_GET['big_weight'];//大件重量 $big_yuliu=$_GET['big_yuliu'];//大件预留号 } if ($_GET['label_type'] == 2) {//小件标签 $type = "93";//标签种类2位 } $materialtype=$_GET['materialtype'];//辅料类型2位 $company_code=$_GET['company_code'];//供应商编码 $product_code=$_GET['product_code'];//辅料编码 $product_time=20180807;//生产日期 $print_time=date('Y-m-d',$time);//打码日期 $big_unipue=$print_time.rand(100000,999999);//唯一编码 $yuliu="000000000000000000";//预留码 $url= $fixedheadcode.$type.$materialtype.$company_code.$product_code.$product_time.$big_num.$big_unipue.$yuliu; $this->qrcode($url); } if($_GET['temple']==2) {//使用老模板 if ($_GET['label_type'] == 1) {//大件标签 $type = "92"; $uniquecode = date('Ymd', $time) . rand(100000, 500000);//大件唯一编码14位(生产日期8位+6位随机码) } if ($_GET['label_type'] == 2) {//小件标签 $type = "93";//标签种类2位 $uniquecode = date('Ymd', $time) . rand(500001, 999999);//小件唯一编码14位(生产日期8位+6位随机码) } $offercode = $_GET['company_code'];//供应商编码12位 $materialcode = $_GET['product_code'];//辅料编码20位不足补零 $producttime = date("Ymd", $time);//生产日期(年月日)8位 $patchcode = "000000";//补位(6位); $fixedheadcode = "90";//固定的头部编码2位; $url = $fixedheadcode . $type . $_GET['materialtype'] . $offercode . $materialcode . $producttime . $uniquecode . $patchcode; $this->qrcode($url); } $this->display('large.html'); } public function qrcode($url)//二维码生成类 { $url=$url; $level=2; $size=4; Vendor('phpqrcode.phpqrcode');//加载生成二维码的核心类 $errorCorrectionLevel =intval($level) ;//容错级别 $matrixPointSize = intval($size);//生成图片大小 //生成二维码图片 $object = new \QRcode(); //打开缓冲区 ob_start(); $object->png($url, false, $errorCorrectionLevel, $matrixPointSize, 2); //这里就是把生成的图片流从缓冲区保存到内存对象上,使用base64_encode变成编码字符串,通过json返回给页面。 $imageString = base64_encode(ob_get_contents()); //关闭缓冲区 ob_end_clean(); //把生成的base64字符串返回给前端 $data = array( 'labelcode'=>$url, 'code'=>200, 'data'=>$imageString, 'product_code'=>$url ); $this->ajaxReturn($data); } /*补打标签*/ public function small(){ $this->display('buda'); } public function buda(){//补打标签 $this->display(); } public function budadetail(){//补打标签详情页 $session_config=I('session.ly_admin_');//获取登陆的session值 if($session_config['user_auth']['addtype']==1) { $nickname=$session_config['user_auth']['nickname']; }else{ $companylist=M('admin_user')->field('nickname')->where('status=1')->select(); } $userinfo=M('admin_user')->where('id='.$session_config['user_auth']['uid'])->find(); $user_product = explode(',',$userinfo['product_id']); $map = array(); $map['id'] = array('in',$user_product); $productlist=M('qcode_product')->where($map)->field('product_name,id,product_size,product_num,temple,product_code')->select(); $this->assign('productlist',$productlist); $this->assign('nickname',$nickname); $this->assign('companylist',$companylist); $this->display(); } /*二级产品下拉框*/ public function MaterialTwoApi(){ /* if(I('get.id')==0 || I('get.id')==NULL){ $secondlist=array('全部'); } if(I('get.id')==1){ $secondlist=array('全部','常规醋纤丝束','特种醋纤丝束','其他醋纤丝束'); } if(I('get.id')==2){ $secondlist=array('全部','常规聚丙烯丝束','低旦聚丙烯丝束','其他聚丙烯丝束'); } if(I('get.id')==3){ $secondlist=array('全部','普通成型纸','高透成型纸','其他成型纸'); } if(I('get.id')==4){ $secondlist=array('全部','醋酸纤维滤棒','常规聚丙烯丝束滤棒','低旦加胶聚丙烯丝束滤棒','纸质滤棒','沟槽滤棒'); } echo json_encode($secondlist);*/ } /*产品列表接口*/ public function ProductApi(){ //$productlist['code']=200; //$productlist['pagesize']=$_GET['pagesize']?$_GET['pagesize']:10; $page=$_GET['page']; $productlist['pagesize']=$_GET['rows']?$_GET['rows']:10; $pagenum=($page-1)* $productlist['pagesize'];//当前页码 if($pagenum<0){ $pagenum=0; } $productlist['rows']=M('qcode_product')->where('id!=0')->limit($pagenum,$productlist['pagesize'])->select(); $total=M('qcode_product')->where('id!=0')->select(); $productlist['total']=count($total); $productlist=json_encode($productlist); //echo date('Y-m-d',1533120226); echo $productlist; //die(); } /*产品打印列表*/ public function PrintListApi(){ if(empty(I('get.product_id'))){//没有产品的id $printlist['code']=100; $printlist['total']="产品id为空"; }else{ //$printlist['code']=200; $page=$_GET['page']; $productlist['pagesize']=$_GET['rows']?$_GET['rows']:10; $pagenum=($page-1)* $productlist['pagesize'];//当前页码 if($pagenum<0){ $pagenum=0; } $printlist['rows']=M('qcode_print')->where('product_id='.I('get.product_id'))->limit($pagenum,$productlist['pagesize'])->select(); /*if(count($printlist['productlist'])==0){//没有找到数据 $printlist['code']=300; $printlist['total']="没有找到对应的数据"; }else{*///有数据返回分页数据 //$total=count($printlist['productlist']); $total=M('qcode_print')->where('product_id='.I('get.product_id'))->select(); $printlist['total']=count($total); $printlist['pagesize']=$_GET['rows']?$_GET['rows']:10; //} } $printlist=json_encode($printlist); echo $printlist; } public function rePrintTg(){ header("Content-type: text/html; charset=utf-8"); $id = I('post.$ids'); $ids=explode(",",$id);//将字符串以逗号转化为数组 $num = I('post.reptQty')?I('post.reptQty'):4; $time=date('Y-m-d',time());//统一更新上一次 for($i=0;$i< count($ids);$i++){//先更新补打次数 $bd_num=M('qcode_print')->field("bd_num,print_time")->where('id='.$ids[$i])->find();//每个标签对应的补打次数 $number=[ 'bd_num'=>$bd_num['bd_num']+$num, 'last_time'=>$bd_num['print_time'], 'print_time'=>$time, ]; M('qcode_print')->where('id='.$ids[$i])->save($number);//每次补打时更新对应的标签补打次数 //unset($type); $sql=M('qcode_print')->getLastSql(); } $where = array(); $where['id'] = array('in',$id);//查询表里面id在 $field = "company_name,product_name,product_size,print_time,qr_code,lable_type"; $data = M('qcode_print')->field($field)->where($where)->select(); $new = array(); foreach($data as $v){ $arr = array(); $arr = $v; $arr['pnum']=$num; unset( $arr['time']); $new[]= $arr; } $this->ajaxReturn($id); } //中烟补打标签页面 public function reprint(){ $this->display(); } public function reprintdetail(){//补打标签详情页 $session_config=I('session.ly_admin_');//获取登陆的session值 $where = array(); $where['status'] = 1; $where['id'] = array('gt',1); $wh = array(); if($_SERVER['REQUEST_METHOD']==='GET'){ if($session_config['user_auth']['uid']==1 || $session_config['user_auth']['uid']==26) { // $companylist=M('admin_user')->where($where)->field('id,nickname')->select(); $companylist=M('qcode_gsmc')->field('id,nickname')->select(); $productlist=M('qcode_product')->where(['id'=>array('gt',27)])->field('product_name')->select(); } $this->assign('companylist',$companylist); $this->assign('productlist',$productlist); $this->display(); }elseif ($_SERVER['REQUEST_METHOD']==='POST'){ $nickname = trim($_POST['nickname']); if ($nickname!=''){ $wh['nickname']=array('like','%'.$nickname.'%'); } if($session_config['user_auth']['uid']==1 || $session_config['user_auth']['uid']==26) { $companylist=M('qcode_gsmc') ->where($wh) ->field('id,nickname') ->select(); } echo json_encode($companylist); } } public function logs($content, $subDir = ''){ $subDir = trim($subDir, '/\\'); if (empty($content)) return false; static $arrConfig = array(); if (empty($arrConfig)){ $arrPath = array(MODULE_NAME, CONTROLLER_NAME, ACTION_NAME); $arrConfig['root_path'] = './Runtime/Logs/'; $arrConfig['sub_dir'] = implode('/', $arrPath); $arrConfig['file_name'] = '/' . date('Ymd') . '.log'; $arrConfig['client_ip'] = get_client_ip(); $arrConfig['logs_no'] = date('ymdHis') . microtime() * 1000000; } $filepath = $arrConfig['root_path']; if ($subDir){ $filepath .= $subDir ; } else { $filepath .= $arrConfig['sub_dir'] ; } if (!file_exists($filepath)){ mkdir($filepath, 0777, TRUE); } $filepath .= $arrConfig['file_name']; $header = sprintf("\r\n\r\n[%s][%s][%s] ", date('Y-m-d H:i:s'), $arrConfig['client_ip'],$arrConfig['logs_no']); @file_put_contents($filepath, $header . $content, FILE_APPEND); return $arrConfig['logs_no'] ; } public function getproduct(){ if (I('post.type')==1){ $map = array(); $map['id'] = array('gt',27); $sysCdNm = trim($_POST['sysCdNm']); if ($sysCdNm!=''){ $map['product_name']=array('like','%'.$sysCdNm.'%'); } $productlist=M('qcode_product')->where($map)->field('product_name,id,product_size,product_num,temple,product_code')->select(); $this->ajaxReturn($productlist); }else if(I('post.type')==2){ //写入日志 $req = I('param.type'); $this->logs($req); $map = array(); $code = $_POST['code']; if ($code!=''){ $map['code']=$code; } $productlist=M('qcode_unit')->where($map)->field('main_unit,sec_unit,proportion')->find(); if ($productlist==[]){ $productlist['main_unit'] = '万张'; $productlist['sec_unit'] = '件'; $productlist['proportion'] = 0.1; }else{ if ($productlist['sec_unit']==null){ $productlist['sec_unit'] = '件'; } if ($productlist['proportion']==null){ $productlist['proportion'] = 0.1; } } $this->ajaxReturn($productlist); }else if(I('post.type')==3){ //写入日志 $req = I('param.type'); $this->logs($req); $map = array(); $map['id'] = array('gt',27); $product_code = $_POST['product_code']; if ($product_code!=''){ $map['product_code']=$product_code; } $productlist=M('qcode_product')->where($map)->field('product_name, temple')->find(); $this->ajaxReturn($productlist); }else if(I('post.type')==4){ //写入日志 $req = I('param.type'); $this->logs($req); $map = array(); $nickname = trim($_POST['nickname']); if ($nickname!=''){ $map['nickname']=$nickname; } $print_code=M('qcode_gsmc')->where($map)->field('print_code')->find(); $map2 = array(); $map2['id'] = array('gt',27); $product_name = trim($_POST['matter_name']); if ($nickname!=''){ $map2['product_name']=$product_name; } $product_code=M('qcode_product')->where($map2)->field('product_code, temple')->find(); $data['print_code'] = $print_code; $data['product_code'] = $product_code; $this->ajaxReturn($data); }else{ $id = I('post.id'); if (!empty($id)){ $userinfo=M('admin_user')->where('id='.$id)->find(); $user_product = explode(',',$userinfo['product_id']); $map = array(); $map['id'] = array('in',$user_product); $sysCdNm = trim($_POST['sysCdNm']); if ($sysCdNm!=''){ $map['product_name']=array('like','%'.$sysCdNm.'%'); } $productlist=M('qcode_product')->where($map)->field('product_name,id,product_size,product_num,temple,product_code')->select(); $this->ajaxReturn($productlist); } } } }