SolitaireModel.class.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. /**
  3. * lionfish 商城系统
  4. *
  5. * ==========================================================================
  6. * @link http://www.liofis.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license http://www.liofis.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fish
  12. *
  13. */
  14. namespace Seller\Model;
  15. use Think\Model;
  16. class SolitaireModel {
  17. public function updatedo($data, $uniacid = 0,$addtype=0, $appstate =1)
  18. {
  19. $id = $data['data']['id'];
  20. $ins_data = array();
  21. $ins_data['uniacid'] = 0;
  22. $ins_data['head_id'] = $data['head_dan_id'];
  23. $ins_data['solitaire_name'] = $data['data']['solitaire_name'];
  24. $ins_data['images_list'] = serialize( $data['images_list'] );
  25. $ins_data['addtype'] = $addtype;
  26. $ins_data['appstate'] = $appstate;
  27. $ins_data['state'] = $data['data']['state'] ;
  28. $ins_data['begin_time'] = strtotime( $data['time']['start']);
  29. $ins_data['end_time'] = strtotime($data['time']['end']);
  30. $ins_data['content'] = htmlspecialchars( $data['data']['content'] );
  31. $ins_data['addtime'] = time();
  32. if( !empty($id) && $id > 0 )
  33. {
  34. unset($ins_data['addtime']);
  35. M('lionfish_comshop_solitaire')->where( array('id' => $id ))->save( $ins_data );
  36. //shagnp shuju
  37. $limit_goods_str = $data['goods_list'];
  38. $limit_goods_list = explode(',', $limit_goods_str );
  39. if( !empty($limit_goods_list) )
  40. {
  41. M('lionfish_comshop_solitaire_goods')->where( 'id not in (' . $limit_goods_str.') and soli_id = '.$id )->delete();
  42. foreach( $limit_goods_list as $goods_id )
  43. {
  44. //新增 goods_ids
  45. $cai_data = array();
  46. $cai_data['uniacid'] = $_W['uniacid'];
  47. $cai_data['soli_id'] = $id;
  48. $cai_data['goods_id'] = $goods_id;
  49. $cai_data['addtime'] = time();
  50. $insid = M('lionfish_comshop_solitaire_goods')->add( $cai_data );
  51. }
  52. }
  53. }else{
  54. foreach( $data['head_id_list'] as $head_dan_id )
  55. {
  56. $ins_data['head_id'] = $head_dan_id;
  57. $id = M('lionfish_comshop_solitaire')->add( $ins_data );
  58. //判断商品是否存在,先删除一次不存在的, limit_goods_list
  59. $limit_goods_str = $data['goods_list'];
  60. $limit_goods_list = explode(',', $limit_goods_str );
  61. if( !empty($limit_goods_list) )
  62. {
  63. foreach( $limit_goods_list as $goods_id )
  64. {
  65. //新增 goods_ids
  66. $cai_data = array();
  67. $cai_data['uniacid'] = 0;
  68. $cai_data['soli_id'] = $id;
  69. $cai_data['goods_id'] = $goods_id;
  70. $cai_data['addtime'] = time();
  71. $insid = M('lionfish_comshop_solitaire_goods')->add( $cai_data );
  72. }
  73. }
  74. }
  75. }
  76. }
  77. }
  78. ?>