where([ 'store_id' => $this->store_id, 'user_id' => $this->user_id, 'is_delete' => 0, ])->andWhere(['<>', 'type', '1']) ->with(['gift' => function ($query) { $query->where([ 'store_id' => $this->store_id, 'is_delete' => 0 ]); }]); $count = $form->count(); $pagination = new Pagination(['totalCount' => $count, 'page' => $this->page - 1, 'pageSize' => $this->limit]); $list = $form->limit($pagination->limit)->offset($pagination->offset)->orderBy('create_time DESC,id DESC')->asArray()->all(); foreach ($list as &$v) { $v['type'] = (int)$v['type']; $v['create_time'] = date('Y:m:d H:i:s', $v['create_time']); switch ($v['type']) { case 2: $v['name'] = $v['gift']['name']; break; case 1: $v['name'] = '谢谢参与'; break; default: } } unset($v); $kf_wechat_img = Option::get(OptionSetting::WEB_KF_WECHAT_IMG, $this->store_id, 'display')['value']; if ($list) { return [ 'code' => 0, 'data' => [ 'kf_wechat_img' => $kf_wechat_img, 'list' => $list, ] ]; } else { return [ 'code' => 0, 'data' => [ 'list' => [] ], ]; } } public function del() { $log = PondLog::findOne([ 'id' => $this->id, 'store_id' => $this->store_id, 'user_id' => $this->user_id, 'is_delete' => 0, ]); if (!$log) { return [ 'code' => 1, 'msg' => '网络异常' ]; } $log->is_delete = 1; if ($log->save()) { return [ 'code' => 0, 'msg' => '删除成功' ]; } return [ 'code' => 1, 'msg' => '网络异常' ]; } }