SalesroomMemberModel.class.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * lionfish 商城系统
  4. *
  5. *
  6. * @author zcy 2020-09-19
  7. *
  8. */
  9. namespace Seller\Model;
  10. class SalesroomMemberModel{
  11. public function update($data)
  12. {
  13. $ins_data = array();
  14. $ins_data['supply_id'] = $data['supply_id'];
  15. $ins_data['username'] = $data['username'];
  16. $ins_data['mobile'] = $data['mobile'];
  17. $ins_data['member_id'] = $data['member_id'];
  18. $ins_data['state'] = $data['state'];
  19. $id = $data['id'];
  20. if($data['state'] == 0){
  21. $ins_data['disable_time'] = time();
  22. }
  23. if( !empty($id) && $id > 0 )
  24. {
  25. unset($ins_data['id']);
  26. M('lionfish_comshop_salesroom_member')->where( array('id' => $id) )->save( $ins_data );
  27. }else{
  28. $ins_data['addtime'] = time();
  29. $id = M('lionfish_comshop_salesroom_member')->add( $ins_data );
  30. }
  31. if(!empty($data['salesroom_ids'])){
  32. M('lionfish_comshop_salesroom_relative_member')->where( array('smember_id' => $id) )->delete();
  33. $salesroom_ids = explode(',',$data['salesroom_ids']);
  34. $salesroom_relative_member = array();
  35. $salesroom_relative_member['smember_id'] = $id;
  36. $salesroom_relative_member['member_id'] = $data['member_id'];
  37. $salesroom_relative_member['addtime'] = time();
  38. foreach($salesroom_ids as $v){
  39. $salesroom_relative_member['salesroom_id'] = $v;
  40. M('lionfish_comshop_salesroom_relative_member')->add( $salesroom_relative_member );
  41. }
  42. }
  43. }
  44. }
  45. ?>