标签:tor 密码 return cat json ora sel 单列 base
<?php namespace app\api\controller; use think\Controller; use think\Db; use think\Log; /** * desc:仓库扫码入库API */ class Storage extends Base { protected static $erp; public function __construct() { parent::__construct(); $dbhost =config(‘erp.dbhost‘); $dbuser = config(‘erp.dbuser‘); //你的mssql用户名 $dbpass = config(‘erp.dbpass‘); //你的mssql密码 $dbname = config(‘erp.dbname‘); //你的mssql库名 try{ self::$erp=odbc_connect("Driver={SQL Server};Server=$dbhost;Database=$dbname","$dbuser","$dbpass"); }catch (\Exception $e){ echo ‘ERP数据库连接错误,请检查数据连接‘; die(); } } /*----------------------------入库扫码模块开始-------------------------------------*/ /** * 列出5天内的入库单 * @return \think\response\Json * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function scan_receipt_list(){ $timestart = input(‘param.start‘); $timeend = input(‘param.end‘); $day=config(‘erp.getnum‘); $search_time_start = $timestart ? $timestart : date("Y-m-d",strtotime("-$day day"));//当天日期 $search_time_end = $timeend ? $timeend : date("Y-m-d");//当天最晚日期 //$map[‘insert_time‘] = array(‘between‘, [strtotime($search_time_start), strtotime($search_time_end)]); //按日期读取erp采购入库单列表 $sql="select cCode from dbo.RdRecord01 where dDate>=‘$search_time_start‘ and dDate<=‘$search_time_end‘"; $exec=odbc_exec(self::$erp,$sql); $list=[]; while ($row = odbc_fetch_array($exec)){ $list[]=$row[‘cCode‘]; } // $list = Db::name(‘Test‘)->where($map)->field(‘receipt‘)->group(‘receipt‘)->select(); if (count($list)) { $data[‘code‘] = 1; $data[‘datas‘] = $list; $data[‘msg‘] = ‘获取成功‘; }else{ $data[‘code‘] = 0; $data[‘datas‘] = ""; $data[‘msg‘] = ‘最近‘.$day.‘日暂无入库单‘; } return json($data); } /** * 仓管扫描入库单,列出入库产品数量 * @return \think\response\Json * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function scan_receipt_info(){ $receipt=input("param.receipt"); if ($receipt != ‘‘) { //$list = Db::name(‘Test‘)->where(‘receipt‘, $receipt)->select(); //根据采购入库单号 获取入库单详细 $sql="select dDate,cCode as receipt,cinvname as p_name,iQuantity as p_num,cInvCode as p_code,cBatch as batch_number,dMadeDate as brithday,iMassDate as validity,dVDate as expiration from dbo.zpurrkdlist where cCode=‘$receipt‘"; $exec=odbc_exec(self::$erp,$sql); $list=[]; $i=0; while ($row = odbc_fetch_array($exec)){ $list[$i]=$row; $list[$i][‘p_num‘]=(int)$row[‘p_num‘]; $list[$i][‘p_name‘]=iconv(‘gbk‘,‘utf-8‘,$row[‘p_name‘]); $i++; } foreach ($list as $key=>$val){ $tracking_code=Db::name(‘Products‘)->where(‘p_code‘,$val[‘p_code‘])->value(‘tracking_code‘); $count=Db::name(‘GoodsStockInfo‘)->where([‘delivery_number‘=>$val[‘receipt‘],‘p_code‘=>$val[‘p_code‘]])->count(); $needscan=intval($val[‘p_num‘])-intval($count); if($count>=$val[‘p_num‘]){ $list[$key][‘flag‘]=1; $list[$key][‘brithday‘]=$val[‘brithday‘]; $list[$key][‘expiration‘]=$val[‘expiration‘]; $list[$key][‘tracking_code‘]=$tracking_code; $list[$key][‘needscan_num‘]=$needscan; }else{ $list[$key][‘flag‘]=0; $list[$key][‘brithday‘]=$val[‘brithday‘]; $list[$key][‘expiration‘]=$val[‘expiration‘]; $list[$key][‘tracking_code‘]=$tracking_code; $list[$key][‘needscan_num‘]=$needscan; } } $data[‘code‘] = 1; $data[‘datas‘] = $list; $data[‘msg‘] = ‘获取成功‘; }else{ $data[‘code‘] = 0; $data[‘datas‘] = ""; $data[‘msg‘] = ‘入库单号不能为空‘; } // return json($data); print_r($data); } }
标签:tor 密码 return cat json ora sel 单列 base
原文地址:https://www.cnblogs.com/houdj/p/8781068.html