Systemprint.php 113 KB

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