瀏覽代碼

修改拼团结算

dongxiaoqin 11 月之前
父節點
當前提交
7fae79da0a

+ 4 - 1
app/adminapi/logic/group_activity/GroupActivityCategoryLogic.php

@@ -325,10 +325,13 @@ class GroupActivityCategoryLogic extends BaseLogic
      */
     public static function total($id)
     {
+        $field = 'a.*, SUM(CASE WHEN c.id IS NOT NULL THEN b.num ELSE 0 END) as order_total';
+        $field .= ',SUM(CASE WHEN c.id IS NOT NULL THEN (c.work_total - c.work_amount) ELSE 0 END) as income_total';
+        $field .= ',SUM(CASE WHEN c.id IS NOT NULL THEN (c.settlement_amount) ELSE 0 END) as engineer_commission';
         $lists = GroupActivity::alias('a')
         ->leftJoin('group_user_order b', 'a.id = b.group_activity_id')
         ->leftJoin('group_service_work c', 'b.id = c.group_user_order_id and c.service_status = 3')
-        ->field('a.*, SUM(CASE WHEN c.id IS NOT NULL THEN 1 ELSE 0 END) as order_total')
+        ->field($field)
         ->where('a.group_category_id', $id)
         ->group('a.id')
         ->select()

+ 22 - 1
app/api/controller/SmsController.php

@@ -27,7 +27,7 @@ use app\api\validate\SendSmsValidate;
 class SmsController extends BaseApiController
 {
 
-    public array $notNeedLogin = ['sendCode'];
+    public array $notNeedLogin = ['sendCode','verifyCode'];
 
 
     /**
@@ -46,4 +46,25 @@ class SmsController extends BaseApiController
         return $this->fail(SmsLogic::getError());
     }
 
+    public function verifyCode()
+    {
+        $res = generateCaptcha();
+
+        // 存储验证码到缓存,有效期2分钟(120秒)
+        cache('verifyCode', $res['captcha'], 120);
+
+        $image = $res['image'];
+
+        // 设置响应头
+        header('Content-Type: image/png');
+        header('Cache-Control: no-cache, must-revalidate');
+        header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
+
+        // 输出图像
+        imagepng($image);
+
+        // 释放资源
+        imagedestroy($image);
+    }
+
 }

+ 3 - 2
app/api/lists/property/PropertyServiceWorkLists.php

@@ -50,7 +50,7 @@ class PropertyServiceWorkLists extends BaseApiDataLists implements ListsSearchIn
         $lists = GroupServiceWork::alias('a')
             ->leftJoin('group_order b','a.group_order_id=b.id')
             ->leftJoin('user c','a.user_id=c.id')
-            ->field('a.id,a.work_sn,a.title,a.appointment_time,a.work_total,c.avatar as image')
+            ->field('a.id,a.work_sn,a.title,a.appointment_time,a.work_total,a.work_amount,c.avatar as image')
             ->where($this->queryWhere())
             ->limit($this->limitOffset, $this->limitLength)
             ->order('a.appointment_time', 'desc')
@@ -58,6 +58,7 @@ class PropertyServiceWorkLists extends BaseApiDataLists implements ListsSearchIn
             ->toArray();
 
         foreach($lists as &$item) {
+            $item['work_total'] = bcsub($item['work_total'], $item['work_amount'], 2);
             $item['appointment_time'] = date('n月j日', strtotime($item['appointment_time']));
         }
         return $lists;
@@ -92,7 +93,7 @@ class PropertyServiceWorkLists extends BaseApiDataLists implements ListsSearchIn
                             ->where($this->searchWhere)
                             ->where($this->queryWhere())
                             ->sum('a.work_amount');
-        return ["total_amount" => $totalWorkTotal - $totalWorkAmount];
+        return ["total_amount" => bcsub($totalWorkTotal, $totalWorkAmount, 2)];
     }
 
 }

+ 51 - 0
app/common.php

@@ -6,6 +6,57 @@ use app\common\model\setting\PostageRegion;
 use app\common\service\FileService;
 use think\helper\Str;
 
+/**
+ * 生成图形验证码
+ */
+function generateCaptcha() {
+    // 配置参数
+    $width = 120;       // 图像宽度
+    $height = 40;       // 图像高度
+    $characters = 4;    // 验证码字符数量
+    $font_size = 20;    // 字体大小
+
+    // 允许的字符(去除易混淆的字符如0、O、1、l等)
+    $allowed_chars = '23456789abcdefghjkmnpqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ';
+
+    // 生成随机验证码
+    $code = '';
+    for ($i = 0; $i < $characters; $i++) {
+        $code .= $allowed_chars[rand(0, strlen($allowed_chars) - 1)];
+    }
+
+    // 创建图像资源
+    $image = imagecreatetruecolor($width, $height);
+
+    // 设置背景色为白色
+    $bg_color = imagecolorallocate($image, 255, 255, 255);
+    imagefill($image, 0, 0, $bg_color);
+
+    // 添加干扰线
+    for ($i = 0; $i < 5; $i++) {
+        $line_color = imagecolorallocate($image, rand(100, 200), rand(100, 200), rand(100, 200));
+        imageline($image, rand(0, $width), rand(0, $height), rand(0, $width), rand(0, $height), $line_color);
+    }
+
+    // 添加噪点
+    for ($i = 0; $i < 100; $i++) {
+        $pixel_color = imagecolorallocate($image, rand(150, 255), rand(150, 255), rand(150, 255));
+        imagesetpixel($image, rand(0, $width), rand(0, $height), $pixel_color);
+    }
+
+    // 绘制验证码字符
+    for ($i = 0; $i < $characters; $i++) {
+        $text_color = imagecolorallocate($image, rand(0, 100), rand(0, 100), rand(0, 100));
+        $x = 15 + ($i * ($width - 30) / $characters);
+        $y = rand($font_size + 5, $height - 5);
+        $angle = rand(-20, 20); // 随机旋转角度
+        imagettftext($image, $font_size, $angle, (int)$x, (int)$y, $text_color, './static/fonts/arial.ttf', $code[$i]);
+    }
+    return [
+        'captcha' => $code,
+        'image' => $image,
+    ];
+}
 
 /**
  * 根据经纬度获取详细地址(高德地图逆地理编码)