Aa.php 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Aa extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->_model('Model_shop','shop');
  6. $this->load->_model('Model_fullorder','fullorder');
  7. $this->load->_model('Model_fullordertt','fullordertt');
  8. $this->load->_model('Model_fullordersmt','fullordersmt');
  9. $this->load->_model('Model_fullorderxw','fullorderxw');
  10. $this->load->_model('Model_fullorder_2020','fullorder2020');
  11. $this->load->_model('Model_fullordersmt_2020','fullordersmt2020');
  12. $this->load->_model('Model_customersmt','customersmt');
  13. $this->load->_model('Model_country','country');
  14. $this->load->_model('Model_hl','hl');
  15. $this->load->_model('Model_is','is');
  16. $this->load->_model('Model_kdniao','kdniao');
  17. $this->load->_model('Model_typeclass','typeclass');
  18. $this->load->_model('Model_warehouse','warehouse');
  19. $this->load->_model('Model_fullorderexcel','fullorderexcel');
  20. $this->load->_model('Model_dhl','dhl');
  21. $this->load->_model('Model_usps','usps');
  22. $this->load->_model('Model_dhltest','dhltest');
  23. $this->load->_model('Model_customer','customer');
  24. $this->load->_model('Model_express','express');
  25. $this->load->_model('Model_notice','notice');
  26. $this->load->_model('Model_whlabel','whlabel');
  27. $this->load->_model('Model_productdescribe','productdescribe');
  28. $this->load->_model('Model_ljg','ljg');
  29. $this->load->_model('Model_commodityread','commodityread');
  30. $this->load->_model('Model_service','service');
  31. $this->load->_model('Model_fedex','fedex');
  32. $this->load->_model('Model_commodity','commodity');
  33. $this->load->_model('Model_fullordersmtorder','fullordersmtorder');
  34. $this->load->_model('Model_ali','ali');
  35. $this->load->_model('Model_fullordersmthb','fullordersmthb');
  36. $this->load->_model('Model_fullordersmtbf','fullordersmtbf');
  37. $this->load->_model('Model_taxzhengzhou','taxzhengzhou');
  38. $this->load->_model('Model_taxshanghai','taxshanghai');
  39. $this->load->_model('Model_excel','excel');
  40. $this->load->_model('Model_ups','ups');
  41. $this->load->_model('Model_dpd','dpd');
  42. $this->load->_model('Model_dpdold','dpdold');
  43. $this->load->_model('Model_dpd_IOSS','dpd_IOSS');
  44. $this->load->_model('Model_dpdxw','dpdxw');
  45. $this->load->_model('Model_cne','cne');
  46. $this->load->_model('Model_outbound','outbound');
  47. $this->load->_model('Model_api','api');
  48. $this->load->_model('Model_dhlhz','dhlhz');
  49. $this->load->_model('Model_apismt','apismt');
  50. $this->load->_model('Model_specialstock','specialstock');
  51. $this->load->_model('Model_systemwigsout','systemwigsout');
  52. $this->load->_model('Model_purchaseorder','purchaseorder');
  53. $this->load->_model('Model_returns','returns');
  54. $this->load->_model('Model_whlabellabel','whlabellabel');
  55. $this->load->_model('Model_whlabelbarcode','whlabelbarcode');
  56. $this->load->_model('Model_tjadd','tjadd');
  57. $this->load->_model('Model_stafflist','stafflist');
  58. $this->load->_model('Model_paypal','paypal');
  59. $this->load->_model('Model_warehousefactory','warehousefactory');
  60. $this->load->_model('Model_commodityread_del','commodityreaddel');
  61. $this->load->_model('Model_als','als');
  62. $this->load->_model('Model_allocation','allocation');
  63. $this->load->_model('Model_17track','17track');
  64. $this->load->_model('Model_hualei','hualei');
  65. $this->load->_model('Model_ck','ck');
  66. $this->load->_model('Model_colour','colour');
  67. $this->load->_model('Model_color','color');
  68. $this->load->_model('Model_emaildata','emaildata');
  69. $this->load->_model('Model_wigprint','wigprint');
  70. $this->load->_model('Model_weight','weight');
  71. $this->load->_model('Model_whlabeltransport','whlabeltransport');
  72. $this->load->_model('Model_pay','pay');
  73. $this->load->_model('Model_orderurl','orderurl');
  74. $this->load->_model('Model_classid','classid');
  75. $this->load->_model('Model_apiyy','apiyy');
  76. $this->load->_model('Model_purchase','purchase');
  77. $this->load->_model('Model_apitt','apitt');
  78. $this->load->_model('Model_whlabel_bh','whlabel_bh');
  79. $this->load->_model('Model_whlabel_fc','whlabel_fc');
  80. $this->load->_model('Model_systemtransfer','systemtransfer');
  81. $this->load->_model('Model_systemtransfer_del','systemtransfer_del');
  82. $this->load->_model('Model_power','power');
  83. $this->load->_model('Model_fullorderexcel','fullorderexcel');
  84. $this->load->_model('Model_fullorderexcelclassid','fullorderexcelclassid');
  85. $this->load->_model('Model_awlgx','awlgx');
  86. $this->load->_model('Model_shopsku','shopsku');
  87. $this->load->_model('Model_ttwebhook','ttwebhook');
  88. $this->load->_model('Model_awlgx','awlgx');
  89. $this->load->_model('Model_customertt','customertt');
  90. $this->load->_model('Model_returncw','returncw');
  91. $this->load->_model('Model_systemtransfer_cr','systemtransfer_cr');
  92. $this->load->_model('Model_systemtransfer','systemtransfer');
  93. $this->load->_model('Model_producttitle','producttitle');
  94. $this->load->_model('Model_setting','setting');
  95. $this->load->_model('Model_whlabel_qh','whlabel_qh');
  96. $this->load->_model('Model_afspaypal','afspaypal');
  97. $this->load->_model('Model_whlabel_list','whlabel_list');
  98. $this->load->_model('Model_message','message');
  99. $this->load->_model('Model_whlabel_type','whlabel_type');
  100. }
  101. //定义方法的调用规则 获取URI第二段值
  102. public function _remap($arg,$arg_array)
  103. {
  104. if($arg == 'a')
  105. {
  106. $this->_a($arg_array);
  107. }
  108. else if($arg == 'ac')
  109. {
  110. $this->_ac($arg_array);
  111. }
  112. else if($arg == 'x')
  113. {
  114. $this->_x($arg_array);
  115. }
  116. else if($arg == 'x2')
  117. {
  118. $this->_x2($arg_array);
  119. }
  120. else if($arg == 'x3')
  121. {
  122. $this->_x3($arg_array);
  123. }
  124. else if($arg == 'xx')
  125. {
  126. $this->_xx($arg_array);
  127. }
  128. else if($arg == 'Token')
  129. {
  130. $this->_sku($arg_array);
  131. }
  132. else if($arg == 'dhl')
  133. {
  134. $this->_dhl($arg_array);
  135. }
  136. }
  137. public function get_hq($name,$shopapi,$shop)
  138. {
  139. $fromTime = time()-130*24*3600;//strtotime('yesterday')-$jqtime;//昨日0点+1小时保险无漏单
  140. $toTime = time()-125*24*3600;;
  141. $post = array();
  142. $post['synchronization'] = 1;
  143. $post['name'] = $name;
  144. $post['from'] = $fromTime;
  145. $post['to'] = $toTime;
  146. $ch = curl_init();
  147. curl_setopt($ch,CURLOPT_URL,$shopapi);
  148. curl_setopt($ch, CURLOPT_POST, 1);
  149. curl_setopt($ch, CURLOPT_HEADER, 0);
  150. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  151. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  152. curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
  153. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
  154. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  155. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,1800000);
  156. $res = curl_exec($ch);
  157. //$this->logic_ding->sendToDing("测试获取magento订单".$res);
  158. curl_close($ch);
  159. if($res)
  160. {
  161. $res = json_decode($res,true);
  162. $x = array();
  163. if($res)
  164. {
  165. foreach ($res as $v)
  166. {
  167. if(!isset($v['order_id']))
  168. {
  169. continue;
  170. }
  171. $source = '';
  172. $sc = substr($v['order_id'],0,3);
  173. if($sc == '600')
  174. {
  175. $source = $shop['thurl']; //手机订单
  176. }
  177. else
  178. {
  179. $source = $shop['url'];//PC订单
  180. }
  181. if($v['wjauthorid'] != '' && $v['sourcecontentid'] != '' && $source != '' && $shop['tweak'] != '')
  182. {
  183. $authorid = $this->authorid($source.'?author_id='.$v['wjauthorid'].'&source_content_id='.$v['sourcecontentid'],$shop['tweak']);
  184. if($authorid)
  185. {
  186. $v['authorid'] = $authorid;
  187. }
  188. }
  189. $x[] = $v;
  190. }
  191. }
  192. return $x;
  193. }
  194. }
  195. public function _a($arg_array)
  196. {
  197. $sid = '';$sd = array();
  198. if(isset($_SESSION['api']))
  199. {
  200. $user = $this->user->get_api($_SESSION['api']);
  201. $user = explode('|',trim($user['shop'],'|'));
  202. foreach ($user as $value)
  203. {
  204. $sid .= " id = '$value' or";
  205. }
  206. $sid = " and (".rtrim($sid,'or').")";
  207. }
  208. $post = $this->input->post(NULL, TRUE);
  209. $api = $this->input->get('api',true);
  210. $dshop = $this->input->get('dshop',true);
  211. //@$gethl = $this->hl->get_hl();//获取即时汇率
  212. $gethl = array();
  213. /* 订单号加入键值-k */
  214. /**
  215. $dataorder = array();
  216. $fdata = $this->fullorder->find_all('dtime > "'.(time()-96*3600).'"','orderinfo');
  217. foreach ($fdata as $v)
  218. {
  219. $dataorder[$v['orderinfo']] = "";//获取到单号
  220. }
  221. **/
  222. /* 订单号加入键值-j */
  223. /* 匹配加入 */
  224. $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');
  225. // 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)
  226. $dtc = array();
  227. foreach ($dictionaries as $v)
  228. {
  229. if(stripos($v['spare'],'|') !== false)//如果有多个值
  230. {
  231. $v['spare'] = explode('|',$v['spare']);
  232. foreach ($v['spare'] as $k=>$vs)
  233. {
  234. if(stripos($v['zh'],'|') !== false)
  235. {
  236. $vzh = explode('|',$v['zh']);
  237. $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$vzh[$k],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
  238. }
  239. else
  240. {
  241. $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
  242. }
  243. }
  244. }
  245. else
  246. {
  247. $dtc[strtolower($v['spare'])] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$v['spare']);
  248. }
  249. }
  250. $dictionaries2 = $this->typeclass->find_all();
  251. foreach ($dictionaries2 as $v)
  252. {
  253. $dtctitle[$v['id']] = $v['title'];
  254. }
  255. /* 匹配结束 */
  256. /* 价格加入 */
  257. /**
  258. $money = array();
  259. $productdescribe = $this->productdescribe->find_all('1=1','number,purchase,cost,salesprice,title');
  260. foreach ($productdescribe as $v)
  261. {
  262. $money[$v['number']] = array('purchase'=>$v['purchase'],'cost'=>$v['cost'],'salesprice'=>$v['salesprice'],'title'=>$v['title']);
  263. }
  264. **/
  265. /* 价格加入 */
  266. /* 匹配ID加入 */
  267. $int = array();
  268. $intdata = $this->typeclass->find_all('classid=14','id,spare');
  269. foreach ($intdata as $v)
  270. {
  271. $v['spare'] = explode('|',$v['spare']);
  272. $int[$v['id']] = $v['spare'][0];
  273. }
  274. /* 匹配ID结束 */
  275. /* 国家加入键值-k */
  276. $cuy = array();
  277. $cuydata = $this->country->find_all('1=1','lb,id');
  278. foreach ($cuydata as $v)
  279. {
  280. $cuy[$v['lb']] = $v['id'];//获取到国家ID
  281. }
  282. /* 国家加入键值-j */
  283. /* 币种加入键值-k */
  284. $typeclass = array();
  285. $tdata = $this->typeclass->find_all('classid=30','id,title');
  286. foreach ($tdata as $v)
  287. {
  288. $typeclass[$v['title']] = $v['id'];
  289. }
  290. /* 币种加入键值-j */
  291. /* 支付方式-k */
  292. $pay = array();
  293. $tdata = $this->typeclass->find_all('classid=4','id,spare');
  294. foreach ($tdata as $v)
  295. {
  296. $paytype = $this->pay->get_typeclass($v['id']);
  297. if(isset($paytype['estimaterate']))
  298. {
  299. $estimaterate = $paytype['estimaterate'];
  300. }
  301. else
  302. {
  303. $estimaterate = 0;
  304. }
  305. if(stripos($v['spare'],'|') !== false)//如果有多个值
  306. {
  307. $v['spare'] = explode('|',$v['spare']);
  308. foreach ($v['spare'] as $k=>$vs)
  309. {
  310. $pay[$vs] = array('id'=>$v['id'],'estimaterate'=>$estimaterate);
  311. }
  312. }
  313. else
  314. {
  315. $pay[$v['spare']] = array('id'=>$v['id'],'estimaterate'=>$estimaterate);
  316. }
  317. }
  318. $pay['stripeios'] = $pay['stripe_payments'];
  319. /* 支付方式-j */
  320. /* 新增SKU-k */
  321. $zjsku = array();
  322. $shopsku = $this->shopsku->find_all();
  323. foreach ($shopsku as $val)
  324. {
  325. $ss = explode(',',trim($val['shop'],','));
  326. foreach ($ss as $v)
  327. {
  328. if(isset($zjsku[$v]))
  329. {
  330. $zjsku[$v] .= ','.trim($val['sku'],',');
  331. }
  332. else
  333. {
  334. $zjsku[$v] = trim($val['sku'],',');
  335. }
  336. }
  337. }
  338. $value = $this->shop->read(4);//获取独立站信息
  339. $is = $this->is->find_all('1=1','*','number asc');//获取仓库平匹配表
  340. $setting = $this->setting->get_settings();
  341. $res = $this->get_hq($value['brandname'],$value['shopadmin'],$value);
  342. $sjc = 1;
  343. $ck = array();
  344. foreach ($res as $v)
  345. {
  346. if($value['id'] == 1)
  347. {
  348. $time = strtotime($v['purchased_on'])-7*3600-$sjc;//-$sjc;//之前是+$sjc
  349. }
  350. else
  351. {
  352. $time = strtotime($v['purchased_on'])-7*3600-$sjc;//订单时间更为时间戳 //之前是+$sjc
  353. }
  354. $num = $this->fullorder->find_count('gtime = "'.date('Ymd',$time).'" and shop = "'.$value['id'].'"');
  355. $order_id = $value['id'].$v['order_id'];
  356. $tc = 0;
  357. if(isset($v['global_currency_code']))
  358. {
  359. $tc = isset($typeclass[$v['global_currency_code']])?$typeclass[$v['global_currency_code']]:0;
  360. }
  361. $dataorder = $this->fullorder->get_orderinfo($order_id);
  362. $hmdid = '';
  363. if(!isset($cuy[$v['country']]))
  364. {
  365. $cuy[$v['country']] = 1004;
  366. }
  367. $post = $this->api->get_data($value,$v,$gethl,$time,$cuy[$v['country']],$is,$num,$v['country'],$tc,$dtc,array(),$int,$dtctitle,$pay,$zjsku);
  368. /**
  369. else if($post['pay'] == 22 && $value['paypalname'] != '' && $value['paypalpass'] != '')
  370. {
  371. $paypal = $this->_paypaldata($post['paypal'],$value['paypalname'],$value['paypalpass']);
  372. if($paypal != '')
  373. {
  374. $post['klarnadata'] = $paypal;
  375. }
  376. }
  377. **/
  378. /** 启用自动分配仓库 **/
  379. /**
  380. $post['express'] = 0;
  381. $warehouse = $this->warehouse->find_all("fpzd = '1'",'*','fpsx desc');
  382. foreach ($warehouse as $v)
  383. {
  384. if($v['bdcountry'] != 0 && $v['bdcountry'] != $post['country'])
  385. {
  386. continue;
  387. }
  388. $yx = 'get_yx_'.$v['bdck'];
  389. $kczd = $this->ck->$yx($post['state'],$v,$post['shop'],$post['number'],$post['whlabel'],$post['fpdata']);
  390. if($kczd['t'] == 0)
  391. {
  392. $country = $this->country->read($post['country']);//获取国家中配置物流
  393. if($country['express'] != 0)
  394. {
  395. $post['express'] = $country['express'];
  396. }
  397. if($v['express'] != 0)//优先使用仓库指定物流,替换掉上面的国家配置物流
  398. {
  399. $post['express'] = $v['express'];
  400. }
  401. $post['type'] = $v['id'];
  402. $post['whlabel'] = $kczd['whlabel'];
  403. $post['fpdata'] = $kczd['fpdata'];
  404. if(stripos($kczd['whlabel'],$v['hz']) !== false)
  405. {
  406. break 1;
  407. }
  408. }
  409. }
  410. $qdw = $this->warehouse->read($post['type']);
  411. $fl = $this->ck->get_fl($qdw['hz'],$post['whlabel'],$post['fpdata']);
  412. $post['sfxh'] = $fl['sfxh'];
  413. $post['ckfl'] = $fl['ckfl'];
  414. $zipcode = substr($post['zipcode'],0,1);
  415. if($post['type'] == 5 && $zipcode > 4)
  416. {
  417. $post['express'] = 63;
  418. }
  419. if($post['express'] > 0)
  420. {
  421. $xze = $this->express->read($post['express']);
  422. $post['printtype'] = $xze['type'];
  423. }
  424. **/
  425. //自动写位置 开始
  426. $zclp = array();$pxsl = array();
  427. $slpx = explode('|',$post['slpx']);//排序
  428. foreach ($slpx as $k=>$v)
  429. {
  430. $v = explode('-',$v);
  431. if(!isset($v[1]))
  432. {
  433. $v[1] == 1;
  434. }
  435. for($i=$v[0];$i<$v[1];$i++)
  436. {
  437. $pxsl[$i] = $k;
  438. }
  439. }
  440. $mc = $qdw['bdck'];$zdidjl = '';$zdwzjl = '';
  441. if($qdw['wz'] == 1)
  442. {
  443. $pm = explode(';',trim($post['shipremarks'],';'));
  444. foreach ($pm as $k=>$vv)
  445. {
  446. $vv = trim($vv,' ');
  447. $lp = $this->typeclass->find_all("zh = '$vv'");
  448. if(isset($lp[0]['classid']))
  449. {
  450. $zclp[] = $vv;
  451. unset($pm[$k]);
  452. }
  453. }
  454. $pm = array_values($pm);
  455. $w = explode('|',trim($post['whlabel'],'|'));
  456. foreach ($w as $k=>$val)
  457. {
  458. $hwm = '';
  459. if(stripos($val,$qdw['hz']) !== false)
  460. {
  461. $num = explode('-',trim($val,'-'));
  462. $xq = explode('~',trim($num[2],'~'));
  463. $pmxq = '(';
  464. foreach ($xq as $v)
  465. {
  466. $zdidjl .= '('.trim($v,$qdw['hz']).')';
  467. $h = $this->$mc->read(trim($v,$qdw['hz']));
  468. if($h['details'] != '')
  469. {
  470. $pmxq .= $qdw['title'].':'.$h['details'].(($h['cpid']>0)?'-'.$h['cpid']:'').',';
  471. }
  472. }
  473. $xrid = ($h['cpid']>0)?'-'.$h['cpid']:'';
  474. if(isset($pxsl[$k]))
  475. {
  476. if(stripos($pm[$pxsl[$k]],$qdw['title'].':'.$h['details'].$xrid) === false)
  477. {
  478. $pm[$pxsl[$k]] .= trim($pmxq,',').')';
  479. }
  480. }
  481. $zdwzjl .= $h['details'].(($h['cpid']>0)?'-'.$h['cpid']:'');
  482. }
  483. }
  484. if($zclp)
  485. {
  486. $zclp = ';'.implode(";",$zclp);
  487. }
  488. else
  489. {
  490. $zclp = '';
  491. }
  492. $post['shipremarks'] = implode(";",$pm).$zclp;
  493. $post['contents'] = $zdidjl.' - '.$zdwzjl;
  494. }
  495. //自动写位置 结束
  496. //条数及申报
  497. $ts = 0;
  498. $dtsbjz = 0;
  499. $zsbjz = 0;
  500. $w = explode('|',trim($post['whlabel'],'|'));
  501. foreach ($w as $k=>$val)
  502. {
  503. $num = explode('-',trim($val,'-'));
  504. $ts += $num[1];
  505. }
  506. if($ts > 0 && $ts < 6 && $post['country'] == 192)
  507. {
  508. $dtsbjz = ($ts==3)?sprintf("%.1f",100/$ts):100/$ts;
  509. $zsbjz = sprintf("%.2f",$dtsbjz*$ts);
  510. }
  511. $post['ts'] = $ts;
  512. $post['dtsbjz'] = $dtsbjz;
  513. $post['zsbjz'] = $zsbjz;
  514. /** **/
  515. //合并重复项
  516. $hbcfw = explode('|',trim($post['whlabel'],'|'));
  517. $hbcff = explode(';',trim($post['fpdata'],';'));
  518. $c = 0;
  519. $hbw = array();
  520. $hbf = array();
  521. for($i=0;$i<count($hbcfw);$i++)
  522. {
  523. $w = explode('-',$hbcfw[$i]);
  524. $f = explode('|',$hbcff[$i]);
  525. $w2 = ($w[2]==0)?0:'';
  526. if(!isset($hbw[$w[0].$w2]))
  527. {
  528. $hbw[$w[0].$w2] = $hbcfw[$i];
  529. $hbf[$w[0].$w2] = $hbcff[$i];
  530. }
  531. else
  532. {
  533. $c++;
  534. $cw = explode('-',$hbw[$w[0].$w2]);
  535. $cf = explode('|',$hbf[$w[0].$w2]);
  536. if($cw[2] != 0 && $w[2] != 0)
  537. {
  538. $cf[2] += $f[2];
  539. $cf[9] .= '~'.$f[9];
  540. $hbf[$w[0].$w2] = implode("|",$cf);
  541. $cw[1] += $f[2];
  542. $cw[2] .= '~'.$f[9];
  543. $hbw[$w[0].$w2] = implode("-",$cw);
  544. }
  545. else if($cw[2] == 0 && $w[2] == 0)
  546. {
  547. $cf[2] += $f[2];
  548. $hbf[$w[0].$w2] = implode("|",$cf);
  549. $cw[1] += $f[2];
  550. $hbw[$w[0].$w2] = implode("-",$cw);
  551. }
  552. else
  553. {
  554. $hbw[] = $hbcfw[$i];
  555. $hbf[] = $hbcff[$i];
  556. }
  557. }
  558. }
  559. if($c > 0)
  560. {
  561. $post['fpdata'] = implode(";",$hbf).';';
  562. $post['whlabel'] = '|'.implode("|",$hbw).'|';
  563. }
  564. //合并重复项结束
  565. //非占单设置为禁止占单开始
  566. $hbw = explode('|',trim($post['whlabel'],'|'));
  567. $hbf = explode(';',trim($post['fpdata'],';'));
  568. foreach ($hbw as $k=>$val)
  569. {
  570. $w = explode('-',$val);
  571. $f = explode('|',$hbf[$k]);
  572. if(!isset($w[2]) || $w[2] == 0)
  573. {
  574. $w[2] = "DNOTO";
  575. $f[9] = "DNOTO";
  576. $hbf[$k] = implode("|",$f);
  577. $hbw[$k] = implode("-",$w);
  578. }
  579. }
  580. $post['fpdata'] = implode(";",$hbf).';';
  581. $post['whlabel'] = '|'.implode("|",$hbw).'|';
  582. //非占单设置为禁止占单结束
  583. //查询净重开始
  584. $post['jweight'] = $this->weight->get_weightcx($post['fpdata']);
  585. $post['zzl'] = ($post['jweight']+100)/1000;
  586. if($post['express'] == 2)
  587. {
  588. $post['zzl'] = intval(($post['jweight']+100)*0.035);
  589. }
  590. //查询净重结束
  591. $ck[] = $post;
  592. }
  593. echo "<pre>";
  594. print_r($ck);
  595. exit;
  596. foreach ($a as $v)
  597. {
  598. $d = $this->fullorder->get_orderinfo($v[0]);
  599. $this->fullorder->save(array('dtime'=>strtotime($v[1]),'buytime'=>strtotime($v[1])),$d['id']);
  600. }
  601. exit;
  602. $v = $this->fullorder->get_number("QQS-40929-102");
  603. $post = array();
  604. $orderinfo = preg_replace('/^' . preg_quote($v['shop'], '/') . '/', '', $v['orderinfo']);
  605. $post['incrementId'] = $orderinfo;
  606. $post['trackingNumber'] = $v['waybill'];
  607. $ex = $this->express->read($v['express']);
  608. $post['carrier'] = $ex['iscode'];
  609. $shop = $this->shop->read($v['shop']);
  610. $url = 'https://www.romandhair.com/applepay/payment/addTrack';
  611. $ch = curl_init();
  612. curl_setopt($ch,CURLOPT_URL,$url);
  613. curl_setopt($ch, CURLOPT_POST, 1);
  614. curl_setopt($ch, CURLOPT_HEADER, 0);
  615. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  616. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  617. curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
  618. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
  619. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  620. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,1800000);
  621. $res = curl_exec($ch);
  622. curl_close($ch);
  623. echo $post['incrementId'];
  624. echo "<pre>";
  625. print_r($res);
  626. exit;
  627. $app_key = '6e17v02701qja';
  628. $code = 'ROW_Ndy4iwAAAAABEL6iLL6-MEYtcOmfF9z17OX066ypDSjWGDjXIbo-ODGO0v7Ui6sSw6H4dKnxir58biBqFqHPWP3kuW2XEvB73nNq0PLD9yyG9inJWhCMnBRNxvCTTIPfTiwt-NdA4F8s2fgBugiU8CK8xNBEX9_bgRhcapvE5E7MtAZLggjTFxWvlRmGi1xyWvURHI7whEaEIPa1gvFg69lsabcgTfIZjqsAZPdk2fwKGWf4Q5QcL6_q2Cwv8wqvPlC6ouHA4nqiynDo4BGswullj3GglvIAW11l1mCw7IWKiNertCXtg4NrpTCimLmsEqEOqBthC9Lg985BoMY1i1IQV1_7wQXUsau34Py3TxT40djLmC1lPLxi67o_tkZuKGtKI5kCIyVRc5at8xqTedkFwawAFIpUfPU5FjNFhDhWg6b7GmLlLw&locale';
  629. $shop = $this->shop->app_key($app_key);
  630. if($shop)
  631. {
  632. $url = 'https://auth.tiktok-shops.com/api/v2/token/get?app_key='.$app_key.'&auth_code='.$code.'&app_secret='.$shop['app_secret'].'&grant_type=authorized_code';
  633. $ch = curl_init();
  634. curl_setopt($ch, CURLOPT_URL,$url);
  635. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  636. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
  637. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  638. $res = curl_exec($ch);
  639. curl_close($ch);
  640. echo $res;
  641. $res = json_decode($res,true);
  642. echo "<pre>";
  643. print_r($res);
  644. /**
  645. if(isset($res['data']))
  646. {
  647. $shop['token'] = $res['data']['access_token'];
  648. $shop['refresh_token'] = $res['data']['refresh_token'];
  649. $shop_cipher = '';
  650. $shopcipher = $this->_shop_cipher($shop);
  651. if(isset($shopcipher['data']['shops'][0]['cipher']))
  652. {
  653. $shop_cipher = $shopcipher['data']['shops'][0]['cipher'];
  654. }
  655. $this->shop->save(array('token'=>$res['data']['access_token'],'tokentime'=>$res['data']['access_token_expire_in']-48*3600,'refresh_token'=>$res['data']['refresh_token'],'app_key'=>$app_key,'code'=>$code,'shop_cipher'=>$shop_cipher),$shop['id']);
  656. echo 'ok';
  657. echo "<pre>";
  658. print_r($res);
  659. }
  660. else
  661. {
  662. echo json_encode($res);
  663. }
  664. **/
  665. }
  666. exit;
  667. exit;
  668. $app_key='6e17v02701qja';
  669. $code = 'ROW_1HX6eQAAAAABEL6iLL6-MEYtcOmfF9z17OX066ypDSjWGDjXIbo-OAP3ojehHnSvVv_F1crabS_0BrWAW_cMO1HQSIq8PfsfX_4L40n5FznGhDmY1W6BCSmJKiOZHCcLdIAqUWF0oPtKQKeBwvyDxXb-ezdT4bn2t17DZ5aEARbX7V6qVAqWyFHrYgTtfjGIGxCgKrxR1-_KhqfC-2rD8PX8DItMw7dyS2MPei6E8O_IcJRc-dSAo7TpuAASCHKYpRunra40zJhjfGjQV0TJ6PI0qWOQoqwgBYHxXocLjJyJwWhJwt-Z4L1OXXDmpm25yI_hig5jBu5UlMprsyDVlFP2o7wMgrXt_WFiSuqKM4PRydNqVoFBY4J7bXFRx8iVokbpaTmM8K8ZD1MorctjSpgCV8L8_A1iDhmVqiANLDXPba49yMPmuA';
  670. $shop = $this->shop->read(59);
  671. $url = 'https://access_tokenrefresh_tokenGETauth.tiktok-shops.com/api/v2/token/get?app_key='.$app_key.'&auth_code='.$code.'&app_secret='.$shop['app_secret'].'&grant_type=authorized_code';
  672. $ch = curl_init();
  673. curl_setopt($ch, CURLOPT_URL,$url);
  674. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  675. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
  676. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  677. $res = curl_exec($ch);
  678. curl_close($ch);
  679. echo $res;
  680. echo "<pre>";
  681. $res = json_decode($res,true);
  682. print_r($res);
  683. exit;
  684. if(isset($res['data']))
  685. {
  686. $shop['token'] = $res['data']['access_token'];
  687. $shop['refresh_token'] = $res['data']['refresh_token'];
  688. $shop_cipher = '';
  689. $shopcipher = $this->_shop_cipher($shop);
  690. if(isset($shopcipher['data']['shops'][0]['cipher']))
  691. {
  692. $shop_cipher = $shopcipher['data']['shops'][0]['cipher'];
  693. }
  694. $this->shop->save(array('token'=>$res['data']['access_token'],'tokentime'=>$res['data']['access_token_expire_in']-48*3600,'refresh_token'=>$res['data']['refresh_token'],'app_key'=>$app_key,'code'=>$code,'shop_cipher'=>$shop_cipher),$shop['id']);
  695. echo 'ok';
  696. echo "<pre>";
  697. print_r($res);
  698. }
  699. else
  700. {
  701. echo json_encode($res);
  702. }
  703. exit;
  704. $this->fullorder->save(array('state'=>216,'print'=>3,'printtime'=>$time,'printnumber'=>1,'libraryconfirm'=>2,'library'=>2,'librarytime'=>$time,'weight'=>'0.4kg','review'=>6,'reviewtime'=>$time),$a['id']);
  705. exit;
  706. //自动写位置 开始
  707. $zclp = array();$pxsl = array();
  708. $slpx = explode('|',$post['slpx']);//排序
  709. foreach ($slpx as $k=>$v)
  710. {
  711. $v = explode('-',$v);
  712. if(!isset($v[1]))
  713. {
  714. $v[1] == 1;
  715. }
  716. for($i=$v[0];$i<$v[1];$i++)
  717. {
  718. $pxsl[$i] = $k;
  719. }
  720. }
  721. $mc = $qdw['bdck'];$zdidjl = '';$zdwzjl = '';
  722. if($qdw['wz'] == 1)
  723. {
  724. $pm = explode(';',trim($post['shipremarks'],';'));
  725. foreach ($pm as $k=>$vv)
  726. {
  727. $vv = trim($vv,' ');
  728. $lp = $this->typeclass->find_all("zh = '$vv'");
  729. if(isset($lp[0]['classid']))
  730. {
  731. $zclp[] = $vv;
  732. unset($pm[$k]);
  733. }
  734. }
  735. $pm = array_values($pm);
  736. $w = explode('|',trim($post['whlabel'],'|'));
  737. foreach ($w as $k=>$val)
  738. {
  739. $hwm = '';
  740. if(stripos($val,$qdw['hz']) !== false)
  741. {
  742. $num = explode('-',trim($val,'-'));
  743. $xq = explode('~',trim($num[2],'~'));
  744. $pmxq = '(';
  745. foreach ($xq as $v)
  746. {
  747. $zdidjl .= '('.trim($v,$qdw['hz']).')';
  748. $h = $this->$mc->read(trim($v,$qdw['hz']));
  749. if($h['details'] != '')
  750. {
  751. $pmxq .= $qdw['title'].':'.$h['details'].(($h['cpid']>0)?'-'.$h['cpid']:'').',';
  752. }
  753. }
  754. $xrid = ($h['cpid']>0)?'-'.$h['cpid']:'';
  755. if(isset($pxsl[$k]))
  756. {
  757. if(stripos($pm[$pxsl[$k]],$qdw['title'].':'.$h['details'].$xrid) === false)
  758. {
  759. $pm[$pxsl[$k]] .= trim($pmxq,',').')';
  760. }
  761. }
  762. $zdwzjl .= $h['details'].(($h['cpid']>0)?'-'.$h['cpid']:'');
  763. }
  764. }
  765. if($zclp)
  766. {
  767. $zclp = ';'.implode(";",$zclp);
  768. }
  769. else
  770. {
  771. $zclp = '';
  772. }
  773. $post['shipremarks'] = implode(";",$pm).$zclp;
  774. $post['contents'] = $zdidjl.' - '.$zdwzjl;
  775. }
  776. //自动写位置 结束
  777. //条数及申报
  778. $ts = 0;
  779. $dtsbjz = 0;
  780. $zsbjz = 0;
  781. $w = explode('|',trim($post['whlabel'],'|'));
  782. foreach ($w as $k=>$val)
  783. {
  784. $num = explode('-',trim($val,'-'));
  785. $ts += $num[1];
  786. }
  787. if($ts > 0 && $ts < 6 && $post['country'] == 192)
  788. {
  789. $dtsbjz = ($ts==3)?sprintf("%.1f",100/$ts):100/$ts;
  790. $zsbjz = sprintf("%.2f",$dtsbjz*$ts);
  791. }
  792. $post['ts'] = $ts;
  793. $post['dtsbjz'] = $dtsbjz;
  794. $post['zsbjz'] = $zsbjz;
  795. /** **/
  796. //合并重复项
  797. $hbcfw = explode('|',trim($post['whlabel'],'|'));
  798. $hbcff = explode(';',trim($post['fpdata'],';'));
  799. $c = 0;
  800. $hbw = array();
  801. $hbf = array();
  802. for($i=0;$i<count($hbcfw);$i++)
  803. {
  804. $w = explode('-',$hbcfw[$i]);
  805. $f = explode('|',$hbcff[$i]);
  806. $w2 = ($w[2]==0)?0:'';
  807. if(!isset($hbw[$w[0].$w2]))
  808. {
  809. $hbw[$w[0].$w2] = $hbcfw[$i];
  810. $hbf[$w[0].$w2] = $hbcff[$i];
  811. }
  812. else
  813. {
  814. $c++;
  815. $cw = explode('-',$hbw[$w[0].$w2]);
  816. $cf = explode('|',$hbf[$w[0].$w2]);
  817. if($cw[2] != 0 && $w[2] != 0)
  818. {
  819. $cf[2] += $f[2];
  820. $cf[9] .= '~'.$f[9];
  821. $hbf[$w[0].$w2] = implode("|",$cf);
  822. $cw[1] += $f[2];
  823. $cw[2] .= '~'.$f[9];
  824. $hbw[$w[0].$w2] = implode("-",$cw);
  825. }
  826. else if($cw[2] == 0 && $w[2] == 0)
  827. {
  828. $cf[2] += $f[2];
  829. $hbf[$w[0].$w2] = implode("|",$cf);
  830. $cw[1] += $f[2];
  831. $hbw[$w[0].$w2] = implode("-",$cw);
  832. }
  833. else
  834. {
  835. $hbw[] = $hbcfw[$i];
  836. $hbf[] = $hbcff[$i];
  837. }
  838. }
  839. }
  840. if($c > 0)
  841. {
  842. $post['fpdata'] = implode(";",$hbf).';';
  843. $post['whlabel'] = '|'.implode("|",$hbw).'|';
  844. }
  845. //合并重复项结束
  846. //非占单设置为禁止占单开始
  847. $hbw = explode('|',trim($post['whlabel'],'|'));
  848. $hbf = explode(';',trim($post['fpdata'],';'));
  849. foreach ($hbw as $k=>$val)
  850. {
  851. $w = explode('-',$val);
  852. $f = explode('|',$hbf[$k]);
  853. if(!isset($w[2]) || $w[2] == 0)
  854. {
  855. $w[2] = "DNOTO";
  856. $f[9] = "DNOTO";
  857. $hbf[$k] = implode("|",$f);
  858. $hbw[$k] = implode("-",$w);
  859. }
  860. }
  861. $post['fpdata'] = implode(";",$hbf).';';
  862. $post['whlabel'] = '|'.implode("|",$hbw).'|';
  863. //非占单设置为禁止占单结束
  864. //查询净重开始
  865. $post['jweight'] = $this->weight->get_weightcx($post['fpdata']);
  866. $post['zzl'] = ($post['jweight']+100)/1000;
  867. if($post['express'] == 2)
  868. {
  869. $post['zzl'] = intval(($post['jweight']+100)*0.035);
  870. }
  871. }
  872. public function _aasd($arg_array)
  873. {
  874. /**
  875. $time = time()-3*24*3600;
  876. $this->db->set('cktype', 1)
  877. ->where('warehouse', 5)
  878. ->where('cktype ', 0)
  879. ->where('state ', 10)
  880. ->where('outk > ', $time)
  881. ->update('whlabel');
  882. exit;
  883. $time = time()-15*24*3600;
  884. $list = $this->whlabel->find_all("sku = 'HDJCLFW24-250D' and outk > '$time'");
  885. foreach ($list as $k=>$v)
  886. {
  887. $list[$k]['outk'] = date('Y-m-d H:i:s',$v['outk']);
  888. }
  889. echo "<pre>";
  890. print_r($list);
  891. exit;
  892. exit;
  893. $this->db->set('rktype', 1)
  894. ->where('warehouse', 5)
  895. ->where('rktype ', 0)
  896. ->update('whlabel');
  897. exit;
  898. $ktime = time()-30*24*3600;
  899. $list = $this->whlabel->read($arg_array[0]);
  900. $this->whlabel->save(array('cktype'=>1),$arg_array[0]);
  901. echo "<pre>";
  902. print_r($list);
  903. exit;
  904. $dtime = strtotime('2024/10/17 13:30:10');
  905. echo substr(date('ymd',$dtime),1);
  906. exit;
  907. $time = 1728638040;
  908. $a = $this->fullorder->get_number('QQS-41008-016');
  909. $this->fullorder->save(array('state'=>216,'print'=>3,'printtime'=>$time,'printnumber'=>1,'libraryconfirm'=>2,'library'=>2,'librarytime'=>$time,'weight'=>'0.4kg','review'=>6,'reviewtime'=>$time),$a['id']);
  910. exit;
  911. $y = $this->fullorder->get_number('ASTE-40913-019');
  912. //$this->fullorder->save(array('librarytime'=>1727359200),$a['id']);
  913. $post['waybill'] = $y['waybill'];
  914. $post['express'] = $y['express'];
  915. $post['printtype'] = $y['printtype'];
  916. $post['ioss'] = $y['ioss'];
  917. $post['review'] = 6;
  918. $post['bx'] = $y['bx'];
  919. $post['qm'] = $y['qm'];
  920. $post['js'] = $y['js'];
  921. $post['state'] = 216;
  922. $post['print'] = $y['print'];
  923. $post['printtime'] = $y['printtime'];
  924. $post['library'] = 2;
  925. $post['librarytime'] = $y['librarytime'];
  926. $post['libraryconfirm'] = 2;
  927. $post['librarynot'] = '';
  928. $this->fullorder->save($post,1168209);
  929. //$this->fullorder->save(array('libraryconfirm'=>2,'library'=>1,'librarytime'=>0,'weight'=>'0'),$a['id']);
  930. echo "<pre>";
  931. //print_r($a);
  932. exit;
  933. $a = $this->fullordertt->get_number('QQS-40911-071');
  934. $paypal = $a['paypal'];
  935. $shop = $this->shop->read($a['shop']);
  936. $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');
  937. $ToState = array_flip($ToState);
  938. $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='.$paypal.'&fields=all&page_size=100&page=1';
  939. $token = $this->token($shop);
  940. $header[] = "Content-Type: application/json";
  941. //$header[] = "Authorization: Basic ".base64_encode($name.":".$pass);
  942. $header[] = "Authorization: Bearer ".$token;
  943. $ch = curl_init();
  944. curl_setopt($ch, CURLOPT_URL, $url);
  945. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  946. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  947. curl_setopt($ch, CURLOPT_HTTPGET, true);
  948. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
  949. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  950. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  951. $res = curl_exec($ch);
  952. curl_close($ch);
  953. $res = json_decode($res,true);
  954. //$time = 1561846608;
  955. //$a = $this->fullordertt->get_number('ALIP-90630-020');
  956. //$this->fullordertt->save(array('state'=>216,'print'=>3,'printtime'=>$time,'printnumber'=>1,'libraryconfirm'=>2,'library'=>2,'librarytime'=>$time,'weight'=>'0.4kg','review'=>6,'reviewtime'=>$time),$a['id']);
  957. //$a = $this->fullorder->get_number('Y-40624-009');
  958. //$this->fullorder->save(array('library'=>2,'retreattime'=>0),$a['id']);
  959. //$a = $this->whlabel->find_all("sku = 'RTG-DEEP4*7WIG16-130D'");
  960. echo "<pre>";
  961. print_r($res);
  962. exit;
  963. $a = $this->fullorder->get_number('Alipearl-70419-001');
  964. $b = $this->fullorder->get_number('Alipearl-70418-001');
  965. $this->fullorder->save(array('merge'=>0,'mergeid'=>0,'dtime'=>1492531200),$a['id']);
  966. $this->fullorder->save(array('merge'=>0,'mergeid'=>0,'dtime'=>1492444800),$b['id']);
  967. exit;
  968. $customer = $this->customer->find_all("email = 'denee_francis@yahoo.com' and shop = 2",'id,email,shop');
  969. foreach ($customer as $k=>$v)
  970. {
  971. $num = $this->fullorder->find_all("email = '".$v['email']."' and shop = '".$v['shop']."' and mergeid = 0","*","dtime desc");
  972. $money = sprintf("%01.2f",array_sum(array_column($num,'shouldmoney')));
  973. $n = count($num);
  974. if($n > 0)
  975. {
  976. $this->customer->save(array('num'=>$n,'money'=>$money,'time'=>$num[0]['dtime']),$v['id']);
  977. }
  978. else
  979. {
  980. $this->customer->save(array('num'=>$n),$v['id']);
  981. }
  982. }
  983. exit;
  984. $a = $this->whlabel->find_all("type != 0");
  985. foreach ($a as $v)
  986. {
  987. $this->whlabel->save(array('type'=>0),$v['id']);
  988. }
  989. exit;
  990. //$data = $this->fullorder->get_number($arg_array[0]);
  991. $data = array();
  992. $data['roles'][0]['roleName'] = 'SHIPPER';
  993. $data['roles'][0]['CRID'] = '27426217';
  994. $data['roles'][0]['MID'] = '902531035';
  995. $data['roles'][0]['manifestMID'] = '902531035';
  996. $data['roles'][0]['accountType'] = 'PERMIT';
  997. $data['roles'][0]['accountNumber'] = '8982';
  998. $token = $this->usps->get_token();
  999. $url = 'https://api.usps.com/payments/v3/payment-authorization';
  1000. // 将请求数据编码为JSON格式
  1001. $data = json_encode($data);
  1002. // 初始化cURL会话
  1003. $ch = curl_init($url);
  1004. // 设置cURL选项
  1005. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  1006. curl_setopt($ch, CURLOPT_HTTPHEADER, [
  1007. 'Authorization: Bearer ' . $token,
  1008. 'Content-Type: application/json'
  1009. ]);
  1010. curl_setopt($ch, CURLOPT_POST, true);
  1011. curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  1012. curl_setopt($ch, CURLOPT_VERBOSE, true);
  1013. // 执行cURL请求
  1014. $response = curl_exec($ch);
  1015. // 检查是否有错误
  1016. if (curl_errno($ch)) {
  1017. echo '请求错误: ' . curl_error($ch);
  1018. curl_close($ch);
  1019. }
  1020. // 获取HTTP状态码
  1021. $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  1022. // 关闭cURL会话
  1023. curl_close($ch);
  1024. // 解析响应数据
  1025. $responseData = json_decode($response, true);
  1026. if ($httpCode == 200) {
  1027. echo 1; // 请求成功,返回响应数据
  1028. } else {
  1029. echo '请求失败,HTTP状态码: ' . $httpCode . "\n";
  1030. }
  1031. print_r($responseData);
  1032. exit;
  1033. **/
  1034. $data = $this->fullorder->get_number('TB-50109-003');
  1035. $res = $this->usps->get_data_new($data);
  1036. echo "<pre>";
  1037. print_r($res);
  1038. exit;
  1039. }
  1040. public function _email($arg_array)//不能删
  1041. {
  1042. $time = time();
  1043. $shop = $this->shop->find_all("emailid != '' and emailsecret != ''");
  1044. foreach ($shop as $v)
  1045. {
  1046. if($v['emailtokentime'] < $time)
  1047. {
  1048. // 请求参数
  1049. $post = array();
  1050. $post['grant_type'] = 'client_credentials';
  1051. $post['client_id'] = $v['emailid'];
  1052. $post['client_secret'] = $v['emailsecret'];
  1053. $url = 'https://alimail-cn.aliyuncs.com/oauth2/v2.0/token';
  1054. $headers = array('Content-Type: application/x-www-form-urlencoded');
  1055. $data = $this->su_curl($post,$url,$headers,$date_type='json',$timeout=300,$httptype="POST",$userpwd='');
  1056. $data = json_decode($data,true);
  1057. $this->shop->save(array('emailtokentime'=>0,'emailtoken'=>$data['access_token']),$v['id']);
  1058. }
  1059. }
  1060. /**
  1061. $url = 'https://alimail-cn.aliyuncs.com/v2/users/paypal@supernovahair.com/mailFolders/1/messages?$select=from,toRecipients,id&size=100&cursor=';
  1062. $headers = array('Authorization: Bearer '.$token,'Content-Type: application/json');
  1063. $data = $this->su_curl('',$url,$headers,$date_type='json',$timeout=300,$httptype="GET",$userpwd='');
  1064. $data = json_decode($data,true);
  1065. echo "<pre>";
  1066. print_r($data);
  1067. **/
  1068. echo "<pre>";
  1069. //print_r($res);
  1070. exit;
  1071. }
  1072. public function _cz($shop,$token,$w,$next='')
  1073. {
  1074. $cs = array();
  1075. $url = 'https://alimail-cn.aliyuncs.com/v2/users/'.$shop['shopid'].'/mailFolders/'.$w.'/messages?$select=from,toRecipients,sentDateTime,id&size=100&cursor='.$next;
  1076. $headers = array('Authorization: Bearer '.$token,'Content-Type: application/json');
  1077. $data = $this->su_curl('',$url,$headers,$date_type='json',$timeout=300,$httptype="GET",$userpwd='');
  1078. $data = json_decode($data,true);
  1079. if(isset($data['messages'][0]))
  1080. {
  1081. foreach ($data['messages'] as $v)
  1082. {
  1083. $fs = $v['from']['email'];
  1084. $js = isset($v['toRecipients'][0])?$v['toRecipients'][0]['email']:(isset($v['toRecipients']['email'])?$v['toRecipients']['email']:'');
  1085. $type = 0;
  1086. $useremail = '';
  1087. if($fs == $shop['shopid'])
  1088. {
  1089. $type = 1;
  1090. $useremail = $js;
  1091. }
  1092. else if($js == $shop['shopid'])
  1093. {
  1094. $type = 2;
  1095. $useremail = $fs;
  1096. }
  1097. $pc = $this->email->get_uid($v['id']);
  1098. if($pc)
  1099. {
  1100. break;
  1101. }
  1102. $this->email->insert(array('type'=>$type,'useremail'=>$useremail,'shopemail'=>$shop['shopid'],'uid'=>$v['id'],'fid'=>$w,'time'=>strtotime($v['sentDateTime'])));
  1103. //
  1104. }
  1105. if(isset($data['nextCursor']) && $data['nextCursor'] != '')
  1106. {
  1107. $this->_cz($shop,$token,$w,$data['nextCursor']);
  1108. }
  1109. }
  1110. return $cs;
  1111. }
  1112. public function _b($arg_array)
  1113. {
  1114. // 目标 URL
  1115. $url = 'https://alimail-cn.aliyuncs.com/oauth2/v2.0/token';
  1116. // 请求参数
  1117. $postData = array(
  1118. 'grant_type' => 'client_credentials',
  1119. 'client_id' => '8jLYqQdJWno8c95B',
  1120. 'client_secret' => 'km9xLaK0SNqqT0ghTRIBcfvhB95B8UCqIOAZIBEk9GeROzj4rJDwNqBhkaorCMux',
  1121. );
  1122. // 初始化 curl
  1123. $ch = curl_init();
  1124. // 设置 curl 选项
  1125. curl_setopt($ch, CURLOPT_URL, $url); // 设置 URL
  1126. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // 返回 response 而不是输出
  1127. curl_setopt($ch, CURLOPT_POST, true); // 设置为 POST 请求
  1128. curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData)); // 设置 POST 数据
  1129. curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  1130. 'Content-Type: application/x-www-form-urlencoded', // 设置请求头为 application/x-www-form-urlencoded
  1131. ));
  1132. // 执行请求并获取返回数据
  1133. $response = curl_exec($ch);
  1134. // 检查是否有错误发生
  1135. if ($response === false) {
  1136. echo 'cURL Error: ' . curl_error($ch);
  1137. } else {
  1138. // 处理返回的数据
  1139. echo $response;
  1140. }
  1141. // 关闭 curl 资源
  1142. curl_close($ch);
  1143. exit;
  1144. // 您的邮箱地址和密码
  1145. $username = 'paypal@supernovahair.com';
  1146. $password = 'Hsn0723.';
  1147. // 阿里云邮箱的 IMAP 服务器地址和端口号
  1148. $hostname = '{imap.mxhichina.com:993/imap/ssl}INBOX';
  1149. // 尝试连接到 IMAP 服务器
  1150. $inbox = imap_open($hostname, $username, $password);
  1151. if (!$inbox) {
  1152. die('IMAP connection failed: ' . imap_last_error());
  1153. }
  1154. // 要搜索的邮件 UID
  1155. $search_uid = 77098; // 替换为您要搜索的具体 UID
  1156. // 获取邮箱中的所有邮件概述信息
  1157. $mail_overviews = imap_fetch_overview($inbox, '1:' . imap_num_msg($inbox), 0);
  1158. if ($mail_overviews) {
  1159. $data = array();
  1160. // 遍历所有邮件概述信息
  1161. foreach ($mail_overviews as $overview) {
  1162. // 获取邮件 UID
  1163. $mail_uid = isset($overview->uid) ? $overview->uid : 0;
  1164. // 检查邮件 UID 是否匹配搜索条件
  1165. if ($mail_uid == $search_uid) {
  1166. // 获取发件人信息
  1167. $sender_email = isset($overview->from) ? $overview->from : '';
  1168. // 获取收件人信息
  1169. $recipient_email = isset($overview->to) ? $overview->to : '';
  1170. // 获取邮件主题
  1171. $subject = isset($overview->subject) ? $overview->subject : '';
  1172. // 获取邮件时间
  1173. $timestamp = isset($overview->date) ? strtotime($overview->date) : '';
  1174. // 构建数据数组
  1175. $data[] = array(
  1176. "UID:" => $mail_uid,
  1177. "标题:" => $subject,
  1178. "发送人:" => $sender_email,
  1179. "接收人:" => $recipient_email,
  1180. "时间:" => date('Y-m-d H:i:s', $timestamp),
  1181. );
  1182. }
  1183. }
  1184. // 输出符合条件的邮件数据
  1185. echo "<pre>";
  1186. print_r($data);
  1187. echo "</pre>";
  1188. } else {
  1189. echo "未找到符合条件的邮件";
  1190. }
  1191. // 关闭连接
  1192. imap_close($inbox);
  1193. exit;
  1194. // 阿里云邮箱的 IMAP 服务器地址和端口号
  1195. $hostname = '{imap.mxhichina.com:993/imap/ssl}INBOX';
  1196. // 尝试连接到阿里云邮箱的 IMAP 服务器
  1197. $inbox = imap_open($hostname, $username, $password);
  1198. // 获取邮箱中的邮件数量
  1199. $total_emails = imap_num_msg($inbox);
  1200. $data = array();
  1201. // 读取前10封邮件的内容
  1202. for ($i = 1; $i <= min($total_emails, 20); $i++)
  1203. {
  1204. // 获取邮件头信息
  1205. $header = imap_header($inbox, $i);
  1206. // 获取邮件内容
  1207. $body = imap_fetchbody($inbox, $i, 1); // 参数2表示获取邮件的第1个部分,通常为邮件正文
  1208. // 获取邮件编码类型
  1209. $encoding = isset($header->encoding) ? $header->encoding : null;
  1210. // 如果邮件内容是base64编码的,则解码
  1211. if ($encoding == 3)
  1212. {
  1213. $body = base64_decode($body);
  1214. }
  1215. $uid = imap_uid($inbox, $i);
  1216. $fsr = $header->from;
  1217. $jsr = $header->to;
  1218. $data[] = array(
  1219. "UID:"=>$uid,
  1220. "标题:"=>$header->subject,
  1221. "发送人:"=>$fsr[0]->mailbox.'@'.$fsr[0]->host,
  1222. "接收人:"=>$jsr[0]->mailbox.'@'.$jsr[0]->host,
  1223. "关联ID:"=>$header->references,
  1224. "关联原始ID:"=>$header->in_reply_to,
  1225. "时间:"=>$header->udate,
  1226. "内容:"=>$body); // nl2br() 函数用于将换行符转换为 HTML 的换行标签
  1227. }
  1228. // 关闭连接
  1229. imap_close($inbox);
  1230. echo "<pre>";
  1231. print_r($data);
  1232. exit;
  1233. }
  1234. public function _dhl($arg_array)//DHL
  1235. {
  1236. $y = $this->fullorder->get_number("AS-PF1-40701-002");
  1237. $a = $this->dhl->get_data_c('AS-PF1-40701-002');
  1238. print_r($a);
  1239. exit;
  1240. $express = $this->express->read($y['express']);
  1241. if($express['printcode'] == "DHLUSA" && $y['waybill'] != '')
  1242. {
  1243. $d = $this->dhl->get_data_9610($y);
  1244. if($d != 1)
  1245. {
  1246. $this->allocation->insert(array('order'=>1,'title'=>$y['number'],'content'=>$d));
  1247. return '9610失败,'.$d;exit;
  1248. }
  1249. $this->allocation->insert(array('order'=>9610,'title'=>$y['number']));
  1250. }
  1251. exit;
  1252. $d = $this->dhl->get_data_9610($data);
  1253. echo "<pre>";
  1254. print_r($d);
  1255. exit;
  1256. }
  1257. public function su_curl($data,$url,$header=array(),$date_type='json',$timeout=300,$httptype="POST",$userpwd='')
  1258. {
  1259. if ($date_type == 'http_build_query')
  1260. {
  1261. $data = http_build_query($data);
  1262. }
  1263. else if ($date_type == 'json')
  1264. {
  1265. $data = json_encode($data);
  1266. }
  1267. $ch = curl_init();
  1268. curl_setopt($ch, CURLOPT_URL, $url);
  1269. curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
  1270. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  1271. curl_setopt($ch, CURLOPT_HEADER, false);
  1272. switch ($httptype)
  1273. {
  1274. case "GET":
  1275. curl_setopt($ch, CURLOPT_HTTPGET, true);
  1276. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
  1277. break;
  1278. case "POST":
  1279. curl_setopt($ch, CURLOPT_POST, true);
  1280. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
  1281. break;
  1282. case "PUT":
  1283. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
  1284. break;
  1285. case "DELETE":
  1286. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
  1287. break;
  1288. }
  1289. $isSecure = strpos($url, "https://");
  1290. if ($isSecure === 0)
  1291. {
  1292. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  1293. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  1294. }
  1295. if(!empty($header))
  1296. {
  1297. curl_setopt($ch, CURLOPT_SSLVERSION , 6); //NEW ADDITION
  1298. curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
  1299. }
  1300. if(!empty($userpwd))
  1301. {
  1302. curl_setopt($ch,CURLOPT_USERPWD,$userpwd);
  1303. }
  1304. curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
  1305. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
  1306. $result = curl_exec($ch);
  1307. curl_close($ch);
  1308. return $result;
  1309. }
  1310. public function _klarnadata($paypal,$name,$pass)
  1311. {
  1312. $url = 'https://api-na.klarna.com/ordermanagement/v1/orders/'.$paypal;
  1313. $header[] = "Content-Type:application/json";
  1314. $header[] = "Authorization: Basic ".base64_encode($name.":".$pass);
  1315. $ch = curl_init();
  1316. curl_setopt($ch, CURLOPT_URL, $url);
  1317. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  1318. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  1319. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  1320. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  1321. $res = curl_exec($ch);
  1322. curl_close($ch);
  1323. $res = json_decode($res,true);
  1324. $data = '';
  1325. if(isset($res['fraud_status']))
  1326. {
  1327. $data = (($res['fraud_status'] == 'ACCEPTED')?1:2).'|<strong>'.$res['purchase_currency'].($res['order_amount']/100).'</strong> , '.(($res['fraud_status'] != 'ACCEPTED')?'<font style="color:#f00">'.$res['fraud_status'].'</font>':$res['fraud_status']).' , description:'.$res['initial_payment_method']['description'].' , number of installments:'.$res['initial_payment_method']['number_of_installments'].'|'.$res['billing_address']['street_address'].(($res['billing_address']['street_address2']!='')?' '.$res['billing_address']['street_address2']:'').','.$res['billing_address']['city'].','.$res['billing_address']['region'].','.$res['billing_address']['postal_code'].','.$res['billing_address']['country'].','.$res['billing_address']['given_name'].' '.$res['billing_address']['family_name'].','.$res['billing_address']['phone'].','.$res['billing_address']['email'].'|'.str_replace('|','&#124;',$res['shipping_address']['street_address']).(($res['shipping_address']['street_address2']!='')?' '.str_replace('|','&#124;',$res['shipping_address']['street_address2']):'').','.$res['shipping_address']['city'].','.$res['shipping_address']['region'].','.$res['shipping_address']['postal_code'].','.$res['shipping_address']['country'].','.$res['shipping_address']['given_name'].' '.$res['shipping_address']['family_name'].','.$res['shipping_address']['phone'].','.$res['shipping_address']['email'];
  1328. }
  1329. return $data;
  1330. }
  1331. public function _afterpay($paypal,$name,$pass)
  1332. {
  1333. $url = 'https://global-api.afterpay.com/v2/payments?ids='.$paypal;
  1334. $header[] = "Accept:application/json";
  1335. $header[] = "User-Agent: Readme.io API Simulator'";
  1336. $header[] = "Authorization: Basic ".base64_encode($name.":".$pass);
  1337. $ch = curl_init();
  1338. curl_setopt($ch, CURLOPT_URL, $url);
  1339. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  1340. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  1341. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  1342. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  1343. $res = curl_exec($ch);
  1344. curl_close($ch);
  1345. $res = json_decode($res,true);
  1346. $data = '';
  1347. if(isset($res['results'][0]['orderDetails']['consumer']['email']))
  1348. {
  1349. $data = $res['results'][0]['orderDetails']['consumer']['email'].'|'.str_replace('|','&#124;',$res['results'][0]['orderDetails']['billing']['line1']).','.str_replace('|','&#124;',$res['results'][0]['orderDetails']['billing']['line2']).','.$res['results'][0]['orderDetails']['billing']['area1'].','.$res['results'][0]['orderDetails']['billing']['region'].','.$res['results'][0]['orderDetails']['billing']['postcode'].','.$res['results'][0]['orderDetails']['billing']['countryCode'].','.$res['results'][0]['orderDetails']['billing']['name'].','.$res['results'][0]['orderDetails']['billing']['phoneNumber'].'|'.str_replace('|','&#124;',$res['results'][0]['orderDetails']['shipping']['line1']).','.str_replace('|','&#124;',$res['results'][0]['orderDetails']['shipping']['line2']).','.$res['results'][0]['orderDetails']['shipping']['area1'].','.$res['results'][0]['orderDetails']['shipping']['region'].','.$res['results'][0]['orderDetails']['shipping']['postcode'].','.$res['results'][0]['orderDetails']['shipping']['countryCode'].','.$res['results'][0]['orderDetails']['shipping']['name'].','.$res['results'][0]['orderDetails']['shipping']['phoneNumber'];
  1350. $data = str_replace(',,',',',$data);
  1351. }
  1352. return $data;
  1353. }
  1354. public function _clearpay($paypal,$name,$pass)
  1355. {
  1356. $url = 'https://global-api.afterpay.com/v2/payments?ids='.$paypal;
  1357. $header[] = "Accept:application/json";
  1358. $header[] = "User-Agent: Readme.io API Simulator'";
  1359. $header[] = "Authorization: Basic ".base64_encode($name.":".$pass);
  1360. $ch = curl_init();
  1361. curl_setopt($ch, CURLOPT_URL, $url);
  1362. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  1363. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  1364. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  1365. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  1366. $res = curl_exec($ch);
  1367. curl_close($ch);
  1368. $res = json_decode($res,true);
  1369. $data = '';
  1370. if(isset($res['results'][0]['orderDetails']['consumer']['email']))
  1371. {
  1372. $data = $res['results'][0]['orderDetails']['consumer']['email'].'|'.str_replace('|','&#124;',$res['results'][0]['orderDetails']['billing']['line1']).','.str_replace('|','&#124;',$res['results'][0]['orderDetails']['billing']['line2']).','.$res['results'][0]['orderDetails']['billing']['area1'].','.$res['results'][0]['orderDetails']['billing']['region'].','.$res['results'][0]['orderDetails']['billing']['postcode'].','.$res['results'][0]['orderDetails']['billing']['countryCode'].','.$res['results'][0]['orderDetails']['billing']['name'].','.$res['results'][0]['orderDetails']['billing']['phoneNumber'].'|'.str_replace('|','&#124;',$res['results'][0]['orderDetails']['shipping']['line1']).','.str_replace('|','&#124;',$res['results'][0]['orderDetails']['shipping']['line2']).','.$res['results'][0]['orderDetails']['shipping']['area1'].','.$res['results'][0]['orderDetails']['shipping']['region'].','.$res['results'][0]['orderDetails']['shipping']['postcode'].','.$res['results'][0]['orderDetails']['shipping']['countryCode'].','.$res['results'][0]['orderDetails']['shipping']['name'].','.$res['results'][0]['orderDetails']['shipping']['phoneNumber'];
  1373. $data = str_replace(',,',',',$data);
  1374. }
  1375. return $data;
  1376. }
  1377. public function _text($fullorder)
  1378. {
  1379. /** 发票地址信息暂时无用
  1380. $fullorder['baddress'] = explode(',',$fullorder['baddress']);
  1381. $fullorder['baddress'] = array_reverse($fullorder['baddress']);
  1382. $fullorder['baddress'][1] = $country['ename'];
  1383. **/
  1384. //获取所用相关信息
  1385. $warehouse = $this->warehouse->read($fullorder['type']);
  1386. $country = $this->country->read($fullorder['country']);//订单国家信息
  1387. $fcountry = $this->country->read($warehouse['country']);//仓库国家信息
  1388. $warehouse['country'] = $fcountry['ename'];//仓库国家名
  1389. $warehouse['lb'] = $fcountry['lb'];//仓库国家编码
  1390. $fullorder['warehouse'] = $warehouse;//仓库数据加入订单
  1391. $fullorder['lb'] = $country['lb'];//订单国家编码加入
  1392. $fullorder['country'] = $country['ename'];//订单国家名
  1393. $fullorder['zhou'] = $country['continent'];//所属州
  1394. $express = $this->express->read($fullorder['express']);
  1395. $fullorder['express'] = $express['servicename'];
  1396. $fullorder['account'] = $express['account'];
  1397. $fullorder['printcode'] = $express['printcode'];
  1398. $fullorder['time'] = date('Y-m-d',time());
  1399. $fullorder['times'] = date('Y-m-d H:i',time());
  1400. $fullorder['sbbm']= ($fullorder['sbpm'] == 'Hair Sample') ? 67042000 : 67041100;
  1401. $fullorder['address'] = str_replace(array('&'),array('&#38;'),$fullorder['address']);
  1402. $fullorder['address2'] = str_replace(array('&'),array('&#38;'),$fullorder['address2']);
  1403. $fullorder['shipremarks'] = str_replace(array('&lt;','&gt;'),array('<','>'),$fullorder['shipremarks']);
  1404. $fullorder['shipremarks'] = str_replace(array('<','>',';',';'),array('&lt','&gt',';<br>',';<br>'),$fullorder['shipremarks']);
  1405. $shop = $this->shop->read($fullorder['shop']);
  1406. $fullorder['shop'] = $shop['shopname'];
  1407. $shoptype = $this->typeclass->read($shop['type']);
  1408. $fullorder['shoptype'] = $shoptype['classtitle'];
  1409. $fullorder['city'] = preg_replace('/( | | |\s)/',' ',$fullorder['city']);
  1410. $fullorder['province'] = preg_replace('/( | | |\s)/',' ',$fullorder['province']);
  1411. if(is_numeric($fullorder['pay']))
  1412. {
  1413. $pay = $this->typeclass->read($fullorder['pay']);
  1414. if($pay['classid'] == '4')
  1415. {
  1416. $fullorder['pay'] = $pay['title'];
  1417. }
  1418. }
  1419. if($fullorder['printcode'] != "USPS")
  1420. {
  1421. $fullorder['client'] = htmlspecialchars($fullorder['client']);
  1422. $fullorder['name'] = htmlspecialchars($fullorder['name']);
  1423. }
  1424. //增加退货单所需信息
  1425. $pt = '';
  1426. $fpdata = explode(';',trim($fullorder['fpdata'],';'));
  1427. foreach ($fpdata as $v)
  1428. {
  1429. $p = explode('|',trim($v,'|'));
  1430. if(isset($p[1]) && isset($p[2]))
  1431. {
  1432. $pt .= '<p>'.$p[1].' * '.$p[2].'</p>';
  1433. }
  1434. }
  1435. $fullorder['pt'] = $pt;
  1436. return $fullorder;
  1437. }
  1438. }