Model_notice_old.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2. class Model_notice extends Lin_Model
  3. {
  4. function __construct(){
  5. parent::__construct();
  6. $this->load->database();
  7. $this->table = 'notice';
  8. $this->load_table('notice');
  9. }
  10. public function get_type($shop,$type,$logisticstatus,$ordertatus)//查找符合消息发送条件的信息
  11. {
  12. if($type == 1)
  13. {
  14. return $this->find("shop = '$shop' and type = '$type' and ordertatus = '$ordertatus' and state = 1 and ktime < 'time()' and jtime < 'time()'");
  15. }
  16. else if($type == 2)
  17. {
  18. return $this->find("shop = '$shop' and type = '$type' and logisticstatus = '$logisticstatus' and state = 1 and ktime < 'time()' and jtime < 'time()'");
  19. }
  20. else if($type == 3)
  21. {
  22. return $this->find("shop = '$shop' and type = '$type' and state = 1 and ktime < 'time()' and jtime < 'time()'");
  23. }
  24. }
  25. //所属店铺、模板类型、物流状态/订单状态
  26. /** 通过订单状态 */
  27. public function get_ordertatus($ordertatus)
  28. {
  29. return $this->find("ordertatus = '$ordertatus'");
  30. }
  31. public function get_go($list,$shop,$genre,$option)
  32. {
  33. //aptsmt获取订单:崔付款、确认地址
  34. $time = time();
  35. $data = $this->find("shop = '".$shop['id']."' and ".$genre." = '$option' and ktime < '$time' and jtime > '$time' and state = 1");//$genre三种模式:订单状态、物流跟踪、营销。启用状态下,有效期内搜索该店铺设置
  36. if($data)//如果可用模板配置
  37. {
  38. $message=2;
  39. $list['orderinfo'] = ($message==1)?substr($list['orderinfo'],1):$list['orderinfo'];
  40. if($message==1)
  41. {
  42. $expresscode = (isset($express['title']))?$express['title']:'';
  43. }
  44. else
  45. {
  46. $expresscode = (isset($express['aecode']))?$express['aecode']:'';
  47. }
  48. if(!isset($list['country']))
  49. {
  50. $list['waybill'] = '';
  51. $list['phone'] = '';
  52. $list['zipcode'] = '';
  53. $list['country'] = '';
  54. $list['province'] = '';
  55. $list['city'] = '';
  56. $list['address'] = '';
  57. $list['product'] = '';
  58. }
  59. $express['url'] = (isset($express['url']))?$express['url']:'';
  60. $list['userName'] = (isset($list['userName']))?$list['userName']:'';
  61. $list['orderid'] = (isset($list['orderid']))?$list['orderid']:'';
  62. $list['name'] = (isset($list['name']))?$list['name']:'';
  63. $list['bname'] = (isset($list['bname']))?$list['bname']:'';
  64. $list['sname'] = (isset($list['sname']))?$list['sname']:'';
  65. $list['saddress'] = (isset($list['saddress']))?$list['saddress']:'';
  66. $list['baddress'] = (isset($list['baddress']))?$list['baddress']:'';
  67. $list['quantity'] = (isset($list['quantity']))?(($list['quantity'] > '1')?$list['quantity'].' packages of':''):'';
  68. $list['parameter'] = (isset($list['parameter']))?$list['parameter']:'';
  69. $product = '';
  70. if($list['product'] != '')
  71. {
  72. $list['product'] = str_replace("'","",$list['product']);
  73. if($list['link'] != '' && $list['source'] != '1')
  74. {
  75. $pt = explode(',',$list['product']);
  76. $lk = explode(',',$list['link']);
  77. for($i=0;$i<count($pt);$i++)
  78. {
  79. $a = $pt[$i];
  80. //$a = (stripos($pt[$i],'Lace Front Wig Body Wave Human Hair Wigs Pre Plucked Brazilian Virgin Hair') !== false || stripos($pt[$i],'Deep Wave Wig 100 Human Hair Swiss Lace Curly Hair Lace Front Wig') !== false || stripos($pt[$i],'Alipearl Lace Front Wig Silky Straight 100% Virgin Human Hair') !== false || stripos($pt[$i],'Long Wigs Water Wave Lace Front Wigs Natural Wave Wigs For Sale') !== false || stripos($pt[$i],'Deep Wave Long Hair Wigs Lace Front Wigs Cheap Human Hair Wigs') !== false || stripos($pt[$i],'Long Wigs Loose Deep Wave Lace Front Wigs For Black Women') !== false || stripos($pt[$i],'Long Black Wigs Body Wave Lace Front Wigs With Baby Hair') !== false || stripos($pt[$i],'Long Curly Wigs Lace Front Wigs Human Hair Lace Front Wigs') !== false || stripos($pt[$i],'Blonde Skunk Stripe Hair Natural Body Wave Hairstyle Lace Wigs for Women') !== false)?'<font style="color:#F39">'.$pt[$i].'</font>':$pt[$i];
  81. if(isset($lk[$i]) && stripos($content,'<img') !== false)
  82. {
  83. $product .= ($product != '')?' , <a href="'.$lk[$i].'" target="_blank">'.$a.'</a>':'<a href="'.$lk[$i].'" target="_blank">'.$a.'</a>';
  84. }
  85. else
  86. {
  87. $product .= ($product != '')?' , '.$a:$a;
  88. }
  89. }
  90. }
  91. }
  92. $firstName = explode(' ',$list['name']);
  93. $t= array('$userName','$firstName','$orderid','$trackingNumber','$expressCompany','$expressWebsite','$contactPerson','$Bname','$Sname','$mobileNo','$zip','$country','$province','$city','$recipientAddress','$productInfo','$ShipAddress','$BillAddress','$Quantity','$parameter','$producttitle',"[Smile]","[Shy]","[Tongue]","[Titter]","[Admire]","[Risus]","[Dance]","[Blow a Kiss]","[Comfort]","[Hug]","[Put on steam]","[Victory]","[Strong]","[Kiss]","[Anthomaniac]","[Grin]","[Seek]","[Call out]","[Cast accounts]","[Miser]","[Good idea]","[Grimace]","[Angel]","[Good bye]","[Drool]","[Enjoy]","[Erotomania]","[Dumbstruck]","[Thinking]","[Puzzle]","[Query]","[No money]","[Bored]","[Suspect]","[Hush]","[Complacent]","[Shake head]","[Cold]","[Awkward]","[Smirk]","[Amazed]","[However]","[Sweat]","[Loneliness]","[Sleepy]","[Faint]","[Distressed]","[Grievance]","[Sob]","[Cry]","[Wail]","[Obey]","[Sorry]","[Bye]","[Frown]","[So tired]","[Fall ill]","[Vomit]","[Fall on evil days]","[Surprised]","[Stunned]","[Shut up]","[Due to flat]","[Despise you]","[Rage]","[Angry]","[Mammon]","[Learn from lei feng]","[Wishing you prosperity]","[Waiter]","[Boss]","[Evil]","[Challenge]","[CS]","[Invisible man]","[Bomb]","[Scream]","[Beautiful girl]","[Handsome boy]","[Fortune cat]","[Deal]","[Handclap]","[Handshake]","[Lips]","[Rose]","[Wither]","[Heart]","[Heartbreak]","[Money]","[Shopping]","[Gift]","[Email]","[Phone]","[Cheers]","[Clock]","[Waiting]","[Late]","[Plane]","[Alipay]");//需要被替换的内容
  94. $h= array($list['name'],$firstName,$list['orderinfo'],$list['waybill'],$expresscode,$express['url'],$list['name'],$list['bname'],$list['sname'],$list['phone'],$list['zipcode'],$list['country'],$list['province'],$list['city'],$list['address'],$list['product'],$list['saddress'],$list['baddress'],$list['quantity'],$list['parameter'],$product,"/:000","/:001","/:002","/:003","/:004","/:005","/:006","/:007","/:008","/:009","/:010","/:011","/:012","/:013","/:014","/:015","/:016","/:017","/:018","/:019","/:020","/:021","/:022","/:023","/:024","/:025","/:026","/:027","/:028","/:029","/:030","/:031","/:032","/:033","/:034","/:035","/:036","/:037","/:038","/:039","/:040","/:041","/:042","/:043","/:044","/:045","/:046","/:047","/:048","/:049","/:050","/:051","/:052","/:053","/:054","/:055","/:056","/:057","/:058","/:059","/:060","/:061","/:062","/:063","/:064","/:065","/:066","/:067","/:068","/:069","/:070","/:071","/:072","/:073","/:074","/:075","/:076","/:077","/:078","/:079","/:080","/:081","/:082","/:083","/:084","/:085","/:086","/:087","/:088","/:089","/:090","/:091","/:092","/:093","/:094","/:095","/:096","/:097","/:098");//替换的内容
  95. $content = str_replace($t,$h,$data['content']);
  96. if($data['message'] == 1)//如果是发送邮件
  97. {
  98. if(!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$list['email']))
  99. {
  100. return '邮箱地址错误,请检查';exit;
  101. }
  102. $emailbt = ($data['emailtitle'] != '')?str_replace($t,$h,$data['emailtitle']):'The product you purchased has a new progress';
  103. $this->load->library('email');
  104. $config['protocol'] = 'smtp';
  105. $config['smtp_host'] = 'smtpdm-ap-southeast-1.aliyun.com';
  106. $config['smtp_port'] = 465;
  107. $config['smtp_user'] = 'service@email.supernovahair.com';
  108. $config['smtp_pass'] = 'LONGyihair374';
  109. $config['smtp_crypto'] = 'ssl';
  110. $config['crlf'] = "\r\n";
  111. $config['newline'] = "\r\n";
  112. $this->email->initialize($config);
  113. $this->email->set_newline("\r\n");
  114. $this->email->from('service@email.supernovahair.com',$shopname);
  115. $this->email->to($list['email']);//收件
  116. $this->email->subject($emailbt);//标题
  117. $this->email->message($content);//内容
  118. if ($this->email->send())
  119. {
  120. return 1;//成功
  121. }
  122. else
  123. {
  124. return '发送失败';
  125. }
  126. }
  127. else if($data['message'] == 2 && $list['userid'] != '')//如果是速卖通站内信,用户ID不为空
  128. {
  129. $ch = curl_init();
  130. $url = 'http://39.100.97.180/smt.php';
  131. curl_setopt($ch,CURLOPT_URL,$url);
  132. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  133. curl_setopt($ch,CURLOPT_HEADER,0);
  134. curl_setopt($ch,CURLOPT_POST, 1);
  135. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
  136. //设置post数据
  137. $post = array();
  138. $post['shopid'] = $shop['brandname'];//速卖通店铺ID
  139. $post['userid'] = $list['userid'];//速卖通买家ID
  140. $post['message_type'] = 'order';//消息类型,product(商品)、member(会员,包含店铺)、order(订单)
  141. $post['content'] = $content;//发送内容
  142. $post['code'] = $shop['code'];
  143. $post['order'] = $list['orderinfo'];
  144. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
  145. $res = curl_exec($ch);
  146. curl_close($ch);
  147. $res = json_decode($res,true);
  148. if(isset($res['is_success']))
  149. {
  150. return 1;//成功
  151. }
  152. else
  153. {
  154. return isset($res['error_msg'])?$res['error_msg']:(isset($res['sub_msg'])?$res['sub_msg']:'发送失败');
  155. }
  156. }
  157. else
  158. {
  159. return '邮箱错误或者没有UserID';
  160. }
  161. }
  162. else
  163. {
  164. return '无可用站内信模板';
  165. }
  166. }
  167. public function get_god($list,$shop,$express,$notice)//单个订单整体模式
  168. {
  169. $list['orderinfo'] = ($notice['message']==1)?substr($list['orderinfo'],1):$list['orderinfo'];
  170. if($notice['message']==1)
  171. {
  172. $expresscode = (isset($express['title']))?$express['title']:'';
  173. }
  174. else
  175. {
  176. $expresscode = (isset($express['aecode']))?$express['aecode']:'';
  177. }
  178. if(!isset($list['country']))
  179. {
  180. $list['waybill'] = '';
  181. $list['phone'] = '';
  182. $list['zipcode'] = '';
  183. $list['country'] = '';
  184. $list['province'] = '';
  185. $list['city'] = '';
  186. $list['address'] = '';
  187. $list['product'] = '';
  188. }
  189. $express['url'] = (isset($express['url']))?$express['url']:'';
  190. $list['userName'] = (isset($list['userName']))?$list['userName']:'';
  191. $list['orderid'] = (isset($list['orderid']))?$list['orderid']:'';
  192. $list['name'] = (isset($list['name']))?$list['name']:'';
  193. $list['bname'] = (isset($list['bname']))?$list['bname']:'';
  194. $list['sname'] = (isset($list['sname']))?$list['sname']:'';
  195. $list['saddress'] = (isset($list['saddress']))?$list['saddress']:'';
  196. $list['baddress'] = (isset($list['baddress']))?$list['baddress']:'';
  197. $list['quantity'] = (isset($list['quantity']))?(($list['quantity'] > '1')?$list['quantity'].' packages of':''):'';
  198. $list['parameter'] = (isset($list['parameter']))?$list['parameter']:'';
  199. $list['waybill'] = (isset($list['waybill']))?$list['waybill']:'';
  200. $product = '';
  201. if($list['product'] != '')
  202. {
  203. $list['product'] = str_replace("'","",$list['product']);
  204. if($list['link'] != '' && $list['source'] != '1')
  205. {
  206. $pt = explode(',',$list['product']);
  207. $lk = explode(',',$list['link']);
  208. for($i=0;$i<count($pt);$i++)
  209. {
  210. $a = $pt[$i];
  211. //$a = (stripos($pt[$i],'Lace Front Wig Body Wave Human Hair Wigs Pre Plucked Brazilian Virgin Hair') !== false || stripos($pt[$i],'Deep Wave Wig 100 Human Hair Swiss Lace Curly Hair Lace Front Wig') !== false || stripos($pt[$i],'Alipearl Lace Front Wig Silky Straight 100% Virgin Human Hair') !== false || stripos($pt[$i],'Long Wigs Water Wave Lace Front Wigs Natural Wave Wigs For Sale') !== false || stripos($pt[$i],'Deep Wave Long Hair Wigs Lace Front Wigs Cheap Human Hair Wigs') !== false || stripos($pt[$i],'Long Wigs Loose Deep Wave Lace Front Wigs For Black Women') !== false || stripos($pt[$i],'Long Black Wigs Body Wave Lace Front Wigs With Baby Hair') !== false || stripos($pt[$i],'Long Curly Wigs Lace Front Wigs Human Hair Lace Front Wigs') !== false || stripos($pt[$i],'Blonde Skunk Stripe Hair Natural Body Wave Hairstyle Lace Wigs for Women') !== false)?'<font style="color:#F39">'.$pt[$i].'</font>':$pt[$i];
  212. if(isset($lk[$i]) && stripos($notice['content'],'<img') !== false)
  213. {
  214. $product .= ($product != '')?' , <a href="'.$lk[$i].'" target="_blank">'.$a.'</a>':'<a href="'.$lk[$i].'" target="_blank">'.$a.'</a>';
  215. }
  216. else
  217. {
  218. $product .= ($product != '')?' , '.$a:$a;
  219. }
  220. }
  221. }
  222. }
  223. $firstName = explode(' ',$list['name']);
  224. $t= array('$userName','$firstName','$orderid','$trackingNumber','$expressCompany','$expressWebsite','$contactPerson','$Bname','$Sname','$mobileNo','$zip','$country','$province','$city','$recipientAddress','$productInfo','$ShipAddress','$BillAddress','$Quantity','$parameter','$producttitle',"[Smile]","[Shy]","[Tongue]","[Titter]","[Admire]","[Risus]","[Dance]","[Blow a Kiss]","[Comfort]","[Hug]","[Put on steam]","[Victory]","[Strong]","[Kiss]","[Anthomaniac]","[Grin]","[Seek]","[Call out]","[Cast accounts]","[Miser]","[Good idea]","[Grimace]","[Angel]","[Good bye]","[Drool]","[Enjoy]","[Erotomania]","[Dumbstruck]","[Thinking]","[Puzzle]","[Query]","[No money]","[Bored]","[Suspect]","[Hush]","[Complacent]","[Shake head]","[Cold]","[Awkward]","[Smirk]","[Amazed]","[However]","[Sweat]","[Loneliness]","[Sleepy]","[Faint]","[Distressed]","[Grievance]","[Sob]","[Cry]","[Wail]","[Obey]","[Sorry]","[Bye]","[Frown]","[So tired]","[Fall ill]","[Vomit]","[Fall on evil days]","[Surprised]","[Stunned]","[Shut up]","[Due to flat]","[Despise you]","[Rage]","[Angry]","[Mammon]","[Learn from lei feng]","[Wishing you prosperity]","[Waiter]","[Boss]","[Evil]","[Challenge]","[CS]","[Invisible man]","[Bomb]","[Scream]","[Beautiful girl]","[Handsome boy]","[Fortune cat]","[Deal]","[Handclap]","[Handshake]","[Lips]","[Rose]","[Wither]","[Heart]","[Heartbreak]","[Money]","[Shopping]","[Gift]","[Email]","[Phone]","[Cheers]","[Clock]","[Waiting]","[Late]","[Plane]","[Alipay]");//需要被替换的内容
  225. $h= array($list['name'],$firstName[0],$list['orderinfo'],$list['waybill'],$expresscode,$express['url'],$list['name'],$list['bname'],$list['sname'],$list['phone'],$list['zipcode'],$list['country'],$list['province'],$list['city'],$list['address'],$list['product'],$list['saddress'],$list['baddress'],$list['quantity'],$list['parameter'],$product,"/:000","/:001","/:002","/:003","/:004","/:005","/:006","/:007","/:008","/:009","/:010","/:011","/:012","/:013","/:014","/:015","/:016","/:017","/:018","/:019","/:020","/:021","/:022","/:023","/:024","/:025","/:026","/:027","/:028","/:029","/:030","/:031","/:032","/:033","/:034","/:035","/:036","/:037","/:038","/:039","/:040","/:041","/:042","/:043","/:044","/:045","/:046","/:047","/:048","/:049","/:050","/:051","/:052","/:053","/:054","/:055","/:056","/:057","/:058","/:059","/:060","/:061","/:062","/:063","/:064","/:065","/:066","/:067","/:068","/:069","/:070","/:071","/:072","/:073","/:074","/:075","/:076","/:077","/:078","/:079","/:080","/:081","/:082","/:083","/:084","/:085","/:086","/:087","/:088","/:089","/:090","/:091","/:092","/:093","/:094","/:095","/:096","/:097","/:098");//替换的内容
  226. $notice['content'] = str_replace($t,$h,$notice['content']);
  227. if($notice['emailtitle'] != '')
  228. {
  229. $notice['emailtitle'] = str_replace($t,$h,$notice['emailtitle']);
  230. $emailbt = $notice['emailtitle'];
  231. }
  232. else
  233. {
  234. $emailbt = $shop['brandname'].' Hair Service- Order Confirmation #'.$list['orderinfo'];
  235. }
  236. if($notice['message'] == 1)//如果是发送邮件
  237. {
  238. if(!$notice['email']['smtp_host'] || !$notice['email']['smtp_user'] || !$notice['email']['smtp_pass'])
  239. {
  240. return '此店铺没有配置邮件服务器信息!';exit;
  241. }
  242. if(!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$list['email']))
  243. {
  244. return '邮箱地址错误,请检查';exit;
  245. }
  246. $this->load->library('email');
  247. $config['protocol'] = $notice['email']['protocol'];
  248. $config['smtp_host'] = $notice['email']['smtp_host'];
  249. $config['smtp_port'] = $notice['email']['smtp_port'];
  250. $config['smtp_timeout']='30';
  251. $config['smtp_user'] = $notice['email']['smtp_user'];
  252. $config['smtp_pass'] = $notice['email']['smtp_pass'];
  253. $config['smtp_crypto'] = $notice['email']['smtp_crypto'];
  254. $config['crlf'] = "\r\n";
  255. $config['newline'] = "\r\n";
  256. if(stripos($notice['content'],'</p>') !== false)
  257. {
  258. $notice['content'] = str_replace(array('<p>','<p style="'),array('<p style="margin:0px;">','<p style="margin:0px;'),$notice['content']);
  259. $config['mailtype'] = "html";
  260. }
  261. $this->email->initialize($config);
  262. $this->email->set_newline("\r\n");
  263. $this->email->from($notice['email']['smtp_user'],$shop['shopname']);//发送方
  264. $this->email->to($list['email']);//收件
  265. $this->email->subject($emailbt);//标题
  266. $this->email->message($notice['content']);//内容
  267. if ($this->email->send())
  268. {
  269. return 1;
  270. }
  271. else
  272. {
  273. return $this->email->print_debugger(array('headers'));
  274. }
  275. }
  276. else if($notice['message'] == 2 && $list['userid'] != '')//如果是速卖通站内信,用户ID不为空
  277. {
  278. $ch = curl_init();
  279. $url = 'http://39.100.97.180/smt.php';
  280. curl_setopt($ch,CURLOPT_URL,$url);
  281. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  282. curl_setopt($ch,CURLOPT_HEADER,0);
  283. curl_setopt($ch,CURLOPT_POST, 1);
  284. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
  285. //设置post数据
  286. $post = array();
  287. $post['shopid'] = $shop['brandname'];//速卖通店铺ID
  288. $post['userid'] = $list['userid'];//速卖通买家ID
  289. $post['message_type'] = 'order';//消息类型,product(商品)、member(会员,包含店铺)、order(订单)
  290. $post['content'] = $notice['content'];//发送内容
  291. $post['code'] = $shop['code'];
  292. $post['order'] = $list['orderinfo'];
  293. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
  294. $res = curl_exec($ch);
  295. curl_close($ch);
  296. $res = json_decode($res,true);
  297. if(isset($res['is_success']))
  298. {
  299. return 1;//成功
  300. }
  301. else
  302. {
  303. return isset($res['error_msg'])?$res['error_msg']:(isset($res['sub_msg'])?$res['sub_msg']:'发送失败');
  304. }
  305. }
  306. else
  307. {
  308. return '无可用发送平台!';
  309. }
  310. }
  311. public function get_smtone($list,$shop,$content)//单个订单非快递信息模式模式
  312. {
  313. if(!isset($list['country']))
  314. {
  315. $list['waybill'] = '';
  316. $list['phone'] = '';
  317. $list['zipcode'] = '';
  318. $list['country'] = '';
  319. $list['province'] = '';
  320. $list['city'] = '';
  321. $list['address'] = '';
  322. $list['product'] = '';
  323. }
  324. $expresscode = (isset($express['aecode']))?$express['aecode']:'';
  325. $express['url'] = (isset($express['url']))?$express['url']:'';
  326. $list['userName'] = (isset($list['userName']))?$list['userName']:'';
  327. $list['orderid'] = (isset($list['orderid']))?$list['orderid']:'';
  328. $list['name'] = (isset($list['name']))?$list['name']:'';
  329. $list['bname'] = (isset($list['bname']))?$list['bname']:'';
  330. $list['sname'] = (isset($list['sname']))?$list['sname']:'';
  331. $product = '';
  332. if($list['product'] != '')
  333. {
  334. $list['product'] = str_replace("'","",$list['product']);
  335. if($list['link'] != '' && $list['source'] != '1')
  336. {
  337. $pt = explode(',',$list['product']);
  338. $lk = explode(',',$list['link']);
  339. for($i=0;$i<count($pt);$i++)
  340. {
  341. $a = $pt[$i];
  342. //$a = (stripos($pt[$i],'Lace Front Wig Body Wave Human Hair Wigs Pre Plucked Brazilian Virgin Hair') !== false || stripos($pt[$i],'Deep Wave Wig 100 Human Hair Swiss Lace Curly Hair Lace Front Wig') !== false || stripos($pt[$i],'Alipearl Lace Front Wig Silky Straight 100% Virgin Human Hair') !== false || stripos($pt[$i],'Long Wigs Water Wave Lace Front Wigs Natural Wave Wigs For Sale') !== false || stripos($pt[$i],'Deep Wave Long Hair Wigs Lace Front Wigs Cheap Human Hair Wigs') !== false || stripos($pt[$i],'Long Wigs Loose Deep Wave Lace Front Wigs For Black Women') !== false || stripos($pt[$i],'Long Black Wigs Body Wave Lace Front Wigs With Baby Hair') !== false || stripos($pt[$i],'Long Curly Wigs Lace Front Wigs Human Hair Lace Front Wigs') !== false || stripos($pt[$i],'Blonde Skunk Stripe Hair Natural Body Wave Hairstyle Lace Wigs for Women') !== false)?'<font style="color:#F39">'.$pt[$i].'</font>':$pt[$i];
  343. if(isset($lk[$i]) && stripos($content,'<img') !== false)
  344. {
  345. $product .= ($product != '')?' , <a href="'.$lk[$i].'" target="_blank">'.$a.'</a>':'<a href="'.$lk[$i].'" target="_blank">'.$a.'</a>';
  346. }
  347. else
  348. {
  349. $product .= ($product != '')?' , '.$a:$a;
  350. }
  351. }
  352. }
  353. }
  354. $firstName = explode(' ',$list['name']);
  355. $t= array('$userName','$firstName','$orderid','$trackingNumber','$expressCompany','$expressWebsite','$contactPerson','$Bname','$Sname','$mobileNo','$zip','$country','$province','$city','$recipientAddress','$productInfo','$ShipAddress','$BillAddress','$Quantity','$parameter','$producttitle',"[Smile]","[Shy]","[Tongue]","[Titter]","[Admire]","[Risus]","[Dance]","[Blow a Kiss]","[Comfort]","[Hug]","[Put on steam]","[Victory]","[Strong]","[Kiss]","[Anthomaniac]","[Grin]","[Seek]","[Call out]","[Cast accounts]","[Miser]","[Good idea]","[Grimace]","[Angel]","[Good bye]","[Drool]","[Enjoy]","[Erotomania]","[Dumbstruck]","[Thinking]","[Puzzle]","[Query]","[No money]","[Bored]","[Suspect]","[Hush]","[Complacent]","[Shake head]","[Cold]","[Awkward]","[Smirk]","[Amazed]","[However]","[Sweat]","[Loneliness]","[Sleepy]","[Faint]","[Distressed]","[Grievance]","[Sob]","[Cry]","[Wail]","[Obey]","[Sorry]","[Bye]","[Frown]","[So tired]","[Fall ill]","[Vomit]","[Fall on evil days]","[Surprised]","[Stunned]","[Shut up]","[Due to flat]","[Despise you]","[Rage]","[Angry]","[Mammon]","[Learn from lei feng]","[Wishing you prosperity]","[Waiter]","[Boss]","[Evil]","[Challenge]","[CS]","[Invisible man]","[Bomb]","[Scream]","[Beautiful girl]","[Handsome boy]","[Fortune cat]","[Deal]","[Handclap]","[Handshake]","[Lips]","[Rose]","[Wither]","[Heart]","[Heartbreak]","[Money]","[Shopping]","[Gift]","[Email]","[Phone]","[Cheers]","[Clock]","[Waiting]","[Late]","[Plane]","[Alipay]");//需要被替换的内容
  356. $h= array($list['name'],$firstName[0],$list['orderinfo'],$list['waybill'],$expresscode,$express['url'],$list['name'],$list['bname'],$list['sname'],$list['phone'],$list['zipcode'],$list['country'],$list['province'],$list['city'],$list['address'],$list['product'],$list['saddress'],$list['baddress'],$list['quantity'],$list['parameter'],$product,"/:000","/:001","/:002","/:003","/:004","/:005","/:006","/:007","/:008","/:009","/:010","/:011","/:012","/:013","/:014","/:015","/:016","/:017","/:018","/:019","/:020","/:021","/:022","/:023","/:024","/:025","/:026","/:027","/:028","/:029","/:030","/:031","/:032","/:033","/:034","/:035","/:036","/:037","/:038","/:039","/:040","/:041","/:042","/:043","/:044","/:045","/:046","/:047","/:048","/:049","/:050","/:051","/:052","/:053","/:054","/:055","/:056","/:057","/:058","/:059","/:060","/:061","/:062","/:063","/:064","/:065","/:066","/:067","/:068","/:069","/:070","/:071","/:072","/:073","/:074","/:075","/:076","/:077","/:078","/:079","/:080","/:081","/:082","/:083","/:084","/:085","/:086","/:087","/:088","/:089","/:090","/:091","/:092","/:093","/:094","/:095","/:096","/:097","/:098");//替换的内容
  357. $content = str_replace($t,$h,$content);
  358. if($list['userid'] != '')//用户ID不为空
  359. {
  360. $ch = curl_init();
  361. $url = 'http://39.100.97.180/smt.php';
  362. curl_setopt($ch,CURLOPT_URL,$url);
  363. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  364. curl_setopt($ch,CURLOPT_HEADER,0);
  365. curl_setopt($ch,CURLOPT_POST, 1);
  366. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,600);
  367. //设置post数据
  368. $post = array();
  369. $post['shopid'] = $shop['brandname'];//速卖通店铺ID
  370. $post['userid'] = $list['userid'];//速卖通买家ID
  371. $post['message_type'] = 'order';//消息类型,product(商品)、member(会员,包含店铺)、order(订单)
  372. $post['content'] = $content;//发送内容
  373. $post['code'] = $shop['code'];
  374. $post['order'] = $list['orderinfo'];
  375. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
  376. $res = curl_exec($ch);
  377. curl_close($ch);
  378. $res = json_decode($res,true);
  379. if(isset($res['is_success']))
  380. {
  381. return 1;//成功
  382. }
  383. else
  384. {
  385. return isset($res['error_msg'])?$res['error_msg']:(isset($res['sub_msg'])?$res['sub_msg']:'发送失败');
  386. }
  387. }
  388. else
  389. {
  390. return 2;
  391. }
  392. }
  393. } //end class