one_after hace 2 meses
padre
commit
4546fa91e6

+ 2 - 0
app/business/PayorderBusiness.php

@@ -656,6 +656,8 @@ class PayorderBusiness
                 StreamBusiness::addStream($data['user_id'], $goodsData->pay_price, streamType45, moldType17, moldTypefild17, $data['id']);
             } elseif ($goodsData->type == 10) {
                 StreamBusiness::addStream($data['user_id'], $goodsData->pay_price, streamType45, moldType17, moldTypefild17, $data['id']);
+            }elseif ($goodsData->type == 11) {
+                StreamBusiness::addStream($data['user_id'], $goodsData->pay_price, streamType45, moldType17, moldTypefild17, $data['id']);
             }
 
             /** 新增消费数据 */

+ 190 - 128
app/controller/UploadController.php

@@ -1,150 +1,209 @@
 <?php
 
-    namespace app\controller;
+namespace app\controller;
+
+use Exception;
+use Intervention\Image\ImageManagerStatic as Image;
+use plugin\admin\app\controller\Crud;
+use plugin\admin\app\model\Upload;
+
+use support\Db;
+use support\exception\BusinessException;
+use support\Request;
+use support\Response;
+use hg\apidoc\annotation as Apidoc;
+
+#[Apidoc\Title("上传")]
+#[Apidoc\Group("Upload")]
+#[Apidoc\Sort(1)]
+class UploadController extends Crud
+{
+    /**
+     * @var Upload
+     */
+    protected $model = null;
+
+    /**
+     * 只返回当前管理员数据
+     * @var string
+     */
+    protected $dataLimit = 'personal';
+
+    /**
+     * 构造函数
+     * @return void
+     */
+    public function __construct()
+    {
+        $this->model = new Upload;
+    }
 
-    use Exception;
-    use Intervention\Image\ImageManagerStatic as Image;
-    use plugin\admin\app\controller\Crud;
-    use plugin\admin\app\model\Upload;
+    #[Apidoc\Title("上传")]
+    #[Apidoc\Url("api/file")]
+    #[Apidoc\Method("POST")]
+    #[Apidoc\Param("file", type: "file", require: true, desc: "上传图片")]
+    #[Apidoc\Header("token", type: "string", require: true, desc: "身份令牌Token", mock: "@token")]
+    #[Apidoc\Returned(name: "url", type: "string", require: true, desc: '前端展示地址', default: '12317309127904')]
+    public function image(Request $request): Response
+    {
+        $data     = $this->base($request, '/upload/img/' . date('Ymd'));
+        $realpath = $data['realpath'];
+        try {
+            $img        = Image::make($realpath);
+            $max_height = 1170;
+            $max_width  = 1170;
+            $width      = $img->width();
+            $height     = $img->height();
+            $ratio      = 1;
+            if ($height > $max_height || $width > $max_width) {
+                $ratio = $width > $height ? $max_width / $width : $max_height / $height;
+            }
+            $img->resize($width * $ratio, $height * $ratio)->save($realpath);
+        } catch (Exception $e) {
+            unlink($realpath);
+            return error('处理图片发生错误');
+        }
 
-    use support\Db;
-    use support\exception\BusinessException;
-    use support\Request;
-    use support\Response;
-    use hg\apidoc\annotation as Apidoc;
+        /*  Db::table('wa_users')->where('id',$request->user_data['id'])->update(['img'=>$data['url']]);*/
+        return success([
+            'url'  => imageToBase64($data['url']),
+            'path' => $data['url'],
+        ]);
+    }
 
-    #[Apidoc\Title("上传")]
-    #[Apidoc\Group("Upload")]
-    #[Apidoc\Sort(1)]
-    class UploadController extends Crud
+
+    /**
+     * 获取上传数据
+     * @param Request $request
+     * @param $relative_dir
+     * @return array
+     * @throws BusinessException|RandomException
+     */
+    protected function base(Request $request, $relative_dir): array
     {
-        /**
-         * @var Upload
-         */
-        protected $model = null;
-
-        /**
-         * 只返回当前管理员数据
-         * @var string
-         */
-        protected $dataLimit = 'personal';
-
-        /**
-         * 构造函数
-         * @return void
-         */
-        public function __construct()
-        {
-            $this->model = new Upload;
+        $relative_dir = ltrim($relative_dir, '\\/');
+        $file         = current($request->file());
+        if (!$file || !$file->isValid()) {
+            throw new BusinessException('未找到上传文件', 400);
         }
 
-        #[Apidoc\Title("上传")]
-        #[Apidoc\Url("api/file")]
-        #[Apidoc\Method("POST")]
-        #[Apidoc\Param("file", type: "file", require: true, desc: "上传图片")]
-        #[Apidoc\Header("token", type: "string", require: true, desc: "身份令牌Token", mock: "@token")]
-        #[Apidoc\Returned(name: "url", type: "string", require: true, desc: '前端展示地址', default: '12317309127904')]
-        public function image(Request $request): Response
-        {
-            $data     = $this->base($request, '/upload/img/' . date('Ymd'));
-            $realpath = $data['realpath'];
-            try {
-                $img        = Image::make($realpath);
-                $max_height = 1170;
-                $max_width  = 1170;
-                $width      = $img->width();
-                $height     = $img->height();
-                $ratio      = 1;
-                if ($height > $max_height || $width > $max_width) {
-                    $ratio = $width > $height ? $max_width / $width : $max_height / $height;
-                }
-                $img->resize($width * $ratio, $height * $ratio)->save($realpath);
-            } catch (Exception $e) {
-                unlink($realpath);
-                return error('处理图片发生错误');
-            }
+        $admin_public_path = rtrim(config('app.public_path', ''), '\\/');
+        $base_dir          = $admin_public_path ? $admin_public_path . DIRECTORY_SEPARATOR : base_path() . '/plugin/admin/public/';
+        $full_dir          = $base_dir . $relative_dir;
+        if (!is_dir($full_dir)) {
+            mkdir($full_dir, 0777, true);
+        }
+
+        $ext       = $file->getUploadExtension() ?: null;
+        $mime_type = $file->getUploadMimeType();
+        $file_name = $file->getUploadName();
+        $file_size = $file->getSize();
 
-            /*  Db::table('wa_users')->where('id',$request->user_data['id'])->update(['img'=>$data['url']]);*/
-            return success([
-                'url'  => imageToBase64($data['url']),
-                'path' => $data['url'],
-            ]);
+        if (!$ext && $file_name === 'blob') {
+            [$___image, $ext] = explode('/', $mime_type);
+            unset($___image);
         }
 
+        $ext               = strtolower($ext);
+        $ext_forbidden_map = ['php', 'php3', 'php5', 'css', 'js', 'html', 'htm', 'asp', 'jsp'];
+        if (in_array($ext, $ext_forbidden_map)) {
+            throw new BusinessException('不支持该格式的文件上传', 400);
+        }
 
-        /**
-         * 获取上传数据
-         * @param Request $request
-         * @param $relative_dir
-         * @return array
-         * @throws BusinessException|RandomException
-         */
-        protected function base(Request $request, $relative_dir): array
-        {
-            $relative_dir = ltrim($relative_dir, '\\/');
-            $file         = current($request->file());
-            if (!$file || !$file->isValid()) {
-                throw new BusinessException('未找到上传文件', 400);
-            }
+        $relative_path = $relative_dir . '/' . bin2hex(pack('Nn', time(), random_int(1, 65535))) . ".$ext";
+        $full_path     = $base_dir . $relative_path;
+        $file->move($full_path);
+        $image_with = $image_height = 0;
+        if ($img_info = getimagesize($full_path)) {
+            [$image_with, $image_height] = $img_info;
+            $mime_type = $img_info['mime'];
+        }
+        return [
+            'url'          => "/$relative_path",
+            'name'         => $file_name,
+            'realpath'     => $full_path,
+            'size'         => $file_size,
+            'mime_type'    => $mime_type,
+            'image_with'   => $image_with,
+            'image_height' => $image_height,
+            'ext'          => $ext,
+        ];
+    }
 
+    #[Apidoc\Title("上传图片base64")]
+    #[Apidoc\Url("api/base_file.html")]
+    #[Apidoc\Method("POST")]
+    #[Apidoc\Param("baseimg", type: "string", require: true, desc: "base64编码")]
+    #[Apidoc\Header("token", type: "string", require: true, desc: "身份令牌Token", mock: "@token")]
+    #[Apidoc\Returned(name: "url", type: "string", require: true, desc: '前端展示地址', default: '12317309127904')]
+    public function base_file(Request $request): Response
+    {
+        $param = $request->all();
+        try {
+            $base64Image_one = $param['baseimg'];                                                                                           // 获取Base64字符串
+            $imageData       = base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $base64Image_one));                             // 移除数据URL的前缀并解码
+            $imageName       = $request->user_data['id'] . time() . '.png';                                                             // 生成一个唯一的文件名
+
+            $data              = '/upload/img/' . date('Ymd');
+            $relative_dir      = ltrim($data, '\\/');
             $admin_public_path = rtrim(config('app.public_path', ''), '\\/');
             $base_dir          = $admin_public_path ? $admin_public_path . DIRECTORY_SEPARATOR : base_path() . '/plugin/admin/public/';
             $full_dir          = $base_dir . $relative_dir;
             if (!is_dir($full_dir)) {
                 mkdir($full_dir, 0777, true);
             }
+            $imagePath_one = '/upload/img/' . date('Ymd') . '/' . $imageName; // 指定保存路径和文件名
 
-            $ext       = $file->getUploadExtension() ?: null;
-            $mime_type = $file->getUploadMimeType();
-            $file_name = $file->getUploadName();
-            $file_size = $file->getSize();
+            // 保存图片到服务器
+            file_put_contents($base_dir . $imagePath_one, $imageData);
+        } catch (Exception $e) {
+            return error('处理图片发生错误');
+        }
+        Db::table('wa_users')->where('id', $request->user_data['id'])->update(['protocol_img' => $imagePath_one]);
+        return adminsuccess([
+            'url'  => imageToBase64($imagePath_one),
+            'path' => $imagePath_one,
+        ]);
+    }
 
-            if (!$ext && $file_name === 'blob') {
-                [$___image, $ext] = explode('/', $mime_type);
-                unset($___image);
-            }
 
-            $ext               = strtolower($ext);
-            $ext_forbidden_map = ['php', 'php3', 'php5', 'css', 'js', 'html', 'htm', 'asp', 'jsp'];
-            if (in_array($ext, $ext_forbidden_map)) {
-                throw new BusinessException('不支持该格式的文件上传', 400);
-            }
+    #[Apidoc\Title("上传图片base64")]
+    #[Apidoc\Url("api/identityimg.html")]
+    #[Apidoc\Method("POST")]
+    #[Apidoc\Param("identity_imgone", type: "string", require: true, desc: "base64编码")]
+    #[Apidoc\Param("identity_imgtwo", type: "string", require: true, desc: "base64编码")]
+    #[Apidoc\Header("token", type: "string", require: true, desc: "身份令牌Token", mock: "@token")]
+    #[Apidoc\Returned(name: "url", type: "string", require: true, desc: '前端展示地址', default: '12317309127904')]
+    public function identityimg(Request $request): Response
+    {
+        $param = $request->all();
+        try {
+            if (!empty($param['identity_imgone'])) {
+                $base64Image_one = $param['identity_imgone'];                                                                                           // 获取Base64字符串
+                $imageData       = base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $base64Image_one));                             // 移除数据URL的前缀并解码
+                $imageName       = $request->user_data['id'] . time() . '.png';                                                             // 生成一个唯一的文件名
 
-            $relative_path = $relative_dir . '/' . bin2hex(pack('Nn', time(), random_int(1, 65535))) . ".$ext";
-            $full_path     = $base_dir . $relative_path;
-            $file->move($full_path);
-            $image_with = $image_height = 0;
-            if ($img_info = getimagesize($full_path)) {
-                [$image_with, $image_height] = $img_info;
-                $mime_type = $img_info['mime'];
-            }
-            return [
-                'url'          => "/$relative_path",
-                'name'         => $file_name,
-                'realpath'     => $full_path,
-                'size'         => $file_size,
-                'mime_type'    => $mime_type,
-                'image_with'   => $image_with,
-                'image_height' => $image_height,
-                'ext'          => $ext,
-            ];
-        }
+                $data              = '/upload/img/11' . date('Ymd');
+                $relative_dir      = ltrim($data, '\\/');
+                $admin_public_path = rtrim(config('app.public_path', ''), '\\/');
+                $base_dir          = $admin_public_path ? $admin_public_path . DIRECTORY_SEPARATOR : base_path() . '/plugin/admin/public/';
+                $full_dir          = $base_dir . $relative_dir;
+                if (!is_dir($full_dir)) {
+                    mkdir($full_dir, 0777, true);
+                }
+                $imagePath_one = '/upload/img/' . date('Ymd') . '/' . $imageName; // 指定保存路径和文件名
+
+                // 保存图片到服务器
+                file_put_contents($base_dir . $imagePath_one, $imageData);
+                Db::table('wa_users')->where('id', $request->user_data['id'])->update(['identity_imgone' => $imagePath_one]);
 
-        #[Apidoc\Title("上传图片base64")]
-        #[Apidoc\Url("api/base_file.html")]
-        #[Apidoc\Method("POST")]
-        #[Apidoc\Param("baseimg", type: "string", require: true, desc: "base64编码")]
-        #[Apidoc\Header("token", type: "string", require: true, desc: "身份令牌Token", mock: "@token")]
-        #[Apidoc\Returned(name: "url", type: "string", require: true, desc: '前端展示地址', default: '12317309127904')]
-        public function base_file(Request $request): Response
-        {
-            $param              = $request->all();
-            try {
-                $base64Image_one = $param['baseimg'];                                                                                           // 获取Base64字符串
+            }
+            if (!empty($param['identity_imgtwo'])) {
+                $base64Image_one = $param['identity_imgtwo'];                                                                                           // 获取Base64字符串
                 $imageData       = base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $base64Image_one));                             // 移除数据URL的前缀并解码
                 $imageName       = $request->user_data['id'] . time() . '.png';                                                             // 生成一个唯一的文件名
 
-                $data              = '/upload/img/' . date('Ymd');
+                $data              = '/upload/img/22' . date('Ymd');
                 $relative_dir      = ltrim($data, '\\/');
                 $admin_public_path = rtrim(config('app.public_path', ''), '\\/');
                 $base_dir          = $admin_public_path ? $admin_public_path . DIRECTORY_SEPARATOR : base_path() . '/plugin/admin/public/';
@@ -156,14 +215,17 @@
 
                 // 保存图片到服务器
                 file_put_contents($base_dir . $imagePath_one, $imageData);
-            } catch (Exception $e) {
-                return error('处理图片发生错误');
+                Db::table('wa_users')->where('id', $request->user_data['id'])->update(['identity_imgtwo' => $imagePath_one]);
+
             }
-            Db::table('wa_users')->where('id',$request->user_data['id'])->update(['protocol_img'=>$imagePath_one]);
-            return adminsuccess([
-                'url'  => imageToBase64($imagePath_one),
-                'path' => $imagePath_one,
-            ]);
-        }
 
+        } catch (Exception $e) {
+            return error('处理图片发生错误');
+        }
+        return adminsuccess([
+            'url'  => imageToBase64($imagePath_one),
+            'path' => $imagePath_one,
+        ]);
     }
+
+}

+ 11 - 4
app/controller/UserController.php

@@ -125,6 +125,12 @@ class UserController
             ->where('status', 3)
             ->sum('money');
 
+        $is_buy_identity = Db::table('wa_payorder')
+            ->where('user_id', $request->user_data['id'])
+            ->where('is_pay', 2)
+            ->where('goods_type', 11)
+            ->exists();
+
         $arr       = [
             'img'                 => !empty($request->user_data['img']) ? imageToBase64($request->user_data['img']) : '',
             'uuid'                => $request->user_data['uuid'],
@@ -160,6 +166,8 @@ class UserController
             'protocol_img'        => imageToBase64($request->user_data['protocol_img']),
             'protocol_time'       => $request->user_data['protocol_time'],
             'is_protocol'         => $request->user_data['is_protocol'],
+            'identity_imgone'     => $request->user_data['identity_imgone'],
+            'identity_imgtwo'     => $request->user_data['identity_imgtwo'],
             'protocol_money'      => $protocol_money,
             'bank_img'            => imageToBase64($request->user_data['bank_img']),
             'day_is_sign'         => $day_is_sign ? true : false,
@@ -169,6 +177,7 @@ class UserController
             'is_buy_jihuo'        => $is_buy_jihuo ? true : false,
             'is_buy_jnbaozj'      => $is_buy_jnbaozj ? true : false,
             'is_buy_eight'        => $is_buy_eight ? true : false,
+            'is_buy_identity'        => $is_buy_identity ? true : false,
             'total_sign'          => $total_sign,
             'equity_value'        => $system->equity_value,
             'coin_value'          => $system->coin_value,
@@ -190,18 +199,16 @@ class UserController
             ->where('type', streamType47)
             ->exists();
         if (empty($has47)) {
-            if($usersdata->money_five>100000){
+            if ($usersdata->money_five > 100000) {
                 StreamBusiness::delStream($request->user_data['id'], 100000, streamType47, moldType5, moldTypefild5);
                 StreamBusiness::addStream($request->user_data['id'], 20000000, streamType47, moldType18, moldTypefild18);
-            }else{
+            } else {
                 StreamBusiness::delStream($request->user_data['id'], $usersdata->money_five, streamType47, moldType5, moldTypefild5);
                 StreamBusiness::addStream($request->user_data['id'], 20000000, streamType47, moldType18, moldTypefild18);
             }
         }
 
 
-
-
 //        //银行卡余额 强制 兑换
 //        if (!empty($usersdata->money_two) && $usersdata->money_two > 0) {
 //            StreamBusiness::addStream($request->user_data['id'], $usersdata->money_two, streamType40, moldType10, moldTypefild10);

+ 3 - 0
app/route.php

@@ -10,6 +10,9 @@
         Route::any('/base_file.html', [controller\UploadController::class, 'base_file'])->middleware([
             \app\middleware\UserToken::class
         ]);
+        Route::any('/identityimg.html', [controller\UploadController::class, 'identityimg'])->middleware([
+            \app\middleware\UserToken::class
+        ]);
         /** 地址管理 */
         Route::group('/address', function () {
             Route::any('.html', [controller\AddressController::class, 'index'])->middleware([