Systemprint.php 84 KB

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