handlerSearch($query, request()->param()); //查询条件 return $query->with(['applyUser']) ->where('is_delete', '=', 0) ->order(['create_time' => 'desc']) ->paginate(15, false, [ 'query' => request()->request() ]); } /** * [add] * 新增申请 * * @Author: Yeshihao * @DateTime: 2024/11/27 18:05 * @param $data * @return false|int * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function add($data) { //判断是否有资质文件 if (!isset($data['certificate_ids']) || empty($data['certificate_ids'])) { $this->error = '请选择资质文件'; return false; } //获取资质文件信息 $certificateList = Certificate::getCertificateList(['id' => ['in', $data['certificate_ids']]]); if ($certificateList->isEmpty()) { $this->error = '查无相关资质文件'; return false; } // $result_data = []; // foreach ($certificateList as $certificate) { // $service = new WaterMarkBase($certificate['file']['file_path'], $data['watermark'], self::$wxapp_id, $certificate['file_type']); // $result = $service->waterMark(); // } //获取文件类型 $data['wxapp_id'] = self::$wxapp_id; $data['store_user_id'] = getStoreUserId(); return $this->allowField(true)->save($data); } /** * [edit] * * @Author: Yeshihao * @DateTime: 2024/11/28 10:56 * @param $data * @return false|int * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function edit($data) { //申请拒绝 if ($data['status'] == 30) { if (!isset($data['refuse_reason']) || empty($data['refuse_reason'])) { $this->error = '请填写拒绝原因'; return false; } } if ($data['status'] == 20) { $result_data = []; //获取资质文件信息 $certificateList = Certificate::getCertificateList(['id' => ['in', $this['certificate_ids']]]); if ($certificateList->isEmpty()) { $this->error = '查无相关资质文件'; return false; } foreach ($certificateList as $certificate) { $service = new WaterMarkBase($certificate['file']['file_path'], $this['watermark'], self::$wxapp_id, $data['alpha'], $certificate['file_type'], '有效期至'.$this['indate'], $certificate['width'], $certificate['height']); $result = $service->waterMark(); $result_data[] = [ 'name' => $certificate['name'], 'file_path' => $result['file_path'], 'file_path_name' => $result['file_name'], ]; } $data['result_data'] = $result_data; } //发送失败通知给客服 $robot = new BaseRobot($this->wxapp_id); if ($data['status'] == 20) { $robot->sendMessage("资质申请:【{$this->project}】,审核成功。", RobotSence::WATERMARK_APPLY, [$this->storeUser->phone]); } if ($data['status'] == 30) { $robot->sendMessage("资质申请:【{$this->project}】,审核失败,失败原因:{$data['refuse_reason']}。", RobotSence::WATERMARK_APPLY, [$this->storeUser->phone]); } //获取文件类型 $data['apply_user_id'] = getStoreUserId(); return $this->allowField(true)->save($data); } /** * [changeAlpha] * 修改水印透明度 * * @Author: Yeshihao * @DateTime: 2024/12/2 16:38 * @param $alpha * @return false|int * @throws \Mpdf\MpdfException * @throws \setasign\Fpdi\PdfParser\CrossReference\CrossReferenceException * @throws \setasign\Fpdi\PdfParser\PdfParserException * @throws \setasign\Fpdi\PdfParser\Type\PdfTypeException * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function changeAlpha($alpha) { if ($this->status != 20) { $this->error = '该申请无法修改水印透明度'; return false; } $result_data = []; //获取资质文件信息 $certificateList = Certificate::getCertificateList(['id' => ['in', $this['certificate_ids']]]); if ($certificateList->isEmpty()) { $this->error = '查无相关资质文件'; return false; } foreach ($certificateList as $certificate) { $service = new WaterMarkBase($certificate['file']['file_path'], $this['watermark'], self::$wxapp_id, $alpha, $certificate['file_type'], '有效期至'.$this['indate'], $certificate['width'], $certificate['height']); $result = $service->waterMark(); $result_data[] = [ 'name' => $certificate['name'], 'file_path' => $result['file_path'], 'file_path_name' => $result['file_name'], ]; } $data['result_data'] = $result_data; $data['alpha'] = $alpha; return $this->allowField(true)->save($data); } }