| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- <?php
- /**
- *
- * @copyright ©2020 点小铺
- * @author hanj
- * @link: https://dyuit.com
- * Created by VSCode
- */
- namespace app\store\model;
- use app\common\model\CertificateApply as CertificateApplyModel;
- use app\common\service\watermark\WaterMarkBase;
- /**
- * 拼团商品分类模型
- * Class Category
- *
- * @package app\common\model
- */
- class CertificateApply extends CertificateApplyModel
- {
- /**
- * [getList]
- *
- * @Author: Yeshihao
- * @DateTime: 2024/11/27 11:12
- * @return \think\Paginator
- * @throws \think\exception\DbException
- */
- public function getList()
- {
- $query = self::useGlobalScope(true);
- $query = $this->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;
- }
- //获取文件类型
- $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);
- }
- }
|