Api.php 90 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Api 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_shop','shop');
  8. $this->load->_model('Model_fullorder','fullorder');
  9. $this->load->_model('Model_fullordertt','fullordertt');
  10. $this->load->_model('Model_fullorder_smt','fullorder_smt');
  11. $this->load->_model('Model_fullordersmt','fullordersmt');
  12. $this->load->_model('Model_country','country');
  13. $this->load->_model('Model_hl','hl');
  14. $this->load->_model('Model_is','is');
  15. $this->load->_model('Model_kdniao','kdniao');
  16. $this->load->_model('Model_typeclass','typeclass');
  17. $this->load->_model('Model_warehouse','warehouse');
  18. $this->load->_model('Model_fullorderexcel','fullorderexcel');
  19. $this->load->_model('Model_dhl','dhl');
  20. $this->load->_model('Model_usps','usps');
  21. $this->load->_model('Model_ups','ups');
  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_emaildata','emaildata');
  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_apismt','apismt');
  34. $this->load->_model('Model_cne','cne');
  35. $this->load->_model('Model_specialstock','specialstock');
  36. $this->load->_model('Model_whlabellabel','whlabellabel');
  37. $this->load->_model('Model_allocation','allocation');
  38. $this->load->_model('Model_yswaybill','yswaybill');
  39. $this->load->_model('Model_paypal','paypal');
  40. $this->load->_model('Model_17track','17track');
  41. $this->load->_model('Model_ck','ck');
  42. $this->load->_model('Model_weight','weight');
  43. $this->load->_model('Model_pay','pay');
  44. $this->load->_model('Model_setting','setting');
  45. $this->load->_model('Model_classid','classid');
  46. $this->load->_model('Model_apiyy','apiyy');
  47. $this->load->_model('Model_whlabel_fc','whlabel_fc');
  48. $this->load->_model('Model_shopsku','shopsku');
  49. $this->load->_model('Model_awlgx','awlgx');
  50. $this->load->_model('Model_apitt','apitt');
  51. $this->load->_model('Model_producttitle','producttitle');
  52. $this->load->_model('Model_afspaypal','afspaypal');
  53. $this->load->_model('Model_message','message');
  54. $this->load->_model("Model_zztmpdata",'zztmpdata');
  55. $this->load->_model("Model_logic_ding","logic_ding");
  56. }
  57. //定义方法的调用规则 获取URI第二段值
  58. public function _remap($arg,$arg_array)
  59. {
  60. if($arg == 'isorder')//添加
  61. {
  62. $this->_isorder();
  63. }
  64. else if($arg == 'tb')//同步独立站
  65. {
  66. $this->_tb();
  67. }
  68. else if($arg == 'waybill')//运单上传独立站
  69. {
  70. $this->_waybill($arg_array);
  71. }
  72. else if($arg == 'waybillemail')
  73. {
  74. $this->_waybillemail($arg_array);
  75. }
  76. else if($arg == 'waybillfs')
  77. {
  78. $this->_waybillfs($arg_array);
  79. }
  80. else if($arg == 'headgear')//传输头套信息
  81. {
  82. $this->_headgear($arg_array);
  83. }
  84. else if($arg == 'fsstate')
  85. {
  86. $this->_fsstate();
  87. }
  88. else if($arg == 'fswaybillemail')
  89. {
  90. $this->_fswaybillemail();
  91. }
  92. else if($arg == 'zz')
  93. {
  94. $this->_zz();
  95. }
  96. else if($arg == 'zzcs')
  97. {
  98. $this->_zzcs();
  99. }
  100. else if($arg == 'cangku')
  101. {
  102. $this->_cangku();
  103. }
  104. else if($arg == 'kc')
  105. {
  106. $this->_kc();
  107. }
  108. else if($arg == 'wlfs')
  109. {
  110. $this->_wlfs();
  111. }
  112. else if($arg == 'query')
  113. {
  114. $this->_query();
  115. }
  116. else if($arg == 'kcjc')
  117. {
  118. $this->_kcjc();
  119. }
  120. else if($arg == 'klarna')
  121. {
  122. $this->_klarna();
  123. }
  124. else if($arg == 'logistics')
  125. {
  126. $this->_logistics();
  127. }
  128. else if($arg == 'hqpaypal')
  129. {
  130. $this->_hqpaypal();
  131. }
  132. else if($arg == 'hqstripe')
  133. {
  134. $this->_hqstripe();
  135. }
  136. else if($arg == 'htmlstock')
  137. {
  138. $this->_htmlstock();
  139. }
  140. else if($arg == 'dhl')
  141. {
  142. $this->_dhl();
  143. }
  144. else if($arg == '17track')
  145. {
  146. $this->_17track();
  147. }
  148. else if($arg == 'zc17track')
  149. {
  150. $this->_zc17track();
  151. }
  152. }
  153. //通过地址直接获取独立站订单信息
  154. public function _isorder()
  155. {
  156. $sid = '';$sd = array();
  157. if(isset($_SESSION['api']))
  158. {
  159. $user = $this->user->get_api($_SESSION['api']);
  160. $user = explode('|',trim($user['shop'],'|'));
  161. foreach ($user as $value)
  162. {
  163. $sid .= " id = '$value' or";
  164. }
  165. $sid = " and (".rtrim($sid,'or').")";
  166. }
  167. $post = $this->input->post(NULL, TRUE);
  168. $api = $this->input->get('api',true);
  169. $dshop = $this->input->get('dshop',true);
  170. //@$gethl = $this->hl->get_hl();//获取即时汇率
  171. $gethl = array();
  172. /* 订单号加入键值-k */
  173. /**
  174. $dataorder = array();
  175. $fdata = $this->fullorder->find_all('dtime > "'.(time()-96*3600).'"','orderinfo');
  176. foreach ($fdata as $v)
  177. {
  178. $dataorder[$v['orderinfo']] = "";//获取到单号
  179. }
  180. **/
  181. /* 订单号加入键值-j */
  182. /* 匹配加入 */
  183. $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');
  184. // 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)
  185. $dtc = array();
  186. foreach ($dictionaries as $v)
  187. {
  188. if(stripos($v['spare'],'|') !== false)//如果有多个值
  189. {
  190. $v['spare'] = explode('|',$v['spare']);
  191. foreach ($v['spare'] as $k=>$vs)
  192. {
  193. if(stripos($v['zh'],'|') !== false)
  194. {
  195. $vzh = explode('|',$v['zh']);
  196. $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$vzh[$k],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
  197. }
  198. else
  199. {
  200. $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
  201. }
  202. }
  203. }
  204. else
  205. {
  206. $dtc[strtolower($v['spare'])] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$v['spare']);
  207. }
  208. }
  209. $dictionaries2 = $this->typeclass->find_all();
  210. foreach ($dictionaries2 as $v)
  211. {
  212. $dtctitle[$v['id']] = $v['title'];
  213. }
  214. /* 匹配结束 */
  215. /* 价格加入 */
  216. /**
  217. $money = array();
  218. $productdescribe = $this->productdescribe->find_all('1=1','number,purchase,cost,salesprice,title');
  219. foreach ($productdescribe as $v)
  220. {
  221. $money[$v['number']] = array('purchase'=>$v['purchase'],'cost'=>$v['cost'],'salesprice'=>$v['salesprice'],'title'=>$v['title']);
  222. }
  223. **/
  224. /* 价格加入 */
  225. /* 匹配ID加入 */
  226. $int = array();
  227. $intdata = $this->typeclass->find_all('classid=14','id,spare');
  228. foreach ($intdata as $v)
  229. {
  230. $v['spare'] = explode('|',$v['spare']);
  231. $int[$v['id']] = $v['spare'][0];
  232. }
  233. /* 匹配ID结束 */
  234. /* 国家加入键值-k */
  235. $cuy = array();
  236. $cuydata = $this->country->find_all('1=1','lb,id');
  237. foreach ($cuydata as $v)
  238. {
  239. $cuy[$v['lb']] = $v['id'];//获取到国家ID
  240. }
  241. /* 国家加入键值-j */
  242. /* 币种加入键值-k */
  243. $typeclass = array();
  244. $tdata = $this->typeclass->find_all('classid=30','id,title');
  245. foreach ($tdata as $v)
  246. {
  247. $typeclass[$v['title']] = $v['id'];
  248. }
  249. /* 币种加入键值-j */
  250. /* 支付方式-k */
  251. $pay = array();
  252. $tdata = $this->typeclass->find_all('classid=4','id,spare');
  253. foreach ($tdata as $v)
  254. {
  255. $paytype = $this->pay->get_typeclass($v['id']);
  256. if(isset($paytype['estimaterate']))
  257. {
  258. $estimaterate = $paytype['estimaterate'];
  259. }
  260. else
  261. {
  262. $estimaterate = 0;
  263. }
  264. if(stripos($v['spare'],'|') !== false)//如果有多个值
  265. {
  266. $v['spare'] = explode('|',$v['spare']);
  267. foreach ($v['spare'] as $k=>$vs)
  268. {
  269. $pay[$vs] = array('id'=>$v['id'],'estimaterate'=>$estimaterate);
  270. }
  271. }
  272. else
  273. {
  274. $pay[$v['spare']] = array('id'=>$v['id'],'estimaterate'=>$estimaterate);
  275. }
  276. }
  277. $pay['stripeios'] = $pay['stripe_payments'];
  278. /* 支付方式-j */
  279. /* 新增SKU-k */
  280. $zjsku = array();
  281. $shopsku = $this->shopsku->find_all();
  282. foreach ($shopsku as $val)
  283. {
  284. $ss = explode(',',trim($val['shop'],','));
  285. foreach ($ss as $v)
  286. {
  287. if(isset($zjsku[$v]))
  288. {
  289. $zjsku[$v] .= ','.trim($val['sku'],',');
  290. }
  291. else
  292. {
  293. $zjsku[$v] = trim($val['sku'],',');
  294. }
  295. }
  296. }
  297. /* 新增SKU-j */
  298. $is = $this->is->find_all('1=1','*','number asc');//获取仓库平匹配表
  299. if(isset($post['is']) || (isset($api) && $api = '89757'))
  300. {
  301. $tb = 0;
  302. if($dshop)
  303. {
  304. $shop = $this->shop->find_all("id = '$dshop'");
  305. }
  306. else
  307. {
  308. $shop = $this->shop->find_all("type = 269 and tb = 1".$sid);//获取独立站信息
  309. }
  310. foreach ($shop as $value)
  311. {
  312. if((time()-$value['tbtime']) < 600)
  313. {
  314. $tb = 1;//正在同步中
  315. break;
  316. }
  317. else
  318. {
  319. $this->shop->save(array('tbtime'=>time()),$value['id']);
  320. }
  321. $setting = $this->setting->get_settings();
  322. $this->db->trans_begin();
  323. $res = $this->api->get_hq($value['brandname'],$value['shopadmin'],$value);
  324. $sd[] = $res;
  325. $sjc = $setting['sctime'];//时间差 之前是3600 现在为0
  326. if($res)
  327. {
  328. foreach ($res as $v)
  329. {
  330. if(!isset($v['order_id']))
  331. {
  332. continue;
  333. }
  334. if($value['token'] == 'SU')
  335. {
  336. $time = $v['purchased_on']-7*3600-$sjc;//之前是+$sjc
  337. }
  338. else if($value['program'] == 'Shopify')
  339. {
  340. $time = $v['purchased_on'];
  341. }
  342. else
  343. {
  344. if($value['id'] == 1)
  345. {
  346. $time = strtotime($v['purchased_on'])-7*3600-$sjc;//-$sjc;//之前是+$sjc
  347. }
  348. else
  349. {
  350. $time = strtotime($v['purchased_on'])-7*3600-$sjc;//订单时间更为时间戳 //之前是+$sjc
  351. }
  352. }
  353. $num = $this->fullorder->find_count('gtime = "'.date('Ymd',$time).'" and shop = "'.$value['id'].'"');
  354. $order_id = $value['id'].$v['order_id'];
  355. $tc = 0;
  356. if(isset($v['global_currency_code']))
  357. {
  358. $tc = isset($typeclass[$v['global_currency_code']])?$typeclass[$v['global_currency_code']]:0;
  359. }
  360. $dataorder = $this->fullorder->get_orderinfo($order_id);
  361. $hmdid = '';
  362. if($value['program'] == 'Shopify' && isset($dataorder['id']))
  363. {
  364. if($v['order_comment'] != $dataorder['clientremarks'])
  365. {
  366. $this->fullorder->save(array('clientremarks'=>$v['order_comment']),$dataorder['id']);
  367. }
  368. }
  369. if(!isset($dataorder['id']))
  370. //现在为所有订单都获取。!$ord && strcasecmp($v['isstatus'],'processing') == 0如果没有此订单并且订单状态为等待发货则继续
  371. {
  372. if(!isset($cuy[$v['country']]))
  373. {
  374. $cuy[$v['country']] = 1004;
  375. }
  376. $post = $this->api->get_data($value,$v,$gethl,$time,$cuy[$v['country']],$is,$num,$v['country'],$tc,$dtc,array(),$int,$dtctitle,$pay,$zjsku);
  377. $kn = explode('-',$post['paypal']);
  378. if($post['pay'] == 23 && $value['klarnaname'] != '' && $value['klarnapass'] != '')
  379. {
  380. $klarna = $this->_klarnadata($post['paypal'],$value['klarnaname'],$value['klarnapass']);
  381. if($klarna != '')
  382. {
  383. $post['klarnadata'] = $klarna;
  384. }
  385. }
  386. if($post['pay'] == 26 && $value['afterpayname'] != '' && $value['afterpaypass'] != '')
  387. {
  388. $afterpay = $this->_afterpay($post['paypal'],$value['afterpayname'],$value['afterpaypass']);
  389. if($afterpay != '')
  390. {
  391. $post['klarnadata'] = $afterpay;
  392. }
  393. }
  394. if($post['pay'] == 27 && $value['clearpayname'] != '' && $value['clearpaypass'] != '')
  395. {
  396. $clearpay = $this->_clearpay($post['paypal'],$value['clearpayname'],$value['clearpaypass']);
  397. if($clearpay != '')
  398. {
  399. $post['klarnadata'] = $clearpay;
  400. }
  401. }
  402. if($post['pay'] == '28' && $post['state'] != '207')
  403. {
  404. continue;
  405. }
  406. if($post['state'] == '217' || $post['state'] == '203')
  407. {
  408. continue;
  409. }
  410. /**
  411. else if($post['pay'] == 22 && $value['paypalname'] != '' && $value['paypalpass'] != '')
  412. {
  413. $paypal = $this->_paypaldata($post['paypal'],$value['paypalname'],$value['paypalpass']);
  414. if($paypal != '')
  415. {
  416. $post['klarnadata'] = $paypal;
  417. }
  418. }
  419. **/
  420. /** 启用自动分配仓库 **/
  421. $post['express'] = 0;
  422. $warehouse = $this->warehouse->find_all("fpzd = '1'",'*','fpsx desc');
  423. foreach ($warehouse as $v)
  424. {
  425. if($v['bdcountry'] != 0 && $v['bdcountry'] != $post['country'])
  426. {
  427. continue;
  428. }
  429. $yx = 'get_yx_'.$v['bdck'];
  430. $kczd = $this->ck->$yx($post['state'],$v,$post['shop'],$post['number'],$post['whlabel'],$post['fpdata']);
  431. if($kczd['t'] == 0)
  432. {
  433. $country = $this->country->read($post['country']);//获取国家中配置物流
  434. if($country['express'] != 0)
  435. {
  436. $post['express'] = $country['express'];
  437. }
  438. if($v['express'] != 0)//优先使用仓库指定物流,替换掉上面的国家配置物流
  439. {
  440. $post['express'] = $v['express'];
  441. }
  442. $post['type'] = $v['id'];
  443. $post['whlabel'] = $kczd['whlabel'];
  444. $post['fpdata'] = $kczd['fpdata'];
  445. if(stripos($kczd['whlabel'],$v['hz']) !== false)
  446. {
  447. break 1;
  448. }
  449. }
  450. }
  451. $qdw = $this->warehouse->read($post['type']);
  452. $fl = $this->ck->get_fl($qdw['hz'],$post['whlabel'],$post['fpdata']);
  453. $post['sfxh'] = $fl['sfxh'];
  454. $post['ckfl'] = $fl['ckfl'];
  455. $zipcode = substr($post['zipcode'],0,1);
  456. if($post['type'] == 5 && $zipcode > 4)
  457. {
  458. $post['express'] = 63;
  459. }
  460. if($post['express'] > 0)
  461. {
  462. $xze = $this->express->read($post['express']);
  463. $post['printtype'] = $xze['type'];
  464. }
  465. //自动写位置 开始
  466. $zclp = array();$pxsl = array();
  467. $slpx = explode('|',$post['slpx']);//排序
  468. //监听报错原因
  469. //解决礼物类没有slpx的数据
  470. if(!empty($post['slpx'])){
  471. foreach ($slpx as $k=>$v)
  472. {
  473. $v = explode('-',$v);
  474. if(!isset($v[1]))
  475. {
  476. $v[1] == 1;
  477. }
  478. for($i=$v[0];$i<$v[1];$i++)
  479. {
  480. $pxsl[$i] = $k;
  481. }
  482. }
  483. }
  484. $mc = $qdw['bdck'];$zdidjl = '';$zdwzjl = '';
  485. if($qdw['wz'] == 1)
  486. {
  487. $pm = explode(';',trim($post['shipremarks'],';'));
  488. foreach ($pm as $k=>$vv)
  489. {
  490. $vv = trim($vv,' ');
  491. $lp = $this->typeclass->find_all("zh = '$vv'");
  492. if(isset($lp[0]['classid']))
  493. {
  494. $zclp[] = $vv;
  495. unset($pm[$k]);
  496. }
  497. }
  498. $pm = array_values($pm);
  499. $w = explode('|',trim($post['whlabel'],'|'));
  500. foreach ($w as $k=>$val)
  501. {
  502. $hwm = '';
  503. if(stripos($val,$qdw['hz']) !== false)
  504. {
  505. $num = explode('-',trim($val,'-'));
  506. $xq = explode('~',trim($num[2],'~'));
  507. $pmxq = '(';
  508. foreach ($xq as $v)
  509. {
  510. $zdidjl .= '('.trim($v,$qdw['hz']).')';
  511. $h = $this->$mc->read(trim($v,$qdw['hz']));
  512. if($h['details'] != '')
  513. {
  514. $pmxq .= $qdw['title'].':'.$h['details'].(($h['cpid']>0)?'-'.$h['cpid']:'').',';
  515. }
  516. }
  517. $xrid = ($h['cpid']>0)?'-'.$h['cpid']:'';
  518. if(isset($pxsl[$k]))
  519. {
  520. if(stripos($pm[$pxsl[$k]],$qdw['title'].':'.$h['details'].$xrid) === false)
  521. {
  522. $pm[$pxsl[$k]] .= trim($pmxq,',').')';
  523. }
  524. }
  525. $zdwzjl .= $h['details'].(($h['cpid']>0)?'-'.$h['cpid']:'');
  526. }
  527. }
  528. if($zclp)
  529. {
  530. $zclp = ';'.implode(";",$zclp);
  531. }
  532. else
  533. {
  534. $zclp = '';
  535. }
  536. $post['shipremarks'] = implode(";",$pm).$zclp;
  537. $post['contents'] = $zdidjl.' - '.$zdwzjl;
  538. }
  539. //自动写位置 结束
  540. //条数及申报
  541. $ts = 0;
  542. $dtsbjz = 0;
  543. $zsbjz = 0;
  544. $w = explode('|',trim($post['whlabel'],'|'));
  545. foreach ($w as $k=>$val)
  546. {
  547. $num = explode('-',trim($val,'-'));
  548. //$ts += $num[1];
  549. //判断是否是礼物 礼物不计数
  550. $is_gift_str = substr($num[0], 0, 3);
  551. if($is_gift_str != '131'){
  552. $ts += $num[1];
  553. }
  554. }
  555. if($ts > 0 && $ts < 6 && $post['country'] == 192)
  556. {
  557. $dtsbjz = ($ts==3)?sprintf("%.2f",100/$ts):100/$ts;
  558. $zsbjz = sprintf("%.2f",$dtsbjz*$ts);
  559. }
  560. $post['ts'] = $ts;
  561. $post['dtsbjz'] = $dtsbjz;
  562. $post['zsbjz'] = $zsbjz;
  563. /** **/
  564. //合并重复项
  565. $hbcfw = explode('|',trim($post['whlabel'],'|'));
  566. $hbcff = explode(';',trim($post['fpdata'],';'));
  567. $c = 0;
  568. $hbw = array();
  569. $hbf = array();
  570. for($i=0;$i<count($hbcfw);$i++)
  571. {
  572. $w = explode('-',$hbcfw[$i]);
  573. $f = explode('|',$hbcff[$i]);
  574. $w2 = ($w[2]==0)?0:'';
  575. if(!isset($hbw[$w[0].$w2]))
  576. {
  577. $hbw[$w[0].$w2] = $hbcfw[$i];
  578. $hbf[$w[0].$w2] = $hbcff[$i];
  579. }
  580. else
  581. {
  582. $c++;
  583. $cw = explode('-',$hbw[$w[0].$w2]);
  584. $cf = explode('|',$hbf[$w[0].$w2]);
  585. if($cw[2] != 0 && $w[2] != 0)
  586. {
  587. $cf[2] += $f[2];
  588. $cf[9] .= '~'.$f[9];
  589. $hbf[$w[0].$w2] = implode("|",$cf);
  590. $cw[1] += $f[2];
  591. $cw[2] .= '~'.$f[9];
  592. $hbw[$w[0].$w2] = implode("-",$cw);
  593. }
  594. else if($cw[2] == 0 && $w[2] == 0)
  595. {
  596. $cf[2] += $f[2];
  597. $hbf[$w[0].$w2] = implode("|",$cf);
  598. $cw[1] += $f[2];
  599. $hbw[$w[0].$w2] = implode("-",$cw);
  600. }
  601. else
  602. {
  603. $hbw[] = $hbcfw[$i];
  604. $hbf[] = $hbcff[$i];
  605. }
  606. }
  607. }
  608. if($c > 0)
  609. {
  610. $post['fpdata'] = implode(";",$hbf).';';
  611. $post['whlabel'] = '|'.implode("|",$hbw).'|';
  612. }
  613. //合并重复项结束
  614. //非占单设置为禁止占单开始
  615. $hbw = explode('|',trim($post['whlabel'],'|'));
  616. $hbf = explode(';',trim($post['fpdata'],';'));
  617. foreach ($hbw as $k=>$val)
  618. {
  619. $w = explode('-',$val);
  620. $f = explode('|',$hbf[$k]);
  621. if(!isset($w[2]) || $w[2] == 0)
  622. {
  623. $w[2] = "DNOTO";
  624. $f[9] = "DNOTO";
  625. $hbf[$k] = implode("|",$f);
  626. $hbw[$k] = implode("-",$w);
  627. }
  628. }
  629. $post['fpdata'] = implode(";",$hbf).';';
  630. $post['whlabel'] = '|'.implode("|",$hbw).'|';
  631. //非占单设置为禁止占单结束
  632. //查询净重开始
  633. $post['jweight'] = $this->weight->get_weightcx($post['fpdata']);
  634. $post['zzl'] = ($post['jweight']+100)/1000;
  635. if($post['express'] == 2)
  636. {
  637. $post['zzl'] = intval(($post['jweight']+100)*0.035);
  638. }
  639. //查询净重结束
  640. $tjid = $this->fullorder->insert($post);
  641. if($post['email'] == '')
  642. {
  643. $post['email'] = $post['name'].'@qq.com';
  644. }
  645. $adrs = $this->customer->get_email($post['email'],$post['shop']);
  646. preg_match_all('/[0-9]/u',$post['phone'],$result);
  647. $numphone = join('',$result[0]);
  648. $hmdaddress1 = str_replace(array(' parkway',' drive',' street',' road',' avenue',' boulevard',' alley',' court',' place',' lane',' manor',' terrace',' trail',' view',' cove'),array(' pkwy',' dr',' st',' rd',' av',' blvd',' aly',' ct',' pl',' ln',' mnr',' ter',' trl',' vw',' cv'),strtolower($post['address']));
  649. $hmdaddress2 = str_replace(array(' pkwy',' dr',' st',' rd',' av',' blvd',' aly',' ct',' pl',' ln',' mnr',' ter',' trl',' vw',' cv'),array(' parkway',' drive',' street',' road',' avenue',' boulevard',' alley',' court',' place',' lane',' manor',' terrace',' trail',' view',' cove'),strtolower($post['address']));
  650. $hmdaddress3 = str_replace(array(' avenue',' ave',' av'),array(' ave',' avenue',' ave'),strtolower($post['address']));
  651. $hmdid = '';
  652. $customerb = $this->customer->find_all("type = 2 and (email = '".$post['email']."' or address = '".$post['address']."' or address = '".$hmdaddress1."' or address = '".$hmdaddress2."' or address = '".$hmdaddress3."' or numphone = '".$numphone."')",'*','id desc');
  653. $lkh = (isset($customerb[0]['id']))?2:1;//白名单1黑名单2
  654. if($lkh == 2)
  655. {
  656. $hmdid = $customerb[0]['id'].'-('.$post['email'].'|'.$post['address'].'|'.$numphone.')'.'('.$customerb[0]['email'].'|'.$customerb[0]['address'].$customerb[0]['numphone'].')';
  657. }
  658. if($adrs)
  659. {
  660. $pdlkh = 1;//这个是判断是否老客户
  661. $this->customer->save(array('time'=>$post['dtime'],'num'=>$adrs['num']+1,'money'=>$adrs['money']+$post['shouldmoney']),$adrs['id']);
  662. $khid = $adrs['id'];
  663. }
  664. else
  665. {
  666. $str = $post['phone'];
  667. preg_match_all('/[0-9]/u',$str,$result);
  668. $numphone = join('',$result[0]);
  669. $ct['shop'] = $post['shop'];
  670. $ct['source'] = 10;
  671. $ct['level'] = 5;
  672. $ct['country'] = $post['country'];
  673. $ct['time'] = $post['dtime'];
  674. $ct['num'] = 1;
  675. $ct['money'] = $post['shouldmoney'];
  676. $ct['zipcode'] = $post['zipcode'];
  677. $ct['name'] = $post['name'];
  678. $ct['phone'] = $post['phone'];
  679. $ct['numphone'] = $numphone;
  680. $ct['email'] = preg_replace('/( | | |\s)+/','',$post['email']);
  681. $ct['province'] = $post['province'];
  682. $ct['city'] = $post['city'];
  683. $ct['address'] = $post['address'];
  684. $ct['zhcx'] = $post['shop'].'-'.$ct['email'];
  685. $khid = $this->customer->insert($ct);
  686. $pdlkh = 0;
  687. }
  688. $this->_znxc($post,$order_id,$lkh,$pdlkh,$hmdid);
  689. /**
  690. if($post['shop'] == '1' || $post['shop'] == '2' || $post['shop'] == '6' || $post['shop'] == '5')
  691. {
  692. $this->_znxc($post,$order_id,$lkh);
  693. }
  694. else
  695. {
  696. $this->_znx($post,$order_id,$lkh);
  697. }
  698. **/
  699. }//else{}如果有此订单
  700. }
  701. }
  702. if ($this->db->trans_status() === FALSE)
  703. {
  704. $this->db->trans_commit();
  705. }
  706. else
  707. {
  708. $this->db->trans_commit();
  709. }
  710. usleep(50);//停留2秒
  711. }
  712. if($tb == 1)
  713. {
  714. echo json_encode(array('msg'=>'有店铺正在同步中,请5分钟后再试!','success'=>true));exit;
  715. }
  716. echo json_encode(array('msg'=>'OK!','success'=>true));exit;
  717. }
  718. }
  719. public function _tb()
  720. {
  721. $api = $this->input->get('api',true);
  722. if(isset($api) && $api = '89757')
  723. {
  724. $data = $this->fullorder->find_all('dlz < 1 and source != 1 and waybill != "" and dtime > "'.(time()-48*3600).'"');
  725. $dataorder = array();$datashop = array();$dataex = array();$datack = array();
  726. /* 店铺加入键值-j */
  727. $fshop = $this->shop->find_all('1=1');
  728. foreach ($fshop as $v)
  729. {
  730. $datashop[$v['id']] = $v;
  731. }
  732. /* 店铺加入键值-k */
  733. /* 快递加入键值-j */
  734. $fex = $this->express->find_all('1=1');
  735. foreach ($fex as $v)
  736. {
  737. $dataex[$v['id']] = $v;
  738. }
  739. /* 快递加入键值-k */
  740. /* 仓库加入键值-k */
  741. $fwh = $this->warehouse->find_all('1=1');
  742. foreach ($fwh as $v)
  743. {
  744. $datack[$v['id']] = $v;
  745. }
  746. /* 仓库加入键值-j */
  747. //$fs = $this->notice->get_ordertatus(216);//216成功状态
  748. foreach ($data as $v)
  749. {
  750. $ddh = substr($v['orderinfo'],1);
  751. $ydh = $v['waybill'];
  752. $xg = $v;//此订单数据
  753. $shop = $datashop[$xg['shop']];//此订单店铺
  754. $ex = $dataex[$xg['express']];//此订单快递
  755. $warehouse = $datack[$xg['type']];//此订单仓库
  756. $shopifyid = $v['shopify'];
  757. if($xg['shop'] < 7)
  758. {
  759. $xg['iscode'] = $ex['title'];
  760. $xg['url'] = $shop['shopname'];
  761. @$fs = $this->api->get_paypal($xg);
  762. $this->afspaypal->insert(array('number'=>$xg['number'],'cs'=>$fs));
  763. }
  764. $ms = $this->message->find_all("express like '%,".$xg['express'].",%'");
  765. if(!isset($ms[0]))
  766. {
  767. $ms = $this->message->read(2);
  768. }
  769. else
  770. {
  771. $ms = $ms[0];
  772. }
  773. $shopname = $shop['brandname']; //店铺名
  774. $buyername = $xg['bname']; //Bill Name
  775. $email_call = $shop['shopid']; //发货人邮箱;
  776. $phone = $shop['shopphone']; //发货人电话
  777. $track_type = $ex['title']; //快递名称
  778. $service = $ex['title']; //快递追踪名称
  779. $track_link = $ex['url']; //快递查询网址
  780. $logistics_number = $ydh; //运单号
  781. $t= array('%buyername%','%email_call%','%track_type%','%service%','%track_link%','%logistics_number%','%shop%','%phone%','%jtime%');
  782. $h= array($buyername,$email_call,$track_type,$service,$track_link,$logistics_number,$shopname,$phone,$ex['yjtime']);
  783. $remark = str_replace($t,$h,$ms['content']);
  784. @$gx = $this->api->get_gx($ddh,$ydh,$xg,$shop,$ex,$remark,$shopifyid);
  785. if(!isset($gx['res']))
  786. {
  787. continue;
  788. }
  789. $this->fullorder->save(array('dlz'=>$gx['res'],'state'=>$gx['state']),$v['id']);
  790. }
  791. }
  792. }
  793. //更新独立站运单信息
  794. public function _waybill($arg_array)
  795. {
  796. $where = "dlz < '1' and state = '207' and shop != '19' and ";
  797. if(date("H",time()) == '8' && date("i",time()) > '20' && date("i",time()) < '39')//USPS-USA单,已出库——使用模板3 每天早上8点半 触发发送【昨天早上7点-今天早上7点】出库的
  798. {
  799. $where .= "(express = '2' or express = '63' or express = '64') and librarytime > '".strtotime(date("Y-m-d 7:00:0",strtotime("-1 day")))."' and librarytime < '".strtotime(date("Y-m-d 7:00:0",time()))."'";
  800. $readid = 3;
  801. }
  802. else if(date("H",time()) == '21' && date("w",time()) != '0')//二、杭州联邦+杭州联邦-不报关,单独用一个模板—新模板2 每天晚上9点半 触发发送 【昨天晚上9:30——今天晚上9:30】出库的
  803. {
  804. if(date("w",time()) == '1')//周一执行:周六晚上9点半——周一晚上9点半 之间出库的
  805. {
  806. $where .= "(express = '24' or express = '31') and librarytime > '".strtotime(date("Y-m-d 21:00:0",strtotime("-2 day")))."' and librarytime < '".strtotime(date("Y-m-d 21:00:0",time()))."'";
  807. }
  808. else //周二到周六: 前一天晚上9点半——当天晚上9点半之间出库的
  809. {
  810. $where .= "(express = '24' or express = '31') and librarytime > '".strtotime(date("Y-m-d 21:00:0",strtotime("-1 day")))."' and librarytime < '".strtotime(date("Y-m-d 21:00:0",time()))."'";
  811. }
  812. $readid = 2;
  813. }
  814. else if(date("H",time()) == '19' && date("w",time()) != '0')//其他快递-使用模板1 DHL官方、UPS、DPEX 等系统里打印运单自动有运单号的,出库后当天晚上7点执行。
  815. {
  816. if(date("w",time()) == '1')//周一执行:周六晚上9点半——周一晚上9点半 之间出库的
  817. {
  818. $where .= "express != '2' and express != '24' and express != '31' and printtype = '1' and waybill != '' and librarytime > '".strtotime(date("Y-m-d 19:00:0",strtotime("-2 day")))."' and librarytime < '".strtotime(date("Y-m-d 19:00:0",time()))."'";
  819. }
  820. else //周二到周六: 前一天晚上9点半——当天晚上9点半之间出库的
  821. {
  822. $where .= "express != '2' and express != '24' and express != '31' and printtype = '1' and waybill != '' and librarytime > '".strtotime(date("Y-m-d 19:00:0",strtotime("-1 day")))."' and librarytime < '".strtotime(date("Y-m-d 19:00:0",time()))."'";
  823. }
  824. $readid = 1;
  825. }
  826. else
  827. {
  828. exit;
  829. }
  830. $dataorder = array();$datashop = array();$dataex = array();$datack = array();
  831. // 订单加入键值-k
  832. $fdata = $this->fullorder->find_all($where);//,'source,id,orderinfo,waybill,shop,express,type,msg,bname,state,client,name,phone,zipcode,address,email,shopify'
  833. //* 订单加入键值-j
  834. //* 店铺加入键值-j
  835. $fshop = $this->shop->find_all('1=1');
  836. foreach ($fshop as $v)
  837. {
  838. $datashop[$v['id']] = $v;
  839. }
  840. //* 店铺加入键值-k
  841. //* 快递加入键值-j
  842. $fex = $this->express->find_all('1=1');
  843. foreach ($fex as $v)
  844. {
  845. $dataex[$v['id']] = $v;
  846. }
  847. //* 快递加入键值-k
  848. //* 仓库加入键值-k
  849. $fwh = $this->warehouse->find_all('1=1');
  850. foreach ($fwh as $v)
  851. {
  852. $datack[$v['id']] = $v;
  853. }
  854. //* 仓库加入键值-j
  855. $i = 0;$j = 0;$ed = array();
  856. foreach ($fdata as $key=>$value)
  857. {
  858. if($value['source'] == 1)
  859. {
  860. $this->fullorder->save(array('dlz'=>3,'state'=>216),$value['id']);
  861. }
  862. else
  863. {
  864. $ddh = substr($value['orderinfo'],1);
  865. $ydh = $value['waybill'];
  866. $xg = $value;//此订单数据
  867. $shop = $datashop[$xg['shop']];//此订单店铺
  868. $ex = $dataex[$xg['express']];//此订单快递
  869. $warehouse = $datack[$xg['type']];//此订单仓库
  870. $shopifyid = $value['shopify'];
  871. if($xg['shop'] < 7)
  872. {
  873. $xg['iscode'] = $ex['title'];
  874. $xg['url'] = $shop['shopname'];
  875. @$fs = $this->api->get_paypal($xg);
  876. $this->afspaypal->insert(array('number'=>$xg['number'],'cs'=>$fs));
  877. }
  878. $ms = $this->message->find_all("express like '%,".$xg['express'].",%'");
  879. if(!isset($ms[0]))
  880. {
  881. $ms = $this->message->read(2);
  882. }
  883. else
  884. {
  885. $ms = $ms[0];
  886. }
  887. $shopname = $shop['brandname']; //店铺名
  888. $buyername = $xg['bname']; //Bill Name
  889. $email_call = $shop['shopid']; //发货人邮箱;
  890. $phone = $shop['shopphone']; //发货人电话
  891. $track_type = $ex['title']; //快递名称
  892. $service = $ex['title']; //快递追踪名称
  893. $track_link = $ex['url']; //快递查询网址
  894. $logistics_number = $ydh; //运单号
  895. $t= array('%buyername%','%email_call%','%track_type%','%service%','%track_link%','%logistics_number%','%shop%','%phone%','%jtime%');
  896. $h= array($buyername,$email_call,$track_type,$service,$track_link,$logistics_number,$shopname,$phone,$ex['yjtime']);
  897. $remark = str_replace($t,$h,$ms['content']);
  898. @$gx = $this->api->get_gx($ddh,$ydh,$xg,$shop,$ex,$remark,$shopifyid);
  899. if(!isset($gx['res']))
  900. {
  901. continue;
  902. }
  903. $this->fullorder->save(array('dlz'=>$gx['res'],'state'=>$gx['state']),$value['id']);
  904. }
  905. //sleep(4);
  906. }
  907. //同步更新 淘宝的运单号
  908. $this->_taobao();
  909. $this->_kcjc();
  910. }
  911. public function _taobao()
  912. {
  913. $data = $this->fullorder->find_all("shop = 19 and dlz != '3' and state = '207' and librarytime > 0");
  914. foreach ($data as $k=>$v)
  915. {
  916. $this->fullorder->save(array('dlz'=>3,'state'=>216),$v['id']);
  917. }
  918. }
  919. public function _kcjc()
  920. {
  921. $gethl = $this->whlabel->find_all("zd != '' and state = '0'");
  922. $b = array();
  923. foreach ($gethl as $k=>$v)
  924. {
  925. $a = $this->fullorder->get_number($v['zd']);
  926. if($a['librarytime'] > 0 && $a['library'] == 2)
  927. {
  928. //$b[] = array($v['sku'],$v['zd']);
  929. $this->whlabel->save(array('state'=>1,'orderinfo'=>$a['orderinfo'],'waybill'=>$a['waybill'],'outk'=>$a['librarytime'],'time'=>$a['librarytime']),$v['id']);
  930. }
  931. }
  932. }
  933. public function _waybillemail($arg_array)
  934. {
  935. $urls = array();$sl = 0;$time = time();
  936. /**
  937. if(date("H",time()) == '8' && date("i",time()) > '20' && date("i",time()) < '39')//USPS-USA单
  938. {
  939. $wid = 1;
  940. }
  941. else if(date("H",time()) == '22' && date("w",time()) != '0' && date("i",time()) > '20' && date("i",time()) < '39')//二、杭州联邦+杭州联邦-不报关
  942. {
  943. if(date("w",time()) == '1')//周一执行:周六晚上9点半——周一晚上9点半 之间出库的
  944. {
  945. $wid = 2;
  946. }
  947. else //周二到周六: 前一天晚上9点半——当天晚上9点半之间出库的
  948. {
  949. $wid = 3;
  950. }
  951. }
  952. else if(date("H",time()) == '20' && date("w",time()) != '0' && date("i",time()) > '20' && date("i",time()) < '39')//其他快递
  953. {
  954. if(date("w",time()) != '1')
  955. {
  956. $wid = 4;
  957. }
  958. else
  959. {
  960. $wid = 5;
  961. }
  962. }
  963. **/
  964. if(date("H",time()) == '8' && date("i",time()) > '20' && date("i",time()) < '39')//USPS-USA单
  965. {
  966. $wid = 1;
  967. }
  968. else if(date("H",time()) == '20' && date("i",time()) > '20' && date("i",time()) < '39')//其他快递
  969. {
  970. $wid = 2;
  971. }
  972. else
  973. {
  974. exit;
  975. }
  976. $notice = $this->notice->find_all("message = '1' and state = '1' and type = '4' and ktime < '$time' and jtime > '$time'");//已有自动发送,这个是物流发送
  977. foreach ($notice as $key=>$var)
  978. {
  979. $urls[] = array('url'=>'http://1.wepolicy.cn/api/waybillfs?v='.$var['id'],'data'=>array('var'=>$var,'wid'=>$wid));
  980. }
  981. foreach($urls as $value) {
  982. $ch = curl_init();
  983. $url = $value['url'];
  984. curl_setopt($ch,CURLOPT_URL,$url);
  985. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  986. curl_setopt($ch,CURLOPT_HEADER,0);
  987. curl_setopt($ch,CURLOPT_POST, 1);
  988. curl_setopt($ch,CURLOPT_TIMEOUT,1);
  989. //设置post数据
  990. $post = array();
  991. $post['data'] = $value['data'];
  992. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
  993. $res = curl_exec($ch);
  994. curl_close($ch);
  995. $sl++;
  996. }
  997. echo $sl;
  998. echo "<pre>";
  999. print_r($urls);
  1000. }
  1001. public function _waybillfs()
  1002. {
  1003. $post = $this->input->post(NULL, TRUE);
  1004. $data = $this->input->post('data',true);
  1005. if($data)
  1006. {
  1007. $notice = $data['var'];
  1008. $notice['email'] = $this->emaildata->read($notice['email']);
  1009. $wid = $data['wid'];
  1010. $fsjs = "";
  1011. if($wid == 1 && (stripos($notice['express'],',2,') !== false || stripos($notice['express'],',63,') !== false || stripos($notice['express'],',64,') !== false))
  1012. {
  1013. $js = explode(',',trim($notice['js'],','));
  1014. if(count($js) > 1)
  1015. {
  1016. $fsjs = " and (";
  1017. foreach ($js as $v)
  1018. {
  1019. $fsjs .= "js = '$v' or ";
  1020. }
  1021. $fsjs = trim($fsjs,' or ').")" ;
  1022. }
  1023. else if(count($js) == 1)
  1024. {
  1025. $fsjs = " and js = '$js[0]'";
  1026. }
  1027. $where = "(express = '2' or express = '63' or express = '64') and librarytime > '".strtotime(date("Y-m-d 8:30:0",strtotime("-6 day")))."' and librarytime < '".strtotime(date("Y-m-d 8:30:0",time()))."'".$fsjs;//3
  1028. }
  1029. /**
  1030. else if($wid == 2 && stripos($notice['express'],',1,') !== false)
  1031. {
  1032. $where = "(express = '24' or express = '31') and librarytime > '".strtotime(date("Y-m-d 22:00:0",strtotime("-6 day")))."' and librarytime < '".strtotime(date("Y-m-d 22:00:0",time()))."'";//4
  1033. }
  1034. else if($wid == 3 && stripos($notice['express'],',1,') !== false)
  1035. {
  1036. $where = "(express = '24' or express = '31') and librarytime > '".strtotime(date("Y-m-d 22:00:0",strtotime("-6 day")))."' and librarytime < '".strtotime(date("Y-m-d 22:00:0",time()))."'";//3
  1037. }
  1038. else if($wid == 4 && stripos($notice['express'],',1,') !== false)
  1039. {
  1040. $where = "express != '2' and express != '24' and express != '31' and printtype = '1' and waybill != '' and librarytime > '".strtotime(date("Y-m-d 20:00:0",strtotime("-6 day")))."' and librarytime < '".strtotime(date("Y-m-d 20:00:0",time()))."'";//3
  1041. }
  1042. else if($wid == 5 && stripos($notice['express'],',1,') !== false)
  1043. {
  1044. $where = "express != '2' and express != '24' and express != '31' and printtype = '1' and waybill != '' and librarytime > '".strtotime(date("Y-m-d 20:00:0",strtotime("-6 day")))."' and librarytime < '".strtotime(date("Y-m-d 20:00:0",time()))."'";//4
  1045. }
  1046. **/
  1047. else if($wid == 2 && stripos($notice['express'],',1,') !== false)
  1048. {
  1049. $where = "express != '2' and express != '63' and express != '64' and printtype = '1' and waybill != '' and librarytime > '".strtotime(date("Y-m-d 20:00:0",strtotime("-6 day")))."' and librarytime < '".strtotime(date("Y-m-d 20:00:0",time()))."'";//4
  1050. }
  1051. else
  1052. {
  1053. exit;
  1054. }
  1055. $wlfs = array();
  1056. $dd = $this->fullorder->find_all("source != '1' and dlzemail < '1' and shop = '".$notice['shop']."' and library = 2 and ".$where);
  1057. foreach ($dd as $v)
  1058. {
  1059. $shop = $this->shop->read($v['shop']);
  1060. $express = $this->express->read($v['express']);
  1061. $fs = $this->notice->get_god($v,$shop,$express,$notice);
  1062. if($fs == 1)
  1063. {
  1064. $this->fullorder->save(array('dlzemail'=>1,'dlzemailtime'=>time()),$v['id']);
  1065. //给crm发送信息 先存储数据 后续定时任务执行
  1066. if($v['shop'] < 10){
  1067. $this->zztmpdata->insert([
  1068. 'type'=>2,
  1069. 'act_name'=>'crm_order',
  1070. 'content'=>json_encode($v),
  1071. 'create_time'=>time()
  1072. ]);
  1073. }
  1074. }
  1075. else
  1076. {
  1077. //$pdtime = date('Y-m-d',time());
  1078. //$folderPath = './data/dlzemail/'.$pdtime; // 文件夹路径
  1079. //$permissions = 0777; // 权限设置
  1080. //if (!file_exists($folderPath)) { mkdir($folderPath, $permissions); }//创建文件夹
  1081. //file_exists($folderPath);
  1082. if(!is_file("./data/dlzemail/".$v['number'].".txt"))
  1083. {
  1084. $myfile = fopen("./data/dlzemail/".$v['number'].".txt", "w") or die("Unable to open file!");
  1085. fwrite($myfile, json_encode($fs.';'.$v.';'.$shop.';'.$express.';'.$notice));
  1086. fclose($myfile);
  1087. }
  1088. else
  1089. {
  1090. $myfile = fopen("./data/dlzemail/".$v['number'].".txt", "a+") or die("Unable to open file!");
  1091. fwrite($myfile, json_encode($fs.';'.$v.';'.$shop.';'.$express.';'.$notice));
  1092. fclose($myfile);
  1093. }
  1094. $this->fullorder->save(array('dlzemail'=>2,'dlzemailtime'=>time()),$v['id']);
  1095. }
  1096. sleep(50);
  1097. }
  1098. }
  1099. }
  1100. /**
  1101. //更新独立站运单信息
  1102. public function _waybill($arg_array)
  1103. {
  1104. //这里订单索引需要修改 8点是出已打印已出库 11点是已打印未出库
  1105. if(!isset($arg_array[0]) || !isset($arg_array[1]))
  1106. {
  1107. exit;
  1108. }
  1109. if(date("w",time()) == '0' && $arg_array[0] != '3')//非usps周日不更新
  1110. {
  1111. echo 7;exit;
  1112. }
  1113. if($arg_array[0] == 3)
  1114. {
  1115. $argarray = 2;
  1116. $typec = ' and express = 2 and printtime > "'.strtotime("-3 day").'"';//更新usps-usa快递的订单
  1117. }
  1118. else
  1119. {
  1120. $argarray = $arg_array[0];
  1121. $typec = ' and librarytime > "'.strtotime(date("Y-m-d 16:30:0",strtotime("-5 day"))).'" and librarytime < "'.strtotime(date("Y-m-d 18:0:0",time())).'"';//更新快递的订单
  1122. }
  1123. $dataorder = array();$datashop = array();$dataex = array();$datack = array();
  1124. // 订单加入键值-k
  1125. $fdata = $this->fullorder->find_all('state = "207" and print = "3" and dlz < "1" and libraryconfirm = "2" and library = "'.$argarray.'" and waybill != ""'.$typec,'source,id,orderinfo,waybill,shop,express,type,msg,bname,state,client,name,phone,zipcode,address,email');
  1126. //* 订单加入键值-j
  1127. //* 店铺加入键值-j
  1128. $fshop = $this->shop->find_all('1=1');
  1129. foreach ($fshop as $v)
  1130. {
  1131. $datashop[$v['id']] = $v;
  1132. }
  1133. //* 店铺加入键值-k
  1134. //* 快递加入键值-j
  1135. $fex = $this->express->find_all('1=1');
  1136. foreach ($fex as $v)
  1137. {
  1138. $dataex[$v['id']] = $v;
  1139. }
  1140. //* 快递加入键值-k
  1141. //* 仓库加入键值-k
  1142. $fwh = $this->warehouse->find_all('1=1');
  1143. foreach ($fwh as $v)
  1144. {
  1145. $datack[$v['id']] = $v;
  1146. }
  1147. //* 仓库加入键值-j
  1148. //$fs = $this->notice->get_ordertatus(216);//216成功状态
  1149. $i = 0;$j = 0;$ed = array();
  1150. foreach ($fdata as $key=>$value)
  1151. {
  1152. if($value['source'] == 1)
  1153. {
  1154. $this->fullorder->save(array('dlz'=>3,'state'=>216),$value['id']);
  1155. }
  1156. else
  1157. {
  1158. $ddh = substr($value['orderinfo'],1);
  1159. $ydh = $value['waybill'];
  1160. $xg = $value;//此订单数据
  1161. $shop = $datashop[$xg['shop']];//此订单店铺
  1162. $ex = $dataex[$xg['express']];//此订单快递
  1163. $warehouse = $datack[$xg['type']];//此订单仓库
  1164. //独立站地址更新订单状态、物流信息
  1165. if($arg_array[0] == 1)//23点更新用留言2
  1166. {
  1167. $readid = 2;
  1168. }
  1169. else if($arg_array[0] == 3)//7点更新用留言3
  1170. {
  1171. $readid = 3;
  1172. }
  1173. else //20点更新用默认留言(默认留言为1)
  1174. {
  1175. $readid = $xg['msg'];
  1176. }
  1177. @$gx = $this->api->get_gx($ddh,$ydh,$xg,$shop,$ex,$readid);
  1178. if(!isset($gx['res']))
  1179. {
  1180. exit;
  1181. }
  1182. $this->fullorder->save(array('dlz'=>$gx['res'],'state'=>$gx['state']),$xg['id']);
  1183. }
  1184. //if($gx['res'] == 1 && $fs)
  1185. //{
  1186. // $ck = $this->_email($fs['content'],$xg,$warehouse['company']);
  1187. //}
  1188. sleep(2);//停留2秒
  1189. }
  1190. }
  1191. **/
  1192. public function _headgear($arg_array)
  1193. {
  1194. $ip = $this->input->ip_address();
  1195. if(!isset($arg_array[0]) || !isset($arg_array[1]))
  1196. {
  1197. exit;
  1198. }
  1199. if(!is_numeric($arg_array[0]) || !is_numeric($arg_array[1]))
  1200. {
  1201. exit;
  1202. }
  1203. $where = 'printtime > "'.strtotime(date('Y-m-d',$arg_array[0])).'" and print = 3 and library = 1 and (type = 4 or type = 13 or type = 11 or type = 12 or type = 16)';//(type = 4 or type = 7)
  1204. if($arg_array[1] == 1)
  1205. {
  1206. $data = $this->fullordersmt->find_all($where,'express,number,orderinfo,shipremarks,printtime');
  1207. }
  1208. else
  1209. {
  1210. $data = $this->fullorder->find_all($where,'express,number,orderinfo,shipremarks,printtime');
  1211. }
  1212. foreach ($data as $k=>$v)
  1213. {
  1214. $express = $this->express->read($v['express']);
  1215. $data[$k]['express'] = $express['servicename'];
  1216. if($data[$k]['printtime'] > 0)
  1217. {
  1218. $data[$k]['printtime'] = date('Y-m-d H:i:s',$v['printtime']);
  1219. }
  1220. }
  1221. //$state = $this->api->get_headgear($data);
  1222. echo json_encode($data);
  1223. }
  1224. public function _kc_old()
  1225. {
  1226. $post = $this->input->post(NULL, TRUE);
  1227. if(isset($post['sku']))
  1228. {
  1229. $sku = $this->input->post('sku',true);
  1230. $warehouse = $this->warehouse->find_all();
  1231. $data = array();
  1232. foreach ($sku as $val)
  1233. {
  1234. $datasku = array();
  1235. foreach ($warehouse as $v)
  1236. {
  1237. $z = $this->whlabel->find_count('sku = "'.$val.'" and zd = "" and state = 0 and warehouse = "'.$v['id'].'"');
  1238. $datasku[] = array('name'=>$v['title'],'number'=>$z);
  1239. }
  1240. $data[$val] = $datasku;
  1241. }
  1242. }
  1243. echo json_encode($data);
  1244. }
  1245. public function _kc()
  1246. {
  1247. $datasku = array();
  1248. $info_list = $this->whlabel->find_pc("warehouse = '5'",'sku,features,warehouse','sku');
  1249. foreach ($info_list as $val)
  1250. {
  1251. $z = $this->whlabel->find_count('sku = "'.$val['sku'].'" and zd = "" and state = 0 and warehouse = "5"');
  1252. $datasku[] = array('sku'=>$val['sku'],'number'=>$z);
  1253. }
  1254. echo json_encode($datasku);
  1255. }
  1256. public function _fsstate()//订单消息页手动发送
  1257. {
  1258. $post = $this->input->post(NULL, TRUE);
  1259. if(isset($post['s']))
  1260. {
  1261. $id_arr = $this->input->post('s');
  1262. $notice = $this->input->post('notice');
  1263. $noticeid = $this->input->post('noticeid');
  1264. $id_arr = explode(',',trim($id_arr,','));
  1265. if(!$id_arr)
  1266. {
  1267. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  1268. }
  1269. if($notice == '1' || $notice == '')
  1270. {
  1271. foreach ($id_arr as $v)
  1272. {
  1273. $data = $this->fullorder->read($v);
  1274. $adrs = $this->customer->get_email($data['email'],$data['shop']);
  1275. //$lkh = ($adrs['type'] == 1)?1:2;//白名单1黑名单2
  1276. $lkh = 1;
  1277. $pdlkh = ($adrs['num'] > 1)?1:0;//判断是否老客户
  1278. $fs = $this->_znxc($data,$data['orderinfo'],$lkh,$pdlkh);
  1279. if($fs == 1)
  1280. {
  1281. $this->fullorder->save(array('exstateerror'=>''),$data['id']);
  1282. }
  1283. sleep(40);
  1284. }
  1285. }
  1286. else
  1287. {
  1288. foreach ($id_arr as $v)
  1289. {
  1290. $data = $this->fullorder->read($v);
  1291. $fs = $this->_sdfs($data,$noticeid);
  1292. sleep(40);
  1293. }
  1294. }
  1295. echo json_encode(array('msg'=>'发送完成!','id'=>$id_arr,'success'=>true));exit;
  1296. }
  1297. }
  1298. public function _fswaybillemail()//运单号通知页手动发送
  1299. {
  1300. $post = $this->input->post(NULL, TRUE);
  1301. if(isset($post['s']))
  1302. {
  1303. $time = time();
  1304. $id_arr = $this->input->post('s');
  1305. $id_arr = explode(',',trim($id_arr,','));
  1306. if(!$id_arr)
  1307. {
  1308. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  1309. }
  1310. foreach ($id_arr as $v)
  1311. {
  1312. $d = $this->fullorder->read($v);
  1313. $shop = $this->shop->read($d['shop']);
  1314. $ex = $this->express->read($d['express']);
  1315. $fs = $this->notice->find_all("shop = '".$d['shop']."' and message = '1' and state = '1' and type = '4' and ktime < '$time' and jtime > '$time'");
  1316. $fs = $fs[0];
  1317. $fs['email'] = $this->emaildata->read($fs['email']);
  1318. $ck = $this->notice->get_god($d,$shop,$ex,$fs);
  1319. if($ck == 1)
  1320. {
  1321. $this->fullorder->save(array('dlzemail'=>1,'dlzemailtime'=>time()),$v);
  1322. }
  1323. sleep(1);
  1324. }
  1325. echo json_encode(array('msg'=>'发送完成!请检查是否成功','id'=>$id_arr,'success'=>true));exit;
  1326. }
  1327. }
  1328. /**
  1329. public function _fsstate()//订单消息页手动发送 _znxc 针对模板对应类型发送
  1330. {
  1331. $post = $this->input->post(NULL, TRUE);
  1332. if(isset($post['s']))
  1333. {
  1334. $id_arr = $this->input->post('s');
  1335. $id_arr = explode(',',$id_arr);
  1336. if(!$id_arr)
  1337. {
  1338. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  1339. }
  1340. foreach ($id_arr as $v)
  1341. {
  1342. $data = $this->fullorder->read($v);
  1343. $adrs = $this->customer->get_email($data['email'],$data['shop']);
  1344. $lkh = ($adrs['type'] == 1)?1:2;//白名单1黑名单2
  1345. $fs = $this->_znxc($data,$data['orderinfo'],$lkh);
  1346. if($fs == 1)
  1347. {
  1348. $this->fullorder->save(array('exstateerror'=>''),$data['id']);
  1349. }
  1350. }
  1351. echo json_encode(array('msg'=>'发送完成!','id'=>$id_arr[0],'success'=>true));exit;
  1352. }
  1353. }
  1354. **/
  1355. public function _cangku()
  1356. {
  1357. $post = $this->input->post(NULL, TRUE);
  1358. if(isset($post['tk']))
  1359. {
  1360. $tk = $this->input->post('tk');
  1361. $tj = $this->input->post('tj');
  1362. $d = $this->fullorder->find_all("dtime > '$tk' and dtime < '$tj'");
  1363. $k = $this->customer->find_all("time > '$tk' and time < '$tj'");
  1364. echo json_encode(array('d'=>$d,'k'=>$k));exit;
  1365. }
  1366. }
  1367. public function _znxc($fullorder,$order_id,$lkh,$pdlkh,$hmdid='')
  1368. {
  1369. $time = time();
  1370. $sl = explode(';',$fullorder['quantity']);
  1371. $quantity = 0;
  1372. foreach ($sl as $v)
  1373. {
  1374. if($v > 1)
  1375. {
  1376. $quantity = 1;
  1377. }
  1378. }
  1379. $fid = $this->fullorder->get_orderinfo($order_id);
  1380. if($lkh == 2 || (count($sl) > 1 && $quantity == 1) || stripos($fullorder['address'],'PO ') !== false || stripos($fullorder['address'],'P.O.') !== false || stripos($fullorder['address'],'P. O.') !== false || stripos($fullorder['address'],'PO.') !== false || stripos($fullorder['address'],'P.O') !== false || stripos($fullorder['address'],' APO ') !== false)//如果是黑名单客户、多产品的、有用户留言的、包含PO BOX、包含APO //留言的正常发$fullorder['clientremarks'] != '' ||
  1381. {
  1382. $asdasd = 0;
  1383. if($lkh == 2)
  1384. {
  1385. $asdasd = 1;
  1386. }
  1387. if(count($sl) > 1 && $quantity == 1)
  1388. {
  1389. $asdasd = 2;
  1390. }
  1391. if(stripos($fullorder['address'],'PO ') !== false || stripos($fullorder['address'],'P.O.') !== false || stripos($fullorder['address'],'P. O.') !== false || stripos($fullorder['address'],'PO.') !== false || stripos($fullorder['address'],'P.O') !== false || stripos($fullorder['address'],' APO ') !== false)
  1392. {
  1393. $asdasd = 3;
  1394. }
  1395. $this->fullorder->save(array('content'=>$fid['content'].'黑名单客户、多产品的、包含PO BOX、包含APO的不发送-'.$asdasd.(($hmdid)?'['.$hmdid.']':''),'zdstate'=>$fid['zdstate'].'1-x|'),$fid['id']);//留言的现在正常发
  1396. return 'a';
  1397. }
  1398. else
  1399. {
  1400. if(count($sl) == '1' && $fullorder['quantity'] > 1)//如果item(产品)是1,但quantity大于等于2
  1401. {
  1402. $tab = 2;
  1403. }
  1404. else if($fullorder['shouldmoney'] > '400' && $fullorder['guarantee'] == 'Ineligible')//如果金额大于400美元并且无卖家保障
  1405. {
  1406. $tab = 1;
  1407. }
  1408. /**
  1409. else if(count($sl) == '1' && $fullorder['quantity'] > 1 && $fullorder['baddress'] != $fullorder['saddress'])//如果item(产品)是1,但quantity大于等于2并且Bill Address不等于Ship Address
  1410. {
  1411. $tab = 4;
  1412. }
  1413. else if($fullorder['baddress'] != $fullorder['saddress'])//如果Bill Address不等于Ship Address
  1414. {
  1415. $tab = 3;
  1416. }
  1417. **/
  1418. else//常规模板
  1419. {
  1420. $tab = 0;
  1421. }
  1422. $notice = $this->notice->find_all("shop = '".$fullorder['shop']."' and ordertatus = '".$fullorder['state']."' and tab = '$tab' and message = '1' and state = '1' and ktime < '$time' and jtime > '$time'");//有条件不同模板匹配
  1423. if(isset($notice[0]['content']))
  1424. {
  1425. if($pdlkh == '1' && $notice[0]['thq'] != ''&& $notice[0]['thh'] != '')//非常规和老客户模板,如果是老客户并且需要替换的话
  1426. {
  1427. $notice[0]['content'] = str_replace($notice[0]['thq'],$notice[0]['thh'],$notice[0]['content']);
  1428. }
  1429. $shop = $this->shop->read($fullorder['shop']);
  1430. //$express = $this->express->read($fullorder['express']);
  1431. //$service = $this->service->read($express['service']);
  1432. $country = $this->country->read($fullorder['country']);
  1433. $fullorder['country'] = $country['ename'];
  1434. //$express['servicename'] =$service['title'];//增加快递名称
  1435. $express = array();
  1436. $notice[0]['email'] = $this->emaildata->read($notice[0]['email']);
  1437. $go = $this->notice->get_god($fullorder,$shop,$express,$notice[0]);
  1438. if($go == 1)
  1439. {
  1440. $this->fullorder->save(array('content'=>$fid['content'].'自动发送-成功;','zdstate'=>$fid['zdstate'].$notice[0]['type'].'-'.$notice[0]['tab'].'|','exstateerror'=>''),$fid['id']);
  1441. return 1;
  1442. }
  1443. else
  1444. {
  1445. $this->fullorder->save(array('exstateerror'=>'自动发送失败1:'.date('Y-m-d H',time()).'-'.$go.'('.$notice[0]['type'].'-'.$notice[0]['message'].')'),$fid['id']);
  1446. }
  1447. }
  1448. else
  1449. {
  1450. $this->fullorder->save(array('exstateerror'=>'当前订单状态无匹配模板'),$fid['id']);
  1451. }
  1452. }
  1453. }
  1454. public function _sdfs($fullorder,$id)//手动发送信息
  1455. {
  1456. $time = time();
  1457. $notice = $this->notice->read($id);//无条件同模板匹配
  1458. $notice['email'] = $this->emaildata->read($notice['email']);
  1459. $shop = $this->shop->read($fullorder['shop']);
  1460. $express = $this->express->read($fullorder['express']);
  1461. if($notice['type'] == '1')
  1462. {
  1463. $fslx = 'tab';
  1464. $content = '自动发送';
  1465. $stripos = '1-';
  1466. }
  1467. else if ($notice['type'] == '2')
  1468. {
  1469. $fslx = 'logisticstatus';
  1470. $content = $notice['title'];
  1471. $stripos = $notice['type'].'-'.$notice[$fslx].'|';
  1472. }
  1473. if(stripos($fullorder['zdstate'],$stripos) === false && $fullorder['wltype'] == '0')//如果没发送过并且允许发送
  1474. {
  1475. $go = $this->notice->get_god($fullorder,$shop,$express,$notice);
  1476. if($go == 1)
  1477. {
  1478. if($notice['type'] == '1')
  1479. {
  1480. $this->fullorder->save(array('content'=>$fullorder['content'].$content.'-成功;','zdstate'=>$fullorder['zdstate'].$notice['type'].'-'.$notice[$fslx].'|','exstateerror'=>'','wlerror'=>''),$fullorder['id']);
  1481. }
  1482. else if ($notice['type'] == '2')
  1483. {
  1484. $this->fullorder->save(array('wlcontent'=>$fullorder['wlcontent'].$content.'-成功;','wlfstime'=>time(),'zdstate'=>$fullorder['zdstate'].$notice['type'].'-'.$notice[$fslx].'|','exstateerror'=>'','wlerror'=>''),$fullorder['id']);
  1485. }
  1486. return 1;
  1487. }
  1488. else
  1489. {
  1490. if($notice['type'] == '1')
  1491. {
  1492. $this->fullorder->save(array('exstateerror'=>$content.'发送失败1:'.date('Y-m-d H',time()).'-'.$go.'('.$notice['type'].'-'.$notice[$fslx].')'),$fullorder['id']);
  1493. }
  1494. else if ($notice['type'] == '2')
  1495. {
  1496. $this->fullorder->save(array('wlerror'=>$content.'发送失败2:'.date('Y-m-d H',time()).'-'.$go.'('.$notice['type'].'-'.$notice[$fslx].')'),$fullorder['id']);
  1497. }
  1498. }
  1499. }
  1500. }
  1501. public function _zz()
  1502. {
  1503. //$f = $this->fullorder->find_all("1=1",'wlfstime','wlfstime desc',0,2);
  1504. if(date("w") == '0')
  1505. {
  1506. exit;
  1507. }
  1508. $f17 = array();
  1509. $time = time();
  1510. $tjlike = array();
  1511. $urls = array();$sl = 0;
  1512. $notice = $this->notice->find_all("message = '1' and state = '1' and type = '2' and ktime < '$time' and jtime > '$time'");//已有自动发送,这个是物流发送
  1513. foreach ($notice as $key=>$var)
  1514. {
  1515. $urls[] = array('url'=>'http://a'.rand(10,50).'.wepolicy.cn/api/wlfs?v='.$var['id'],'data'=>array('where'=>array('shop'=>$var['shop'],'expressstate'=>$var['logisticstatus'],'wlcontent'=>$var['title']),'var'=>$var));
  1516. }
  1517. foreach($urls as $value) {
  1518. $tjlike[] = $value['url'];
  1519. $ch = curl_init();
  1520. $url = $value['url'];
  1521. curl_setopt($ch,CURLOPT_URL,$url);
  1522. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  1523. curl_setopt($ch,CURLOPT_HEADER,0);
  1524. curl_setopt($ch,CURLOPT_POST, 1);
  1525. curl_setopt($ch,CURLOPT_TIMEOUT,5);
  1526. //设置post数据
  1527. $post = array();
  1528. $post['data'] = $value['data'];
  1529. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
  1530. $res = curl_exec($ch);
  1531. curl_close($ch);
  1532. $sl++;
  1533. }
  1534. echo "<pre>";
  1535. print_r($tjlike);
  1536. echo $sl;
  1537. /**
  1538. $urls = array();
  1539. $notice = $this->notice->find_all("message = '1' and state = '1' and type = '2' and ktime < '$time' and jtime > '$time'");//已有自动发送,这个是物流发送
  1540. foreach ($notice as $key=>$var)
  1541. {
  1542. $urls[] = array('url'=>'http://1.wepolicy.cn/api/wlfs?v='.$var['id'],'data'=>array('where'=>array('shop'=>$var['shop'],'expressstate'=>$var['logisticstatus'],'wlcontent'=>$var['title']),'var'=>$var));
  1543. }
  1544. $mh = curl_multi_init();
  1545. $urlHandlers = array();
  1546. $urlData = array();
  1547. // 初始化多个请求句柄为一个
  1548. foreach($urls as $value) {
  1549. $ch = curl_init();
  1550. $url = $value['url'];
  1551. $url .= strpos($url, '?') ? '&' : '?';
  1552. curl_setopt($ch, CURLOPT_URL, $url);
  1553. // 设置数据通过字符串返回,而不是直接输出
  1554. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  1555. curl_setopt($ch,CURLOPT_HEADER,0);
  1556. curl_setopt($ch,CURLOPT_POST, 1);
  1557. $post = array();
  1558. $post['data'] = $value['data'];
  1559. curl_setopt($ch,CURLOPT_POSTFIELDS,http_build_query($post));
  1560. $urlHandlers[] = $ch;
  1561. curl_multi_add_handle($mh, $ch);
  1562. }
  1563. $active = null;
  1564. // 检测操作的初始状态是否OK,CURLM_CALL_MULTI_PERFORM为常量值-1
  1565. do {
  1566. // 返回的$active是活跃连接的数量,$mrc是返回值,正常为0,异常为-1
  1567. $mrc = curl_multi_exec($mh, $active);
  1568. } while ($mrc == CURLM_CALL_MULTI_PERFORM);
  1569. // 如果还有活动的请求,同时操作状态OK,CURLM_OK为常量值0
  1570. while ($active && $mrc == CURLM_OK) {
  1571. // 持续查询状态并不利于处理任务,每60ms检查一次,此时释放CPU,降低机器负载
  1572. usleep(50000);
  1573. // 如果批处理句柄OK,重复检查操作状态直至OK。select返回值异常时为-1,正常为1(因为只有1个批处理句柄)
  1574. if (curl_multi_select($mh) != -1) {
  1575. do {
  1576. $mrc = curl_multi_exec($mh, $active);
  1577. } while ($mrc == CURLM_CALL_MULTI_PERFORM);
  1578. }
  1579. }
  1580. // 获取返回结果
  1581. foreach($urlHandlers as $index => $ch) {
  1582. $urlData[$index] = curl_multi_getcontent($ch);
  1583. // 移除单个curl句柄
  1584. curl_multi_remove_handle($mh, $ch);
  1585. }
  1586. curl_multi_close($mh);
  1587. print_r($urlData);
  1588. **/
  1589. /**
  1590. $notice = $this->notice->find_all("message = '1' and state = '1' and type = '2' and ktime < '$time' and jtime > '$time'");//已有自动发送,这个是物流发送
  1591. foreach ($notice as $key=>$var)
  1592. {
  1593. $where = "shop = '".$var['shop']."' and waybill != '' and library = '2' and expressstate <= '".$var['logisticstatus']."' and librarytime > '".(time()-15*24*3600)."' and wlcontent not like '%".$var['title']."%'";//正式发送的时候开启这个"'
  1594. //$where = "shop = '2' and waybill != '' and library = '2' and librarytime > '".(time()-15*24*3600)."'";
  1595. $ch = curl_init();
  1596. curl_setopt($ch,CURLOPT_URL,'http://'.$_SERVER['HTTP_HOST'].'/api/wlfs?v='.$var['id']);
  1597. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  1598. curl_setopt($ch,CURLOPT_HEADER,0);
  1599. curl_setopt($ch,CURLOPT_POST, 1);
  1600. curl_setopt($ch,CURLOPT_TIMEOUT,1);
  1601. //设置post数据
  1602. $post = array();
  1603. $post['data'] = array('where'=>$where,'var'=>$var);
  1604. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
  1605. $res = curl_exec($ch);
  1606. curl_close($ch);
  1607. //$this->_wlfs($where,$var);
  1608. }
  1609. **/
  1610. /**
  1611. $var = $this->notice->read(63);//已有自动发送,这个是物流发送
  1612. $where = "shop = '".$var['shop']."' and waybill != '' and library = '2' and expressstate <= '".$var['logisticstatus']."' and librarytime > '".(time()-15*24*3600)."' and wlcontent not like '%".$var['title']."%'";//正式发送的时候开启这个"'
  1613. $this->_wlfs($where,$var);
  1614. **/
  1615. }
  1616. public function _wlfs()
  1617. {
  1618. $webhookregister = 0;
  1619. $post = $this->input->post(NULL, TRUE);
  1620. $data = $this->input->post('data',true);
  1621. $where = $data['where'];
  1622. $var = $data['var'];
  1623. $wlfs = array();
  1624. $shopid = $where['shop'];
  1625. @$this->allocation->insert(array('title'=>date('Y-m-d',time()).'-'.$shopid));
  1626. $where = "shop = '".$where['shop']."' and waybill != '' and library = '2' and expressstate <= '".$where['expressstate']."' and librarytime > '".(time()-22*24*3600)."' and wlcontent not like '%".$where['wlcontent']."%'";//正式发送的时候开启这个"'
  1627. //$where = "shop = '".$where['shop']."' and waybill != '' and library = '2' and express = '3' and librarytime > '1636300800' and wlcontent not like '%".$where['wlcontent']."%'";//正式发送的时候开启这个"'
  1628. $data = $this->fullorder->find_all($where);
  1629. $csck = array();
  1630. foreach ($data as $k=>$v)
  1631. {
  1632. $vexpress = $v['express'];
  1633. $shop = $this->shop->read($v['shop']);
  1634. $express = $this->express->read($v['express']);
  1635. $service = $this->service->read($express['service']);
  1636. $country = $this->country->read($v['country']);
  1637. $v['country'] = $country['ename'];
  1638. $express['servicename'] =$service['title'];//增加快递名称
  1639. $v['cxcode'] = strtolower($express['cxcode']);//增加快递服务商码
  1640. if($v['expressstate'] == $var['logisticstatus'] && $v['wlyc'] == '0' && $v['wltype'] != '1' && $v['source'] != '1')//获取快递状态等于模板状态、订单状态等于模板状态、出库时间大于-、未加入物流异常、允许发送邮件状态、非线下单
  1641. {
  1642. if($v['shop'] < '7')// && $v['shouldmoney'] > 100)
  1643. {
  1644. $wlfs[] = array('v'=>$v,'id'=>$var['id']);
  1645. //$go = $this->_sdfs($v,$var['id']);//更新顺带发送
  1646. }
  1647. continue;
  1648. }
  1649. if(($express['cxcode'] == '' && $v['exstateerror'] == '') || ($express['cxcode'] == '' && $v['exstateerror'] != ''))
  1650. {
  1651. continue;
  1652. }
  1653. else if($express['cxcode'] == 'usps')//$express['cxcode'] == 'fedex' || $express['cxcode'] == 'dhl' || $express['cxcode'] == 'cne' || $express['cxcode'] == 'dpex' || $express['cxcode'] == 'dpd'
  1654. {
  1655. /**
  1656. if($express['cxcode'] == 'dpex' || $express['cxcode'] == 'dpd')
  1657. {
  1658. $express['cxcode'] = 'cne';
  1659. }
  1660. **/
  1661. $logistics = $express['cxcode'];
  1662. }
  1663. else if(($express['cxcode'] == 'ups' && $v['webhookregister'] == 1) || $express['cxcode'] == '17track')
  1664. {
  1665. continue;
  1666. }
  1667. else if($express['cxcode'] == 'ups' && $v['webhookregister'] < 1)//使用webhook注册模式 || $express['cxcode'] == '17track'
  1668. {
  1669. $logistics = $express['cxcode'];
  1670. $webhookregister = 1;
  1671. }
  1672. else
  1673. {
  1674. //暂时不启用第三方,这里直接跳出
  1675. $this->fullorder->save(array('expressstate'=>'99'),$v['id']);
  1676. continue;
  1677. //$logistics = 'apismt';
  1678. //$v['express'] = strtolower($express['cxcode']);//替换为快递服务商码
  1679. }
  1680. $v['servicename'] =$service['title'];//增加快递名称
  1681. $v['url'] = $express['url'];//增加快递链接
  1682. @$fs = $this->$logistics->get_logistics($v);
  1683. $csck[] = array($v['number'],$fs['f'],$fs['content']);
  1684. if(!isset($fs['f']))
  1685. {
  1686. $fs = $this->$logistics->get_logistics($v);
  1687. if(!isset($fs['f']))
  1688. {
  1689. continue;
  1690. }
  1691. if($fs['f'] == '1')
  1692. {
  1693. $v['express'] = $vexpress;
  1694. if($fs['exstate'] > $v['expressstate'] || isset($fs['webhookregister']))
  1695. {
  1696. $this->fullorder->save(array('expressstate'=>$fs['exstate'],'excontent'=>$fs['data'],'webhookregister'=>$webhookregister,'wlerror'=>''),$v['id']);
  1697. }
  1698. if($fs['exstate'] == $var['logisticstatus'] && $v['wlyc'] == '0' && $v['wltype'] != '1' && $v['source'] != '1')//获取快递状态等于模板状态、订单状态等于模板状态、出库时间大于-、未加入物流异常、允许发送邮件状态、非线下单
  1699. {
  1700. if($v['shop'] < '7')// && $v['shouldmoney'] > 100)
  1701. {
  1702. $wlfs[] = array('v'=>$v,'id'=>$var['id']);
  1703. //$go = $this->_sdfs($v,$var['id']);//更新顺带发送
  1704. }
  1705. }
  1706. }
  1707. /**
  1708. if($logistics == 'apismt')//第三方未购买,第三方查询直接进入无法查询状态
  1709. {
  1710. $this->fullorder->save(array('expressstate'=>'99'),$v['id']);
  1711. }
  1712. **/
  1713. }
  1714. else
  1715. {
  1716. if($fs['f'] == '1')
  1717. {
  1718. $v['express'] = $vexpress;
  1719. if($fs['exstate'] > $v['expressstate'] || isset($fs['webhookregister']))
  1720. {
  1721. $this->fullorder->save(array('expressstate'=>$fs['exstate'],'excontent'=>$fs['data'],'webhookregister'=>$webhookregister,'wlerror'=>''),$v['id']);
  1722. }
  1723. if($fs['exstate'] == $var['logisticstatus'] && $v['wlyc'] == '0' && $v['wltype'] != '1' && $v['source'] != '1')//获取快递状态等于模板状态、订单状态等于模板状态、出库时间大于-、未加入物流异常、允许发送邮件状态、非线下单
  1724. {
  1725. if($v['shop'] < '7')// && $v['shouldmoney'] > 100)
  1726. {
  1727. $wlfs[] = array('v'=>$v,'id'=>$var['id']);
  1728. //$go = $this->_sdfs($v,$var['id']);//更新顺带发送
  1729. }
  1730. }
  1731. }
  1732. else
  1733. {
  1734. $this->fullorder->save(array('wlerror'=>$fs['content']),$v['id']);
  1735. }
  1736. }
  1737. }
  1738. @$this->allocation->insert(array('title'=>$shopid.'-'.json_encode($csck)));
  1739. if($wlfs)
  1740. {
  1741. foreach ($wlfs as $k=>$v)
  1742. {
  1743. $t1 = microtime(true);
  1744. $this->_sdfs($v['v'],$v['id']);
  1745. $t2 = microtime(true);
  1746. $t3 = (40-($t2-$t1) < 1)?1:round(40-($t2-$t1));
  1747. sleep($t3);
  1748. }
  1749. }
  1750. }
  1751. public function _zzold()
  1752. {
  1753. $data = $this->fullorder->find_all("library = '2' and waybill != '' and exstate != '4' and exstate != '5' and dtime > '1580486400'");
  1754. foreach ($data as $k=>$v)
  1755. {
  1756. $shop = $this->shop->read($v['shop']);
  1757. $express = $this->express->read($v['express']);
  1758. $service = $this->service->read($express['service']);
  1759. $country = $this->country->read($v['country']);
  1760. $v['country'] = $country['ename'];
  1761. $express['servicename'] =$service['title'];//增加快递名称
  1762. if($express['cxcode'] == '' && $v['exstateerror'] == '')
  1763. {
  1764. continue;
  1765. }
  1766. else if($express['cxcode'] == '' && $v['exstateerror'] != '')
  1767. {
  1768. continue;
  1769. }
  1770. else if($express['cxcode'] == 'fedex' || $express['cxcode'] == 'usps' || $express['cxcode'] == 'dhl' || $express['cxcode'] == 'cne' || $express['cxcode'] == 'dpex' || $express['cxcode'] == 'dpd')
  1771. {
  1772. $logistics = $express['cxcode'];
  1773. }
  1774. else
  1775. {
  1776. $logistics = 'apismt';
  1777. }
  1778. $v['express'] = strtolower($express['cxcode']);//替换为快递服务商码
  1779. $v['servicename'] =$service['title'];//增加快递名称
  1780. $v['url'] = $express['url'];//增加快递链接
  1781. $fs = $this->$logistics->get_logistics($v);
  1782. if(!isset($fs['f']))
  1783. {
  1784. $this->fullorder->save(array('exstate'=>'99'),$v['id']);
  1785. }
  1786. else
  1787. {
  1788. if($fs['f'] == '0')
  1789. {
  1790. $this->fullorder->save(array('excontent'=>$fs['content']),$v['id']);
  1791. }
  1792. if($fs['f'] == '2')
  1793. {
  1794. }
  1795. else
  1796. {
  1797. $this->fullorder->save(array('exstate'=>$fs['exstate'],'excontent'=>$fs['data']),$v['id']);
  1798. }
  1799. }
  1800. }
  1801. }
  1802. public function _query()
  1803. {
  1804. header('Access-Control-Allow-Origin: *');
  1805. $post = $this->input->post(NULL, TRUE);
  1806. if(isset($post['orderinfo']))
  1807. {
  1808. $list = array();
  1809. $orderinfo = $this->input->post('orderinfo',true);
  1810. $orderinfo = explode(',',trim($orderinfo,','));
  1811. foreach ($orderinfo as $v)
  1812. {
  1813. $exp="/^([0-9A-Za-z\\-_\\.]+)@([0-9a-z]+\\.[a-z]{2,3}(\\.[a-z]{2})?)$/i";
  1814. if(is_numeric($v) && mb_strlen($v) > 8)
  1815. {
  1816. $w = "orderinfo like '%$v%'";
  1817. }
  1818. else if(filter_var($v, FILTER_VALIDATE_EMAIL))
  1819. {
  1820. $w = "email like '%$v%'";
  1821. }
  1822. else
  1823. {
  1824. echo json_encode(array('site'=>0,'success'=>true));exit;
  1825. }
  1826. $data = $this->fullorder->find_all($w." and dtime > '1577811600'");
  1827. if(isset($data[0]))
  1828. {
  1829. if($data[0]['library'] != '2')
  1830. {
  1831. $list[] = array('orderinfo'=>$v,'site'=>1);
  1832. }
  1833. else if($data[0]['library'] == '2' && $data[0]['exstate'] == '99')
  1834. {
  1835. $list[] = array('orderinfo'=>$v,'site'=>2);
  1836. }
  1837. else if($data[0]['library'] == '2' && $data[0]['exstate'] != '99')
  1838. {
  1839. if($data[0]['excontent'] != '成功;' && $data[0]['excontent'] != '')
  1840. {
  1841. $list[] = array('orderinfo'=>$v,'site'=>3,'data'=>$data[0]['excontent']);
  1842. }
  1843. else
  1844. {
  1845. $list[] = array('orderinfo'=>$v,'site'=>2);
  1846. }
  1847. }
  1848. }
  1849. else
  1850. {
  1851. $list[] = array('orderinfo'=>$v,'site'=>0);
  1852. }
  1853. }
  1854. echo json_encode(array('t'=>count($orderinfo),'list'=>$list,'success'=>true));exit;
  1855. }
  1856. }
  1857. public function _logistics()
  1858. {
  1859. if(isset($_GET['waybill']))
  1860. {
  1861. $waybill = $this->input->get('waybill',true);
  1862. $s = $this->input->get('shop',true);
  1863. //$express = $this->input->get('express',true);
  1864. $data = $this->fullorder->get_waybill($waybill);
  1865. if(isset($data['excontent']) && $data['excontent'] != '')
  1866. {
  1867. //$a = $this->$express->get_logistics(array('waybill'=>$waybill));
  1868. echo json_encode(array('track'=>array('f'=>1,'data'=>$data['excontent']),'msg'=>'','success'=>1));exit;
  1869. }
  1870. else
  1871. {
  1872. $shop = $this->shop->get_shopname($s);
  1873. if(!$shop)
  1874. {
  1875. echo json_encode(array('track'=>'','msg'=>'No logistics information','success'=>0));exit;
  1876. }
  1877. $data = $this->fullorder->get_orderinfo($shop.$waybill);
  1878. if(isset($data['excontent']) && $data['excontent'] != '')
  1879. {
  1880. echo json_encode(array('track'=>array('f'=>1,'data'=>$data['excontent']),'msg'=>'','success'=>1));exit;
  1881. }
  1882. echo json_encode(array('track'=>'','msg'=>'No logistics information','success'=>0));exit;
  1883. }
  1884. }
  1885. }
  1886. public function _klarna()
  1887. {
  1888. $shop = array();$cg = array();$sb = array();
  1889. $ftime = strtotime(date("Y-m-d 0:00:0",strtotime("-10 day")))+8*3600;
  1890. $ttime = strtotime(date("Y-m-d 8:00:0",time()));
  1891. $shopdata = $this->shop->find_all("type = '269' and klarnaname != '' and klarnapass != ''");
  1892. foreach($shopdata as $v)
  1893. {
  1894. $data = $this->fullorder->find_all("paypal like '%-%-%-%' and librarytime > '$ftime' and librarytime < '$ttime' and pay = '23' and library = '2' and source != '1' and klarna < '2' and shop = '".$v['id']."'","id,number,orderinfo,paypal,shouldmoney,shop");
  1895. foreach($data as $val)
  1896. {
  1897. $api = $this->_klarnaapi($val['paypal'],$val['shouldmoney'],$v['klarnaname'],$v['klarnapass']);
  1898. $header = $api['header'];
  1899. $api = $api['res'];
  1900. if(isset($api['error_messages'][0]))
  1901. {
  1902. if(stripos($api['error_messages'][0],'amount is 0 for') !== false)
  1903. {
  1904. $this->fullorder->save(array('klarna'=>3),$val['id']);
  1905. $sb[] = array($val['number'],$val['orderinfo'],'oooo3');
  1906. }
  1907. else
  1908. {
  1909. $this->fullorder->save(array('klarna'=>1,'klarnaerror'=>$api['error_messages'][0]),$val['id']);
  1910. $sb[] = array($val['number'],$val['orderinfo'],'oooo1');
  1911. }
  1912. }
  1913. else if($api == '')
  1914. {
  1915. if(isset($header['http_code']) && $header['http_code'] == 201)
  1916. {
  1917. $this->fullorder->save(array('klarna'=>2),$val['id']);
  1918. $cg[] = array($val['number'],$val['orderinfo'],'oooo2');
  1919. }
  1920. else
  1921. {
  1922. $this->fullorder->save(array('klarna'=>1,'klarnaerror'=>'未知错误'),$val['id']);
  1923. $sb[] = array($val['number'],$val['orderinfo'],'oooo0');
  1924. }
  1925. }
  1926. else if(isset($api['cs']))
  1927. {
  1928. $this->fullorder->save(array('klarna'=>1,'klarnaerror'=>'超时'),$val['id']);
  1929. $sb[] = array($val['number'],$val['orderinfo'],'oooo0');
  1930. }
  1931. else
  1932. {
  1933. $this->fullorder->save(array('klarna'=>1,'klarnaerror'=>'未知错误'),$val['id']);
  1934. $sb[] = array($val['number'],$val['orderinfo'],'oooo0');
  1935. }
  1936. }
  1937. }
  1938. echo "<pre>";
  1939. print_r($cg);
  1940. echo "<pre>";
  1941. print_r($sb);
  1942. }
  1943. public function _klarnaapi($paypal,$shouldmoney,$name,$pass)
  1944. {
  1945. $url = 'https://api-na.klarna.com/ordermanagement/v1/orders/'.$paypal.'/captures';
  1946. $data = '{"captured_amount": '.str_replace('.','',$shouldmoney).'}';
  1947. $header[] = "Content-Type:application/json";
  1948. $header[] = "Authorization: Basic ".base64_encode($name.":".$pass);
  1949. $ch = curl_init();
  1950. curl_setopt($ch, CURLOPT_URL, $url);
  1951. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  1952. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  1953. curl_setopt($ch, CURLINFO_HEADER_OUT, TRUE);
  1954. curl_setopt($ch, CURLOPT_POST, 1);
  1955. curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  1956. curl_setopt($ch, CURLOPT_TIMEOUT, 20);
  1957. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  1958. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  1959. $res = curl_exec($ch);
  1960. $header = curl_getinfo($ch);
  1961. if($res === false)
  1962. {
  1963. if(curl_errno($ch))
  1964. {
  1965. return array('res'=>'1','header'=>'','cs'=>1);
  1966. }
  1967. }
  1968. else
  1969. {
  1970. $res = json_decode($res,true);
  1971. return array('res'=>$res,'header'=>$header);
  1972. }
  1973. curl_close($ch);
  1974. }
  1975. public function _klarnadata($paypal,$name,$pass)
  1976. {
  1977. $url = 'https://api-na.klarna.com/ordermanagement/v1/orders/'.$paypal;
  1978. $header[] = "Content-Type:application/json";
  1979. $header[] = "Authorization: Basic ".base64_encode($name.":".$pass);
  1980. $ch = curl_init();
  1981. curl_setopt($ch, CURLOPT_URL, $url);
  1982. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  1983. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  1984. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  1985. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  1986. $res = curl_exec($ch);
  1987. curl_close($ch);
  1988. $res = json_decode($res,true);
  1989. $data = '';
  1990. if(isset($res['fraud_status']))
  1991. {
  1992. $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'];
  1993. }
  1994. return $data;
  1995. }
  1996. public function _hqpaypal()
  1997. {
  1998. $shop = $this->shop->find_all("paypalname != ''");
  1999. foreach ($shop as $val)
  2000. {
  2001. $d = $this->fullorder->find_all("shop = '".$val['id']."' and dtime > '".(time()-(5*24*3600))."' and dtime < '".(time()-(3*3600))."' and (pay = '22' || pay = '7') and klarnadata = ''");
  2002. foreach ($d as $v)
  2003. {
  2004. $paypal = $this->paypal->data($v['paypal'],$val);
  2005. if($paypal != '')
  2006. {
  2007. $this->fullorder->save(array('klarnadata'=>$paypal),$v['id']);
  2008. }
  2009. }
  2010. }
  2011. }
  2012. public function _hqstripe()
  2013. {
  2014. $shop = $this->shop->find_all("stripe != ''");
  2015. foreach ($shop as $val)
  2016. {
  2017. $d = $this->fullorder->find_all("shop = '".$val['id']."' and dtime > '".(time()-(5*24*3600))."' and dtime < '".time()."' and pay = '1211' and klarnadata = ''");
  2018. foreach ($d as $v)
  2019. {
  2020. $paypal = $this->_stripe($v['paypal'],$val['stripe']);
  2021. if($paypal != '')
  2022. {
  2023. $this->fullorder->save(array('klarnadata'=>$paypal),$v['id']);
  2024. }
  2025. }
  2026. }
  2027. }
  2028. public function _stripe($pay,$stripe)
  2029. {
  2030. $url = 'https://api.stripe.com/v1/payment_intents/'.$pay;
  2031. $header[] = "Authorization:Bearer ".$stripe;
  2032. $ch = curl_init();
  2033. curl_setopt($ch, CURLOPT_URL, $url);
  2034. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  2035. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  2036. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  2037. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  2038. $res = curl_exec($ch);
  2039. curl_close($ch);
  2040. $res = json_decode($res,true);
  2041. $k = '';
  2042. if(isset($res['shipping']['name']))
  2043. {
  2044. $line = ($res['shipping']['address']['line2'] != '')?$res['shipping']['address']['line1'].' '.$res['shipping']['address']['line2']:$res['shipping']['address']['line1'];
  2045. $k = 'stripe|'.json_encode(array('name'=>$res['shipping']['name'],'email'=>$res['receipt_email'],'address'=>$line.','.$res['shipping']['address']['city'].','.$res['shipping']['address']['state'].','.$res['shipping']['address']['postal_code'].','.$res['shipping']['address']['country'].','.$res['shipping']['phone'],'shouldmoney'=>$res['amount']/100));
  2046. }
  2047. return $k;
  2048. }
  2049. public function _afterpay($paypal,$name,$pass)
  2050. {
  2051. $url = 'https://global-api.afterpay.com/v2/payments?ids='.$paypal;
  2052. $header[] = "Accept:application/json";
  2053. $header[] = "User-Agent: Readme.io API Simulator'";
  2054. $header[] = "Authorization: Basic ".base64_encode($name.":".$pass);
  2055. $ch = curl_init();
  2056. curl_setopt($ch, CURLOPT_URL, $url);
  2057. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  2058. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  2059. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  2060. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  2061. $res = curl_exec($ch);
  2062. curl_close($ch);
  2063. $res = json_decode($res,true);
  2064. $data = '';
  2065. if(isset($res['results'][0]['orderDetails']['consumer']['email']))
  2066. {
  2067. $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'];
  2068. $data = str_replace(',,',',',$data);
  2069. }
  2070. return $data;
  2071. }
  2072. public function _clearpay($paypal,$name,$pass)
  2073. {
  2074. $url = 'https://global-api.afterpay.com/v2/payments?ids='.$paypal;
  2075. $header[] = "Accept:application/json";
  2076. $header[] = "User-Agent: Readme.io API Simulator'";
  2077. $header[] = "Authorization: Basic ".base64_encode($name.":".$pass);
  2078. $ch = curl_init();
  2079. curl_setopt($ch, CURLOPT_URL, $url);
  2080. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  2081. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  2082. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  2083. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  2084. $res = curl_exec($ch);
  2085. curl_close($ch);
  2086. $res = json_decode($res,true);
  2087. $data = '';
  2088. if(isset($res['results'][0]['orderDetails']['consumer']['email']))
  2089. {
  2090. $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'];
  2091. $data = str_replace(',,',',',$data);
  2092. }
  2093. return $data;
  2094. }
  2095. public function _htmlstock()
  2096. {
  2097. if(isset($_GET['hq']))
  2098. {
  2099. $ProductsType = $this->typeclass->find_all("classid = '16' and hq = '1'",'id,title','sequence asc');
  2100. foreach ($ProductsType as $k=>$v)
  2101. {
  2102. if($v['title'] == 'Closure')
  2103. {
  2104. $ProductsType[$k]['title'] = 'Closure/Frontal';
  2105. }
  2106. }
  2107. $HairColor = $this->typeclass->find_all("classid = '8' and hq = '1'",'id,title','sequence asc');
  2108. $HairWavy = $this->typeclass->find_all("classid = '15' and hq = '1'",'id,title','sequence asc');
  2109. $WigType = $this->typeclass->find_all("classid = '18' and hq = '1'",'id,title','sequence asc');
  2110. $Length = $this->typeclass->find_all("classid = '14' and hq = '1'",'id,title','sequence asc');
  2111. echo json_encode(array('ProductsType'=>$ProductsType,'HairColor'=>$HairColor,'HairWavy'=>$HairWavy,'WigType'=>$WigType,'Length'=>$Length));exit;
  2112. //http://1.wepolicy.cn/api/htmlstock?hq=1
  2113. }
  2114. if(isset($_GET['page']))
  2115. {
  2116. $del = array();
  2117. $typeclass13 = $this->typeclass->find_all("classid = '13'");
  2118. $typeclass16 = $this->typeclass->find_all("classid = '16'");
  2119. foreach ($typeclass16 as $key=>$value)
  2120. {
  2121. foreach ($typeclass13 as $v)
  2122. {
  2123. $del[] = $value['title'].' '.$v['title'];
  2124. }
  2125. }
  2126. $page = $this->input->get('page',true);
  2127. $perpage = $this->input->get('perpage',true);
  2128. $category = $this->input->get('ProductsType',true);//类目
  2129. $color = $this->input->get('HairColor',true);//颜色
  2130. $lowe = $this->input->get('HairWavy',true);//花型
  2131. $lacetype = $this->input->get('WigType',true);//头套种类
  2132. $size = $this->input->get('Length',true);//长度
  2133. $title = $this->input->get('title',true);//传输文本
  2134. $warehouse = 5;
  2135. $state = $this->input->get('state',true);
  2136. $where = "warehouse = '5' and state = '0'";
  2137. if($category)
  2138. {
  2139. $where .= " and features like '%-$category-%'";
  2140. }
  2141. if($color)
  2142. {
  2143. $where .= " and features like '%-$color-%'";
  2144. }
  2145. if($lowe)
  2146. {
  2147. $where .= " and features like '%-$lowe-%'";
  2148. }
  2149. if($lacetype)
  2150. {
  2151. $where .= " and features like '%-$lacetype-%'";
  2152. }
  2153. if($size)
  2154. {
  2155. $where .= " and features like '%-$size-%'";
  2156. }
  2157. if($title)
  2158. {
  2159. $where .= " and title like '%$title%'";
  2160. }
  2161. $order_str = "id desc";
  2162. if(empty($page))
  2163. {
  2164. $start = 0;
  2165. $perpage = 1;
  2166. }
  2167. else
  2168. {
  2169. $start = ($page - 1)*$perpage;
  2170. }
  2171. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features,number',$order_str,$start,$perpage);
  2172. $data = array();
  2173. foreach ($info_list as $key=>$value)
  2174. {
  2175. $c = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "5" and features = "'.$value['features'].'" and zd = ""');
  2176. if($c > 1)
  2177. {
  2178. $data[] = array('Item'=>str_replace($del,'',$value['title']),'Stock'=>$c);
  2179. }
  2180. }
  2181. $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  2182. $pagenum = ceil($total/$perpage);
  2183. $over = $total-($start+$perpage);
  2184. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($data));//总数量,剩余数量,总页数,数据
  2185. echo json_encode($rows);exit;
  2186. ///api/htmlstock?page=1&perpage=50&ProductsType=&HairColor=&HairWavy=&WigType=&Length= //页数、每页数量、类目、颜色、花型、头套种类、尺寸
  2187. }
  2188. }
  2189. public function _zc17track()
  2190. {
  2191. $express = array();
  2192. $ex = $this->express->find_all("cxcode = '17track'");
  2193. foreach ($ex as $v)
  2194. {
  2195. $express[$v['id']] = $v['title'];
  2196. }
  2197. $time_threshold = time() - 12 * 24 * 3600;
  2198. $this->db->select('a.number, a.express,a.waybill');
  2199. $this->db->from('crowd_fullorder as a');
  2200. $this->db->join('express as b', 'a.express = b.id', 'inner');
  2201. $this->db->where('a.waybill !=', '');
  2202. $this->db->where('a.library', '2');
  2203. $this->db->where('a.librarytime >', $time_threshold);
  2204. $this->db->where('a.webhookregister <', 1);
  2205. $this->db->where('b.cxcode', '17track');
  2206. $query = $this->db->get();
  2207. $data = $query->result_array();
  2208. $fsdata = array();
  2209. foreach ($data as $v)
  2210. {
  2211. if(!isset($express[$v['express']]))
  2212. {
  2213. continue;
  2214. }
  2215. if(stripos($express[$v['express']],'DHL') !== false)
  2216. {
  2217. $fsdata[] = array('number'=>$v['waybill'],'carrier'=>'100001');
  2218. }
  2219. else if(stripos($express[$v['express']],'UPS') !== false)
  2220. {
  2221. $fsdata[] = array('number'=>$v['waybill'],'carrier'=>'100002');
  2222. }
  2223. else if(stripos($express[$v['express']],'FEDEX') !== false)
  2224. {
  2225. $fsdata[] = array('number'=>$v['waybill'],'carrier'=>'100003');
  2226. }
  2227. else
  2228. {
  2229. $fsdata[] = array('number'=>$v['waybill'],'auto_detection'=>'true');
  2230. }
  2231. }
  2232. $fsdata = array_chunk($fsdata, 40);
  2233. $logistics = '17track';
  2234. foreach ($fsdata as $v)
  2235. {
  2236. $fs = $this->$logistics->get_logistics(json_encode($v));
  2237. if(isset($fs['f']))
  2238. {
  2239. $csck[] = array($v,$fs['f'],$fs['content']);
  2240. foreach ($v as $val)
  2241. {
  2242. $d = $this->fullorder->get_waybill($val['number']);
  2243. if($fs['f'] == '1')
  2244. {
  2245. $this->fullorder->save(array('webhookregister'=>1,'wlerror'=>''),$d['id']);
  2246. }
  2247. else
  2248. {
  2249. $this->fullorder->save(array('wlerror'=>$fs['content']),$d['id']);
  2250. }
  2251. }
  2252. }
  2253. else
  2254. {
  2255. $csck[] = array($v,'CW',"CS");
  2256. }
  2257. sleep(3);
  2258. }
  2259. @$this->allocation->insert(array('title'=>json_encode($csck)));
  2260. /**
  2261. $data = $this->fullorder->find_all("waybill != '' and library = '2' and librarytime > '".(time()-12*24*3600)."' and webhookregister < 1");
  2262. $csck = array();
  2263. foreach ($data as $k=>$v)
  2264. {
  2265. $express = $this->express->read($v['express']);
  2266. $service = $this->service->read($express['service']);
  2267. $v['servicename'] =$service['title'];//增加快递名称
  2268. $v['url'] = $express['url'];//增加快递链接
  2269. $logistics = '17track';
  2270. $fs = $this->$logistics->get_logistics($v);
  2271. if(isset($fs['f']))
  2272. {
  2273. $csck[] = array($v['number'],$fs['f'],$fs['content']);
  2274. if($fs['f'] == '1')
  2275. {
  2276. $this->fullorder->save(array('webhookregister'=>1,'wlerror'=>''),$v['id']);
  2277. }
  2278. else
  2279. {
  2280. $this->fullorder->save(array('wlerror'=>$fs['content']),$v['id']);
  2281. }
  2282. }
  2283. else
  2284. {
  2285. $csck[] = array($v['number'],'CW',"CS");
  2286. }
  2287. sleep(1);
  2288. }
  2289. @$this->allocation->insert(array('title'=>$shopid.'-'.json_encode($csck)));
  2290. **/
  2291. }
  2292. public function _17track()
  2293. {
  2294. $xq = array();
  2295. $j = file_get_contents('PHP://input');
  2296. $j = json_decode($j, true);
  2297. $j = $j['data'];
  2298. $express = array();
  2299. $expressdata = $this->express->find_all('1=1');
  2300. foreach ($expressdata as $v)
  2301. {
  2302. $express[$v['id']] = $v['title'];
  2303. }
  2304. //$sh = hash("sha256",$j['event'].'/'.json_encode($j).'/0811AC1711EAABB7D764D04B824F8C2D');
  2305. $f = 'fullorder';
  2306. $d = $this->fullorder->get_waybill($j['number']);
  2307. if(!$d)
  2308. {
  2309. $f = 'fullordersmt';
  2310. $d = $this->fullordersmt->get_waybill($j['number']);
  2311. if(!$d)
  2312. {
  2313. $f = 'fullordertt';
  2314. $d = $this->fullordertt->get_waybill($j['number']);
  2315. }
  2316. }
  2317. if(!$d)
  2318. {
  2319. exit;
  2320. }
  2321. $state = '';
  2322. $zxzt = array_reverse($j['track_info']['milestone']);
  2323. foreach ($zxzt as $v)
  2324. {
  2325. if($v['time_iso'] != NULL)
  2326. {
  2327. $state = $v['key_stage'];
  2328. break;
  2329. }
  2330. }
  2331. $exstate = 0;//无信息
  2332. if($state == 'InfoReceived' || $state == 'PickedUp' || $state == 'Departure' || $state == 'Arrival')//运输途中
  2333. {
  2334. $exstate = 3;//在途中
  2335. }
  2336. else if($state == 'OutForDelivery')//派送中
  2337. {
  2338. $exstate = 4;
  2339. }
  2340. else if($state == 'Returned' || $zxzt == 'Returning')//投递失败
  2341. {
  2342. $exstate = 1;//派送异常
  2343. }
  2344. else if($state == 'Delivered')//成功签收
  2345. {
  2346. $exstate = 6;//签收
  2347. }
  2348. $pd = array();$xq = '';
  2349. if(isset($j['track_info']['tracking']['providers'][0]['events']))
  2350. {
  2351. foreach ($j['track_info']['tracking']['providers'][0]['events'] as $k=>$v)
  2352. {
  2353. if($k == 0)
  2354. {
  2355. $pd = $v['description'];
  2356. }
  2357. $xq .= date('Y-m-d H:i:s',strtotime($v['time_iso'])).' ['.$v['location'].'] '.$v['description'].'<br />';// a日期 c地址 z状态
  2358. }
  2359. if(stripos($express[$d['express']],'Fedex') !== false && stripos($pd,'International shipment release - Import') !== false)
  2360. {
  2361. $exstate = 4;//即将派送
  2362. }
  2363. else if(stripos($express[$d['express']],'DHL') !== false && stripos($pd,'Clearance processing complete') !== false)
  2364. {
  2365. $exstate = 4;//即将派送
  2366. }
  2367. else if(stripos($express[$d['express']],'UPS') !== false && stripos($pd['c'],'Louisville, KY, US') !== false && stripos($pd,'Departed from Facility') !== false)
  2368. {
  2369. $exstate = 4;//即将派送
  2370. }
  2371. else if(stripos($express[$d['express']],'GES') !== false && stripos($pd,'Shipment picked up') !== false)
  2372. {
  2373. $exstate = 4;//即将派送
  2374. }
  2375. else if(stripos($pd,'Delivery exception') !== false || stripos($pd,'Addressee Unknown') !== false || stripos($pd,'Delivered to Agent for Final Delivery') !== false || stripos($pd,'Reminder to pick up your item') !== false || stripos($pd,'Available for Pickup') !== false || stripos($pd,'Processing Exception') !== false || stripos($pd,'Return to Sender Processed') !== false || stripos($pd,'Redelivery Scheduled') !== false || stripos($pd,'Notice Left') !== false || stripos($pd,'Delivery attempted but no response at Consignee address') !== false || stripos($pd,'Delivery attempt could not be completed') !== false || stripos($pd,'Forwarded to a third party agent') !== false || stripos($pd,'Awaiting collection by the consignee') !== false || stripos($pd,'Consignee has moved from the address provided') !== false || stripos($pd,'awaiting customer pickup') !== false)
  2376. {
  2377. $exstate = 1;//异常
  2378. }
  2379. }
  2380. $awlgx = $this->awlgx->get_number($d['number']);
  2381. if($awlgx)
  2382. {
  2383. $this->awlgx->save(array("content"=>$xq,"time"=>time(),'exstate'=>$exstate,'type'=>$f),$awlgx['id']);
  2384. }
  2385. else
  2386. {
  2387. $this->awlgx->insert(array("number"=>$d['number'],"content"=>$xq,"time"=>time(),'exstate'=>$exstate,'type'=>$f));
  2388. }
  2389. if($xq != '')
  2390. {
  2391. $this->$f->save(array('expressstate'=>$exstate,'excontent'=>$xq),$d['id']);
  2392. $time = time();
  2393. if($f == 'fullorder')
  2394. {
  2395. $notice = $this->notice->find_all("message = '1' and state = '1' and type = '2' and ktime < '$time' and jtime > '$time' and shop = '".$d['shop']."' and logisticstatus = '".$exstate."'");
  2396. if($notice && $d['wlyc'] == '0' && $d['wltype'] != '1' && $d['source'] != '1' && stripos($d['wlcontent'],$notice[0]['title']) === false)
  2397. {
  2398. $this->_sdfs($d,$notice[0]['id']);
  2399. //给crm发送信息 先存储数据 后续定时任务执行
  2400. if($d['shop'] < 10){
  2401. //派送中
  2402. if($exstate == 4){
  2403. $this->zztmpdata->insert([
  2404. 'type'=>3,
  2405. 'act_name'=>'crm_order',
  2406. 'content'=>json_encode($d),
  2407. 'create_time'=>time()
  2408. ]);
  2409. }
  2410. //签收完成
  2411. if($exstate == 6){
  2412. $this->zztmpdata->insert([
  2413. 'type'=>4,
  2414. 'act_name'=>'crm_order',
  2415. 'content'=>json_encode($d),
  2416. 'create_time'=>time()
  2417. ]);
  2418. }
  2419. }
  2420. }
  2421. }
  2422. }
  2423. }
  2424. public function _dhl()//DHL
  2425. {
  2426. $data = $this->dhl->find_all("type != 1 and time > '".(time()-24*3600)."'");
  2427. foreach ($data as $v)
  2428. {
  2429. $y = $this->fullorder->get_number($v['number']);
  2430. if(!$y)
  2431. {
  2432. $y = $this->fullordertt->get_number($v['number']);
  2433. if(!$y)
  2434. {
  2435. $y = $this->fullordersmt->get_number($v['number']);
  2436. if(!$y)
  2437. {
  2438. continue;
  2439. }
  2440. }
  2441. }
  2442. $this->dhl->get_data_c($y,$v['id']);
  2443. }
  2444. }
  2445. }