Systemprint.php 95 KB

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