Sfoglia il codice sorgente

Merge commit 'cf2faeb841ad2f0e849a56753b01661ff6acf86e' into prod-v1

Mark 1 anno fa
parent
commit
34c2f0f016

+ 14 - 9
dyu/application/common/service/watermark/WaterMarkBase.php

@@ -28,6 +28,8 @@ class WaterMarkBase
 
 	public $water;
 
+	public $water2;
+
 	public $wxapp_id;
 
 	public $type;
@@ -41,21 +43,25 @@ class WaterMarkBase
 	 * @param $water //水印内容
 	 * @param $wxapp_id //wxappid
 	 */
-	public function __construct($url, $water, $wxapp_id, $type = 'image')
+	public function __construct($url, $water, $wxapp_id, $type = 'image', $water2 = '')
 	{
 		$this->url      = $url;
 		$this->water    = $water;
+		$this->water2   = $water2;
 		$this->wxapp_id = $wxapp_id;
 		$this->type     = $type;
 	}
 
 	/**
 	 * [waterMark]
-	 * 添加水印
 	 *
 	 * @Author: Yeshihao
-	 * @DateTime: 2024/11/27 14:03
-	 * @return string
+	 * @DateTime: 2024/11/28 17:19
+	 * @return array
+	 * @throws \Mpdf\MpdfException
+	 * @throws \setasign\Fpdi\PdfParser\CrossReference\CrossReferenceException
+	 * @throws \setasign\Fpdi\PdfParser\PdfParserException
+	 * @throws \setasign\Fpdi\PdfParser\Type\PdfTypeException
 	 */
 	public function waterMark()
 	{
@@ -65,15 +71,15 @@ class WaterMarkBase
 		switch ($this->type) {
 			case 'image':
 				$image = new Image();
-				$image->waterMark($filePath, $this->water, 1);
+				$image->waterMark($filePath, $this->water, 1, $this->water2);
 				break;
 			case 'pdf':
 				$pdf = new Pdf();
-				$pdf->waterMark($filePath, $this->water);
+				$pdf->waterMark($filePath, $this->water, 1, $this->water2);
 				break;
 		}
 
-		return $filePath;
+		return ['file_path' => $filePath, 'file_name' => $this->tempDownloadFileName];
 	}
 
 
@@ -88,8 +94,7 @@ class WaterMarkBase
 	 * @param string $mark
 	 * @return string
 	 */
-	private
-	function saveTempImage($wxapp_id, $url, $mark = 'temp')
+	private function saveTempImage($wxapp_id, $url, $mark = 'temp')
 	{
 		$savePath = $this->getTempSavePath($wxapp_id, $url, $mark);
 		if (file_exists($savePath)) {

+ 9 - 5
dyu/application/common/service/watermark/image/Image.php

@@ -20,7 +20,7 @@ class Image
 	 * @return bool
 	 * @throws
 	 */
-	public function waterMark($filePath, $waterText, $type = 0)
+	public function waterMark($filePath, $waterText, $type = 0, $waterText2 = '')
 	{
 		// 1 打开海报背景图
 		$editor = Grafika::createEditor(['Gd']);
@@ -41,13 +41,13 @@ class Image
 			// 获取文字大小宽高
 			$fontSizeArr = $this->get_text_box($waterText, $fontSize, $fontPath);
 			$fontX       = intval(($size[0] * (($hypo - $fontSizeArr[0]) / 2)) / $hypo);
-			$fontY       = intval(($size[1] * (($hypo - $fontSizeArr[0]) / 2)) / $hypo);
+			$fontY       = $size[1] - intval(($size[1] * (($hypo - $fontSizeArr[0]) / 2)) / $hypo);
 			//计算倾斜角度
 			$angle = intval(atan($size[1] / $size[0]) * 180 / pi());
 			$image = imagecreatetruecolor($size[0], $size[1]);
 		} else {
 			// 判断文字图片开始的位置
-			$fontSize = $size[0] / $fontNum * 0.7;
+			$fontSize = $size[0] / $fontNum;
 			// 获取文字大小宽高
 			$fontSizeArr = $this->get_text_box($waterText, $fontSize, $fontPath);
 			$fontX       = 0;
@@ -63,8 +63,12 @@ class Image
 		$fontImage = new \Grafika\Gd\Image($image, '', imagesx($image), imagesy($image), ImageType::PNG);
 
 		//设置文字颜色
-		$Color = new Color('#C0C0C0');
-		$editor->text($fontImage, $waterText, $fontSize, $fontX, $fontY, $Color, $fontPath, -$angle);
+		$Color = new Color('#CCCCCC');
+		$editor->text($fontImage, $waterText, $fontSize, $fontX, $fontY, $Color, $fontPath, $angle);
+		if($waterText2){
+			$editor->text($fontImage, $waterText2, $fontSize, $fontX + $fontSize, $fontY + $fontSize, $Color, $fontPath, $angle);
+		}
+
 		//合并图片
 		$editor->blend($backdropImage, $fontImage, 'overlay', 1, 'center');
 		// 保存图片

+ 6 - 5
dyu/application/common/service/watermark/pdf/Pdf.php

@@ -45,6 +45,7 @@ class Pdf
 	/**
 	 * [waterMark]
 	 * 打印水印
+	 *
 	 * @Author: Yeshihao
 	 * @DateTime: 2024/11/28 13:39
 	 * @param     $filePath
@@ -56,26 +57,26 @@ class Pdf
 	 * @throws \setasign\Fpdi\PdfParser\PdfParserException
 	 * @throws \setasign\Fpdi\PdfParser\Type\PdfTypeException
 	 */
-	public function waterMark($filePath, $waterText, $type = 0)
+	public function waterMark($filePath, $waterText, $type = 0, $waterText2 = '')
 	{
 		$defaultConfig          = (new ConfigVariables())->getDefaults();
 		$fontDirs               = $defaultConfig['fontDir'];
 		$defaultFontConfig      = (new FontVariables())->getDefaults();
 		$fontData               = $defaultFontConfig['fontdata'];
 		$mpdf                   = new Mpdf(['mode'         => '+aCJK',
-		                                    'fontDir'      => array_merge($fontDirs,[__DIR__.'/fonts']),
+		                                    'fontDir'      => array_merge($fontDirs, [__DIR__.'/fonts']),
 		                                    'fontdata'     => $fontData + ['msyh' => ['R' => 'msyh.ttf',],],
 		                                    'default_font' => 'msyh'
 		]);
 		$mpdf->autoScriptToLang = true;
 		$mpdf->autoLangToFont   = true;
 
-		$text = $waterText;
+		$text = $waterText.$waterText2;
 		//文字水印
-		$watermarkText = new \Mpdf\WatermarkText($text, 30, 30, '#cccccc', 0.4);
+		$watermarkText = new \Mpdf\WatermarkText($text, 30, 30, '#cccccc', 0.2);
 		$mpdf->SetWatermarkText($watermarkText, 0.3);
 		$mpdf->showWatermarkText = true;
-		$mpdf->watermarkAngle    = '-45';
+		$mpdf->watermarkAngle    = '45';
 		$pageCount               = $mpdf->SetSourceFile($filePath); //读取原始文件页数
 		for ($i = 1; $i <= $pageCount; $i++) {
 			$import_page = $mpdf->ImportPage($i);

+ 34 - 2
dyu/application/store/controller/content/certificate/Watermark.php

@@ -68,7 +68,7 @@ class Watermark extends Controller
 		$model = CertificateApplyModel::detail($id);
 		if (!$this->request->isAjax()) {
 			$category        = CertificateCategoryModel::getAll();
-			$certificateList = CertificateModel::getCertificateList(['certificate_category_id' => ['in', $model['category_ids']]], ['id', 'name']);
+			$certificateList = CertificateModel::getCertificateList(['id' => ['in', $model['certificate_ids']]]);
 			return $this->fetch('edit', compact('model', 'category', 'certificateList'));
 		}
 		// 更新记录
@@ -78,6 +78,33 @@ class Watermark extends Controller
 		return $this->renderError($model->getError() ?: '审核失败');
 	}
 
+	/**
+	 * [detail]
+	 *
+	 * @Author: Yeshihao
+	 * @DateTime: 2024/11/28 16:52
+	 * @param $id
+	 * @return array|bool|mixed
+	 * @throws \think\db\exception\DataNotFoundException
+	 * @throws \think\db\exception\ModelNotFoundException
+	 * @throws \think\exception\DbException
+	 */
+	public function detail($id)
+	{
+		// 分类详情
+		$model = CertificateApplyModel::detail($id);
+		if (!$this->request->isAjax()) {
+			$category        = CertificateCategoryModel::getAll();
+			$certificateList = CertificateModel::getCertificateList(['id' => ['in', $model['certificate_ids']]]);
+			return $this->fetch('detail', compact('model', 'category', 'certificateList'));
+		}
+		// 更新记录
+		if ($model->edit($this->postData())) {
+			return $this->renderSuccess('审核成功', url('content.certificate.watermark/index'));
+		}
+		return $this->renderError($model->getError() ?: '审核失败');
+	}
+
 	/**
 	 * [delete]
 	 *
@@ -89,6 +116,9 @@ class Watermark extends Controller
 	public function delete($id)
 	{
 		$model = CertificateApplyModel::detail($id);
+		if ($model['status'] != 10) {
+			return $this->renderError('取消失败');
+		}
 		if (!$model->setDelete()) {
 			return $this->renderError($model->getError() ?: '取消失败');
 		}
@@ -119,6 +149,7 @@ class Watermark extends Controller
 	/**
 	 * [zipDownload]
 	 * 下载zip
+	 *
 	 * @Author: Yeshihao
 	 * @DateTime: 2024/11/28 11:15
 	 * @param $id
@@ -143,9 +174,10 @@ class Watermark extends Controller
 		//新建zip压缩包
 		$zip->open($zipFilePath, \ZIPARCHIVE::OVERWRITE | \ZIPARCHIVE::CREATE);
 
+
 		//循环压缩文件
 		foreach ($model['result_data'] as $value) {
-			$substr = mb_substr($value['file_path'], mb_strpos($value['file_path'], "."));
+			$substr = mb_substr($value['file_path'], mb_strrpos($value['file_path'], "."));
 			//查询文件名称(若之前保存文件为源文件名保存可跳过该步骤)
 			$zip->addFile($value['file_path'], basename($value['name'].$substr));
 		}

+ 1 - 0
dyu/application/store/extra/menus.php

@@ -246,6 +246,7 @@ return [
 			[
 				'name'    => '资质管理',
 				'active'  => true,
+				'index'   => 'content.certificate/index',
 				'submenu' => [
 					[
 						'name'  => '资质列表',

+ 5 - 4
dyu/application/store/model/CertificateApply.php

@@ -107,11 +107,12 @@ class CertificateApply extends CertificateApplyModel
 				return false;
 			}
 			foreach ($certificateList as $certificate) {
-				$service       = new WaterMarkBase($certificate['file']['file_path'], $this['watermark'], self::$wxapp_id, $certificate['file_type']);
-				$filePath      = $service->waterMark();
+				$service       = new WaterMarkBase($certificate['file']['file_path'], $this['watermark'], self::$wxapp_id, $certificate['file_type'], '有效期至'.$this['indate']);
+				$result        = $service->waterMark();
 				$result_data[] = [
-					'name'      => $certificate['name'],
-					'file_path' => $filePath,
+					'name'           => $certificate['name'],
+					'file_path'      => $result['file_path'],
+					'file_path_name' => $result['file_name'],
 				];
 			}
 			$data['result_data'] = $result_data;

+ 38 - 2
dyu/application/store/view/content/certificate/watermark/add.php

@@ -131,18 +131,47 @@
         //         form.render(); // 重新渲染
         //     });
         // });
+        // var selected = [];
+        // $('input[type="checkbox"]').change(function () {
+        //     if ($(this).is(":checked")) {
+        //         var value = $(this).val();
+        //         selected.push(value);
+        //     } else {
+        //         var value = $(this).val();
+        //         selected.splice(selected.indexOf(value), 1);
+        //     }
+        // })
+        // console.log(selected);
+        // var selected = [];
+        // $('input[type="checkbox"]').each(function () {
+        //     if ($(this).is(":checked")) {
+        //         var value = $(this).val();
+        //         selected.push(value);
+        //     } else {
+        //         var value = $(this).val();
+        //         selected.splice(selected.indexOf(value), 1);
+        //     }
+        // })
+
         var $selected = $('#category_select');
         $selected.on('change', function () {
             var url = "<?= url('content.certificate.watermark/getCertificateList') ?>";
             var load = layer.load();
             var category_ids = $(this).val();
-            console.log(category_ids);
+            var selectedValues = $('input[type="checkbox"]:checked').map(function () {
+                return $(this).val();
+            }).get();
             $.post(url, {'category_ids': category_ids}, function (result) {
                 if (result.code === 1) {
                     var data = result.data;
                     $('#checkboxContainer').html('');
                     $.each(data, function (index, item) {
-                        const checkboxHtml = '<label class="am-checkbox-inline"> <input required type="checkbox" name="certificate_ids[]" value="' + item.id + '"> ' + item.name + '</label>';
+                        if (in_array(item.id.toString(), selectedValues)) {
+                            var checkboxHtml = '<label class="am-checkbox-inline"> <input required type="checkbox" name="certificate_ids[]" value="' + item.id + '" checked> ' + item.name + '</label>';
+                        } else {
+                            var checkboxHtml = '<label class="am-checkbox-inline"> <input required type="checkbox" name="certificate_ids[]" value="' + item.id + '"> ' + item.name + '</label>';
+                        }
+                        // const checkboxHtml = '<label class="am-checkbox-inline"> <input required type="checkbox" name="certificate_ids[]" value="' + item.id + '"> ' + item.name + '</label>';
                         $('#checkboxContainer').append(checkboxHtml);
                     });
                     // // 使用 Layui 的 form 模块来渲染刚添加的复选框
@@ -166,5 +195,12 @@
             // });
         });
 
+        function in_array(elem, arr) {
+            var i = 0, n = arr.length;
+            for (; i < n; ++i)
+                if (arr[i] === elem)
+                    return true;
+            return false;
+        }
     });
 </script>

+ 168 - 0
dyu/application/store/view/content/certificate/watermark/detail.php

@@ -0,0 +1,168 @@
+<style>
+    .am-selected {
+        width: 100%;
+    }
+</style>
+<div class="row-content am-cf">
+    <div class="row">
+        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
+            <div class="widget am-cf">
+                <form id="my-form" class="am-form tpl-form-line-form" method="post">
+                    <div class="widget-body">
+                        <fieldset>
+                            <div class="widget-head am-cf">
+                                <div class="widget-title am-fl">资质查看</div>
+                            </div>
+                            <div class="am-form-group">
+                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">申请人 </label>
+                                <div class="am-u-sm-9 am-u-end">
+                                    <input type="text" class="tpl-form-input" name="username"
+                                           value="<?= $model['username'] ?>" placeholder="请输入申请人" disabled>
+                                </div>
+                            </div>
+                            <div class="am-form-group">
+                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">项目名称 </label>
+                                <div class="am-u-sm-9 am-u-end">
+                                    <input type="text" class="tpl-form-input" name="project"
+                                           value="<?= $model['project'] ?>" placeholder="请输入项目名称" disabled>
+                                </div>
+                            </div>
+                            <div class="am-form-group">
+                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">申请用途 </label>
+                                <div class="am-u-sm-9 am-u-end">
+                                    <input type="text" class="tpl-form-input" name="reason"
+                                           value="<?= $model['reason'] ?>" placeholder="请输入项目名称" disabled>
+                                </div>
+                            </div>
+                            <div class="am-form-group">
+                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">水印 </label>
+                                <div class="am-u-sm-9 am-u-end">
+                                    <input type="text" class="tpl-form-input" name="watermark"
+                                           value="<?= $model['watermark'] ?>" placeholder="请输入水印" disabled>
+                                </div>
+                            </div>
+                            <div class="am-form-group">
+                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 活动时间 </label>
+                                <div class="am-u-sm-9 am-u-md-6 am-u-lg-5 am-u-end">
+                                    <!-- 会员等级列表-->
+                                    <div class="am-input-group">
+                                        <input type="text" class="j-laydate-start am-form-field"
+                                               name="indate"
+                                               placeholder="有效期"
+                                               value="<?= $model['indate'] ?>" disabled>
+                                    </div>
+                                    <div class="help-block">
+                                        <small>砍价活动的开始时间与截止时间</small>
+                                    </div>
+                                </div>
+                            </div>
+                            <div class="am-form-group">
+                                <label class="am-u-sm-3 am-u-lg-2 am-form-label ">申请备注 </label>
+                                <div class="am-u-sm-9 am-u-end">
+                                     <textarea rows="3" name="remark" placeholder="请输入申请用途"
+                                               class="am-field-valid" disabled><?= $model['remark'] ?></textarea>
+                                </div>
+                            </div>
+                            <div class="am-form-group">
+                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">资质分类 </label>
+                                <div class="am-u-sm-9 am-u-end">
+                                    <select id="category_select" data-am-selected="{searchBox: 1, btnSize: 'sm',
+                                             placeholder:'请选择', maxHeight: 400}" multiple disabled style="width: 100%">
+                                        <option value=""></option>
+										<?php if (isset($category)): foreach ($category as $item): ?>
+                                            <option <?= in_array($item['id'], $model['category_ids']) ? 'selected' : '' ?>
+                                                    value="<?= $item['id'] ?>"><?= $item['name'] ?></option>
+										<?php endforeach; endif; ?>
+                                    </select>
+                                </div>
+                            </div>
+
+                            <div class="am-form-group">
+                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">资质资料 </label>
+                                <div class="am-u-sm-9 am-u-end">
+									<?php if (isset($certificateList)): foreach ($certificateList as $certificate): ?>
+                                        <div class="file-item">
+                                            <p title="<?= $certificate['name'] ?>"><?= $certificate['name'] ?></p>
+                                        </div>
+									<?php endforeach; endif; ?>
+                                </div>
+                            </div>
+							<?php if ($model['status'] == 20): ?>
+                                <div class="am-form-group">
+                                    <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">水印下载 </label>
+                                    <div class="am-u-sm-9 am-u-end">
+                                        <a href="<?= url('content.certificate.watermark/zipDownload', ['id' => $model['id']]) ?>">zip打包下载</a>
+                                    </div>
+                                </div>
+                                <div class="am-form-group">
+                                    <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">水印资料 </label>
+                                    <div class="am-u-sm-9 am-u-end">
+										<?php if (isset($model['result_data'])): foreach ($model['result_data'] as $data): ?>
+                                            <div class="file-item">
+                                                <a title="<?= $data['name'] ?>"
+                                                   href="<?= base_url().'temp/image/'.$model['wxapp_id'].'/'.$data['file_path_name'] ?>"
+                                                   target="_blank"><?= $data['name'] ?>
+                                                </a>
+                                            </div>
+										<?php endforeach; endif; ?>
+                                    </div>
+                                </div>
+							<?php endif; ?>
+                            <div class="am-form-group">
+                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">审批状态 </label>
+                                <div class="am-u-sm-9 am-u-end">
+                                    <label class="am-radio-inline">
+                                        <input type="radio" name="status" value="20" data-am-ucheck
+											<?= in_array($model['status'], [20]) ? 'checked' : '' ?> disabled>
+                                        通过
+                                    </label>
+                                    <label class="am-radio-inline">
+                                        <input type="radio" name="status" value="30" data-am-ucheck
+										       <?= $model['status'] == 30 ? 'checked' : '' ?>disabled>
+                                        拒绝
+                                    </label>
+                                </div>
+                            </div>
+                            <div id="reason_div" class="am-form-group" <?= $model['status'] != 30 ? 'hidden' : '' ?>>
+                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 审核拒绝原因 </label>
+                                <div class="am-u-sm-9 am-u-end">
+                                    <textarea rows="2" name="refuse_reason" id="reason_textarea" placeholder="请输入拒绝原因"
+                                              class="am-field-valid" <?= $model['status'] != 10 ? 'disabled' : '' ?> required><?= $model['refuse_reason'] ?></textarea>
+                                </div>
+                            </div>
+                        </fieldset>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+</div>
+
+
+<script src="static/common/plugins/laydate/laydate.js"></script>
+
+<script>
+    $(function () {
+        // 时间选择器
+        laydate.render({
+            elem: '.j-laydate-start'
+            , type: 'date'
+        });
+
+        /**
+         * 表单验证提交
+         * @type {*}
+         */
+        $('#my-form').superForm();
+        $("input[name='status']").change(function () {
+            var num = $('input:radio[name="status"]:checked').val();
+            if (num == 20) {
+                $("#reason_div").hide();
+                $("#reason_textarea").val('');
+            } else {
+                $("#reason_div").show();
+            }
+        });
+
+    });
+</script>

+ 8 - 8
dyu/application/store/view/content/certificate/watermark/edit.php

@@ -87,16 +87,16 @@
                             <div class="am-form-group">
                                 <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">资质资料 </label>
                                 <div class="am-u-sm-9 am-u-end">
-                                    <div id="checkboxContainer">
-										<?php if (isset($certificateList)): foreach ($certificateList as $certificate): ?>
-                                            <label class="am-checkbox-inline">
-                                                <input type="checkbox"
-                                                       disabled <?= in_array($certificate['id'], $model['certificate_ids']) ? 'checked' : '' ?> > <?= $certificate['name'] ?>
-                                            </label>
-										<?php endforeach; endif; ?>
-                                    </div>
+									<?php if (isset($certificateList)): foreach ($certificateList as $certificate): ?>
+                                        <div class="file-item">
+                                            <a href="<?= $certificate['file']['file_path'] ?>"
+                                               title="<?= $certificate['name'] ?>" target="_blank"><?= $certificate['name'] ?>
+                                            </a>
+                                        </div>
+									<?php endforeach; endif; ?>
                                 </div>
                             </div>
+
                             <div class="am-form-group">
                                 <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">审批状态 </label>
                                 <div class="am-u-sm-9 am-u-end">

+ 11 - 3
dyu/application/store/view/content/certificate/watermark/index.php

@@ -48,9 +48,17 @@
                                     <td class="am-text-middle">
                                         <div class="tpl-table-black-operation">
 											<?php if (checkPrivilege('content.certificate.watermark/edit')): ?>
-                                                <a href="<?= url('content.certificate.watermark/edit',
+												<?php if ($item['status'] == 10): ?>
+                                                    <a href="<?= url('content.certificate.watermark/edit',
+														['id' => $item['id']]) ?>">
+                                                        <i class="am-icon-pencil"></i> 审核
+                                                    </a>
+												<?php endif; ?>
+											<?php endif; ?>
+											<?php if (checkPrivilege('content.certificate.watermark/detail')): ?>
+                                                <a href="<?= url('content.certificate.watermark/detail',
 													['id' => $item['id']]) ?>">
-                                                    <i class="am-icon-pencil"></i> <?= $item['status'] == 10 ? '审核' : '查看' ?>
+                                                    <i class="am-icon-eye"></i>查看
                                                 </a>
 											<?php endif; ?>
 											<?php if (checkPrivilege('content.certificate.watermark/delete')): ?>
@@ -89,7 +97,7 @@
 
         // 删除元素
         var url = "<?= url('content.certificate.watermark/delete') ?>";
-        $('.item-delete').delete('id', url,'确认要取消申请吗');
+        $('.item-delete').delete('id', url, '确认要取消申请吗');
 
     });
 </script>