load->library('session'); $this->load->_model('Model_fullorder','fullorder'); $this->load->_model('Model_fullordertt','fullordertt'); $this->load->_model('Model_fullordersmt','fullordersmt'); $this->load->_model('Model_als','als'); $this->load->_model('Model_notice','notice'); $this->load->_model('Model_express','express'); $this->load->_model('Model_shop','shop'); } public function _remap($arg,$arg_array) { if($arg == '17track') { $this->_17track(); } else { $this->_index(); } } public function _17track() { $xq = array(); $j = file_get_contents('PHP://input'); $j = json_decode($j, true); if(isset($j['data']) && isset($j['sign'])) { $sh = hash("sha256",$j['event'].'/'.json_encode($j['data']).'/0811AC1711EAABB7D764D04B824F8C2D'); if($j['data']['number'] != '') { $f = 'fullorder'; $d = $this->fullorder->get_waybill($j['data']['number']); if(!$d) { $f = 'fullordersmt'; $d = $this->fullordersmt->get_waybill($j['data']['number']); } if(!$d) { exit; } if($j['data']['track']['e'] == 0)//查询不到 { $exstate = 0;//无信息 } else if($j['data']['track']['e'] == 10)//运输途中 { $exstate = 3;//在途中 } else if($j['data']['track']['e'] == 20)//运输过久 { $exstate = 3;//在途中 } else if($j['data']['track']['e'] == 30)//到达待取 { $exstate = 5;//派送中 } else if($j['data']['track']['e'] == 35)//投递失败 { $exstate = 1;//派送异常 } else if($j['data']['track']['e'] == 40)//成功签收 { $exstate = 6;//签收 } else if($j['data']['track']['e'] == 50)//可能异常 { $exstate = 1;//派送异常 } if(isset($j['data']['track']['z1'][0])) { foreach ($j['data']['track']['z1'] as $v) { $xq .= $v['a'].' ['.$v['c'].'] '.$v['z'].'
';// a日期 c地址 z状态 } } $this->$f->save(array('expressstate'=>$exstate,'excontent'=>$xq),$d['id']); $time = time(); $notice = $this->notice->find_all("message = '1' and state = '1' and type = '2' and ktime < '$time' and jtime > '$time' and shop = '".$d['shop']."' and logisticstatus = '".$exstate."'"); if($notice && $d['wlyc'] == '0' && $d['wltype'] != '1' && $d['source'] != '1' && stripos($d['wlcontent'],$notice[0]['title']) === false) { $this->_sdfs($d,$notice[0]['id']); } } } } public function _sdfs($fullorder,$id)//手动发送信息 { $time = time(); $notice = $this->notice->read($id);//无条件同模板匹配 $shop = $this->shop->read($fullorder['shop']); $express = $this->express->read($fullorder['express']); if($notice['type'] == '1') { $fslx = 'tab'; $content = '自动发送'; $stripos = '1-'; } else if ($notice['type'] == '2') { $fslx = 'logisticstatus'; $content = $notice['title']; $stripos = $notice['type'].'-'.$notice[$fslx].'|'; } if(stripos($fullorder['zdstate'],$stripos) === false && $fullorder['wltype'] == '0')//如果没发送过并且允许发送 { $go = $this->notice->get_god($fullorder,$shop,$express,$notice['content'],$notice['message'],$notice['emailtitle']); if($go == 1) { if($notice['type'] == '1') { $this->fullorder->save(array('content'=>$fullorder['content'].$content.'-成功;','zdstate'=>$fullorder['zdstate'].$notice['type'].'-'.$notice[$fslx].'|','exstateerror'=>''),$fullorder['id']); } else if ($notice['type'] == '2') { $this->fullorder->save(array('wlcontent'=>$fullorder['wlcontent'].$content.'-成功;','wlfstime'=>time(),'zdstate'=>$fullorder['zdstate'].$notice['type'].'-'.$notice[$fslx].'|','exstateerror'=>''),$fullorder['id']); } return 1; } else { if($notice['type'] == '1') { $this->fullorder->save(array('exstateerror'=>$content.'发送失败:'.date('Y-m-d H',time()).'-'.$go.'('.$notice['type'].'-'.$notice[$fslx].')'),$fullorder['id']); } else if ($notice['type'] == '2') { $this->fullorder->save(array('wlerror'=>$content.'发送失败:'.date('Y-m-d H',time()).'-'.$go.'('.$notice['type'].'-'.$notice[$fslx].')'),$fullorder['id']); } } } } }