Systemprint.php 102 KB

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