Apixw.php 74 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Apixw 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_fullorderxw','fullorderxw');
  10. $this->load->_model('Model_fullordertt','fullordertt');
  11. $this->load->_model('Model_fullorder_smt','fullorder_smt');
  12. $this->load->_model('Model_fullordersmt','fullordersmt');
  13. $this->load->_model('Model_country','country');
  14. $this->load->_model('Model_hl','hl');
  15. $this->load->_model('Model_is','is');
  16. $this->load->_model('Model_kdniao','kdniao');
  17. $this->load->_model('Model_typeclass','typeclass');
  18. $this->load->_model('Model_warehouse','warehouse');
  19. $this->load->_model('Model_fullorderexcel','fullorderexcel');
  20. $this->load->_model('Model_dhl','dhl');
  21. $this->load->_model('Model_usps','usps');
  22. $this->load->_model('Model_ups','ups');
  23. $this->load->_model('Model_dhltest','dhltest');
  24. $this->load->_model('Model_customer','customer');
  25. $this->load->_model('Model_customerxw','customerxw');
  26. $this->load->_model('Model_express','express');
  27. $this->load->_model('Model_notice','notice');
  28. $this->load->_model('Model_emaildata','emaildata');
  29. $this->load->_model('Model_whlabel','whlabel');
  30. $this->load->_model('Model_productdescribe','productdescribe');
  31. $this->load->_model('Model_ljg','ljg');
  32. $this->load->_model('Model_commodityread','commodityread');
  33. $this->load->_model('Model_service','service');
  34. $this->load->_model('Model_fedex','fedex');
  35. $this->load->_model('Model_apixw','apixw');
  36. $this->load->_model('Model_cne','cne');
  37. $this->load->_model('Model_specialstock','specialstock');
  38. $this->load->_model('Model_whlabellabel','whlabellabel');
  39. $this->load->_model('Model_allocation','allocation');
  40. $this->load->_model('Model_yswaybill','yswaybill');
  41. $this->load->_model('Model_paypal','paypal');
  42. $this->load->_model('Model_17track','17track');
  43. $this->load->_model('Model_ck','ck');
  44. $this->load->_model('Model_weight','weight');
  45. $this->load->_model('Model_pay','pay');
  46. $this->load->_model('Model_setting','setting');
  47. $this->load->_model('Model_classid','classid');
  48. $this->load->_model('Model_whlabel_fc','whlabel_fc');
  49. $this->load->_model('Model_shopsku','shopsku');
  50. }
  51. //定义方法的调用规则 获取URI第二段值
  52. public function _remap($arg,$arg_array)
  53. {
  54. if($arg == 'isorder')//添加
  55. {
  56. $this->_isorder();
  57. }
  58. else if($arg == 'tb')//同步独立站
  59. {
  60. $this->_tb();
  61. }
  62. else if($arg == 'waybill')//运单上传独立站
  63. {
  64. $this->_waybill($arg_array);
  65. }
  66. else if($arg == 'waybillemail')
  67. {
  68. $this->_waybillemail($arg_array);
  69. }
  70. else if($arg == 'waybillfs')
  71. {
  72. $this->_waybillfs($arg_array);
  73. }
  74. else if($arg == 'headgear')//传输头套信息
  75. {
  76. $this->_headgear($arg_array);
  77. }
  78. else if($arg == 'fsstate')
  79. {
  80. $this->_fsstate();
  81. }
  82. else if($arg == 'zz')
  83. {
  84. $this->_zz();
  85. }
  86. else if($arg == 'zzcs')
  87. {
  88. $this->_zzcs();
  89. }
  90. else if($arg == 'cangku')
  91. {
  92. $this->_cangku();
  93. }
  94. else if($arg == 'kc')
  95. {
  96. $this->_kc();
  97. }
  98. else if($arg == 'wlfs')
  99. {
  100. $this->_wlfs();
  101. }
  102. else if($arg == 'query')
  103. {
  104. $this->_query();
  105. }
  106. else if($arg == 'kcjc')
  107. {
  108. $this->_kcjc();
  109. }
  110. else if($arg == 'klarna')
  111. {
  112. $this->_klarna();
  113. }
  114. else if($arg == 'logistics')
  115. {
  116. $this->_logistics();
  117. }
  118. else if($arg == 'hqpaypal')
  119. {
  120. $this->_hqpaypal();
  121. }
  122. else if($arg == 'hqstripe')
  123. {
  124. $this->_hqstripe();
  125. }
  126. else if($arg == 'htmlstock')
  127. {
  128. $this->_htmlstock();
  129. }
  130. else if($arg == '17track')
  131. {
  132. $this->_17track();
  133. }
  134. }
  135. //通过地址直接获取独立站订单信息
  136. public function _isorder()
  137. {
  138. $sid = '';$sd = array();
  139. if(isset($_SESSION['api']))
  140. {
  141. $user = $this->user->get_api($_SESSION['api']);
  142. $user = explode('|',trim($user['shop'],'|'));
  143. foreach ($user as $value)
  144. {
  145. $sid .= " id = '$value' or";
  146. }
  147. $sid = " and (".rtrim($sid,'or').")";
  148. }
  149. $post = $this->input->post(NULL, TRUE);
  150. $api = $this->input->get('api',true);
  151. $dshop = $this->input->get('dshop',true);
  152. //@$gethl = $this->hl->get_hl();//获取即时汇率
  153. $gethl = array();
  154. /* 订单号加入键值-k */
  155. /**
  156. $dataorder = array();
  157. $fdata = $this->fullorderxw->find_all('dtime > "'.(time()-96*3600).'"','orderinfo');
  158. foreach ($fdata as $v)
  159. {
  160. $dataorder[$v['orderinfo']] = "";//获取到单号
  161. }
  162. **/
  163. /* 订单号加入键值-j */
  164. /* 匹配加入 */
  165. $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');
  166. // 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)
  167. $dtc = array();
  168. foreach ($dictionaries as $v)
  169. {
  170. if(stripos($v['spare'],'|') !== false)//如果有多个值
  171. {
  172. $v['spare'] = explode('|',$v['spare']);
  173. foreach ($v['spare'] as $k=>$vs)
  174. {
  175. if(stripos($v['zh'],'|') !== false)
  176. {
  177. $vzh = explode('|',$v['zh']);
  178. $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$vzh[$k],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
  179. }
  180. else
  181. {
  182. $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
  183. }
  184. }
  185. }
  186. else
  187. {
  188. $dtc[strtolower($v['spare'])] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$v['spare']);
  189. }
  190. }
  191. $dictionaries2 = $this->typeclass->find_all();
  192. foreach ($dictionaries2 as $v)
  193. {
  194. $dtctitle[$v['id']] = $v['title'];
  195. }
  196. /* 匹配结束 */
  197. /* 价格加入 */
  198. /**
  199. $money = array();
  200. $productdescribe = $this->productdescribe->find_all('1=1','number,purchase,cost,salesprice,title');
  201. foreach ($productdescribe as $v)
  202. {
  203. $money[$v['number']] = array('purchase'=>$v['purchase'],'cost'=>$v['cost'],'salesprice'=>$v['salesprice'],'title'=>$v['title']);
  204. }
  205. **/
  206. /* 价格加入 */
  207. /* 匹配ID加入 */
  208. $int = array();
  209. $intdata = $this->typeclass->find_all('classid=14','id,spare');
  210. foreach ($intdata as $v)
  211. {
  212. $v['spare'] = explode('|',$v['spare']);
  213. $int[$v['id']] = $v['spare'][0];
  214. }
  215. /* 匹配ID结束 */
  216. /* 国家加入键值-k */
  217. $cuy = array();
  218. $cuydata = $this->country->find_all('1=1','lb,id');
  219. foreach ($cuydata as $v)
  220. {
  221. $cuy[$v['lb']] = $v['id'];//获取到国家ID
  222. }
  223. /* 国家加入键值-j */
  224. /* 币种加入键值-k */
  225. $typeclass = array();
  226. $tdata = $this->typeclass->find_all('classid=30','id,title');
  227. foreach ($tdata as $v)
  228. {
  229. $typeclass[$v['title']] = $v['id'];
  230. }
  231. /* 币种加入键值-j */
  232. /* 支付方式-k */
  233. $pay = array();
  234. $tdata = $this->typeclass->find_all('classid=4','id,spare');
  235. foreach ($tdata as $v)
  236. {
  237. $paytype = $this->pay->get_typeclass($v['id']);
  238. if(isset($paytype['estimaterate']))
  239. {
  240. $estimaterate = $paytype['estimaterate'];
  241. }
  242. else
  243. {
  244. $estimaterate = 0;
  245. }
  246. if(stripos($v['spare'],'|') !== false)//如果有多个值
  247. {
  248. $v['spare'] = explode('|',$v['spare']);
  249. foreach ($v['spare'] as $k=>$vs)
  250. {
  251. $pay[$vs] = array('id'=>$v['id'],'estimaterate'=>$estimaterate);
  252. }
  253. }
  254. else
  255. {
  256. $pay[$v['spare']] = array('id'=>$v['id'],'estimaterate'=>$estimaterate);
  257. }
  258. }
  259. $pay['stripeios'] = $pay['stripe_payments'];
  260. /* 支付方式-j */
  261. /* 新增SKU-k */
  262. $zjsku = array();
  263. $shopsku = $this->shopsku->find_all();
  264. foreach ($shopsku as $val)
  265. {
  266. $ss = explode(',',trim($val['shop'],','));
  267. foreach ($ss as $v)
  268. {
  269. if(isset($zjsku[$v]))
  270. {
  271. $zjsku[$v] .= ','.trim($val['sku'],',');
  272. }
  273. else
  274. {
  275. $zjsku[$v] = trim($val['sku'],',');
  276. }
  277. }
  278. }
  279. /* 新增SKU-j */
  280. $is = $this->is->find_all('1=1','*','number asc');//获取仓库平匹配表
  281. if(isset($post['is']) || (isset($api) && $api = '89757'))
  282. {
  283. $tb = 0;
  284. if($dshop)
  285. {
  286. $shop = $this->shop->find_all("id = '$dshop'");
  287. }
  288. else
  289. {
  290. $shop = $this->shop->find_all("type = 2297 and tb = 1".$sid);//获取独立站信息
  291. }
  292. foreach ($shop as $value)
  293. {
  294. if((time()-$value['tbtime']) < 1)
  295. {
  296. $tb = 1;//正在同步中
  297. break;
  298. }
  299. else
  300. {
  301. $this->shop->save(array('tbtime'=>time()),$value['id']);
  302. }
  303. $setting = $this->setting->get_settings();
  304. $this->db->trans_begin();
  305. $res = $this->apixw->get_hq($value['brandname'],$value['shopadmin'],$value);
  306. $sd[] = $res;
  307. $sjc = $setting['sctime'];//时间差 之前是3600 现在为0
  308. if($res)
  309. {
  310. foreach ($res as $v)
  311. {
  312. if($value['token'] == 'SU')
  313. {
  314. $time = $v['purchased_on']-7*3600-$sjc;//之前是+$sjc
  315. }
  316. else if($value['program'] == 'Shopify')
  317. {
  318. $time = $v['purchased_on'];
  319. }
  320. else
  321. {
  322. if($value['id'] == 1)
  323. {
  324. $time = strtotime($v['purchased_on'])-7*3600-$sjc;//-$sjc;//之前是+$sjc
  325. }
  326. else
  327. {
  328. $time = strtotime($v['purchased_on'])-7*3600-$sjc;//订单时间更为时间戳 //之前是+$sjc
  329. }
  330. }
  331. $num = $this->fullorderxw->find_count('gtime = "'.date('Ymd',$time).'" and shop = "'.$value['id'].'"');
  332. $order_id = $value['id'].$v['order_id'];
  333. $tc = $typeclass[$v['global_currency_code']];
  334. $dataorder = $this->fullorderxw->get_orderinfo($order_id);
  335. $hmdid = '';
  336. if($value['program'] == 'Shopify' && isset($dataorder['id']))
  337. {
  338. if($v['order_comment'] != $dataorder['clientremarks'])
  339. {
  340. $this->fullorderxw->save(array('clientremarks'=>$v['order_comment']),$dataorder['id']);
  341. }
  342. }
  343. if(!isset($dataorder['id']))
  344. //现在为所有订单都获取。!$ord && strcasecmp($v['isstatus'],'processing') == 0如果没有此订单并且订单状态为等待发货则继续
  345. {
  346. if(!isset($cuy[$v['country']]))
  347. {
  348. $cuy[$v['country']] = 1004;
  349. }
  350. $post = $this->apixw->get_data($value,$v,$gethl,$time,$cuy[$v['country']],$is,$num,$v['country'],$tc,$dtc,array(),$int,$dtctitle,$pay,$zjsku);
  351. $kn = explode('-',$post['paypal']);
  352. if($post['pay'] == 23 && $value['klarnaname'] != '' && $value['klarnapass'] != '')
  353. {
  354. $klarna = $this->_klarnadata($post['paypal'],$value['klarnaname'],$value['klarnapass']);
  355. if($klarna != '')
  356. {
  357. $post['klarnadata'] = $klarna;
  358. }
  359. }
  360. if($post['pay'] == 26 && $value['afterpayname'] != '' && $value['afterpaypass'] != '')
  361. {
  362. $afterpay = $this->_afterpay($post['paypal'],$value['afterpayname'],$value['afterpaypass']);
  363. if($afterpay != '')
  364. {
  365. $post['klarnadata'] = $afterpay;
  366. }
  367. }
  368. if($post['pay'] == 27 && $value['clearpayname'] != '' && $value['clearpaypass'] != '')
  369. {
  370. $clearpay = $this->_clearpay($post['paypal'],$value['clearpayname'],$value['clearpaypass']);
  371. if($clearpay != '')
  372. {
  373. $post['klarnadata'] = $clearpay;
  374. }
  375. }
  376. if($post['pay'] == '28' && $post['state'] != '207')
  377. {
  378. continue;
  379. }
  380. if($post['state'] == '217' || $post['state'] == '203')
  381. {
  382. continue;
  383. }
  384. /**
  385. else if($post['pay'] == 22 && $value['paypalname'] != '' && $value['paypalpass'] != '')
  386. {
  387. $paypal = $this->_paypaldata($post['paypal'],$value['paypalname'],$value['paypalpass']);
  388. if($paypal != '')
  389. {
  390. $post['klarnadata'] = $paypal;
  391. }
  392. }
  393. **/
  394. /** 启用自动分配仓库 **/
  395. /** **/
  396. //合并重复项
  397. $hbcfw = explode('|',trim($post['whlabel'],'|'));
  398. $hbcff = explode(';',trim($post['fpdata'],';'));
  399. $c = 0;
  400. $hbw = array();
  401. $hbf = array();
  402. for($i=0;$i<count($hbcfw);$i++)
  403. {
  404. $w = explode('-',$hbcfw[$i]);
  405. $f = explode('|',$hbcff[$i]);
  406. $w2 = ($w[2]==0)?0:'';
  407. if(!isset($hbw[$w[0].$w2]))
  408. {
  409. $hbw[$w[0].$w2] = $hbcfw[$i];
  410. $hbf[$w[0].$w2] = $hbcff[$i];
  411. }
  412. else
  413. {
  414. $c++;
  415. $cw = explode('-',$hbw[$w[0].$w2]);
  416. $cf = explode('|',$hbf[$w[0].$w2]);
  417. if($cw[2] != 0 && $w[2] != 0)
  418. {
  419. $cf[2] += $f[2];
  420. $cf[9] .= '~'.$f[9];
  421. $hbf[$w[0].$w2] = implode("|",$cf);
  422. $cw[1] += $f[2];
  423. $cw[2] .= '~'.$f[9];
  424. $hbw[$w[0].$w2] = implode("-",$cw);
  425. }
  426. else if($cw[2] == 0 && $w[2] == 0)
  427. {
  428. $cf[2] += $f[2];
  429. $hbf[$w[0].$w2] = implode("|",$cf);
  430. $cw[1] += $f[2];
  431. $hbw[$w[0].$w2] = implode("-",$cw);
  432. }
  433. else
  434. {
  435. $hbw[] = $hbcfw[$i];
  436. $hbf[] = $hbcff[$i];
  437. }
  438. }
  439. }
  440. if($c > 0)
  441. {
  442. $post['fpdata'] = implode(";",$hbf).';';
  443. $post['whlabel'] = '|'.implode("|",$hbw).'|';
  444. }
  445. //合并重复项结束
  446. //非占单设置为禁止占单开始
  447. $hbw = explode('|',trim($post['whlabel'],'|'));
  448. $hbf = explode(';',trim($post['fpdata'],';'));
  449. foreach ($hbw as $k=>$val)
  450. {
  451. $w = explode('-',$val);
  452. $f = explode('|',$hbf[$k]);
  453. if(!isset($w[2]) || $w[2] == 0)
  454. {
  455. $w[2] = "DNOTO";
  456. $f[9] = "DNOTO";
  457. $hbf[$k] = implode("|",$f);
  458. $hbw[$k] = implode("-",$w);
  459. }
  460. }
  461. $post['fpdata'] = implode(";",$hbf).';';
  462. $post['whlabel'] = '|'.implode("|",$hbw).'|';
  463. //非占单设置为禁止占单结束
  464. //查询净重开始
  465. $post['jweight'] = $this->weight->get_weightcx($post['fpdata']);
  466. //查询净重结束
  467. $tjid = $this->fullorderxw->insert($post);
  468. if($post['email'] == '')
  469. {
  470. $post['email'] = $post['name'].'@qq.com';
  471. }
  472. $adrs = $this->customerxw->get_email($post['email'],$post['shop']);
  473. preg_match_all('/[0-9]/u',$post['phone'],$result);
  474. $numphone = join('',$result[0]);
  475. $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']));
  476. $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']));
  477. $hmdaddress3 = str_replace(array(' avenue',' ave',' av'),array(' ave',' avenue',' ave'),strtolower($post['address']));
  478. $hmdid = '';
  479. $customerb = $this->customerxw->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');
  480. $lkh = (isset($customerb[0]['id']))?2:1;//白名单1黑名单2
  481. if($lkh == 2)
  482. {
  483. $hmdid = $customerb[0]['id'].'-('.$post['email'].'|'.$post['address'].'|'.$numphone.')'.'('.$customerb[0]['email'].'|'.$customerb[0]['address'].$customerb[0]['numphone'].')';
  484. }
  485. if($adrs)
  486. {
  487. $pdlkh = 1;//这个是判断是否老客户
  488. $this->customerxw->save(array('time'=>$post['dtime'],'num'=>$adrs['num']+1,'money'=>$adrs['money']+$post['shouldmoney']),$adrs['id']);
  489. $khid = $adrs['id'];
  490. }
  491. else
  492. {
  493. $str = $post['phone'];
  494. preg_match_all('/[0-9]/u',$str,$result);
  495. $numphone = join('',$result[0]);
  496. $ct['shop'] = $post['shop'];
  497. $ct['source'] = 10;
  498. $ct['level'] = 5;
  499. $ct['country'] = $post['country'];
  500. $ct['time'] = $post['dtime'];
  501. $ct['num'] = 1;
  502. $ct['money'] = $post['shouldmoney'];
  503. $ct['zipcode'] = $post['zipcode'];
  504. $ct['name'] = $post['name'];
  505. $ct['phone'] = $post['phone'];
  506. $ct['numphone'] = $numphone;
  507. $ct['email'] = preg_replace('/( | | |\s)+/','',$post['email']);
  508. $ct['province'] = $post['province'];
  509. $ct['city'] = $post['city'];
  510. $ct['address'] = $post['address'];
  511. $ct['zhcx'] = $post['shop'].'-'.$ct['email'];
  512. $khid = $this->customerxw->insert($ct);
  513. $pdlkh = 0;
  514. }
  515. //$this->_znxc($post,$order_id,$lkh,$pdlkh,$hmdid);
  516. }//else{}如果有此订单
  517. }
  518. }
  519. if ($this->db->trans_status() === FALSE)
  520. {
  521. $this->db->trans_commit();
  522. }
  523. else
  524. {
  525. $this->db->trans_commit();
  526. }
  527. sleep(5);//停留2秒
  528. }
  529. if($tb == 1)
  530. {
  531. echo json_encode(array('msg'=>'有店铺正在同步中,请5分钟后再试!','success'=>true));exit;
  532. }
  533. echo json_encode(array('msg'=>'OK!','success'=>true));exit;
  534. }
  535. }
  536. public function _tb()
  537. {
  538. $api = $this->input->get('api',true);
  539. if(isset($api) && $api = '89757')
  540. {
  541. $xg = $this->fullorderxw->find_all('dlz < 1 and source != 1 and waybill != "" and dtime > "'.(time()-48*3600).'"');
  542. /* 店铺加入键值-j */
  543. $fshop = $this->shop->find_all('1=1');
  544. foreach ($fshop as $v)
  545. {
  546. $datashop[$v['id']] = $v;
  547. }
  548. /* 店铺加入键值-k */
  549. /* 快递加入键值-j */
  550. $fex = $this->express->find_all('1=1');
  551. foreach ($fex as $v)
  552. {
  553. $dataex[$v['id']] = $v;
  554. }
  555. /* 快递加入键值-k */
  556. /* 仓库加入键值-k */
  557. $fwh = $this->warehouse->find_all('1=1');
  558. foreach ($fwh as $v)
  559. {
  560. $datack[$v['id']] = $v;
  561. }
  562. /* 仓库加入键值-j */
  563. //$fs = $this->notice->get_ordertatus(216);//216成功状态
  564. foreach ($xg as $v)
  565. {
  566. $shop = $datashop[$v['shop']];
  567. $ex = $dataex[$v['express']];
  568. $warehouse = $datack[$v['type']];
  569. if($ex['iscode'] != 'Other')
  570. {
  571. //独立站地址更新订单状态、物流信息
  572. @$gx = $this->apixw->get_gx(substr($v['orderinfo'],1),$v['waybill'],$xg,$shop,$ex,$xg['shopify']);
  573. $this->fullorderxw->save(array('dlz'=>$gx['res'],'state'=>$gx['state']),$v['id']);
  574. /**
  575. if($gx['res'] == 1 && $fs)
  576. {
  577. $ck = $this->_email($fs['content'],$v,$warehouse['company']);
  578. }
  579. **/
  580. }
  581. sleep(3);//停留2秒
  582. }
  583. }
  584. }
  585. //更新独立站运单信息
  586. public function _waybill($arg_array)
  587. {
  588. $where = "dlz < '1' and state = '207' and ";
  589. if(date("H",time()) == '8' && date("i",time()) > '20' && date("i",time()) < '39')//USPS-USA单,已出库——使用模板3 每天早上8点半 触发发送【昨天早上7点-今天早上7点】出库的
  590. {
  591. $where .= "express = '2' and librarytime > '".strtotime(date("Y-m-d 7:00:0",strtotime("-1 day")))."' and librarytime < '".strtotime(date("Y-m-d 7:00:0",time()))."'";
  592. $readid = 3;
  593. }
  594. else if(date("H",time()) == '21' && date("w",time()) != '0')//二、杭州联邦+杭州联邦-不报关,单独用一个模板—新模板2 每天晚上9点半 触发发送 【昨天晚上9:30——今天晚上9:30】出库的
  595. {
  596. if(date("w",time()) == '1')//周一执行:周六晚上9点半——周一晚上9点半 之间出库的
  597. {
  598. $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()))."'";
  599. }
  600. else //周二到周六: 前一天晚上9点半——当天晚上9点半之间出库的
  601. {
  602. $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()))."'";
  603. }
  604. $readid = 2;
  605. }
  606. else if(date("H",time()) == '19' && date("w",time()) != '0')//其他快递-使用模板1 DHL官方、UPS、DPEX 等系统里打印运单自动有运单号的,出库后当天晚上7点执行。
  607. {
  608. if(date("w",time()) == '1')//周一执行:周六晚上9点半——周一晚上9点半 之间出库的
  609. {
  610. $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()))."'";
  611. }
  612. else //周二到周六: 前一天晚上9点半——当天晚上9点半之间出库的
  613. {
  614. $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()))."'";
  615. }
  616. $readid = 1;
  617. }
  618. else
  619. {
  620. exit;
  621. }
  622. $dataorder = array();$datashop = array();$dataex = array();$datack = array();
  623. // 订单加入键值-k
  624. $fdata = $this->fullorderxw->find_all($where);//,'source,id,orderinfo,waybill,shop,express,type,msg,bname,state,client,name,phone,zipcode,address,email,shopify'
  625. //* 订单加入键值-j
  626. //* 店铺加入键值-j
  627. $fshop = $this->shop->find_all('1=1');
  628. foreach ($fshop as $v)
  629. {
  630. $datashop[$v['id']] = $v;
  631. }
  632. //* 店铺加入键值-k
  633. //* 快递加入键值-j
  634. $fex = $this->express->find_all('1=1');
  635. foreach ($fex as $v)
  636. {
  637. $dataex[$v['id']] = $v;
  638. }
  639. //* 快递加入键值-k
  640. //* 仓库加入键值-k
  641. $fwh = $this->warehouse->find_all('1=1');
  642. foreach ($fwh as $v)
  643. {
  644. $datack[$v['id']] = $v;
  645. }
  646. //* 仓库加入键值-j
  647. $i = 0;$j = 0;$ed = array();
  648. foreach ($fdata as $key=>$value)
  649. {
  650. if($value['source'] == 1)
  651. {
  652. $this->fullorderxw->save(array('dlz'=>3,'state'=>216),$value['id']);
  653. }
  654. else
  655. {
  656. $ddh = substr($value['orderinfo'],1);
  657. $ydh = $value['waybill'];
  658. $xg = $value;//此订单数据
  659. $shop = $datashop[$xg['shop']];//此订单店铺
  660. $ex = $dataex[$xg['express']];//此订单快递
  661. $warehouse = $datack[$xg['type']];//此订单仓库
  662. $shopifyid = $value['shopify'];
  663. @$gx = $this->apixw->get_gx($ddh,$ydh,$xg,$shop,$ex,$readid,$shopifyid);
  664. if(!isset($gx['res']))
  665. {
  666. continue;
  667. }
  668. $this->fullorderxw->save(array('dlz'=>$gx['res'],'state'=>$gx['state']),$value['id']);
  669. }
  670. sleep(4);
  671. }
  672. $this->_kcjc();
  673. }
  674. public function _kcjc()
  675. {
  676. $gethl = $this->whlabel->find_all("zd != '' and state = '0'");
  677. $b = array();
  678. foreach ($gethl as $k=>$v)
  679. {
  680. $a = $this->fullorderxw->get_number($v['zd']);
  681. if($a['librarytime'] > 0 && $a['library'] == 2)
  682. {
  683. //$b[] = array($v['sku'],$v['zd']);
  684. $this->whlabel->save(array('state'=>1,'orderinfo'=>$a['orderinfo'],'waybill'=>$a['waybill'],'outk'=>$a['librarytime'],'time'=>$a['librarytime']),$v['id']);
  685. }
  686. }
  687. }
  688. public function _waybillemail($arg_array)
  689. {
  690. $this->fullorderxw->save(array('email'=>date("H:i:s",time())),14786);
  691. $urls = array();$sl = 0;$time = time();
  692. if(date("H",time()) == '8' && date("i",time()) > '20' && date("i",time()) < '39')//USPS-USA单
  693. {
  694. $wid = 1;
  695. }
  696. else if(date("H",time()) == '22' && date("w",time()) != '0' && date("i",time()) > '20' && date("i",time()) < '39')//二、杭州联邦+杭州联邦-不报关
  697. {
  698. if(date("w",time()) == '1')//周一执行:周六晚上9点半——周一晚上9点半 之间出库的
  699. {
  700. $wid = 2;
  701. }
  702. else //周二到周六: 前一天晚上9点半——当天晚上9点半之间出库的
  703. {
  704. $wid = 3;
  705. }
  706. }
  707. else if(date("H",time()) == '20' && date("w",time()) != '0' && date("i",time()) > '20' && date("i",time()) < '39')//其他快递
  708. {
  709. if(date("w",time()) != '1')
  710. {
  711. $wid = 4;
  712. }
  713. else
  714. {
  715. $wid = 5;
  716. }
  717. }
  718. else
  719. {
  720. exit;
  721. }
  722. $notice = $this->notice->find_all("message = '1' and state = '1' and type = '4' and ktime < '$time' and jtime > '$time'");//已有自动发送,这个是物流发送
  723. foreach ($notice as $key=>$var)
  724. {
  725. $urls[] = array('url'=>'http://1.wepolicy.cn/api/waybillfs?v='.$var['id'],'data'=>array('var'=>$var,'wid'=>$wid));
  726. }
  727. foreach($urls as $value) {
  728. $ch = curl_init();
  729. $url = $value['url'];
  730. curl_setopt($ch,CURLOPT_URL,$url);
  731. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  732. curl_setopt($ch,CURLOPT_HEADER,0);
  733. curl_setopt($ch,CURLOPT_POST, 1);
  734. curl_setopt($ch,CURLOPT_TIMEOUT,1);
  735. //设置post数据
  736. $post = array();
  737. $post['data'] = $value['data'];
  738. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
  739. $res = curl_exec($ch);
  740. curl_close($ch);
  741. $sl++;
  742. }
  743. echo $sl;
  744. echo "<pre>";
  745. print_r($urls);
  746. }
  747. public function _waybillfs()
  748. {
  749. $post = $this->input->post(NULL, TRUE);
  750. $data = $this->input->post('data',true);
  751. if($data)
  752. {
  753. $notice = $data['var'];
  754. $notice['email'] = $this->emaildata->read($notice['email']);
  755. $wid = $data['wid'];
  756. $fsjs = "";
  757. if($wid == 1 && stripos($notice['express'],',2,') !== false)
  758. {
  759. $js = explode(',',trim($notice['js'],','));
  760. if(count($js) > 1)
  761. {
  762. $fsjs = " and (";
  763. foreach ($js as $v)
  764. {
  765. $fsjs .= "js = '$v' or ";
  766. }
  767. $fsjs = trim($fsjs,' or ').")" ;
  768. }
  769. else if(count($js) == 1)
  770. {
  771. $fsjs = " and js = '$js[0]'";
  772. }
  773. $where = "express = '2' 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
  774. }
  775. else if($wid == 2 && stripos($notice['express'],',1,') !== false)
  776. {
  777. $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
  778. }
  779. else if($wid == 3 && stripos($notice['express'],',1,') !== false)
  780. {
  781. $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
  782. }
  783. else if($wid == 4 && stripos($notice['express'],',1,') !== false)
  784. {
  785. $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
  786. }
  787. else if($wid == 5 && stripos($notice['express'],',1,') !== false)
  788. {
  789. $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
  790. }
  791. else
  792. {
  793. exit;
  794. }
  795. $wlfs = array();
  796. $dd = $this->fullorderxw->find_all("source != '1' and dlzemail < '1' and shop = '".$notice['shop']."' and library = 2 and ".$where);
  797. foreach ($dd as $v)
  798. {
  799. $shop = $this->shop->read($v['shop']);
  800. $express = $this->express->read($v['express']);
  801. $fs = $this->notice->get_god($v,$shop,$express,$notice);
  802. if($fs == 1)
  803. {
  804. $this->fullorderxw->save(array('dlzemail'=>1,'dlzemailtime'=>time()),$v['id']);
  805. }
  806. else
  807. {
  808. //$pdtime = date('Y-m-d',time());
  809. //$folderPath = './data/dlzemail/'.$pdtime; // 文件夹路径
  810. //$permissions = 0777; // 权限设置
  811. //if (!file_exists($folderPath)) { mkdir($folderPath, $permissions); }//创建文件夹
  812. //file_exists($folderPath);
  813. if(!is_file("./data/dlzemail/".$v['number'].".txt"))
  814. {
  815. $myfile = fopen("./data/dlzemail/".$v['number'].".txt", "w") or die("Unable to open file!");
  816. fwrite($myfile, json_encode($fs.';'.$v.';'.$shop.';'.$express.';'.$notice));
  817. fclose($myfile);
  818. }
  819. else
  820. {
  821. $myfile = fopen("./data/dlzemail/".$v['number'].".txt", "a+") or die("Unable to open file!");
  822. fwrite($myfile, json_encode($fs.';'.$v.';'.$shop.';'.$express.';'.$notice));
  823. fclose($myfile);
  824. }
  825. $this->fullorderxw->save(array('dlzemail'=>2,'dlzemailtime'=>time()),$v['id']);
  826. }
  827. sleep(50);
  828. }
  829. }
  830. }
  831. /**
  832. //更新独立站运单信息
  833. public function _waybill($arg_array)
  834. {
  835. //这里订单索引需要修改 8点是出已打印已出库 11点是已打印未出库
  836. if(!isset($arg_array[0]) || !isset($arg_array[1]))
  837. {
  838. exit;
  839. }
  840. if(date("w",time()) == '0' && $arg_array[0] != '3')//非usps周日不更新
  841. {
  842. echo 7;exit;
  843. }
  844. if($arg_array[0] == 3)
  845. {
  846. $argarray = 2;
  847. $typec = ' and express = 2 and printtime > "'.strtotime("-3 day").'"';//更新usps-usa快递的订单
  848. }
  849. else
  850. {
  851. $argarray = $arg_array[0];
  852. $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())).'"';//更新快递的订单
  853. }
  854. $dataorder = array();$datashop = array();$dataex = array();$datack = array();
  855. // 订单加入键值-k
  856. $fdata = $this->fullorderxw->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');
  857. //* 订单加入键值-j
  858. //* 店铺加入键值-j
  859. $fshop = $this->shop->find_all('1=1');
  860. foreach ($fshop as $v)
  861. {
  862. $datashop[$v['id']] = $v;
  863. }
  864. //* 店铺加入键值-k
  865. //* 快递加入键值-j
  866. $fex = $this->express->find_all('1=1');
  867. foreach ($fex as $v)
  868. {
  869. $dataex[$v['id']] = $v;
  870. }
  871. //* 快递加入键值-k
  872. //* 仓库加入键值-k
  873. $fwh = $this->warehouse->find_all('1=1');
  874. foreach ($fwh as $v)
  875. {
  876. $datack[$v['id']] = $v;
  877. }
  878. //* 仓库加入键值-j
  879. //$fs = $this->notice->get_ordertatus(216);//216成功状态
  880. $i = 0;$j = 0;$ed = array();
  881. foreach ($fdata as $key=>$value)
  882. {
  883. if($value['source'] == 1)
  884. {
  885. $this->fullorderxw->save(array('dlz'=>3,'state'=>216),$value['id']);
  886. }
  887. else
  888. {
  889. $ddh = substr($value['orderinfo'],1);
  890. $ydh = $value['waybill'];
  891. $xg = $value;//此订单数据
  892. $shop = $datashop[$xg['shop']];//此订单店铺
  893. $ex = $dataex[$xg['express']];//此订单快递
  894. $warehouse = $datack[$xg['type']];//此订单仓库
  895. //独立站地址更新订单状态、物流信息
  896. if($arg_array[0] == 1)//23点更新用留言2
  897. {
  898. $readid = 2;
  899. }
  900. else if($arg_array[0] == 3)//7点更新用留言3
  901. {
  902. $readid = 3;
  903. }
  904. else //20点更新用默认留言(默认留言为1)
  905. {
  906. $readid = $xg['msg'];
  907. }
  908. @$gx = $this->apixw->get_gx($ddh,$ydh,$xg,$shop,$ex,$readid);
  909. if(!isset($gx['res']))
  910. {
  911. exit;
  912. }
  913. $this->fullorderxw->save(array('dlz'=>$gx['res'],'state'=>$gx['state']),$xg['id']);
  914. }
  915. //if($gx['res'] == 1 && $fs)
  916. //{
  917. // $ck = $this->_email($fs['content'],$xg,$warehouse['company']);
  918. //}
  919. sleep(2);//停留2秒
  920. }
  921. }
  922. **/
  923. public function _headgear($arg_array)
  924. {
  925. $ip = $this->input->ip_address();
  926. if(!isset($arg_array[0]) || !isset($arg_array[1]))
  927. {
  928. exit;
  929. }
  930. if(!is_numeric($arg_array[0]) || !is_numeric($arg_array[1]))
  931. {
  932. exit;
  933. }
  934. $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)
  935. if($arg_array[1] == 1)
  936. {
  937. $data = $this->fullordersmt->find_all($where,'express,number,orderinfo,shipremarks,printtime');
  938. }
  939. else
  940. {
  941. $data = $this->fullorderxw->find_all($where,'express,number,orderinfo,shipremarks,printtime');
  942. }
  943. foreach ($data as $k=>$v)
  944. {
  945. $express = $this->express->read($v['express']);
  946. $data[$k]['express'] = $express['servicename'];
  947. if($data[$k]['printtime'] > 0)
  948. {
  949. $data[$k]['printtime'] = date('Y-m-d H:i:s',$v['printtime']);
  950. }
  951. }
  952. //$state = $this->apixw->get_headgear($data);
  953. echo json_encode($data);
  954. }
  955. public function _kc_old()
  956. {
  957. $post = $this->input->post(NULL, TRUE);
  958. if(isset($post['sku']))
  959. {
  960. $sku = $this->input->post('sku',true);
  961. $warehouse = $this->warehouse->find_all();
  962. $data = array();
  963. foreach ($sku as $val)
  964. {
  965. $datasku = array();
  966. foreach ($warehouse as $v)
  967. {
  968. $z = $this->whlabel->find_count('sku = "'.$val.'" and zd = "" and state = 0 and warehouse = "'.$v['id'].'"');
  969. $datasku[] = array('name'=>$v['title'],'number'=>$z);
  970. }
  971. $data[$val] = $datasku;
  972. }
  973. }
  974. echo json_encode($data);
  975. }
  976. public function _kc()
  977. {
  978. $datasku = array();
  979. $info_list = $this->whlabel->find_pc("warehouse = '5'",'sku,features,warehouse','sku');
  980. foreach ($info_list as $val)
  981. {
  982. $z = $this->whlabel->find_count('sku = "'.$val['sku'].'" and zd = "" and state = 0 and warehouse = "5"');
  983. $datasku[] = array('sku'=>$val['sku'],'number'=>$z);
  984. }
  985. echo json_encode($datasku);
  986. }
  987. public function _fsstate()//订单消息页手动发送
  988. {
  989. $post = $this->input->post(NULL, TRUE);
  990. if(isset($post['s']))
  991. {
  992. $id_arr = $this->input->post('s');
  993. $notice = $this->input->post('notice');
  994. $noticeid = $this->input->post('noticeid');
  995. $id_arr = explode(',',trim($id_arr,','));
  996. if(!$id_arr)
  997. {
  998. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  999. }
  1000. if($notice == '1' || $notice == '')
  1001. {
  1002. foreach ($id_arr as $v)
  1003. {
  1004. $data = $this->fullorderxw->read($v);
  1005. $adrs = $this->customerxw->get_email($data['email'],$data['shop']);
  1006. //$lkh = ($adrs['type'] == 1)?1:2;//白名单1黑名单2
  1007. $lkh = 1;
  1008. $pdlkh = ($adrs['num'] > 1)?1:0;//判断是否老客户
  1009. $fs = $this->_znxc($data,$data['orderinfo'],$lkh,$pdlkh);
  1010. if($fs == 1)
  1011. {
  1012. $this->fullorderxw->save(array('exstateerror'=>''),$data['id']);
  1013. }
  1014. sleep(40);
  1015. }
  1016. }
  1017. else
  1018. {
  1019. foreach ($id_arr as $v)
  1020. {
  1021. $data = $this->fullorderxw->read($v);
  1022. $fs = $this->_sdfs($data,$noticeid);
  1023. sleep(40);
  1024. }
  1025. }
  1026. echo json_encode(array('msg'=>'发送完成!','id'=>$id_arr,'success'=>true));exit;
  1027. }
  1028. }
  1029. public function _cangku()
  1030. {
  1031. $post = $this->input->post(NULL, TRUE);
  1032. if(isset($post['tk']))
  1033. {
  1034. $tk = $this->input->post('tk');
  1035. $tj = $this->input->post('tj');
  1036. $d = $this->fullorderxw->find_all("dtime > '$tk' and dtime < '$tj'");
  1037. $k = $this->customerxw->find_all("time > '$tk' and time < '$tj'");
  1038. echo json_encode(array('d'=>$d,'k'=>$k));exit;
  1039. }
  1040. }
  1041. public function _znxc($fullorder,$order_id,$lkh,$pdlkh,$hmdid='')
  1042. {
  1043. exit;
  1044. $time = time();
  1045. $sl = explode(';',$fullorder['quantity']);
  1046. $quantity = 0;
  1047. foreach ($sl as $v)
  1048. {
  1049. if($v > 1)
  1050. {
  1051. $quantity = 1;
  1052. }
  1053. }
  1054. $fid = $this->fullorderxw->get_orderinfo($order_id);
  1055. 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'] != '' ||
  1056. {
  1057. $asdasd = 0;
  1058. if($lkh == 2)
  1059. {
  1060. $asdasd = 1;
  1061. }
  1062. if(count($sl) > 1 && $quantity == 1)
  1063. {
  1064. $asdasd = 2;
  1065. }
  1066. 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)
  1067. {
  1068. $asdasd = 3;
  1069. }
  1070. $this->fullorderxw->save(array('content'=>$fid['content'].'黑名单客户、多产品的、包含PO BOX、包含APO的不发送-'.$asdasd.(($hmdid)?'['.$hmdid.']':''),'zdstate'=>$fid['zdstate'].'1-x|'),$fid['id']);//留言的现在正常发
  1071. return 'a';
  1072. }
  1073. else
  1074. {
  1075. /**
  1076. if($fullorder['shouldmoney'] > '400' && $fullorder['guarantee'] == 'Ineligible')//如果金额大于400美元并且无卖家保障
  1077. {
  1078. $tab = 1;
  1079. }
  1080. else if(count($sl) == '1' && $fullorder['quantity'] > 1 && $fullorder['baddress'] != $fullorder['saddress'])//如果item(产品)是1,但quantity大于等于2并且Bill Address不等于Ship Address
  1081. {
  1082. $tab = 4;
  1083. }
  1084. else if($fullorder['baddress'] != $fullorder['saddress'])//如果Bill Address不等于Ship Address
  1085. {
  1086. $tab = 3;
  1087. }
  1088. **/
  1089. if(count($sl) == '1' && $fullorder['quantity'] > 1)//如果item(产品)是1,但quantity大于等于2
  1090. {
  1091. $tab = 2;
  1092. }
  1093. else//常规模板
  1094. {
  1095. $tab = 0;
  1096. }
  1097. $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'");//有条件不同模板匹配
  1098. if(isset($notice[0]['content']))
  1099. {
  1100. if($pdlkh == '1' && $notice[0]['thq'] != ''&& $notice[0]['thh'] != '')//非常规和老客户模板,如果是老客户并且需要替换的话
  1101. {
  1102. $notice[0]['content'] = str_replace($notice[0]['thq'],$notice[0]['thh'],$notice[0]['content']);
  1103. }
  1104. $shop = $this->shop->read($fullorder['shop']);
  1105. //$express = $this->express->read($fullorder['express']);
  1106. //$service = $this->service->read($express['service']);
  1107. $country = $this->country->read($fullorder['country']);
  1108. $fullorder['country'] = $country['ename'];
  1109. //$express['servicename'] =$service['title'];//增加快递名称
  1110. $express = array();
  1111. $notice[0]['email'] = $this->emaildata->read($notice[0]['email']);
  1112. $go = $this->notice->get_god($fullorder,$shop,$express,$notice[0]);
  1113. if($go == 1)
  1114. {
  1115. $this->fullorderxw->save(array('content'=>$fid['content'].'自动发送-成功;','zdstate'=>$fid['zdstate'].$notice[0]['type'].'-'.$notice[0]['tab'].'|','exstateerror'=>''),$fid['id']);
  1116. return 1;
  1117. }
  1118. else
  1119. {
  1120. $this->fullorderxw->save(array('exstateerror'=>'自动发送失败1:'.date('Y-m-d H',time()).'-'.$go.'('.$notice[0]['type'].'-'.$notice[0]['message'].')'),$fid['id']);
  1121. }
  1122. }
  1123. else
  1124. {
  1125. $this->fullorderxw->save(array('exstateerror'=>'当前订单状态无匹配模板'),$fid['id']);
  1126. }
  1127. }
  1128. }
  1129. public function _sdfs($fullorder,$id)//手动发送信息
  1130. {
  1131. $time = time();
  1132. $notice = $this->notice->read($id);//无条件同模板匹配
  1133. $notice['email'] = $this->emaildata->read($notice['email']);
  1134. $shop = $this->shop->read($fullorder['shop']);
  1135. $express = $this->express->read($fullorder['express']);
  1136. if($notice['type'] == '1')
  1137. {
  1138. $fslx = 'tab';
  1139. $content = '自动发送';
  1140. $stripos = '1-';
  1141. }
  1142. else if ($notice['type'] == '2')
  1143. {
  1144. $fslx = 'logisticstatus';
  1145. $content = $notice['title'];
  1146. $stripos = $notice['type'].'-'.$notice[$fslx].'|';
  1147. }
  1148. if(stripos($fullorder['zdstate'],$stripos) === false && $fullorder['wltype'] == '0')//如果没发送过并且允许发送
  1149. {
  1150. $go = $this->notice->get_god($fullorder,$shop,$express,$notice);
  1151. if($go == 1)
  1152. {
  1153. if($notice['type'] == '1')
  1154. {
  1155. $this->fullorderxw->save(array('content'=>$fullorder['content'].$content.'-成功;','zdstate'=>$fullorder['zdstate'].$notice['type'].'-'.$notice[$fslx].'|','exstateerror'=>'','wlerror'=>''),$fullorder['id']);
  1156. }
  1157. else if ($notice['type'] == '2')
  1158. {
  1159. $this->fullorderxw->save(array('wlcontent'=>$fullorder['wlcontent'].$content.'-成功;','wlfstime'=>time(),'zdstate'=>$fullorder['zdstate'].$notice['type'].'-'.$notice[$fslx].'|','exstateerror'=>'','wlerror'=>''),$fullorder['id']);
  1160. }
  1161. return 1;
  1162. }
  1163. else
  1164. {
  1165. if($notice['type'] == '1')
  1166. {
  1167. $this->fullorderxw->save(array('exstateerror'=>$content.'发送失败1:'.date('Y-m-d H',time()).'-'.$go.'('.$notice['type'].'-'.$notice[$fslx].')'),$fullorder['id']);
  1168. }
  1169. else if ($notice['type'] == '2')
  1170. {
  1171. $this->fullorderxw->save(array('wlerror'=>$content.'发送失败2:'.date('Y-m-d H',time()).'-'.$go.'('.$notice['type'].'-'.$notice[$fslx].')'),$fullorder['id']);
  1172. }
  1173. }
  1174. }
  1175. }
  1176. public function _zz()
  1177. {
  1178. //$f = $this->fullorderxw->find_all("1=1",'wlfstime','wlfstime desc',0,2);
  1179. if(date("w") == '0')
  1180. {
  1181. exit;
  1182. }
  1183. $time = time();
  1184. $tjlike = array();
  1185. $urls = array();$sl = 0;
  1186. $notice = $this->notice->find_all("message = '1' and state = '1' and type = '2' and ktime < '$time' and jtime > '$time'");//已有自动发送,这个是物流发送
  1187. foreach ($notice as $key=>$var)
  1188. {
  1189. $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));
  1190. }
  1191. foreach($urls as $value) {
  1192. $tjlike[] = $value['url'];
  1193. $ch = curl_init();
  1194. $url = $value['url'];
  1195. curl_setopt($ch,CURLOPT_URL,$url);
  1196. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  1197. curl_setopt($ch,CURLOPT_HEADER,0);
  1198. curl_setopt($ch,CURLOPT_POST, 1);
  1199. curl_setopt($ch,CURLOPT_TIMEOUT,5);
  1200. //设置post数据
  1201. $post = array();
  1202. $post['data'] = $value['data'];
  1203. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
  1204. $res = curl_exec($ch);
  1205. curl_close($ch);
  1206. $sl++;
  1207. }
  1208. echo "<pre>";
  1209. print_r($tjlike);
  1210. echo $sl;
  1211. /**
  1212. $urls = array();
  1213. $notice = $this->notice->find_all("message = '1' and state = '1' and type = '2' and ktime < '$time' and jtime > '$time'");//已有自动发送,这个是物流发送
  1214. foreach ($notice as $key=>$var)
  1215. {
  1216. $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));
  1217. }
  1218. $mh = curl_multi_init();
  1219. $urlHandlers = array();
  1220. $urlData = array();
  1221. // 初始化多个请求句柄为一个
  1222. foreach($urls as $value) {
  1223. $ch = curl_init();
  1224. $url = $value['url'];
  1225. $url .= strpos($url, '?') ? '&' : '?';
  1226. curl_setopt($ch, CURLOPT_URL, $url);
  1227. // 设置数据通过字符串返回,而不是直接输出
  1228. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  1229. curl_setopt($ch,CURLOPT_HEADER,0);
  1230. curl_setopt($ch,CURLOPT_POST, 1);
  1231. $post = array();
  1232. $post['data'] = $value['data'];
  1233. curl_setopt($ch,CURLOPT_POSTFIELDS,http_build_query($post));
  1234. $urlHandlers[] = $ch;
  1235. curl_multi_add_handle($mh, $ch);
  1236. }
  1237. $active = null;
  1238. // 检测操作的初始状态是否OK,CURLM_CALL_MULTI_PERFORM为常量值-1
  1239. do {
  1240. // 返回的$active是活跃连接的数量,$mrc是返回值,正常为0,异常为-1
  1241. $mrc = curl_multi_exec($mh, $active);
  1242. } while ($mrc == CURLM_CALL_MULTI_PERFORM);
  1243. // 如果还有活动的请求,同时操作状态OK,CURLM_OK为常量值0
  1244. while ($active && $mrc == CURLM_OK) {
  1245. // 持续查询状态并不利于处理任务,每60ms检查一次,此时释放CPU,降低机器负载
  1246. usleep(50000);
  1247. // 如果批处理句柄OK,重复检查操作状态直至OK。select返回值异常时为-1,正常为1(因为只有1个批处理句柄)
  1248. if (curl_multi_select($mh) != -1) {
  1249. do {
  1250. $mrc = curl_multi_exec($mh, $active);
  1251. } while ($mrc == CURLM_CALL_MULTI_PERFORM);
  1252. }
  1253. }
  1254. // 获取返回结果
  1255. foreach($urlHandlers as $index => $ch) {
  1256. $urlData[$index] = curl_multi_getcontent($ch);
  1257. // 移除单个curl句柄
  1258. curl_multi_remove_handle($mh, $ch);
  1259. }
  1260. curl_multi_close($mh);
  1261. print_r($urlData);
  1262. **/
  1263. /**
  1264. $notice = $this->notice->find_all("message = '1' and state = '1' and type = '2' and ktime < '$time' and jtime > '$time'");//已有自动发送,这个是物流发送
  1265. foreach ($notice as $key=>$var)
  1266. {
  1267. $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']."%'";//正式发送的时候开启这个"'
  1268. //$where = "shop = '2' and waybill != '' and library = '2' and librarytime > '".(time()-15*24*3600)."'";
  1269. $ch = curl_init();
  1270. curl_setopt($ch,CURLOPT_URL,'http://'.$_SERVER['HTTP_HOST'].'/api/wlfs?v='.$var['id']);
  1271. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  1272. curl_setopt($ch,CURLOPT_HEADER,0);
  1273. curl_setopt($ch,CURLOPT_POST, 1);
  1274. curl_setopt($ch,CURLOPT_TIMEOUT,1);
  1275. //设置post数据
  1276. $post = array();
  1277. $post['data'] = array('where'=>$where,'var'=>$var);
  1278. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
  1279. $res = curl_exec($ch);
  1280. curl_close($ch);
  1281. //$this->_wlfs($where,$var);
  1282. }
  1283. **/
  1284. /**
  1285. $var = $this->notice->read(63);//已有自动发送,这个是物流发送
  1286. $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']."%'";//正式发送的时候开启这个"'
  1287. $this->_wlfs($where,$var);
  1288. **/
  1289. }
  1290. public function _wlfs()
  1291. {
  1292. $webhookregister = 0;
  1293. $post = $this->input->post(NULL, TRUE);
  1294. $data = $this->input->post('data',true);
  1295. $where = $data['where'];
  1296. $var = $data['var'];
  1297. $wlfs = array();
  1298. $shopid = $where['shop'];
  1299. @$this->allocation->insert(array('title'=>date('Y-m-d',time()).'-'.$shopid));
  1300. $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']."%'";//正式发送的时候开启这个"'
  1301. //$where = "shop = '".$where['shop']."' and waybill != '' and library = '2' and express = '3' and librarytime > '1636300800' and wlcontent not like '%".$where['wlcontent']."%'";//正式发送的时候开启这个"'
  1302. $data = $this->fullorderxw->find_all($where);
  1303. $csck = array();
  1304. foreach ($data as $k=>$v)
  1305. {
  1306. $vexpress = $v['express'];
  1307. $shop = $this->shop->read($v['shop']);
  1308. $express = $this->express->read($v['express']);
  1309. $service = $this->service->read($express['service']);
  1310. $country = $this->country->read($v['country']);
  1311. $v['country'] = $country['ename'];
  1312. $express['servicename'] =$service['title'];//增加快递名称
  1313. $v['cxcode'] = strtolower($express['cxcode']);//增加快递服务商码
  1314. if($v['expressstate'] == $var['logisticstatus'] && $v['wlyc'] == '0' && $v['wltype'] != '1' && $v['source'] != '1')//获取快递状态等于模板状态、订单状态等于模板状态、出库时间大于-、未加入物流异常、允许发送邮件状态、非线下单
  1315. {
  1316. if($v['shop'] < '7')// && $v['shouldmoney'] > 100)
  1317. {
  1318. $wlfs[] = array('v'=>$v,'id'=>$var['id']);
  1319. //$go = $this->_sdfs($v,$var['id']);//更新顺带发送
  1320. }
  1321. continue;
  1322. }
  1323. if(($express['cxcode'] == '' && $v['exstateerror'] == '') || ($express['cxcode'] == '' && $v['exstateerror'] != ''))
  1324. {
  1325. continue;
  1326. }
  1327. else if($express['cxcode'] == 'fedex' || $express['cxcode'] == 'usps' || $express['cxcode'] == 'dhl')// || $express['cxcode'] == 'cne' || $express['cxcode'] == 'dpex' || $express['cxcode'] == 'dpd'
  1328. {
  1329. /**
  1330. if($express['cxcode'] == 'dpex' || $express['cxcode'] == 'dpd')
  1331. {
  1332. $express['cxcode'] = 'cne';
  1333. }
  1334. **/
  1335. $logistics = $express['cxcode'];
  1336. }
  1337. else if(($express['cxcode'] == 'ups' || $express['cxcode'] == '17track') && $v['webhookregister'] == 1)
  1338. {
  1339. continue;
  1340. }
  1341. else if(($express['cxcode'] == 'ups' || $express['cxcode'] == '17track') && $v['webhookregister'] < 1)//使用webhook注册模式 || $express['cxcode'] == '17track'
  1342. {
  1343. $logistics = $express['cxcode'];
  1344. $webhookregister = 1;
  1345. }
  1346. else
  1347. {
  1348. //暂时不启用第三方,这里直接跳出
  1349. $this->fullorderxw->save(array('expressstate'=>'99'),$v['id']);
  1350. continue;
  1351. //$logistics = 'apismt';
  1352. //$v['express'] = strtolower($express['cxcode']);//替换为快递服务商码
  1353. }
  1354. $v['servicename'] =$service['title'];//增加快递名称
  1355. $v['url'] = $express['url'];//增加快递链接
  1356. @$fs = $this->$logistics->get_logistics($v);
  1357. $csck[] = array($v['number'],$fs['f']);
  1358. if(!isset($fs['f']))
  1359. {
  1360. $fs = $this->$logistics->get_logistics($v);
  1361. if(!isset($fs['f']))
  1362. {
  1363. continue;
  1364. }
  1365. if($fs['f'] == '1')
  1366. {
  1367. $v['express'] = $vexpress;
  1368. if($fs['exstate'] > $v['expressstate'] || isset($fs['webhookregister']))
  1369. {
  1370. $this->fullorderxw->save(array('expressstate'=>$fs['exstate'],'excontent'=>$fs['data'],'webhookregister'=>$webhookregister),$v['id']);
  1371. }
  1372. if($fs['exstate'] == $var['logisticstatus'] && $v['wlyc'] == '0' && $v['wltype'] != '1' && $v['source'] != '1')//获取快递状态等于模板状态、订单状态等于模板状态、出库时间大于-、未加入物流异常、允许发送邮件状态、非线下单
  1373. {
  1374. if($v['shop'] < '7')// && $v['shouldmoney'] > 100)
  1375. {
  1376. $wlfs[] = array('v'=>$v,'id'=>$var['id']);
  1377. //$go = $this->_sdfs($v,$var['id']);//更新顺带发送
  1378. }
  1379. }
  1380. }
  1381. /**
  1382. if($logistics == 'apismt')//第三方未购买,第三方查询直接进入无法查询状态
  1383. {
  1384. $this->fullorderxw->save(array('expressstate'=>'99'),$v['id']);
  1385. }
  1386. **/
  1387. }
  1388. else
  1389. {
  1390. if($fs['f'] == '1')
  1391. {
  1392. $v['express'] = $vexpress;
  1393. if($fs['exstate'] > $v['expressstate'])
  1394. {
  1395. $this->fullorderxw->save(array('expressstate'=>$fs['exstate'],'excontent'=>$fs['data'],'webhookregister'=>$webhookregister),$v['id']);
  1396. }
  1397. if($fs['exstate'] == $var['logisticstatus'] && $v['wlyc'] == '0' && $v['wltype'] != '1' && $v['source'] != '1')//获取快递状态等于模板状态、订单状态等于模板状态、出库时间大于-、未加入物流异常、允许发送邮件状态、非线下单
  1398. {
  1399. if($v['shop'] < '7')// && $v['shouldmoney'] > 100)
  1400. {
  1401. $wlfs[] = array('v'=>$v,'id'=>$var['id']);
  1402. //$go = $this->_sdfs($v,$var['id']);//更新顺带发送
  1403. }
  1404. }
  1405. }
  1406. }
  1407. }
  1408. @$this->allocation->insert(array('title'=>$shopid.'-'.json_encode($csck)));
  1409. if($wlfs)
  1410. {
  1411. foreach ($wlfs as $k=>$v)
  1412. {
  1413. $t1 = microtime(true);
  1414. $this->_sdfs($v['v'],$v['id']);
  1415. $t2 = microtime(true);
  1416. $t3 = (40-($t2-$t1) < 1)?1:round(40-($t2-$t1));
  1417. sleep($t3);
  1418. }
  1419. }
  1420. }
  1421. public function _zzold()
  1422. {
  1423. $data = $this->fullorderxw->find_all("library = '2' and waybill != '' and exstate != '4' and exstate != '5' and dtime > '1580486400'");
  1424. foreach ($data as $k=>$v)
  1425. {
  1426. $shop = $this->shop->read($v['shop']);
  1427. $express = $this->express->read($v['express']);
  1428. $service = $this->service->read($express['service']);
  1429. $country = $this->country->read($v['country']);
  1430. $v['country'] = $country['ename'];
  1431. $express['servicename'] =$service['title'];//增加快递名称
  1432. if($express['cxcode'] == '' && $v['exstateerror'] == '')
  1433. {
  1434. continue;
  1435. }
  1436. else if($express['cxcode'] == '' && $v['exstateerror'] != '')
  1437. {
  1438. continue;
  1439. }
  1440. else if($express['cxcode'] == 'fedex' || $express['cxcode'] == 'usps' || $express['cxcode'] == 'dhl' || $express['cxcode'] == 'cne' || $express['cxcode'] == 'dpex' || $express['cxcode'] == 'dpd')
  1441. {
  1442. $logistics = $express['cxcode'];
  1443. }
  1444. else
  1445. {
  1446. $logistics = 'apismt';
  1447. }
  1448. $v['express'] = strtolower($express['cxcode']);//替换为快递服务商码
  1449. $v['servicename'] =$service['title'];//增加快递名称
  1450. $v['url'] = $express['url'];//增加快递链接
  1451. $fs = $this->$logistics->get_logistics($v);
  1452. if(!isset($fs['f']))
  1453. {
  1454. $this->fullorderxw->save(array('exstate'=>'99'),$v['id']);
  1455. }
  1456. else
  1457. {
  1458. if($fs['f'] == '0')
  1459. {
  1460. $this->fullorderxw->save(array('excontent'=>$fs['content']),$v['id']);
  1461. }
  1462. if($fs['f'] == '2')
  1463. {
  1464. }
  1465. else
  1466. {
  1467. $this->fullorderxw->save(array('exstate'=>$fs['exstate'],'excontent'=>$fs['data']),$v['id']);
  1468. }
  1469. }
  1470. }
  1471. }
  1472. public function _query()
  1473. {
  1474. header('Access-Control-Allow-Origin: *');
  1475. $post = $this->input->post(NULL, TRUE);
  1476. if(isset($post['orderinfo']))
  1477. {
  1478. $list = array();
  1479. $orderinfo = $this->input->post('orderinfo',true);
  1480. $orderinfo = explode(',',trim($orderinfo,','));
  1481. foreach ($orderinfo as $v)
  1482. {
  1483. $exp="/^([0-9A-Za-z\\-_\\.]+)@([0-9a-z]+\\.[a-z]{2,3}(\\.[a-z]{2})?)$/i";
  1484. if(is_numeric($v) && mb_strlen($v) > 8)
  1485. {
  1486. $w = "orderinfo like '%$v%'";
  1487. }
  1488. else if(filter_var($v, FILTER_VALIDATE_EMAIL))
  1489. {
  1490. $w = "email like '%$v%'";
  1491. }
  1492. else
  1493. {
  1494. echo json_encode(array('site'=>0,'success'=>true));exit;
  1495. }
  1496. $data = $this->fullorderxw->find_all($w." and dtime > '1577811600'");
  1497. if(isset($data[0]))
  1498. {
  1499. if($data[0]['library'] != '2')
  1500. {
  1501. $list[] = array('orderinfo'=>$v,'site'=>1);
  1502. }
  1503. else if($data[0]['library'] == '2' && $data[0]['exstate'] == '99')
  1504. {
  1505. $list[] = array('orderinfo'=>$v,'site'=>2);
  1506. }
  1507. else if($data[0]['library'] == '2' && $data[0]['exstate'] != '99')
  1508. {
  1509. if($data[0]['excontent'] != '成功;' && $data[0]['excontent'] != '')
  1510. {
  1511. $list[] = array('orderinfo'=>$v,'site'=>3,'data'=>$data[0]['excontent']);
  1512. }
  1513. else
  1514. {
  1515. $list[] = array('orderinfo'=>$v,'site'=>2);
  1516. }
  1517. }
  1518. }
  1519. else
  1520. {
  1521. $list[] = array('orderinfo'=>$v,'site'=>0);
  1522. }
  1523. }
  1524. echo json_encode(array('t'=>count($orderinfo),'list'=>$list,'success'=>true));exit;
  1525. }
  1526. }
  1527. public function _logistics()
  1528. {
  1529. if(isset($_GET['waybill']))
  1530. {
  1531. $waybill = $this->input->get('waybill',true);
  1532. if($waybill == 1231233123)
  1533. {
  1534. $data = $this->fullorderxw->get_number('ASTE-30922-034');
  1535. echo json_encode(array('track'=>array('f'=>1,'data'=>$data['excontent']),'msg'=>'','success'=>1));exit;
  1536. }
  1537. //$express = $this->input->get('express',true);
  1538. $data = $this->fullorderxw->get_waybill($waybill);
  1539. if($data['excontent'])
  1540. {
  1541. //$a = $this->$express->get_logistics(array('waybill'=>$waybill));
  1542. echo json_encode(array('track'=>array('f'=>1,'data'=>$data['excontent']),'msg'=>'','success'=>1));exit;
  1543. }
  1544. else
  1545. {
  1546. echo json_encode(array('track'=>'','msg'=>'No logistics information','success'=>0));exit;
  1547. }
  1548. }
  1549. }
  1550. public function _klarna()
  1551. {
  1552. $shop = array();$cg = array();$sb = array();
  1553. $ftime = strtotime(date("Y-m-d 0:00:0",strtotime("-10 day")))+8*3600;
  1554. $ttime = strtotime(date("Y-m-d 8:00:0",time()));
  1555. $shopdata = $this->shop->find_all("type = '269' and klarnaname != '' and klarnapass != ''");
  1556. foreach($shopdata as $v)
  1557. {
  1558. $data = $this->fullorderxw->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");
  1559. foreach($data as $val)
  1560. {
  1561. $api = $this->_klarnaapi($val['paypal'],$val['shouldmoney'],$v['klarnaname'],$v['klarnapass']);
  1562. $header = $api['header'];
  1563. $api = $api['res'];
  1564. if(isset($api['error_messages'][0]))
  1565. {
  1566. if(stripos($api['error_messages'][0],'amount is 0 for') !== false)
  1567. {
  1568. $this->fullorderxw->save(array('klarna'=>3),$val['id']);
  1569. $sb[] = array($val['number'],$val['orderinfo'],'oooo3');
  1570. }
  1571. else
  1572. {
  1573. $this->fullorderxw->save(array('klarna'=>1,'klarnaerror'=>$api['error_messages'][0]),$val['id']);
  1574. $sb[] = array($val['number'],$val['orderinfo'],'oooo1');
  1575. }
  1576. }
  1577. else if($api == '')
  1578. {
  1579. if(isset($header['http_code']) && $header['http_code'] == 201)
  1580. {
  1581. $this->fullorderxw->save(array('klarna'=>2),$val['id']);
  1582. $cg[] = array($val['number'],$val['orderinfo'],'oooo2');
  1583. }
  1584. else
  1585. {
  1586. $this->fullorderxw->save(array('klarna'=>1,'klarnaerror'=>'未知错误'),$val['id']);
  1587. $sb[] = array($val['number'],$val['orderinfo'],'oooo0');
  1588. }
  1589. }
  1590. else if(isset($api['cs']))
  1591. {
  1592. $this->fullorderxw->save(array('klarna'=>1,'klarnaerror'=>'超时'),$val['id']);
  1593. $sb[] = array($val['number'],$val['orderinfo'],'oooo0');
  1594. }
  1595. else
  1596. {
  1597. $this->fullorderxw->save(array('klarna'=>1,'klarnaerror'=>'未知错误'),$val['id']);
  1598. $sb[] = array($val['number'],$val['orderinfo'],'oooo0');
  1599. }
  1600. }
  1601. }
  1602. echo "<pre>";
  1603. print_r($cg);
  1604. echo "<pre>";
  1605. print_r($sb);
  1606. }
  1607. public function _klarnaapi($paypal,$shouldmoney,$name,$pass)
  1608. {
  1609. $url = 'https://api-na.klarna.com/ordermanagement/v1/orders/'.$paypal.'/captures';
  1610. $data = '{"captured_amount": '.str_replace('.','',$shouldmoney).'}';
  1611. $header[] = "Content-Type:application/json";
  1612. $header[] = "Authorization: Basic ".base64_encode($name.":".$pass);
  1613. $ch = curl_init();
  1614. curl_setopt($ch, CURLOPT_URL, $url);
  1615. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  1616. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  1617. curl_setopt($ch, CURLINFO_HEADER_OUT, TRUE);
  1618. curl_setopt($ch, CURLOPT_POST, 1);
  1619. curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  1620. curl_setopt($ch, CURLOPT_TIMEOUT, 20);
  1621. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  1622. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  1623. $res = curl_exec($ch);
  1624. $header = curl_getinfo($ch);
  1625. if($res === false)
  1626. {
  1627. if(curl_errno($ch))
  1628. {
  1629. return array('res'=>'1','header'=>'','cs'=>1);
  1630. }
  1631. }
  1632. else
  1633. {
  1634. $res = json_decode($res,true);
  1635. return array('res'=>$res,'header'=>$header);
  1636. }
  1637. curl_close($ch);
  1638. }
  1639. public function _klarnadata($paypal,$name,$pass)
  1640. {
  1641. $url = 'https://api-na.klarna.com/ordermanagement/v1/orders/'.$paypal;
  1642. $header[] = "Content-Type:application/json";
  1643. $header[] = "Authorization: Basic ".base64_encode($name.":".$pass);
  1644. $ch = curl_init();
  1645. curl_setopt($ch, CURLOPT_URL, $url);
  1646. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  1647. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  1648. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  1649. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  1650. $res = curl_exec($ch);
  1651. curl_close($ch);
  1652. $res = json_decode($res,true);
  1653. $data = '';
  1654. if(isset($res['fraud_status']))
  1655. {
  1656. $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'];
  1657. }
  1658. return $data;
  1659. }
  1660. public function _hqpaypal()
  1661. {
  1662. $shop = $this->shop->find_all("paypalname != ''");
  1663. foreach ($shop as $val)
  1664. {
  1665. $d = $this->fullorderxw->find_all("shop = '".$val['id']."' and dtime > '".(time()-(5*24*3600))."' and dtime < '".(time()-(3*3600))."' and pay = '22' and klarnadata = ''");
  1666. foreach ($d as $v)
  1667. {
  1668. $paypal = $this->paypal->data($v['paypal'],$val);
  1669. if($paypal != '')
  1670. {
  1671. $this->fullorderxw->save(array('klarnadata'=>$paypal),$v['id']);
  1672. }
  1673. }
  1674. }
  1675. }
  1676. public function _hqstripe()
  1677. {
  1678. $shop = $this->shop->find_all("stripe != ''");
  1679. foreach ($shop as $val)
  1680. {
  1681. $d = $this->fullorderxw->find_all("shop = '".$val['id']."' and dtime > '".(time()-(5*24*3600))."' and dtime < '".time()."' and pay = '1211' and klarnadata = ''");
  1682. foreach ($d as $v)
  1683. {
  1684. $paypal = $this->_stripe($v['paypal'],$val['stripe']);
  1685. if($paypal != '')
  1686. {
  1687. $this->fullorderxw->save(array('klarnadata'=>$paypal),$v['id']);
  1688. }
  1689. }
  1690. }
  1691. }
  1692. public function _stripe($pay,$stripe)
  1693. {
  1694. $url = 'https://api.stripe.com/v1/payment_intents/'.$pay;
  1695. $header[] = "Authorization:Bearer ".$stripe;
  1696. $ch = curl_init();
  1697. curl_setopt($ch, CURLOPT_URL, $url);
  1698. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  1699. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  1700. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  1701. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  1702. $res = curl_exec($ch);
  1703. curl_close($ch);
  1704. $res = json_decode($res,true);
  1705. $k = '';
  1706. if(isset($res['shipping']['name']))
  1707. {
  1708. $line = ($res['shipping']['address']['line2'] != '')?$res['shipping']['address']['line1'].' '.$res['shipping']['address']['line2']:$res['shipping']['address']['line1'];
  1709. $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));
  1710. }
  1711. return $k;
  1712. }
  1713. public function _afterpay($paypal,$name,$pass)
  1714. {
  1715. $url = 'https://global-api.afterpay.com/v2/payments?ids='.$paypal;
  1716. $header[] = "Accept:application/json";
  1717. $header[] = "User-Agent: Readme.io API Simulator'";
  1718. $header[] = "Authorization: Basic ".base64_encode($name.":".$pass);
  1719. $ch = curl_init();
  1720. curl_setopt($ch, CURLOPT_URL, $url);
  1721. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  1722. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  1723. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  1724. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  1725. $res = curl_exec($ch);
  1726. curl_close($ch);
  1727. $res = json_decode($res,true);
  1728. $data = '';
  1729. if(isset($res['results'][0]['orderDetails']['consumer']['email']))
  1730. {
  1731. $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'];
  1732. $data = str_replace(',,',',',$data);
  1733. }
  1734. return $data;
  1735. }
  1736. public function _clearpay($paypal,$name,$pass)
  1737. {
  1738. $url = 'https://global-api.afterpay.com/v2/payments?ids='.$paypal;
  1739. $header[] = "Accept:application/json";
  1740. $header[] = "User-Agent: Readme.io API Simulator'";
  1741. $header[] = "Authorization: Basic ".base64_encode($name.":".$pass);
  1742. $ch = curl_init();
  1743. curl_setopt($ch, CURLOPT_URL, $url);
  1744. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  1745. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  1746. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  1747. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  1748. $res = curl_exec($ch);
  1749. curl_close($ch);
  1750. $res = json_decode($res,true);
  1751. $data = '';
  1752. if(isset($res['results'][0]['orderDetails']['consumer']['email']))
  1753. {
  1754. $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'];
  1755. $data = str_replace(',,',',',$data);
  1756. }
  1757. return $data;
  1758. }
  1759. public function _htmlstock()
  1760. {
  1761. if(isset($_GET['hq']))
  1762. {
  1763. $ProductsType = $this->typeclass->find_all("classid = '16' and hq = '1'",'id,title','sequence asc');
  1764. foreach ($ProductsType as $k=>$v)
  1765. {
  1766. if($v['title'] == 'Closure')
  1767. {
  1768. $ProductsType[$k]['title'] = 'Closure/Frontal';
  1769. }
  1770. }
  1771. $HairColor = $this->typeclass->find_all("classid = '8' and hq = '1'",'id,title','sequence asc');
  1772. $HairWavy = $this->typeclass->find_all("classid = '15' and hq = '1'",'id,title','sequence asc');
  1773. $WigType = $this->typeclass->find_all("classid = '18' and hq = '1'",'id,title','sequence asc');
  1774. $Length = $this->typeclass->find_all("classid = '14' and hq = '1'",'id,title','sequence asc');
  1775. echo json_encode(array('ProductsType'=>$ProductsType,'HairColor'=>$HairColor,'HairWavy'=>$HairWavy,'WigType'=>$WigType,'Length'=>$Length));exit;
  1776. //http://1.wepolicy.cn/api/htmlstock?hq=1
  1777. }
  1778. if(isset($_GET['page']))
  1779. {
  1780. $del = array();
  1781. $typeclass13 = $this->typeclass->find_all("classid = '13'");
  1782. $typeclass16 = $this->typeclass->find_all("classid = '16'");
  1783. foreach ($typeclass16 as $key=>$value)
  1784. {
  1785. foreach ($typeclass13 as $v)
  1786. {
  1787. $del[] = $value['title'].' '.$v['title'];
  1788. }
  1789. }
  1790. $page = $this->input->get('page',true);
  1791. $perpage = $this->input->get('perpage',true);
  1792. $category = $this->input->get('ProductsType',true);//类目
  1793. $color = $this->input->get('HairColor',true);//颜色
  1794. $lowe = $this->input->get('HairWavy',true);//花型
  1795. $lacetype = $this->input->get('WigType',true);//头套种类
  1796. $size = $this->input->get('Length',true);//长度
  1797. $title = $this->input->get('title',true);//传输文本
  1798. $warehouse = 5;
  1799. $state = $this->input->get('state',true);
  1800. $where = "warehouse = '5' and state = '0'";
  1801. if($category)
  1802. {
  1803. $where .= " and features like '%-$category-%'";
  1804. }
  1805. if($color)
  1806. {
  1807. $where .= " and features like '%-$color-%'";
  1808. }
  1809. if($lowe)
  1810. {
  1811. $where .= " and features like '%-$lowe-%'";
  1812. }
  1813. if($lacetype)
  1814. {
  1815. $where .= " and features like '%-$lacetype-%'";
  1816. }
  1817. if($size)
  1818. {
  1819. $where .= " and features like '%-$size-%'";
  1820. }
  1821. if($title)
  1822. {
  1823. $where .= " and title like '%$title%'";
  1824. }
  1825. $order_str = "id desc";
  1826. if(empty($page))
  1827. {
  1828. $start = 0;
  1829. $perpage = 1;
  1830. }
  1831. else
  1832. {
  1833. $start = ($page - 1)*$perpage;
  1834. }
  1835. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features,number',$order_str,$start,$perpage);
  1836. $data = array();
  1837. foreach ($info_list as $key=>$value)
  1838. {
  1839. $c = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "5" and features = "'.$value['features'].'" and zd = ""');
  1840. if($c > 1)
  1841. {
  1842. $data[] = array('Item'=>str_replace($del,'',$value['title']),'Stock'=>$c);
  1843. }
  1844. }
  1845. $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  1846. $pagenum = ceil($total/$perpage);
  1847. $over = $total-($start+$perpage);
  1848. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($data));//总数量,剩余数量,总页数,数据
  1849. echo json_encode($rows);exit;
  1850. ///api/htmlstock?page=1&perpage=50&ProductsType=&HairColor=&HairWavy=&WigType=&Length= //页数、每页数量、类目、颜色、花型、头套种类、尺寸
  1851. }
  1852. }
  1853. public function _17track()
  1854. {
  1855. $xq = array();
  1856. $j = file_get_contents('PHP://input');
  1857. $j = json_decode($j, true);
  1858. if(isset($j['data']) && isset($j['sign']))
  1859. {
  1860. $sh = hash("sha256",$j['event'].'/'.json_encode($j['data']).'/0811AC1711EAABB7D764D04B824F8C2D');
  1861. if($j['data']['number'] != '')
  1862. {
  1863. $f = 'fullorder';
  1864. $d = $this->fullorderxw->get_waybill($j['data']['number']);
  1865. if(!$d)
  1866. {
  1867. $f = 'fullordersmt';
  1868. $d = $this->fullordersmt->get_waybill($j['data']['number']);
  1869. }
  1870. if(!$d)
  1871. {
  1872. exit;
  1873. }
  1874. if($j['data']['track']['e'] == 0)//查询不到
  1875. {
  1876. $exstate = 0;//无信息
  1877. }
  1878. else if($j['data']['track']['e'] == 10)//运输途中
  1879. {
  1880. $exstate = 3;//在途中
  1881. }
  1882. else if($j['data']['track']['e'] == 20)//运输过久
  1883. {
  1884. $exstate = 3;//在途中
  1885. }
  1886. else if($j['data']['track']['e'] == 30)//到达待取
  1887. {
  1888. $exstate = 5;//派送中
  1889. }
  1890. else if($j['data']['track']['e'] == 35)//投递失败
  1891. {
  1892. $exstate = 1;//派送异常
  1893. }
  1894. else if($j['data']['track']['e'] == 40)//成功签收
  1895. {
  1896. $exstate = 6;//签收
  1897. }
  1898. else if($j['data']['track']['e'] == 50)//可能异常
  1899. {
  1900. $exstate = 1;//派送异常
  1901. }
  1902. if(isset($j['data']['track']['z1'][0]))
  1903. {
  1904. foreach ($j['data']['track']['z1'] as $v)
  1905. {
  1906. $xq .= $v['a'].' ['.$v['c'].'] '.$v['z'].'<br />';// a日期 c地址 z状态
  1907. }
  1908. }
  1909. $this->$f->save(array('expressstate'=>$exstate,'excontent'=>$xq),$d['id']);
  1910. $time = time();
  1911. $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."'");
  1912. if($notice && $d['wlyc'] == '0' && $d['wltype'] != '1' && $d['source'] != '1' && stripos($d['wlcontent'],$notice[0]['title']) === false)
  1913. {
  1914. $this->_sdfs($d,$notice[0]['id']);
  1915. }
  1916. }
  1917. }
  1918. }
  1919. }