SalesroomMemberModel.class.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 zcy 2020-09-19
  12. *
  13. */
  14. namespace Seller\Model;
  15. class SalesroomMemberModel{
  16. public function update($data)
  17. {
  18. $ins_data = array();
  19. $ins_data['supply_id'] = $data['supply_id'];
  20. $ins_data['username'] = $data['username'];
  21. $ins_data['mobile'] = $data['mobile'];
  22. $ins_data['member_id'] = $data['member_id'];
  23. $ins_data['state'] = $data['state'];
  24. $id = $data['id'];
  25. if($data['state'] == 0){
  26. $ins_data['disable_time'] = time();
  27. }
  28. if( !empty($id) && $id > 0 )
  29. {
  30. unset($ins_data['id']);
  31. M('lionfish_comshop_salesroom_member')->where( array('id' => $id) )->save( $ins_data );
  32. }else{
  33. $ins_data['addtime'] = time();
  34. $id = M('lionfish_comshop_salesroom_member')->add( $ins_data );
  35. }
  36. if(!empty($data['salesroom_ids'])){
  37. M('lionfish_comshop_salesroom_relative_member')->where( array('smember_id' => $id) )->delete();
  38. $salesroom_ids = explode(',',$data['salesroom_ids']);
  39. $salesroom_relative_member = array();
  40. $salesroom_relative_member['smember_id'] = $id;
  41. $salesroom_relative_member['member_id'] = $data['member_id'];
  42. $salesroom_relative_member['addtime'] = time();
  43. foreach($salesroom_ids as $v){
  44. $salesroom_relative_member['salesroom_id'] = $v;
  45. M('lionfish_comshop_salesroom_relative_member')->add( $salesroom_relative_member );
  46. }
  47. }
  48. }
  49. }
  50. ?>