Systemprint.php 84 KB

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