load->library('session'); $this->load->_model('Model_api','api'); $this->load->_model('Model_apismt','apismt'); $this->load->_model('Model_shop','shop'); $this->load->_model('Model_fullorder','fullorder'); $this->load->_model('Model_fullordertt','fullordertt'); $this->load->_model('Model_fedex_cby','fedex_cby'); $this->load->_model('Model_fullorder_smt','fullorder_smt'); $this->load->_model('Model_fullordersmt','fullordersmt'); $this->load->_model('Model_customersmt','customersmt'); $this->load->_model('Model_country','country'); $this->load->_model('Model_hl','hl'); $this->load->_model('Model_is','is'); $this->load->_model('Model_kdniao','kdniao'); $this->load->_model('Model_typeclass','typeclass'); $this->load->_model('Model_warehouse','warehouse'); $this->load->_model('Model_fullorderexcel','fullorderexcel'); $this->load->_model('Model_dhl','dhl'); $this->load->_model('Model_usps','usps'); $this->load->_model('Model_dhltest','dhltest'); $this->load->_model('Model_customer','customer'); $this->load->_model('Model_express','express'); $this->load->_model('Model_notice','notice'); $this->load->_model('Model_whlabel','whlabel'); $this->load->_model('Model_productdescribe','productdescribe'); $this->load->_model('Model_ljg','ljg'); $this->load->_model('Model_commodityread','commodityread'); $this->load->_model('Model_service','service'); $this->load->_model('Model_fedex','fedex'); $this->load->_model('Model_commodity','commodity'); $this->load->_model('Model_fullordersmtorder','fullordersmtorder'); $this->load->_model('Model_ali','ali'); $this->load->_model('Model_fullordersmthb','fullordersmthb'); $this->load->_model('Model_fullordersmtbf','fullordersmtbf'); $this->load->_model('Model_taxzhengzhou','taxzhengzhou'); $this->load->_model('Model_taxshanghai','taxshanghai'); $this->load->_model('Model_excel','excel'); $this->load->_model('Model_ups','ups'); $this->load->_model('Model_dpd','dpd'); $this->load->_model('Model_cne','cne'); $this->load->_model('Model_outbound','outbound'); $this->load->_model('Model_specialstock','specialstock'); $this->load->_model('Model_setting','setting'); $this->load->_model('Model_pay','pay'); $this->load->_model('Model_shopsku','shopsku'); } //定义方法的调用规则 获取URI第二段值 public function _remap($arg,$arg_array) { if($arg == 'out') { $this->_out($arg_array); } else if($arg == 'sku') { $this->_sku(); } else if($arg == 'spexcel') { $this->_spexcel(); } else if($arg == 'qczd') { $this->_qczd(); } else if($arg == 'setting') { $this->_setting(); } else if($arg == 'sctime') { $this->_sctime(); } else if($arg == 'dpex') { $this->_dpex(); } else if($arg == 'dpay') { $this->_dpay(); } else if($arg == 'excellkh') { $this->_excellkh(); } else if($arg == 'excelshop') { $this->_excelshop(); } else { $this->_index(); } } public function _index() { $setting = $this->setting->get_settings(); $this->data['excelpass'] = $setting['excelpass']; $this->data['excelusernum'] = $setting['excelusernum']; $this->data['exceljmnum'] = $setting['exceljmnum']; $this->data['sctime'] = $setting['sctime']; $this->_Template('boss',$this->data); } public function _out($arg_array) { $post = $this->input->post(NULL, TRUE); if(isset($post['order'])) { $time = $this->input->post('time',true); $time = strtotime($time); $order = $this->input->post('order',true); $weight = $this->input->post('weight',true); if(!isset($weight))//测试没问题后可以删 { $weight = ''; } if(substr($order,0,3) == '788' && substr($order,-4,4) == '0430')//Fedex联邦 { $order = substr($order,0,12); } if(strlen($order) == '34')//联邦杭州超长运单截取 { $order = substr($order,22,12); } if(!$order) { echo json_encode(array('msg'=>'出库信息不能为空!','success'=>false));exit; } $fullorder_name = 'fullorder';$outtype = 1; $y = $this->fullorder->get_waybill($order); if(!$y) { $y = $this->fullorder->get_number($order); $outtype = 2; if(!$y) { $fullorder_name = 'fullordersmt';$outtype = 1; $y = $this->fullordersmt->get_waybill($order); if(!$y) { $y = $this->fullordersmt->get_number($order); $outtype = 2; if(!$y) { $fullorder_name = 'fullordertt';$outtype = 1; $y = $this->fullordertt->get_waybill($order); if(!$y) { $y = $this->fullordertt->get_number($order); $outtype = 2; if(!$y) { echo json_encode(array('msg'=>'无此数据','success'=>false));exit; } } } } } } if($y['mergeid'] == '1') { $y = $this->$fullorder_name->read($y['merge']); } $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')) && $y['type'] != 3)//独立站216先关了 { echo json_encode(array('msg'=>'禁止出库!'.$y['librarynot'],'success'=>false));exit; } if($y['library'] > 1) { 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')?'运单':'发货单'; echo json_encode(array('msg'=>'扫描类型错误!此单需要扫描'.$smlx,'success'=>false));exit; } } if($y['type'] != 7 && $y['waybill'] != '' && $y['printtype'] == '1') { $y['waybill'] = trim($y['waybill'],' '); if(strlen($y['waybill']) == 12 && $y['express'] != 24 && $y['express'] != 31 && $y['express'] != 38 && $y['express'] != 41 && $y['express'] != 6 && $y['express'] != 43 && $y['express'] != 48 && $y['express'] != 50) { echo json_encode(array('msg'=>'出库物流和系统不匹配,请联系梦体解决'.$y['express'].'-1','success'=>false));exit; } else if(strlen($y['waybill']) == 10 && $y['express'] != 1 && $y['express'] != 37 && $y['express'] != 49 && $y['express'] != 42) { echo json_encode(array('msg'=>'出库物流和系统不匹配,请联系梦体解决'.$y['express'].'-2','success'=>false));exit; } else if(strlen($y['waybill']) == 18 && $y['express'] != 3) { echo json_encode(array('msg'=>'出库物流和系统不匹配,请联系梦体解决'.$y['express'].'-3','success'=>false));exit; } } if(($y['express'] == '24' || $y['express'] == '3' || $y['express'] == '28' || $y['express'] == '33' || $y['express'] == '42') && $y['type'] != 6)//杭州除外 { $numweight = str_replace('kg','',$weight); if($weight == '' || $numweight < '0.1' || !is_numeric($numweight)) { echo json_encode(array('msg'=>'此单需要称重!','success'=>false));exit; } $yzweight = explode('.',$numweight); if($yzweight[0] == '') { echo json_encode(array('msg'=>'重量错误,请重新称重!','success'=>false));exit; } if($numweight > '0.98' && $y['express'] == '3') { echo json_encode(array('msg'=>'UPS大于0.98公斤需要拆包!','success'=>false));exit; } if($numweight > '2' && $y['express'] == '37') { echo json_encode(array('msg'=>'杭州DHL大于2公斤需要联系店员!','success'=>false));exit; } if($numweight >= '10' && ($y['express'] == '24' || $y['express'] == '31')) { echo json_encode(array('msg'=>'联邦不能大于10公斤!','success'=>false));exit; } } 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']) > (4*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; echo json_encode(array('msg'=>'此运单过期无法出库,请联系成会处理!','success'=>false));exit; } 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']); if($warehouse['zd'] == '1') { if($warehouse['bdck'] == '') { echo json_encode(array('msg'=>'仓库设置错误!','success'=>false));exit; } $bdck = $warehouse['bdck']; $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['fpdata'] != '' && $kcyz['t'] == '0') { $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) { echo json_encode(array('msg'=>'库存占用量与实际出库量不符!','success'=>false));exit; } } foreach ($wh['sj'] as $v) { $this->$bdck->save(array('state'=>1,'orderinfo'=>$y['orderinfo'],'waybill'=>$y['waybill'],'outk'=>$time,'time'=>$time),$v['id']); } } if($fullorder_name == 'fullordersmt') { $stt = ($y['waybill']!='')?209:$y['state']; $this->$fullorder_name->save(array('library'=>2,'state'=>$stt,'librarytime'=>$time,'weight'=>$weight),$y['id']); } else { if($y['type'] == 3) { $this->$fullorder_name->save(array('print'=>3,'printtime'=>$time,'printnumber'=>1,'state'=>216,'libraryconfirm'=>2,'library'=>2,'librarytime'=>$time,'weight'=>$weight),$y['id']); } else { $this->$fullorder_name->save(array('library'=>2,'librarytime'=>$time,'weight'=>$weight),$y['id']); } } if ($this->db->trans_status() === TRUE) { $this->db->trans_commit(); echo json_encode(array('msg'=>'操作成功!','success'=>true));exit; } else { $this->db->trans_rollback(); echo json_encode(array('msg'=>'出库失败,请重试','success'=>false)); } } } public 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); } } public function _sku()//测试SKU { $post = $this->input->post(NULL, TRUE); if(isset($post['sku'])) { $sku = $this->input->post('sku',true); if($sku == '') { echo json_encode(array('msg'=>'SKU不能为空!','success'=>false));exit; } $gethl = $this->hl->get_hl();//获取即时汇率 $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'); $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']); } } $dictionaries2 = $this->typeclass->find_all(); foreach ($dictionaries2 as $v) { $dtctitle[$v['id']] = $v['title']; } /* 匹配结束 */ /* 价格加入 */ $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]; } /* 匹配ID加入 */ $zjsku = array(); $shopsku = $this->shopsku->find_all(); foreach ($shopsku as $val) { $ss = explode(',',trim($val['shop'],',')); foreach ($ss as $v) { if(isset($zjsku[$v])) { $zjsku[$v] .= ','.trim($val['sku'],','); } else { $zjsku[$v] = trim($val['sku'],','); } } } /* 匹配ID结束 */ $q = ''; $quantity = explode(',',trim($sku,',')); foreach ($quantity as $v) { $q .= '1;'; } $is = $this->is->find_all('1=1','*','number asc');//获取仓库平匹配表 $shop = $this->shop->read(19); if(isset($zjsku[$shop['id']]))//判断是否找到店铺SKU { $sku = rtrim($sku,',').','.$zjsku[$shop['id']]; } $r = $this->api->matching(trim($q,';'),$sku,$dtc,$money,$int,$dtctitle,$shop); $p = ''; $product = explode(';',trim($r['product'],';')); if($r['title'] != '' && $product) { foreach ($product as $v) { $vc = explode('|',$v); $p .= $vc[1].'
'; } $r['title'] = str_replace(array('<','>'),array('<','>'),$r['title']); echo json_encode(array('msg'=>'仓库品名:'.$r['title'].'
商品名称:'.$p,'success'=>true,'r'=>$r));exit; } else { echo json_encode(array('msg'=>'SKU错误','success'=>false));exit; } } } public function matching($quantity,$issku,$dtc,$money,$int,$dtctitle) { $sl = explode(';',$quantity); $x=0;$product = '';//product 每单多产品链接组合 $purchase = 0;$cost = 0;//每单所有产品总成本价格; $whlabel = '|';//库存产品码 $nr = '';$cs = array(); $t = array('/\-\-/','/\+/','/\#Color/','/\#Long/','/-[1-4]-/','/(\w+)~(\w+)-/'); $h = array('-','-','','','-',''); $issku = str_replace(array('(',')'),array('(',')'),$issku); $issku = str_replace(array(' <','> '),array('<','>'),$issku); $issku = strtolower($issku); $varsku = preg_replace($t,$h,$issku);////转大写、匹配更改和删除 $varsku = strtolower($varsku);//转小写 $sku = explode(',',$varsku);//多产品分割为多数组 $pd = explode(',',$issku); $cid = array(); $slpx = array(); $tqjcskua = array();//先检测是否只匹配品名 $tqjcskub = array(); $tqjcqda = array(); $tqjcqdb = array(); $tqjcgit = array();//礼物类放SKU顺序中间 $tqjcgitpd = array();//礼物类放SKU顺序中间 foreach ($sku as $k=>$value) { //查找是否有头套和HD开始 $cf = explode('-',trim($value,'-')); $cf = array_filter($cf); foreach ($cf as $v) { if(isset($dtc[$v]['id'])) { $cid[$dtc[$v]['classid']] = array('id'=>$dtc[$v]['id'],'spare'=>$v,'jm'=>$dtc[$v]['jm']); } } if(isset($cid['44']) && isset($cid['18']) && isset($dtc[strtolower($cid['44']['jm']).$cid['18']['spare']]['id'])) { $value = '-'.$value.'-'; $sku[$k] = '-'.$sku[$k].'-'; $pd[$k] = '-'.$pd[$k].'-'; $value = str_replace('-'.$cid['18']['spare'].'-','-'.$dtc[strtolower($cid['44']['jm']).$cid['18']['spare']]['spare'].'-',$value); $value = str_replace('-'.$cid['44']['spare'],'-',$value); $sku[$k] = str_replace('-'.$cid['18']['spare'].'-','-'.$dtc[strtolower($cid['44']['jm']).$cid['18']['spare']]['spare'].'-',$sku[$k]); $sku[$k] = str_replace('-'.$cid['44']['spare'],'-',$sku[$k]); $pd[$k] = str_replace('-'.$cid['18']['spare'].'-','-'.$dtc[strtolower($cid['44']['jm']).$cid['18']['spare']]['spare'].'-',$pd[$k]); $pd[$k] = str_replace('-'.$cid['44']['spare'],'-',$pd[$k]); $value = strtolower(trim($value,'-')); $pd[$k] = strtolower(trim($pd[$k],'-')); $sku[$k] = strtolower(trim($sku[$k],'-')); } //查找是否有头套和HD结束 if(isset($dtc[$value]['classid'])) { if($dtc[$value]['classid'] == '999' || $dtc[$value]['classid'] == '9999') { $tqjcskua[$k] = $value; $tqjcqda[$k] = $pd[$k]; continue; } } if(stripos($value,'gift') !== false) { $tqjcgit[$k] = $value; $tqjcgitpd[$k] = $pd[$k]; continue; } $tqjcskub[$k] = $value; $tqjcqdb[$k] = $pd[$k]; } $sku = $tqjcskub+$tqjcgit+$tqjcskua; $newsl = array(); foreach ($sku as $k=>$value) { if(!isset($sl[$k])) { $sl[$k] = 1; } $newsl[] = $sl[$k]; } $sl = array_values($newsl); $pd = $tqjcqdb+$tqjcgitpd+$tqjcqda; $sku = array_values($sku);//按照现有顺序键值重新由0开始 $pd = array_values($pd); /** $tqjcskua = array();//先检测是否只匹配品名 $tqjcskub = array(); foreach ($sku as $k=>$value) { if(isset($dtc[$value]['classid'])) { if($dtc[$value]['classid'] == '999' || $dtc[$value]['classid'] == '9999') { $tqjcskua[$k] = $value; continue; } } $tqjcskub[$k] = $value; } $sku = $tqjcskub+$tqjcskua; $sku = array_values($sku);//按照现有顺序键值重新由0开始 **/ foreach ($sku as $value) { $bmsku = ''; if(stripos($value,'-<') !== false && stripos($value,'>-') === false) { $isskufg = explode('-<',$value); $bmsku = '<'.strtoupper($isskufg[1]); } if(stripos($value,'-<') !== false && stripos($value,'>-') !== false) { $isskufg = explode('-<',$value); $isskufgh = explode('>-',$isskufg[1]); $bmsku = '<'.strtoupper($isskufgh[0]).'>'; } if(stripos($value,'-<') === false && stripos($value,'>-') !== false) { $isskufg = explode('>-',$value); $bmsku = strtoupper($isskufg[0]).'>'; } if(stripos($value,'-<') !== false && stripos($value,'>-') === false) { $isskufg = explode('-<',$value); $bmsku = '<'.strtoupper($isskufg[1]); } if(stripos($value,'-<') !== false && stripos($value,'>-') !== false) { $isskufg = explode('-<',$value); $isskufgh = explode('>-',$isskufg[1]); $bmsku = '<'.strtoupper($isskufgh[0]).'>'; } if(stripos($value,'-<') === false && stripos($value,'>-') !== false) { $isskufg = explode('>-',$value); $bmsku = strtoupper($isskufg[0]).'>'; } $value = trim($value,' ');$cpson = array();$cplf = array(); $thisid='';$tha=array();$thb=array(); $purchasemy=0;$costmy=0;$salespricemy=0; $djay = array();//每单单个产品公司销售价格 $ptitlea='';$ptitleb='';//每单产品名称 $cpa='';$cpb='';$fc = 0; $number = array('dc'=>'','c'=>''); $classid = $this->classid->sku(); $pm = $classid;//品名顺序 //等级-真人发类型-化纤发编号-颜色-花型-蕾丝头套种类-化纤头套类型-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-化纤其它属性-头套其它属性-头套属性 100为头套额外附加 $cp = array(16=>126,22=>'',13=>80,14=>'',43=>'',8=>57,15=>'');//产品默认ID内容 //16->类目、22->真人发类型、13->等级、14->长度、8->颜色、15->曲度(花型) $cptt = array(16=>128,13=>80,43=>'',8=>'57',15=>'',18=>'',6=>30,10=>72,9=>'',39=>'');//头套 $cpcp = array(16=>130,13=>80,14=>'',33=>'',8=>57,15=>'',38=>'');//卡子发,7=>33重量 $cpgi = array(16=>131,34=>'');//礼物 $cpac = array(16=>133,35=>'');//配件 $cphxtt = array(16=>1297,13=>80,14=>'',40=>'',8=>57,15=>'',41=>'',42=>''); $cphxhair = array(16=>1702,13=>80,14=>'',47=>'',46=>'',8=>57,15=>'',38=>'',48=>''); if((preg_match('/\d\*\df/',$pd[$x]) || preg_match('/\df/',$pd[$x]) || stripos($pd[$x],'+F') !== false || stripos($pd[$x],'Frontal') !== false) && stripos($pd[$x],'wig') === false && stripos($pd[$x],'Bob') === false) { $u27 = (stripos($pd[$x],'SilkBaseFrontal') !== false)?199:197; $cplf = array(16=>127,27=>$u27,12=>75,10=>72,26=>191,9=>'');//蕾丝发块 $fc = 1; } else if((preg_match('/\d\*\dc/',$pd[$x]) || preg_match('/\dc/',$pd[$x]) || stripos($pd[$x],'+C') !== false || stripos($pd[$x],'Closure') !== false) && stripos($pd[$x],'wig') === false && stripos($pd[$x],'Bob') === false) { $u27 = (stripos($pd[$x],'SilkBaseClosure') !== false)?196:195; $cplf = array(16=>127,27=>$u27,12=>75,10=>72,25=>182,9=>'');//蕾丝发块 if(stripos($pd[$x],'2*6') !== false) { $cplf[12] = 76; } $fc = 1; } $cpcppd = 0; $cpcptype = $this->typeclass->find_all("classid = 33"); foreach ($cpcptype as $v) { $val = explode('|',trim($v['spare'],'|')); foreach ($val as $vv) { if(stripos($pd[$x],$vv) !== false) { $cpcppd++; } } } if($fc==1) { $cpson = $cplf; } else if ((stripos($pd[$x],'wig') !== false || stripos($pd[$x],'Bob') !== false) && stripos($pd[$x],'Syn') === false && stripos($pd[$x],'Gift') === false)// { $cpson = $cptt; } else if ((stripos($pd[$x],'SyHair') !== false || (stripos($pd[$x],'SyHair') !== false && stripos($pd[$x],'Syn') !== false)) && $cpcppd == 0) { $cpson = $cphxhair; $cp = $cpson; } else if (stripos($pd[$x],'Syn') !== false && $cpcppd == 0) { $cpson = $cphxtt; $cp = $cpson; } else if ($cpcppd > 0) { $cpson = $cpcp; $cp = $cpcp; } else if (stripos($pd[$x],'Gift') !== false) { $cpson = $cpgi; } else if (stripos($pd[$x],'Accs') !== false) { $cpson = $cpac; } else { $cpson = $cp; } //$cpson = $fc==1?$cplf:((stripos($pd[$x],'wig') !== false || stripos($pd[$x],'Bob') !== false)?$cptt:(stripos($pd[$x],'Clip') !== false?$cpcp:array()));//是否是类似发块或头套产品 $cs[$x] = $cpson; $son = explode('-',$value);//字符串转数组 $snum = 0;$cpsl = 0; foreach ($son as $val) { if(stripos($val,'^') !== false) { $snum += str_replace('^','',$val); } if(isset($dtc[$val]))//如果能匹配到 { if(is_numeric($val) || $dtc[$val]['classid'] == '14')//如果是组合产品 { $cpsl++; if(!is_numeric($val)) { $pm['c'] = $dtc[$val]['zh']; } else { $pm['c'] = $val.'寸';//尺寸不匹配,并且准备写入到+号后面 } $number['c'] = $val; } else { if(isset($cp[$dtc[$val]['classid']]))//判断匹配ID属于头部还是尾部 { $cp[$dtc[$val]['classid']] = $dtc[$val]['id']; } if(isset($cpson[$dtc[$val]['classid']])) { if($dtc[$val]['id'] != 66)//按要求暂时不匹配中棕颜色 { $cpson[$dtc[$val]['classid']] = $dtc[$val]['id']; } } /** if($pm[15] == '卡子发卡子发' || $dtc[$val]['zh'] == '卡子发卡子发') { $slpx[] = 1; $pm[$dtc[$val]['classid']] = $pm[$dtc[$val]['classid']].' '.$dtc[$val]['zh']; } else **/ if($dtc[$val]['classid'] == '999') { $pm[$dtc[$val]['classid']] .= $dtc[$val]['zh'];//其它正常匹配 } else { $pm[$dtc[$val]['classid']] = $dtc[$val]['zh'];//其它正常匹配 } } } else if(preg_match('/((\d+)\s+(\d+))/',$val) && stripos($val,'NO') === false)//如果不能匹配是多尺寸字符串 { $j = (stripos($pd[$x],'+') !== false)?' +':'';//判断sku是否是+号类型 if(isset($cpson[16])) { if($cpson[16] != 128) { $cpslnum = explode(' ',trim($val,' ')); $cpsl += count($cpslnum); $pm['dc'] = $val.$j;//写入多尺寸字符串 } } else { $cpslnum = explode(' ',trim($val,' ')); $cpsl += count($cpslnum); $pm['dc'] = $val.$j; } $number['dc'] = $val; } } if($sl[$x] > 1 || $snum > 1) { $slx = $sl[$x]; if($snum>1) { $slx = ($slx>1)?$slx:1; $slx *= $snum; } $slpx[] = $cpsl; $nr .= '['.$bmsku.implode(" ",$pm).']*'.$slx.'包'.';';//数组转字符串 } else { if($cpsl > 0) { $slpx[] = $cpsl; } $slx = 1; $pdpm = $bmsku.implode("",$pm); if($pdpm != '') { $nr .= $bmsku.implode(" ",$pm).';';//数组转字符串 } } //以下是特殊类型的匹配 if(stripos($nr,'带绒布内衬半蕾丝头套') !== false && stripos($nr,'#') !== false) { $nr = preg_replace('/\#(\d+)/','内衬颜色$1号色',$nr); } $weightsku = array(); $weightdata = $this->weight->find_all(); foreach ($weightdata as $w) { $weightsku[$w['features']] = $w['weight']; } if($number['dc'] != '') { if(stripos($pd[$x],'+') !== false) { foreach ($cp as $v) { $ptitlea .= isset($dtctitle[$v])?$dtctitle[$v].' ':''; } } else { foreach ($cpson as $v) { $ptitlea .= isset($dtctitle[$v])?$dtctitle[$v].' ':''; } } $dc = explode(' ',trim($number['dc'],' ')); for($i=0;$i$tha[$dc[$i]]['zh'],'id'=>$tha[$dc[$i]]['id'],'count'=>$tha[$dc[$i]]['count']+1):array('zh'=>$dc[$i],'id'=>$thisid,'count'=>1); **/ //一样的不再合并 $tha[] = array('zh'=>$dc[$i],'id'=>$thisid,'count'=>1); } } foreach ($tha as $v) { $item = array_merge($cp);$weight = 0; if($cp['16'] == '126') { $weight = $weightsku['126']; } else if($cp['16'] == '127') { if(isset($item[9])) { $sku127a = $item[0].'-'.$v['id'].'-'.$item[3].'-'.$item[6].'-'.$item[9]; $sku127b = $item[0].'-'.$v['id'].'-'.$item[6].'-'.$item[9]; if(isset($weightsku[$sku127a])) { $weight = $weightsku[$sku127a]; } else if(isset($weightsku[$sku127b])) { $weight = $weightsku[$sku127b]; } } } else if($cp['16'] == '128') { if(isset($item[8])) { $sku128 = $item[0].'-'.$v['id'].'-'.$item[6].'-'.$item[8]; if(isset($weightsku[$sku128])) { $weight = $weightsku[$sku128]; } } } $cpa = $cp;$cpa[14] = $v['id'];$cpa[22] = '';//增加长度ID、去除真人发类型 $whlabel .= implode("",$cpa).'-'.$slx*$v['count'].'-0|'; $pdcc = (is_numeric($v['zh']))?$v['zh'].'inch |':strtoupper($v['zh']).'|'; $product .= $v['id'].',-'.rtrim(implode("-",$cp),'-').'-|'.$ptitlea.$pdcc.$slx*$v['count'].'|0|0|'.$v['zh'].'|0|0|'.$slx*$v['count']*$weight.'|0;'; } } if($number['c'] != '') { $fk = $cp; foreach ($cpson as $k=>$v) { $fk[$k] = $v;//+号左右ID合并右完整ID } foreach ($fk as $v) { $ptitleb .= isset($dtctitle[$v])?$dtctitle[$v].' ':''; } $c = explode(' ',trim($number['c'],' ')); for($i=0;$i$thb[$c[$i]]['zh'],'id'=>$thb[$c[$i]]['id'],'count'=>$thb[$c[$i]]['count']+1):array('zh'=>$c[$i],'id'=>$thisid,'count'=>1); **/ //一样的不再合并 $thb[] = array('zh'=>$c[$i],'id'=>$thisid,'count'=>1); } foreach ($thb as $v) { $item = array_merge($fk);$weight = 0; if($fk['16'] == '126') { $weight = $weightsku[$item[0]]; } else if($fk['16'] == '127') { if(isset($item[9])) { $sku127a = $item[0].'-'.$v['id'].'-'.$item[3].'-'.$item[6].'-'.$item[9]; $sku127b = $item[0].'-'.$v['id'].'-'.$item[6].'-'.$item[9]; if(isset($weightsku[$sku127a])) { $weight = $weightsku[$sku127a]; } else if(isset($weightsku[$sku127b])) { $weight = $weightsku[$sku127b]; } } } else if($fk['16'] == '128') { if(isset($item[8])) { $sku128 = $item[0].'-'.$v['id'].'-'.$item[6].'-'.$item[8]; if(isset($weightsku[$sku128])) { $weight = $weightsku[$sku128]; } } } $cpb = $fk;$cpb[14] = $v['id'];$cpb[22] = '';//增加长度ID、去除真人发类型 $whlabel .= implode("",$cpb).'-'.$slx*$v['count'].'-0|'; $pdcc = (is_numeric($v['zh']))?$v['zh'].'inch |':strtoupper($v['zh']).'|'; $product .= $v['id'].',-'.rtrim(implode("-",$fk),'-').'-|'.$ptitleb.$pdcc.$slx*$v['count'].'|0|0|'.$v['zh'].'|0|0|'.$slx*$v['count']*$weight.'|0;'; } } if (stripos($pd[$x],'Gift-') !== false) { $ptitleg = ''; foreach ($cpson as $v) { $ptitleg .= isset($dtctitle[$v])?$dtctitle[$v].' ':''; } $whlabel .= implode("",$cpson).'-'.$slx.'-0|'; $product .= '-'.rtrim(implode("-",$cpson),'-').'-|'.$ptitleg.'|'.$slx.'|0|0||0|0|0|0;'; } $x++; $purchase += $purchasemy; $cost += $costmy; } $product = str_replace('--','-',$product); $qbslpx = 0;$wcslpx = ''; foreach ($slpx as $v) { $wcslpx .= $qbslpx.'-'.($qbslpx+$v).'|'; $qbslpx += $v; } $nr = str_replace(array('(',')'),array('(',')'),$nr); if(stripos($whlabel,'|--|') !== false) { $whlabel = ''; $product = ''; } return array('title'=>preg_replace(array('/(\s+)/','/分\s/u'),array(' ','分'),trim($nr,';')),'purchase'=>$purchase,'cost'=>$cost,'product'=>str_replace(array('---','--'),array('-','-'),$product),'whlabel'=>$whlabel,'wcslpx'=>trim($wcslpx,'|'),'cs'=>$sku); } public function _spexcel() { $tc = array(); $typeclass = $this->typeclass->find_all(); foreach ($typeclass as $v) { $tc[$v['id']] = $v; } if(isset($_SESSION['api'])) { $user = $this->user->get_api($_SESSION['api']); $usp = $user; $fgshop = "";$sid = "";$excelshop=""; $usersp = explode('|',trim($user['shop'],'|')); foreach ($usersp as $value) { $fgshop .= " shop = ".$value." or"; $sid .= " id = ".$value." or"; } $userexcel = explode('|',trim($user['excelshop'],'|')); foreach ($userexcel as $value) { $excelshop .= " shop = ".$value." or"; } if($excelshop != "") { $excelshop = "(".rtrim($excelshop,'or').")"; } } $post = $this->input->post(NULL, TRUE); if(isset($_GET['category'])) { $timetk = $this->input->get('timetk',true); $timetj = $this->input->get('timetj',true); $color = $this->input->get('color',true); $lowe = $this->input->get('lowe',true); $size = $this->input->get('size',true); $grade = $this->input->get('grade',true); $lacetype = $this->input->get('lacetype',true); $category = $this->input->get('category',true); $shop = $this->input->get('shop',true); $density = $this->input->get('density',true); $time = $this->input->get('time',true); $timetk = strtotime($timetk); $timetj = strtotime($timetj); $where = ""; if($category) { $where .= "fpdata like '%-".$category."-%' and "; } if($color) { $where .= "fpdata like '%-".$color."-%' and "; } if($size) { $where .= "fpdata like '%-".$size."-%' and "; } if($grade) { $where .= "fpdata like '%-".$grade."-%' and "; } if($shop) { $where .= "shop = '$shop' and "; } else { $where .= $excelshop." and "; } if($lowe) { $where .= "fpdata like '%-".$lowe."-%' and "; } if($density) { $where .= "fpdata like '%-".$density."-%' and "; } if($lacetype) { $where .= "fpdata like '%-".$lacetype."-%' and "; } $dataa = $this->fullorder->find_all($where.$time." > '$timetk' and ".$time." < '$timetj'",'fpdata,number,whlabel','id desc'); $datab = $this->fullordersmt->find_all($where.$time." > '$timetk' and ".$time." < '$timetj' and shop != '9'",'fpdata,number,whlabel','id desc'); $datac = $this->fullordertt->find_all($where.$time." > '$timetk' and ".$time." < '$timetj'",'fpdata,number,whlabel','id desc'); $data = array_merge($dataa,$datab,$datac); $sp = array();$cs = array(); foreach ($data as $val) { $f = explode(';',trim($val['fpdata'],';')); $w = explode('|',trim($val['whlabel'],'|')); foreach ($f as $k=>$v) { if($category) { if(stripos($v,'-'.$category.'-') === false) { continue; } } if($color) { if(stripos($v,'-'.$color.'-') === false) { continue; } } if($lowe) { if(stripos($v,'-'.$lowe.'-') === false) { continue; } } if($size) { if(stripos($v,$size.',') === false) { continue; } } if($grade) { if(stripos($v,'-'.$grade.'-') === false) { continue; } } if($lacetype) { if(stripos($v,'-'.$lacetype.'-') === false) { continue; } } if($density) { if(stripos($v,'-'.$density.'-') === false) { continue; } } $title = explode('|',$v); $fg = str_replace(array('-163-','-164-','-165-','-166-','-0-','-126-','-127-','-128-','-197-','-195-'),'-',$title[0]); $fg = explode(',',$fg); $fg = explode('-',trim($fg[1].$fg[0],'-')); $pm = array(13=>'',22=>'',8=>'',15=>'',18=>'','100'=>'',33=>'',34=>'',35=>'','dc'=>'','c'=>'',12=>'',25=>'',26=>'',14=>'',27=>'',10=>'',6=>'',9=>'',39=>'',999=>'',9999=>'');//品名顺序 foreach($fg as $vv) { if(isset($tc[$vv]['zh'])) { $zh = explode('|',trim($tc[$vv]['zh'],'|')); $pm[$tc[$vv]['classid']] = $zh[0]; } } $zh = implode(" ",$pm); $zh = str_replace('自然色 ','',rtrim($zh,' ')); $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh); if(isset($sp[$title[1]])) { $sp[$title[1]]['n'] += $title[2]; } else { $wh = explode('-',$w[$k]); $wsku = $this->whlabel->find_all("number = '".$wh[0]."' and sku != 'Preset'"); $whs = (isset($wsku[0]['sku']))?$wsku[0]['sku']:''; $sp[$title[1]] = array('t'=>$title[1],'z'=>$zh,'w'=>$whs,'n'=>$title[2]); } } } $sp = array_values($sp); $title = "商品统计".date('Y-m-d H-i-s',time()); $titlename = "
名称 中文 SKU 数量
"; $filename = $title.".xls"; $tail = "\n"; $this->excel->get_fz2($sp,$titlename,$filename,$tail); } } public function _setting() { $post = $this->input->post(NULL, TRUE); if(isset($post['excelpass'])) { $excelpass = $this->input->post('excelpass',true); $exceljmnum = $this->input->post('exceljmnum',true); $excelusernum = $this->input->post('excelusernum',true); if($excelpass == '') { echo json_encode(array('msg'=>'密码不能为空','success'=>false));exit; } if($exceljmnum < 1 || $excelusernum < 1) { echo json_encode(array('msg'=>'数量不可以小于1','success'=>false));exit; } $this->setting->save(array('svalue'=>$excelpass),'excelpass'); echo json_encode(array('msg'=>'Excel加密密码修改成功','success'=>false));exit; } } public function _sctime() { $post = $this->input->post(NULL, TRUE); if(isset($post['sctime'])) { $sctime = $this->input->post('sctime',true); if(!is_numeric($sctime)) { echo json_encode(array('msg'=>'必须为正整数的数字!','success'=>false));exit; } $sctime = ($sctime>0)?$sctime*3600:0; $this->setting->save(array('svalue'=>$sctime),'sctime'); echo json_encode(array('msg'=>'时差修改成功!','success'=>false));exit; } } public function _dpay() { $post = $this->input->post(NULL, TRUE); if(isset($post['pay'])) { $pay = $this->input->post('pay',true); $timetk = $this->input->post('timetk',true); $timetj = $this->input->post('timetj',true); $timetk = strtotime($timetk); $timetj = strtotime($timetj); $where = "shouldmoney > '0' and dtime > '$timetk' and dtime < '$timetj' and pay = '$pay'"; if(!$pay) { echo json_encode(array('msg'=>'请选择支付方式!','success'=>false));exit; } $fullorder = $this->fullorder->find_all($where); $this->db->trans_begin(); $cs = array(); $p = $this->pay->get_typeclass($pay); foreach($fullorder as $v) { $yga = $v['shouldmoney'];//金额 $ygc = $p['estimaterate'];//预估到账公式 $ifbudget = eval("return $yga*1.$ygc;"); if($ifbudget > 0) { $this->fullorder->save(array('budget'=>$ifbudget,'estimaterate'=>$ygc),$v['id']); } } if ($this->db->trans_status() === TRUE) { $this->db->trans_commit(); echo json_encode(array('msg'=>'操作成功!','success'=>true));exit; } else { $this->db->trans_rollback(); echo json_encode(array('msg'=>'失败,请重试','success'=>false)); } } } public function _dpex() { $post = $this->input->post(NULL, TRUE); if(isset($post['n'])) { $number = $this->input->post('n',true); $postdata = $this->input->post('postdata',true); $postdata = json_decode($postdata,true); $d = array(); foreach ($postdata as $val) { $d[] = array( 'Money' => 'USD',//货币单位 //'Sku' => '123123',//产品 Sku (OrderType 为仓储订单必传) 'Cnname' => $val['zh'],//产品中文名 'Enname' => $val['en'].'*'.$val['num'],//产品英文名 'Price' => $val['dj']*1,//单价 'Weight' => $val['zl']*1,//重量 'Num' => $val['num']*1,//数量 'CustomsCode'=> $val['hg']//海关编码 ); } $fullorder = $this->fullorder->get_number($number); if(!$fullorder) { $fullorder = $this->fullordersmt->get_number($number); } if(!$fullorder) { echo json_encode(array('msg'=>'没有此编号的订单!','success'=>false));exit; } $fullorder = $this->_text($fullorder); $fullorder['number'] = $fullorder['number'].'-'.date('s',time());//订单号重复修改新订单好 $data = $fullorder; $url = "http://ambcargo.kingtrans.cn/PostInterfaceService?method=createOrder"; $Clientid = 'LYFZP'; $Token = 'NGkJSDx3bAxojl1YN232'; $code = array('DPEX'=>array('11','DPEX','1'),'ARAMEX'=>array('002','安迈世',0),'FEDEX'=>array('FEDEX_1CC','FEDEX_1CC',';lab10_10'),'UPS'=>array('04','UPS',0),'DHL'=>array('06','DHL',';lab10_10'),'FED-SN-IP'=>array('07','FED-SN-IP',';lab10_10'),'WML-FEDEX-ZZ'=>array('05','WML-FEDEX-ZZ',';lab10_10'),'FED-XS-F'=>array('03','FED-XS-F',';lab10_10'),'CNE'=>array('08','全球优先CNE','label10x10;0'),'TCNE'=>array('09','E速宝特惠','label10x10;0')); $printcode = $code[$data['printcode']]; //创建并预报订单 $count = array( 'Verify' => array( 'Clientid'=>$Clientid, 'Token'=>$Token ), 'OrderType' => '1',//1:快件订单 2:快递制单-非实时返回单号 3:仓储订单 4:快递制单-实时返回单号(等待时间较 长)。此方法选择 4,后续如需调用其他 方法,例如调用删除接口,其他方法 OrderType 请选择 2。 'OrderDatas' => array(0=>array( 'CustomerNumber' => $data['number'],//订单号 'ChannelCode' => $printcode[0],//渠道代码 'CountryCode' => $data['lb'],//国家二字码 'TotalWeight' => $data['zzl'],//订单重量 'TotalValue' => $data['zsbjz'],//申报价值 'Number' => $data['zjs'],//件数 'Note' => $data['number'],//备注 /** 'Insurance' => array(//是否购买保险 'Code' => '',//保险类型 'Value' => '',//保险金额 ), **/ 'FeePayData' => array(//运费支付信息 'FeePayType' => 'PP',//支付方式 [ PP:预付,CC:到付, TP:第三方] 'FeePayAccountNumber' => '',//支付账号 支付方式为 TP 时必传 支付方式为 PP 并且渠道 UPS 时必传 'FeePayCountryCode' => '',//支付账号对应国家 支付方式为 TP 时必传 'FeePayPostCode' => '',//支付账号对应邮编 支付方式为 TP 并且渠道 FEDEX 时必传 ), 'TaxPayData' => array(//税金/关税支付信息 OrderType 为 [快递制单] 时必传字段 'TaxPayType' => 'PP',//支付方式 [ PP:预付,CC:到付, TP:第三方] 'TaxPayAccountNumber' => '',//支付账号 支付方式为 TP 时必传 支付方式为 PP 并且渠道 UPS 时必传 'TaxPayCountryCode' => '',//支付账号对应国家 支付方式为 TP 时必传 'TaxPayPostCode' => '',//支付账号对应邮编 支付方式为 TP 并且渠道 FEDEX 时必传 ), 'Recipient' => array(//收件人信息 'Name' => $data['name'],//姓名 'Addres1' => $data['address'],//地址1 'Addres2' => $data['address2'],//地址2 'Mobile' => preg_replace('/\D/s','',$data['phone']),//手机 'Province' => $data['province'],//省/州 'City' => $data['city'],//城市 'Post' => trim($data['zipcode'],' '),//邮编 ), 'OrderItems' => $d)) /**, 'Volumes' => array(//材积明细 (OrderType 为快递制单必传) 'Weight' => '123123',//实重 'Number' => '123123',//件数 'Length' => '123123',//长 'Width' => '123123',//宽 'Height' => '123123',//高 ), **/ ); $count = json_encode($count,true); $ch = curl_init(); curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_HEADER,0); curl_setopt($ch,CURLOPT_POST, 1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600); curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query(array('json'=>$count))); $res = curl_exec($ch); curl_close($ch); $res = json_decode($res,true); if(!isset($res['returnDatas'][0]['corpBillid'])) { echo json_encode(array('msg'=>$res['returnDatas'][0]['message'],'success'=>false));exit; } else { $yd = $this->get_dpex_yd($res['returnDatas'][0]['corpBillid'],$printcode[2]); $fp = $this->get_dpex_fp($res['returnDatas'][0]['corpBillid'],$count); if($yd != 'c' && $fp != 'c') { echo json_encode(array('msg'=>'

查看发票 查看运单

','success'=>true));exit; } else { echo json_encode(array('msg'=>'获取运单失败,请重试','success'=>false));exit; } } } } public function _text($fullorder) { /** 发票地址信息暂时无用 $fullorder['baddress'] = explode(',',$fullorder['baddress']); $fullorder['baddress'] = array_reverse($fullorder['baddress']); $fullorder['baddress'][1] = $country['ename']; **/ //获取所用相关信息 $warehouse = $this->warehouse->read($fullorder['type']); $country = $this->country->read($fullorder['country']);//订单国家信息 $fcountry = $this->country->read($warehouse['country']);//仓库国家信息 $warehouse['country'] = $fcountry['ename'];//仓库国家名 $warehouse['lb'] = $fcountry['lb'];//仓库国家编码 $fullorder['warehouse'] = $warehouse;//仓库数据加入订单 $fullorder['lb'] = $country['lb'];//订单国家编码加入 $fullorder['country'] = $country['ename'];//订单国家名 $fullorder['zhou'] = $country['continent'];//所属州 $express = $this->express->read($fullorder['express']); $fullorder['express'] = $express['servicename']; $fullorder['account'] = $express['account']; $fullorder['printcode'] = $express['printcode']; $fullorder['time'] = date('Y-m-d',time()); $fullorder['times'] = date('Y-m-d H:i',time()); $fullorder['sbbm']= ($fullorder['sbpm'] == 'Hair Sample') ? 67042000 : 67041100; $fullorder['address'] = str_replace(array('&'),array('&'),$fullorder['address']); $fullorder['address2'] = str_replace(array('&'),array('&'),$fullorder['address2']); $fullorder['shipremarks'] = str_replace(array('<','>',';',';'),array('<','>',';
',';
'),$fullorder['shipremarks']); $shop = $this->shop->read($fullorder['shop']); $fullorder['shop'] = $shop['shopname']; if(is_numeric($fullorder['pay'])) { $pay = $this->typeclass->read($fullorder['pay']); if($pay['classid'] == '4') { $fullorder['pay'] = $pay['title']; } } if($fullorder['printcode'] != "USPS") { $fullorder['client'] = htmlspecialchars($fullorder['client']); $fullorder['name'] = htmlspecialchars($fullorder['name']); } //增加退货单所需信息 $pt = ''; $fpdata = explode(';',trim($fullorder['fpdata'],';')); foreach ($fpdata as $v) { $p = explode('|',trim($v,'|')); $pt .= '

'.$p[1].' * '.$p[2].'

'; } $fullorder['pt'] = $pt; return $fullorder; } public function get_dpex_yd($waybill,$PrintPaper) { $url = "http://ambcargo.kingtrans.cn/PostInterfaceService?method=printOrderLabel"; $Clientid = 'LYFZP'; $Token = 'NGkJSDx3bAxojl1YN232'; $count = array( 'Verify' => array( 'Clientid'=>$Clientid, 'Token'=>$Token ), 'CorpBillidDatas'=> array(0=>array('CorpBillid'=>$waybill)), 'OrderType'=> "1",//1:快件订单 2:快递制单 3:仓库订单 'PrintPaper'=> $PrintPaper,//打印纸张 快递制单只固定为:label 和 A4 'PrintContent'=> "1"//打印内容 1:地址标签 2:报关单 3:配货信息 可自由组合用“,”号隔开 如:1,2,3 ); $count = json_encode($count,true); $ch = curl_init(); curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_HEADER,0); curl_setopt($ch,CURLOPT_POST, 1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600); curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query(array('json'=>$count))); $res = curl_exec($ch); curl_close($ch); $res = json_decode($res,true); if($res['statusCode'] == 'success') { return $res['url']; } else { return 'c'; } } public function get_dpex_fp($waybill) { $url = "http://ambcargo.kingtrans.cn/PostInterfaceService?method=printOrderInvoice"; $Clientid = 'LYFZP'; $Token = 'NGkJSDx3bAxojl1YN232'; $count = array( 'Verify' => array( 'Clientid'=>$Clientid, 'Token'=>$Token ), 'CorpBillidDatas'=> array(0=>array('CorpBillid'=>$waybill)) ); $count = json_encode($count,true); $ch = curl_init(); curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_HEADER,0); curl_setopt($ch,CURLOPT_POST, 1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600); curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query(array('json'=>$count))); $res = curl_exec($ch); curl_close($ch); $res = json_decode($res,true); if($res['statusCode'] == 'success') { return $res['url']; } else { return 'c'; } } public function _excellkh() { if(isset($_SESSION['api'])) { $user = $this->user->get_api($_SESSION['api']); $usp = $user; $fgshop = "";$sid = ""; $user = explode('|',trim($user['shop'],'|')); foreach ($user as $value) { if($value != '18' && $value != '19' && $value != '12' && $value != '13' && $value != '9' && $value != '15' && $value != '27') { $fgshop .= " shop = ".$value." or";//去掉指定的店铺 } $sid .= " id = ".$value." or"; } } $post = $this->input->post(NULL, TRUE); if(isset($_GET['time'])) { $s = $this->input->get('shop',true); $time = $this->input->get('time',true); $timetk = $this->input->get('timetk',true); $timetj = $this->input->get('timetj',true); $timetk = strtotime($timetk); $timetj = strtotime($timetj); if($s) { $shop = $this->shop->find_all("id = '$shop'"); } else { $shop = $this->shop->find_all("type = 269 and (".rtrim($sid,'or').')'); } $d = array(); $k = $timetk-24*3600;//少一天为增加选择开始天时间 $j = $timetj; $n = ($j-$k)/(24*3600); if($n < 1) { $n = 1; } for($i=1;$i<$n;$i++) { $t = $j-($n*24*60*60)+($i*24*60*60); foreach($shop as $val) { $data = $this->fullorder->find_all("$time > '$t' and $time < '".($t+24*3600)."' and shop = '".$val['id']."'"); $dd = 0;$m = 0; foreach($data as $v) { $customer = $this->customer->get_email($v['email'],$v['shop']); $customernum = $this->fullorder->find_count("email = '".$v['email']."' and shop = '".$v['shop']."'"); preg_match_all('/[0-9]/u',$v['phone'],$result); $numphone = join('',$result[0]); $customerc = $this->customer->find_all("type = 1 and shop = '".$v['shop']."' and address = '".$v['address']."' and numphone = '".$numphone."'",'*','id desc'); if($customer) { if(($customer['type'] == 1 && $customernum > 1) || (isset($customerc[0]['num']) && $customerc[0]['num'] > 1))// || $customerc['type'] == 1 && $customerc['num'] > 1 { $dd++; $m += $v['shouldmoney']; } } } $d[] = array(date('Y-m-d',$t),$val['shopname'],count($data),sprintf("%01.2f",array_sum(array_column($data,'shouldmoney'))),$dd,$m); } } $title = "老客户数据统计".date('Y-m-d H-i-s',time()); $titlename = "
时间 店铺 订单数 订单金额 老客户订单数 老客户订单金额
"; $filename = $title.".xls"; $tail = "\n"; $this->excel->get_fz2($d,$titlename,$filename,$tail); } } public function _excelshop() { if(isset($_SESSION['api'])) { $user = $this->user->get_api($_SESSION['api']); $usp = $user; $fgshop = "";$sid = ""; $user = explode('|',trim($user['shop'],'|')); foreach ($user as $value) { if($value != '18' && $value != '19' && $value != '12' && $value != '13' && $value != '9' && $value != '15' && $value != '27') { $fgshop .= " shop = ".$value." or";//去掉指定的店铺 } $sid .= " id = ".$value." or"; } } $post = $this->input->post(NULL, TRUE); if(isset($_GET['time'])) { $s = $this->input->get('shop',true); $time = $this->input->get('time',true); $timetk = $this->input->get('timetk',true); $timetj = $this->input->get('timetj',true); $timetk = strtotime($timetk); $timetj = strtotime($timetj); if($s) { $shop = $this->shop->find_all("id = '$shop'"); } else { $shop = $this->shop->find_all("type = 269 and (".rtrim($sid,'or').')'); } $d = array(); $k = $timetk-24*3600;//少一天为增加选择开始天时间 $j = $timetj; $n = ($j-$k)/(24*3600); if($n < 1) { $n = 1; } for($i=1;$i<$n;$i++) { $t = $j-($n*24*60*60)+($i*24*60*60); foreach($shop as $val) { $data = $this->fullorder->find_all("$time > '$t' and $time < '".($t+24*3600)."' and shop = '".$val['id']."'"); $dd = 0;$m = 0; $d[] = array(date('Y-m-d',$t),$val['shopname'],count($data),sprintf("%01.2f",array_sum(array_column($data,'shouldmoney')))); } } $title = "店铺数据统计".date('Y-m-d H-i-s',time()); $titlename = "
时间 店铺 订单数 订单金额
"; $filename = $title.".xls"; $tail = "\n"; $this->excel->get_fz2($d,$titlename,$filename,$tail); } } public function _qczd() { $post = $this->input->post(NULL, TRUE); if(isset($post['number'])) { $number = $this->input->post('number',true); if(!$number || $number == '' || $number == NULL) { echo json_encode(array('msg'=>'没有编号信息','success'=>false));exit; } $a = $this->whlabel->find_all("zd = '$number' and state = '0'"); foreach ($a as $v) { $this->whlabel->save(array('zd'=>''),$v['id']); } echo json_encode(array('msg'=>'清除完成!','success'=>true));exit; } } }