PopadvModel.class.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. /**
  3. * 小梦科技资源nanodreamtech.com
  4. *
  5. * ==========================================================================
  6. * @link https://www.nanodreamtech.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license https://www.nanodreamtech.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fld
  12. *
  13. */
  14. namespace Seller\Model;
  15. class PopadvModel{
  16. public function update($_GPC)
  17. {
  18. $data = $_GPC['data'];
  19. $time = $_GPC['time'];
  20. $ins_data = array();
  21. $ins_data['adv_name'] = $data['adv_name'];
  22. $ins_data['begin_time'] = strtotime($time['start']);
  23. $ins_data['end_time'] = strtotime($time['end']);
  24. $ins_data['send_person'] = $data['send_person'];
  25. $ins_data['member_id'] = $_GPC['member_id'];
  26. $ins_data['member_group_id'] = $data['member_group_id'];
  27. $ins_data['pop_page'] = $data['pop_page'];
  28. $ins_data['is_index_show'] = $data['is_index_show'];
  29. $ins_data['show_hour'] = $data['show_hour'];
  30. $ins_data['sort_order'] = $data['sort_order'];
  31. $ins_data['status'] = $data['status'];
  32. $id = $data['id'];
  33. if( !empty($id) && $id > 0 )
  34. {
  35. $add_time = time();
  36. M('lionfish_comshop_pop_adv')->where( array('id' => $id) )->save( $ins_data );
  37. $aid = $_GPC['aid'];
  38. $thumb = $_GPC['thumb'];
  39. $adv_id = $_GPC['adv_id'];
  40. M('lionfish_comshop_pop_adv_list')->where( array('ad_id' => $id) )->delete();
  41. for($i = 0;$i < count($aid);$i++){
  42. $adv_data = array();
  43. $adv_data['ad_id'] = $id;
  44. $adv_data['thumb'] = $thumb[$i];
  45. $adv_data['link'] = $data['link_'.$aid[$i]];
  46. $adv_data['linktype'] = $data['linktype_'.$aid[$i]];
  47. $adv_data['appid'] = $data['appid_'.$aid[$i]];
  48. $adv_data['addtime'] = $add_time;
  49. M('lionfish_comshop_pop_adv_list')->add($adv_data);
  50. }
  51. }else{
  52. $add_time = time();
  53. $ins_data['addtime'] = $add_time;
  54. $adv_id = M('lionfish_comshop_pop_adv')->add($ins_data);
  55. $aid = $_GPC['aid'];
  56. $thumb = $_GPC['thumb'];
  57. for($i = 0;$i < count($aid);$i++){
  58. $adv_data = array();
  59. $adv_data['ad_id'] = $adv_id;
  60. $adv_data['thumb'] = $thumb[$i];
  61. $adv_data['link'] = $data['link_'.$aid[$i]];
  62. $adv_data['linktype'] = $data['linktype_'.$aid[$i]];
  63. $adv_data['appid'] = $data['appid_'.$aid[$i]];
  64. $adv_data['addtime'] = $add_time;
  65. M('lionfish_comshop_pop_adv_list')->add($adv_data);
  66. }
  67. }
  68. }
  69. }
  70. ?>