Systemprint.php 89 KB

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