Systemprint.php 101 KB

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