moonsflyer 4 ay önce
ebeveyn
işleme
743562e555

+ 3 - 1
app/adminapi/logic/after_sale/AfterSaleLogic.php

@@ -332,8 +332,10 @@ class AfterSaleLogic extends BaseLogic
 
             // 退款
             $order = Order::findOrEmpty($afterSale->order_id)->toArray();
+            outFileLog($order,'refund_money','$order');
+
             RefundLogic::refund($afterSale->refund_way, $order, $afterSale->id, $afterSale->refund_total_amount);
-    
+
             //更新订单状态
             RefundLogic::afterSaleRefundUpdate($afterSale->order_id);
 

+ 17 - 1
app/common/logic/RefundLogic.php

@@ -60,6 +60,9 @@ class RefundLogic extends BaseLogic
      */
     public static function refund($refundWay, $order, $afterSaleId, $refundAmount)
     {
+        outFileLog($refundWay,'refund_money','$refundWay');
+        outFileLog($afterSaleId,'refund_money','$afterSaleId');
+        outFileLog($refundAmount,'refund_money','$refundAmount');
         if ($refundAmount < 0) {
             return false;
         }
@@ -175,6 +178,19 @@ class RefundLogic extends BaseLogic
             'refund_status'     => 1,
             'refund_msg'        => json_encode([], JSON_UNESCAPED_UNICODE),
         ], ['id' => self::$refund['id']]);
+        //更新售后订单状态
+        $re_where['order_id'] = $order['id'];
+        $re_where['refund_total_amount'] = $refundAmount;
+        $afterSale = AfterSale::where($re_where)->findOrEmpty();
+        if(!$afterSale->isEmpty()){
+            $afterSale->status = AfterSaleEnum::STATUS_SUCCESS;
+            $afterSale->sub_status = AfterSaleEnum::SUB_STATUS_SELLER_REFUND_SUCCESS;
+            $afterSale->refund_status = $refundStauts ?? AfterSaleEnum::FULL_REFUND;
+            $afterSale->save();
+            AfterSaleService::createAfterLog($afterSale['id'], '系统已完成退款', 0, AfterSaleLogEnum::ROLE_SYS);
+        }
+
+
     }
 
 
@@ -286,7 +302,7 @@ class RefundLogic extends BaseLogic
             ->group('order_goods_id')
             ->where('status', AfterSaleEnum::STATUS_SUCCESS)
             ->count();
-
+        outFileLog($order_id,'refund_money','afterSaleRefundUpdate-refund');
         //如果订单商品已全部退款
         if ($order_goods_count == $after_sale_count) {
             Order::update([ 'order_status' => OrderEnum::STATUS_CLOSE ], [

+ 122 - 0
app/common/service/ImageMagickCompressService.php

@@ -0,0 +1,122 @@
+<?php
+
+namespace app\common\service;
+
+use Exception;
+
+class ImageMagickCompressService
+{
+    /**
+     * 使用ImageMagick压缩图片
+     */
+    public static function compress($sourcePath, $compressConfig = [])
+    {
+        try {
+            // 检查ImageMagick扩展
+            if (!extension_loaded('imagick')) {
+                outFileLog('ImageMagick扩展未安装', 'upload_img', 'imagick_not_installed');
+                return false;
+            }
+
+            // 默认配置
+            $config = array_merge([
+                'max_width' => 1920,
+                'max_height' => 1080,
+                'quality' => 80,
+                'format' => null // 保持原格式
+            ], $compressConfig);
+
+            // 检查源文件
+            if (!file_exists($sourcePath)) {
+                throw new Exception('源文件不存在: ' . $sourcePath);
+            }
+
+            // 获取文件信息
+            $pathInfo = pathinfo($sourcePath);
+            $extension = strtolower($pathInfo['extension']);
+            
+            // 支持的格式
+            $supportedFormats = ['jpg', 'jpeg', 'png', 'gif', 'webp', 'bmp'];
+            if (!in_array($extension, $supportedFormats)) {
+                outFileLog('不支持的图片格式: ' . $extension, 'upload_img', 'unsupported_format');
+                return false;
+            }
+
+            // 创建Imagick对象
+            $imagick = new \Imagick($sourcePath);
+            
+            // 获取原始尺寸
+            $originalWidth = $imagick->getImageWidth();
+            $originalHeight = $imagick->getImageHeight();
+            
+            outFileLog("原始尺寸: {$originalWidth}x{$originalHeight}", 'upload_img', 'original_size');
+
+            // 计算新尺寸
+            $newSize = self::calculateNewSize(
+                $originalWidth, 
+                $originalHeight, 
+                $config['max_width'], 
+                $config['max_height']
+            );
+
+            // 如果需要缩放
+            if ($newSize['width'] < $originalWidth || $newSize['height'] < $originalHeight) {
+                $imagick->resizeImage(
+                    $newSize['width'], 
+                    $newSize['height'], 
+                    \Imagick::FILTER_LANCZOS, 
+                    1
+                );
+                outFileLog("压缩后尺寸: {$newSize['width']}x{$newSize['height']}", 'upload_img', 'compressed_size');
+            }
+
+            // 设置压缩质量
+            $imagick->setImageCompressionQuality($config['quality']);
+            
+            // 去除EXIF信息减小文件大小
+            $imagick->stripImage();
+
+            // 生成压缩后的文件路径
+            $compressedPath = self::generateCompressedPath($sourcePath);
+            
+            // 保存压缩后的图片
+            $imagick->writeImage($compressedPath);
+            $imagick->clear();
+            $imagick->destroy();
+
+            // 检查压缩效果
+            $originalSize = filesize($sourcePath);
+            $compressedSize = filesize($compressedPath);
+            $compressionRatio = round((1 - $compressedSize / $originalSize) * 100, 2);
+            
+            outFileLog("压缩完成,原大小: {$originalSize}字节,压缩后: {$compressedSize}字节,压缩率: {$compressionRatio}%", 'upload_img', 'compression_result');
+
+            return $compressedPath;
+
+        } catch (Exception $e) {
+            outFileLog('ImageMagick压缩失败: ' . $e->getMessage(), 'upload_img', 'imagick_compress_error');
+            return false;
+        }
+    }
+
+    /**
+     * 计算新尺寸(保持宽高比)
+     */
+    private static function calculateNewSize($width, $height, $maxWidth, $maxHeight)
+    {
+        $ratio = min($maxWidth / $width, $maxHeight / $height, 1);
+        return [
+            'width' => intval($width * $ratio),
+            'height' => intval($height * $ratio)
+        ];
+    }
+
+    /**
+     * 生成压缩后的文件路径
+     */
+    private static function generateCompressedPath($sourcePath)
+    {
+        $pathInfo = pathinfo($sourcePath);
+        return $pathInfo['dirname'] . '/' . $pathInfo['filename'] . '_compressed.' . $pathInfo['extension'];
+    }
+}

+ 1 - 0
app/common/service/pay/wechat/WechatPayV2Default.php

@@ -220,6 +220,7 @@ class WechatPayV2Default extends BasePayService
         );
         
         if (($result['return_code'] ?? '') == 'SUCCESS' && ($result['result_code'] ?? '') == 'SUCCESS') {
+            outFileLog($result,'refund_money','$result-refund');
             return true;
         }
         

+ 9 - 0
config/project.php

@@ -223,4 +223,13 @@ return [
     'file_video' => [
         'wmv', 'avi', 'mpg', 'mpeg', '3gp', 'mov', 'mp4', 'flv', 'f4v', 'rmvb', 'mkv'
     ],
+    'image_compress' => [
+        'enable' => true,
+        'max_width' => 1920,
+        'max_height' => 1080,
+        'quality' => 80,
+        'max_file_size' => 2 * 1024 * 1024, // 2MB
+        'preferred_method' => 'imagick' // imagick, ffmpeg, simple
+    ],
+
 ];