Systemprint.php 103 KB

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