Systemprint.php 90 KB

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