|
@@ -0,0 +1,514 @@
|
|
|
|
|
+<?php defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
|
+header("Access-Control-Allow-Origin: *");
|
|
|
|
|
+class Outerrors extends Start_Controller{
|
|
|
|
|
+ public function __construct(){
|
|
|
|
|
+ parent::__construct();
|
|
|
|
|
+ $this->load->library('session');
|
|
|
|
|
+ $this->load->_model('Model_outerrors','outerrors');
|
|
|
|
|
+ $this->load->_model("Model_logic_order","logic_order");
|
|
|
|
|
+ $this->load->_model("Model_check",'check');
|
|
|
|
|
+ $this->load->_model("Model_express","express");
|
|
|
|
|
+ $this->load->_model("Model_warehouse","warehouse");
|
|
|
|
|
+ $this->load->_model('Model_whlabel','whlabel');
|
|
|
|
|
+ $this->load->_model("Model_logic_express","logic_express");
|
|
|
|
|
+ $this->load->_model("Model_ck",'ck');
|
|
|
|
|
+ $this->load->_model("Model_shop","shop");
|
|
|
|
|
+ $this->load->_model('Model_specialstock','specialstock');
|
|
|
|
|
+ $this->load->_model('Model_fullorder','fullorder');
|
|
|
|
|
+ $this->load->_model('Model_fullordersmt','fullordersmt');
|
|
|
|
|
+ $this->load->_model('Model_fullordertt','fullordertt');
|
|
|
|
|
+ $this->load->_model('Model_fullorderamz','fullorderamz');
|
|
|
|
|
+ $this->load->_model('Model_dhl','dhl');
|
|
|
|
|
+ $this->load->_model('Model_dhlhz','dhlhz');
|
|
|
|
|
+ $this->load->_model('Model_typeclass','typeclass');
|
|
|
|
|
+ }
|
|
|
|
|
+ //定义方法的调用规则 获取URI第二段值
|
|
|
|
|
+ public function _remap($arg,$arg_array)
|
|
|
|
|
+ {
|
|
|
|
|
+ if($arg == 'scan')//出库页
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->_scan();
|
|
|
|
|
+ }
|
|
|
|
|
+ else if($arg == 'operate')//出库列表页
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->_operate();
|
|
|
|
|
+ }
|
|
|
|
|
+ else if($arg == 'excel'){
|
|
|
|
|
+ $this->_excel();
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->_index();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private function _index()
|
|
|
|
|
+ {
|
|
|
|
|
+ if($this->input->method() === 'post'){
|
|
|
|
|
+ $page = $this->input->post('page',true);
|
|
|
|
|
+ $perpage = $this->input->post('perpage',true);
|
|
|
|
|
+ $number = $this->input->post('number',true);
|
|
|
|
|
+ $timetk = $this->input->post('timetk',true);
|
|
|
|
|
+ $timetj = $this->input->post('timetj',true);
|
|
|
|
|
+ $timetk = strtotime($timetk);
|
|
|
|
|
+ $timetj = strtotime($timetj);
|
|
|
|
|
+ $where = "";
|
|
|
|
|
+ if($number){
|
|
|
|
|
+ $where .= " number = '$number' ";
|
|
|
|
|
+ }
|
|
|
|
|
+ if(empty($where)){
|
|
|
|
|
+ $where = " scan_time > '$timetk' and scan_time < '$timetj' ";
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $where .= " and scan_time > '$timetk' and scan_time < '$timetj' ";
|
|
|
|
|
+ }
|
|
|
|
|
+ //数据排序
|
|
|
|
|
+ $order_str = " id desc";
|
|
|
|
|
+ if(empty($page))
|
|
|
|
|
+ {
|
|
|
|
|
+ $start = 0;
|
|
|
|
|
+ $perpage = 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ $start = ($page - 1)*$perpage;
|
|
|
|
|
+ }
|
|
|
|
|
+ $list = $this->outerrors->find_all($where,"*",$order_str,$start,$perpage);
|
|
|
|
|
+ $info_list = [];
|
|
|
|
|
+ foreach($list as $k => $v){
|
|
|
|
|
+ $str = "";
|
|
|
|
|
+ if(empty($v['dy_status'])){
|
|
|
|
|
+ $str .= "<p ><b style='font-size:18px !important' data-id='".$v['id']."' data-type='1' onclick='dycz(this)'>店员操作</b></p>";
|
|
|
|
|
+ }
|
|
|
|
|
+ if(!empty($v['dy_status']) && empty($v['ck_status'])){
|
|
|
|
|
+ $str .= "<p><b style='font-size:18px !important;background-color: #FFC125;color: #000;' data-id='".$v['id']."' data-type='2' onclick='dycz(this)'>仓库操作</b></p>";
|
|
|
|
|
+ }
|
|
|
|
|
+ $info_list[] = [
|
|
|
|
|
+ 'id' => $v['id'],
|
|
|
|
|
+ 'scan_time' => date('Y-m-d H:i:s',$v['scan_time']),
|
|
|
|
|
+ 'number' => $v['number'],
|
|
|
|
|
+ 'dy_status'=>empty($v['dy_status'])?'':$v['dy_operate'],
|
|
|
|
|
+ 'ck_status' => empty($v['ck_status'])?'':$v['ck_operate'],
|
|
|
|
|
+ 'remark'=>empty($v['remark'])?'':$v['remark'],
|
|
|
|
|
+ 'opreate'=>$str
|
|
|
|
|
+ ];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $total = $this->outerrors->find_count($where);
|
|
|
|
|
+ $pagenum = ceil($total/$perpage);
|
|
|
|
|
+ $over = $total-($start+$perpage);
|
|
|
|
|
+ $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
|
|
|
|
|
+ echo json_encode($rows);exit;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $this->_Template('outerrors',$this->data);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private function _operate(){
|
|
|
|
|
+ if($this->input->method() === 'post'){
|
|
|
|
|
+ $id = $this->input->post('id',true);
|
|
|
|
|
+ $type = $this->input->post('operate_type',true);
|
|
|
|
|
+ $remark = $this->input->post('operate_remark',true);
|
|
|
|
|
+ if($type == 1){
|
|
|
|
|
+ $arr = [
|
|
|
|
|
+ 'dy_status'=>1,
|
|
|
|
|
+ 'dy_operate'=>$remark,
|
|
|
|
|
+ 'dy_time'=>time(),
|
|
|
|
|
+ ];
|
|
|
|
|
+ }else if($type == 2){
|
|
|
|
|
+ $arr = [
|
|
|
|
|
+ 'ck_status'=>1,
|
|
|
|
|
+ 'ck_operate'=>$remark,
|
|
|
|
|
+ 'ck_time'=>time(),
|
|
|
|
|
+ ];
|
|
|
|
|
+ }else{
|
|
|
|
|
+ echo json_encode(['code'=>-1,'msg'=>'执行类型异常']);exit;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if($this->outerrors->save($arr,$id)){
|
|
|
|
|
+ echo json_encode(['code'=>1,'msg'=>'操作成功']);exit;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ echo json_encode(['code'=>-1,'msg'=>'操作失败']);exit;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ echo json_encode(['code'=>-1,'msg'=>'参数异常']);exit;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //excel 下载
|
|
|
|
|
+ private function _excel(){
|
|
|
|
|
+ if($this->input->method() === 'get'){
|
|
|
|
|
+ $excel = $this->input->get('excel',true);
|
|
|
|
|
+ if($excel == 2){
|
|
|
|
|
+ $number = $this->input->get('number',true);
|
|
|
|
|
+ $timetk = $this->input->get('timetk',true);
|
|
|
|
|
+ $timetj = $this->input->get('timetj',true);
|
|
|
|
|
+ $timetk = strtotime($timetk);
|
|
|
|
|
+ $timetj = strtotime($timetj);
|
|
|
|
|
+ $where = "";
|
|
|
|
|
+ if($number){
|
|
|
|
|
+ $where .= " number = '$number' ";
|
|
|
|
|
+ }
|
|
|
|
|
+ if(empty($where)){
|
|
|
|
|
+ $where = " scan_time > '$timetk' and scan_time < '$timetj' ";
|
|
|
|
|
+ }else{
|
|
|
|
|
+ $where .= " and scan_time > '$timetk' and scan_time < '$timetj' ";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $list = $this->outerrors->find_all($where,"*");
|
|
|
|
|
+ $info_list = [];
|
|
|
|
|
+ foreach($list as $k => $v){
|
|
|
|
|
+
|
|
|
|
|
+ $info_list[] = [
|
|
|
|
|
+ 'id' => $v['id'],
|
|
|
|
|
+ 'number' => $v['number'],
|
|
|
|
|
+ 'dy_operate'=>$v['dy_operate'],
|
|
|
|
|
+ 'ck_operate' => $v['ck_operate'],
|
|
|
|
|
+ 'remark'=>empty($v['remark'])?'':$v['remark'],
|
|
|
|
|
+ 'scan_time' => date('Y-m-d H:i:s',$v['scan_time']),
|
|
|
|
|
+ 'dy_time'=>empty($v['dy_time'])?'':date('Y-m-d H:i:s',$v['dy_time']),
|
|
|
|
|
+ 'ck_time'=>empty($v['ck_time'])?'':date('Y-m-d H:i:s',$v['ck_time']),
|
|
|
|
|
+ ];
|
|
|
|
|
+ }
|
|
|
|
|
+ $filename = date("Y-m-d")."扫不出库记录.xls";
|
|
|
|
|
+ $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
|
|
|
|
|
+ <head>
|
|
|
|
|
+ <!--[if gte mso 9]><xml>
|
|
|
|
|
+ <x:ExcelWorkbook>
|
|
|
|
|
+ <x:ExcelWorksheets>
|
|
|
|
|
+ <x:ExcelWorksheet>
|
|
|
|
|
+ <x:Name>EXCEL</x:Name>
|
|
|
|
|
+ <x:WorksheetOptions>
|
|
|
|
|
+ <x:Print>
|
|
|
|
|
+ <x:ValidPrinterInfo />
|
|
|
|
|
+ </x:Print>
|
|
|
|
|
+ </x:WorksheetOptions>
|
|
|
|
|
+ </x:ExcelWorksheet>
|
|
|
|
|
+ </x:ExcelWorksheets>
|
|
|
|
|
+ </x:ExcelWorkbook>
|
|
|
|
|
+ </xml>
|
|
|
|
|
+ <![endif]-->
|
|
|
|
|
+ </head><body>";
|
|
|
|
|
+ $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
|
|
|
|
|
+ $str .= "<tr><td>订单编码</td><td>店员操作</td><td>仓库操作</td><td>不能出库原因</td><td>扫描时间</td><td>店员操作时间</td><td>仓库操作时间</td></tr>";
|
|
|
|
|
+ foreach ($info_list as $key=>$value)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ $str .= "<tr>";
|
|
|
|
|
+ $str .= "<td>". $value['number']. "</td>";
|
|
|
|
|
+ $str .= "<td>". $value['dy_operate']. "</td>";
|
|
|
|
|
+ $str .= "<td>". $value['ck_operate']. "</td>";
|
|
|
|
|
+ $str .= "<td>". $value['remark']. "</td>";
|
|
|
|
|
+ $str .= "<td>". $value['scan_time']. "</td>";
|
|
|
|
|
+ $str .= "<td>". $value['dy_time']. "</td>";
|
|
|
|
|
+ $str .= "<td>". $value['ck_time']. "</td>";
|
|
|
|
|
+ $str .= "</tr>";
|
|
|
|
|
+ }
|
|
|
|
|
+ $str .= "</table></body></html>";
|
|
|
|
|
+ header( "Content-Type: application/vnd.ms-excel; name='excel'" );
|
|
|
|
|
+ header( "Content-type: application/octet-stream" );
|
|
|
|
|
+ header( "Content-Disposition: attachment; filename=".$filename );
|
|
|
|
|
+ header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
|
|
|
|
|
+ header( "Pragma: no-cache" );
|
|
|
|
|
+ header( "Expires: 0" );
|
|
|
|
|
+ exit($str);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //扫描未出库的单子
|
|
|
|
|
+ private function _scan(){
|
|
|
|
|
+ if($this->input->method() === 'post'){
|
|
|
|
|
+ $waybill = $this->input->post('waybill',true);
|
|
|
|
|
+ $weight = $this->input->post('weight',true);
|
|
|
|
|
+ if(empty($waybill)){
|
|
|
|
|
+ echo json_encode(['code'=>-1,'msg'=>'快递单号不能为空']);exit;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $info = $this->logic_order->getInfo("waybill = '$waybill'");
|
|
|
|
|
+ $outtype = 1;
|
|
|
|
|
+ if(empty($info)){
|
|
|
|
|
+ $info = $this->logic_order->getInfo("oldwaybill like '%/".$waybill."%'");
|
|
|
|
|
+ }
|
|
|
|
|
+ if(empty($info)){
|
|
|
|
|
+ $outtype = 2;
|
|
|
|
|
+ $info = $this->logic_order->getInfo("number = '$waybill'");
|
|
|
|
|
+ }
|
|
|
|
|
+ if(empty($info)){
|
|
|
|
|
+ echo json_encode(['code'=>-1,'msg'=>'未发现和 '.$waybill.' 关联的订单信息']);exit;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $r = $this->_outerrorinfo($info,$weight,$outtype);
|
|
|
|
|
+
|
|
|
|
|
+ if($r['success']){
|
|
|
|
|
+ echo json_encode(['code'=>-1,'msg'=>$r['msg']]);exit;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $arr = [
|
|
|
|
|
+ 'number'=>$info['number'],
|
|
|
|
|
+ 'waybill'=>$waybill,//扫描单号
|
|
|
|
|
+ 'plat'=>$info['lv_platform'],
|
|
|
|
|
+ 'shop'=>$info['shop'],
|
|
|
|
|
+ 'remark'=>$r['msg'],
|
|
|
|
|
+ 'scan_time'=>time(),
|
|
|
|
|
+ ];
|
|
|
|
|
+ if($this->outerrors->insert($arr)){
|
|
|
|
|
+ echo json_encode(['code'=>1,'msg'=>'扫描成功']);exit;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ echo json_encode(['code'=>-1,'msg'=>'操作失败']);exit;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ $this->_Template('outerrors_scan',$this->data);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //出库错误的原因返回
|
|
|
|
|
+ private function _outerrorinfo($info,$weight,$outtype){
|
|
|
|
|
+ $time = time();
|
|
|
|
|
+ if(!isset($weight))//测试没问题后可以删
|
|
|
|
|
+ {
|
|
|
|
|
+ $weight = '';
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $y = $info;
|
|
|
|
|
+ $fullorder_name = $y['lv_platform'];
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if($y['mergeid'] == '1')
|
|
|
|
|
+ {
|
|
|
|
|
+ $y = $this->$fullorder_name->read($y['merge']);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 66 云途(欧洲) 67 云途(欧洲)-带保险 如果是欧洲云途 需要检擦出库时间是否超过15天
|
|
|
|
|
+ if(in_array($y['express'],[66,67,82])){
|
|
|
|
|
+ if((time() - $y['printtime']) >= (14*24*3600)){
|
|
|
|
|
+ return array('msg'=>'运单超时!请联系梦体处理!','success'=>false);
|
|
|
|
|
+ //echo json_encode(array('msg'=>'运单超时!请联系梦体处理!','success'=>false));exit;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 78 dpd英国 和 79dpd欧盟
|
|
|
|
|
+ if(in_array($y['express'],[78,79,84])){
|
|
|
|
|
+ $r = $this->check->checkOverdue($y['name'],$y['number'],$y['address']);
|
|
|
|
|
+ if(!$r){
|
|
|
|
|
+ return array('msg'=>'同一个客户3天内发货超过2包,不可出库!请联系店员做申报信息修改!'.$y['name']."-".$y['number']."-".$r*1,'success'=>false);
|
|
|
|
|
+ //echo json_encode(array('msg'=>'同一个客户3天内发货超过2包,不可出库!请联系店员做申报信息修改!'.$y['name']."-".$y['number']."-".$r*1,'success'=>false));exit;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $express = $this->express->read($y['express']);
|
|
|
|
|
+ if($y['state'] == 216 && $fullorder_name == 'fullordersmt')
|
|
|
|
|
+ {
|
|
|
|
|
+ $y['librarynot'] = '客户已取消!';
|
|
|
|
|
+ }
|
|
|
|
|
+ if($y['print'] != 3 || $y['libraryconfirm'] == 1 || $y['state'] == 214 || $y['state'] == 217 || $y['state'] == 283 || $y['state'] == 206 || $y['state'] == 205 || $y['state'] == 204 || $y['state'] == 210 || $y['state'] == 211 || $y['state'] == 212 || ($y['state'] == 216 && $fullorder_name == 'fullordersmt'))//独立站216先关了
|
|
|
|
|
+ {
|
|
|
|
|
+ return array('msg'=>'禁止出库!'.$y['librarynot'],'success'=>false);
|
|
|
|
|
+ //echo json_encode(array('msg'=>'禁止出库!'.$y['librarynot'],'success'=>false));exit;
|
|
|
|
|
+ }
|
|
|
|
|
+ if($y['library'] > 1)
|
|
|
|
|
+ {
|
|
|
|
|
+ return array('msg'=>'此数据 '.date('Y-m-d H:i:s',$y['librarytime']).' 已操作出库','success'=>false);
|
|
|
|
|
+ // echo json_encode(array('msg'=>'此数据 '.date('Y-m-d H:i:s',$y['librarytime']).' 已操作','success'=>false));exit;
|
|
|
|
|
+ }
|
|
|
|
|
+ if($express['out'] != 3)
|
|
|
|
|
+ {
|
|
|
|
|
+ if($express['out'] != $outtype)
|
|
|
|
|
+ {
|
|
|
|
|
+ $smlx = ($express['out']=='1')?'运单':'发货单';
|
|
|
|
|
+ return array('msg'=>'扫描类型错误!此单需要扫描'.$smlx,'success'=>false);
|
|
|
|
|
+ //echo json_encode(array('msg'=>'扫描类型错误!此单需要扫描'.$smlx,'success'=>false));exit;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if($y['type'] != 7 && $y['waybill'] != '' && $y['printtype'] == '1')
|
|
|
|
|
+ {
|
|
|
|
|
+ $r = $this->logic_express->ydCheckById($y['waybill'],$y['express']);
|
|
|
|
|
+ if(!$r){
|
|
|
|
|
+ return array('msg'=>'出库物流和系统不匹配,请联系梦体解决'.$y['express'],'success'=>false);
|
|
|
|
|
+ //echo json_encode(array('msg'=>'出库物流和系统不匹配,请联系梦体解决'.$y['express'],'success'=>false));exit;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if(stripos($weight,',') !== false){
|
|
|
|
|
+ $tmp_arr = explode(",",$weight);
|
|
|
|
|
+ $weight = end($tmp_arr);
|
|
|
|
|
+
|
|
|
|
|
+ $numweight = (float)$weight;
|
|
|
|
|
+ $weight = $numweight."kg";
|
|
|
|
|
+ }
|
|
|
|
|
+ $numweight = str_replace('kg','',$weight);
|
|
|
|
|
+
|
|
|
|
|
+ //根据要求 USPS-USA 2 FEDEX-US2 63 USPS-US2 64 这三个快递方式除外的所有快递都需要称重再发货 或者说是【国内发货】的都需要称重
|
|
|
|
|
+ //还有翔文仓库的 不执行
|
|
|
|
|
+ //源代码是
|
|
|
|
|
+ //所有快递必须称重
|
|
|
|
|
+ //所有快递必须称重 翔文除外
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //$this->logic_ding->sendToDing("检测订单".$y['number']."称重".$numweight."快递公司".$y['express']."-".$weight."[".$numweight."]");
|
|
|
|
|
+ if(!in_array($y['express'],[2,8,39,43,44,45,47,48,49,55,61,63,64,65,74,81,83,85])){
|
|
|
|
|
+ if($weight == '' || $numweight < '0.1' || !is_numeric($numweight))
|
|
|
|
|
+ {
|
|
|
|
|
+ return array('msg'=>'此单需要称重!','success'=>false);
|
|
|
|
|
+ //echo json_encode(array('msg'=>'此单需要称重!','success'=>false));exit;
|
|
|
|
|
+ }
|
|
|
|
|
+ $yzweight = explode('.',$numweight);
|
|
|
|
|
+ if($yzweight[0] == '')
|
|
|
|
|
+ {
|
|
|
|
|
+ return array('msg'=>'重量错误,请重新称重!','success'=>false);
|
|
|
|
|
+ //echo json_encode(array('msg'=>'重量错误,请重新称重!','success'=>false));exit;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(empty($numweight)){
|
|
|
|
|
+ return array('msg'=>'此单需要称重2!','success'=>false);
|
|
|
|
|
+ //echo json_encode(array('msg'=>'此单需要称重2!','success'=>false));exit;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $express_info = $this->express->read($y['express']);
|
|
|
|
|
+ if(empty($express_info)){
|
|
|
|
|
+ return array('msg'=>'快递信息异常,请联系技术!','success'=>false);
|
|
|
|
|
+ }
|
|
|
|
|
+ $weight_limit = $express_info['weight_limit']*1;
|
|
|
|
|
+ if($weight_limit > 0 && $y['type'] != 5){
|
|
|
|
|
+
|
|
|
|
|
+ $yzweight = explode('.',$numweight);
|
|
|
|
|
+ if($yzweight[0] == '')
|
|
|
|
|
+ {
|
|
|
|
|
+ return array('msg'=>'重量错误,请重新称重!','success'=>false);
|
|
|
|
|
+ }
|
|
|
|
|
+ if($numweight < ($y['jweight']/1000)){
|
|
|
|
|
+ return array('msg'=>'重量小于净重,请重新称重!','success'=>false);
|
|
|
|
|
+ }
|
|
|
|
|
+ //Fedex(杭州),UPS,DHL官方-美国 需要判断实际重量和净重差 其他快递不需要
|
|
|
|
|
+ if(in_array($y['express'],[3,24,42])){
|
|
|
|
|
+ //规定实际重量不允许超过 净重为1kg
|
|
|
|
|
+ if($numweight -($y['jweight']/1000) > 1 )
|
|
|
|
|
+ {
|
|
|
|
|
+ return array('msg'=>'称重重量和净重相差过大,请找成会处理!','success'=>false);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if($weight_limit < $numweight){
|
|
|
|
|
+ return array('msg'=>$express['servicename'].'大于'.$weight_limit.'公斤需要拆包!','success'=>false);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if(((time() - $y['printtime']) > (15*24*3600) || $y['printtime'] < 1590211800) && $y['express'] == '24' && $y['type'] != 6)//杭州店铺除外
|
|
|
|
|
+ {
|
|
|
|
|
+ //echo json_encode(array('yd'=>1,'id'=>$y['id'],'express'=>$y['express'],'name'=>$fullorder_name,'success'=>true));exit;
|
|
|
|
|
+ }
|
|
|
|
|
+ if((time() - $y['printtime']) > (6*24*3600) && $y['express'] == '3' && $y['type'] != 6)//杭州店铺除外
|
|
|
|
|
+ {
|
|
|
|
|
+ //echo json_encode(array('yd'=>1,'id'=>$y['id'],'express'=>$y['express'],'name'=>$fullorder_name,'success'=>true));exit;
|
|
|
|
|
+ return array('msg'=>'此运单过期无法出库,请联系成会处理!','success'=>false);
|
|
|
|
|
+ }
|
|
|
|
|
+ if((time() - $y['printtime']) > (7*24*3600) && $y['express'] == '37' && $y['type'] != 6)//杭州店铺除外
|
|
|
|
|
+ {
|
|
|
|
|
+ //echo json_encode(array('yd'=>1,'id'=>$y['id'],'express'=>$y['express'],'name'=>$fullorder_name,'success'=>true));exit;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $this->db->trans_begin();
|
|
|
|
|
+ $warehouse = $this->warehouse->read($y['type']);
|
|
|
|
|
+ $bdck = $warehouse['bdck'];
|
|
|
|
|
+ if($warehouse['zd'] == '1')
|
|
|
|
|
+ {
|
|
|
|
|
+ if($warehouse['bdck'] == '')
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->db->trans_rollback();
|
|
|
|
|
+ return array('msg'=>'仓库设置错误!','success'=>false);
|
|
|
|
|
+ }
|
|
|
|
|
+ $wh = $this->_fout_db($y,$warehouse,$bdck);
|
|
|
|
|
+ if($wh['fh'] == 2)
|
|
|
|
|
+ {
|
|
|
|
|
+ $kcyz = $this->ck->get_kc($y['state'],$warehouse,$y['shop'],$y['number'],$y['whlabel'],$y['fpdata']);
|
|
|
|
|
+ if($kcyz['t'] == '0')
|
|
|
|
|
+ {
|
|
|
|
|
+ if($kcyz['fpdata'] != '')
|
|
|
|
|
+ {
|
|
|
|
|
+ $x['whlabel'] = $kcyz['whlabel'];
|
|
|
|
|
+ $x['fpdata'] = $kcyz['fpdata'];
|
|
|
|
|
+ $y['whlabel'] = $x['whlabel'];
|
|
|
|
|
+ $this->$fullorder_name->save($x,$y['id']);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ $wh = $this->_fout_db($y,$warehouse,$bdck);
|
|
|
|
|
+ if($wh['fh'] == 2)
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->db->trans_rollback();
|
|
|
|
|
+ return array('msg'=>'库存占用量与实际出库量不符!','success'=>false);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ foreach ($wh['sj'] as $v)
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->$bdck->save(array('state'=>1,'cktype'=>1,'orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'outk'=>$time,'time'=>$time),$v['id']);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $shop = $this->shop->read($y['shop']);
|
|
|
|
|
+ if($express['printcode'] == "DHLUSA" && $y['waybill'] != '')
|
|
|
|
|
+ {
|
|
|
|
|
+ $type = $this->typeclass->read($shop['type']);
|
|
|
|
|
+ $y['shoptype'] = $type['title'];
|
|
|
|
|
+ $y['weight'] = $weight;
|
|
|
|
|
+ $d = $this->dhl->get_data_9610($y);
|
|
|
|
|
+ if($d != 1)
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->db->trans_rollback();
|
|
|
|
|
+ return array('msg'=>'9610失败,'.$d,'success'=>false);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if($fullorder_name == 'fullordersmt')
|
|
|
|
|
+ {
|
|
|
|
|
+ $stt = ($y['waybill']!='')?209:$y['state'];
|
|
|
|
|
+ $post = array('library'=>2,'state'=>$stt,'librarytime'=>$time,'weight'=>$weight,'dbapi'=>0);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if(($fullorder_name == 'fullordertt' || $fullorder_name == 'fullorderxw' || $fullorder_name == 'fullorder' || $fullorder_name = 'fullorderamz') && $y['source'] == 1)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ $post = array('library'=>2,'state'=>216,'librarytime'=>$time,'weight'=>$weight,'dbapi'=>0);
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ $post = array('library'=>2,'librarytime'=>$time,'weight'=>$weight,'dbapi'=>0);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if($outtype == 2 && $y['printnumber'] > 1)
|
|
|
|
|
+ {
|
|
|
|
|
+ $p = json_encode($post);
|
|
|
|
|
+ $this->db->trans_rollback();
|
|
|
|
|
+ return array('msg'=>'该单共打印过'.$y['printnumber'].'次,请注意核对当前发货单是否是最新发货单!','outnumber'=>$y['id'],'post'=>$p,'fullorder_name'=>$fullorder_name,'success'=>false);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $this->db->trans_rollback();
|
|
|
|
|
+ return array('msg'=>'此单允许出库 !!!','success'=>true);
|
|
|
|
|
+ //$this->$fullorder_name->save($post,$y['id']);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private function _fout_db($y,$warehouse,$bdck)//对比占单是否正确
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ $wh = $this->$bdck->find_all("zd = '".$y['number']."' and warehouse = '".$y['type']."' and (state = '0' or state = '9')");
|
|
|
|
|
+ $cpsl = 0;
|
|
|
|
|
+ $pp = explode('|',trim($y['whlabel'],'|'));
|
|
|
|
|
+ foreach ($pp as $va)
|
|
|
|
|
+ {
|
|
|
|
|
+ $num = explode('-',$va);
|
|
|
|
|
+ if(isset($num[2]))
|
|
|
|
|
+ {
|
|
|
|
|
+ if(stripos($num[2],$warehouse['hz']) !== false)
|
|
|
|
|
+ {
|
|
|
|
|
+ $cpsl += $num[1];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if(count($wh) == $cpsl)
|
|
|
|
|
+ {
|
|
|
|
|
+ return array('fh'=>1,'sj'=>$wh);
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ return array('fh'=>2);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|