1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
- namespace App\Services;
- use App\Models\GroupTherapyRecord;
- use App\Models\UserLectureRelation;
- use App\Models\WorkstationLectureRelation;
- use App\Models\Lecture; // 确保引入 Lecture 模型
- use App\Traits\PageTrait;
- class GroupTherapyService
- {
- use PageTrait;
- public function getList($condition, $sort = 'id', $sortable = 'desc')
- {
- $query = GroupTherapyRecord::query();
- $query->select(
- 'id',
- 'open_vc_id',
- 'type',
- 'customer_data',
- 'created_at',
- 'workstation_name',
- 'workstation_id',
- 'open_vt_id',
- 'vt_title'
- );
- // 使用 whereIn 方法筛选 lecture_id 在 $lectureIdArr 数组中的记录
- // 搜索
- if (isset($condition['keywords']) && $condition['keywords']) {
- $query->where('customer_data', 'like', '%' . $condition['keywords'] . '%');
- }
- // 排序
- $query->orderBy($sort, $sortable);
- // 执行查询并返回结果
- return self::JsonPage($query);
- }
- public function report($data)
- {
- if($data['customer_data']) {
- $customerData = json_decode($data['customer_data'], true);
- foreach($customerData as $v){
- $insertData[]=[
- 'open_vc_id' =>$v['open_vc_id'],
- 'type' =>$data['type'],
- 'customer_data' =>json_encode($v),
- 'created_at' =>date('Y-m-d H:i:s'),
- 'updated_at' =>date('Y-m-d H:i:s'),
- 'workstation_id'=>auth('grider')->user()->workstation_id,
- 'workstation_name'=>auth('grider')->user()->workstation_name,
- 'open_vt_id' => $v['vt_id'],
- 'vt_title' => $v['vt_title'],
- ];
- }
- $res = GroupTherapyRecord::insert($insertData);
- return $res;
- }
- return true;
- }
- }
|