Systemprint.php 102 KB

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