Notice.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Notice extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model('Model_user','user');
  7. $this->load->_model('Model_notice','notice');
  8. $this->load->_model('Model_noticeemail','noticeemail');
  9. $this->load->_model('Model_shop','shop');
  10. $this->load->_model('Model_typeclass','typeclass');
  11. $this->load->_model('Model_fullorder','fullorder');
  12. $this->load->_model('Model_fullordertt','fullordertt');
  13. $this->load->_model('Model_fullordersmt','fullordersmt');
  14. $this->load->_model('Model_express','express');
  15. $this->load->_model('Model_emaildata','emaildata');
  16. $this->load->_model('Model_als','als');
  17. $this->load->_model('Model_apitt','apitt');
  18. $this->load->_model('Model_producttitle','producttitle');
  19. }
  20. //定义方法的调用规则 获取URI第二段值
  21. public function _remap($arg,$arg_array)
  22. {
  23. if($arg == 'add')//添加
  24. {
  25. $this->_add($arg_array);
  26. }
  27. else if($arg == 'edit')//修改
  28. {
  29. $this->_edit($arg_array);
  30. }
  31. else if($arg == 'del')//修改
  32. {
  33. $this->_del();
  34. }
  35. else if($arg == 'rows')//数据
  36. {
  37. $this->_rows();
  38. }
  39. else if($arg == 'email')
  40. {
  41. $this->_email();
  42. }
  43. else if($arg == 'addemail')
  44. {
  45. $this->_addemail();
  46. }
  47. else if($arg == 'emailfs')
  48. {
  49. $this->_emailfs();
  50. }
  51. else if($arg == 'testfs')
  52. {
  53. $this->_testfs();
  54. }
  55. else
  56. {
  57. $this->_index($arg_array);
  58. }
  59. }
  60. //管理
  61. public function _index($arg_array)
  62. {
  63. if(isset($_SESSION['api']))
  64. {
  65. $user = $this->user->get_api($_SESSION['api']);
  66. $fgshop = "";$sid = "";
  67. $user = explode('|',trim($user['shop'],'|'));
  68. foreach ($user as $value)
  69. {
  70. $fgshop .= " shop = ".$value." or";
  71. $sid .= " id = ".$value." or";
  72. }
  73. }
  74. $post = $this->input->post(NULL, TRUE);
  75. if(isset($post['page']))
  76. {
  77. $page = $this->input->post('page',true);
  78. $perpage = $this->input->post('perpage',true);
  79. $shop = $this->input->post('shop',true);
  80. $type = $this->input->post('type',true);
  81. $ordertatus = $this->input->post('ordertatus',true);
  82. $arg = $this->input->post('arg',true);
  83. $logisticstatus = $this->input->post('logisticstatus',true);
  84. $where = "1=1 and (".rtrim($fgshop,'or').")";
  85. if($shop)
  86. {
  87. $where .= " and shop = '$shop'";
  88. }
  89. if($type)
  90. {
  91. $where .= " and type = '$type'";
  92. }
  93. if($ordertatus)
  94. {
  95. $where .= " and ordertatus = '$ordertatus'";
  96. }
  97. if($logisticstatus)
  98. {
  99. $where .= " and logisticstatus = '$logisticstatus'";
  100. }
  101. //数据排序
  102. $order_str = "id asc";
  103. if(empty($page))
  104. {
  105. $start = 0;
  106. $perpage = 1;
  107. }
  108. else
  109. {
  110. $start = ($page - 1)*$perpage;
  111. }
  112. //取得信息列表
  113. $info_list = $this->notice->find_all($where,'id,shop,title,type,message,email,ordertatus,logisticstatus,ktime,jtime,state',$order_str,$start,$perpage);
  114. //格式化数据
  115. foreach ($info_list as $key=>$value)
  116. {
  117. $shop = $this->shop->read($value['shop']);
  118. $info_list[$key]['shop'] = $shop['shopname'];
  119. $email = $this->emaildata->read($value['email']);
  120. $info_list[$key]['email'] = $email['smtp_user'];
  121. $info_list[$key]['ktime'] = date('Y-m-d',$value['ktime']);
  122. $info_list[$key]['jtime'] = date('Y-m-d',$value['jtime']);
  123. if($value['type'] == 1)
  124. {
  125. $info_list[$key]['type'] = '自动发送';
  126. }
  127. else if($value['type'] == 2)
  128. {
  129. $info_list[$key]['type'] = '物流追踪';
  130. }
  131. else if($value['type'] == 3)
  132. {
  133. $info_list[$key]['type'] = '营销';
  134. }
  135. else if($value['type'] == 4)
  136. {
  137. $info_list[$key]['type'] = '运单号通知';
  138. }
  139. if($value['message'] == 1)
  140. {
  141. $info_list[$key]['message'] = '发送邮件';
  142. }
  143. //订单状态开始
  144. $typeclass = $this->typeclass->read($value['ordertatus']);
  145. $info_list[$key]['ordertatus'] = $typeclass?(($arg==1)?$typeclass['title']:$typeclass['spare']):'';
  146. //订单状态结束
  147. if($value['logisticstatus'] == 0)
  148. {
  149. $info_list[$key]['logisticstatus'] = "无信息";
  150. }
  151. else if($value['logisticstatus'] == 2)
  152. {
  153. $info_list[$key]['logisticstatus'] = "已取件";
  154. }
  155. else if($value['logisticstatus'] == 3)
  156. {
  157. $info_list[$key]['logisticstatus'] = "在途中";
  158. }
  159. /**
  160. else if($value['logisticstatus'] == 4)
  161. {
  162. $info_list[$key]['logisticstatus'] = "到达目的地国";
  163. }
  164. **/
  165. else if($value['logisticstatus'] == 4 || $value['logisticstatus'] == 5)
  166. {
  167. $info_list[$key]['logisticstatus'] = "即将派送";
  168. }
  169. else if($value['logisticstatus'] == 6)
  170. {
  171. $info_list[$key]['logisticstatus'] = "已签收";
  172. }
  173. else if($value['logisticstatus'] == 1)
  174. {
  175. $info_list[$key]['logisticstatus'] = "派送异常";
  176. }
  177. if($value['message'] == 1)
  178. {
  179. $info_list[$key]['message'] = '发送邮件';
  180. }
  181. else if($value['message'] == 2)
  182. {
  183. $info_list[$key]['message'] = 'AE站内信';
  184. }
  185. else if($value['message'] == 3)
  186. {
  187. $info_list[$key]['message'] = 'TT会话';
  188. }
  189. if($value['state'] == 1)
  190. {
  191. $info_list[$key]['state'] = '启用中';
  192. }
  193. else if($value['state'] == 2)
  194. {
  195. $info_list[$key]['state'] = '未启用';
  196. }
  197. }
  198. $total = $this->notice->find_count($where);
  199. $pagenum = ceil($total/$perpage);
  200. $over = $total-($start+$perpage);
  201. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  202. echo json_encode($rows);exit;
  203. }
  204. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  205. $this->data['wlshop'] = $wlshop;
  206. $mb = 2;
  207. if(isset($arg_array[0]))
  208. {
  209. if($arg_array[0]=='smt')
  210. {
  211. $mb = 1;
  212. }
  213. else if($arg_array[0]=='dlz')
  214. {
  215. $mb = 2;
  216. }
  217. else if($arg_array[0]=='tt')
  218. {
  219. $mb = 3;
  220. }
  221. }
  222. $this->data['arg'] = $mb;
  223. $this->_Template('notice',$this->data);
  224. }
  225. //添加
  226. public function _add($arg_array)
  227. {
  228. if(isset($_SESSION['api']))
  229. {
  230. $user = $this->user->get_api($_SESSION['api']);
  231. $fgshop = "";$sid = "";
  232. $user = explode('|',trim($user['shop'],'|'));
  233. foreach ($user as $value)
  234. {
  235. $fgshop .= " shop = ".$value." or";
  236. $sid .= " id = ".$value." or";
  237. }
  238. }
  239. $post = $this->input->post(NULL, TRUE);
  240. if(isset($post['title']))
  241. {
  242. $post['title'] = $this->input->post('title',true);
  243. $post['shop'] = $this->input->post('shop',true);
  244. $post['message'] = $this->input->post('message',true);
  245. $post['type'] = $this->input->post('type',true);
  246. $post['repeat'] = $this->input->post('repeat',true);
  247. $ktime = $this->input->post('ktime',true);
  248. $post['ktime'] = strtotime($ktime);
  249. $jtime = $this->input->post('jtime',true);
  250. $post['jtime'] = strtotime($jtime);
  251. $post['content'] = $this->input->post('content');
  252. $emailtitle = $this->input->post('emailtitle');
  253. $post['js'] = '';
  254. if($emailtitle)
  255. {
  256. $post['emailtitle'] = $emailtitle;
  257. }
  258. if($post['type'] == 1)
  259. {
  260. $post['ordertatus'] = $this->input->post('ordertatus',true);
  261. if($post['ordertatus'] == 2 || $post['ordertatus'] == 3)
  262. {
  263. $post['sending'] = $this->input->post('sending',true);
  264. $post['timeinterval'] = $this->input->post('timeinterval',true);
  265. }
  266. }
  267. else if($post['type'] == 2)
  268. {
  269. $post['logisticstatus'] = $this->input->post('logisticstatus',true);
  270. }
  271. else if($post['type'] == 3)
  272. {
  273. $marketing = $this->input->post('marketing',true);
  274. $post['marketing'] = strtotime($marketing);
  275. }
  276. else if($post['type'] == 4)
  277. {
  278. $post['js'] = $this->input->post('js',true);
  279. if($post['js'] != '')
  280. {
  281. $post['js'] = ','.$post['js'];
  282. }
  283. $post['express'] = $this->input->post('express',true);
  284. if($post['express'] != '')
  285. {
  286. $post['express'] = ','.$post['express'];
  287. }
  288. }
  289. $post['state'] = $this->input->post('state',true);
  290. if($post['state'] == 1)
  291. {
  292. $post['statetime'] = time();
  293. }
  294. if($this->notice->insert($post))
  295. {
  296. echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
  297. }
  298. else
  299. {
  300. echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
  301. }
  302. }
  303. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  304. $this->data['wlshop'] = $wlshop;
  305. $email = $this->emaildata->find_all('1=1 and '.rtrim($fgshop,'or'));
  306. $this->data['email'] = $email;
  307. $mb = 2;
  308. if(isset($arg_array[0]))
  309. {
  310. if($arg_array[0]=='smt')
  311. {
  312. $mb = 1;
  313. }
  314. else if($arg_array[0]=='dlz')
  315. {
  316. $mb = 2;
  317. }
  318. else if($arg_array[0]=='tt')
  319. {
  320. $mb = 3;
  321. }
  322. }
  323. $this->data['arg'] = $mb;
  324. $this->_Template('notice_add',$this->data);
  325. }
  326. //修改
  327. public function _edit($arg_array)
  328. {
  329. if(isset($_SESSION['api']))
  330. {
  331. $user = $this->user->get_api($_SESSION['api']);
  332. $fgshop = "";$sid = "";
  333. $user = explode('|',trim($user['shop'],'|'));
  334. foreach ($user as $value)
  335. {
  336. $fgshop .= " shop = ".$value." or";
  337. $sid .= " id = ".$value." or";
  338. }
  339. }
  340. $post = $this->input->post(NULL, TRUE);
  341. if(isset($post['id']))
  342. {
  343. $id = $this->input->post('id',true);
  344. $post['title'] = $this->input->post('title',true);
  345. $post['shop'] = $this->input->post('shop',true);
  346. $post['message'] = $this->input->post('message',true);
  347. $post['type'] = $this->input->post('type',true);
  348. $post['repeat'] = $this->input->post('repeat',true);
  349. $ktime = $this->input->post('ktime',true);
  350. $post['ktime'] = strtotime($ktime);
  351. $jtime = $this->input->post('jtime',true);
  352. $post['jtime'] = strtotime($jtime);
  353. $post['content'] = $this->input->post('content');
  354. $post['emailtitle'] = $this->input->post('emailtitle');
  355. $post['js'] = '';
  356. if($post['type'] == 1)
  357. {
  358. $post['ordertatus'] = $this->input->post('ordertatus',true);
  359. if($post['ordertatus'] == 2 || $post['ordertatus'] == 3)
  360. {
  361. $post['sending'] = $this->input->post('sending',true);
  362. $post['timeinterval'] = $this->input->post('timeinterval',true);
  363. }
  364. $post['logisticstatus'] = 0;
  365. }
  366. else if($post['type'] == 2)
  367. {
  368. $post['ordertatus'] = 0;//非订单状态写入:未获取
  369. $post['logisticstatus'] = $this->input->post('logisticstatus',true);
  370. }
  371. else if($post['type'] == 3)
  372. {
  373. $post['ordertatus'] = 0;//非订单状态写入:未获取
  374. $marketing = $this->input->post('marketing',true);
  375. $post['marketing'] = strtotime($marketing);
  376. }
  377. else if($post['type'] == 4)
  378. {
  379. $post['js'] = $this->input->post('js',true);
  380. if($post['js'] != '')
  381. {
  382. $post['js'] = ','.$post['js'];
  383. }
  384. $post['express'] = $this->input->post('express',true);
  385. if($post['express'] != '')
  386. {
  387. $post['express'] = ','.$post['express'];
  388. }
  389. }
  390. $post['state'] = $this->input->post('state',true);
  391. if($post['state'] == 1)
  392. {
  393. $post['statetime'] = time();
  394. }
  395. if($this->notice->save($post,$id))
  396. {
  397. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  398. }
  399. else
  400. {
  401. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  402. }
  403. }
  404. $notice = $this->notice->read($arg_array[0]);
  405. $this->data['notice'] = $notice;
  406. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  407. $this->data['wlshop'] = $wlshop;
  408. $email = $this->emaildata->find_all('1=1 and '.rtrim($fgshop,'or'));
  409. $this->data['email'] = $email;
  410. $mb = 2;
  411. if(isset($arg_array[0]))
  412. {
  413. if($arg_array[0]=='smt')
  414. {
  415. $mb = 1;
  416. }
  417. else if($arg_array[0]=='dlz')
  418. {
  419. $mb = 2;
  420. }
  421. else if($arg_array[0]=='tt')
  422. {
  423. $mb = 3;
  424. }
  425. }
  426. $this->data['arg'] = $mb;
  427. $this->_Template('notice_edit',$this->data);
  428. }
  429. //删除
  430. public function _del()
  431. {
  432. $post = $this->input->post(NULL, TRUE);
  433. if(isset($post['s']))
  434. {
  435. $id_arr = $this->input->post('s');
  436. $id_arr = explode(',',$id_arr);
  437. if(!$id_arr)
  438. {
  439. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  440. }
  441. //循环删除记录
  442. foreach ($id_arr as $v)
  443. {
  444. $this->notice->remove($v);
  445. }
  446. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  447. }
  448. }
  449. public function _email()
  450. {
  451. if(isset($_SESSION['api']))
  452. {
  453. $user = $this->user->get_api($_SESSION['api']);
  454. $fgshop = "";$sid = "";
  455. $user = explode('|',trim($user['shop'],'|'));
  456. foreach ($user as $value)
  457. {
  458. $fgshop .= " shop = ".$value." or";
  459. $sid .= " id = ".$value." or";
  460. }
  461. }
  462. $post = $this->input->post(NULL, TRUE);
  463. if(isset($post['page']))
  464. {
  465. $page = $this->input->post('page',true);
  466. $perpage = $this->input->post('perpage',true);
  467. $shop = $this->input->post('shop',true);
  468. $email = $this->input->post('email',true);
  469. $notice = $this->input->post('notice',true);
  470. $xztime = $this->input->post('xztime',true);
  471. $timetk = $this->input->post('timetk',true);
  472. $timetj = $this->input->post('timetj',true);
  473. $timetk = strtotime($timetk);
  474. $timetj = strtotime($timetj);
  475. $where = "1=1 and (".rtrim($fgshop,'or').")";
  476. if($shop)
  477. {
  478. $where .= " and shop = '$shop'";
  479. }
  480. if($email)
  481. {
  482. $where .= " and email like '%$email%'";
  483. }
  484. if($notice)
  485. {
  486. $where .= " and notice = '$notice'";
  487. }
  488. if($timetk && $timetj)
  489. {
  490. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  491. }
  492. //数据排序
  493. $order_str = "id desc";
  494. if(empty($page))
  495. {
  496. $start = 0;
  497. $perpage = 1;
  498. }
  499. else
  500. {
  501. $start = ($page - 1)*$perpage;
  502. }
  503. //取得信息列表
  504. $info_list = $this->noticeemail->find_all($where,'id,shop,email,notice,addtime,time',$order_str,$start,$perpage);
  505. //格式化数据
  506. foreach ($info_list as $key=>$value)
  507. {
  508. $data = $this->noticeemail->read($value['id']);
  509. $shop = $this->shop->read($value['shop']);
  510. $info_list[$key]['shop'] = $shop['shopname'];
  511. $info_list[$key]['addtime'] = date('Y-m-d H:i:s',$value['addtime']);
  512. if(is_numeric($value['time']) && $value['time'] > 0)
  513. {
  514. $info_list[$key]['time'] = date('Y-m-d H:i:s',$value['time']);
  515. }
  516. else
  517. {
  518. $info_list[$key]['time'] = '';
  519. if($data['error'] != '')
  520. {
  521. $info_list[$key]['time'] = $data['error'];
  522. }
  523. }
  524. $notice = $this->notice->read($value['notice']);
  525. $info_list[$key]['notice'] = $notice['title'];
  526. }
  527. $total = $this->noticeemail->find_count($where);
  528. $pagenum = ceil($total/$perpage);
  529. $over = $total-($start+$perpage);
  530. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  531. echo json_encode($rows);exit;
  532. }
  533. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  534. $this->data['wlshop'] = $wlshop;
  535. $notice = $this->notice->find_all("message = 1 and type = '3' and (".rtrim($fgshop,'or').")");
  536. $this->data['notice'] = $notice;
  537. $this->_Template('notice_email',$this->data);
  538. }
  539. public function _addemail()
  540. {
  541. if(isset($_SESSION['api']))
  542. {
  543. $user = $this->user->get_api($_SESSION['api']);
  544. $fgshop = "";$sid = "";
  545. $user = explode('|',trim($user['shop'],'|'));
  546. foreach ($user as $value)
  547. {
  548. $fgshop .= " shop = ".$value." or";
  549. $sid .= " id = ".$value." or";
  550. }
  551. }
  552. $post = $this->input->post(NULL, TRUE);
  553. if(isset($post['email']))
  554. {
  555. $time = time();$cw = '';$i = 0;$fs = '';
  556. $notice = $this->input->post('notice',true);
  557. $n = $this->notice->read($notice);
  558. $email = $this->input->post('email',true);
  559. $email = str_replace(PHP_EOL, ',', $email);
  560. $email = explode(',',trim($email,','));
  561. $this->db->trans_begin();
  562. foreach ($email as $v)
  563. {
  564. $f = $this->fullorder->find_all("email = '$v' and shop = '".$n['shop']."'",'*','id desc');
  565. if(isset($f[0]['email']))
  566. {
  567. $tid = $this->noticeemail->insert(array('shop'=>$f[0]['shop'],'email'=>$v,'notice'=>$notice,'addtime'=>$time));
  568. $fs .= $f[0]['id'].'-'.$tid.',';
  569. }
  570. else
  571. {
  572. $i++;
  573. $cw .= $v.',';
  574. }
  575. }
  576. if(count($email) == $i)
  577. {
  578. echo json_encode(array('msg'=>'Email地址全部错误,请排查!','success'=>false));exit;
  579. }
  580. if($this->db->trans_status() === TRUE)
  581. {
  582. $this->db->trans_commit();
  583. $ch = curl_init();
  584. $url = 'http://a'.rand(10,50).'.wepolicy.cn/notice/emailfs';
  585. curl_setopt($ch,CURLOPT_URL,$url);
  586. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  587. curl_setopt($ch,CURLOPT_HEADER,0);
  588. curl_setopt($ch,CURLOPT_POST, 1);
  589. curl_setopt($ch,CURLOPT_TIMEOUT,1);
  590. //设置post数据
  591. $post = array();
  592. $post['notice'] = $notice;
  593. $post['fs'] = trim($fs,',');
  594. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
  595. $res = curl_exec($ch);
  596. curl_close($ch);
  597. if($i > 0)
  598. {
  599. echo json_encode(array('msg'=>'有错误Email地址,请排查!其它正常发送中。<br>错误Email:<br>'.trim($cw,',').'<br>','success'=>true));exit;
  600. }
  601. else
  602. {
  603. echo json_encode(array('n'=>0,'msg'=>'添加成功,邮件逐条发送中','success'=>true));exit;
  604. }
  605. }
  606. else
  607. {
  608. $this->db->trans_rollback();
  609. echo json_encode(array('msg'=>'系统错误,请重试!!','success'=>false));exit;
  610. }
  611. }
  612. $notice = $this->notice->find_all("message = 1 and type = '3' and (".rtrim($fgshop,'or').")");
  613. $this->data['notice'] = $notice;
  614. $this->_Template('notice_addemail',$this->data);
  615. }
  616. public function _emailfs()
  617. {
  618. $time = time();
  619. $post = $this->input->post(NULL, TRUE);
  620. if(isset($post['notice']))
  621. {
  622. $notice = $this->input->post('notice');
  623. $notice = $this->notice->read($notice);
  624. $notice['email'] = $this->emaildata->read($notice['email']);
  625. $fs = $this->input->post('fs');
  626. $fs = explode(',',$fs);
  627. foreach ($fs as $v)
  628. {
  629. $v = explode('-',$v);
  630. $data = $this->fullorder->read($v[0]);
  631. $shop = $this->shop->read($data['shop']);
  632. $express = $this->express->read($data['express']);
  633. $this->als->save(array('cs'=>json_encode(array($data,$shop,$express,$notice))),1);
  634. $go = $this->notice->get_god($data,$shop,$express,$notice);
  635. if($go == 1)
  636. {
  637. $this->noticeemail->save(array('time'=>time()),$v[1]);
  638. }
  639. else
  640. {
  641. $this->noticeemail->save(array('error'=>$go),$v[1]);
  642. }
  643. sleep(50);
  644. }
  645. }
  646. }
  647. public function _testfs()
  648. {
  649. $time = time();
  650. $post = $this->input->post(NULL, TRUE);
  651. if(isset($post['id']))
  652. {
  653. $id = $this->input->post('id');
  654. $email = $this->input->post('email');
  655. $number = $this->input->post('number');
  656. $data = $this->fullorder->get_number($number);
  657. if(!$data)
  658. {
  659. $data = $this->fullordersmt->get_number($number);
  660. if(!$data)
  661. {
  662. $data = $this->fullordertt->get_number($number);
  663. if(!$data)
  664. {
  665. echo json_encode(array('msg'=>'编号无效!','success'=>false));exit;
  666. }
  667. }
  668. }
  669. else
  670. {
  671. if(!$email)
  672. {
  673. echo json_encode(array('msg'=>'请输入邮箱!','success'=>false));exit;
  674. }
  675. }
  676. $data['email'] = $email;
  677. $shop = $this->shop->read($data['shop']);
  678. $express = $this->express->read($data['express']);
  679. $id_arr = explode(',',trim($id,','));$i = 0;
  680. foreach ($id_arr as $v)
  681. {
  682. $notice = $this->notice->read($v);
  683. if($notice)
  684. {
  685. $notice['email'] = $this->emaildata->read($notice['email']);
  686. $go = $this->notice->get_god($data,$shop,$express,$notice);
  687. if($go == 1)
  688. {
  689. $i++;
  690. }
  691. }
  692. }
  693. if($i == count($id_arr))
  694. {
  695. echo json_encode(array('msg'=>'发送成功','success'=>false));exit;
  696. }
  697. else
  698. {
  699. echo json_encode(array('msg'=>'有部分发送失败'.$go,'success'=>false));exit;
  700. }
  701. }
  702. }
  703. }