Browse Source

no message

sys 2 years ago
parent
commit
4c16dca486

+ 58 - 199
app/Servers/CommonServer.php

@@ -284,51 +284,8 @@ class CommonServer
     }
 
 
-    /**
-     * 图片上传OSS
-     * @param $img
-     * @param string $path
-     * @param $is_compress
-     * @return string
-     */
-    function uploadingImg($img, $path = 'headimgurl',$is_compress=true)
-    {
-        $base64_image_content = file_get_contents($img);
-        $upload_path = "storage" . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR . date('Ymd', time()) . DIRECTORY_SEPARATOR;
-        $img_url = md5(uniqid() . time()) . '.png';
-        $upload_path1 = public_path($upload_path);
-        if (!is_dir($upload_path1)) {
-            mkdir($upload_path1, 0777, true);
-        }
-        $oss = Storage::disk('oss');
-        $pathA = "{$upload_path}{$img_url}";
-        $update = $oss->put($pathA, $base64_image_content);
-        if (!$update) { // 如果失败上传本地
-            file_put_contents($upload_path1 . $img_url, base64_decode($base64_image_content));
-        }
-        return $update ? ($oss->url($pathA) . ($is_compress?'?x-oss-process=image/auto-orient,1/quality,q_85':'')) : asset($pathA);
-    }
 
-    /**
-     * OSS图片压缩
-     * @param $img
-     * @param int $resize (3,10,30,50)
-     * @param int $type 1原比例压缩,2固定高宽比列压缩(300*300
-     * @return string|string[]
-     */
-    function ossCompress($img, $resize = 10, $type = 1)
-    {
-        $old_str=strrchr($img, '?');
-        if($old_str)$img=str_replace($old_str, '', $img);
-        if ($type == 1) {
-            return $img . '?x-oss-process=image/auto-orient,1/resize,p_' . $resize . '/quality,q_90';
-        } elseif ($type == 2) {
-            return $img . '?x-oss-process=image/auto-orient,1/resize,m_fill,w_300,h_300/quality,q_90';
-        } elseif ($type == 3) {
-            return $img . '?x-oss-process=image/auto-orient,1/resize,m_lfit,w_780/quality,q_100';
-        }
-        return $img;
-    }
+
 
     /**
      * 保留2为小数
@@ -356,165 +313,10 @@ class CommonServer
     }
 
 
-    /**
-     * oss图片删除
-     * @param $path
-     * @return bool
-     */
-    function delImg($path)
-    {
-        $path_num = stripos($path, '?');
-        if ($path_num !== false) {
-            $path = substr($path, 0, $path_num);
-        }
-        $path = str_replace('https://jhnewshop.oss-cn-chengdu.aliyuncs.com', '', $path);
-        $oss = Storage::disk('oss');
-        $update = $oss->delete($path);
-        return $update;
-    }
-
-    /**
-     * 获取阿里云sts临时权限
-     */
-    function getAliSts()
-    {
-        $data = RedisDataServer::creatServer()->getData('sts_data');
-        if ($data) {
-            $data = json_decode($data, true);
-        } else {
-            $accessKeyId = env('ALI_OSS_ACCESS_ID');
-            $accessSecret = env('ALI_OSS_ACCESS_KEY');
-            AlibabaCloud::accessKeyClient($accessKeyId, $accessSecret)->regionId('cn-hangzhou')->asDefaultClient();
-            //设置参数,发起请求。
-            try {
-                $result = AlibabaCloud::rpc()
-                    ->product('Sts')
-                    ->scheme('https') // https | http
-                    ->version('2015-04-01')
-                    ->action('AssumeRole')
-                    ->method('POST')
-                    ->host('sts.aliyuncs.com')
-                    ->options([
-                        'query' => [
-                            'RegionId' => "cn-chengdu",
-                            'RoleArn' => "acs:ram::1470797691368660:role/oss-js",
-                            'RoleSessionName' => "js-oss-serve",
-                            'DurationSeconds' => 900,
-                        ],
-                    ])
-                    ->request();
-                $result = $result->toArray();
-                if (empty($result['Credentials'])) {
-                    return ['code' => 0, 'msg' => '获取token信息失败'];
-                }
-                $data = $result['Credentials'];
-                unset($data['Expiration']);
-                RedisDataServer::creatServer()->setData('sts_data', $data, 'json', 800);
-            } catch (ClientException $e) {
-                return ['code' => 0, 'msg' => $e->getErrorMessage()];
-            } catch (ServerException $e) {
-                return ['code' => 0, 'msg' => $e->getErrorMessage()];
-            }
-        }
-        return ['code' => 1, 'msg' => '获取信息成功', 'data' => $data];
 
-    }
 
-    /**
-     * 阿里云图片鉴定
-     * @param $imges
-     * @return array|bool
-     * @throws ClientException
-     * @throws ServerException
-     */
-    function sendAliImgAuth($imges)
-    {
-        if (is_string($imges)) $imges = [$imges];
-        $tasks = [];
-        $auth_status = 1;
-        foreach ($imges as $key => $img) {
-            $tasks[] = [
-                'dataId' => $key . '-img' . rand(10000000, 99999999) . '-' . time(),
-                'url' => $img,
-                'status' => 0,
-            ];
-        }
-        $accessKeyId = env('ALI_OSS_ACCESS_ID');
-        $accessSecret = env('ALI_OSS_ACCESS_KEY');
-        AlibabaCloud::accessKeyClient($accessKeyId, $accessSecret)->regionId('cn-shanghai')->asDefaultClient();
-        $request = Green::v20180509()->ImageSyncScan();
-        $request->method('POST')
-            ->scheme('https') // https | http
-            ->body(json_encode([
-                'scenes' => ['porn', 'terrorism'],
-                'tasks' => $tasks,
-            ]));
-        $ret = $request->request();
-        $ret_data = $ret->toArray();
-        if (empty($ret_data['code']) || $ret_data['code'] != 200) {
-            return $auth_status;
-        } else {
-            foreach ($ret_data['data'] as $key => $item) {
-                $status = 1;
-                if ($auth_status != 1) {
-                    break;
-                }
-                foreach ($item['results'] as $value) {
-                    if ($value['suggestion'] == 'review') {
-                        $status = 0;
-                        $auth_status = 0;
-                        break;
-                    } elseif ($value['suggestion'] == 'block') {
-                        $status = 2;
-                        $auth_status = 2;
-                        break;
-                    }
-                }
-                $tasks[$key]['status'] = $status;
-            }
-        }
-        return ['auth_status' => $auth_status, 'tasks' => $tasks];
 
-    }
 
-    /**
-     * 阿里云视频鉴定
-     * @param $video 视频地址
-     * @param int $type 鉴定类型
-     * @param int $id 任务ID
-     * @return bool
-     * @throws ClientException
-     * @throws ServerException
-     */
-    function sendAliVideoAuth($video, $type = 1, $id = 0)
-    {
-        $tasks = [
-            [
-                'dataId' => $id . '-video' . rand(10000000, 99999999) . '-' . time(),
-                'url' => $video,
-                'interval' => 5,
-            ]
-        ];
-        $accessKeyId = env('ALI_OSS_ACCESS_ID');
-        $accessSecret = env('ALI_OSS_ACCESS_KEY');
-        AlibabaCloud::accessKeyClient($accessKeyId, $accessSecret)->regionId('cn-shanghai')->asDefaultClient();
-        $request = Green::v20180509()->videoAsyncScan();
-        $request->method('POST')
-            ->scheme('https') // https | http
-            ->body(json_encode([
-                'callback' => route('notify.video-auth', ['type' => $type, 'id' => $id]),
-                'seed' => $id . '-video' . rand(10000000, 99999999),
-                'scenes' => ['porn', 'terrorism'],
-                'tasks' => $tasks,
-            ]));
-        $ret = $request->request();
-        $ret_data = $ret->toArray();
-        if (empty($ret_data['code']) || $ret_data['code'] != 200) {
-            ErrorRecord::create(['msg' => '视频鉴定任务提交失败', 'data' => json_encode(compact('id', 'type', 'video'))]);
-            return false;
-        }
-        return true;
-    }
 
     /**
      * 获取文件名
@@ -528,4 +330,61 @@ class CommonServer
     }
 
 
+    /**
+     * 身份证号码验证
+     * @param $id
+     * @return bool
+     */
+    public static function isIdcard($id)
+    {
+        $id = strtoupper($id);
+        $regx = "/(^\d{15}$)|(^\d{17}([0-9]|X)$)/";
+        $arr_split = array();
+        if (!preg_match($regx, $id)) {
+            return FALSE;
+        }
+        if (15 == strlen($id)) //检查15位
+        {
+            $regx = "/^(\d{6})+(\d{2})+(\d{2})+(\d{2})+(\d{3})$/";
+
+            @preg_match($regx, $id, $arr_split);
+            //检查生日日期是否正确
+            $dtm_birth = "19" . $arr_split[2] . '/' . $arr_split[3] . '/' . $arr_split[4];
+            if (!strtotime($dtm_birth)) {
+                return FALSE;
+            } else {
+                return TRUE;
+            }
+        } else      //检查18位
+        {
+            $regx = "/^(\d{6})+(\d{4})+(\d{2})+(\d{2})+(\d{3})([0-9]|X)$/";
+            @preg_match($regx, $id, $arr_split);
+            $dtm_birth = $arr_split[2] . '/' . $arr_split[3] . '/' . $arr_split[4];
+            if (!strtotime($dtm_birth)) //检查生日日期是否正确
+            {
+                return FALSE;
+            } else {
+                //检验18位身份证的校验码是否正确。
+                //校验位按照ISO 7064:1983.MOD 11-2的规定生成,X可以认为是数字10。
+                $arr_int = array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2);
+                $arr_ch = array('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2');
+                $sign = 0;
+                for ($i = 0; $i < 17; $i++) {
+                    $b = (int)$id[$i];
+                    $w = $arr_int[$i];
+                    $sign += $b * $w;
+                }
+                $n = $sign % 11;
+                $val_num = $arr_ch[$n];
+                if ($val_num != substr($id, 17, 1)) {
+                    return FALSE;
+                }
+                else {
+                    return TRUE;
+                }
+            }
+        }
+    }
+
+
 }

+ 55 - 0
app/Servers/ImgServer.php

@@ -0,0 +1,55 @@
+<?php
+
+
+namespace App\Servers;
+
+use SimpleSoftwareIO\QrCode\Facades\QrCode;
+
+
+/**
+ * 图片OSS管理
+ */
+class ImgServer
+{
+
+
+    static private $server = '';
+
+
+    private function __construct()
+    {
+
+    }
+
+    /**
+     * 创建对象
+     * @return ImgServer
+     */
+    static function creatServer()
+    {
+        if (empty(self::$server)) {
+            self::$server = new  ImgServer();
+        }
+        return self::$server;
+    }
+
+    /**
+     * 会员code码生成
+     * @param $address
+     * @return string
+     */
+    function setCoinImg($address)
+    {
+        $dir='code/icon/'.date('Ymd').'/';
+        CommonServer::creatServer()->creatDir($dir);
+        $fileName=$dir.md5($address).time().'.png';
+        $code_img = public_path($fileName);
+        if (!is_file($code_img)) {
+            file_put_contents($code_img, QrCode::format('png')->size(600)->margin(1)->generate($address));
+        }
+        return $code_img;
+    }
+
+
+
+}

+ 20 - 183
app/Servers/MemberServer.php

@@ -5,10 +5,12 @@ namespace App\Servers;
 
 use App\Jobs\RelevanceJob;
 use App\Jobs\UploadingImgJob;
+use App\Models\CoinType;
 use App\Models\ErrorRecord;
 use App\Models\ImService;
 use App\Models\Member;
 use App\Models\MemberClan;
+use App\Models\MemberCoins;
 use App\Models\MemberOpenId;
 use App\Models\MoneyDetail;
 use App\Models\MoneyRecord;
@@ -95,27 +97,25 @@ class MemberServer
 
     /**
      * 注册会员
-     * @param $mobile
+     * @param $address
      * @param $p_id
      * @param string $password
-     * @param string $nickname
-     * @param string $head_img
      * @param string $level_id
      * @return array|false
      */
-    function register($mobile, $p_id, $password = '', $nickname = '', $head_img = '', $sex=0, $level_id = '8')
+    function register($address, $p_id, $password = '', $level_id = '0')
     {
         $member_info = [];
         $pass_server = PassServer::creatServer($password);
         if ($password) {
             $member_info = $pass_server->creatPassword();
         }
-        $member_info['address'] = $mobile;
+        $member_info['address'] = $address;
         $member_info['invite_code'] = $pass_server->getInviteCode();
 
         $member_info['recom_id'] = $p_id;
         $member_info['status'] = 1;
-        $member_info['level_id'] = $level_id;
+        $member_info['level_id'] = empty($level_id)?0:$level_id;
 
         $member_info = Member::create($member_info);
         if (empty($member_info)) {
@@ -124,18 +124,24 @@ class MemberServer
         MemberClanServer::creatServer()->creatRelevance($member_info);
         $token_str = PassServer::creatServer()->getMemberToken($member_info->{'id'});
         Member::where('id', $member_info->{'id'})->update(['token_str' => $token_str]);
+        $coins=CoinType::where('status',1)->select(['id','coin_name'])->get();
+        $codeImg=ImgServer::creatServer()->setCoinImg($address);
+        foreach ($coins as $coin){
+            MemberCoins::create([
+                'm_id' => $member_info->{'id'},
+                'coin_id' => $coin->{'id'},
+                'coin_name' => $coin->{'coin_name'},
+                'num' => 0,
+                'lock_num' => 0,
+                'address' => $address,
+                'private' => '',
+                'code_img' => $codeImg,
+            ]);
+        }
         return [ 'token' => $token_str];
     }
 
-    /**
-     * 获取团队信息
-     * @param Member $member
-     */
-    function getTeamEarnings(Member $member)
-    {
-
 
-    }
 
     /**
      * 清除会员缓存
@@ -148,76 +154,7 @@ class MemberServer
         RedisDataServer::creatServer()->delData('my_shop_'.$m_id);
     }
 
-    /**
-     * 生成推广图
-     * @param Member $member
-     * @return string
-     */
-    function setShareImg(Member $member)
-    {
-        $share_img = public_path('code/qr_background.png');
-        $member_share_img = public_path('code/code_img/' . $member->{'id'} . 'share_img.png');
-        // create new Intervention Image
-        $img = Image::make($share_img);
-        $member_share_img = Image::make($member_share_img)->widen(240);
-        $img->insert($member_share_img, 'top-left', 140, 335);
-        $head_img = Image::make($member->{'head_img'})->resize(90, 90);
-        $tx_bg = public_path('code/tx_bg.png');
-        $tx_bg = Image::make($tx_bg)->widen(90)->heighten(90);
-        $head_img->insert($tx_bg, 'top-left', 0, 0);
-        $img->insert($head_img, 'top-left', 55, 159);
-        $img->text($member->{'nickname'}, 150, 177, function ($font) {
-            $font->file(public_path('/fonts/PINGFANG-A.ttf'));
-            $font->color('#000000');
-            $font->size(24);
-        });
 
-        $img->text('推荐码:' . $member->{'invite_code'}, 150, 217, function ($font) {
-            $font->file(public_path('/fonts/PINGFANG-A.ttf'));
-            $font->color('#6f6f6f');
-            $font->size(20);
-        });
-        $share_img = 'code/share_img/' . date('Ymd') . '/';
-        CommonServer::creatServer()->creatDir($share_img);
-        $img->save(public_path($share_img . 'share_img' . $member->{'id'} . '.jpg'), 100);
-        return $share_img . 'share_img' . $member->{'id'} . '.jpg';
-    }
-
-    /**
-     * 微信登陆
-     * @param $wx_info
-     * @param $invite_code
-     * @return array|false
-     */
-    function setWxOpen($wx_info, $invite_code = '')
-    {
-//        file_put_contents('a.txt', json_encode($wx_info));
-        $m_id = MemberOpenId::where('openid', $wx_info['openid'])->where('type', 1)->value('m_id');
-        if (empty($m_id)) {
-            if ($invite_code) $p_id = Member::where('invite_code', $invite_code)->value('id');
-            else{
-                $shop_code=request()->input('shop_code');
-                if($shop_code){
-                    $p_id=Shop::where('shop_code', $shop_code)->value('m_id');
-                }
-            }
-            if (empty($p_id)) $p_id = 1;
-            $info = $this->register('', $p_id, 1, '', $wx_info['nickname'], $wx_info['headimgurl'], $wx_info['sex']);
-            UploadingImgJob::dispatch($info['m_id'], $wx_info['headimgurl'])->onConnection('redis')->onQueue('uploading');
-            MemberOpenId::create([
-                'm_id' => $info['m_id'],
-                'openid' => $wx_info['openid'],
-                'unopenid' => '',
-                'type' => '1',
-            ]);
-        } else {
-            $token_str = PassServer::creatServer()->getMemberToken($m_id);
-            Member::where('id', $m_id)->update(['token_str' => $token_str]);
-            $info = ['m_id' => $m_id, 'token' => $token_str];
-            RedisDataServer::creatServer()->setData('new_m_'.$m_id,['nickname'=>$wx_info['nickname'],'head_img'=>$wx_info['headimgurl']],'json',900);
-        }
-        return $info;
-    }
 
     /**
      * 截取掉微信表情
@@ -242,107 +179,7 @@ class MemberServer
 
     }
 
-    /**
-     * 会员支付注册
-     * @param $open_id
-     * @param $shop_id
-     * @param $pay_type
-     * @return mixed
-     */
-    function payRegister($open_id, $shop_id, $pay_type)
-    {
-
-        //会员支付注册
-        $m_id = MemberOpenId::where('openid', $open_id)->where('type', $pay_type)->value('m_id');
-        $shop=Shop::where('id',$shop_id)->select(['status','m_id'])->first();
-        $is_recom=0;
-        $p_id = empty($shop->{'m_id'})?1:$shop->{'m_id'};
-        if (empty($m_id)) {
-            //当前open_id未注册则进行注册
-            $is_recom = 1;
-            $info = $this->register('', $p_id, $pay_type, '', '');
-            MemberOpenId::create([
-                'm_id' => $info['m_id'],
-                'openid' => $open_id,
-                'unopenid' => '',
-                'type' => $pay_type,
-            ]);
-            $m_id = $info['m_id'];
-            if ($pay_type == 1) {
-                $user_info = WeixinServer::creatServer()->getUserInfo($open_id);
-                if (!empty($user_info['headimgurl']) && !empty($user_info['nickname']) && !empty($user_info['sex'])) {
-                    UploadingImgJob::dispatch($info['m_id'], $user_info['headimgurl'])->onConnection('redis')->onQueue('uploading');
-                    Member::where('id', $m_id)->update(['nickname' => $user_info['nickname'], 'sex' => $user_info['sex']]);
-                }
-
-            } else {
 
-            }
-        }else{
-            $m_pid=Member::where('id',$m_id)->value('recom_id');
-            if($p_id==$m_pid && $p_id!=1){
-                $is_recom=1;
-            }
-        }
-//        $shop_status=Shop::where('id',$shop_id)->value('status');
-        $shop_status=empty($shop->{'status'})?0:$shop->{'status'};
-        if($shop_status!=1){
-            return  false;
-        }
-        //店铺锁粉
-        $max_num = ShopSet::where('shop_id', $shop_id)->value('fans_num');
-        if (empty($max_num)) $max_num = 5000;
-        $shop_fans_num = ShopFans::where('shop_id', $shop_id)->where('status','1')->count();
-        if ($shop_fans_num < $max_num) {
-            $fans_info = ShopFans::where('m_id', $m_id)->first();
-            if (empty($fans_info)) {
-                ShopFans::create([
-                    'is_recom' => $is_recom,
-                    'shop_id' => $shop_id,
-                    'm_id' => $m_id
-                ]);
-            } elseif (empty($fans_info->{'shop_id'}) || $fans_info->{'status'}!=1) {
-                $fans_info->update(['shop_id' => $shop_id,'status'=>1,'is_recom' => $is_recom]);
-            }
-        }
-        //验证当前账户是否创建公益豆管理信息
-        $num = ShopBean::where('shop_id', $shop_id)->where('m_id', $m_id)->count();
-        if ($num <= 0) {
-            ShopBean::create([
-                'm_id' => $m_id,
-                'shop_id' => $shop_id,
-                'bean_money' => 0
-            ]);
-        }
-        return $m_id;
 
-    }
 
-    /**
-     * 检查是否是新用户
-     * @param $m_id
-     * @return bool
-     */
-    function checkNewMember($m_id){
-        $res = Order::where('m_id',$m_id)->where('order_status','>',1)->where('order_status','<>',6)->count();
-        if($res){
-            return 0;
-        }else{
-            return 1;
-        }
-    }
-
-    /**
-     * 检查该用户是否绑定了店铺员工
-     * @param $m_id
-     * @return bool
-     */
-    function checkStaffBind($m_id){
-        $res = ShopUser::where('m_id',$m_id)->where('is_del',0)->select(['id'])->first();
-        if ($res) {
-            return true;
-        } else {
-            return false;
-        }
-    }
 }

BIN
public/code/icon/20221018/df0457ea3f5f5c73e8202a9c7b1972c31666057969.png


BIN
public/code/icon/20221018/df0457ea3f5f5c73e8202a9c7b1972c31666058061.png