Systemprint.php 99 KB

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