Ab.php 107 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Ab extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model('Model_api','api');
  7. $this->load->_model('Model_apismt','apismt');
  8. $this->load->_model('Model_shop','shop');
  9. $this->load->_model('Model_fullorder','fullorder');
  10. $this->load->_model('Model_fullordertt','fullordertt');
  11. $this->load->_model('Model_fullorder_smt','fullorder_smt');
  12. $this->load->_model('Model_fullordersmt','fullordersmt');
  13. $this->load->_model('Model_customersmt','customersmt');
  14. $this->load->_model('Model_country','country');
  15. $this->load->_model('Model_hl','hl');
  16. $this->load->_model('Model_is','is');
  17. $this->load->_model('Model_kdniao','kdniao');
  18. $this->load->_model('Model_typeclass','typeclass');
  19. $this->load->_model('Model_warehouse','warehouse');
  20. $this->load->_model('Model_fullorderexcel','fullorderexcel');
  21. $this->load->_model('Model_dhl','dhl');
  22. $this->load->_model('Model_usps','usps');
  23. $this->load->_model('Model_dhltest','dhltest');
  24. $this->load->_model('Model_customer','customer');
  25. $this->load->_model('Model_express','express');
  26. $this->load->_model('Model_notice','notice');
  27. $this->load->_model('Model_whlabel','whlabel');
  28. $this->load->_model('Model_productdescribe','productdescribe');
  29. $this->load->_model('Model_ljg','ljg');
  30. $this->load->_model('Model_commodityread','commodityread');
  31. $this->load->_model('Model_service','service');
  32. $this->load->_model('Model_fedex','fedex');
  33. $this->load->_model('Model_commodity','commodity');
  34. $this->load->_model('Model_fullordersmtorder','fullordersmtorder');
  35. $this->load->_model('Model_fullordersmthb','fullordersmthb');
  36. $this->load->_model('Model_allocation','allocation');
  37. $this->load->_model('Model_excel','excel');
  38. $this->load->_model('Model_reset','reset');
  39. }
  40. //定义方法的调用规则 获取URI第二段值
  41. public function _remap($arg,$arg_array)
  42. {
  43. if($arg == 'jsf')
  44. {
  45. $this->_jsf($arg_array);
  46. }
  47. else if($arg == 'jsm')
  48. {
  49. $this->_jsm($arg_array);
  50. }
  51. else if($arg == 'sku')
  52. {
  53. $this->_sku($arg_array);
  54. }
  55. else if($arg == 'order')
  56. {
  57. $this->_order($arg_array);//查询获取到fullordersmtorder的单
  58. }
  59. else if($arg == 'data')
  60. {
  61. $this->_data($arg_array);//查询获取到fullordersmtorder的单
  62. }
  63. else if($arg == 'dataxr')
  64. {
  65. $this->_dataxr($arg_array);//查询获取到fullordersmtorder的单写入
  66. }
  67. else if($arg == 'cf')
  68. {
  69. $this->_cf($arg_array);//查询获取到fullordersmtorder的单
  70. }
  71. else if($arg == 'khjz')
  72. {
  73. $this->_khjz($arg_array);
  74. }
  75. else if($arg == 'khjzfs')
  76. {
  77. $this->_khjzfs($arg_array);
  78. }
  79. else if($arg == 'tbsmt')
  80. {
  81. $this->_tbsmt($arg_array);
  82. }
  83. else if($arg == 'xqcx')
  84. {
  85. $this->_xqcx($arg_array);
  86. }
  87. else if($arg == 'dpex')
  88. {
  89. $this->_dpex($arg_array);
  90. }
  91. else if($arg == 'fedexhz')
  92. {
  93. $this->_fedexhz($arg_array);
  94. }
  95. else if($arg == 'smtck')
  96. {
  97. $this->_smtck($arg_array);
  98. }
  99. else if($arg == 'xxfs')
  100. {
  101. $this->_xxfs($arg_array);//消息发送测试
  102. }
  103. else if($arg == 'smtprintout')
  104. {
  105. $this->_smtprintout($arg_array);//速卖通亚马逊操作出库
  106. }
  107. else if($arg == 'feite')
  108. {
  109. $this->_feite($arg_array);//飞特提取内容下载
  110. }
  111. else if($arg == 'rl')
  112. {
  113. $this->_rl($arg_array);//return label信息查找
  114. }
  115. else if($arg == 'cz')
  116. {
  117. $this->_cz($arg_array);//重置恢复打印、出库
  118. }
  119. else if($arg == 'paypal')
  120. {
  121. $this->_paypal($arg_array);//重置恢复打印、出库
  122. }
  123. else if($arg == 'qcfs')
  124. {
  125. $this->_qcfs($arg_array);//清除邮件发送信息
  126. }
  127. else if($arg == 'yd')
  128. {
  129. $this->_yd($arg_array);//测试运单
  130. }
  131. else if($arg == 'jzw')
  132. {
  133. $this->_jzw($arg_array);//矫正whlabel
  134. }
  135. else if($arg == 'qlzd')
  136. {
  137. $this->_qlzd($arg_array);//清除无效占单
  138. }
  139. }
  140. public function _qcfs($arg_array)
  141. {
  142. $a = $this->fullorder->get_number($arg_array[0]);
  143. $this->fullorder->save(array('zdstate'=>'','wltype'=>0,'wlcontent'=>'','wlfstime'=>''),$a['id']);
  144. }
  145. public function _jzw($arg_array)//矫正number和features不一致
  146. {
  147. $d = $this->whlabel->find_pc("1=1",'sku,features,warehouse','*');
  148. foreach ($d as $val)
  149. {
  150. $xd = $this->whlabel->find_all("sku = '".$val['sku']."' and features = '".$val['features']."' and warehouse = '".$val['warehouse']."'",'id,number,features,title,warehouse');
  151. foreach ($xd as $v)
  152. {
  153. $f = str_replace('-','',$v['features']);
  154. if($v['number'] != $f)
  155. {
  156. $this->whlabel->save(array("number"=>$f),$v['id']);
  157. }
  158. }
  159. }
  160. }
  161. public function _qlzd()//清除无效占单
  162. {
  163. $cw = array();$s = array();
  164. $wh = $this->whlabel->find_all("state = '0' and zd != ''");
  165. foreach ($wh as $v)
  166. {
  167. $d = $this->fullorder->get_number($v['zd']);
  168. if(!$d)
  169. {
  170. $d = $this->fullordersmt->get_number($v['zd']);
  171. if(!$d)
  172. {
  173. $d = $this->fullordertt->get_number($v['zd']);
  174. if(!$d)
  175. {
  176. $cw[] = $v['id'];
  177. continue;
  178. }
  179. }
  180. }
  181. if($d['state'] != 207 && $d['state'] != 209)
  182. {
  183. $s[] = $v['zd'];
  184. $this->whlabel->save(array("zd"=>''),$v['id']);
  185. }
  186. }
  187. echo "<pre>";
  188. print_r($s);
  189. }
  190. public function _smtprintout($arg_array)
  191. {
  192. $time = time();
  193. $a = $this->fullordersmt->get_number($arg_array[0]);
  194. if($a)
  195. {
  196. if($a['zsbjz'] < 1)
  197. {
  198. echo "9610要求必须要申报价值!";exit;
  199. }
  200. if($a['waybill'] != '' && $a['printtime'] == '0' && $a['librarytime'] == '0' && $a['warehouse'] == '3')
  201. {
  202. if($this->fullordersmt->save(array('review'=>5,'reviewtime'=>$time,'print'=>3,'printtime'=>$time,'printnumber'=>1,'library'=>2,'librarytime'=>$time,'libraryconfirm'=>2),$a['id']))
  203. {
  204. echo "操作已完成";
  205. }
  206. else
  207. {
  208. echo "操作失败,请重试";
  209. }
  210. }
  211. else
  212. {
  213. echo "操作失败,订单已操作完成或不符合条件";
  214. }
  215. }
  216. else
  217. {
  218. echo "找不到此编号";
  219. }
  220. }
  221. public function _smtck($arg_array)//测试SKU
  222. {
  223. $notice = $this->notice->read($arg_array[1]);
  224. $v = $this->fullorder->get_number($arg_array[0]);
  225. $shop = $this->shop->read($v['shop']);
  226. $express = $this->express->read($v['express']);
  227. $fs = $this->notice->get_god($v,$shop,$express,$notice['content'],$notice['message'],$notice['emailtitle']);
  228. }
  229. public function _sku($arg_array)//测试SKU
  230. {
  231. $gethl = $this->hl->get_hl();//获取即时汇率
  232. $dictionaries = $this->typeclass->find_all('ae!= "" and (classid=13 or classid=22 or classid=8 or classid=15 or classid=27 or classid=25 or classid=26 or classid=18 or classid=14 or classid=9 or classid=12 or classid=10 or classid=6 or classid=100 or classid=999)'); //产品人发类型颜色
  233. $dtc = array();
  234. foreach ($dictionaries as $v)
  235. {
  236. if(stripos($v['spare'],'|') !== false)//如果有多个值
  237. {
  238. $v['spare'] = explode('|',$v['spare']);
  239. foreach ($v['spare'] as $k=>$vs)
  240. {
  241. if(stripos($v['zh'],'|') !== false)
  242. {
  243. $vzh = explode('|',$v['zh']);
  244. $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$vzh[$k],'id'=>$v['id']);
  245. }
  246. else
  247. {
  248. $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id']);
  249. }
  250. }
  251. }
  252. else if(stripos($v['spare'],'|') !== false)//如果有多个值
  253. {
  254. $v['spare'] = explode('|',$v['spare']);
  255. foreach ($v['spare'] as $k=>$vs)
  256. {
  257. if(stripos($v['zh'],'|') !== false)
  258. {
  259. $vzh = explode('|',$v['zh']);
  260. $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$vzh[$k],'id'=>$v['id']);
  261. }
  262. else
  263. {
  264. $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id']);
  265. }
  266. }
  267. }
  268. else
  269. {
  270. $dtc[strtolower($v['spare'])] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id']);
  271. }
  272. }
  273. $dictionaries2 = $this->typeclass->find_all();
  274. foreach ($dictionaries2 as $v)
  275. {
  276. $dtctitle[$v['id']] = $v['title'];
  277. }
  278. $dtc['Clip'] = array('classid'=>18,'zh'=>'卡子发卡子发','id'=>0);
  279. $dtc['Clip--D'] = array('classid'=>18,'zh'=>'卡子发卡子发','id'=>0);
  280. $dtc['Clip--L'] = array('classid'=>18,'zh'=>'卡子发卡子发','id'=>0);
  281. $dtc['with bangs'] = array('classid'=>999,'zh'=>'(带齐刘海)','id'=>0);
  282. $dtc['no bangs'] = array('classid'=>999,'zh'=>'(无刘海)','id'=>0);
  283. $dtc['right'] = array('classid'=>999,'zh'=>'右偏分(戴上后U型部分在右边)','id'=>0);
  284. $dtc['middle'] = array('classid'=>999,'zh'=>'中分(戴上后U型部分在中间)','id'=>0);
  285. $dtc['left'] = array('classid'=>999,'zh'=>'左偏分(戴上后U型部分在左边)','id'=>0);
  286. $dtc['freeeyelash'] = array('classid'=>999,'zh'=>'(送假睫毛)','id'=>0);
  287. $dtc['stwbob10'] = array('classid'=>999,'zh'=>'+自然色 直发波波头 10寸','id'=>0);
  288. $dtc['stwbob12'] = array('classid'=>999,'zh'=>'+自然色 直发波波头 12寸','id'=>0);
  289. $dtc['stwbob14'] = array('classid'=>999,'zh'=>'+自然色 直发波波头 14寸','id'=>0);
  290. $dtc['HDTransparent'] = array('classid'=>9,'zh'=>'(HD透明蕾丝)','id'=>0);
  291. $dtc['HDLight Brown'] = array('classid'=>9,'zh'=>'(HD透明蕾丝)','id'=>0);
  292. $dtc['nwb'] = array('classid'=>15,'zh'=>'扁头 自然曲','id'=>111);//中文词不一样,ID一样
  293. $dtctitle[126] = 'Hair Weaving';
  294. $dtctitle[127] = 'Closure';
  295. $dtctitle[128] = 'Wigs';
  296. $dtctitle[130] = 'Clip-in Full Head';
  297. /* 匹配结束 */
  298. /* 价格加入 */
  299. $money = array();
  300. $productdescribe = $this->productdescribe->find_all('1=1','number,purchase,cost,salesprice,title');
  301. foreach ($productdescribe as $v)
  302. {
  303. $money[$v['number']] = array('purchase'=>$v['purchase'],'cost'=>$v['cost'],'salesprice'=>$v['salesprice'],'title'=>$v['title']);
  304. }
  305. /* 价格加入 */
  306. /* 匹配ID加入 */
  307. $int = array();
  308. $intdata = $this->typeclass->find_all('classid=14','id,ae');
  309. foreach ($intdata as $v)
  310. {
  311. $v['spare'] = explode('|',$v['spare']);
  312. $int[$v['id']] = $v['spare'][0];
  313. }
  314. /* 匹配ID结束 */
  315. /* 匹配状态加入 */
  316. $zt = array();$ste = array();
  317. $ztdata = $this->typeclass->find_all('classid=29','id,classtitle');
  318. foreach ($ztdata as $v)
  319. {
  320. $zt[$v['classtitle']] = $v['id'];
  321. $ste[$v['id']] = $v['classtitle'];
  322. }
  323. /* 匹配状态结束 */
  324. /* 国家加入键值-k */
  325. $cuy = array();
  326. $cuydata = $this->country->find_all('1=1','al,lb,id');
  327. foreach ($cuydata as $v)
  328. {
  329. $cuy[$v['al']] = array('id'=>$v['id'],'lb'=>$v['lb']);//获取到国家ID
  330. }
  331. /* 国家加入键值-j */
  332. /* 币种加入键值-k */
  333. $typeclass = array();
  334. $tdata = $this->typeclass->find_all('classid=30','id,title');
  335. foreach ($tdata as $v)
  336. {
  337. $typeclass[$v['title']] = $v['id'];
  338. }
  339. /* 币种加入键值-j */
  340. $is = $this->is->find_all('1=1','*','number asc');//获取仓库平匹配表
  341. $r = $this->api->matching('1;1','BW--3+13*6F-24 26 28-20',$dtc,$money,$int,$dtctitle);
  342. echo "<pre>";
  343. print_r($r);
  344. }
  345. public function _cf($arg_array) //速卖通订单拆分
  346. {
  347. $b = $this->fullordersmt->get_orderinfo($arg_array[0]);
  348. if($b['merge'] == $b['id'])
  349. {
  350. $data = $this->fullordersmt->find_all("merge = '".$b['merge']."'");
  351. foreach ($data as $v)
  352. {
  353. $a = $this->fullordersmthb->get_orderinfo($v['orderinfo']);
  354. if($a)
  355. {
  356. $this->fullordersmt->save($a,$v['id']);
  357. }
  358. }
  359. }
  360. }
  361. public function _khjzfs($arg_array)//独立站客户下单数量矫正
  362. {
  363. //@$this->allocation->insert(array('title'=>'khfs - '.date('Y-m-d H:i:s',time())));
  364. $customer = $this->customer->find_all("1=1",'id,email,shop','id asc',$arg_array[0],$arg_array[1]);
  365. foreach ($customer as $k=>$v)
  366. {
  367. $num = $this->fullorder->find_all("email = '".$v['email']."' and shop = '".$v['shop']."' and mergeid = 0","*","dtime desc");
  368. $money = sprintf("%01.2f",array_sum(array_column($num,'shouldmoney')));
  369. $n = count($num);
  370. if($n > 0)
  371. {
  372. $this->customer->save(array('num'=>$n,'money'=>$money,'time'=>$num[0]['dtime']),$v['id']);
  373. }
  374. else
  375. {
  376. $this->customer->save(array('num'=>$n),$v['id']);
  377. }
  378. }
  379. }
  380. public function _khjz($arg_array)//独立站客户下单数量矫正
  381. {
  382. $customer = $this->customer->find_count();
  383. $customer = ceil($customer/20000);
  384. for($i=0;$i<$customer;$i++)
  385. {
  386. $a = ($i=='0')?0:$i*20000;
  387. $b = ($i+1)*20000;
  388. $ch = curl_init();
  389. $url = 'http://a'.($i+10).'.wepolicy.cn/ab/khjzfs/'.$a.'/'.$b;
  390. curl_setopt($ch,CURLOPT_URL,$url);
  391. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  392. curl_setopt($ch,CURLOPT_HEADER,0);
  393. curl_setopt($ch,CURLOPT_POST, 1);
  394. curl_setopt($ch,CURLOPT_TIMEOUT,20);
  395. //设置post数据
  396. $post = array();
  397. $post['data'] = 1;
  398. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
  399. $res = curl_exec($ch);
  400. curl_close($ch);
  401. }
  402. }
  403. public function _tbsmt($arg_array)//同步速卖通新店
  404. {
  405. $ch = curl_init();
  406. $url = 'http://39.100.97.180/start/order';
  407. curl_setopt($ch,CURLOPT_URL,$url);
  408. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  409. curl_setopt($ch,CURLOPT_HEADER,0);
  410. curl_setopt($ch,CURLOPT_POST, 1);
  411. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
  412. //设置post数据
  413. $post = array();
  414. $post['starttime'] = 1393606800;
  415. $post['endtime'] = 1590021229;
  416. $post['page'] = $arg_array[0];
  417. $post['size'] = 50;
  418. $post['state'] = '["IN_CANCEL","WAIT_SELLER_SEND_GOODS","SELLER_PART_SEND_GOODS","WAIT_BUYER_ACCEPT_GOODS","FUND_PROCESSING","IN_ISSUE","IN_FROZEN","WAIT_SELLER_EXAMINE_MONEY","RISK_CONTROL"]';
  419. $post['code'] = '50002100d409LZqwnvDc1iVenS9ysG7EbP4LuxhnfuHykTwEciGd1129c3d57tI3Sin';
  420. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
  421. $res = curl_exec($ch);
  422. curl_close($ch);
  423. $res = json_decode($res,true);
  424. echo "<pre>";
  425. print_r($res);
  426. }
  427. public function _xqcx($arg_array)
  428. {
  429. $cw = array();
  430. $class = array();$classdata = array();$lx = array();$pm = array();
  431. $a = $this->typeclass->find_all('classid=6 or classid=7 or classid=8 or classid=10 or classid=12 or classid=13 or classid=15 or classid=19 or classid=20 or classid=21 or classid=22 or classid=23 or classid=24');
  432. foreach ($a as $val)
  433. {
  434. $class[] = '-'.$val['id'].'-';
  435. }
  436. $b = $this->typeclass->find_all();
  437. foreach ($b as $val)
  438. {
  439. $classdata[$val['id']] = $val['title'];
  440. $lx[$val['id']] = $val['classid'];
  441. $pm[$val['id']] = $val['zh'];
  442. }
  443. //Closure wigs
  444. $dataa = $this->fullorder->find_all("librarytime > '1598889600' and librarytime < '1601395200' and (fpdata like '%Closure%' or fpdata like '%Wigs%')",'number,fpdata','id desc');
  445. $datab = $this->fullordersmt->find_all("librarytime > '1598889600' and librarytime < '1601395200' and (fpdata like '%Closure%' or fpdata like '%Wigs%')",'number,fpdata','id desc');
  446. $data = array_merge($dataa,$datab);
  447. $p = $class;
  448. $resdata = array();
  449. foreach ($data as $val)
  450. {
  451. $f = explode(';',trim($val['fpdata'],';'));
  452. foreach ($f as $v)
  453. {
  454. if((stripos($v,'-127-') !== false || stripos($v,'-128-') !== false) && stripos($v,'-57-') !== false)
  455. {
  456. $e = explode('|',$v);
  457. $d = str_replace($p,'-',$e[0]);
  458. $q = str_replace(array('-163-','-164-','-165-','-166-'),'-',$e[0]);
  459. $q = explode('-',trim($q,'-'));
  460. $c = explode(',',$e[0]);
  461. if(!isset($resdata[$d]))
  462. {
  463. if(stripos($v,'-127-') !== false)
  464. {
  465. if(isset($q[9]))
  466. {
  467. $s = ($q[9] != 68 && $q[9] != 69)?1:2;
  468. }
  469. else
  470. {
  471. $s = 1;
  472. }
  473. $bt = (!isset($q[8]))?$q[5]:$q[8];//360类型的蕾丝尺寸直接显示为类型名称
  474. if($lx[$q[5]] == '27')//如果是发块类型
  475. {
  476. $resdata[$d] = array($e[2],rtrim($classdata[$c[0]],'inch'),$q[5],$bt,$s);//数量、尺寸、类型、蕾丝尺寸、蕾丝颜色
  477. }
  478. }
  479. else
  480. {
  481. if(isset($q[8]))
  482. {
  483. $s = ($q[8] != 68 && $q[8] != 69)?1:2;
  484. }
  485. else
  486. {
  487. $s = 1;
  488. }
  489. if($lx[$q[5]] == '18')//如果是头套种类
  490. {
  491. $resdata[$d] = array($e[2],rtrim($classdata[$c[0]],'inch'),$q[5],$s);//数量、尺寸、头套种类、蕾丝颜色
  492. }
  493. }
  494. }
  495. else
  496. {
  497. if(is_array($e[2]) || !is_numeric($e[2]))
  498. {
  499. $cw[] = $v;
  500. continue;
  501. }
  502. else
  503. {
  504. $resdata[$d][0] += $e[2];
  505. }
  506. }
  507. }
  508. }
  509. }
  510. $data = array();
  511. foreach ($resdata as $v)
  512. {
  513. if(isset($v[4]))
  514. {
  515. if(!isset($data[$v[1].$v[2].$v[3].$v[4]]))
  516. {
  517. $data[$v[1].$v[2].$v[3].$v[4]] = array($v[0],$v[1],$pm[$v[2]],$classdata[$v[3]],$v[4]);//$classdata[$v[2]]英文名,$pm[$v[2]]中文名
  518. }
  519. else
  520. {
  521. $data[$v[1].$v[2].$v[3].$v[4]][0] += $v[0];
  522. }
  523. }
  524. else
  525. {
  526. if(!isset($data[$v[1].$v[2].$v[3]]))
  527. {
  528. $data[$v[1].$v[2].$v[3]] = array($v[0],$v[1],$pm[$v[2]],$v[3]);//$classdata[$v[2]]英文名,$pm[$v[2]]中文名
  529. }
  530. else
  531. {
  532. $data[$v[1].$v[2].$v[3]][0] += $v[0];
  533. }
  534. }
  535. }
  536. $list = array();
  537. foreach ($data as $v)
  538. {
  539. $x = (isset($v[4]))?$v[3]:$v[2];
  540. if(!isset($list[$v[2]]))
  541. {
  542. $list[$v[2]] = array();
  543. if(!isset($list[$v[2]][$x]))
  544. {
  545. $list[$v[2]][$x] = array();
  546. $list[$v[2]][$x][] = $v;
  547. }
  548. else
  549. {
  550. $list[$v[2]][$x][] = $v;
  551. }
  552. }
  553. else
  554. {
  555. if(!isset($list[$v[2]][$x]))
  556. {
  557. $list[$v[2]][$x] = array();
  558. $list[$v[2]][$x][] = $v;
  559. }
  560. else
  561. {
  562. $list[$v[2]][$x][] = $v;
  563. }
  564. }
  565. }
  566. foreach ($list as $key=>$val)
  567. {
  568. foreach ($val as $k=>$va)
  569. {
  570. $dd = array();
  571. foreach ($va as $v)
  572. {
  573. $ss = (!isset($v[4]))?$v[3]:$v[4];
  574. if(!isset($dd[$v['1']]))
  575. {
  576. $dd[$v['1']] = array();
  577. $dd[$v['1']][$ss] = $v;
  578. }
  579. else
  580. {
  581. $dd[$v['1']][$ss] = $v;
  582. }
  583. }
  584. ksort($dd);
  585. $list[$key][$k] = $dd;
  586. }
  587. }
  588. //echo count($list);
  589. //echo "<pre>";
  590. //print_r($list);
  591. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  592. <head>
  593. <!--[if gte mso 9]><xml>
  594. <x:ExcelWorkbook>
  595. <x:ExcelWorksheets>
  596. <x:ExcelWorksheet>
  597. <x:Name>EXCEL</x:Name>
  598. <x:WorksheetOptions>
  599. <x:Print>
  600. <x:ValidPrinterInfo />
  601. </x:Print>
  602. </x:WorksheetOptions>
  603. </x:ExcelWorksheet>
  604. </x:ExcelWorksheets>
  605. </x:ExcelWorkbook>
  606. </xml>
  607. <![endif]-->
  608. </head><body>";
  609. foreach ($list as $key=>$val)
  610. {
  611. $btnum = count($val);
  612. $str .= "<table border=1>
  613. <tr style='color: #F00;'><th colspan='".($btnum+$btnum*2)."' align='left'><h3>".$key."<h3></th></tr>
  614. <tr>";
  615. foreach ($val as $k=>$v)
  616. {
  617. $str .="<td style='background-color: #ffff00;color: #F00;width:20px'>".$k."</td>
  618. <td>中棕</td>
  619. <td>透明</td>";
  620. }
  621. $str .= "</tr>
  622. </table>";
  623. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'><tr>";
  624. foreach ($val as $k=>$v)
  625. {
  626. $str .= "<td><table border=1>";
  627. foreach ($v as $sk=>$s)
  628. {
  629. $xk1 = (isset($s[1]))?$s[1][0]:0;
  630. $xk2 = (isset($s[2]))?$s[2][0]:0;
  631. $str .="<tr><td style='color: #F00;'>".$sk."</td><td>".$xk1."</td><td>".$xk2."</td></tr>";
  632. }
  633. $str .= "</table></td>";
  634. }
  635. $str .= "</table>";
  636. }
  637. $str .= "</body></html>";
  638. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  639. header( "Content-type: application/octet-stream" );
  640. header( "Content-Disposition: attachment; filename=".time().'.xls' );
  641. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  642. header( "Pragma: no-cache" );
  643. header( "Expires: 0" );
  644. exit($str);
  645. }
  646. public function _fedexhz($arg_array)
  647. {
  648. $fullorder = $this->fullorder->get_number($arg_array[0]);
  649. if(!$fullorder)
  650. {
  651. $fullorder = $this->fullordersmt->get_number($arg_array[0]);
  652. }
  653. $fullorder = $this->_text($fullorder);
  654. $data = $fullorder;
  655. $ToState = array('alabama'=>'AL','alaska'=>'AK','arizona'=>'AZ','arkansas'=>'AR','california'=>'CA','colorado'=>'CO','connecticut'=>'CT','delaware'=>'DE','florida'=>'FL','georgia'=>'GA','hawaii'=>'HI','idaho'=>'ID','illinois'=>'IL','indiana'=>'IN','iowa'=>'IA','kansas'=>'KS','kentucky'=>'KY','louisiana'=>'LA','maine'=>'ME','maryland'=>'MD','massachusetts'=>'MA','michigan'=>'MI','minnesota'=>'MN','mississippi'=>'MS','missouri'=>'MO','montana'=>'MT','nebraska'=>'NE','nevada'=>'NV','new hampshire'=>'NH','new jersey'=>'NJ','new mexico'=>'NM','new york'=>'NY','north carolina'=>'NC','north dakota'=>'ND','ohio'=>'OH','oklahoma'=>'OK','oregon'=>'OR','pennsylvania'=>'PA','rhode island'=>'RI','south carolina'=>'SC','south dakota'=>'SD','tennessee'=>'TN','texas'=>'TX','utah'=>'UT','vermont'=>'VT','virginia'=>'VA','washington'=>'WA','west virginia'=>'WV','wisconsin'=>'WI','wyoming'=>'WY','district of columbia'=>'DC','virgin islands'=>'VI','guam'=>'GU');
  656. $data['province'] = preg_replace('/( | | |\s)/',' ',$data['province']);
  657. $data['province'] = trim($data['province'],' ');
  658. $dataprovince = strlen($data['province'])==2?$data['province']:$ToState[strtolower($data['province'])];
  659. $data['province'] = $dataprovince;
  660. //your account details here
  661. /**许昌联邦账号
  662. $key = 'L7Vtg0uUP0BxgNfp';
  663. $password = 'iOqmHwfjx12sxszdEZstGtRYs';
  664. $AccountNumber = '644155250';
  665. $MeterNumber = '250140772';
  666. **/
  667. //杭州联邦账号
  668. $key = 'Jx8Rq9QL34sMKJTK';
  669. $password = 'lmnYVRVcOISI0D1i48CEiXpYh';
  670. $AccountNumber = '692362136';
  671. $MeterNumber = '250759448';
  672. $xml = '<?xml version="1.0" encoding="UTF-8"?>';
  673. $xml.='<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v26="http://fedex.com/ws/ship/v26">';
  674. $xml.='<soapenv:Header/>';
  675. $xml.='<soapenv:Body>';
  676. $xml.='<v26:ProcessShipmentRequest>';
  677. $xml.='<v26:WebAuthenticationDetail>';
  678. $xml.='<v26:ParentCredential>';
  679. $xml.='<v26:Key>'.$key.'</v26:Key>';
  680. $xml.='<v26:Password>'.$password.'</v26:Password>';
  681. $xml.='</v26:ParentCredential>';
  682. $xml.='<v26:UserCredential>';
  683. $xml.='<v26:Key>'.$key.'</v26:Key>';
  684. $xml.='<v26:Password>'.$password.'</v26:Password>';
  685. $xml.='</v26:UserCredential>';
  686. $xml.='</v26:WebAuthenticationDetail>';
  687. $xml.='<v26:ClientDetail>';
  688. $xml.='<v26:AccountNumber>'.$AccountNumber.'</v26:AccountNumber>';
  689. $xml.='<v26:MeterNumber>'.$MeterNumber.'</v26:MeterNumber>';
  690. $xml.='</v26:ClientDetail>';
  691. $xml.='<v26:TransactionDetail>';
  692. //$xml.='<v26:CustomerTransactionId>Ship_International_basic</v26:CustomerTransactionId>';
  693. $xml.='</v26:TransactionDetail>';
  694. $xml.='<v26:Version>';
  695. $xml.='<v26:ServiceId>ship</v26:ServiceId>';
  696. $xml.='<v26:Major>26</v26:Major>';
  697. $xml.='<v26:Intermediate>0</v26:Intermediate>';
  698. $xml.='<v26:Minor>0</v26:Minor>';
  699. $xml.='</v26:Version>';
  700. $xml.='<v26:RequestedShipment>';
  701. $xml.='<v26:ShipTimestamp>'.date('Y-m-d',time()).'T'.date('H:i:s',time()).'-12:00'.'</v26:ShipTimestamp>';
  702. $xml.='<v26:DropoffType>REGULAR_PICKUP</v26:DropoffType>';
  703. $xml.='<v26:ServiceType>FEDEX_INTERNATIONAL_PRIORITY</v26:ServiceType>';//FEDEX_INTERNATIONAL_PRIORITY、FEDEX_INTERNATIONAL_PRIORITY_EXPRESS也是优先。INTERNATIONAL_ECONOMY经济
  704. //超过重量需要换包装,现在不设置,超出也按0.4走
  705. if($data['zzl'] < '9999999')//现在限制死,只有0.4 实际应填写 $data['zzl'] < 0.5
  706. {
  707. $xml.='<v26:PackagingType>FEDEX_PAK</v26:PackagingType>';
  708. }
  709. else
  710. {
  711. $xml.='<v26:PackagingType>FEDEX_BOX</v26:PackagingType>';
  712. }
  713. $xml.='<v26:Shipper>';//发货人信息开始
  714. $xml.='<v26:AccountNumber>'.$AccountNumber.'</v26:AccountNumber>';
  715. $xml.='<v26:Contact>';
  716. $xml.='<v26:PersonName>LONGYI</v26:PersonName>';//$data['warehouse']['company']
  717. $xml.='<v26:CompanyName>LONGYI</v26:CompanyName>';//$data['warehouse']['company']
  718. $xml.='<v26:PhoneNumber>18539006340</v26:PhoneNumber>';//$data['warehouse']['phone']
  719. //$xml.='<v26:EMailAddress>'.$data['warehouse']['name'].'</v26:EMailAddress>';
  720. $xml.='</v26:Contact>';
  721. $xml.='<v26:Address>';
  722. $xml.='<v26:StreetLines>4703,building C,bodi center,ningwei street</v26:StreetLines>';//$data['warehouse']['address']
  723. $xml.='<v26:City>Hang Zhou</v26:City>';//$data['warehouse']['city']
  724. //$xml.='<v26:StateOrProvinceCode>TN</v26:StateOrProvinceCode>';
  725. $xml.='<v26:PostalCode>310000</v26:PostalCode>';//$data['warehouse']['zipcode'] //许昌联邦要求使用郑州邮编:450016
  726. $xml.='<v26:CountryCode>'.$data['warehouse']['lb'].'</v26:CountryCode>';
  727. $xml.='</v26:Address>';
  728. $xml.='</v26:Shipper>';
  729. $xml.='<v26:Recipient>';//收货人信息开始
  730. $xml.='<v26:AccountNumber>'.$AccountNumber.'</v26:AccountNumber>';
  731. $xml.='<v26:Contact>';
  732. $xml.='<v26:PersonName>'.$data['name'].'</v26:PersonName>';
  733. $xml.='<v26:CompanyName>'.$data['client'].'</v26:CompanyName>';
  734. $xml.='<v26:PhoneNumber>'.$data['phone'].'</v26:PhoneNumber>';
  735. //$xml.='<v26:EMailAddress>'.$data['name'].'</v26:EMailAddress>';
  736. $xml.='</v26:Contact>';
  737. $xml.='<v26:Address>';
  738. $xml.='<v26:StreetLines>'.$data['address'].'</v26:StreetLines>';
  739. $xml.='<v26:StreetLines>'.$data['address2'].'</v26:StreetLines>';
  740. $xml.='<v26:City>'.$data['city'].'</v26:City>';
  741. $xml.='<v26:StateOrProvinceCode>'.$data['province'].'</v26:StateOrProvinceCode>';
  742. $xml.='<v26:PostalCode>'.$data['zipcode'].'</v26:PostalCode>';
  743. $xml.='<v26:CountryCode>'.$data['lb'].'</v26:CountryCode>';
  744. $xml.='</v26:Address>';
  745. $xml.='</v26:Recipient>';
  746. $xml.='<v26:ShippingChargesPayment>';
  747. $xml.='<v26:PaymentType>SENDER</v26:PaymentType>';
  748. $xml.='<v26:Payor>';
  749. $xml.='<v26:ResponsibleParty>';
  750. $xml.='<v26:AccountNumber>'.$AccountNumber.'</v26:AccountNumber>';
  751. $xml.='<v26:Contact>';
  752. $xml.='<v26:PersonName>He Cong</v26:PersonName>';
  753. //$xml.='<v26:EMailAddress></v26:EMailAddress>';
  754. $xml.='</v26:Contact>';
  755. $xml.='</v26:ResponsibleParty>';
  756. $xml.='</v26:Payor>';
  757. $xml.='</v26:ShippingChargesPayment>';
  758. //ETD开始
  759. $xml.='<v26:SpecialServicesRequested>';
  760. $xml.='<v26:SpecialServiceTypes>ELECTRONIC_TRADE_DOCUMENTS</v26:SpecialServiceTypes>';
  761. $xml.='<v26:EtdDetail>';
  762. $xml.='<v26:RequestedDocumentCopies>COMMERCIAL_INVOICE</v26:RequestedDocumentCopies>';
  763. $xml.='</v26:EtdDetail>';
  764. $xml.='</v26:SpecialServicesRequested>';
  765. //ETD结束
  766. $xml.='<v26:CustomsClearanceDetail>';
  767. $xml.='<v26:DutiesPayment>';
  768. $xml.='<v26:PaymentType>RECIPIENT</v26:PaymentType>';
  769. $xml.='<v26:Payor>';
  770. $xml.='<v26:ResponsibleParty>';
  771. $xml.='<v26:AccountNumber></v26:AccountNumber>';
  772. //$xml.='<v26:Tins>';
  773. //$xml.='<v26:TinType>BUSINESS_STATE</v26:TinType>';//雇主识别代码BUSINESS_NATIONAL、BUSINESS_STATE、BUSINESS_UNION、PERSONAL_NATIONAL、PERSONAL_STATE
  774. //$xml.='<v26:Number>213456</v26:Number>';//这里填税号
  775. //$xml.='</v26:Tins>';
  776. //$xml.='<v26:Contact>';
  777. //$xml.='<v26:ContactId>12345</v26:ContactId>';
  778. //$xml.='<v26:PersonName>INPUT YOUR INFORMATION</v26:PersonName>';
  779. //$xml.='</v26:Contact>';
  780. $xml.='</v26:ResponsibleParty>';
  781. $xml.='</v26:Payor>';
  782. $xml.='</v26:DutiesPayment>';
  783. $xml.='<v26:DocumentContent>DOCUMENTS_ONLY</v26:DocumentContent>';
  784. $xml.='<v26:CustomsValue>';
  785. $xml.='<v26:Currency>USD</v26:Currency>';
  786. $xml.='<v26:Amount>'.$data['zsbjz'].'</v26:Amount>';
  787. $xml.='</v26:CustomsValue>';
  788. //DESC1---:Commodities循环
  789. $xml.='<v26:Commodities>';
  790. $xml.='<v26:NumberOfPieces>1</v26:NumberOfPieces>';//件数
  791. $xml.='<v26:Description>satin bags-100PCS</v26:Description>';//品名和数量
  792. $xml.='<v26:CountryOfManufacture>CN</v26:CountryOfManufacture>';
  793. $xml.='<v26:HarmonizedCode>4202320000</v26:HarmonizedCode>';//海关编码
  794. $xml.='<v26:Weight>';
  795. $xml.='<v26:Units>KG</v26:Units>';//重量:磅
  796. $xml.='<v26:Value>0.1</v26:Value>';//重量填写单位为KG $data['zzl'] 现在限制死,只有0.4
  797. $xml.='</v26:Weight>';
  798. $xml.='<v26:Quantity>100</v26:Quantity>';//需要填写数量
  799. $xml.='<v26:QuantityUnits>cm</v26:QuantityUnits>';
  800. $xml.='<v26:UnitPrice>';
  801. $xml.='<v26:Currency>USD</v26:Currency>';
  802. $xml.='<v26:Amount>0.2</v26:Amount>';//单条申报价值
  803. $xml.='</v26:UnitPrice>';
  804. $xml.='</v26:Commodities>';
  805. //DESC2
  806. $xml.='<v26:Commodities>';
  807. $xml.='<v26:NumberOfPieces>1</v26:NumberOfPieces>';//件数
  808. $xml.='<v26:Description>hair accessories-100PCS</v26:Description>';//品名和数量
  809. $xml.='<v26:CountryOfManufacture>CN</v26:CountryOfManufacture>';
  810. $xml.='<v26:HarmonizedCode>9615110000</v26:HarmonizedCode>';//海关编码
  811. $xml.='<v26:Weight>';
  812. $xml.='<v26:Units>KG</v26:Units>';//重量:磅
  813. $xml.='<v26:Value>0.1</v26:Value>';//重量填写单位为KG $data['zzl'] 现在限制死,只有0.4
  814. $xml.='</v26:Weight>';
  815. $xml.='<v26:Quantity>100</v26:Quantity>';//需要填写数量
  816. $xml.='<v26:QuantityUnits>cm</v26:QuantityUnits>';
  817. $xml.='<v26:UnitPrice>';
  818. $xml.='<v26:Currency>USD</v26:Currency>';
  819. $xml.='<v26:Amount>0.3</v26:Amount>';//单条申报价值
  820. $xml.='</v26:UnitPrice>';
  821. $xml.='</v26:Commodities>';
  822. //DESC3
  823. $xml.='<v26:Commodities>';
  824. $xml.='<v26:NumberOfPieces>1</v26:NumberOfPieces>';//件数
  825. $xml.='<v26:Description>woven label-1000PCS</v26:Description>';//品名和数量
  826. $xml.='<v26:CountryOfManufacture>CN</v26:CountryOfManufacture>';
  827. $xml.='<v26:HarmonizedCode>5901101090</v26:HarmonizedCode>';//海关编码
  828. $xml.='<v26:Weight>';
  829. $xml.='<v26:Units>KG</v26:Units>';//重量:磅
  830. $xml.='<v26:Value>0.2</v26:Value>';//重量填写单位为KG $data['zzl'] 现在限制死,只有0.4
  831. $xml.='</v26:Weight>';
  832. $xml.='<v26:Quantity>1000</v26:Quantity>';//需要填写数量
  833. $xml.='<v26:QuantityUnits>cm</v26:QuantityUnits>';
  834. $xml.='<v26:UnitPrice>';
  835. $xml.='<v26:Currency>USD</v26:Currency>';
  836. $xml.='<v26:Amount>0.05</v26:Amount>';//单条申报价值
  837. $xml.='</v26:UnitPrice>';
  838. $xml.='</v26:Commodities>';
  839. /**
  840. //DESC4
  841. $xml.='<v26:Commodities>';
  842. $xml.='<v26:NumberOfPieces>1</v26:NumberOfPieces>';//件数
  843. $xml.='<v26:Description>satin bags-100PCS</v26:Description>';//品名和数量
  844. $xml.='<v26:CountryOfManufacture>CN</v26:CountryOfManufacture>';
  845. $xml.='<v26:HarmonizedCode>4202320000</v26:HarmonizedCode>';//海关编码
  846. $xml.='<v26:Weight>';
  847. $xml.='<v26:Units>KG</v26:Units>';//重量:磅
  848. $xml.='<v26:Value>0.2</v26:Value>';//重量填写单位为KG $data['zzl'] 现在限制死,只有0.4
  849. $xml.='</v26:Weight>';
  850. $xml.='<v26:Quantity>100</v26:Quantity>';//需要填写数量
  851. $xml.='<v26:QuantityUnits>cm</v26:QuantityUnits>';
  852. $xml.='<v26:UnitPrice>';
  853. $xml.='<v26:Currency>USD</v26:Currency>';
  854. $xml.='<v26:Amount>0.2</v26:Amount>';//单条申报价值
  855. $xml.='</v26:UnitPrice>';
  856. $xml.='</v26:Commodities>';
  857. **/
  858. $xml.='<v26:ExportDetail>';
  859. $xml.='<v26:ExportComplianceStatement>30.37(f)</v26:ExportComplianceStatement>';
  860. $xml.='</v26:ExportDetail>';
  861. $xml.='</v26:CustomsClearanceDetail>';
  862. $xml.='<v26:LabelSpecification>';
  863. $xml.='<v26:LabelFormatType>COMMON2D</v26:LabelFormatType>';
  864. $xml.='<v26:ImageType>PDF</v26:ImageType>';
  865. $xml.='<v26:LabelStockType>STOCK_4X6.75</v26:LabelStockType>';
  866. $xml.='</v26:LabelSpecification>';
  867. //发票参数开始
  868. $xml.='<v26:ShippingDocumentSpecification>';
  869. $xml.='<v26:ShippingDocumentTypes>COMMERCIAL_INVOICE</v26:ShippingDocumentTypes>';
  870. //ETD
  871. $xml.='<v26:CommercialInvoiceDetail>';
  872. $xml.='<v26:Format>';
  873. $xml.='<v26:ImageType>PDF</v26:ImageType>';
  874. $xml.='<v26:StockType>PAPER_LETTER</v26:StockType>';
  875. $xml.='<v26:ProvideInstructions>true</v26:ProvideInstructions>';
  876. $xml.='</v26:Format>';
  877. $xml.='<v26:CustomerImageUsages>';
  878. $xml.='<v26:Type>LETTER_HEAD</v26:Type>';
  879. $xml.='<v26:Id>IMAGE_1</v26:Id>';
  880. $xml.='</v26:CustomerImageUsages>';
  881. $xml.='<v26:CustomerImageUsages>';
  882. $xml.='<v26:Type>SIGNATURE</v26:Type>';
  883. $xml.='<v26:Id>IMAGE_2</v26:Id>';
  884. $xml.='</v26:CustomerImageUsages>';
  885. //ETD
  886. $xml.='</v26:CommercialInvoiceDetail>';
  887. $xml.='</v26:ShippingDocumentSpecification>';
  888. //发票参数结束
  889. $xml.='<v26:RateRequestTypes>LIST</v26:RateRequestTypes>';//费率请求类型
  890. $xml.='<v26:PackageCount>'.$data['zjs'].'</v26:PackageCount>';//包装数量
  891. $xml.='<v26:RequestedPackageLineItems>';
  892. $xml.='<v26:SequenceNumber>1</v26:SequenceNumber>';
  893. //$xml.='<v26:InsuredValue><v26:Currency>USD</v26:Currency><v26:Amount>120.00</v26:Amount></v26:InsuredValue>';//保险金额
  894. $xml.='<v26:Weight>';
  895. $xml.='<v26:Units>KG</v26:Units>';
  896. $xml.='<v26:Value>0.4</v26:Value>';//现在限制死,只有0.4 '.$data['zzl'].'
  897. $xml.='</v26:Weight>';
  898. //超过重量需要填尺寸,现在不设置,超出也按0.4走
  899. if($data['zzl'] > '99999')//这个正常设置应该是$data['zzl'] > '0.4'
  900. {
  901. $xml.='<v26:Dimensions>';
  902. $xml.='<v26:Length>4</v26:Length>';
  903. $xml.='<v26:Width>20</v26:Width>';
  904. $xml.='<v26:Height>30</v26:Height>';
  905. $xml.='<v26:Units>CM</v26:Units>';
  906. $xml.='</v26:Dimensions>';
  907. }
  908. //$xml.='<v26:ItemDescription>Book</v26:ItemDescription>';//阿联酋需要选择
  909. $xml.='<v26:CustomerReferences>';
  910. $xml.='<v26:CustomerReferenceType>CUSTOMER_REFERENCE</v26:CustomerReferenceType>';
  911. $xml.='<v26:Value>'.$data['number'].'</v26:Value>';
  912. $xml.='</v26:CustomerReferences>';
  913. //签名开始
  914. if($data['qm'] > 0)
  915. {
  916. $qm = ($data['qm']=='1')?'ADULT':'INDIRECT';//DIRECT直接签名 ADULT成人签名 INDIRECT间接签名
  917. $xml.='<v26:SpecialServicesRequested>';
  918. $xml.='<v26:SpecialServiceTypes>SIGNATURE_OPTION</v26:SpecialServiceTypes>';
  919. $xml.='<v26:SignatureOptionDetail>';
  920. $xml.='<v26:OptionType>'.$qm.'</v26:OptionType>';
  921. $xml.='</v26:SignatureOptionDetail>';
  922. $xml.='</v26:SpecialServicesRequested>';
  923. }
  924. //签名结束
  925. $xml.='</v26:RequestedPackageLineItems>';
  926. $xml.='</v26:RequestedShipment>';
  927. $xml.='</v26:ProcessShipmentRequest>';
  928. $xml.='</soapenv:Body>';
  929. $xml.='</soapenv:Envelope>';
  930. /**
  931. $ch = curl_init();
  932. curl_setopt($ch, CURLOPT_URL, 'https://ws.fedex.com:443/web-services/ship');
  933. curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
  934. curl_setopt($ch, CURLOPT_VERBOSE, 1);
  935. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  936. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  937. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  938. curl_setopt($ch, CURLOPT_POST, 1);
  939. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,35);
  940. $result_xml = curl_exec($ch);
  941. $result_xml = str_replace(array(':','-'), '', $result_xml);
  942. @$values = json_decode(json_encode(simplexml_load_string($result_xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
  943. **/
  944. $ch = curl_init();
  945. $url = 'http://z.wepolicy.cn/fedexhz.php';
  946. curl_setopt($ch,CURLOPT_URL,$url);
  947. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  948. curl_setopt($ch,CURLOPT_HEADER,0);
  949. curl_setopt($ch,CURLOPT_POST, 1);
  950. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,35);
  951. //设置post数据
  952. $post = array();
  953. $post['data'] = $xml;
  954. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
  955. $res = curl_exec($ch);
  956. curl_close($ch);
  957. $values = json_decode($res,true);
  958. if(isset($values['SOAPENVBody']['ProcessShipmentReply']['CompletedShipmentDetail']['MasterTrackingId']['TrackingNumber']))
  959. {
  960. $g = array('x'=>'1','waybill'=>$values['SOAPENVBody']['ProcessShipmentReply']['CompletedShipmentDetail']['MasterTrackingId']['TrackingNumber'],'label'=>$values['SOAPENVBody']['ProcessShipmentReply']['CompletedShipmentDetail']['CompletedPackageDetails']['Label']['Parts']['Image'],'invoice'=>$values['SOAPENVBody']['ProcessShipmentReply']['CompletedShipmentDetail']['ShipmentDocuments']['Parts']['Image']);
  961. }
  962. else if(isset($values['SOAPENVBody']['ProcessShipmentReply']['Notifications']))
  963. {
  964. $a = '';
  965. if(isset($values['SOAPENVBody']['ProcessShipmentReply']['Notifications']['LocalizedMessage']))
  966. {
  967. $a = $values['SOAPENVBody']['ProcessShipmentReply']['Notifications']['LocalizedMessage'];
  968. }
  969. else
  970. {
  971. foreach ($values['SOAPENVBody']['ProcessShipmentReply']['Notifications'] as $v)
  972. {
  973. $a .= $v['LocalizedMessage'].'--';
  974. }
  975. }
  976. $g = array('x'=>'0','Description'=>$a);
  977. }
  978. else
  979. {
  980. $g = array('x'=>'0','Description'=>'未知错误');
  981. }
  982. echo "<pre>";
  983. print_r($g);
  984. }
  985. public function _text($fullorder)
  986. {
  987. /** 发票地址信息暂时无用
  988. $fullorder['baddress'] = explode(',',$fullorder['baddress']);
  989. $fullorder['baddress'] = array_reverse($fullorder['baddress']);
  990. $fullorder['baddress'][1] = $country['ename'];
  991. **/
  992. //获取所用相关信息
  993. $warehouse = $this->warehouse->read($fullorder['type']);
  994. $country = $this->country->read($fullorder['country']);//订单国家信息
  995. $fcountry = $this->country->read($warehouse['country']);//仓库国家信息
  996. $warehouse['country'] = $fcountry['ename'];//仓库国家名
  997. $warehouse['lb'] = $fcountry['lb'];//仓库国家编码
  998. $fullorder['warehouse'] = $warehouse;//仓库数据加入订单
  999. $fullorder['lb'] = $country['lb'];//订单国家编码加入
  1000. $fullorder['country'] = $country['ename'];//订单国家名
  1001. $fullorder['zhou'] = $country['continent'];//所属州
  1002. $express = $this->express->read($fullorder['express']);
  1003. $fullorder['express'] = $express['servicename'];
  1004. $fullorder['account'] = $express['account'];
  1005. $fullorder['printcode'] = $express['printcode'];
  1006. $fullorder['time'] = date('Y-m-d',time());
  1007. $fullorder['times'] = date('Y-m-d H:i',time());
  1008. $fullorder['sbbm']= ($fullorder['sbpm'] == 'Hair Sample') ? 67042000 : 67041100;
  1009. $fullorder['address'] = str_replace(array('&'),array('&#38;'),$fullorder['address']);
  1010. $fullorder['address2'] = str_replace(array('&'),array('&#38;'),$fullorder['address2']);
  1011. $fullorder['shipremarks'] = str_replace(array('<','>',';',';'),array('&lt','&gt',';<br>',';<br>'),$fullorder['shipremarks']);
  1012. $shop = $this->shop->read($fullorder['shop']);
  1013. $fullorder['shop'] = $shop['shopname'];
  1014. if(is_numeric($fullorder['pay']))
  1015. {
  1016. $pay = $this->typeclass->read($fullorder['pay']);
  1017. if($pay['classid'] == '4')
  1018. {
  1019. $fullorder['pay'] = $pay['title'];
  1020. }
  1021. }
  1022. if($fullorder['printcode'] != "USPS")
  1023. {
  1024. $fullorder['client'] = htmlspecialchars($fullorder['client']);
  1025. $fullorder['name'] = htmlspecialchars($fullorder['name']);
  1026. }
  1027. //增加退货单所需信息
  1028. $pt = '';
  1029. $fpdata = explode(';',trim($fullorder['fpdata'],';'));
  1030. foreach ($fpdata as $v)
  1031. {
  1032. $p = explode('|',trim($v,'|'));
  1033. $pt .= '<p>'.$p[1].' * '.$p[2].'</p>';
  1034. }
  1035. $fullorder['pt'] = $pt;
  1036. return $fullorder;
  1037. }
  1038. public function _dpex($arg_array)
  1039. {
  1040. $fullorder = $this->fullorder->get_number($arg_array[0]);
  1041. if(!$fullorder)
  1042. {
  1043. $fullorder = $this->fullordersmt->get_number($arg_array[0]);
  1044. }
  1045. $fullorder = $this->_text($fullorder);
  1046. /**
  1047. $warehouse = $this->warehouse->read($fullorder['type']);
  1048. $country = $this->country->read($fullorder['country']);//订单国家信息
  1049. $fcountry = $this->country->read($warehouse['country']);//仓库国家信息
  1050. $warehouse['country'] = $fcountry['ename'];//仓库国家名
  1051. $warehouse['lb'] = $fcountry['lb'];//仓库国家编码
  1052. $fullorder['warehouse'] = $warehouse;//仓库数据加入订单
  1053. $fullorder['lb'] = $country['lb'];//订单国家编码加入
  1054. $fullorder['country'] = $country['ename'];//订单国家名
  1055. $fullorder['zhou'] = $country['continent'];//所属州
  1056. $express = $this->express->read($fullorder['express']);
  1057. $fullorder['express'] = $express['servicename'];
  1058. $fullorder['account'] = $express['account'];
  1059. $fullorder['printcode'] = $express['printcode'];
  1060. $fullorder['time'] = date('Y-m-d',time());
  1061. $fullorder['times'] = date('Y-m-d H:i',time());
  1062. $fullorder['sbbm']= ($fullorder['sbpm'] == 'Hair Sample') ? 67042000 : 67041100;
  1063. $fullorder['address'] = str_replace(array('&'),array('&#38;'),$fullorder['address']);
  1064. $fullorder['address2'] = str_replace(array('&'),array('&#38;'),$fullorder['address2']);
  1065. $shop = $this->shop->read($fullorder['shop']);
  1066. $fullorder['shop'] = $shop['shopname'];
  1067. **/
  1068. $fullorder['number'] = $fullorder['number'].'-1';//订单号重复修改新订单好
  1069. $data = $fullorder;
  1070. $url = "http://ambcargo.kingtrans.cn/PostInterfaceService?method=createOrder";
  1071. $Clientid = 'LYFZP';
  1072. $Token = 'NGkJSDx3bAxojl1YN232';
  1073. $code = array('DPEX'=>array('11','DPEX','1'),'ARAMEX'=>array('002','安迈世',0),'FEDEX'=>array('FEDEX_1CC','FEDEX_1CC',';lab10_10'),'UPS'=>array('04','UPS',0),'DHL'=>array('06','DHL',';lab10_10'),'FED-SN-IP'=>array('07','FED-SN-IP',';lab10_10'),'WML-FEDEX-ZZ'=>array('05','WML-FEDEX-ZZ',';lab10_10'),'FED-XS-F'=>array('03','FED-XS-F',';lab10_10'),'CNE'=>array('08','全球优先CNE','label10x10;0'),'TCNE'=>array('09','E速宝特惠','label10x10;0'));
  1074. $printcode = $code[$data['printcode']];
  1075. //创建并预报订单
  1076. $count = array(
  1077. 'Verify' => array(
  1078. 'Clientid'=>$Clientid,
  1079. 'Token'=>$Token
  1080. ),
  1081. 'OrderType' => '1',//1:快件订单 2:快递制单-非实时返回单号 3:仓储订单 4:快递制单-实时返回单号(等待时间较 长)。此方法选择 4,后续如需调用其他 方法,例如调用删除接口,其他方法 OrderType 请选择 2。
  1082. 'OrderDatas' => array(0=>array(
  1083. 'CustomerNumber' => $data['number'],//订单号
  1084. 'ChannelCode' => $printcode[0],//渠道代码
  1085. 'CountryCode' => $data['lb'],//国家二字码
  1086. 'TotalWeight' => $data['zzl'],//订单重量
  1087. 'TotalValue' => $data['zsbjz'],//申报价值
  1088. 'Number' => $data['zjs'],//件数
  1089. 'Note' => $data['number'],//备注
  1090. /**
  1091. 'Insurance' => array(//是否购买保险
  1092. 'Code' => '',//保险类型
  1093. 'Value' => '',//保险金额
  1094. ),
  1095. **/
  1096. 'FeePayData' => array(//运费支付信息
  1097. 'FeePayType' => 'PP',//支付方式 [ PP:预付,CC:到付, TP:第三方]
  1098. 'FeePayAccountNumber' => '',//支付账号 支付方式为 TP 时必传 支付方式为 PP 并且渠道 UPS 时必传
  1099. 'FeePayCountryCode' => '',//支付账号对应国家 支付方式为 TP 时必传
  1100. 'FeePayPostCode' => '',//支付账号对应邮编 支付方式为 TP 并且渠道 FEDEX 时必传
  1101. ),
  1102. 'TaxPayData' => array(//税金/关税支付信息 OrderType 为 [快递制单] 时必传字段
  1103. 'TaxPayType' => 'PP',//支付方式 [ PP:预付,CC:到付, TP:第三方]
  1104. 'TaxPayAccountNumber' => '',//支付账号 支付方式为 TP 时必传 支付方式为 PP 并且渠道 UPS 时必传
  1105. 'TaxPayCountryCode' => '',//支付账号对应国家 支付方式为 TP 时必传
  1106. 'TaxPayPostCode' => '',//支付账号对应邮编 支付方式为 TP 并且渠道 FEDEX 时必传
  1107. ),
  1108. 'Recipient' => array(//收件人信息
  1109. 'Name' => $data['name'],//姓名
  1110. 'Addres1' => $data['address'],//地址1
  1111. 'Addres2' => $data['address2'],//地址2
  1112. 'Mobile' => preg_replace('/\D/s','',$data['phone']),//手机
  1113. 'Province' => $data['province'],//省/州
  1114. 'City' => $data['city'],//城市
  1115. 'Post' => trim($data['zipcode'],' '),//邮编
  1116. ),
  1117. 'OrderItems' => array(
  1118. 0=>array(//订单明细
  1119. 'Money' => 'USD',//货币单位
  1120. //'Sku' => '123123',//产品 Sku (OrderType 为仓储订单必传)
  1121. 'Cnname' => '化纤发',//产品中文名
  1122. 'Enname' => 'synthetic hair*1',//产品英文名
  1123. 'Price' => '10',//单价
  1124. 'Weight' => '0.1',//重量
  1125. 'Num' => 1,//数量
  1126. 'CustomsCode'=>6704190000//海关编码
  1127. ),
  1128. 1=>array(//订单明细
  1129. 'Money' => 'USD',//货币单位
  1130. //'Sku' => '123123',//产品 Sku (OrderType 为仓储订单必传)
  1131. 'Cnname' => '头饰',//产品中文名
  1132. 'Enname' => 'hair accessories*1',//产品英文名
  1133. 'Price' => '0.5',//单价
  1134. 'Weight' => '0.1',//重量
  1135. 'Num' => '1',//数量
  1136. 'CustomsCode'=>9615110000//海关编码
  1137. ),
  1138. 2=>array(//订单明细
  1139. 'Money' => 'USD',//货币单位
  1140. //'Sku' => '123123',//产品 Sku (OrderType 为仓储订单必传)
  1141. 'Cnname' => '小发刷',//产品中文名
  1142. 'Enname' => 'Hairbrush*1',//产品英文名
  1143. 'Price' => '0.5',//单价
  1144. 'Weight' => '0.1',//重量
  1145. 'Num' => '1',//数量
  1146. 'CustomsCode'=>9603290090//海关编码
  1147. ),
  1148. 3=>array(//订单明细
  1149. 'Money' => 'USD',//货币单位
  1150. //'Sku' => '123123',//产品 Sku (OrderType 为仓储订单必传)
  1151. 'Cnname' => '袋子',//产品中文名
  1152. 'Enname' => 'Satin Bag*1',//产品英文名
  1153. 'Price' => '0.5',//单价
  1154. 'Weight' => '0.1',//重量
  1155. 'Num' => '1',//数量
  1156. 'CustomsCode'=>4202320000//海关编码
  1157. ),
  1158. 4=>array(//订单明细
  1159. 'Money' => 'USD',//货币单位
  1160. //'Sku' => '123123',//产品 Sku (OrderType 为仓储订单必传)
  1161. 'Cnname' => '假睫毛',//产品中文名
  1162. 'Enname' => 'Eyelashes*1',//产品英文名
  1163. 'Price' => '0.5',//单价
  1164. 'Weight' => '0.1',//重量
  1165. 'Num' => '1',//数量
  1166. 'CustomsCode'=>6704200000//海关编码
  1167. ),
  1168. /**
  1169. 2=>array(//订单明细
  1170. 'Money' => 'USD',//货币单位
  1171. //'Sku' => '123123',//产品 Sku (OrderType 为仓储订单必传)
  1172. 'Cnname' => '假睫毛',//产品中文名
  1173. 'Enname' => 'Eyelashes*1',//产品英文名
  1174. 'Price' => '0.5',//单价
  1175. 'Weight' => '0.1',//重量
  1176. 'Num' => '1',//数量
  1177. 'CustomsCode'=>6704200000//海关编码
  1178. ),
  1179. 3=>array(//订单明细
  1180. 'Money' => 'USD',//货币单位
  1181. //'Sku' => '123123',//产品 Sku (OrderType 为仓储订单必传)
  1182. 'Cnname' => '袋子',//产品中文名
  1183. 'Enname' => 'Satin Bag*1',//产品英文名
  1184. 'Price' => '0.5',//单价
  1185. 'Weight' => '0.1',//重量
  1186. 'Num' => '1',//数量
  1187. 'CustomsCode'=>4202320000//海关编码
  1188. )
  1189. **/
  1190. ))
  1191. )
  1192. /**,
  1193. 'Volumes' => array(//材积明细 (OrderType 为快递制单必传)
  1194. 'Weight' => '123123',//实重
  1195. 'Number' => '123123',//件数
  1196. 'Length' => '123123',//长
  1197. 'Width' => '123123',//宽
  1198. 'Height' => '123123',//高
  1199. ),
  1200. **/
  1201. );
  1202. $count = json_encode($count,true);
  1203. $ch = curl_init();
  1204. curl_setopt($ch,CURLOPT_URL,$url);
  1205. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  1206. curl_setopt($ch,CURLOPT_HEADER,0);
  1207. curl_setopt($ch,CURLOPT_POST, 1);
  1208. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
  1209. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query(array('json'=>$count)));
  1210. $res = curl_exec($ch);
  1211. curl_close($ch);
  1212. $res = json_decode($res,true);
  1213. if(!isset($res['returnDatas'][0]['corpBillid']))
  1214. {
  1215. $g = array('x'=>'0','Description'=>$res['returnDatas'][0]['message']);
  1216. }
  1217. else
  1218. {
  1219. $yd = $this->get_dpex_yd($res['returnDatas'][0]['corpBillid'],$printcode[2]);
  1220. $fp = $this->get_dpex_fp($res['returnDatas'][0]['corpBillid'],$count);
  1221. if($yd != 'c' && $fp != 'c')
  1222. {
  1223. $g = array('x'=>'1','waybillid'=>$res['returnDatas'][0]['corpBillid'],'waybill'=>$res['returnDatas'][0]['trackNumber'],'yd'=>'<a href="'.$yd.'" target="_blank">'.$yd.'</a>','fp'=>'<a href="'.$fp.'" target="_blank">'.$fp.'</a>');
  1224. }
  1225. else
  1226. {
  1227. $g = array('x'=>'0','Description'=>'换取运单失败,请重试');
  1228. }
  1229. }
  1230. echo "<pre>";
  1231. print_r($g);
  1232. }
  1233. public function get_dpex_yd($waybill,$PrintPaper)
  1234. {
  1235. $url = "http://ambcargo.kingtrans.cn/PostInterfaceService?method=printOrderLabel";
  1236. $Clientid = 'LYFZP';
  1237. $Token = 'NGkJSDx3bAxojl1YN232';
  1238. $count = array(
  1239. 'Verify' => array(
  1240. 'Clientid'=>$Clientid,
  1241. 'Token'=>$Token
  1242. ),
  1243. 'CorpBillidDatas'=> array(0=>array('CorpBillid'=>$waybill)),
  1244. 'OrderType'=> "1",//1:快件订单 2:快递制单 3:仓库订单
  1245. 'PrintPaper'=> $PrintPaper,//打印纸张 快递制单只固定为:label 和 A4
  1246. 'PrintContent'=> "1"//打印内容 1:地址标签 2:报关单 3:配货信息 可自由组合用“,”号隔开 如:1,2,3
  1247. );
  1248. $count = json_encode($count,true);
  1249. $ch = curl_init();
  1250. curl_setopt($ch,CURLOPT_URL,$url);
  1251. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  1252. curl_setopt($ch,CURLOPT_HEADER,0);
  1253. curl_setopt($ch,CURLOPT_POST, 1);
  1254. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
  1255. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query(array('json'=>$count)));
  1256. $res = curl_exec($ch);
  1257. curl_close($ch);
  1258. $res = json_decode($res,true);
  1259. if($res['statusCode'] == 'success')
  1260. {
  1261. return $res['url'];
  1262. }
  1263. else
  1264. {
  1265. return 'c';
  1266. }
  1267. }
  1268. public function get_dpex_fp($waybill)
  1269. {
  1270. $url = "http://ambcargo.kingtrans.cn/PostInterfaceService?method=printOrderInvoice";
  1271. $Clientid = 'LYFZP';
  1272. $Token = 'NGkJSDx3bAxojl1YN232';
  1273. $count = array(
  1274. 'Verify' => array(
  1275. 'Clientid'=>$Clientid,
  1276. 'Token'=>$Token
  1277. ),
  1278. 'CorpBillidDatas'=> array(0=>array('CorpBillid'=>$waybill))
  1279. );
  1280. $count = json_encode($count,true);
  1281. $ch = curl_init();
  1282. curl_setopt($ch,CURLOPT_URL,$url);
  1283. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  1284. curl_setopt($ch,CURLOPT_HEADER,0);
  1285. curl_setopt($ch,CURLOPT_POST, 1);
  1286. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
  1287. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query(array('json'=>$count)));
  1288. $res = curl_exec($ch);
  1289. curl_close($ch);
  1290. $res = json_decode($res,true);
  1291. if($res['statusCode'] == 'success')
  1292. {
  1293. return $res['url'];
  1294. }
  1295. else
  1296. {
  1297. return 'c';
  1298. }
  1299. }
  1300. public function _feite($waybill)//飞特提取内容下载
  1301. {
  1302. $a = '{"data":{"items":[{"orderId":"F370142205310002","traceId":"1Z88F19Y0396934797","remark":"LY-Supernova-0531-FBA16QRN39JPU-4","importTime":"2022-05-31 15:57:25","sentTime":"2022-06-02 22:40:19","iossNumber":null,"ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F370142205300001","traceId":"1Z287F0E6705824870","remark":"LY-AP-2022053009-FBA16QQ0TC4N","importTime":"2022-05-30 15:45:42","sentTime":"2022-05-31 19:10:01","iossNumber":null,"ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F370142205270006","traceId":"1Z88F19Y0303244340","remark":"LY-WK- 2022052701-FBA16QJXYP99","importTime":"2022-05-27 15:24:16","sentTime":"2022-05-30 15:40:40","iossNumber":"","ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F370142205270005","traceId":"1Z88F19Y0302468708","remark":"LY-SN-2022052701","importTime":"2022-05-27 15:23:16","sentTime":"2022-05-30 15:40:40","iossNumber":"","ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F370142205270001","traceId":"1Z88F19Y0301362654","remark":"LY-Wiggins-2022052705-FBA16QJHKJ5R","importTime":"2022-05-27 11:58:23","sentTime":"2022-05-30 15:40:40","iossNumber":"","ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F370142205120001","traceId":"1Z88F19Y0312674270","remark":"LY-H-2022051203-FBA16PSVQ9YF","importTime":"2022-05-12 09:51:55","sentTime":"2022-05-13 15:40:37","iossNumber":"","ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F37014220511000A","traceId":"1Z88F19Y0315997229","remark":"LY-Wiggins-2022051105-FBA16PRXMZ5L","importTime":"2022-05-11 15:01:31","sentTime":"2022-05-13 15:40:37","iossNumber":"","ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F37014220510000M","traceId":"1Z88F19Y0399360286","remark":"LY-XCLY-20220510-024-FBA00001","importTime":"2022-05-10 14:55:18","sentTime":"2022-05-10 20:19:19","iossNumber":"","ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F37014220510000J","traceId":"1Z88F19Y0397487868","remark":"LY-WK-2022050703-","importTime":"2022-05-10 12:22:22","sentTime":"2022-05-10 12:52:17","iossNumber":"","ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F37014220510000I","traceId":"1Z88F19Y0395774837","remark":"LY-Wiggins-2022050703-","importTime":"2022-05-10 12:22:23","sentTime":"2022-05-10 12:52:17","iossNumber":null,"ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F37014220510000H","traceId":"1Z88F19Y0397543547","remark":"LY-AP-22050711-","importTime":"2022-05-10 12:22:19","sentTime":"2022-05-10 12:52:17","iossNumber":"","ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F370142205090002","traceId":"1Z88F19Y0397647720","remark":"LY-YMS-22050901-FBA16PNXD0GM","importTime":"2022-05-09 09:56:49","sentTime":"2022-05-09 16:54:15","iossNumber":"","ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F370142205090001","traceId":"1Z88F19Y0397194737","remark":"LY-AS-22050902-FBA16PNSGL89","importTime":"2022-05-09 08:39:18","sentTime":"2022-05-09 16:54:15","iossNumber":"","ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F370142205080005","traceId":"1Z88F19Y0399894754","remark":"LY-YMS-22050805","importTime":"2022-05-08 12:19:57","sentTime":"2022-05-09 16:54:15","iossNumber":"","ptName":"FBA-美洲专线(郑州)","countryName":"美国"},{"orderId":"F37014220427000I","traceId":"272474117028","remark":"SUPER-20426-004","importTime":"2022-04-27 16:01:08","sentTime":"2022-04-28 18:39:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F37014220427000H","traceId":"272474116466","remark":"QQS-20426-052","importTime":"2022-04-27 15:59:38","sentTime":"2022-04-28 18:39:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F37014220427000G","traceId":"272474117109","remark":"QQS-20426-001","importTime":"2022-04-27 15:59:34","sentTime":"2022-04-28 18:39:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F37014220427000F","traceId":"272474116352","remark":"QQS-20425-102","importTime":"2022-04-27 15:59:29","sentTime":"2022-04-28 18:39:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"荷兰"},{"orderId":"F37014220427000D","traceId":"272474117337","remark":"Y-20426-058","importTime":"2022-04-27 14:07:57","sentTime":"2022-04-28 00:19:50","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"德国"},{"orderId":"F37014220427000B","traceId":"272474117017","remark":"KISS-20426-021","importTime":"2022-04-27 14:07:50","sentTime":"2022-04-28 00:19:50","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"芬兰"},{"orderId":"F37014220427000A","traceId":"272474116341","remark":"ALIP-20423-217","importTime":"2022-04-27 14:07:36","sentTime":"2022-04-28 18:39:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"德国"},{"orderId":"F370142204270009","traceId":"272474117532","remark":"Y-20427-011","importTime":"2022-04-27 14:03:31","sentTime":"2022-04-28 00:19:50","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"葡萄牙"},{"orderId":"F370142204270008","traceId":"272474116569","remark":"AAP-20426-030","importTime":"2022-04-27 14:03:20","sentTime":"2022-04-28 00:19:50","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"荷兰"},{"orderId":"F370142204270004","traceId":"272467942761","remark":"ALIP-20425-072","importTime":"2022-04-27 11:10:19","sentTime":"2022-04-28 00:19:50","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F370142204270003","traceId":"272467945153","remark":"ALIP-20426-015","importTime":"2022-04-27 10:13:06","sentTime":"2022-04-28 18:39:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"瑞典"},{"orderId":"F370142204270002","traceId":"272467947649","remark":"KISS-20425-019","importTime":"2022-04-27 10:13:03","sentTime":"2022-04-28 18:39:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F370142204270001","traceId":"272467946860","remark":"AAP-20425-002","importTime":"2022-04-27 10:12:51","sentTime":"2022-04-28 00:19:50","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F370142204260009","traceId":"272419119163","remark":"KISS-20423-033","importTime":"2022-04-26 14:17:33","sentTime":"2022-04-28 18:39:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"荷兰"},{"orderId":"F370142204260008","traceId":"272419119185","remark":"Y-20426-006","importTime":"2022-04-26 13:12:56","sentTime":"2022-04-28 18:39:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F370142204260007","traceId":"272419119060","remark":"ALIP-20425-067","importTime":"2022-04-26 13:12:48","sentTime":"2022-04-26 23:54:20","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F370142204260006","traceId":"272419118970","remark":"KISS-20425-023","importTime":"2022-04-26 13:12:39","sentTime":"2022-04-26 23:54:20","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F370142204260005","traceId":"272467947351","remark":"ALIP-20424-090","importTime":"2022-04-26 13:12:30","sentTime":"2022-04-28 00:19:50","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"丹麦"},{"orderId":"F370142204260004","traceId":"272419118671","remark":"ALIP-20424-074","importTime":"2022-04-26 13:12:22","sentTime":"2022-04-26 23:54:20","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"爱尔兰"},{"orderId":"F370142204260003","traceId":"272419119233","remark":"ALIP-20423-157","importTime":"2022-04-26 13:12:13","sentTime":"2022-04-26 23:54:20","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F370142204260002","traceId":"272419118248","remark":"AAP-20425-016","importTime":"2022-04-26 13:12:05","sentTime":"2022-04-26 23:54:20","iossNumber":"IM5280002556","ptName":"中速FEDEX","countryName":"荷兰"},{"orderId":"F370142204260001","traceId":"272419118947","remark":"AAP-20425-023","importTime":"2022-04-26 10:59:31","sentTime":"2022-04-26 23:54:20","iossNumber":"FR76880693544","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F37014220425000H","traceId":"272362120808","remark":"KISS-20423-063","importTime":"2022-04-25 14:12:43","sentTime":"2022-04-28 18:39:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"荷兰"},{"orderId":"F37014220425000G","traceId":"272362120896","remark":"ALIP-20423-111","importTime":"2022-04-25 14:12:39","sentTime":"2022-04-25 21:38:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"荷兰"},{"orderId":"F37014220425000F","traceId":"272362120234","remark":"KISS-20422-051","importTime":"2022-04-25 14:12:34","sentTime":"2022-04-25 21:38:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F37014220425000E","traceId":"272362120040","remark":"KISS-20417-041","importTime":"2022-04-25 14:12:27","sentTime":"2022-04-28 18:39:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"爱尔兰"},{"orderId":"F37014220425000D","traceId":"272362119918","remark":"AAP-20424-006","importTime":"2022-04-25 14:12:22","sentTime":"2022-04-26 23:54:20","iossNumber":"IM5280002556","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F37014220425000C","traceId":"272362121285","remark":"Y-20423-049","importTime":"2022-04-25 11:54:54","sentTime":"2022-04-25 21:38:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F37014220425000B","traceId":"272362120223","remark":"ALIP-20419-117","importTime":"2022-04-25 11:48:14","sentTime":"2022-04-26 23:54:20","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F37014220425000A","traceId":"272362119540","remark":"ALIP-20422-137","importTime":"2022-04-25 11:42:36","sentTime":"2022-04-25 21:38:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"德国"},{"orderId":"F370142204250009","traceId":"272362119653","remark":"ALIP-20423-100","importTime":"2022-04-25 11:42:23","sentTime":"2022-04-25 21:38:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F370142204250008","traceId":"272362120061","remark":"ALIP-20422-191","importTime":"2022-04-25 11:42:20","sentTime":"2022-04-25 21:38:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"德国"},{"orderId":"F370142204250006","traceId":"272362120495","remark":"AAP-20424-016","importTime":"2022-04-25 11:19:23","sentTime":"2022-04-25 21:38:11","iossNumber":"IM5280002556","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F370142204250005","traceId":"272362119355","remark":"AAP-20424-025","importTime":"2022-04-25 11:02:10","sentTime":"2022-04-25 21:38:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"瑞典"},{"orderId":"F370142204250004","traceId":"272362120407","remark":"AAP-20423-017","importTime":"2022-04-25 10:55:58","sentTime":"2022-04-25 21:38:11","iossNumber":"IM5280002556","ptName":"中速FEDEX","countryName":"荷兰"},{"orderId":"F370142204250003","traceId":"272362120392","remark":"AAP-20423-006","importTime":"2022-04-25 10:55:42","sentTime":"2022-04-25 21:38:11","iossNumber":"IM5280002556","ptName":"中速FEDEX","countryName":"法国"},{"orderId":"F370142204250002","traceId":"272362121171","remark":"Y-20423-003","importTime":"2022-04-25 09:21:30","sentTime":"2022-04-25 21:38:11","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"}],"pageInfo":{"pageIndex":1,"pageSize":1000,"totalCount":51,"totalPage":1}},"status":1,"msg":"","datas":null,"errCode":0}';
  1303. //发货页面当前页数量拉满
  1304. //格式:{"data":{"items":[{"orderId":"F37014220102000D","traceId":"288335360044","remark":"ALIP-11230-109","importTime":"2022-01-02 13:48:27","sentTime":"2022-01-05 07:57:00","iossNumber":"IM3800007691","ptName":"中速FEDEX","countryName":"法国"}],"pageInfo":{"pageIndex":1,"pageSize":1000,"totalCount":563,"totalPage":1}},"status":1,"msg":"","datas":null,"errCode":0}
  1305. $a = json_decode($a,true);$b = array();
  1306. foreach ($a['data']['items'] as $v)
  1307. {
  1308. //if($v['iossNumber'] == 'IM3800007691')
  1309. //{
  1310. $b[] = $v;
  1311. //}
  1312. }
  1313. $title = "飞特";
  1314. $titlename = "<table border=1>
  1315. <tr>
  1316. <td>订单号</td>
  1317. <td>跟踪号</td>
  1318. <td>编号</td>
  1319. <td>导入时间</td>
  1320. <td>发货时间</td>
  1321. <td>IOSS</td>
  1322. <td>快递方式</td>
  1323. <td>国家</td>
  1324. </table>";
  1325. $filename = $title.".xls";
  1326. $tail = "\n";
  1327. $this->excel->get_fz2($b,$titlename,$filename,$tail);
  1328. }
  1329. public function _rl($arg_array)
  1330. {
  1331. $t = (1646064000-1635696000)/(24*3600);
  1332. $list = array();
  1333. for($i=0;$i<$t;$i++)
  1334. {
  1335. $time = ($i>0)?1635696000+($i*24*3600):1646064000;
  1336. $time = date('Ymd',$time);
  1337. $d = $this->fullorder->find_all("returndata like '%$time%'",'number,returndata,js,zzl');
  1338. foreach ($d as $v)
  1339. {
  1340. $list[] = $v;
  1341. }
  1342. $s = $this->fullordersmt->find_all("returndata like '%$time%'",'number,returndata,js,zzl');
  1343. foreach ($s as $v)
  1344. {
  1345. $list[] = $v;
  1346. }
  1347. }
  1348. $data = array();
  1349. foreach ($list as $k=>$v)
  1350. {
  1351. $js = ($v['js'] == '0')?'FIRST CLASS':'PRIORITY';
  1352. $return = explode('/t-',$v['returndata']);
  1353. $time = explode('/pdf/',$return[0]);
  1354. $time = strtotime($time[1]);
  1355. $return = explode('.pdf"',$return[1]);
  1356. $data[] = array($v['number'],$return[0],$js,$v['zzl'],date('Y-m-d',$time));
  1357. }
  1358. $title = 'return';
  1359. $titlename = "<table border=1>
  1360. <tr>
  1361. <td>编号</td>
  1362. <td>return label 运单号</td>
  1363. <td>服务类型</td>
  1364. <td>重量</td>
  1365. <td>return label 时间</td>
  1366. </tr>
  1367. </table>";
  1368. $filename = $title.".xls";
  1369. $tail = "\n";
  1370. $this->excel->get_fz2($data,$titlename,$filename,$tail);
  1371. echo "<pre>";
  1372. print_r($data);
  1373. }
  1374. public function _cz($arg_array)
  1375. {
  1376. $f = 'fullorder';
  1377. $d = $this->fullorder->get_number($arg_array[0]);
  1378. if(!$d)
  1379. {
  1380. $f = 'fullordersmt';
  1381. $d = $this->fullordersmt->get_number($arg_array[0]);
  1382. if(!$d)
  1383. {
  1384. $f = 'fullordertt';
  1385. $d = $this->fullordertt->get_number($arg_array[0]);
  1386. }
  1387. }
  1388. if(!$d)
  1389. {
  1390. echo '找不到此编号';exit;
  1391. }
  1392. $cz = 'reset';
  1393. $c = $this->$cz->find_all("number = '".$arg_array[0]."'",'*','id desc');
  1394. if(!$c)
  1395. {
  1396. echo '找不到此编号';exit;
  1397. }
  1398. $c = $c[0];
  1399. if($c['printtime'] != '无' && $c['librarytime'] != '无')
  1400. {
  1401. $this->$f->save(array('printtime'=>strtotime($c['printtime']),'print'=>3,'printnumber'=>1,'librarytime'=>strtotime($c['librarytime']),'library'=>2,'reviewtime'=>strtotime($c['reviewtime']),'review'=>6),$d['id']);
  1402. }
  1403. else if($c['printtime'] != '无' && $c['librarytime'] == '无')
  1404. {
  1405. $this->$f->save(array('printtime'=>strtotime($c['printtime']),'print'=>3,'printnumber'=>1,'reviewtime'=>strtotime($c['reviewtime']),'review'=>6),$d['id']);
  1406. }
  1407. else if($c['printtime'] == '无' && $c['librarytime'] == '无' && $c['reviewtime'] != '无')
  1408. {
  1409. $this->$f->save(array('reviewtime'=>strtotime($c['reviewtime']),'review'=>6),$d['id']);
  1410. }
  1411. else
  1412. {
  1413. echo '没有可恢复的状态';exit;
  1414. }
  1415. }
  1416. public function _paypal($arg_array)//paypal用 返回头部数据
  1417. {
  1418. $f = $this->fullorder->get_number($arg_array[0]);
  1419. $s = $this->shop->read($f['shop']);
  1420. $client_id = $s['paypalname'];
  1421. $secret_id = $s['paypalpass'];
  1422. $url = 'https://api-m.paypal.com/v1/reporting/transactions?start_date='.date('Y-m-d',time()-26*24*3600).'T00:00:00-0700&end_date='.date('Y-m-d',time()+24*3600).'T23:59:59-0700&transaction_id='.$f['paypal'].'&fields=all&page_size=100&page=1';
  1423. $ToState = array('alabama'=>'AL','alaska'=>'AK','arizona'=>'AZ','arkansas'=>'AR','california'=>'CA','colorado'=>'CO','connecticut'=>'CT','delaware'=>'DE','florida'=>'FL','georgia'=>'GA','hawaii'=>'HI','idaho'=>'ID','illinois'=>'IL','indiana'=>'IN','iowa'=>'IA','kansas'=>'KS','kentucky'=>'KY','louisiana'=>'LA','maine'=>'ME','maryland'=>'MD','massachusetts'=>'MA','michigan'=>'MI','minnesota'=>'MN','mississippi'=>'MS','missouri'=>'MO','montana'=>'MT','nebraska'=>'NE','nevada'=>'NV','new hampshire'=>'NH','new jersey'=>'NJ','new mexico'=>'NM','new york'=>'NY','north carolina'=>'NC','north dakota'=>'ND','ohio'=>'OH','oklahoma'=>'OK','oregon'=>'OR','pennsylvania'=>'PA','rhode island'=>'RI','south carolina'=>'SC','south dakota'=>'SD','tennessee'=>'TN','texas'=>'TX','utah'=>'UT','vermont'=>'VT','virginia'=>'VA','washington'=>'WA','west virginia'=>'WV','wisconsin'=>'WI','wyoming'=>'WY','district of columbia'=>'DC','virgin islands'=>'VI','guam'=>'GU');
  1424. $ToState = array_flip($ToState);
  1425. $header[] = "Content-Type: application/json";
  1426. $header[] = "Authorization: Basic ".base64_encode($client_id.":".$secret_id);
  1427. $ch = curl_init();
  1428. curl_setopt($ch, CURLOPT_HTTPGET, true);
  1429. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //TRUE 将curl_exec()获取的信息以字符串返回,而不是直接输出。
  1430. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  1431. curl_setopt($ch, CURLOPT_HEADER, true); //返回response头部信息
  1432. curl_setopt($ch, CURLINFO_HEADER_OUT, true);
  1433. curl_setopt($ch, CURLOPT_URL, $url);
  1434. $result = curl_exec($ch);
  1435. curl_getinfo($ch, CURLINFO_HEADER_OUT);
  1436. curl_close($ch);
  1437. echo "<pre>";
  1438. echo $result;exit;
  1439. }
  1440. public function _yd($arg_array)
  1441. {
  1442. $fullorder = $this->fullorder->get_number($arg_array[0]);
  1443. if(!$fullorder)
  1444. {
  1445. $fullorder = $this->fullordersmt->get_number($arg_array[0]);
  1446. }
  1447. if(!$fullorder)
  1448. {
  1449. echo "编号错误";exit;
  1450. }
  1451. /** 发票地址信息暂时无用
  1452. $fullorder['baddress'] = explode(',',$fullorder['baddress']);
  1453. $fullorder['baddress'] = array_reverse($fullorder['baddress']);
  1454. $fullorder['baddress'][1] = $country['ename'];
  1455. **/
  1456. //获取所用相关信息
  1457. $warehouse = $this->warehouse->read($fullorder['type']);
  1458. $country = $this->country->read($fullorder['country']);//订单国家信息
  1459. $fcountry = $this->country->read($warehouse['country']);//仓库国家信息
  1460. $warehouse['country'] = $fcountry['ename'];//仓库国家名
  1461. $warehouse['lb'] = $fcountry['lb'];//仓库国家编码
  1462. $fullorder['warehouse'] = $warehouse;//仓库数据加入订单
  1463. $fullorder['lb'] = $country['lb'];//订单国家编码加入
  1464. $fullorder['country'] = $country['ename'];//订单国家名
  1465. $fullorder['zhou'] = $country['continent'];//所属州
  1466. $express = $this->express->read($fullorder['express']);
  1467. $fullorder['express'] = $express['servicename'];
  1468. $fullorder['account'] = $express['account'];
  1469. $fullorder['printcode'] = $express['printcode'];
  1470. $fullorder['time'] = date('Y-m-d',time());
  1471. $fullorder['times'] = date('Y-m-d H:i',time());
  1472. $fullorder['sbbm']= ($fullorder['sbpm'] == 'Hair Sample') ? 67042000 : 67041100;
  1473. $fullorder['address'] = str_replace(array('&'),array('&#38;'),$fullorder['address']);
  1474. $fullorder['address2'] = str_replace(array('&'),array('&#38;'),$fullorder['address2']);
  1475. $fullorder['shipremarks'] = str_replace(array('&lt;','&gt;'),array('<','>'),$fullorder['shipremarks']);
  1476. $fullorder['shipremarks'] = str_replace(array('<','>',';',';'),array('&lt','&gt',';<br>',';<br>'),$fullorder['shipremarks']);
  1477. $shop = $this->shop->read($fullorder['shop']);
  1478. $fullorder['shop'] = $shop['shopname'];
  1479. $fullorder['city'] = preg_replace('/( | | |\s)/',' ',$fullorder['city']);
  1480. $fullorder['province'] = preg_replace('/( | | |\s)/',' ',$fullorder['province']);
  1481. if(is_numeric($fullorder['pay']))
  1482. {
  1483. $pay = $this->typeclass->read($fullorder['pay']);
  1484. if($pay['classid'] == '4')
  1485. {
  1486. $fullorder['pay'] = $pay['title'];
  1487. }
  1488. }
  1489. if($fullorder['printcode'] != "USPS")
  1490. {
  1491. $fullorder['client'] = htmlspecialchars($fullorder['client']);
  1492. $fullorder['name'] = htmlspecialchars($fullorder['name']);
  1493. }
  1494. //增加退货单所需信息
  1495. $pt = '';
  1496. $fpdata = explode(';',trim($fullorder['fpdata'],';'));
  1497. foreach ($fpdata as $v)
  1498. {
  1499. $p = explode('|',trim($v,'|'));
  1500. $pt .= '<p>'.$p[1].' * '.$p[2].'</p>';
  1501. }
  1502. $fullorder['pt'] = $pt;
  1503. //$fullorder['printcode'] = 'HUALEIXW-FEDEX';
  1504. //$fullorder['sbbm']= ($fullorder['sbpm'] == 'Hair Sample') ? 67042000 : 67041100;
  1505. //$fullorder['sbbm']= 4202320000;//($fullorder['sbpm'] == 'Hair Sample') ? 67042000 : 67041100;
  1506. //$fullorder['sbpm']= 'eyelashes';
  1507. //$fullorder['zwpm']= '假睫毛';
  1508. //$fullorder['sbpm']= 'Satin Bag';
  1509. //$fullorder['zwpm']= '袋子';
  1510. //$fullorder['hgbm']= 4202320000;
  1511. //$fullorder['address'] = '1653 Treutlan Place';
  1512. //$fullorder['address2'] = '';
  1513. //$fullorder['qm'] = 2;
  1514. //$notice = $this->notice->read(6);
  1515. //$fcountry['warehouse']['name'] = 'Hair Me Please LLC';
  1516. //$fullorder['cxcode'] = strtolower($express['cxcode']);
  1517. //$barcode = $this->fedex->get_logistics($fullorder);//获取联邦快递信息
  1518. //echo $fullorder['name'];
  1519. //$b = $this->ups->get_data($fullorder);
  1520. $barcode = $this->get_data($fullorder);
  1521. //$b = $this->usps->get_logistics($fullorder);
  1522. echo "<pre>";
  1523. print_r($barcode);
  1524. //echo "<pre>";
  1525. //echo $barcode['Postage'];
  1526. //$b = $this->_pdf($barcode['yd'],$barcode['waybill'],time());
  1527. //header("Content-type: text/xml");
  1528. //echo $barcode;
  1529. //echo $Hyd;
  1530. //echo "<pre>";
  1531. //print_r($barcode);
  1532. //print_r($barcode);
  1533. /**
  1534. $time = '1586232000';
  1535. $bctime = date('Ymd',$time);
  1536. $Hwaybill = $barcode['waybill'];
  1537. $Hyd = $this->_pdf($barcode['label'],'y-'.$Hwaybill,$bctime);
  1538. $Hfp = $this->_pdf($barcode['invoice'],'f-'.$Hwaybill,$bctime);
  1539. //header("Content-type:text/xml");
  1540. echo 'data/pdf/'.$bctime.'/y-'.$Hwaybill.'.pdf';
  1541. //echo "<pre>";
  1542. //print_r($barcode);
  1543. //$a = $this->whlabel->find_all(array('zd'=>'ASTE-00212-025'));//专属
  1544. **/
  1545. }
  1546. public function get_data($data)
  1547. {
  1548. if($data['pay'] == 1)
  1549. {
  1550. $data['pay'] == 'PayPal';
  1551. }
  1552. else if($data['pay'] == 2)
  1553. {
  1554. $data['pay'] == 'Western Union';
  1555. }
  1556. else if($data['pay'] == 3)
  1557. {
  1558. $data['pay'] == '微信';
  1559. }
  1560. else if($data['pay'] == 4)
  1561. {
  1562. $data['pay'] == '支付宝';
  1563. }
  1564. else if($data['pay'] == 5)
  1565. {
  1566. $data['pay'] == '银行转账';
  1567. }
  1568. else if($data['pay'] == 6)
  1569. {
  1570. $data['pay'] == '现金收款';
  1571. }
  1572. else if($data['pay'] == 7)
  1573. {
  1574. $data['pay'] == 'PingPong金融';
  1575. }
  1576. $id = 'XUCHANGLONGY';
  1577. $pass = 'dJ84as3ELr';
  1578. //$sid = '603521441';//官方DHL
  1579. $sid = '605062090';//官方DHL美国
  1580. $xmend = "\n";
  1581. $Pieces = '';
  1582. for($i=0;$i<$data['zjs'];$i++)
  1583. {
  1584. $Pieces .= "<Piece>".$xmend;
  1585. $Pieces .= "<PieceID>".($i+1)."</PieceID>".$xmend;
  1586. $Pieces .= "<PackageType>EE</PackageType>".$xmend;
  1587. $Pieces .= "<Weight>".$data['zzl']."</Weight>".$xmend;
  1588. $Pieces .= "<Width>15</Width>".$xmend;
  1589. $Pieces .= "<Height>3</Height>".$xmend;
  1590. $Pieces .= "<Depth>5</Depth>".$xmend;
  1591. $Pieces .= "</Piece>".$xmend;
  1592. }
  1593. /** 此内容是添加发票信息
  1594. $dataadress = array();$baddress = '';$ba1 = '';$ba2 = '';
  1595. for($i=5;$i<count($data['baddress']);$i++)
  1596. {
  1597. $dataadress[] = $data['baddress'][$i];
  1598. }
  1599. if(count($dataadress) > 1)
  1600. {
  1601. for($i=0;$i<count($dataadress);$i++)
  1602. {
  1603. if($i < 2)
  1604. {
  1605. $ba1 .= $dataadress[$i].',';
  1606. }
  1607. else
  1608. {
  1609. $ba2 .= $dataadress[$i].',';
  1610. }
  1611. }
  1612. $baddress .= "<BillToAddressLine>".rtrim($ba1,',')."</BillToAddressLine>".$xmend;
  1613. $baddress .= "<BillToAddressLine>".rtrim($ba2,',')."</BillToAddressLine>".$xmend;
  1614. }
  1615. else
  1616. {
  1617. for($i=0;$i<count($dataadress);$i++)
  1618. {
  1619. $ba1 .= $dataadress[$i].',';
  1620. }
  1621. $baddress .= "<BillToAddressLine>".rtrim($ba1,',')."</BillToAddressLine>".$xmend;
  1622. }
  1623. **/
  1624. $hgbm = $data['sbbm'];
  1625. if(isset($data['hgbm']))
  1626. {
  1627. if($data['hgbm'] != '')
  1628. {
  1629. $hgbm = $data['hgbm'];
  1630. }
  1631. }
  1632. $xml = "";
  1633. $xml .= "<?xml version='1.0' encoding='UTF-8'?>".$xmend;
  1634. $xml .= "<req:ShipmentRequest xsi:schemaLocation='http://www.dhl.com ship-val-global-req.xsd' schemaVersion='10.0' xmlns:req='http://www.dhl.com' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>".$xmend;
  1635. $xml .= "<Request>".$xmend;
  1636. $xml .= "<ServiceHeader>".$xmend;
  1637. $xml .= "<MessageTime>".date('c')."</MessageTime>".$xmend;
  1638. //$rand = (strlen($data['orderinfo']) < 15)?rand(10000000,99999999):rand(100000,999999);
  1639. //$xml .= "<MessageReference>".time().$data['orderinfo'].$rand."</MessageReference>".$xmend;
  1640. $xml .= "<MessageReference>".time().time().rand(10000000,99999999)."</MessageReference>".$xmend;
  1641. $xml .= "<SiteID>".$id."</SiteID>".$xmend;//DHL账号
  1642. $xml .= "<Password>".$pass."</Password>".$xmend;//DHL密码
  1643. $xml .= "</ServiceHeader>".$xmend;
  1644. $xml .= "<MetaData>".$xmend;
  1645. $xml .= "<SoftwareName>LongYi ERP</SoftwareName>".$xmend;
  1646. $xml .= "<SoftwareVersion>V1.0.0</SoftwareVersion>".$xmend;
  1647. $xml .= "</MetaData>".$xmend;
  1648. $xml .= "</Request>".$xmend;
  1649. $xml .= "<RegionCode>AP</RegionCode>".$xmend;//地区代码
  1650. $xml .= "<LanguageCode>en</LanguageCode>".$xmend;//语言
  1651. ///$xml .= "<PiecesEnabled>Y</PiecesEnabled>".$xmend;
  1652. $xml .= "<Billing>".$xmend;
  1653. $xml .= "<ShipperAccountNumber>".$sid."</ShipperAccountNumber>".$xmend;
  1654. $xml .= "<ShippingPaymentType>S</ShippingPaymentType>".$xmend;
  1655. $xml .= "<BillingAccountNumber>".$sid."</BillingAccountNumber>".$xmend;
  1656. ///$xml .= "<DutyPaymentType>R</DutyPaymentType>".$xmend;//R为收件人付关税 S发件人付关税
  1657. $xml .= "</Billing>".$xmend;
  1658. $xml .= "<Consignee>".$xmend;
  1659. $xml .= "<CompanyName>".$data['name']."</CompanyName>".$xmend;//收货人名称
  1660. /**
  1661. if(strlen($data['address'].$data['address2']) > 44)
  1662. {
  1663. $adl = $data['address'].$data['address2'];
  1664. $adl1 = substr($adl,0,44);//截取44字符前内容
  1665. $adlnum = strripos($adl1," ");//查找最后一次出现空格位置
  1666. $adl1 = substr($adl,0,$adlnum);//0到空格前之间的内容
  1667. $adl2 = substr($adl,$adlnum+1,strlen($adl));//空格后到最后的内容
  1668. $xml .= "<AddressLine1>".$adl1."</AddressLine1>".$xmend;//收货人地址1
  1669. $xml .= "<AddressLine2>".$adl2."</AddressLine2>".$xmend;//收货人地址2
  1670. }
  1671. **/
  1672. if($data['address2'])
  1673. {
  1674. //$adl = $data['address'].$data['address2'];
  1675. //$adl1 = substr($adl,0,44);//截取44字符前内容
  1676. //$adlnum = strripos($adl1," ");//查找最后一次出现空格位置
  1677. //$adl1 = substr($adl,0,$adlnum);//0到空格前之间的内容
  1678. //$adl2 = substr($adl,$adlnum+1,strlen($adl));//空格后到最后的内容
  1679. $xml .= "<AddressLine1>".$data['address']."</AddressLine1>".$xmend;//收货人地址1
  1680. $xml .= "<AddressLine2>".$data['address2']."</AddressLine2>".$xmend;//收货人地址2
  1681. }
  1682. else
  1683. {
  1684. $xml .= "<AddressLine1>".$data['address'].$data['address2']."</AddressLine1>".$xmend;//收货人地址
  1685. }
  1686. if($data['street'] != '')
  1687. {
  1688. $xml .= "<AddressLine>".$data['street']."</AddressLine>".$xmend;//收货人街道
  1689. }
  1690. $xml .= "<City>".$data['city']."</City>".$xmend;//城市
  1691. if($data['lb'] == 'US')
  1692. {
  1693. $xml .= "<DivisionCode>".$data['province']."</DivisionCode>".$xmend;//州代码,仅美国
  1694. }
  1695. $xml .= "<PostalCode>".trim($data['zipcode'],' ')."</PostalCode>".$xmend;//邮编
  1696. $xml .= "<CountryCode>".$data['lb']."</CountryCode>".$xmend;//国家代码
  1697. $xml .= "<CountryName>".$data['country']."</CountryName>".$xmend;//国家名称
  1698. $xml .= "<Contact>".$xmend;
  1699. $xml .= "<PersonName>".$data['client']."</PersonName>".$xmend;//名称
  1700. $xml .= "<PhoneNumber>".preg_replace('/\D/s','',$data['phone'])."</PhoneNumber>".$xmend;//联系方式
  1701. //$xml .= "<Email>".$data['email']."</Email>".$xmend;//联系邮箱
  1702. $xml .= "</Contact>".$xmend;
  1703. $xml .= "</Consignee>".$xmend;
  1704. $xml .= "<Commodity>".$xmend;//多商品循环此外层标签及内层标签
  1705. $xml .= "<CommodityCode>".$hgbm."</CommodityCode>".$xmend;//商品编码
  1706. $xml .= "<CommodityName>".$data['sbpm']."</CommodityName>".$xmend;//商品名称
  1707. $xml .= "</Commodity>".$xmend;
  1708. $xml .= "<Dutiable>".$xmend;
  1709. $xml .= "<DeclaredValue>".$data['zsbjz']."</DeclaredValue>".$xmend;//申报价值
  1710. $xml .= "<DeclaredCurrency>".$data['currencytitle']."</DeclaredCurrency>".$xmend;//货币代码
  1711. $xml .= "<TermsOfTrade>DAP</TermsOfTrade>".$xmend;//贸易条款
  1712. $xml .= "</Dutiable>".$xmend;
  1713. /** 发票信息开始 **/
  1714. $xml .= "<UseDHLInvoice>Y</UseDHLInvoice>".$xmend;
  1715. $xml .= "<DHLInvoiceLanguageCode>en</DHLInvoiceLanguageCode>".$xmend;
  1716. $xml .= "<DHLInvoiceType>CMI</DHLInvoiceType>".$xmend;
  1717. $xml .= "<ExportDeclaration>".$xmend;
  1718. $xml .= "<ExportReasonCode>P</ExportReasonCode>".$xmend;
  1719. if(strlen($data['paypal']) > 30)
  1720. {
  1721. $xml .= "<InvoiceNumber>".str_replace(array('-'),array(''),$data['paypal'])."</InvoiceNumber>".$xmend;
  1722. }
  1723. else
  1724. {
  1725. $xml .= "<InvoiceNumber>".$data['paypal'].' '.$data['pay']."</InvoiceNumber>".$xmend;
  1726. }
  1727. $xml .= "<InvoiceDate>".date('Y-m-d',time())."</InvoiceDate>".$xmend;
  1728. /**
  1729. $xml .= "<BillToContactName>".$data['client']."</BillToContactName>".$xmend;
  1730. $xml .= "<BillToContanctName>".$data['client']."</BillToContanctName>".$xmend;//账单名称
  1731. $xml .= "<BillToAddressLine1><BillToAddressLine1>";//地址1
  1732. $xml .= "<BillToAddressLine2><BillToAddressLine2>";//地址2
  1733. $xml .= "<BillToCity>".$data['baddress'][4]."</BillToCity>".$xmend;//城市
  1734. $xml .= "<BillToPostcode>".$data['baddress'][2]."</BillToPostcode>".$xmend;//邮编
  1735. $xml .= "<BillToSuburb/>".$xmend;//所在郊区
  1736. if($data['baddress'][1] == 'United States')
  1737. {
  1738. $xml .= "<BillToState>".$data['baddress'][3]."</BillToState>".$xmend;//省、州
  1739. }
  1740. $xml .= "<BillToCountryName>".$data['baddress'][1]."</BillToCountryName>".$xmend;//国家
  1741. $xml .= "<BillToPhoneNumber>".preg_replace('/\D/s','',$data['baddress'][0])."</BillToPhoneNumber>".$xmend;//号码
  1742. **/
  1743. $xml .= "<ExportLineItem>".$xmend;
  1744. $xml .= "<LineNumber>1</LineNumber>".$xmend;//顺序号
  1745. $xml .= "<Quantity>".$data['ts']."</Quantity>".$xmend;//数量
  1746. $xml .= "<QuantityUnit>PCS</QuantityUnit>".$xmend;//单位
  1747. $xml .= "<Description>".$data['sbpm']."</Description>".$xmend;//品名
  1748. $xml .= "<Value>".$data['dtsbjz']."</Value>".$xmend;//单价
  1749. $xml .= "<IsDomestic>Y</IsDomestic>".$xmend;//是否国产,Y本国,N国外
  1750. $xml .= "<CommodityCode>".$hgbm."</CommodityCode>".$xmend;//品名编码
  1751. $xml .= "<Weight>".$xmend;
  1752. $xml .= "<Weight>".$data['zzl']."</Weight>".$xmend;//净重
  1753. $xml .= "<WeightUnit>K</WeightUnit>".$xmend;//重量单位,K千克
  1754. $xml .= "</Weight>".$xmend;
  1755. $xml .= "<GrossWeight>".$xmend;
  1756. $xml .= "<Weight>".$data['zzl']."</Weight>".$xmend;//毛重
  1757. $xml .= "<WeightUnit>K</WeightUnit>".$xmend;//毛重单位,K千克
  1758. $xml .= "</GrossWeight>".$xmend;
  1759. $xml .= "<ManufactureCountryCode>CN</ManufactureCountryCode>".$xmend;//原产国国家代码
  1760. $xml .= "<ManufactureCountryName>CHINA</ManufactureCountryName>".$xmend;//原产国名称
  1761. $xml .= "</ExportLineItem>".$xmend;
  1762. $xml .= "<PlaceOfIncoterm>PEK PORT</PlaceOfIncoterm>".$xmend;//适用港口
  1763. $xml .= "</ExportDeclaration>".$xmend;
  1764. /** 发票信息结束 **/
  1765. $xml .= "<Reference>".$xmend;
  1766. $xml .= "<ReferenceID>".$data['number']."</ReferenceID>".$xmend;
  1767. $xml .= "</Reference>".$xmend;
  1768. $xml .= "<ShipmentDetails>".$xmend;
  1769. ///$xml .= "<NumberOfPieces>".$data['zjs']."</NumberOfPieces>".$xmend;
  1770. $xml .= "<Pieces>".$xmend;
  1771. $xml .= $Pieces;
  1772. $xml .= "</Pieces>".$xmend;
  1773. ///$xml .= "<Weight>".$data['zzl']."</Weight>".$xmend;
  1774. $xml .= "<WeightUnit>K</WeightUnit>".$xmend;
  1775. $xml .= "<GlobalProductCode>P</GlobalProductCode>".$xmend;
  1776. $xml .= "<LocalProductCode>P</LocalProductCode>".$xmend;
  1777. $xml .= "<Date>".date('Y-m-d',time())."</Date>".$xmend;
  1778. $xml .= "<Contents>".$data['sbpm']."</Contents>".$xmend;//内容
  1779. ///$xml .= "<DoorTo>DD</DoorTo>".$xmend;
  1780. $xml .= "<DimensionUnit>C</DimensionUnit>".$xmend;
  1781. ///$xml .= "<InsuredAmount>".$data['bx']."</InsuredAmount>".$xmend;//保险金额
  1782. $xml .= "<PackageType>EE</PackageType>".$xmend;
  1783. $xml .= "<IsDutiable>Y</IsDutiable>".$xmend;
  1784. $xml .= "<CurrencyCode>".$data['currencytitle']."</CurrencyCode>".$xmend;//货币代码
  1785. $xml .= "</ShipmentDetails>".$xmend;
  1786. $xml .= "<Shipper>".$xmend;
  1787. $xml .= "<ShipperID>".$sid."</ShipperID>".$xmend;
  1788. $xml .= "<CompanyName>LongYing</CompanyName>".$xmend;//发货公司名称
  1789. $xml .= "<AddressLine1>LongYingShiYe, Yinghao Rd.</AddressLine1>".$xmend;//发货地址
  1790. $xml .= "<AddressLine2>Shangji Economic Development Zone</AddressLine2>".$xmend;//发货地址
  1791. $xml .= "<City>".$data['warehouse']['city']."</City>".$xmend;//发货城市
  1792. $xml .= "<PostalCode>".$data['warehouse']['zipcode']."</PostalCode>".$xmend;
  1793. $xml .= "<CountryCode>CN</CountryCode>".$xmend;//发货国家代码
  1794. $xml .= "<CountryName>CHINA</CountryName>".$xmend;//发货国家名称
  1795. $xml .= "<Contact>".$xmend;
  1796. $xml .= '<PersonName>GeMengTi</PersonName>'.$xmend;//发货人 '.$data['warehouse']['company'].'
  1797. $xml .= '<PhoneNumber>15939964739</PhoneNumber>'.$xmend;
  1798. $xml .= "</Contact>".$xmend;
  1799. $xml .= "<RegistrationNumbers>".$xmend;
  1800. $xml .= "<RegistrationNumber>".$xmend;
  1801. $xml .= '<Number>91411002MA3X46XC9K</Number>'.$xmend;
  1802. $xml .= '<NumberTypeCode>VAT</NumberTypeCode>'.$xmend;
  1803. $xml .= '<NumberIssuerCountryCode>CN</NumberIssuerCountryCode>'.$xmend;
  1804. $xml .= "</RegistrationNumber>".$xmend;
  1805. $xml .= "</RegistrationNumbers>".$xmend;
  1806. $xml .= "</Shipper>".$xmend;
  1807. /** 无纸化 PLT 开始 **/
  1808. $xml .= "<SpecialService>".$xmend;
  1809. $xml .= "<SpecialServiceType>WY</SpecialServiceType>".$xmend;
  1810. $xml .= "</SpecialService>".$xmend;
  1811. /** 无纸化 PLT 结束 **/
  1812. if($data['bx'] > 0)
  1813. {
  1814. $xml .= "<SpecialService>".$xmend;
  1815. $xml .= "<SpecialServiceType>II</SpecialServiceType>".$xmend;
  1816. $xml .= "<ChargeValue>".$data['bx']."</ChargeValue>".$xmend;
  1817. $xml .= "<CurrencyCode>USD</CurrencyCode>".$xmend;
  1818. $xml .= "</SpecialService>".$xmend;
  1819. }
  1820. $xml .= "<LabelImageFormat>PDF</LabelImageFormat>".$xmend;
  1821. /** 无纸化 PLT 启用这个 **/
  1822. $xml .= "<RequestArchiveDoc>N</RequestArchiveDoc>".$xmend;
  1823. /** 无纸化 PLT 启用这个 **/
  1824. /** 无纸化 PLT 关闭这个 **/
  1825. //$xml .= "<RequestArchiveDoc>Y</RequestArchiveDoc>".$xmend;
  1826. //$xml .= "<NumberOfArchiveDoc>1</NumberOfArchiveDoc>".$xmend;
  1827. /** 无纸化 PLT 关闭这个 **/
  1828. $xml .= "<Label>".$xmend;
  1829. $xml .= "<HideAccount>N</HideAccount>".$xmend;
  1830. $xml .= "<LabelTemplate>8X4_PDF</LabelTemplate>".$xmend;
  1831. $xml .= "<CustomsInvoiceTemplate>COMMERCIAL_INVOICE_P_10</CustomsInvoiceTemplate>".$xmend;
  1832. $xml .= "<Resolution>200</Resolution>".$xmend;
  1833. $xml .= "</Label>".$xmend;
  1834. $xml .= "</req:ShipmentRequest>".$xmend;
  1835. echo "<pre>";
  1836. echo $xml;
  1837. exit;
  1838. $ch = curl_init();
  1839. curl_setopt($ch, CURLOPT_URL,'https://xml-api.dhl.com/XMLShippingServlet');
  1840. curl_setopt($ch, CURLOPT_POST, 1);
  1841. curl_setopt($ch, CURLOPT_HEADER, 0);
  1842. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  1843. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  1844. curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
  1845. curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
  1846. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  1847. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,15);
  1848. $data = curl_exec($ch);
  1849. curl_close($ch);
  1850. $data = utf8_encode($data);
  1851. libxml_disable_entity_loader(true);
  1852. @$values = json_decode(json_encode(simplexml_load_string($data, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
  1853. }
  1854. public function _xx()
  1855. {
  1856. $shop = $this->shop->read(57);
  1857. if($shop['apitoken_time'] > time())
  1858. {
  1859. $token = $shop['apitoken'];
  1860. }
  1861. else
  1862. {
  1863. $res = $this->shop->hq_token($shop);
  1864. $token = $res;
  1865. }
  1866. $data = '?';
  1867. //$data .= '&searchCriteria[filterGroups][0][filters][0][conditionType]=ConditionType';//字段类型
  1868. $data .= 'searchCriteria[sortOrders][0][field]=created_at';
  1869. $data .= '&searchCriteria[sortOrders][0][direction]=DESC';
  1870. $data .= '&searchCriteria[pageSize]=200';
  1871. $data .= '&searchCriteria[currentPage]=1';
  1872. $data .= '&searchCriteria[filterGroups][0][filters][0][field]=status';//字段名称
  1873. $data .= '&searchCriteria[filterGroups][0][filters][0][value]=processing';//字段内容
  1874. $url = 'https://pc.bilisar.com/rest/V1/orders'.$data;//订单
  1875. $res = $this->su_curl('',$url,$header=array("Authorization: Bearer ".$token,"Content-Type: application/json"),$date_type='json',$timeout=300,$httptype="GET",$userpwd='');
  1876. $res = json_decode($res,true);
  1877. foreach ($res['items'] as $read)
  1878. {
  1879. $productNames = '';//产品名称
  1880. $sku = '';
  1881. $parameters = '';
  1882. $quantity = '';
  1883. $orderid = '';
  1884. $link = '';
  1885. foreach ($read['items'] as $list)
  1886. {
  1887. $productNames .= $list['name'].',';
  1888. $sku .= $list['sku'].',';
  1889. $link .= $list['extension_attributes']['product_url'].',';
  1890. if(isset($list['extension_attributes']['select_options']))
  1891. {
  1892. foreach ($list['extension_attributes']['select_options'] as $s)
  1893. {
  1894. $p = json_decode($s,true);
  1895. $parameters .= $p['label'].':'.$p['value'].'---';
  1896. }
  1897. }
  1898. $parameters = trim($parameters,'---').';';
  1899. $quantity .= $list['qty_ordered'].';';
  1900. $orderid = $list['order_id'];
  1901. }
  1902. $sku = str_replace(array('<','>'),array('&lt;','&gt;'),$sku);
  1903. $bill_street = '';//街道地址
  1904. foreach ($read['billing_address']['street'] as $s)
  1905. {
  1906. $bill_street .= $s.' ';
  1907. }
  1908. $ship_street = '';//街道地址
  1909. foreach ($read['billing_address']['street'] as $s)
  1910. {
  1911. $ship_street .= $s.' ';
  1912. }
  1913. $ly = isset($read['extension_attributes']['osc_order_comment'])?addslashes($read['extension_attributes']['osc_order_comment']):'';//留言
  1914. $thatDayOrder[] = array
  1915. (
  1916. 'orderid' => $orderid,
  1917. 'order_id' => $read['increment_id'],
  1918. 'insurance' => $read['extension_attributes']['amextrafee_base_fee_amount'],//运费险
  1919. 'product_name' => trim($productNames,','),
  1920. 'purchased_on' => $read['created_at'],
  1921. 'name' => (isset($read['customer_firstname'])?$read['customer_firstname']:'').' '.(isset($read['customer_lastname'])?$read['customer_lastname']:''),
  1922. 'bill_to_name' => $read['billing_address']['firstname'].' '.$read['billing_address']['lastname'],
  1923. 'ship_to_name' => $read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['firstname'].' '.$read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['lastname'],
  1924. 'billing_address' => trim($bill_street,' '). ',' .$read['billing_address']['city']. ',' .(isset($read['billing_address']['region'])?$read['billing_address']['region']. ',':'') .$read['billing_address']['postcode']. ',' .$read['billing_address']['country_id']. ',' .$read['billing_address']['telephone'],
  1925. 'shipping_address' => trim($ship_street,' '). ',' . $read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['city']. ',' .(isset($read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['region'])?$read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['region'].',':'').$read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['postcode']. ',' .$read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['country_id']. ',' .$read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['telephone'],
  1926. 'country' => $read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['country_id'],
  1927. 'region' => isset($read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['region'])?$read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['region']:'',
  1928. 'city' => $read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['city'],
  1929. 'street' => $ship_street,
  1930. 'telephone' => $read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['telephone'],
  1931. 'postcode' => $read['extension_attributes']['shipping_assignments']['0']['shipping']['address']['postcode'],
  1932. 'email' =>$read['billing_address']['email'],
  1933. 'global_currency_code' => $read['global_currency_code'],
  1934. 'base_grand_total' => $read['base_grand_total'],
  1935. 'grand_total' => $read['order_currency_code'].$read['grand_total'],
  1936. 'isstatus' => $read['status'],
  1937. 'isparameter' => trim($parameters,';'),
  1938. 'sku' => trim($sku,','),
  1939. 'order_quantity' => trim($quantity,';'),
  1940. 'order_comment' => $ly,
  1941. 'paypal_num' => isset($read['payment']['last_trans_id'])?$read['payment']['last_trans_id']:'',
  1942. 'pay' => $read['payment']['method'],
  1943. 'paypal_protection_eligibility' => isset($read['payment']['additional_information']['9'])?$read['payment']['additional_information']['9']:'',
  1944. 'shippingmethod'=> ($read['base_shipping_amount'] > 0 || $read['tax_amount'] > 0)?$read['shipping_description'].' '.$read['base_shipping_amount'].' Tax:'.$read['tax_amount'].';':$read['shipping_description'].' '.$read['base_shipping_amount'].' Tax:'.$read['tax_amount'],
  1945. 'link'=>trim($link,','),
  1946. 'author_id' => '',
  1947. 'source_content_id' => '',
  1948. );
  1949. }
  1950. echo "<pre>";
  1951. print_r($thatDayOrder);
  1952. exit;
  1953. }
  1954. public function _a()
  1955. {
  1956. $where = "dlz < '1' and state = '207' and (express = '2' or express = '63' or express = '64') and librarytime > '".strtotime(date("Y-m-d 7:00:0",strtotime("-20 day")))."' and librarytime < '".strtotime(date("Y-m-d 7:00:0",time()))."'";
  1957. $fdata = $this->fullorder->find_count($where);
  1958. echo "<pre>";
  1959. echo $fdata;
  1960. //print_r($fdata);
  1961. exit;
  1962. $sid = '';$sd = array();
  1963. if(isset($_SESSION['api']))
  1964. {
  1965. $user = $this->user->get_api($_SESSION['api']);
  1966. $user = explode('|',trim($user['shop'],'|'));
  1967. foreach ($user as $value)
  1968. {
  1969. $sid .= " id = '$value' or";
  1970. }
  1971. $sid = " and (".rtrim($sid,'or').")";
  1972. }
  1973. $post = $this->input->post(NULL, TRUE);
  1974. $api = $this->input->get('api',true);
  1975. $dshop = $this->input->get('dshop',true);
  1976. //@$gethl = $this->hl->get_hl();//获取即时汇率
  1977. $gethl = array();
  1978. /* 订单号加入键值-k */
  1979. /**
  1980. $dataorder = array();
  1981. $fdata = $this->fullorder->find_all('dtime > "'.(time()-96*3600).'"','orderinfo');
  1982. foreach ($fdata as $v)
  1983. {
  1984. $dataorder[$v['orderinfo']] = "";//获取到单号
  1985. }
  1986. **/
  1987. /* 订单号加入键值-j */
  1988. /* 匹配加入 */
  1989. $dictionaries = $this->typeclass->find_all('spare!= "" and classid != 1 and classid != 2 and classid != 3 and classid != 4 and classid != 5 and classid != 11 and classid != 16 and classid != 17 and classid != 20 and classid != 21 and classid != 23 and classid != 24 and classid != 29 and classid != 30 and classid != 31 and classid != 32 and classid != 36');
  1990. // and (classid=13 or classid=22 or classid=8 or classid=15 or classid=27 or classid=25 or classid=26 or classid=18 or classid=14 or classid=9 or classid=12 or classid=10 or classid=6 or classid=100 or classid=999)
  1991. $dtc = array();
  1992. foreach ($dictionaries as $v)
  1993. {
  1994. if(stripos($v['spare'],'|') !== false)//如果有多个值
  1995. {
  1996. $v['spare'] = explode('|',$v['spare']);
  1997. foreach ($v['spare'] as $k=>$vs)
  1998. {
  1999. if(stripos($v['zh'],'|') !== false)
  2000. {
  2001. $vzh = explode('|',$v['zh']);
  2002. $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$vzh[$k],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
  2003. }
  2004. else
  2005. {
  2006. $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
  2007. }
  2008. }
  2009. }
  2010. else
  2011. {
  2012. $dtc[strtolower($v['spare'])] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$v['spare']);
  2013. }
  2014. }
  2015. $dictionaries2 = $this->typeclass->find_all();
  2016. foreach ($dictionaries2 as $v)
  2017. {
  2018. $dtctitle[$v['id']] = $v['title'];
  2019. }
  2020. /* 匹配结束 */
  2021. /* 价格加入 */
  2022. /**
  2023. $money = array();
  2024. $productdescribe = $this->productdescribe->find_all('1=1','number,purchase,cost,salesprice,title');
  2025. foreach ($productdescribe as $v)
  2026. {
  2027. $money[$v['number']] = array('purchase'=>$v['purchase'],'cost'=>$v['cost'],'salesprice'=>$v['salesprice'],'title'=>$v['title']);
  2028. }
  2029. **/
  2030. /* 价格加入 */
  2031. /* 匹配ID加入 */
  2032. $int = array();
  2033. $intdata = $this->typeclass->find_all('classid=14','id,spare');
  2034. foreach ($intdata as $v)
  2035. {
  2036. $v['spare'] = explode('|',$v['spare']);
  2037. $int[$v['id']] = $v['spare'][0];
  2038. }
  2039. /* 匹配ID结束 */
  2040. /* 国家加入键值-k */
  2041. $cuy = array();
  2042. $cuydata = $this->country->find_all('1=1','lb,id');
  2043. foreach ($cuydata as $v)
  2044. {
  2045. $cuy[$v['lb']] = $v['id'];//获取到国家ID
  2046. }
  2047. /* 国家加入键值-j */
  2048. /* 币种加入键值-k */
  2049. $typeclass = array();
  2050. $tdata = $this->typeclass->find_all('classid=30','id,title');
  2051. foreach ($tdata as $v)
  2052. {
  2053. $typeclass[$v['title']] = $v['id'];
  2054. }
  2055. /* 币种加入键值-j */
  2056. /* 支付方式-k */
  2057. $pay = array();
  2058. $tdata = $this->typeclass->find_all('classid=4','id,spare');
  2059. foreach ($tdata as $v)
  2060. {
  2061. $paytype = $this->pay->get_typeclass($v['id']);
  2062. if(isset($paytype['estimaterate']))
  2063. {
  2064. $estimaterate = $paytype['estimaterate'];
  2065. }
  2066. else
  2067. {
  2068. $estimaterate = 0;
  2069. }
  2070. if(stripos($v['spare'],'|') !== false)//如果有多个值
  2071. {
  2072. $v['spare'] = explode('|',$v['spare']);
  2073. foreach ($v['spare'] as $k=>$vs)
  2074. {
  2075. $pay[$vs] = array('id'=>$v['id'],'estimaterate'=>$estimaterate);
  2076. }
  2077. }
  2078. else
  2079. {
  2080. $pay[$v['spare']] = array('id'=>$v['id'],'estimaterate'=>$estimaterate);
  2081. }
  2082. }
  2083. $pay['stripeios'] = $pay['stripe_payments'];
  2084. /* 支付方式-j */
  2085. /* 新增SKU-k */
  2086. $zjsku = array();
  2087. $shopsku = $this->shopsku->find_all();
  2088. foreach ($shopsku as $val)
  2089. {
  2090. $ss = explode(',',trim($val['shop'],','));
  2091. foreach ($ss as $v)
  2092. {
  2093. if(isset($zjsku[$v]))
  2094. {
  2095. $zjsku[$v] .= ','.trim($val['sku'],',');
  2096. }
  2097. else
  2098. {
  2099. $zjsku[$v] = trim($val['sku'],',');
  2100. }
  2101. }
  2102. }
  2103. /* 新增SKU-j */
  2104. $is = $this->is->find_all('1=1','*','number asc');//获取仓库平匹配表
  2105. $value = $this->shop->read(57);
  2106. $setting = $this->setting->get_settings();
  2107. $this->db->trans_begin();
  2108. $res = $this->_xx($value['brandname'],$value['shopadmin'],$value);
  2109. $sd[] = $res;
  2110. $sjc = $setting['sctime'];//时间差 之前是3600 现在为0
  2111. if($res)
  2112. {
  2113. foreach ($res as $v)
  2114. {
  2115. if($value['token'] == 'SU')
  2116. {
  2117. $time = $v['purchased_on']-7*3600-$sjc;//之前是+$sjc
  2118. }
  2119. else if($value['program'] == 'Shopify')
  2120. {
  2121. $time = $v['purchased_on'];
  2122. }
  2123. else
  2124. {
  2125. if($value['id'] == 1)
  2126. {
  2127. $time = strtotime($v['purchased_on'])-7*3600-$sjc;//-$sjc;//之前是+$sjc
  2128. }
  2129. else
  2130. {
  2131. $time = strtotime($v['purchased_on'])-7*3600-$sjc;//订单时间更为时间戳 //之前是+$sjc
  2132. }
  2133. }
  2134. $num = $this->fullorder->find_count('gtime = "'.date('Ymd',$time).'" and shop = "'.$value['id'].'"');
  2135. $order_id = $value['id'].$v['order_id'];
  2136. $tc = isset($typeclass[$v['global_currency_code']])?$typeclass[$v['global_currency_code']]:0;
  2137. $dataorder = $this->fullorder->get_orderinfo($order_id);
  2138. $hmdid = '';
  2139. if($value['program'] == 'Shopify' && isset($dataorder['id']))
  2140. {
  2141. if($v['order_comment'] != $dataorder['clientremarks'])
  2142. {
  2143. $this->fullorder->save(array('clientremarks'=>$v['order_comment']),$dataorder['id']);
  2144. }
  2145. }
  2146. if(!isset($dataorder['id']))
  2147. //现在为所有订单都获取。!$ord && strcasecmp($v['isstatus'],'processing') == 0如果没有此订单并且订单状态为等待发货则继续
  2148. {
  2149. if(!isset($cuy[$v['country']]))
  2150. {
  2151. $cuy[$v['country']] = 1004;
  2152. }
  2153. $post = $this->api->get_data($value,$v,$gethl,$time,$cuy[$v['country']],$is,$num,$v['country'],$tc,$dtc,array(),$int,$dtctitle,$pay,$zjsku);
  2154. $kn = explode('-',$post['paypal']);
  2155. if($post['pay'] == 23 && $value['klarnaname'] != '' && $value['klarnapass'] != '')
  2156. {
  2157. $klarna = $this->_klarnadata($post['paypal'],$value['klarnaname'],$value['klarnapass']);
  2158. if($klarna != '')
  2159. {
  2160. $post['klarnadata'] = $klarna;
  2161. }
  2162. }
  2163. if($post['pay'] == 26 && $value['afterpayname'] != '' && $value['afterpaypass'] != '')
  2164. {
  2165. $afterpay = $this->_afterpay($post['paypal'],$value['afterpayname'],$value['afterpaypass']);
  2166. if($afterpay != '')
  2167. {
  2168. $post['klarnadata'] = $afterpay;
  2169. }
  2170. }
  2171. if($post['pay'] == 27 && $value['clearpayname'] != '' && $value['clearpaypass'] != '')
  2172. {
  2173. $clearpay = $this->_clearpay($post['paypal'],$value['clearpayname'],$value['clearpaypass']);
  2174. if($clearpay != '')
  2175. {
  2176. $post['klarnadata'] = $clearpay;
  2177. }
  2178. }
  2179. if($post['pay'] == '28' && $post['state'] != '207')
  2180. {
  2181. continue;
  2182. }
  2183. if($post['state'] == '217' || $post['state'] == '203')
  2184. {
  2185. continue;
  2186. }
  2187. /**
  2188. else if($post['pay'] == 22 && $value['paypalname'] != '' && $value['paypalpass'] != '')
  2189. {
  2190. $paypal = $this->_paypaldata($post['paypal'],$value['paypalname'],$value['paypalpass']);
  2191. if($paypal != '')
  2192. {
  2193. $post['klarnadata'] = $paypal;
  2194. }
  2195. }
  2196. **/
  2197. /** 启用自动分配仓库 **/
  2198. $warehouse = $this->warehouse->find_all("fpzd = '1'",'*','fpsx desc');
  2199. foreach ($warehouse as $v)
  2200. {
  2201. if($v['bdcountry'] != 0 && $v['bdcountry'] != $post['country'])
  2202. {
  2203. continue;
  2204. }
  2205. $yx = 'get_yx_'.$v['bdck'];
  2206. $post['express'] = 0;
  2207. $kczd = $this->ck->$yx($post['state'],$v,$post['shop'],$post['number'],$post['whlabel'],$post['fpdata']);
  2208. if($kczd['t'] == 0)
  2209. {
  2210. $country = $this->country->read($post['country']);//获取国家中配置物流
  2211. if($country['express'] != 0)
  2212. {
  2213. $post['express'] = $country['express'];
  2214. }
  2215. if($v['express'] != 0)//优先使用仓库指定物流,替换掉上面的国家配置物流
  2216. {
  2217. $post['express'] = $v['express'];
  2218. }
  2219. $post['type'] = $v['id'];
  2220. $post['whlabel'] = $kczd['whlabel'];
  2221. $post['fpdata'] = $kczd['fpdata'];
  2222. if(stripos($kczd['whlabel'],$v['hz']) !== false)
  2223. {
  2224. break 1;
  2225. }
  2226. }
  2227. }
  2228. $qdw = $this->warehouse->read($post['type']);
  2229. $fl = $this->ck->get_fl($qdw['hz'],$post['whlabel'],$post['fpdata']);
  2230. $post['sfxh'] = $fl['sfxh'];
  2231. $post['ckfl'] = $fl['ckfl'];
  2232. $zipcode = substr($post['zipcode'],0,1);
  2233. if($post['type'] == 5 && $zipcode > 6)
  2234. {
  2235. $post['express'] = 63;
  2236. }
  2237. //自动写位置 开始
  2238. $zclp = array();$pxsl = array();
  2239. $slpx = explode('|',$post['slpx']);//排序
  2240. foreach ($slpx as $k=>$v)
  2241. {
  2242. $v = explode('-',$v);
  2243. if(!isset($v[1]))
  2244. {
  2245. $v[1] == 1;
  2246. }
  2247. for($i=$v[0];$i<$v[1];$i++)
  2248. {
  2249. $pxsl[$i] = $k;
  2250. }
  2251. }
  2252. $mc = $qdw['bdck'];$zdidjl = '';$zdwzjl = '';
  2253. if($qdw['wz'] == 1)
  2254. {
  2255. $pm = explode(';',trim($post['shipremarks'],';'));
  2256. foreach ($pm as $k=>$vv)
  2257. {
  2258. $vv = trim($vv,' ');
  2259. $lp = $this->typeclass->find_all("zh = '$vv'");
  2260. if(isset($lp[0]['classid']))
  2261. {
  2262. $zclp[] = $vv;
  2263. unset($pm[$k]);
  2264. }
  2265. }
  2266. $pm = array_values($pm);
  2267. $w = explode('|',trim($post['whlabel'],'|'));
  2268. foreach ($w as $k=>$val)
  2269. {
  2270. $hwm = '';
  2271. if(stripos($val,$qdw['hz']) !== false)
  2272. {
  2273. $num = explode('-',trim($val,'-'));
  2274. $xq = explode('~',trim($num[2],'~'));
  2275. $pmxq = '(';
  2276. foreach ($xq as $v)
  2277. {
  2278. $zdidjl .= '('.trim($v,$qdw['hz']).')';
  2279. $h = $this->$mc->read(trim($v,$qdw['hz']));
  2280. if($h['details'] != '')
  2281. {
  2282. $pmxq .= $qdw['title'].':'.$h['details'].(($h['cpid']>0)?'-'.$h['cpid']:'').',';
  2283. }
  2284. }
  2285. $xrid = ($h['cpid']>0)?'-'.$h['cpid']:'';
  2286. if(isset($pxsl[$k]))
  2287. {
  2288. if(stripos($pm[$pxsl[$k]],$qdw['title'].':'.$h['details'].$xrid) === false)
  2289. {
  2290. $pm[$pxsl[$k]] .= trim($pmxq,',').')';
  2291. }
  2292. }
  2293. $zdwzjl .= $h['details'].(($h['cpid']>0)?'-'.$h['cpid']:'');
  2294. }
  2295. }
  2296. if($zclp)
  2297. {
  2298. $zclp = ';'.implode(";",$zclp);
  2299. }
  2300. else
  2301. {
  2302. $zclp = '';
  2303. }
  2304. $post['shipremarks'] = implode(";",$pm).$zclp;
  2305. $post['contents'] = $zdidjl.' - '.$zdwzjl;
  2306. }
  2307. //自动写位置 结束
  2308. //条数及申报
  2309. $ts = 0;
  2310. $dtsbjz = 0;
  2311. $zsbjz = 0;
  2312. $w = explode('|',trim($post['whlabel'],'|'));
  2313. foreach ($w as $k=>$val)
  2314. {
  2315. $num = explode('-',trim($val,'-'));
  2316. $ts += $num[1];
  2317. }
  2318. if($ts > 0 && $ts < 6 && $post['country'] == 192)
  2319. {
  2320. $dtsbjz = ($ts==3)?sprintf("%.1f",100/$ts):100/$ts;
  2321. $zsbjz = sprintf("%.2f",$dtsbjz*$ts);
  2322. }
  2323. $post['ts'] = $ts;
  2324. $post['dtsbjz'] = $dtsbjz;
  2325. $post['zsbjz'] = $zsbjz;
  2326. /** **/
  2327. //合并重复项
  2328. $hbcfw = explode('|',trim($post['whlabel'],'|'));
  2329. $hbcff = explode(';',trim($post['fpdata'],';'));
  2330. $c = 0;
  2331. $hbw = array();
  2332. $hbf = array();
  2333. for($i=0;$i<count($hbcfw);$i++)
  2334. {
  2335. $w = explode('-',$hbcfw[$i]);
  2336. $f = explode('|',$hbcff[$i]);
  2337. $w2 = ($w[2]==0)?0:'';
  2338. if(!isset($hbw[$w[0].$w2]))
  2339. {
  2340. $hbw[$w[0].$w2] = $hbcfw[$i];
  2341. $hbf[$w[0].$w2] = $hbcff[$i];
  2342. }
  2343. else
  2344. {
  2345. $c++;
  2346. $cw = explode('-',$hbw[$w[0].$w2]);
  2347. $cf = explode('|',$hbf[$w[0].$w2]);
  2348. if($cw[2] != 0 && $w[2] != 0)
  2349. {
  2350. $cf[2] += $f[2];
  2351. $cf[9] .= '~'.$f[9];
  2352. $hbf[$w[0].$w2] = implode("|",$cf);
  2353. $cw[1] += $f[2];
  2354. $cw[2] .= '~'.$f[9];
  2355. $hbw[$w[0].$w2] = implode("-",$cw);
  2356. }
  2357. else if($cw[2] == 0 && $w[2] == 0)
  2358. {
  2359. $cf[2] += $f[2];
  2360. $hbf[$w[0].$w2] = implode("|",$cf);
  2361. $cw[1] += $f[2];
  2362. $hbw[$w[0].$w2] = implode("-",$cw);
  2363. }
  2364. else
  2365. {
  2366. $hbw[] = $hbcfw[$i];
  2367. $hbf[] = $hbcff[$i];
  2368. }
  2369. }
  2370. }
  2371. if($c > 0)
  2372. {
  2373. $post['fpdata'] = implode(";",$hbf).';';
  2374. $post['whlabel'] = '|'.implode("|",$hbw).'|';
  2375. }
  2376. //合并重复项结束
  2377. //非占单设置为禁止占单开始
  2378. $hbw = explode('|',trim($post['whlabel'],'|'));
  2379. $hbf = explode(';',trim($post['fpdata'],';'));
  2380. foreach ($hbw as $k=>$val)
  2381. {
  2382. $w = explode('-',$val);
  2383. $f = explode('|',$hbf[$k]);
  2384. if(!isset($w[2]) || $w[2] == 0)
  2385. {
  2386. $w[2] = "DNOTO";
  2387. $f[9] = "DNOTO";
  2388. $hbf[$k] = implode("|",$f);
  2389. $hbw[$k] = implode("-",$w);
  2390. }
  2391. }
  2392. $post['fpdata'] = implode(";",$hbf).';';
  2393. $post['whlabel'] = '|'.implode("|",$hbw).'|';
  2394. //非占单设置为禁止占单结束
  2395. //查询净重开始
  2396. $post['jweight'] = $this->weight->get_weightcx($post['fpdata']);
  2397. $post['zzl'] = ($post['jweight']+100)/1000;
  2398. if($post['express'] == 2)
  2399. {
  2400. $post['zzl'] = intval(($post['jweight']+100)*0.035);
  2401. }
  2402. //查询净重结束
  2403. $tjid = $this->fullorder->insert($post);
  2404. /**
  2405. if($post['shop'] == '1' || $post['shop'] == '2' || $post['shop'] == '6' || $post['shop'] == '5')
  2406. {
  2407. $this->_znxc($post,$order_id,$lkh);
  2408. }
  2409. else
  2410. {
  2411. $this->_znx($post,$order_id,$lkh);
  2412. }
  2413. **/
  2414. }//else{}如果有此订单
  2415. }
  2416. }
  2417. if ($this->db->trans_status() === FALSE)
  2418. {
  2419. $this->db->trans_commit();
  2420. }
  2421. else
  2422. {
  2423. $this->db->trans_commit();
  2424. }
  2425. echo json_encode(array('msg'=>'OK!','success'=>true));exit;
  2426. }
  2427. }