Systemprint.php 112 KB

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