| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 | 
							- <?php defined('BASEPATH') OR exit('No direct script access allowed');
 
- class Kdniao extends Start_Controller {
 
- 	public function __construct(){
 
- 		parent::__construct();
 
- 		$this->load->library('session');
 
- 		$this->load->_model('Model_fullorder','fullorder');
 
- 		$this->load->_model('Model_fullordertt','fullordertt');
 
- 		$this->load->_model('Model_notice','notice');
 
- 		$this->load->_model('Model_kdniao','kdniao');
 
- 		$this->load->_model('Model_shop','shop');
 
- 		$this->load->_model('Model_express','express');
 
- 		$this->load->_model('Model_warehouse','warehouse');
 
- 	}
 
- 	//定义方法的调用规则 获取URI第二段值
 
-     public function _remap($arg,$arg_array)
 
-     {
 
- 		if($arg == 'js')//添加
 
-         {
 
-              $this->_js();
 
-         }
 
-     }
 
- 	public function _js()
 
- 	{
 
- 		$post = $this->input->post(NULL, TRUE);
 
-         $data = $this->input->post('RequestData',true);
 
- 		if(isset($data))
 
- 		{
 
- 			$data = json_decode($data,true);//josn转数组
 
- 			foreach ($data['Data'] as $value)//循环出每个运单信息
 
- 			{
 
- 				$rows = "";
 
- 				$waybill = $value['LogisticCode'];//运单号
 
- 				$fullorder = $this->fullorder->get_waybill($waybill);//查找此运单号
 
- 				if($fullorder)//如果有此运单号
 
- 				{
 
- 					if($fullorder['exstate'] != $value['State'])//如果状态已更新
 
- 					{
 
- 						$notice = $this->notice->get_type($fullorder['shop'],2,$value['State'],0);//查找消息配置
 
- 						if($notice)//如果有此消息配置
 
- 				 	    {
 
- 							$warehouse = $this->warehouse->read($fullorder['type']);
 
- 							if($notice['type'] == 2)//发送邮件
 
- 				    	    {
 
- 						    	$st = $this->_email($notice['content'],$fullorder,$warehouse['company']);//发送数据
 
- 							}
 
- 							else
 
- 							{
 
- 								$st = 2;
 
- 								//订单留言 AE需要 1.成功2.失败
 
- 							}
 
- 						}
 
- 						foreach ($value['Traces'] as $v)//物流详情
 
- 		            	{
 
- 							$rows .= "<p>时间:".$v['AcceptTime']." 状态:".$v['AcceptStation']."</p>";
 
- 						}
 
- 						$this->fullorder->save(array('exstate'=>$value['State'],'fsstate'=>$st,'content'=>$rows),$fullorder['id']);
 
- 					
 
- 					}
 
- 				}
 
- 			}
 
- 		}
 
- 		$echo = array("EBusinessID"=>$data['EBusinessID'],"UpdateTime"=>date('Y-m-d H:i:s',time()),"Success"=>true,"Reason"=>"");
 
- 		echo json_encode($echo);
 
- 	}
 
- 	
 
- 	public function _email($content,$data,$shopname)
 
- 	{
 
- 		$express = $this->express->read($data['express']);
 
- 		$t= array('$userName','$orderid','$trackingNumber','$expressCompany','$contactPerson','$mobileNo','$zip','$recipientAddress');//需要被替换的内容
 
- 		$h= array($data['client'],$data['orderinfo'],$data['waybill'],$express['title'],$data['name'],$data['phone'],$data['zipcode'],$data['address']);//替换的内容
 
- 		$content = str_replace($t,$h,$content);
 
- 		$this->load->library('email');		
 
- 		$config['protocol'] = 'smtp';
 
- 		$config['smtp_host'] = 'smtpdm-ap-southeast-1.aliyun.com';
 
- 		$config['smtp_port'] = 465; 
 
- 		$config['smtp_user'] = 'service@email.supernovahair.com';
 
- 		$config['smtp_pass'] = 'LONGyihair374';
 
- 		$config['smtp_crypto'] = 'ssl';
 
- 		$config['crlf'] = "\r\n"; 
 
- 		$config['newline'] = "\r\n";
 
- 		$this->email->initialize($config);
 
- 		$this->email->from('service@email.supernovahair.com',$shopname);
 
- 		$this->email->to($data['email']);//收件
 
- 		$this->email->subject('The product you purchased has a new progress');//标题
 
- 		$this->email->message($content);//内容
 
- 		if ( ! $this->email->send())
 
-         {
 
- 			return 2;
 
-         }
 
- 		else
 
- 		{
 
- 			return 1;
 
- 		}
 
- 	}
 
- }
 
 
  |