Systemprint.php 100 KB

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