MeetingSpeechScheduleModel.php 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. namespace App\Web\Models;
  3. use App\Models\BaseModel;
  4. use Illuminate\Support\Facades\DB;
  5. use Illuminate\Support\Facades\Log;
  6. class MeetingSpeechScheduleModel extends BaseModel
  7. {
  8. /**
  9. * 状态字段
  10. */
  11. const DELETED_AT = 'status';
  12. /**
  13. * @var string
  14. */
  15. protected $table = 'meeting_speech_schedule';
  16. /**
  17. * 保存日程
  18. * */
  19. public function saveSpeechScheduleData($meetingId,$speechScheduleData=array(),$userId=0){
  20. $time=nowTime();
  21. $ids=[];
  22. if(!empty($speechScheduleData)){
  23. foreach ($speechScheduleData as $item){
  24. $saveData=[
  25. 'theme'=>!empty($item['theme'])?$item['theme']:'',
  26. 'address'=>!empty($item['address'])?$item['address']:'',
  27. 'title'=>!empty($item['title'])?$item['title']:'',
  28. 'description'=>!empty($item['description'])?$item['description']:'',
  29. 'cover_url'=>!empty($item['cover_url'])?$item['cover_url']:'',
  30. 'cover_alt'=>!empty($item['cover_alt'])?$item['cover_alt']:'',
  31. 'expert_name'=>!empty($item['expert_name'])?$item['expert_name']:'',
  32. 'expert_des'=>!empty($item['expert_des'])?$item['expert_des']:'',
  33. 'expert_expert'=>!empty($item['expert_expert'])?$item['expert_expert']:'',
  34. 'start_date'=>!empty($item['start_date'])?$item['start_date']:'',
  35. 'end_date'=>!empty($item['end_date'])?$item['end_date']:'',
  36. 'update_time'=>$time,
  37. ];
  38. if (!empty($item['expand_content'])) {
  39. $saveData['expand_content'] = empty($item['expand_content'])?'':json_encode($item['expand_content']);
  40. }
  41. if(!empty($item['id'])){
  42. $saveData['id']=$item['id'];
  43. $ids[]=$saveData['id'];
  44. $this->newInstance()->where('id', $saveData['id'])->update($saveData);
  45. }else{
  46. $saveData['user_id']=$userId;
  47. $saveData['meeting_id']=$meetingId;
  48. $saveData['create_time']=$time;
  49. $saveData['update_time']=$time;
  50. // Log::info($saveData);
  51. $id = $this->newInstance()->insertGetId($saveData);
  52. $ids[]=$id;
  53. }
  54. }
  55. //删除移除的权限
  56. $this->where('meeting_id',$meetingId)->where('status',0)
  57. ->WhereNotIn('id',$ids)
  58. ->update(['status'=>2,'update_time'=>$time]);
  59. }else{
  60. $this->where('meeting_id',$meetingId)->where('status',0)
  61. ->update(['status'=>2,'update_time'=>$time]);
  62. }
  63. return $meetingId;
  64. }
  65. /**
  66. * 获取产品类型ids
  67. * */
  68. public function getSpeechScheduleByMeetingId($meetingId){
  69. $typeIds= $this->newInstance()
  70. ->where('meeting_id','=',$meetingId)
  71. ->where('status','<',2)
  72. ->get()->toArray();
  73. return $typeIds;
  74. }
  75. }