load->library('session'); $this->load->_model('Model_whlabel','whlabel'); $this->load->_model('Model_warehouse','warehouse'); $this->load->_model('Model_productprice','productprice'); $this->load->_model('Model_excel','excel'); $this->load->_model('Model_fullorder','fullorder'); $this->load->_model('Model_fullordertt','fullordertt'); $this->load->_model('Model_fullordersmt','fullordersmt'); $this->load->_model('Model_outbound','outbound'); $this->load->_model('Model_express','express'); $this->load->_model('Model_shop','shop'); $this->load->_model('Model_typeclass','typeclass'); $this->load->_model('Model_country','country'); $this->load->_model('Model_kdniao','kdniao'); $this->load->_model('Model_notice','notice'); $this->load->_model('Model_dhl','dhl'); $this->load->_model('Model_dhlhz','dhlhz'); $this->load->_model('Model_usps','usps'); $this->load->_model('Model_fedex','fedex'); $this->load->_model('Model_fedex_cby','fedex_cby'); $this->load->_model('Model_ups','ups'); $this->load->_model('Model_ali','ali'); $this->load->_model('Model_dpd','dpd'); $this->load->_model('Model_shop','shop'); $this->load->_model('Model_user','user'); $this->load->_model('Model_whlabel','whlabel'); $this->load->_model('Model_specialstock','specialstock'); $this->load->_model('Model_ck','ck'); $this->load->_model('Model_whlabellabel','whlabellabel'); $this->load->_model('Model_apiyy','apiyy'); $this->load->helper('url'); $this->load->_model('Model_whlabel_fc','whlabel_fc'); $this->load->_model('Model_systemtransfer','systemtransfer'); $this->load->_model('Model_classid','classid'); $this->load->_model('Model_allocation','allocation'); $this->load->_model('Model_fullorderxw','fullorderxw'); $this->load->_model('Model_fullorderpaypal','fullorderpaypal'); $this->load->_model('Model_fedexv1','fedexv1'); $this->load->_model('Model_logic_crm','logic_crm'); $this->load->_model("Model_fullorder","fullorder"); $this->load->_model("Model_express","express"); $this->load->_model("Model_logic_ding","logic_ding"); $this->load->_model("Model_api",'api'); $this->load->_model("Model_usps",'usps'); $this->load->_model('Model_emaildata','emaildata'); $this->load->_model('Model_logic_tools','logic_tools'); $this->load->_model('Model_logic_order','logic_order'); $this->load->_model('Model_returngoods','returngoods'); $this->load->_model('Model_returnlogs','returnlogs'); $this->load->_model('Model_productdescribe','productdescribe'); $this->load->_model('Model_logic_u9tools','logic_u9tools'); } //定义方法的调用规则 获取URI第二段值 public function _remap($arg,$arg_array) { if($arg == 'fout') { $this->_fout(); }else if($arg == 'waybillemail'){ $this->_waybillemail(); }else if($arg == 'getorder'){ $this->_getorder(); }elseif($arg == 'logistic'){ $this->_logistic(); }elseif($arg == 'th'){ $this->_th($arg_array); }else{ $this->_a($arg_array); } } public function _th($arg_array){ die; if(empty($arg_array)){ die(1); } $order_no = $arg_array[0]; var_dump($order_no); $data = $this->fullorder->get_number($order_no); if(empty($data)){ echo 2; exit(2); } $r = $this->usps->get_return($data); echo "
";
var_dump($r);
}
//物流轨迹
public function _logistic(){
echo "";
// $list = $this->fullorder->find_all("waybill = 284280923614");
// var_dump($list);
// die;
// $v = $list[0];
// $v = [
// 'waybill'=>'285250961332'
// ];
// $fs = $this->fedexv1->get_logistics($v);
// var_dump($fs);
// die;
die;
$list = $this->fullorder->get_waybill("9205890251001335261703");
$v = $list;
@$fs = $this->usps->get_logistics_new($v);
// $csck[] = array($v['number'],$fs['f'],$fs['content']);
// if(!isset($fs['f']))
// {
// $fs = $this->usps->get_logistics($v);
// }
var_dump($fs);
//$fs = $this->usps->get_logistics($v);
die;
}
public function _getorder(){
$name = 'SuperNova';
$userKey = array(
'Alipearl' => array('username'=>'huchunmei','api_key'=>'huchunmei126_alipearl_erp888','url'=>'https://www.alipearlhair.com'),
'Asteria' => array('username'=>'huchunmei','api_key'=>'huchunmei126_asteria_erp888','url'=>'https://www.asteriahair.com'),
'WestKiss' => array('username'=>'huchunmei','api_key'=>'huchunmei126_westkiss_erp868','url'=>'https://www.westkiss.com'),
'SuperNova' => array('username'=>'huchunmei','api_key'=>'huchunmei126_supernova_erp6898','url'=>'https://www.supernovahair.com'),
'Wiggins' => array('username'=>'huchunmei','api_key'=>'huchunmei126_wiggins_erp652','url'=>'https://www.wigginshair.com'),
'Yolissa' => array('username'=>'huchunmei','api_key'=>'huchunmei126_yolissa_688','url'=>'https://www.yolissahair.com'),
);
$proxy = new SoapClient($userKey[$name]['url'].'/api/soap/?wsdl');
try {
$sessionId = $proxy->login($userKey[$name]['username'], $userKey[$name]['api_key']);
}
catch (Exception $e) {
echo $e->getMessage();
}
$data = array('proxy'=>$proxy,'sessionId'=>$sessionId,'url'=>$userKey[$name]['url']);
$fromTime = date('Y-m-d H:i:s',time()- 3600*24*6);
$toTime = date('Y-m-d H:i:s',time());
$filters = array(array('created_at'=>array('from'=>$fromTime,'to'=>$toTime)));
$result = $data['proxy']->call($data['sessionId'],'sales_order.list',$filters);
echo "";
// print_r($result[0]);
foreach($result as $item)
{
// print_r($item);exit;
$iteminfo= $data['proxy']->call($data['sessionId'], 'sales_order.info', $item['increment_id']);
print_r($iteminfo['items']);
die;
}
}
public function getDtc(){
$dictionaries = $this->typeclass->find_all('spare!= "" and classid != 1 and classid != 2 and classid != 3 and classid != 4 and classid != 5 and classid != 11 and classid != 16 and classid != 17 and classid != 20 and classid != 21 and classid != 23 and classid != 24 and classid != 29 and classid != 30 and classid != 31 and classid != 32 and classid != 36');
$dtc = array();
foreach ($dictionaries as $v)
{
if(stripos($v['spare'],'|') !== false)//如果有多个值
{
$v['spare'] = explode('|',$v['spare']);
foreach ($v['spare'] as $k=>$vs)
{
if(stripos($v['zh'],'|') !== false)
{
$vzh = explode('|',$v['zh']);
$dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$vzh[$k],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
}
else
{
$dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
}
}
}
else
{
$dtc[strtolower($v['spare'])] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$v['spare']);
}
}
$dtctitle = [];
$dictionaries2 = $this->typeclass->find_all();
foreach ($dictionaries2 as $v)
{
$dtctitle[$v['id']] = $v['title'];
}
return [
'dtc'=>$dtc,
'dtctitle'=>$dtctitle
];
}
public function _a($arg_array){
$list = [
[
'sku2'=>'-128-80-89-57-106-341-30-72-',
],
[
'sku2'=>'-128-80-88-57-2248-2096-30-72-2071-1645-',
]
];
$r = $this->logic_u9tools->getU9bm($list,'sku2');
echo "";
var_dump($r);
die;
$data = $this->getDtc();
$dtc = $data['dtc'];
$dtctitle = $data['dtctitle'];
$quantity = 'Loose Body--HDWig-26-HD5*5Wig-180%,WKPack';
$issku = '1;1';
$money = array();
$productdescribe = $this->productdescribe->find_all('1=1');
foreach ($productdescribe as $v)
{
$money[$v['number']] = array();
}
/* 价格加入 */
/* 匹配ID加入 */
$int = array();
$intdata = $this->typeclass->find_all('classid=14','id,spare');
foreach ($intdata as $v)
{
$v['spare'] = explode('|',$v['spare']);
$int[$v['id']] = $v['spare'][0];
}
var_dump($dtc);
var_dump($dtctitle);
$r = $this->api->matching($quantity,$issku,$dtc,$money,$int,$dtctitle,[1],[
]);
echo "";
var_dump($r);
die;
$time = time();
$jiami = "alipearlhair+".(string)$time;
echo json_encode([
'shop'=>3,
'waybill'=>'283786008019',
'time'=>$time,
'key'=>$this->logic_tools->toolsjiami($jiami,"6amg!pnfrlbpnjgirv", "6ook4k!2w94m6jtm"),
]);
die;
$dtc = array();
/* 订单号加入键值-j */
/* 匹配加入 */
$dictionaries = $this->typeclass->find_all('spare!= "" and classid != 1 and classid != 2 and classid != 3 and classid != 4 and classid != 5 and classid != 11 and classid != 16 and classid != 17 and classid != 20 and classid != 21 and classid != 23 and classid != 24 and classid != 29 and classid != 30 and classid != 31 and classid != 32 and classid != 36');
// and (classid=13 or classid=22 or classid=8 or classid=15 or classid=27 or classid=25 or classid=26 or classid=18 or classid=14 or classid=9 or classid=12 or classid=10 or classid=6 or classid=100 or classid=999)
foreach ($dictionaries as $v)
{
if(stripos($v['spare'],'|') !== false)//如果有多个值
{
$v['spare'] = explode('|',$v['spare']);
foreach ($v['spare'] as $k=>$vs)
{
if(stripos($v['zh'],'|') !== false)
{
$vzh = explode('|',$v['zh']);
$dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$vzh[$k],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
}
else
{
$dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
}
}
}
else
{
$dtc[strtolower($v['spare'])] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$v['spare']);
}
}
$dtctitle = [];
$dictionaries2 = $this->typeclass->find_all();
foreach ($dictionaries2 as $v)
{
$dtctitle[$v['id']] = $v['title'];
}
echo "";
$sku = "Free,Gift--PackQQS,NW--3+Ori6*6C-22 24 26-20-6*6C";
$sl = "1;1;1;";
$r = $this->api->matching($sl,$sku,$dtc,"","",$dtctitle,$shop=[],$extra = [
"price"=>"565.7700",
"row_total"=>"565.7700"
]);
var_dump($r['title']);
$r = $r['product'];
$rr = explode(";",$r);
print_r($rr);
}
public function _fout()
{
$waybill = $this->input->get('waybill');
$info = $this->fullorder->get_waybill($waybill);
//$r = $this->usps->get_new_logistics($info);
$r = $this->fedexv1->get_logistics(123);
echo "";
var_dump($r);
//$this->fedexv1->makeAccessToken();
}
public function _waybillemail()
{
$urls = array();$sl = 0;$time = time();
$wid = 2;
// if(date("H",time()) == '8' && date("i",time()) > '20' && date("i",time()) < '39')//USPS-USA单
// {
// $wid = 1;
// }
// else if(date("H",time()) == '20' && date("i",time()) > '20' && date("i",time()) < '39')//其他快递
// {
// $wid = 2;
// }
// else
// {
// exit;
// }
$notice = $this->notice->find_all("message = '1' and state = '1' and type = '4' and ktime < '$time' and jtime > '$time'");//已有自动发送,这个是物流发送
foreach ($notice as $key=>$var)
{
$this->_waybillfs([
'var'=>$var,
'wid'=>$wid
]);
}
}
public function upadtel(){
$returngoods_id = 150;
$insert_flag = 1217819;
$number = 'KISS-50206-004';
$returngoods_info = $this->returngoods->read($returngoods_id);
$this->returngoods->save([
'status'=>80,
'back_no'=>$number,
'back_id'=>$insert_flag,
'update_time'=>date('Y-m-d H:i:s'),
],$returngoods_id);
$this->returnlogs->insert([
'rg_id'=>(int)$returngoods_id,
'operat_id'=>10,
'operat_name'=>'admin',
'remark'=>"订单号:".$returngoods_info['orderinfo']."重新换货-换货新订单编码".$number,
'create_time'=>date('Y-m-d H:i:s'),
]);
}
public function _waybillfs($data)
{
if($data)
{
$notice = $data['var'];
$notice['email'] = $this->emaildata->read($notice['email']);
$wid = $data['wid'];
$fsjs = "";
if($wid == 1 && (stripos($notice['express'],',2,') !== false || stripos($notice['express'],',63,') !== false || stripos($notice['express'],',64,') !== false))
{
$js = explode(',',trim($notice['js'],','));
if(count($js) > 1)
{
$fsjs = " and (";
foreach ($js as $v)
{
$fsjs .= "js = '$v' or ";
}
$fsjs = trim($fsjs,' or ').")" ;
}
else if(count($js) == 1)
{
$fsjs = " and js = '$js[0]'";
}
$where = "(express = '2' or express = '63' or express = '64') and librarytime > '".strtotime(date("Y-m-d 8:30:0",strtotime("-6 day")))."' and librarytime < '".strtotime(date("Y-m-d 8:30:0",time()))."'".$fsjs;//3
}
else if($wid == 2 && stripos($notice['express'],',1,') !== false)
{
$where = "express != '2' and express != '63' and express != '64' and printtype = '1' and waybill != '' and librarytime > '".strtotime(date("Y-m-d 20:00:0",strtotime("-6 day")))."' and librarytime < '".strtotime(date("Y-m-d 20:00:0",time()))."'";//4
}
else
{
exit;
}
$this->logic_ding->sendToDing("source != '1' and dlzemail < '1' and shop = '".$notice['shop']."' and library = 2 and ".$where);
// $wlfs = array();
// $dd = $this->fullorder->find_all("source != '1' and dlzemail < '1' and shop = '".$notice['shop']."' and library = 2 and ".$where);
// foreach($dd as $v){
// $this->logic_ding->sendToDing($v['orderinfo']."监听邮件发送的异常:订单信息【".json_encode($v,JSON_UNESCAPED_UNICODE)."】");
// }
// foreach ($dd as $v)
// {
// $shop = $this->shop->read($v['shop']);
// $express = $this->express->read($v['express']);
// $fs = $this->notice->get_god($v,$shop,$express,$notice);
// $this->logic_ding->sendToDing($v['orderinfo']."监听邮件发送的异常:订单信息【".json_encode($v,JSON_UNESCAPED_UNICODE)."】获取快递信息【".json_encode($notice,JSON_UNESCAPED_UNICODE)."】返回的信息".json_encode($fs));
// if($fs == 1)
// {
// $this->fullorder->save(array('dlzemail'=>1,'dlzemailtime'=>time()),$v['id']);
// //给crm发送信息 先存储数据 后续定时任务执行
// if($v['shop'] < 10){
// $this->zztmpdata->insert([
// 'type'=>2,
// 'act_name'=>'crm_order',
// 'content'=>json_encode($v),
// 'create_time'=>time()
// ]);
// }
// }
// else
// {
// //$pdtime = date('Y-m-d',time());
// //$folderPath = './data/dlzemail/'.$pdtime; // 文件夹路径
// //$permissions = 0777; // 权限设置
// //if (!file_exists($folderPath)) { mkdir($folderPath, $permissions); }//创建文件夹
// //file_exists($folderPath);
// if(!is_file("./data/dlzemail/".$v['number'].".txt"))
// {
// $myfile = fopen("./data/dlzemail/".$v['number'].".txt", "w") or die("Unable to open file!");
// fwrite($myfile, json_encode($fs.';'.$v.';'.$shop.';'.$express.';'.$notice));
// fclose($myfile);
// }
// else
// {
// $myfile = fopen("./data/dlzemail/".$v['number'].".txt", "a+") or die("Unable to open file!");
// fwrite($myfile, json_encode($fs.';'.$v.';'.$shop.';'.$express.';'.$notice));
// fclose($myfile);
// }
// $this->fullorder->save(array('dlzemail'=>2,'dlzemailtime'=>time()),$v['id']);
// }
// sleep(50);
// }
}
}
}