Systemprint.php 102 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. header("Access-Control-Allow-Origin: *");
  3. class Systemprint extends Start_Controller {
  4. public function __construct(){
  5. parent::__construct();
  6. $this->load->library('session');
  7. $this->load->_model('Model_whlabel','whlabel');
  8. $this->load->_model('Model_warehouse','warehouse');
  9. $this->load->_model('Model_productprice','productprice');
  10. $this->load->_model('Model_excel','excel');
  11. $this->load->_model('Model_fullorder','fullorder');
  12. $this->load->_model('Model_fullorder_smt','fullorder_smt');
  13. $this->load->_model('Model_fullordersmt','fullordersmt');
  14. $this->load->_model('Model_fullordertt','fullordertt');
  15. $this->load->_model('Model_fullorderamz','fullorderamz');
  16. $this->load->_model('Model_outbound','outbound');
  17. $this->load->_model('Model_express','express');
  18. $this->load->_model('Model_shop','shop');
  19. $this->load->_model('Model_typeclass','typeclass');
  20. $this->load->_model('Model_country','country');
  21. $this->load->_model('Model_kdniao','kdniao');
  22. $this->load->_model('Model_notice','notice');
  23. $this->load->_model('Model_dhl','dhl');
  24. $this->load->_model('Model_dhlhz','dhlhz');
  25. $this->load->_model('Model_usps','usps');
  26. $this->load->_model('Model_fedex','fedex');
  27. $this->load->_model('Model_cne','cne');
  28. $this->load->_model('Model_fedex_cby','fedex_cby');
  29. $this->load->_model('Model_ups','ups');
  30. $this->load->_model('Model_ali','ali');
  31. $this->load->_model('Model_dpd','dpd');
  32. $this->load->_model('Model_hualeixw','hualeixw');
  33. $this->load->_model('Model_dpdxw','dpdxw');
  34. $this->load->_model('Model_shop','shop');
  35. $this->load->_model('Model_user','user');
  36. $this->load->_model('Model_whlabel','whlabel');
  37. $this->load->_model('Model_dpd_IOSS','dpdioss');
  38. $this->load->_model('Model_whlabelbarcodeprint','whlabelbarcodeprint');
  39. $this->load->_model('Model_whlabelbarcode','whlabelbarcode');
  40. $this->load->_model('Model_yswaybill','yswaybill');
  41. $this->load->_model('Model_hualei','hualei');
  42. $this->load->_model('Model_apiyy','apiyy');
  43. $this->load->_model('Model_classid','classid');
  44. $this->load->_model('Model_fullorderxw','fullorderxw');
  45. $this->load->_model('Model_setting','setting');
  46. $this->load->helper('url');
  47. $this->load->_model("Model_yuntu","yuntu");
  48. $this->load->_model("Model_api","api");
  49. $this->load->_model("Model_fedexv1",'fedexv1');
  50. $this->load->_model("Model_customsdeclaration","customsdeclaration");
  51. $this->load->_model("Model_logic_ding","logic_ding");
  52. $this->load->_model("Model_zxyuntu","zxyuntu");
  53. $this->load->_model("Model_logic_order","logic_order");
  54. $this->load->_model("Model_itsxb","itsxb");
  55. $this->load->_model("Model_express_tt","express_tt");
  56. }
  57. //定义方法的调用规则 获取URI第二段值
  58. public function _remap($arg,$arg_array)
  59. {
  60. if($arg == 'printing')//打印操作
  61. {
  62. $this->_printing();
  63. }
  64. else if($arg == 'printbyfh')
  65. {
  66. $this->_printbyfh();
  67. }
  68. else if($arg == 'getorderinfo')
  69. {
  70. $this->_getInfoByNumber();
  71. }
  72. else if($arg == 'exceldy')
  73. {
  74. $this->_exceldy($arg_array);
  75. }
  76. else if($arg == 'screen')
  77. {
  78. $this->_screen();
  79. }
  80. else if($arg == 'cz')
  81. {
  82. $this->_cz();
  83. }
  84. else if($arg == 'barcode')
  85. {
  86. $this->_barcode();
  87. }
  88. else if($arg == 'barcodedc')
  89. {
  90. $this->_barcodedc();
  91. }
  92. else if($arg == 'barcodedr')
  93. {
  94. $this->_barcodedr();
  95. }
  96. else if($arg == 'yswaybill')
  97. {
  98. $this->_yswaybill();
  99. }
  100. else if($arg == 'mcindex'){
  101. $this->_mcindex();
  102. }
  103. else
  104. {
  105. $this->_index();
  106. }
  107. }
  108. public function _cz()
  109. {
  110. if(isset($_SESSION['api']))
  111. {
  112. $user = $this->user->get_api($_SESSION['api']);
  113. $usp = $user;
  114. $shop = array();$type = array();
  115. $usersp = explode('|',trim($user['shop'],'|'));
  116. $userwh = explode('|',trim($user['warehouse'],'|'));
  117. foreach ($usersp as $v)
  118. {
  119. $shop[$v] = $v;
  120. }
  121. foreach ($userwh as $v)
  122. {
  123. $type[$v] = $v;
  124. }
  125. }
  126. $post = $this->input->post(NULL, TRUE);
  127. if(isset($post['cz']))
  128. {
  129. $cz = $this->input->post('cz');
  130. $cz = explode(',',trim($cz,','));
  131. $bj = $this->input->post('bj');
  132. $i = 0;$a = array();
  133. foreach ($cz as $v)
  134. {
  135. $dd = explode('-',$v);
  136. $fu = $dd[1];
  137. $thisdd = $this->$fu->read($dd[0]);
  138. if(isset($shop[$thisdd['shop']]) && isset($type[$thisdd['type']]))
  139. {
  140. $this->$fu->save(array('wigs'=>$bj),$dd[0]);
  141. $i++;
  142. }
  143. }
  144. if(count($cz) == $i)
  145. {
  146. echo json_encode(array('msg'=>'标记完成!','success'=>true));exit;
  147. }
  148. else if($i == '0')
  149. {
  150. echo json_encode(array('msg'=>'标记失败,请重试!','success'=>false));exit;
  151. }
  152. else
  153. {
  154. echo json_encode(array('msg'=>'有部分标记失败,请检查!','success'=>false));exit;
  155. }
  156. }
  157. }
  158. public function _screen()
  159. {
  160. $post = $this->input->post(NULL, TRUE);
  161. if(isset($_SESSION['api']))
  162. {
  163. $user = $this->user->get_api($_SESSION['api']);
  164. $usp = $user;
  165. $fgshop = "";$sid = "";$wid="";$wtype="";
  166. $usersp = explode('|',trim($user['shop'],'|'));
  167. $userwh = explode('|',trim($user['warehouse'],'|'));
  168. foreach ($usersp as $value)
  169. {
  170. $fgshop .= " shop = ".$value." or";
  171. $sid .= " id = ".$value." or";
  172. }
  173. foreach ($userwh as $value)
  174. {
  175. $wid .= " id = ".$value." or";
  176. $wtype .= " type = ".$value." or";
  177. }
  178. }
  179. if(isset($post['page']))
  180. {
  181. $page = $this->input->post('page',true);
  182. $perpage = $this->input->post('perpage',true);
  183. $wigs = $this->input->post('wigs',true);
  184. $shop = $this->input->post('shop',true);
  185. $orderinfo = $this->input->post('orderinfo',true);
  186. $number = $this->input->post('number',true);
  187. $so = $this->input->post('so',true);
  188. //$where = (isset($_SESSION['api']))?"mergeid != '1' and (state = '207' or state = '209') and (".rtrim($fgshop,'or').") and (".rtrim($wtype,'or').")":"id = '0'";
  189. //$where .= " and express != 0 and printtype > 0 and printtype < 3 and print = 2 and review > 4 and library = 1 and type = 4";
  190. $where = (isset($_SESSION['api']))?"mergeid != '1' and (".rtrim($fgshop,'or').") and (".rtrim($wtype,'or').")":"id = '0'";
  191. if($shop)
  192. {
  193. $where .= " and shop = '$shop'";
  194. }
  195. if($orderinfo)
  196. {
  197. $where .= " and orderinfo = '$orderinfo'";
  198. }
  199. if($number)
  200. {
  201. $where .= " and number = '$number'";
  202. }
  203. if($wigs || $wigs == '0')
  204. {
  205. $where .= " and wigs = '$wigs'";
  206. }
  207. //数据排序
  208. $order_str = "id desc";
  209. if(empty($page))
  210. {
  211. $start = 0;
  212. $perpage = 1;
  213. }
  214. else
  215. {
  216. $start = ($page - 1)*$perpage;
  217. }
  218. $info_list = array();
  219. $info_listsmt = array();
  220. $info_listtt = array();
  221. $info_listxw = array();
  222. $dlz = 0; $smt = 0; $tt = 0;$xw = 0;
  223. //取得信息列表
  224. $info_list = $this->fullorder->find_all($where,'id,shop,orderinfo,number,shipremarks',$order_str,$start,$perpage);
  225. //格式化数据
  226. foreach ($info_list as $key=>$value)
  227. {
  228. $w = $this->fullorder->read($value['id']);
  229. if(stripos($w['issku'],'#pack') !== false)
  230. {
  231. unset($info_list[$key]);
  232. continue;
  233. }
  234. $info_list[$key]['id'] = $value['id'].'-fullorder';
  235. $shop = $this->shop->read($value['shop']);
  236. $info_list[$key]['shop'] = $shop['shopname'];
  237. }
  238. $dlz = $this->fullorder->find_count($where);
  239. $info_listtt = $this->fullordertt->find_all($where,'id,shop,orderinfo,number,shipremarks',$order_str,$start,$perpage);
  240. //格式化数据
  241. foreach ($info_listtt as $key=>$value)
  242. {
  243. $w = $this->fullordertt->read($value['id']);
  244. if(stripos($w['issku'],'#pack') !== false)
  245. {
  246. unset($info_list[$key]);
  247. continue;
  248. }
  249. $info_list[$key]['id'] = $value['id'].'-fullordertt';
  250. $shop = $this->shop->read($value['shop']);
  251. $info_list[$key]['shop'] = $shop['shopname'];
  252. }
  253. $tt = $this->fullordertt->find_count($where);
  254. $info_listamz = $this->fullorderamz->find_all($where,'id,shop,orderinfo,number,shipremarks',$order_str,$start,$perpage);
  255. //格式化数据
  256. foreach ($info_listamz as $key=>$value)
  257. {
  258. $w = $this->fullorderamz->read($value['id']);
  259. if(stripos($w['issku'],'#pack') !== false)
  260. {
  261. unset($info_list[$key]);
  262. continue;
  263. }
  264. $info_list[$key]['id'] = $value['id'].'-fullorderamz';
  265. $shop = $this->shop->read($value['shop']);
  266. $info_list[$key]['shop'] = $shop['shopname'];
  267. }
  268. $amz = $this->fullorderamz->find_count($where);
  269. $info_listxw = $this->fullorderxw->find_all($where,'id,shop,orderinfo,number,shipremarks',$order_str,$start,$perpage);
  270. //格式化数据
  271. foreach ($info_listxw as $key=>$value)
  272. {
  273. $w = $this->fullorderxw->read($value['id']);
  274. if(stripos($w['issku'],'#pack') !== false)
  275. {
  276. unset($info_list[$key]);
  277. continue;
  278. }
  279. $info_list[$key]['id'] = $value['id'].'-fullorderxw';
  280. $shop = $this->shop->read($value['shop']);
  281. $info_list[$key]['shop'] = $shop['shopname'];
  282. }
  283. $xw = $this->fullorderxw->find_count($where);
  284. $info_listsmt = $this->fullordersmt->find_all($where,'id,shop,orderinfo,number,shipremarks',$order_str,$start,$perpage);
  285. //格式化数据
  286. foreach ($info_listsmt as $key=>$value)
  287. {
  288. $w = $this->fullordersmt->read($value['id']);
  289. if(stripos($w['sku'],'#pack') !== false)
  290. {
  291. unset($info_listsmt[$key]);
  292. continue;
  293. }
  294. $info_listsmt[$key]['id'] = $value['id'].'-fullordersmt';
  295. $shop = $this->shop->read($value['shop']);
  296. $info_listsmt[$key]['shop'] = $shop['shopname'];
  297. }
  298. $smt += $this->fullordersmt->find_count($where);
  299. //$total += $this->fullorder_smt->find_count($where);
  300. $total = $dlz+$smt+$tt+$xw+$amz;
  301. $rows = array_merge($info_list,$info_listtt,$info_listamz,$info_listxw,$info_listsmt);
  302. //$rows = array_slice($rows,$start,$perpage);
  303. $pagenum = ceil($total/$perpage);
  304. $over = $total-($start+$perpage);
  305. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($rows));//array_merge($info_list,$info_list_smt,$info_listsmt)
  306. echo json_encode($rows);exit;
  307. }
  308. if(isset($_SESSION['api']))
  309. {
  310. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  311. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  312. $this->data['wlshop'] = $wlshop;
  313. $this->data['warehouse'] = $warehouse;
  314. }
  315. $this->_Template('systemprint_screen',$this->data);
  316. }
  317. public function _index()
  318. {
  319. $post = $this->input->post(NULL, TRUE);
  320. if(isset($_SESSION['api']))
  321. {
  322. $user = $this->user->get_api($_SESSION['api']);
  323. $usp = $user;
  324. $fgshop = "";$sid = "";$wid="";$wtype="";
  325. $usersp = explode('|',trim($user['shop'],'|'));
  326. $userwh = explode('|',trim($user['warehouse'],'|'));
  327. foreach ($usersp as $value)
  328. {
  329. $fgshop .= " shop = ".$value." or";
  330. $sid .= " id = ".$value." or";
  331. }
  332. foreach ($userwh as $value)
  333. {
  334. $wid .= " id = ".$value." or";
  335. $wtype .= " type = ".$value." or";
  336. }
  337. }
  338. if(isset($post['page']))
  339. {
  340. $page = $this->input->post('page',true);
  341. $perpage = $this->input->post('perpage',true);
  342. $timetk = $this->input->post('timetk',true);
  343. $timetj = $this->input->post('timetj',true);
  344. $shop = $this->input->post('shop',true);
  345. $print = $this->input->post('print',true);
  346. $express = $this->input->post('express',true);
  347. $waybill = $this->input->post('waybill',true);
  348. $printtype = $this->input->post('printtype',true);
  349. $orderinfo = $this->input->post('orderinfo',true);
  350. $number = $this->input->post('number',true);
  351. $type = $this->input->post('type',true);
  352. $lowe = $this->input->post('lowe',true);
  353. $info = $this->input->post('info',true);
  354. $ji = $this->input->post('ji',true);
  355. $so = $this->input->post('so',true);
  356. $ckfl = $this->input->post('ckfl',true);
  357. $sfxh = $this->input->post('sfxh',true);
  358. $lowe = $this->input->post('lowe',true);
  359. $color = $this->input->post('color',true);
  360. $is_jiaji = $this->input->post('is_jiaji',true);
  361. $timetk = strtotime($timetk);
  362. $timetj = strtotime($timetj);
  363. $where = (isset($_SESSION['api']))?"(state = '207' or state = '209') and (".rtrim($fgshop,'or').") and (".rtrim($wtype,'or').")":"id = '0'";
  364. if($print == 3)
  365. {
  366. $where .= " and printtime > '$timetk' and printtime < '$timetj' and print = '3' and library = 1";
  367. }
  368. else
  369. {
  370. $where .= " and express != 0 and printtype != 3 and printtype > 0 and print = 2 and review > 4 and library = 1 and reviewtime > '".(time() - 30*24*3600)."'";
  371. //$where .= " and express != 0 and printtype != 3 and printtype > 0 and print = 2 and review > 4 and library = 1 ";
  372. }
  373. if($shop)
  374. {
  375. $where .= " and shop = '$shop'";
  376. }
  377. if($express)
  378. {
  379. $where .= " and express = '$express'";
  380. }
  381. if($printtype)
  382. {
  383. $where .= " and printtype = '$printtype'";
  384. }
  385. if($orderinfo)
  386. {
  387. $where .= " and orderinfo = '$orderinfo'";
  388. }
  389. if($number)
  390. {
  391. $where .= " and number = '$number'";
  392. }
  393. if($waybill)
  394. {
  395. $where .= " and waybill = '$waybill'";
  396. }
  397. if($color)
  398. {
  399. $where .= " and fpdata like '%-$color-%'";
  400. }
  401. if($lowe)
  402. {
  403. $where .= " and fpdata like '%-$lowe-%'";
  404. }
  405. if($type)
  406. {
  407. $where .= " and type = '$type'";
  408. }
  409. else
  410. {
  411. $where .= " and type != '16'";
  412. }
  413. /**
  414. if($type)
  415. {
  416. if($type != '4')
  417. {
  418. $where .= " and type = '$type'";
  419. $where2 = '';
  420. $where3 = '';
  421. }
  422. else
  423. {
  424. $where2 = " and type = '4' and (wigs = '3' or wigs = '8') and issku not like '%#pack%'";
  425. $where3 = " and type = '4' and (wigs = '3' or wigs = '8') and sku not like '%#pack%'";
  426. }
  427. $where_a = "";
  428. $where_b = "";
  429. }
  430. else
  431. {
  432. $where .= " and type != '4'";
  433. $where_a = "(";
  434. $where_b = ")";
  435. $where2 = " or (type = '4' and (wigs = '3' or wigs = '8') and issku not like '%#pack%')";
  436. $where3 = " or (type = '4' and (wigs = '3' or wigs = '8') and sku not like '%#pack%')";
  437. }
  438. **/
  439. if($ji)
  440. {
  441. $where .= " and shipremarks like '%急%'";
  442. }
  443. if($so)
  444. {
  445. $where .= " and shipremarks like '%$so%'";
  446. }
  447. if($ckfl)
  448. {
  449. $where .= " and ckfl = '$ckfl'";
  450. }
  451. if($sfxh != '')
  452. {
  453. $where .= " and sfxh = '$sfxh'";
  454. }
  455. //数据排序
  456. $order_str = ($print != 3)?"id desc":"printtime desc";
  457. if(empty($page))
  458. {
  459. $start = 0;
  460. $perpage = 1;
  461. }
  462. else
  463. {
  464. $start = ($page - 1)*$perpage;
  465. }
  466. $info_list = $info_listtt = $info_listxw = $info_listsmt = $info_listamz =[];
  467. $info_list_jj = $info_listtt_jj = $info_listxw_jj = $info_listsmt_jj = $info_listamz_jj =[];
  468. $dlz = 0; $smt = 0; $tt = 0; $xw = 0;$amz = 0;
  469. $dlz_jj = 0;$smt_jj=0;$tt_jj=0;$xw_jj=0;$amz_jj=0;
  470. $field = 'id,shop,orderinfo,number,express,waybill,print,printtype,printnumber,printtime,shipremarks,is_jiaji';
  471. if(($is_jiaji == 1)||($is_jiaji == -1)){
  472. $where_jiaji = $where." and is_jiaji = 1 ";
  473. $dlz_ret_jj = $this->indexData('fullorder',$start,$perpage,$where_jiaji,$field,$order_str);
  474. $info_list_jj = $dlz_ret_jj['list'];
  475. $dlz_jj = $dlz_ret_jj['total'];
  476. $tt_ret_jj = $this->indexData('fullordertt',$start,$perpage,$where_jiaji,$field,$order_str);
  477. $info_listtt_jj = $tt_ret_jj['list'];
  478. $tt_jj = $tt_ret_jj['total'];
  479. $amz_ret_jj = $this->indexData('fullorderamz',$start,$perpage,$where_jiaji,$field,$order_str);
  480. $info_listamz_jj = $amz_ret_jj['list'];
  481. $amz_jj = $amz_ret_jj['total'];
  482. $smt_ret_jj = $this->indexData('fullordersmt',$start,$perpage,$where_jiaji,$field,$order_str);
  483. $info_listsmt_jj = $smt_ret_jj['list'];
  484. $smt_jj = $smt_ret_jj['total'];
  485. $xw_ret_jj = $this->indexData('fullorderxw',$start,$perpage,$where_jiaji,$field,$order_str);
  486. $info_listxw_jj = $xw_ret_jj['list'];
  487. $xw_jj = $xw_ret_jj['total'];
  488. }
  489. /****************************执行非加急的************************************/
  490. if(($is_jiaji == 0) || ($is_jiaji == -1)){
  491. $where_nojj = $where." and is_jiaji = 0 ";
  492. $dlz_ret = $this->indexData('fullorder',$start,$perpage,$where_nojj,$field,$order_str);
  493. $info_list = $dlz_ret['list'];
  494. $dlz = $dlz_ret['total'];
  495. $tt_ret = $this->indexData('fullordertt',$start,$perpage,$where_nojj,$field,$order_str);
  496. $info_listtt = $tt_ret['list'];
  497. $tt = $tt_ret['total'];
  498. $amz_ret = $this->indexData('fullorderamz',$start,$perpage,$where_nojj,$field,$order_str);
  499. $info_listamz = $amz_ret['list'];
  500. $amz = $amz_ret['total'];
  501. $smt_ret = $this->indexData('fullordersmt',$start,$perpage,$where_nojj,$field,$order_str);
  502. $info_listsmt = $smt_ret['list'];
  503. $smt = $smt_ret['total'];
  504. $xw_ret = $this->indexData('fullorderxw',$start,$perpage,$where_nojj,$field,$order_str);
  505. $info_listxw = $xw_ret['list'];
  506. $xw = $xw_ret['total'];
  507. }
  508. $total = $dlz+$tt+$amz+$smt+$xw+$dlz_jj+$tt_jj+$amz_jj+$smt_jj+$xw_jj;
  509. $pagenum = ceil($total/$perpage);
  510. $over = $total-($start+$perpage);
  511. if($print == 3){
  512. // $rows_jj = $this->indexSort($info_list_jj,$info_listamz_jj,$info_listtt_jj,$info_listxw_jj,$info_listsmt_jj,$print);
  513. // $rows_no = $this->indexSort($info_list,$info_listamz,$info_listtt,$info_listxw,$info_listsmt,$print);
  514. $tmp_all_rows = array_merge($info_list_jj,$info_listamz_jj,$info_listsmt_jj,$info_listtt_jj,$info_listxw_jj,$info_list,$info_listamz,$info_listsmt,$info_listtt,$info_listxw);
  515. $rows = $this->indexSort($tmp_all_rows,$print);
  516. }else{
  517. $tmp_jj_row = array_merge($info_list_jj,$info_listamz_jj,$info_listtt_jj,$info_listxw_jj,$info_listsmt_jj);
  518. $rows_jj = $this->indexSort($tmp_jj_row,$print);
  519. $tmp_no_row = array_merge($info_list,$info_listamz,$info_listtt,$info_listxw,$info_listsmt);
  520. $rows_no = $this->indexSort($tmp_no_row,$print);
  521. $rows = array_merge($rows_jj,$rows_no);
  522. }
  523. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($rows),'cs'=>$where);//array_merge($info_list,$info_list_smt,$info_listsmt)
  524. echo json_encode($rows);exit;
  525. }
  526. if(isset($_SESSION['api']))
  527. {
  528. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  529. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  530. $this->data['wlshop'] = $wlshop;
  531. $this->data['warehouse'] = $warehouse;
  532. }
  533. $this->_Template('systemprint',$this->data);
  534. }
  535. public function _mcindex()
  536. {
  537. $post = $this->input->post(NULL, TRUE);
  538. if(isset($_SESSION['api']))
  539. {
  540. $user = $this->user->get_api($_SESSION['api']);
  541. $usp = $user;
  542. $fgshop = "";$sid = "";$wid="";$wtype="";
  543. $usersp = explode('|',trim($user['shop'],'|'));
  544. $userwh = explode('|',trim($user['warehouse'],'|'));
  545. foreach ($usersp as $value)
  546. {
  547. $fgshop .= " shop = ".$value." or";
  548. $sid .= " id = ".$value." or";
  549. }
  550. foreach ($userwh as $value)
  551. {
  552. $wid .= " id = ".$value." or";
  553. $wtype .= " type = ".$value." or";
  554. }
  555. }
  556. if(isset($_SESSION['api']))
  557. {
  558. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  559. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  560. $this->data['wlshop'] = $wlshop;
  561. $this->data['warehouse'] = $warehouse;
  562. }else{
  563. //未登录不允许访问
  564. header("location:/");
  565. exit;
  566. }
  567. $this->_Template('systemprintmc',$this->data);
  568. }
  569. /**
  570. * $table_name 订单表名
  571. * $start 偏移开始坐标
  572. * $limit 偏移量
  573. * $where 条件
  574. * $field 字段
  575. * $order_str 排序
  576. */
  577. protected function indexData($table_name,$start,$limit,$where,$filed,$order_str){
  578. $info_list = $this->$table_name->find_all($where,$filed,$order_str,$start,$limit);
  579. if(empty($info_list)){
  580. $info_list = [];
  581. }
  582. //格式化数据
  583. foreach ($info_list as $key=>$value)
  584. {
  585. $info_list[$key]['id'] = $value['id'].'-'.$table_name;
  586. $shop = $this->shop->read($value['shop']);
  587. $info_list[$key]['shop'] = $shop['shopname'];
  588. $express = $this->express->read($value['express']);
  589. if($express)
  590. {
  591. $info_list[$key]['express'] = $express['servicename'];
  592. }
  593. else
  594. {
  595. $info_list[$key]['express'] = '未选择';
  596. }
  597. if($value['printtime'] != 0)
  598. {
  599. $info_list[$key]['printtime'] = date('Y-m-d H:i',$value['printtime']);
  600. }
  601. else
  602. {
  603. $info_list[$key]['printtime'] = '无';
  604. }
  605. if($value['print'] == 1)
  606. {
  607. $info_list[$key]['print'] = "禁止打印";
  608. }
  609. else if($value['print'] == 2)
  610. {
  611. $info_list[$key]['print'] = "未打印";
  612. }
  613. else if($value['print'] == 3)
  614. {
  615. $info_list[$key]['print'] = "已打印";
  616. }
  617. if($value['printtype'] == 1)
  618. {
  619. $info_list[$key]['printtype'] = "运单";
  620. }
  621. else if($value['printtype'] == 2)
  622. {
  623. $info_list[$key]['printtype'] = "发货单";
  624. }
  625. else if($value['printtype'] == 0)
  626. {
  627. $info_list[$key]['printtype'] = "未选择";
  628. }
  629. if($value['is_jiaji'] == 1){
  630. $info_list[$key]['number'] = "<c style='color:red'>".$value['number']."</c>";
  631. }
  632. unset($info_list[$key]['is_jiaji']);
  633. $info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  634. }
  635. $total = $this->$table_name->find_count($where);
  636. return [
  637. 'list'=>$info_list,
  638. 'total'=>$total,
  639. ];
  640. }
  641. //订单表排序
  642. protected function indexSort($rows,$print){
  643. foreach($rows as $k=>$v){
  644. $rows[$k]['index'] = $v['shipremarks'].$v['id'];
  645. }
  646. $tmp_rows = array_column($rows,null,'index');
  647. ksort($tmp_rows);
  648. $tmp_rows = array_values($tmp_rows);
  649. foreach($tmp_rows as $k=>$v){
  650. unset($tmp_rows[$k]['index']);
  651. }
  652. $rows = $tmp_rows;
  653. $tmp = array();
  654. if($print == 3)
  655. {
  656. foreach ($rows as $key => $val)
  657. {
  658. $tmp[$key] = $val['printtime'];
  659. }
  660. array_multisort($tmp,SORT_DESC,$rows);
  661. }
  662. return $rows;
  663. }
  664. //打印
  665. public function _printing()
  666. {
  667. $post = $this->input->post(NULL, TRUE);
  668. if(isset($post['s']))
  669. {
  670. $v = $this->input->post('s');
  671. $va = explode(',',rtrim($v,','));
  672. $n = $this->input->post('n');
  673. $tf = $this->input->post('tf');
  674. $type = 3;$text = array();$text['data'] = array();$time = time();
  675. $pd = explode('-',$va[$n]);
  676. $va[$n] = $pd[0];
  677. $fullorder_name = $pd[1];
  678. $fullorder = $this->$fullorder_name->read($va[$n]);
  679. if(isset($va[$n+1]))
  680. {
  681. $xyz = explode('-',$va[$n+1]);
  682. $sf = $this->$fullorder_name->read($xyz[0]);
  683. }
  684. if($tf)
  685. {
  686. if($tf == '2' && ($fullorder['print'] == 3 || $fullorder['printtime'] > 0))
  687. {
  688. echo json_encode(array('msg'=>$fullorder['number'].' 此订单已打印,请提交给技术处理','success'=>false));exit;
  689. }
  690. }
  691. if($fullorder['print'] == 1)
  692. {
  693. echo json_encode(array('msg'=>$fullorder['number'].' 店员已操作禁止打印,请刷新当前程序','success'=>false));exit;
  694. }
  695. if($fullorder['print'] == 2 && $fullorder['printtime'] > 0)
  696. {
  697. echo json_encode(array('msg'=>$fullorder['number'].' 状态异常,请提交给技术处理','success'=>false));exit;
  698. }
  699. $fullorder = $this->_text($fullorder);//获取所需信息
  700. $this->logic_ding->sendToDing("打印快递单,订单的信息".json_encode($fullorder,JSON_UNESCAPED_UNICODE));
  701. //美仓不需要海关报关信息,
  702. if($fullorder['type'] != 5){
  703. //中国发货的 目前是dhl需要海关申报编码
  704. if(empty($fullorder['sbbm'])){
  705. echo json_encode(array('msg'=>$fullorder['number'].' 海关申报配置异常,请提交给技术处理'.$fullorder['sbbm'],'success'=>false));exit;
  706. }
  707. }
  708. $oldprinttime = ($fullorder['printtime'] > 0)?$fullorder['oldprinttime'].$fullorder['printtime'].'-':'';
  709. $fullorder['printtime'] = date('m-d H:i',$time);//打印用时间、发货单用,不能删
  710. $pdfnum = 1;//PDF打印几遍
  711. if($fullorder['printtype'] == 1 && $fullorder['library'] != 2)// && $fullorder['library'] != 2
  712. {
  713. if($fullorder['printcode'] == "DHL")//如果打印过那么重新获取运单
  714. {
  715. $barcode = $this->dhl->get_data($fullorder);//获取DHL快递信息
  716. if(isset($barcode['AirwayBillNumber']))
  717. {
  718. $bctime = date('Ymd',$time);
  719. $Hwaybill = $barcode['AirwayBillNumber'];
  720. $Hfp = $this->_pdf($barcode['LabelImage']['MultiLabels']['MultiLabel']['DocImageVal'],'f-'.$Hwaybill,$bctime);
  721. $Hyd = $this->_pdf($barcode['LabelImage']['OutputImage'],'y-'.$Hwaybill,$bctime);
  722. if(isset($Hfp) && isset($Hyd) && isset($Hwaybill))
  723. {
  724. if($fullorder['waybill'] != "")
  725. {
  726. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  727. }
  728. else
  729. {
  730. $oldwaybill = $fullorder['oldwaybill'];
  731. }
  732. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  733. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  734. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  735. {
  736. $type = 1;
  737. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>70);
  738. }
  739. }
  740. }
  741. else
  742. {
  743. $this->$fullorder_name->save(array('print'=>1,'failed'=>json_encode($barcode,JSON_UNESCAPED_UNICODE)),$va[$n]);
  744. // if(isset($barcode['Response']['Status']['Condition']['ConditionData']) || isset($barcode['Response']['Status']['Condition'][0]['ConditionData']))
  745. // {
  746. // $failed = (isset($barcode['Response']['Status']['Condition']['ConditionData'])?$barcode['Response']['Status']['Condition']['ConditionData']:$barcode['Response']['Status']['Condition'][0]['ConditionData']);
  747. // $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  748. // }
  749. }
  750. }
  751. else if($fullorder['printcode'] == "DHLUSA")//DHL9610
  752. {
  753. $barcode = $this->dhl->get_data($fullorder);//获取DHL快递信息
  754. if(isset($barcode['AirwayBillNumber']))
  755. {
  756. $bctime = date('Ymd',$time);
  757. $Hwaybill = $barcode['AirwayBillNumber'];
  758. $Hfp = $this->_pdf($barcode['LabelImage']['MultiLabels']['MultiLabel']['DocImageVal'],'f-'.$Hwaybill,$bctime);
  759. $Hyd = $this->_pdf($barcode['LabelImage']['OutputImage'],'y-'.$Hwaybill,$bctime);
  760. if(isset($Hfp) && isset($Hyd) && isset($Hwaybill))
  761. {
  762. if($fullorder['waybill'] != "")
  763. {
  764. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  765. }
  766. else
  767. {
  768. $oldwaybill = $fullorder['oldwaybill'];
  769. }
  770. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  771. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  772. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  773. {
  774. $type = 1;
  775. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>85);
  776. }
  777. }
  778. }
  779. else
  780. {
  781. if(isset($barcode['Response']['Status']['Condition']['ConditionData']) || isset($barcode['Response']['Status']['Condition'][0]['ConditionData']))
  782. {
  783. $failed = (isset($barcode['Response']['Status']['Condition']['ConditionData'])?$barcode['Response']['Status']['Condition']['ConditionData']:$barcode['Response']['Status']['Condition'][0]['ConditionData']);
  784. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  785. }
  786. }
  787. /**
  788. if(isset($barcode['AirwayBillNumber']))
  789. {
  790. $bctime = date('Ymd',$time);
  791. $Hwaybill = $barcode['AirwayBillNumber'];
  792. $Hfp = $this->_pdf($barcode['LabelImage']['MultiLabels']['MultiLabel']['DocImageVal'],'f-'.$Hwaybill,$bctime);
  793. $Hyd = $this->_pdf($barcode['LabelImage']['OutputImage'],'y-'.$Hwaybill,$bctime);
  794. if(isset($Hfp) && isset($Hyd) && isset($Hwaybill))
  795. {
  796. $fullorder['waybill'] = $Hwaybill;
  797. $sb = $this->dhl->get_data_9610($fullorder);
  798. if($sb != 1)
  799. {
  800. $this->$fullorder_name->save(array('print'=>1,'failed'=>$sb),$va[$n]);
  801. }
  802. else
  803. {
  804. if($fullorder['waybill'] != "")
  805. {
  806. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  807. }
  808. else
  809. {
  810. $oldwaybill = $fullorder['oldwaybill'];
  811. }
  812. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  813. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  814. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  815. {
  816. $type = 1;
  817. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>85);
  818. }
  819. }
  820. }
  821. }
  822. else
  823. {
  824. if(isset($barcode['Response']['Status']['Condition']['ConditionData']) || isset($barcode['Response']['Status']['Condition'][0]['ConditionData']))
  825. {
  826. $failed = (isset($barcode['Response']['Status']['Condition']['ConditionData'])?$barcode['Response']['Status']['Condition']['ConditionData']:$barcode['Response']['Status']['Condition'][0]['ConditionData']);
  827. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  828. }
  829. }
  830. **/
  831. }
  832. /**
  833. else if($fullorder['printcode'] == "DHLHZ")//如果打印过那么重新获取运单
  834. {
  835. $barcode = $this->dhlhz->get_data($fullorder);//获取DHL快递信息
  836. if($barcode['c'] == 1)
  837. {
  838. $bctime = date('Ymd',$time);
  839. $Hwaybill = $barcode['data']['waybill'];
  840. $Hfp = $this->_pdf($barcode['data']['fp'],'f-'.$Hwaybill,$bctime);
  841. $Hyd = $this->_pdf($barcode['data']['yd'],'y-'.$Hwaybill,$bctime);
  842. if(isset($Hfp) && isset($Hyd) && isset($Hwaybill))
  843. {
  844. if($fullorder['waybill'] != "")
  845. {
  846. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  847. }
  848. else
  849. {
  850. $oldwaybill = $fullorder['oldwaybill'];
  851. }
  852. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  853. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  854. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  855. {
  856. $type = 1;
  857. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>85);
  858. }
  859. }
  860. }
  861. else
  862. {
  863. if(isset($barcode['data']))
  864. {
  865. $failed = $barcode['data'];
  866. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  867. }
  868. }
  869. }
  870. **/
  871. else if($fullorder['printcode'] == "USPS")
  872. {
  873. $barcode = $this->usps->get_data($fullorder);
  874. //改新的去掉
  875. // if(isset($barcode[0]))
  876. // {
  877. // $barcode = $barcode[0];
  878. // }
  879. //if(isset($barcode['LabelImage']) || isset($barcode[0]['LabelImage']))
  880. //改新的去掉
  881. if(isset($barcode['labelImage']))
  882. {
  883. $bctime = date('Ymd',$time);
  884. //$Hwaybill = substr($barcode['BarcodeNumber'], 8); //改新的去掉 新的 Labellmage 改 labelImage
  885. $Hwaybill = $barcode['trackingNumber'];
  886. $Hyd = $this->_pdf($barcode['labelImage'],'y-'.$Hwaybill,$bctime);
  887. //$Hyd = $this->_pdf($barcode['LabelImage'],'y-'.$Hwaybill,$bctime);
  888. //if(isset($barcode['LabelImage']) && isset($Hwaybill))
  889. if(isset($barcode['labelImage']) && isset($Hwaybill))
  890. {
  891. if($fullorder['waybill'] != "")
  892. {
  893. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  894. }
  895. else
  896. {
  897. $oldwaybill = $fullorder['oldwaybill'];
  898. }
  899. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  900. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  901. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime,'freight'=>0),$va[$n]))//'freight'=>$barcode['extraServices'][0]['price']
  902. {
  903. $type = 1;
  904. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>95);
  905. }
  906. }
  907. }
  908. else if(isset($barcode['error']))
  909. {
  910. $failed = $barcode['Description'];//错误提示
  911. if(stripos($failed,'The requested Mail') === false)
  912. {
  913. if($failed != 'false')
  914. {
  915. $this->$fullorder_name->save(array('print'=>1,'failed'=>json_encode($barcode['error'])),$va[$n]);
  916. }
  917. }
  918. }
  919. /**
  920. else if(isset($barcode['error']['message']))
  921. {
  922. if(isset($barcode['error']['errors'][0]['detail']))
  923. {
  924. $failed = $barcode['error']['errors'][0]['detail'];//错误提示
  925. }
  926. else
  927. {
  928. $failed = $barcode['error']['message'];//错误提示
  929. }
  930. //if(stripos($failed,'The requested Mail') === false)
  931. //{
  932. if($failed != 'false')
  933. {
  934. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  935. }
  936. //}
  937. }
  938. **/
  939. else
  940. {
  941. $failed = json_encode($barcode);//错误提示
  942. if($failed != 'false')
  943. {
  944. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  945. }
  946. }
  947. }
  948. else if($fullorder['printcode'] == "FEDEXGF")//官方FEDEX接口
  949. {
  950. //$barcode = $this->fedex->get_data($fullorder);//获取联邦快递信息
  951. //接口升级
  952. $barcode = $this->fedexv1->get_data($fullorder);//获取联邦快递信息
  953. if($barcode['x'] == 1)
  954. {
  955. $bctime = date('Ymd',$time);
  956. $Hwaybill = $barcode['waybill'];
  957. $Hyd = $this->_pdfurl($barcode['label'],'y-'.$Hwaybill,$bctime);
  958. $Hfp = $this->_pdfurl($barcode['invoice'],'f-'.$Hwaybill,$bctime);//开通ETD模式,保留PDF,不需要打印
  959. // $Hyd = $this->_pdf($barcode['label'],'y-'.$Hwaybill,$bctime);
  960. // $Hfp = $this->_pdf($barcode['invoice'],'f-'.$Hwaybill,$bctime);//开通ETD模式,保留PDF,不需要打印
  961. if(isset($barcode['label']) && isset($Hwaybill))
  962. {
  963. if($fullorder['waybill'] != "")
  964. {
  965. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  966. }
  967. else
  968. {
  969. $oldwaybill = $fullorder['oldwaybill'];
  970. }
  971. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  972. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  973. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  974. {
  975. $type = 1;
  976. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>95,'fp'=>base_url().'data/pdf/'.$bctime.'/f-'.$Hwaybill.'.pdf');
  977. }
  978. }
  979. }
  980. else
  981. {
  982. if(isset($barcode['Description']))
  983. {
  984. if($barcode['Description'] != 'FEDEX_INTERNATIONAL_PRIORITY is not supported for the origin and destination pair.')
  985. {
  986. $failed = $barcode['Description'];//错误提示
  987. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  988. }
  989. else
  990. {
  991. $failed = 'FEDEX返回不正确信息';//错误提示
  992. }
  993. }
  994. }
  995. }
  996. /**
  997. else if($fullorder['printcode'] == "FEDEXCBY")//官方FEDEX接口许昌玉美桥
  998. {
  999. $barcode = $this->fedex_cby->get_data($fullorder);//获取联邦快递信息
  1000. if($barcode['x'] == 1)
  1001. {
  1002. $bctime = date('Ymd',$time);
  1003. $Hwaybill = $barcode['waybill'];
  1004. $Hyd = $this->_pdf($barcode['label'],'y-'.$Hwaybill,$bctime);
  1005. $Hfp = $this->_pdf($barcode['invoice'],'f-'.$Hwaybill,$bctime);//开通ETD模式,保留PDF,不需要打印
  1006. if(isset($barcode['label']) && isset($Hwaybill))
  1007. {
  1008. if($fullorder['waybill'] != "")
  1009. {
  1010. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1011. }
  1012. else
  1013. {
  1014. $oldwaybill = $fullorder['oldwaybill'];
  1015. }
  1016. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1017. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1018. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1019. {
  1020. $type = 1;
  1021. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>95);
  1022. }
  1023. }
  1024. }
  1025. else
  1026. {
  1027. if(isset($barcode['Description']))
  1028. {
  1029. $failed = $barcode['Description'];//错误提示
  1030. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1031. }
  1032. }
  1033. }
  1034. **/
  1035. else if($fullorder['printcode'] == "DPD" || $fullorder['printcode'] == "FTFEDEX")
  1036. {
  1037. $barcode = $this->dpd->get_data($fullorder);//获取联邦快递信息
  1038. if($barcode['x'] == 1)
  1039. {
  1040. $bctime = date('Ymd',$time);
  1041. $Hwaybill = $barcode['waybill'];
  1042. $Hyd = $this->_pdf($barcode['yd'],'y-'.$Hwaybill,$bctime);
  1043. if(isset($barcode['yd']) && isset($Hwaybill) && $Hwaybill != '' && $barcode['yd'] != '')
  1044. {
  1045. if($fullorder['waybill'] != "")
  1046. {
  1047. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1048. }
  1049. else
  1050. {
  1051. $oldwaybill = $fullorder['oldwaybill'];
  1052. }
  1053. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1054. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1055. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1056. {
  1057. $type = 1;
  1058. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>98);
  1059. }
  1060. }
  1061. else if(isset($barcode['yd']) && $Hwaybill == '' && $barcode['yd'] == '')
  1062. {
  1063. $oldwaybill = $fullorder['oldwaybill'];
  1064. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1065. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1066. {
  1067. $type = 2;
  1068. }
  1069. }
  1070. else
  1071. {
  1072. $failed = 'DPD平台可能已产生订单信息,需要查看并删除再处理错误。'.$barcode['res'];//错误提示
  1073. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1074. }
  1075. }
  1076. else
  1077. {
  1078. $failed = $barcode['Description'];//错误提示
  1079. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1080. }
  1081. }
  1082. else if($fullorder['printcode'] == "DPDIOSS" || $fullorder['printcode'] == "FTFEDEXIOSS")
  1083. {
  1084. $barcode = $this->dpdioss->get_data($fullorder);//获取联邦快递信息
  1085. /** 正常
  1086. if($barcode['x'] == 1)
  1087. {
  1088. $bctime = date('Ymd',$time);
  1089. $Hwaybill = $barcode['waybill'];
  1090. $Hyd = $this->_pdf($barcode['yd'],'y-'.$Hwaybill,$bctime);
  1091. if(isset($barcode['yd']) && isset($Hwaybill) && $Hwaybill != '' && $barcode['yd'] != '')
  1092. {
  1093. if($fullorder['waybill'] != "")
  1094. {
  1095. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1096. }
  1097. else
  1098. {
  1099. $oldwaybill = $fullorder['oldwaybill'];
  1100. }
  1101. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1102. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1103. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1104. {
  1105. $type = 1;
  1106. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>98);
  1107. }
  1108. }
  1109. else
  1110. {
  1111. $failed = '平台可能已产生订单信息,需要查看并删除再处理错误。'.$barcode['res'];//错误提示
  1112. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1113. }
  1114. }
  1115. **/
  1116. //临时开始
  1117. if($barcode['x'] == 1)
  1118. {
  1119. $bctime = date('Ymd',$time);
  1120. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1121. if($this->$fullorder_name->save(array('libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldprinttime'=>$oldprinttime),$va[$n]))
  1122. {
  1123. $type = 2;
  1124. }
  1125. }
  1126. //临时结束
  1127. else
  1128. {
  1129. $failed = $barcode['Description'];//错误提示
  1130. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1131. }
  1132. }
  1133. // 只获取运单号不打印运单
  1134. else if($fullorder['printcode'] == "DPDXW" || $fullorder['printcode'] == "UKDHLXW" || $fullorder['printcode'] == "FTFEDEXXW")
  1135. {
  1136. $barcode = $this->dpdxw->get_data($fullorder);//获取联邦快递信息
  1137. if($barcode['x'] == 1)
  1138. {
  1139. $bctime = date('Ymd',$time);
  1140. $Hwaybill = $barcode['waybill'];
  1141. $Hyd = $this->_pdf($barcode['yd'],'y-'.$Hwaybill,$bctime);
  1142. if(isset($barcode['yd']) && isset($Hwaybill) && $Hwaybill != '' && $barcode['yd'] != '')
  1143. {
  1144. if($fullorder['waybill'] != "")
  1145. {
  1146. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1147. }
  1148. else
  1149. {
  1150. $oldwaybill = $fullorder['oldwaybill'];
  1151. }
  1152. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1153. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1154. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1155. {
  1156. $type = 1;
  1157. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>98);
  1158. }
  1159. }
  1160. else
  1161. {
  1162. $failed = 'DPD平台可能已产生订单信息,需要查看并删除再处理错误。'.$barcode['res'];//错误提示
  1163. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1164. }
  1165. }
  1166. else
  1167. {
  1168. $failed = $barcode['Description'];//错误提示
  1169. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1170. }
  1171. }
  1172. /**
  1173. // 此DPD接口暂时不用
  1174. // DPD只获取运单号不打印运单
  1175. else if($fullorder['printcode'] == "DPD")
  1176. {
  1177. if($fullorder['zhou'] == '12')//欧洲
  1178. {
  1179. if($fullorder_name == 'fullordersmt')//速卖通9610
  1180. {
  1181. $fullorder['ysfs'] == '1921';
  1182. }
  1183. else if($fullorder_name == 'fullorder')//独立站9610
  1184. {
  1185. $fullorder['ysfs'] == '2021';
  1186. }
  1187. }
  1188. else if($fullorder['zhou'] == '13')//非洲
  1189. {
  1190. $fullorder['ysfs'] == '1881';
  1191. }
  1192. //$fullorder['ysfs'] == '2041';//欧洲全程不包双清、税
  1193. //$fullorder['ysfs'] == '1981';//欧洲速卖通非9610
  1194. //$fullorder['ysfs'] == '2001';//欧洲独立站非9610
  1195. $barcode = $this->dpd->get_data($fullorder);//获取信息
  1196. if($barcode['x'] == 1)//$barcode['a'] == 2 && $Hyd['a'] == 2
  1197. {
  1198. $bctime = date('Ymd',$time);
  1199. $Hwaybill = $barcode['waybill'];//运单号
  1200. if($fullorder['waybill'] != "")
  1201. {
  1202. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1203. }
  1204. else
  1205. {
  1206. $oldwaybill = $fullorder['oldwaybill'];
  1207. }
  1208. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1209. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1210. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1211. {
  1212. $type = 2;
  1213. }
  1214. }
  1215. else
  1216. {
  1217. $failed = $barcode['Description'];
  1218. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1219. }
  1220. }
  1221. **/
  1222. /** 阿里仓联邦不打印运单模式
  1223. else if($fullorder['printcode'] == "FEDEX" || $fullorder['printcode'] == "TOLL" || $fullorder['printcode'] == "ARAMEX")
  1224. {
  1225. $lj = $this->ali->get_lj($fullorder['number'],2,'订单修改');
  1226. $barcode = $this->ali->get_data($fullorder);//获取DHL快递信息
  1227. //$Hyd = $this->ali->get_label($fullorder['number'],1);//目前不需要打印标签
  1228. //1:10 X 10标签 2:A4纸 3:10X15标签 默认1
  1229. if($barcode['a'] == 2)//$barcode['a'] == 2 && $Hyd['a'] == 2
  1230. {
  1231. $bctime = date('Ymd',$time);
  1232. $Hwaybill = $barcode['number'];//运单号
  1233. //$this->_pdfurl($Hyd['pdf'],'y-'.$Hwaybill,$bctime);//目前不需要打印标签
  1234. if($fullorder['waybill'] != "")
  1235. {
  1236. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1237. }
  1238. else
  1239. {
  1240. $oldwaybill = $fullorder['oldwaybill'];
  1241. }
  1242. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1243. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1244. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1245. {
  1246. $type = 2;
  1247. }
  1248. }
  1249. else
  1250. {
  1251. $failed = $barcode['m'];
  1252. //$failed = isset($barcode['m'])?$barcode['m']:'-(此单已预报,务必先取消再允许打印)';//获取运单号错误提示
  1253. //$failed .= isset($Hyd['m'])?$Hyd['m']:'';//获取标签错误提示
  1254. if($fullorder['print'] == 3)
  1255. {
  1256. $this->$fullorder_name->save(array('libraryconfirm'=>1,'failed'=>date('Y-m-d H:i:s',time()).$failed),$va[$n]);
  1257. }
  1258. else
  1259. {
  1260. $this->$fullorder_name->save(array('print'=>1,'failed'=>date('Y-m-d H:i:s',time()).$failed),$va[$n]);
  1261. }
  1262. }
  1263. }
  1264. **/
  1265. else if($fullorder['printcode'] == "FEDEX" || $fullorder['printcode'] == "TOLL" || $fullorder['printcode'] == "ARAMEX")
  1266. {
  1267. $lj = $this->ali->get_lj($fullorder['number'],2,'订单修改');
  1268. $barcode = $this->ali->get_data($fullorder);//获取快递信息
  1269. $Hyd = $this->ali->get_label($fullorder['number'],1);//目前不需要打印标签
  1270. //1:10 X 10标签 2:A4纸 3:10X15标签 默认1
  1271. if($barcode['a'] == 2 && $Hyd['a'] == 2)
  1272. {
  1273. $bctime = date('Ymd',$time);
  1274. $Hwaybill = $barcode['number'];//运单号
  1275. $this->_pdfurl($Hyd['pdf'],'y-'.$Hwaybill,$bctime);//上传PDF
  1276. if($fullorder['waybill'] != "")
  1277. {
  1278. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1279. }
  1280. else
  1281. {
  1282. $oldwaybill = $fullorder['oldwaybill'];
  1283. }
  1284. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1285. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1286. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1287. {
  1288. $type = 1;
  1289. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>95);
  1290. }
  1291. }
  1292. else
  1293. {
  1294. //$failed = $barcode['m'];
  1295. $failed = isset($barcode['m'])?$barcode['m']:'-(此单已预报,务必先取消再允许打印)';//获取运单号错误提示
  1296. $failed .= isset($Hyd['m'])?$Hyd['m']:'';//获取标签错误提示
  1297. if($fullorder['print'] == 3)
  1298. {
  1299. $this->$fullorder_name->save(array('libraryconfirm'=>1,'failed'=>date('Y-m-d H:i:s',time()).$failed),$va[$n]);
  1300. }
  1301. else
  1302. {
  1303. $this->$fullorder_name->save(array('print'=>1,'failed'=>date('Y-m-d H:i:s',time()).$failed),$va[$n]);
  1304. }
  1305. }
  1306. }
  1307. else if($fullorder['printcode'] == "UPS")//接口
  1308. {
  1309. $barcode = $this->ups->get_data($fullorder);//获取快递信息
  1310. if($barcode['x'] == 1)
  1311. {
  1312. $bctime = date('Ymd',$time);
  1313. $Hwaybill = $barcode['waybill'];
  1314. $Hyd = $this->_pdfurl($barcode['label'],'y-'.$Hwaybill,$bctime);
  1315. if(isset($barcode['label']) && isset($Hwaybill))
  1316. {
  1317. if($fullorder['waybill'] != "")
  1318. {
  1319. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1320. }
  1321. else
  1322. {
  1323. $oldwaybill = $fullorder['oldwaybill'];
  1324. }
  1325. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1326. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1327. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1328. {
  1329. $type = 1;
  1330. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>95);
  1331. }
  1332. }
  1333. }
  1334. else
  1335. {
  1336. $failed = $barcode['Description'];//错误提示
  1337. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1338. }
  1339. }
  1340. else if($fullorder['printcode'] == "DPEX" || $fullorder['printcode'] == "FedEx_2day" || $fullorder['printcode'] == "usps_priority" || $fullorder['printcode'] == 'FEDEX_G' || $fullorder['printcode'] == 'FedEx_GD')//官方FEDEX接口
  1341. {
  1342. if($fullorder['waybillid'] != '')
  1343. {
  1344. $del = $this->cne->get_del($fullorder['waybillid']);
  1345. }
  1346. $barcode = $this->cne->get_data($fullorder);
  1347. if($barcode['x'] == 1)
  1348. {
  1349. $bctime = date('Ymd',$time);
  1350. $Hwaybill = $barcode['waybill'];
  1351. $Hyd = $this->_pdfurl($barcode['yd'],'y-'.$Hwaybill,$bctime);
  1352. //$Hfp = $this->_pdfurl($barcode['fp'],'f-'.$Hwaybill,$bctime);//保留PDF,不需要打印
  1353. if(isset($barcode['yd']) && isset($Hwaybill))
  1354. {
  1355. if($fullorder['waybill'] != "")
  1356. {
  1357. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1358. }
  1359. else
  1360. {
  1361. $oldwaybill = $fullorder['oldwaybill'];
  1362. }
  1363. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1364. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1365. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'waybillid'=>$barcode['waybillid'],'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1366. {
  1367. $type = 1;
  1368. $pdfnum = ($fullorder['printcode'] == "DPEX")?2:1;
  1369. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>100);
  1370. }
  1371. }
  1372. }
  1373. else
  1374. {
  1375. //云尚比较特殊 有时间请求500 也会在对方系统中
  1376. //$fullorder['printnumber'] = $fullorder['printnumber'] +1;
  1377. if(empty($barcode['Description'])){
  1378. $this->logic_ding->sendToDing("云尚打印返回错误未保存【".$fullorder['number']."】".json_encode($barcode));
  1379. $failed = "API接口异常,订单打印失败";//错误提示
  1380. }else{
  1381. $failed = $barcode['Description'];//错误提示
  1382. }
  1383. //$this->$fullorder_name->save(array('print'=>1,'failed'=>$failed,'printnumber'=>$fullorder['printnumber']),$va[$n]);
  1384. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1385. }
  1386. }
  1387. else if($fullorder['printcode'] == "HUALEIXW-FEDEX" || $fullorder['printcode'] == "HUALEIXW-GES-GB-A" || $fullorder['printcode'] == "HUALEIXW-GES-EU9610" || $fullorder['printcode'] == "HUALEIXW-TNT" || $fullorder['printcode'] == "HUALEIXW-FEDEX" || $fullorder['printcode'] == "HUALEIXW-UPS" || $fullorder['printcode'] == "HUALEIXW-FEDEX-EUROPE" || $fullorder['printcode'] == "HUALEIXW-USPS" || $fullorder['printcode'] == "HUALEIXW-DHL" || $fullorder['printcode'] == "HUALEIXW-ARAMEX"|| $fullorder['printcode'] == "HUALEIXW-HC-FEDEX")
  1388. {
  1389. $barcode = $this->hualeixw->get_data($fullorder);
  1390. $bctime = date('Ymd',$time);
  1391. if(!isset($barcode['x']))
  1392. {
  1393. print_r($barcode);exit;
  1394. }
  1395. if($barcode['x'] == 1)
  1396. {
  1397. if($barcode['ys'] == 1)
  1398. {
  1399. if(!$this->yswaybill->insert(array('type'=>$fullorder_name,'express'=>'hualeixw','number'=>$fullorder['number'])))
  1400. {
  1401. echo json_encode(array('msg'=>'失败请重试','success'=>false));exit;
  1402. }
  1403. $bctime = date('Ymd',$time);
  1404. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1405. if($this->$fullorder_name->save(array('waybill'=>$barcode['waybill'],'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldprinttime'=>$oldprinttime),$va[$n]))
  1406. {
  1407. $type = 2;
  1408. }
  1409. }
  1410. else
  1411. {
  1412. $Hwaybill = $barcode['waybill'];
  1413. $Hyd = $this->_pdfurl($barcode['label'],'y-'.$Hwaybill,$bctime);
  1414. if(isset($barcode['label']) && isset($Hwaybill))
  1415. {
  1416. if($fullorder['waybill'] != "")
  1417. {
  1418. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1419. }
  1420. else
  1421. {
  1422. $oldwaybill = $fullorder['oldwaybill'];
  1423. }
  1424. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1425. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1426. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1427. {
  1428. if($fullorder['printcode'] == "HUALEIXW-FEDEX")
  1429. {
  1430. $type = 5;
  1431. }
  1432. else
  1433. {
  1434. $type = 2;
  1435. }
  1436. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>95);
  1437. }
  1438. }
  1439. }
  1440. }
  1441. else
  1442. {
  1443. $failed = $barcode['Description'];//错误提示
  1444. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1445. }
  1446. /**
  1447. if($barcode['x'] == 1)
  1448. {
  1449. if($barcode['ys'] == 1)
  1450. {
  1451. if(!$this->yswaybill->insert(array('type'=>$fullorder_name,'express'=>'hualeixw','number'=>$fullorder['number'])))
  1452. {
  1453. echo json_encode(array('msg'=>'失败请重试','success'=>false));exit;
  1454. }
  1455. }
  1456. $bctime = date('Ymd',$time);
  1457. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1458. if($this->$fullorder_name->save(array('libraryconfirm'=>2,'librarynot'=>'','waybill'=>$barcode['waybill'],'printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldprinttime'=>$oldprinttime),$va[$n]))
  1459. {
  1460. $type = 2;
  1461. }
  1462. }
  1463. else
  1464. {
  1465. $failed = $barcode['Description'];//错误提示
  1466. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1467. }
  1468. **/
  1469. }
  1470. else if($fullorder['printcode'] == "HUALEI-FEDEX" || $fullorder['printcode'] == "HUALEI-ARAMEX-S" || $fullorder['printcode'] == "HUALEI-ARAMEX-G" || $fullorder['printcode'] == "HUALEI-GES-EU" || $fullorder['printcode'] == "HUALEI-DHL-A1" || $fullorder['printcode'] == "HUALEI-WMS"||$fullorder['printcode'] == 'HUALEI-DHL' || $fullorder['printcode'] == 'HUALEI-MLXY' || $fullorder['printcode'] == 'HUALEI-MGLB' || $fullorder['printcode'] == 'HUALEI-UNI')
  1471. {
  1472. $barcode = $this->hualei->get_data($fullorder);
  1473. $bctime = date('Ymd',$time);
  1474. if(!isset($barcode['x']))
  1475. {
  1476. print_r($barcode);exit;
  1477. }
  1478. if($barcode['x'] == 1)
  1479. {
  1480. if($barcode['ys'] == 1)
  1481. {
  1482. if(!$this->yswaybill->insert(array('type'=>$fullorder_name,'express'=>'hualei','number'=>$fullorder['number'])))
  1483. {
  1484. echo json_encode(array('msg'=>'失败请重试','success'=>false));exit;
  1485. }
  1486. $bctime = date('Ymd',$time);
  1487. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1488. $waybill2 = '';
  1489. if(isset($barcode['waybill2']))
  1490. {
  1491. $waybill2 = $barcode['waybill2'];
  1492. }
  1493. if($this->$fullorder_name->save(array('waybill'=>$barcode['waybill'],'waybill2'=>$waybill2,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldprinttime'=>$oldprinttime),$va[$n]))
  1494. {
  1495. $type = 2;
  1496. }
  1497. }
  1498. else
  1499. {
  1500. $Hwaybill = $barcode['waybill'];
  1501. $Hyd = $this->_pdfurl($barcode['label'],'y-'.$Hwaybill,$bctime);
  1502. if(isset($barcode['label']) && isset($Hwaybill))
  1503. {
  1504. if($fullorder['waybill'] != "")
  1505. {
  1506. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1507. }
  1508. else
  1509. {
  1510. $oldwaybill = $fullorder['oldwaybill'];
  1511. }
  1512. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1513. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1514. $waybill2 = '';
  1515. if(isset($barcode['waybill2']))
  1516. {
  1517. $waybill2 = $barcode['waybill2'];
  1518. }
  1519. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'waybill2'=>$waybill2,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1520. {
  1521. if($fullorder['printcode'] == "HUALEI-FEDEX" || $fullorder['printcode'] == "HUALEI-MLXY" )
  1522. {
  1523. //$type = 5;
  1524. $type = 1;
  1525. }
  1526. else if($fullorder['printcode'] == "HUALEI-ARAMEX-G" || $fullorder['printcode'] == "HUALEI-ARAMEX-S" || $fullorder['printcode'] == "HUALEI-GES-EU")
  1527. {
  1528. $type = 1;
  1529. }
  1530. else if($fullorder['printcode'] == "HUALEI-DHL")
  1531. {
  1532. //$type = 5;
  1533. $type = 1;
  1534. }
  1535. else if($fullorder['printcode'] == "HUALEI-MGLB")
  1536. {
  1537. //$type = 5;
  1538. $type = 1;
  1539. }
  1540. else if($fullorder['printcode'] == "HUALEI-UNI"){
  1541. $type = 1;
  1542. }
  1543. else
  1544. {
  1545. $type = 2;
  1546. }
  1547. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>95);
  1548. }
  1549. }
  1550. }
  1551. }
  1552. else
  1553. {
  1554. $failed = $barcode['Description'];//错误提示
  1555. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1556. }
  1557. }
  1558. /** 云途开始**/
  1559. else if(($fullorder['printcode'] == "YunExpress")||($fullorder['printcode'] =='YunExpress_BaoXian'))
  1560. {
  1561. // echo "123";
  1562. // exit;
  1563. // if(!empty($fullorder['waybill']))
  1564. // {
  1565. // $label = $this->yuntu->get_label($fullorder['number']);
  1566. // if($label['x'] == 1){
  1567. // $bctime = date('Ymd',$time);
  1568. // $Hwaybill = $fullorder['waybill'];//运单号
  1569. // $this->_pdfurl($label['url'],'y-'.$Hwaybill,$bctime);//上传PDF
  1570. // $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1571. // if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3),$va[$n]))
  1572. // {
  1573. // $type = 1;
  1574. // $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>95);
  1575. // }
  1576. // }
  1577. // }
  1578. // else{
  1579. $barcode = $this->yuntu->get_data($fullorder);//获取快递信息
  1580. // var_dump($barcode);
  1581. if($barcode['x'] == 1){
  1582. $bctime = date('Ymd',$time);
  1583. $Hwaybill = $barcode['waybill'];//运单号
  1584. $this->_pdfurl($barcode['url'],'y-'.$Hwaybill,$bctime);//上传PDF
  1585. if($fullorder['waybill'] != "")
  1586. {
  1587. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1588. }
  1589. else
  1590. {
  1591. $oldwaybill = $fullorder['oldwaybill'];
  1592. }
  1593. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1594. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1595. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1596. {
  1597. $type = 1;
  1598. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>95);
  1599. }
  1600. }else{
  1601. $failed = $barcode['Description'].'123';//错误提示
  1602. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1603. }
  1604. //}
  1605. //die;
  1606. }
  1607. elseif(($fullorder['printcode'] == "USKD01") || ($fullorder['printcode'] == "ZXDPD_UK") || ($fullorder['printcode'] == "ZXDPD_BTC")){
  1608. if($fullorder['waybillid'] != '')
  1609. {
  1610. $del = $this->zxyuntu->get_del($fullorder['waybillid']);
  1611. }
  1612. // $send_info = $fullorder;
  1613. // $send_info['number'] = $send_info['number']."_".$fullorder['printnumber'];
  1614. //$barcode = $this->zxyuntu->get_data($send_info);
  1615. $barcode = $this->zxyuntu->get_data($fullorder);
  1616. if($barcode['x'] == 1)
  1617. {
  1618. $bctime = date('Ymd',$time);
  1619. $Hwaybill = $barcode['waybill'];
  1620. $Hyd = $this->_pdfurl($barcode['yd'],'y-'.$Hwaybill,$bctime);
  1621. //$Hfp = $this->_pdfurl($barcode['fp'],'f-'.$Hwaybill,$bctime);//保留PDF,不需要打印
  1622. if(isset($barcode['yd']) && isset($Hwaybill))
  1623. {
  1624. if($fullorder['waybill'] != "")
  1625. {
  1626. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1627. }
  1628. else
  1629. {
  1630. $oldwaybill = $fullorder['oldwaybill'];
  1631. }
  1632. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1633. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1634. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'waybillid'=>$barcode['waybillid'],'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1635. {
  1636. $type = 1;
  1637. $pdfnum = 1;
  1638. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>100);
  1639. }
  1640. }
  1641. }
  1642. else
  1643. {
  1644. $failed = $barcode['Description'];//错误提示
  1645. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1646. }
  1647. }elseif(($fullorder['printcode'] == "3PE_XB") || ($fullorder['printcode'] == "3PE_NONBOX")){
  1648. //$fullorder['printnumber'] = $fullorder['printnumber'] +1;//暂时等一下
  1649. if($fullorder['printnumber'] > 0){
  1650. $tmp_number = $fullorder['number'];
  1651. $tmp_printnumber = $fullorder['printnumber'] - 1;
  1652. if($tmp_printnumber > 0){
  1653. $tmp_number = $tmp_number."_".$tmp_printnumber;
  1654. }
  1655. $this->itsxb->cancel_order($tmp_number);
  1656. }
  1657. $barcode = $this->itsxb->get_data($fullorder);
  1658. if($barcode['x'] == 1)
  1659. {
  1660. $bctime = date('Ymd',$time);
  1661. $Hwaybill = $barcode['waybill'];
  1662. $Hyd = $this->_pdfurl($barcode['label'],'y-'.$Hwaybill,$bctime);
  1663. //$Hfp = $this->_pdfurl($barcode['fp'],'f-'.$Hwaybill,$bctime);//保留PDF,不需要打印
  1664. if(isset($barcode['label']) && isset($Hwaybill))
  1665. {
  1666. if($fullorder['waybill'] != "")
  1667. {
  1668. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1669. }
  1670. else
  1671. {
  1672. $oldwaybill = $fullorder['oldwaybill'];
  1673. }
  1674. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1675. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1676. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'waybill2'=>$barcode['waybill2'],'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1677. {
  1678. $type = 8;
  1679. $pdfnum = 1;
  1680. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>100);
  1681. }
  1682. }
  1683. }
  1684. else
  1685. {
  1686. $failed = $barcode['Description'];//错误提示
  1687. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1688. }
  1689. }elseif(($fullorder['printcode'] == "TTUK")){
  1690. $barcode = $this->express_tt->get_data($fullorder,"FBT");
  1691. $this->logic_ding->sendToDing("TTUK获取快递面单".json_encode($barcode));
  1692. if($barcode['x'] == 1)
  1693. {
  1694. $bctime = date('Ymd',$time);
  1695. $Hwaybill = $barcode['waybill'];
  1696. $Hyd = $this->_pdfurl($barcode['label'],'y-'.$Hwaybill,$bctime);
  1697. //$Hfp = $this->_pdfurl($barcode['fp'],'f-'.$Hwaybill,$bctime);//保留PDF,不需要打印
  1698. if(isset($barcode['label']) && isset($Hwaybill))
  1699. {
  1700. if($fullorder['waybill'] != "")
  1701. {
  1702. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  1703. }
  1704. else
  1705. {
  1706. $oldwaybill = $fullorder['oldwaybill'];
  1707. }
  1708. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  1709. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1710. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$va[$n]))
  1711. {
  1712. $type = 1;
  1713. $pdfnum = 1;
  1714. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>85);
  1715. }
  1716. }
  1717. }
  1718. else
  1719. {
  1720. $failed = $barcode['Description'];//错误提示
  1721. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$va[$n]);
  1722. }
  1723. }else
  1724. {
  1725. $this->$fullorder_name->save(array('print'=>1,'failed'=>'未找到此快递运单接口'),$va[$n]);
  1726. }
  1727. if($fullorder_name == 'fullordersmt' || $fullorder_name == 'fullorder_smt')
  1728. {
  1729. $text['name'] = '速卖通';
  1730. }
  1731. else if($fullorder_name == 'fullordertt')
  1732. {
  1733. $text['name'] = 'TikTok';
  1734. }
  1735. else if($fullorder_name == 'fullorderamz')
  1736. {
  1737. $text['name'] = '亚马逊';
  1738. }
  1739. else if($fullorder_name == 'fullorderxw')
  1740. {
  1741. $text['name'] = '翔文';
  1742. }
  1743. else
  1744. {
  1745. $text['name'] = '独立站';
  1746. }
  1747. $text['express'] = $fullorder['express'];
  1748. //$text['country'] = $fullorder['country'];
  1749. $text['country'] = $this->logic_order->getCountry($fullorder['country']);
  1750. $text['orderinfo'] = $fullorder['orderinfo'];
  1751. $text['number'] = $fullorder['number'];
  1752. $text['shipremarks'] = $fullorder['shipremarks'];
  1753. $text['ts'] = $fullorder['ts'];
  1754. $text['time'] = $fullorder['times'];
  1755. $text['printnumber'] = $fullorder['printnumber'];
  1756. $text['pdfnum'] = $pdfnum;
  1757. $text['pt'] = $fullorder['pt'];
  1758. $text['warehouse'] = $fullorder['warehouse']['title'];
  1759. $text['is_jiaji'] = $fullorder['is_jiaji'];
  1760. $rows = array('type'=>$type,'n'=>$n-1,'data'=>$v,'text'=>$text);
  1761. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  1762. }
  1763. else if(($fullorder['printtype'] == 2 || $fullorder['printtype'] == 4) && $fullorder['library'] != 2)
  1764. {
  1765. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  1766. if($this->$fullorder_name->save(array('libraryconfirm'=>2,'librarynot'=>'','printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldprinttime'=>$oldprinttime),$va[$n]))
  1767. {
  1768. $type = 2;
  1769. }
  1770. if($fullorder_name == 'fullordersmt' || $fullorder_name == 'fullorder_smt')
  1771. {
  1772. $text['name'] = '速卖通';
  1773. }
  1774. else
  1775. {
  1776. $text['name'] = '独立站';
  1777. }
  1778. $text['express'] = $fullorder['express'];
  1779. //$text['country'] = $fullorder['country'];
  1780. $text['country'] = $this->logic_order->getCountry($fullorder['country']);
  1781. $text['orderinfo'] = $fullorder['orderinfo'];
  1782. $text['number'] = $fullorder['number'];
  1783. $text['shipremarks'] = $fullorder['shipremarks'];
  1784. $text['ts'] = $fullorder['ts'];
  1785. $text['time'] = $fullorder['times'];
  1786. $text['printnumber'] = $fullorder['printnumber'];
  1787. $text['pdfnum'] = $pdfnum;
  1788. $text['pt'] = $fullorder['pt'];
  1789. $text['warehouse'] = $fullorder['warehouse']['title'];
  1790. $text['is_jiaji'] = $fullorder['is_jiaji'];
  1791. $rows = array('type'=>$fullorder['printtype'],'n'=>$n-1,'data'=>$v,'text'=>$text);
  1792. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  1793. }
  1794. else
  1795. {
  1796. if($fullorder_name == 'fullordersmt' || $fullorder_name == 'fullorder_smt')
  1797. {
  1798. $text['name'] = '速卖通';
  1799. }
  1800. else
  1801. {
  1802. $text['name'] = '独立站';
  1803. }
  1804. $text['express'] = $fullorder['express'];
  1805. //$text['country'] = $fullorder['country'];
  1806. $text['country'] = $this->logic_order->getCountry($fullorder['country']);
  1807. $text['orderinfo'] = $fullorder['orderinfo'];
  1808. $text['number'] = $fullorder['number'];
  1809. $text['shipremarks'] = $fullorder['shipremarks'];
  1810. $text['ts'] = $fullorder['ts'];
  1811. $text['time'] = $fullorder['times'];
  1812. $text['printnumber'] = $fullorder['printnumber'];
  1813. $text['pdfnum'] = $pdfnum;
  1814. $text['warehouse'] = $fullorder['warehouse']['title'];
  1815. $text['is_jiaji'] = $fullorder['is_jiaji'];
  1816. $rows = array('type'=>$type,'n'=>$n-1,'data'=>$v,'text'=>$text);
  1817. echo json_encode(array('msg'=>'该订单已出库,无法打印!','success'=>false));exit;
  1818. }
  1819. }
  1820. }
  1821. public function _text($fullorder)
  1822. {
  1823. /** 发票地址信息暂时无用
  1824. $fullorder['baddress'] = explode(',',$fullorder['baddress']);
  1825. $fullorder['baddress'] = array_reverse($fullorder['baddress']);
  1826. $fullorder['baddress'][1] = $country['ename'];
  1827. **/
  1828. //获取所用相关信息
  1829. $warehouse = $this->warehouse->read($fullorder['type']);
  1830. $country = $this->country->read($fullorder['country']);//订单国家信息
  1831. $fcountry = $this->country->read($warehouse['country']);//仓库国家信息
  1832. $warehouse['country'] = $fcountry['ename'];//仓库国家名
  1833. $warehouse['lb'] = $fcountry['lb'];//仓库国家编码
  1834. $fullorder['warehouse'] = $warehouse;//仓库数据加入订单
  1835. $fullorder['lb'] = $country['lb'];//订单国家编码加入
  1836. $fullorder['country'] = $country['ename'];//订单国家名
  1837. $fullorder['zhou'] = $country['continent'];//所属州
  1838. $express = $this->express->read($fullorder['express']);
  1839. $fullorder['express'] = $express['servicename'];
  1840. $fullorder['account'] = $express['account'];
  1841. $fullorder['printcode'] = $express['printcode'];
  1842. $fullorder['time'] = date('Y-m-d',time());
  1843. $fullorder['times'] = date('Y-m-d H:i',time());
  1844. // $fullorder['sbbm']= ($fullorder['sbpm'] == 'Hair Sample') ? 67042000 : 67041100;
  1845. // 修复报关编码问题
  1846. $declara_info = $this->customsdeclaration->find("ename like '%".trim($fullorder['sbpm'])."%' ","*");
  1847. $sbbm = "";
  1848. if(empty($declara_info)){
  1849. $sbbm = "";
  1850. }else{
  1851. $sbbm = $declara_info['bname'];
  1852. }
  1853. $fullorder['sbbm']= $sbbm;
  1854. $fullorder['address'] = str_replace(array('&'),array('&#38;'),$fullorder['address']);
  1855. $fullorder['address2'] = str_replace(array('&'),array('&#38;'),$fullorder['address2']);
  1856. $fullorder['shipremarks'] = str_replace(array('&lt;','&gt;'),array('<','>'),$fullorder['shipremarks']);
  1857. $fullorder['shipremarks'] = str_replace(array('<','>',';',';'),array('&lt','&gt',';<br>',';<br>'),$fullorder['shipremarks']);
  1858. $shop = $this->shop->read($fullorder['shop']);
  1859. $fullorder['tmp_shop_id'] = $fullorder['shop'];
  1860. $fullorder['shop'] = $shop['shopname'];
  1861. $shoptype = $this->typeclass->read($shop['type']);
  1862. $fullorder['shoptype'] = $shoptype['classtitle'];
  1863. $fullorder['city'] = preg_replace('/( | | |\s)/',' ',$fullorder['city']);
  1864. $fullorder['province'] = preg_replace('/( | | |\s)/',' ',$fullorder['province']);
  1865. if(is_numeric($fullorder['pay']))
  1866. {
  1867. $pay = $this->typeclass->read($fullorder['pay']);
  1868. if($pay['classid'] == '4')
  1869. {
  1870. $fullorder['pay'] = $pay['title'];
  1871. }
  1872. }
  1873. if($fullorder['printcode'] != "USPS")
  1874. {
  1875. $fullorder['client'] = htmlspecialchars($fullorder['client']);
  1876. $fullorder['name'] = htmlspecialchars($fullorder['name']);
  1877. }
  1878. //增加退货单所需信息
  1879. $pt = '';
  1880. $fpdata = explode(';',trim($fullorder['fpdata'],';'));
  1881. foreach ($fpdata as $v)
  1882. {
  1883. $p = explode('|',trim($v,'|'));
  1884. if(isset($p[1]) && isset($p[2]))
  1885. {
  1886. $pt .= '<p>'.$p[1].' * '.$p[2].'</p>';
  1887. }
  1888. }
  1889. $fullorder['pt'] = $pt;
  1890. return $fullorder;
  1891. }
  1892. public function _pdf($pdf,$title,$bctime)
  1893. {
  1894. $pdf_path = './data/pdf/'.$bctime.'/';
  1895. $file_base64 = $pdf;
  1896. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  1897. $file_base64 = base64_decode($file_base64);
  1898. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  1899. file_put_contents($pdf_path.$title.'.pdf',$file_base64);
  1900. return $bctime;
  1901. }
  1902. public function _pdfurl($pdf,$title,$bctime)
  1903. {
  1904. $pdf_path = './data/pdf/'.$bctime.'/';
  1905. $pdf = fopen($pdf,"r");
  1906. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  1907. file_put_contents($pdf_path.$title.'.pdf',$pdf);
  1908. return $bctime;
  1909. }
  1910. public function _exceldy()
  1911. {
  1912. if(isset($_GET['fexcel']))
  1913. {
  1914. if(isset($_SESSION['api']))
  1915. {
  1916. $user = $this->user->get_api($_SESSION['api']);
  1917. $usp = $user;
  1918. $fgshop = "";$sid = "";$wid="";$wtype="";
  1919. $usersp = explode('|',trim($user['shop'],'|'));
  1920. $userwh = explode('|',trim($user['warehouse'],'|'));
  1921. foreach ($usersp as $value)
  1922. {
  1923. $fgshop .= " shop = ".$value." or";
  1924. $sid .= " id = ".$value." or";
  1925. }
  1926. foreach ($userwh as $value)
  1927. {
  1928. $wid .= " id = ".$value." or";
  1929. $wtype .= " type = ".$value." or";
  1930. }
  1931. }
  1932. $dowid = $this->input->get('a');
  1933. $wid = "";
  1934. if($dowid != "")
  1935. {
  1936. $id_arr = explode(',',rtrim($dowid,','));
  1937. foreach ($id_arr as $v)
  1938. {
  1939. $wid .= " id = '$v' or";
  1940. }
  1941. $wid = " and (".rtrim($wid,'or').")";
  1942. }
  1943. $page = $this->input->get('page',true);
  1944. $perpage = $this->input->get('perpage',true);
  1945. $timetk = $this->input->get('timetk',true);
  1946. $timetj = $this->input->get('timetj',true);
  1947. $shop = $this->input->get('shop',true);
  1948. $print = $this->input->get('print',true);
  1949. $express = $this->input->get('express',true);
  1950. $waybill = $this->input->get('waybill',true);
  1951. $printtype = $this->input->get('printtype',true);
  1952. $orderinfo = $this->input->get('orderinfo',true);
  1953. $number = $this->input->get('number',true);
  1954. $type = $this->input->get('type',true);
  1955. $lowe = $this->input->get('lowe',true);
  1956. $info = $this->input->get('info',true);
  1957. $ji = $this->input->get('ji',true);
  1958. $so = $this->input->get('so',true);
  1959. $timetk = strtotime($timetk);
  1960. $timetj = strtotime($timetj);
  1961. $where = (isset($_SESSION['api']))?"(state = '207' or state = '209') and (".rtrim($fgshop,'or').") and (".rtrim($wtype,'or').")":"id = '0'";
  1962. if($print == 3)
  1963. {
  1964. $where .= " and printtime > '$timetk' and printtime < '$timetj' and print = '3' and library = 1";
  1965. }
  1966. else
  1967. {
  1968. $where .= " and express != 0 and printtype != 3 and printtype > 0 and print = 2 and review > 4 and library = 1 and reviewtime > '".(time() - 30*24*3600)."'";
  1969. }
  1970. if($shop)
  1971. {
  1972. $where .= " and shop = '$shop'";
  1973. }
  1974. if($express)
  1975. {
  1976. $where .= " and express = '$express'";
  1977. }
  1978. if($printtype)
  1979. {
  1980. $where .= " and printtype = '$printtype'";
  1981. }
  1982. if($orderinfo)
  1983. {
  1984. $where .= " and orderinfo = '$orderinfo'";
  1985. }
  1986. if($number)
  1987. {
  1988. $where .= " and number = '$number'";
  1989. }
  1990. if($waybill)
  1991. {
  1992. $where .= " and waybill = '$waybill'";
  1993. }
  1994. if($type)
  1995. {
  1996. $where .= " and type = '$type'";
  1997. }
  1998. else
  1999. {
  2000. $where .= " and type != '16'";
  2001. }
  2002. /**
  2003. if($type)
  2004. {
  2005. if($type != '4')
  2006. {
  2007. $where .= " and type = '$type'";
  2008. $where2 = '';
  2009. $where3 = '';
  2010. }
  2011. else
  2012. {
  2013. $where2 = " and type = '4' and (wigs = '3' or wigs = '8') and issku not like '%#pack%'";
  2014. $where3 = " and type = '4' and (wigs = '3' or wigs = '8') and sku not like '%#pack%'";
  2015. }
  2016. $where_a = "";
  2017. $where_b = "";
  2018. }
  2019. else
  2020. {
  2021. $where .= " and type != '4'";
  2022. $where_a = "(";
  2023. $where_b = ")";
  2024. $where2 = " or (type = '4' and (wigs = '3' or wigs = '8') and issku not like '%#pack%')";
  2025. $where3 = " or (type = '4' and (wigs = '3' or wigs = '8') and sku not like '%#pack%')";
  2026. }
  2027. **/
  2028. if($lowe)
  2029. {
  2030. $where .= " and fpdata like '%-$lowe-%'";
  2031. }
  2032. if($ji)
  2033. {
  2034. $where .= " and shipremarks like '%急%'";
  2035. }
  2036. if($so)
  2037. {
  2038. $where .= " and shipremarks like '%$so%'";
  2039. }
  2040. //数据排序
  2041. $order_str = ($print != 3)?"id desc":"printtime desc";
  2042. //取得信息列表
  2043. $info_list = $this->fullorder->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,printnumber,library,printtime,printtype,shipremarks,ts',$order_str);
  2044. //格式化数据
  2045. foreach ($info_list as $key=>$value)
  2046. {
  2047. $shop = $this->shop->read($value['shop']);
  2048. $info_list[$key]['shop'] = $shop['shopname'];
  2049. if($value['waybill'] == '0')
  2050. {
  2051. $info_list[$key]['waybill'] = "";
  2052. }
  2053. $express = $this->express->read($value['express']);
  2054. $info_list[$key]['express'] = $express['servicename'];
  2055. $warehouse = $this->warehouse->read($value['type']);
  2056. $info_list[$key]['type'] = $warehouse['title'];
  2057. if($value['printtime'] == '0')
  2058. {
  2059. $info_list[$key]['printtime'] = '<em class="t"></em>';
  2060. }
  2061. else
  2062. {
  2063. $info_list[$key]['printtime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['printtime']).'</em>';
  2064. }
  2065. if($value['print'] == 1)
  2066. {
  2067. $info_list[$key]['print'] = '不可打印';
  2068. }
  2069. else if($value['print'] == 2)
  2070. {
  2071. $info_list[$key]['print'] = '未打印';
  2072. }
  2073. else if($value['print'] == 3)
  2074. {
  2075. $info_list[$key]['print'] = '已打印';
  2076. }
  2077. if($value['library'] == 1)
  2078. {
  2079. $info_list[$key]['library'] = '<em class="c">未出库</em>';
  2080. }
  2081. else if($value['library'] == 2)
  2082. {
  2083. $info_list[$key]['library'] = '<em class="c">已出库</em>';
  2084. }
  2085. else if($value['library'] == 3)
  2086. {
  2087. $info_list[$key]['library'] = '<em class="c">已退库</em>';
  2088. }
  2089. if($value['printtype'] == 1){
  2090. $info_list[$key]['printtype'] = '运单';
  2091. }elseif($value['printtype'] == 2){
  2092. $info_list[$key]['printtype'] = '发货单';
  2093. }else{
  2094. $info_list[$key]['printtype'] = '不打印单据';
  2095. }
  2096. //$info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  2097. }
  2098. //取得信息列表
  2099. $info_listsmt = $this->fullordersmt->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,printnumber,library,printtime,printtype,shipremarks,ts',$order_str);
  2100. //格式化数据
  2101. foreach ($info_listsmt as $key=>$value)
  2102. {
  2103. $shop = $this->shop->read($value['shop']);
  2104. $info_listsmt[$key]['shop'] = $shop['shopname'];
  2105. if($value['waybill'] == '0')
  2106. {
  2107. $info_listsmt[$key]['waybill'] = "";
  2108. }
  2109. $express = $this->express->read($value['express']);
  2110. $info_listsmt[$key]['express'] = $express['servicename'];
  2111. $warehouse = $this->warehouse->read($value['type']);
  2112. $info_listsmt[$key]['type'] = $warehouse['title'];
  2113. if($value['printtime'] == '0')
  2114. {
  2115. $info_listsmt[$key]['printtime'] = '<em class="t"></em>';
  2116. }
  2117. else
  2118. {
  2119. $info_listsmt[$key]['printtime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['printtime']).'</em>';
  2120. }
  2121. if($value['print'] == 1)
  2122. {
  2123. $info_listsmt[$key]['print'] = '不可打印';
  2124. }
  2125. else if($value['print'] == 2)
  2126. {
  2127. $info_listsmt[$key]['print'] = '未打印';
  2128. }
  2129. else if($value['print'] == 3)
  2130. {
  2131. $info_listsmt[$key]['print'] = '已打印';
  2132. }
  2133. if($value['library'] == 1)
  2134. {
  2135. $info_listsmt[$key]['library'] = '<em class="c">未出库</em>';
  2136. }
  2137. else if($value['library'] == 2)
  2138. {
  2139. $info_listsmt[$key]['library'] = '<em class="c">已出库</em>';
  2140. }
  2141. else if($value['library'] == 3)
  2142. {
  2143. $info_listsmt[$key]['library'] = '<em class="c">已退库</em>';
  2144. }
  2145. if($value['printtype'] == 1){
  2146. $info_listsmt[$key]['printtype'] = '运单';
  2147. }elseif($value['printtype'] == 2){
  2148. $info_listsmt[$key]['printtype'] = '发货单';
  2149. }else{
  2150. $info_listsmt[$key]['printtype'] = '不打印单据';
  2151. }
  2152. //$info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  2153. }
  2154. $info_listtt = $this->fullordertt->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,printnumber,library,printtime,printtype,shipremarks,ts',$order_str);
  2155. //格式化数据
  2156. foreach ($info_listtt as $key=>$value)
  2157. {
  2158. $shop = $this->shop->read($value['shop']);
  2159. $info_listtt[$key]['shop'] = $shop['shopname'];
  2160. if($value['waybill'] == '0')
  2161. {
  2162. $info_listtt[$key]['waybill'] = "";
  2163. }
  2164. $express = $this->express->read($value['express']);
  2165. $info_listtt[$key]['express'] = $express['servicename'];
  2166. $warehouse = $this->warehouse->read($value['type']);
  2167. $info_listtt[$key]['type'] = $warehouse['title'];
  2168. if($value['printtime'] == '0')
  2169. {
  2170. $info_listtt[$key]['printtime'] = '<em class="t"></em>';
  2171. }
  2172. else
  2173. {
  2174. $info_listtt[$key]['printtime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['printtime']).'</em>';
  2175. }
  2176. if($value['print'] == 1)
  2177. {
  2178. $info_listtt[$key]['print'] = '不可打印';
  2179. }
  2180. else if($value['print'] == 2)
  2181. {
  2182. $info_listtt[$key]['print'] = '未打印';
  2183. }
  2184. else if($value['print'] == 3)
  2185. {
  2186. $info_listtt[$key]['print'] = '已打印';
  2187. }
  2188. if($value['library'] == 1)
  2189. {
  2190. $info_listtt[$key]['library'] = '<em class="c">未出库</em>';
  2191. }
  2192. else if($value['library'] == 2)
  2193. {
  2194. $info_listtt[$key]['library'] = '<em class="c">已出库</em>';
  2195. }
  2196. else if($value['library'] == 3)
  2197. {
  2198. $info_listtt[$key]['library'] = '<em class="c">已退库</em>';
  2199. }
  2200. if($value['printtype'] == 1){
  2201. $info_listtt[$key]['printtype'] = '运单';
  2202. }elseif($value['printtype'] == 2){
  2203. $info_listtt[$key]['printtype'] = '发货单';
  2204. }else{
  2205. $info_listtt[$key]['printtype'] = '不打印单据';
  2206. }
  2207. //$info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  2208. }
  2209. $info_listamz = $this->fullorderamz->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,printnumber,library,printtime,printtype,shipremarks,ts',$order_str);
  2210. //格式化数据
  2211. foreach ($info_listamz as $key=>$value)
  2212. {
  2213. $shop = $this->shop->read($value['shop']);
  2214. $info_listamz[$key]['shop'] = $shop['shopname'];
  2215. if($value['waybill'] == '0')
  2216. {
  2217. $info_listamz[$key]['waybill'] = "";
  2218. }
  2219. $express = $this->express->read($value['express']);
  2220. $info_listamz[$key]['express'] = $express['servicename'];
  2221. $warehouse = $this->warehouse->read($value['type']);
  2222. $info_listamz[$key]['type'] = $warehouse['title'];
  2223. if($value['printtime'] == '0')
  2224. {
  2225. $info_listamz[$key]['printtime'] = '<em class="t"></em>';
  2226. }
  2227. else
  2228. {
  2229. $info_listamz[$key]['printtime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['printtime']).'</em>';
  2230. }
  2231. if($value['print'] == 1)
  2232. {
  2233. $info_listamz[$key]['print'] = '不可打印';
  2234. }
  2235. else if($value['print'] == 2)
  2236. {
  2237. $info_listamz[$key]['print'] = '未打印';
  2238. }
  2239. else if($value['print'] == 3)
  2240. {
  2241. $info_listamz[$key]['print'] = '已打印';
  2242. }
  2243. if($value['library'] == 1)
  2244. {
  2245. $info_listamz[$key]['library'] = '<em class="c">未出库</em>';
  2246. }
  2247. else if($value['library'] == 2)
  2248. {
  2249. $info_listamz[$key]['library'] = '<em class="c">已出库</em>';
  2250. }
  2251. else if($value['library'] == 3)
  2252. {
  2253. $info_listamz[$key]['library'] = '<em class="c">已退库</em>';
  2254. }
  2255. if($value['printtype'] == 1){
  2256. $info_listamz[$key]['printtype'] = '运单';
  2257. }elseif($value['printtype'] == 2){
  2258. $info_listamz[$key]['printtype'] = '发货单';
  2259. }else{
  2260. $info_listamz[$key]['printtype'] = '不打印单据';
  2261. }
  2262. //$info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  2263. }
  2264. $info_listxw = $this->fullorderxw->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,printnumber,library,printtime,printtype,shipremarks,ts',$order_str);
  2265. //格式化数据
  2266. foreach ($info_listxw as $key=>$value)
  2267. {
  2268. $shop = $this->shop->read($value['shop']);
  2269. $info_listxw[$key]['shop'] = $shop['shopname'];
  2270. if($value['waybill'] == '0')
  2271. {
  2272. $info_listxw[$key]['waybill'] = "";
  2273. }
  2274. $express = $this->express->read($value['express']);
  2275. $info_listxw[$key]['express'] = $express['servicename'];
  2276. $warehouse = $this->warehouse->read($value['type']);
  2277. $info_listxw[$key]['type'] = $warehouse['title'];
  2278. if($value['printtime'] == '0')
  2279. {
  2280. $info_listxw[$key]['printtime'] = '<em class="t"></em>';
  2281. }
  2282. else
  2283. {
  2284. $info_listxw[$key]['printtime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['printtime']).'</em>';
  2285. }
  2286. if($value['print'] == 1)
  2287. {
  2288. $info_listxw[$key]['print'] = '不可打印';
  2289. }
  2290. else if($value['print'] == 2)
  2291. {
  2292. $info_listxw[$key]['print'] = '未打印';
  2293. }
  2294. else if($value['print'] == 3)
  2295. {
  2296. $info_listxw[$key]['print'] = '已打印';
  2297. }
  2298. if($value['library'] == 1)
  2299. {
  2300. $info_listxw[$key]['library'] = '<em class="c">未出库</em>';
  2301. }
  2302. else if($value['library'] == 2)
  2303. {
  2304. $info_listxw[$key]['library'] = '<em class="c">已出库</em>';
  2305. }
  2306. else if($value['library'] == 3)
  2307. {
  2308. $info_listxw[$key]['library'] = '<em class="c">已退库</em>';
  2309. }
  2310. if($value['printtype'] == 1){
  2311. $info_listxw[$key]['printtype'] = '运单';
  2312. }elseif($value['printtype'] == 2){
  2313. $info_listxw[$key]['printtype'] = '发货单';
  2314. }else{
  2315. $info_listxw[$key]['printtype'] = '不打印单据';
  2316. }
  2317. //$info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  2318. }
  2319. $title = '订单出库-'.date('Ymd',time());
  2320. $titlename = "<table border=1><td>店铺名称</td><td>仓库</td><td>订单号</td><td>编号</td><td>运单号</td><td>快递</td><td>类型</td><td>打印次数</td><td>打印类型</td><td>状态</td><td>打印时间</td><td>仓库品名</td><td>条数</td></table>";
  2321. $tail = "\n";
  2322. $filename = $title.".xls";
  2323. $this->excel->get_fz2(array_merge($info_list,$info_listamz,$info_listsmt,$info_listtt,$info_listxw),$titlename,$filename,$tail);
  2324. }
  2325. }
  2326. public function _barcode()
  2327. {
  2328. $post = $this->input->post(NULL, TRUE);
  2329. if(isset($_SESSION['api']))
  2330. {
  2331. $user = $this->user->get_api($_SESSION['api']);
  2332. $usp = $user;
  2333. $fgshop = "";$sid = "";$wid="";$wtype="";
  2334. $usersp = explode('|',trim($user['shop'],'|'));
  2335. $userwh = explode('|',trim($user['warehouse'],'|'));
  2336. foreach ($usersp as $value)
  2337. {
  2338. $fgshop .= " shop = ".$value." or";
  2339. $sid .= " id = ".$value." or";
  2340. }
  2341. foreach ($userwh as $value)
  2342. {
  2343. $wid .= " id = ".$value." or";
  2344. $wtype .= " type = ".$value." or";
  2345. }
  2346. }
  2347. if(isset($post['page']))
  2348. {
  2349. $page = $this->input->post('page',true);
  2350. $perpage = $this->input->post('perpage',true);
  2351. $warehouse = $this->input->post('warehouse',true);
  2352. $sku = $this->input->post('sku ',true);
  2353. $title = $this->input->post('title',true);
  2354. $print = $this->input->post('print ',true);
  2355. $timetk = $this->input->post('timetk',true);
  2356. $timetj = $this->input->post('timetj',true);
  2357. $timetk = strtotime($timetk);
  2358. $timetj = strtotime($timetj);
  2359. $where = "time > '$timetk' and time < '$timetj'";
  2360. if($warehouse)
  2361. {
  2362. $where .= " and warehouse = '$warehouse'";
  2363. }
  2364. if($sku)
  2365. {
  2366. $where .= " and sku like '%$sku%'";
  2367. }
  2368. if($title)
  2369. {
  2370. $where .= " and title like '%$title%'";
  2371. }
  2372. if($print)
  2373. {
  2374. $where .= " and print = '$print'";
  2375. }
  2376. //数据排序
  2377. $order_str = "time desc";
  2378. if(empty($page))
  2379. {
  2380. $start = 0;
  2381. $perpage = 1;
  2382. }
  2383. else
  2384. {
  2385. $start = ($page - 1)*$perpage;
  2386. }
  2387. //取得信息列表
  2388. $info_list = $this->whlabelbarcodeprint->find_all($where,'id,sku,title,num,printtime',$order_str,$start,$perpage);
  2389. //格式化数据
  2390. foreach ($info_list as $key=>$value)
  2391. {
  2392. if($value['printtime'] > 0)
  2393. {
  2394. $info_list[$key]['printtime'] = date("Y-m-d H:i:s",$value['printtime']);
  2395. }
  2396. else
  2397. {
  2398. $info_list[$key]['printtime'] = '未打印';
  2399. }
  2400. }
  2401. $total = $this->whlabelbarcodeprint->find_count($where);
  2402. $pagenum = ceil($total/$perpage);
  2403. $over = $total-($start+$perpage);
  2404. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2405. echo json_encode($rows);exit;
  2406. }
  2407. if(isset($_SESSION['api']))
  2408. {
  2409. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  2410. $this->data['warehouse'] = $warehouse;
  2411. }
  2412. $this->_Template('systemprint_barcode',$this->data);
  2413. }
  2414. public function _barcodedc()
  2415. {
  2416. if(isset($_GET['excel']))
  2417. {
  2418. $warehouse = $this->input->post('warehouse',true);
  2419. $sku = $this->input->post('sku ',true);
  2420. $title = $this->input->post('title',true);
  2421. $print = $this->input->post('print ',true);
  2422. $ktime = $this->input->post('timetk',true);
  2423. $jtime = $this->input->post('timetj',true);
  2424. $ktime = strtotime($ktime);
  2425. $jtime = strtotime($jtime);
  2426. $where = "time > '$timetk' and time < '$timetj'";
  2427. if($warehouse)
  2428. {
  2429. $where .= " and warehouse = '$warehouse'";
  2430. }
  2431. if($sku)
  2432. {
  2433. $where .= " and sku like '%$sku%'";
  2434. }
  2435. if($title)
  2436. {
  2437. $where .= " and title like '%$title%'";
  2438. }
  2439. if($print)
  2440. {
  2441. $where .= " and print = '$print'";
  2442. }
  2443. $order_str = "time desc";
  2444. if(empty($page))
  2445. {
  2446. $start = 0;
  2447. $perpage = 1;
  2448. }
  2449. else
  2450. {
  2451. $start = ($page - 1)*$perpage;
  2452. }
  2453. $info_list = $this->whlabelbarcodeprint->find_all($where,'label,sku,title',$order_str);
  2454. $title = '标签-'.date('Y-m-d H-i-s',time());
  2455. $titlename = "<table border=1>
  2456. <tr align='center'>
  2457. <td>条码号</td>
  2458. <td>SKU</td>
  2459. <td>产品名称</td>
  2460. </tr>
  2461. </table>";
  2462. $filename = $title.".xls";
  2463. $tail = "";
  2464. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  2465. }
  2466. }
  2467. public function _barcodedr()
  2468. {
  2469. $dir = '/data/excel/'.date('Ymd',time()).'/';
  2470. $config['upload_path'] = '.'.$dir ;
  2471. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  2472. $config['allowed_types'] = 'xls|xlsx|csv';
  2473. $config['max_size'] = 10240;
  2474. $this->load->library('upload', $config);
  2475. $this->upload->initialize($config);
  2476. if ($this->upload->do_upload('userfile'))
  2477. {
  2478. $full_path = $dir.$this->upload->data('file_name');
  2479. $fileName = '.' . $full_path;
  2480. if (!file_exists($fileName))
  2481. {
  2482. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  2483. }
  2484. else
  2485. {
  2486. libxml_use_internal_errors(true);
  2487. require_once "./data/excel/PHPExcel/IOFactory.php";
  2488. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  2489. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  2490. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  2491. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  2492. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  2493. ++$column;//如果列数大于26行
  2494. $list = array();
  2495. for ($i = 2; $i <= $row; $i++) // 行数循环
  2496. {
  2497. $data = array();
  2498. for ($c = 'A'; $c != $column; $c++) // 列数循环
  2499. {
  2500. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  2501. }
  2502. $list[] = $data;
  2503. }
  2504. }
  2505. $i = 0;$j = 0;$ed = array();
  2506. foreach ($list as $key=>$value)
  2507. {
  2508. $time = time();
  2509. if($value['0'] == "")
  2510. {
  2511. continue;
  2512. }
  2513. $label = $value['0'];
  2514. $sku = $value['1'];
  2515. $title = $value['2'];
  2516. $num = $value['3'];
  2517. $d = $this->whlabelbarcode->get_skulabel($sku,$label);
  2518. if(!$d)//如果没有这个SKU
  2519. {
  2520. $ed[] = array($sku.'-库存中不存在此SKU');
  2521. $j++;
  2522. continue;
  2523. }
  2524. if($num < 1)
  2525. {
  2526. $ed[] = array($sku.'-数量错误!');
  2527. $j++;
  2528. continue;
  2529. }
  2530. unset($d['id']);
  2531. $d['time'] = $time;
  2532. $d['num'] = $num;
  2533. $this->whlabelbarcodeprint->insert($d);
  2534. }
  2535. if($j > 0)
  2536. {
  2537. $tt = date('Ymd',time());
  2538. $title = '库存导入错误信息-'.$tt;
  2539. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  2540. $tail = "\n";
  2541. $filename = $title.".xls";
  2542. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  2543. $dir = '/data/excel/'.$time.'/';
  2544. $file_name = 'error_'.$time.rand(1000,9999);
  2545. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  2546. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  2547. fwrite($myfile,$ecl);
  2548. fclose($myfile);
  2549. $error = $dir.$file_name.'.xls';
  2550. echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
  2551. }
  2552. else
  2553. {
  2554. echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
  2555. }
  2556. }
  2557. }
  2558. public function _yswaybill()
  2559. {
  2560. $data = $this->yswaybill->find_all("waybill = ''");
  2561. foreach ($data as $v)
  2562. {
  2563. $type = $v['type'];
  2564. $number = $v['number'];
  2565. $express = $v['express'];
  2566. $fullorder = $this->$type->get_number($number);
  2567. $fullorder = $this->_text($fullorder);
  2568. $barcode = $this->$express->get_hqwaybill($number);
  2569. if(!isset($barcode['x']))
  2570. {
  2571. continue;
  2572. }
  2573. if($barcode['x'] == 1)
  2574. {
  2575. if($barcode['ys'] != 1)
  2576. {
  2577. $this->db->trans_begin();
  2578. $this->$type->save(array('waybill'=>$barcode['waybill']),$fullorder['id']);
  2579. $this->yswaybill->save(array('waybill'=>$barcode['waybill'],'time'=>time()),$v['id']);
  2580. if ($this->db->trans_status() === TRUE)
  2581. {
  2582. $this->db->trans_commit();
  2583. }
  2584. else
  2585. {
  2586. $this->db->trans_rollback();
  2587. }
  2588. }
  2589. }
  2590. else
  2591. {
  2592. $this->yswaybill->save(array('cw'=>$barcode['Description'],'time'=>time()),$v['id']);
  2593. }
  2594. }
  2595. echo 1;
  2596. }
  2597. /**
  2598. * 根据发货单打印快递
  2599. */
  2600. public function _printbyfh(){
  2601. $this->_Template('systemprint_fhd',$this->data);
  2602. }
  2603. /**
  2604. * 此方法是为了临时解决一下打印的问题
  2605. */
  2606. public function _getInfoByNumber(){
  2607. $param = $this->input->get(NULL, TRUE);
  2608. if(empty($param['number'])){
  2609. $param = $this->input->post(NULL, TRUE);
  2610. }
  2611. if(empty($param['number'])){
  2612. echo json_encode([
  2613. 'code'=>-1,
  2614. 'msg'=>"订单编码未传递",
  2615. 'data'=>[]
  2616. ],JSON_UNESCAPED_UNICODE);
  2617. die;
  2618. }
  2619. $this->logic_ding->sendToDing("扫面发货单出运单订单编码".json_encode($param));
  2620. $info = $this->logic_order->getInfo("number = '".$param['number']."'");
  2621. if(empty($info)){
  2622. echo json_encode([
  2623. 'code'=>-1,
  2624. 'msg'=>"未查询到订单信息",
  2625. 'data'=>[]
  2626. ],JSON_UNESCAPED_UNICODE);
  2627. die;
  2628. }
  2629. if($info['library'] ==2 ){
  2630. echo json_encode([
  2631. 'code'=>-1,
  2632. 'msg'=>"该订单已出库!",
  2633. 'data'=>[]
  2634. ],JSON_UNESCAPED_UNICODE);
  2635. die;
  2636. }
  2637. if(empty($param['is_ok'])){
  2638. if($info['printnumber'] > 1){
  2639. echo json_encode([
  2640. 'code'=>2,
  2641. 'msg'=>'该单共打印过<b style="color:red;">'.$info['printnumber'].'</b>次,请核对当前发货单是否是最新发货单',
  2642. 'data'=>[
  2643. 'number'=>$info['number'],
  2644. 'is_ok'=>1
  2645. ]
  2646. ],JSON_UNESCAPED_UNICODE);
  2647. die;
  2648. }
  2649. }
  2650. if(!in_array($info['express'],[71])){
  2651. // if(!empty($info['waybill'])&&!empty($info['waybill'])){
  2652. // $yd = base_url()."data/pdf/".date('Ymd',$info['printtime']).'/y-'.$info['waybill'].'.pdf' ;
  2653. // if(file_exists("./data/pdf/".date('Ymd',$info['printtime']).'/y-'.$info['waybill'].'.pdf')){
  2654. // if(!in_array($info['express'],[76,77])){
  2655. // $text = array('yd'=>$yd,'mode'=>100,'type'=>1);
  2656. // }else{
  2657. // $text = array('yd'=>$yd,'mode'=>100,'type'=>8);
  2658. // }
  2659. // $this->logic_ding->sendToDing($info['number']."扫面发货单补发运单的text".json_encode($text,JSON_UNESCAPED_UNICODE));
  2660. // echo json_encode([
  2661. // 'code'=>1,
  2662. // 'msg'=>"ok",
  2663. // 'data'=>$text
  2664. // ],JSON_UNESCAPED_UNICODE);
  2665. // die;
  2666. // }
  2667. // ob_clean();
  2668. // echo json_encode([
  2669. // 'code'=>-1,
  2670. // 'msg'=>"快递面单不存在",
  2671. // 'data'=>[]
  2672. // ],JSON_UNESCAPED_UNICODE);
  2673. // die;
  2674. // }
  2675. echo json_encode([
  2676. 'code'=>-1,
  2677. 'msg'=>"快递不符合打印要求",
  2678. 'data'=>[]
  2679. ],JSON_UNESCAPED_UNICODE);
  2680. die;
  2681. }
  2682. $fullorder_name = $info['lv_platform'];
  2683. if($info['libraryconfirm'] == 1){
  2684. echo json_encode([
  2685. 'code'=>-1,
  2686. 'msg'=>"该订单不允许出库:".$info['librarynot'],
  2687. 'data'=>[]
  2688. ],JSON_UNESCAPED_UNICODE);
  2689. die;
  2690. }
  2691. if($info['library'] == 3){
  2692. echo json_encode([
  2693. 'code'=>-1,
  2694. 'msg'=>"该订单已退库!",
  2695. 'data'=>[]
  2696. ],JSON_UNESCAPED_UNICODE);
  2697. die;
  2698. }
  2699. $fullorder = $this->_text($info);//获取所需信息
  2700. $this->logic_ding->sendToDing("打印快递单,订单的信息".json_encode($fullorder,JSON_UNESCAPED_UNICODE));
  2701. //美仓不需要海关报关信息,
  2702. if($fullorder['type'] != 5){
  2703. //中国发货的 目前是dhl需要海关申报编码
  2704. if(empty($fullorder['sbbm'])){
  2705. echo json_encode([
  2706. 'code'=>-1,
  2707. 'msg'=>$fullorder['number'].' 海关申报配置异常,请提交给技术处理'.$fullorder['sbbm'],
  2708. 'data'=>[]
  2709. ],JSON_UNESCAPED_UNICODE);
  2710. die;
  2711. }
  2712. }
  2713. $time = time();
  2714. $oldprinttime = ($fullorder['printtime'] > 0)?$fullorder['oldprinttime'].$fullorder['printtime'].'-':'';
  2715. $fullorder['printtime'] = date('m-d H:i',$time);//打印用时间、发货单用,不能删
  2716. $pdfnum = 1;//PDF打印几遍
  2717. if($fullorder['waybillid'] != '')
  2718. {
  2719. $del = $this->cne->get_del($fullorder['waybillid']);
  2720. }
  2721. $barcode = $this->cne->get_data($fullorder);
  2722. $this->logic_ding->sendToDing("扫面发货单出运单".json_encode($barcode,JSON_UNESCAPED_UNICODE));
  2723. if($barcode['x'] == 1)
  2724. {
  2725. $bctime = date('Ymd',$time);
  2726. $Hwaybill = $barcode['waybill'];
  2727. $Hyd = $this->_pdfurl($barcode['yd'],'y-'.$Hwaybill,$bctime);
  2728. //$Hfp = $this->_pdfurl($barcode['fp'],'f-'.$Hwaybill,$bctime);//保留PDF,不需要打印
  2729. if(isset($barcode['yd']) && isset($Hwaybill))
  2730. {
  2731. if($fullorder['waybill'] != "")
  2732. {
  2733. $oldwaybill = $fullorder['oldwaybill'].'-'.date('Ymd',$time).'/'.$fullorder['waybill'];
  2734. }
  2735. else
  2736. {
  2737. $oldwaybill = $fullorder['oldwaybill'];
  2738. }
  2739. $oldwaybill .= '-'.$bctime.'/'.$Hwaybill;
  2740. $fullorder['printnumber'] = $fullorder['printnumber'] +1;//不能删
  2741. if($this->$fullorder_name->save(array('waybill'=>$Hwaybill,'waybillid'=>$barcode['waybillid'],'printtime'=>$time,'printnumber'=>$fullorder['printnumber'],'print'=>3,'oldwaybill'=>$oldwaybill,'oldprinttime'=>$oldprinttime),$info['id']))
  2742. {
  2743. $text = array('yd'=>base_url().'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf','mode'=>100);
  2744. $this->logic_ding->sendToDing("扫面发货单出运单的text".json_encode($text,JSON_UNESCAPED_UNICODE));
  2745. echo json_encode([
  2746. 'code'=>1,
  2747. 'msg'=>"ok",
  2748. 'data'=>$text
  2749. ],JSON_UNESCAPED_UNICODE);
  2750. die;
  2751. }else{
  2752. echo json_encode([
  2753. 'code'=>-1,
  2754. 'msg'=>"订单信息保存异常",
  2755. 'data'=>[]
  2756. ],JSON_UNESCAPED_UNICODE);
  2757. die;
  2758. }
  2759. }
  2760. }
  2761. else
  2762. {
  2763. $failed = $barcode['Description'];//错误提示
  2764. //$fullorder['printnumber'] = $fullorder['printnumber'] +1;
  2765. //$this->$fullorder_name->save(array('print'=>1,'failed'=>$failed,'printnumber'=>$fullorder['printnumber']),$info['id']);
  2766. $this->$fullorder_name->save(array('print'=>1,'failed'=>$failed),$info['id']);
  2767. echo json_encode([
  2768. 'code'=>-1,
  2769. 'msg'=>$failed,
  2770. 'data'=>[]
  2771. ],JSON_UNESCAPED_UNICODE);
  2772. die;
  2773. }
  2774. echo json_encode([
  2775. 'code'=>-1,
  2776. 'msg'=>"执行订单异常,请联系技术",
  2777. 'data'=>[]
  2778. ],JSON_UNESCAPED_UNICODE);
  2779. die;
  2780. }
  2781. }