xxxrrrdddd 3 年之前
父节点
当前提交
5fd3ef4d70

+ 1 - 1
application/api/controller/Common.php

@@ -20,7 +20,7 @@ class Common extends Api
     protected $noNeedRight="*";
     /**
      * 获取各种协议
-     * @param int id 1入网许可协议2个人信息收集证明3查询订单说明4商务合作说明
+     * @param int id 1入网许可协议2个人信息收集证明3查询订单说明4商务合作说明5隐私权政策6法律责任风险提示告知书
      * @ApiReturnParams(name=title,type=string,description=标题)
      * @ApiReturnParams(name=content,type=string,description=内容)
      */

+ 0 - 93
application/common/model/Favourite.php

@@ -1,93 +0,0 @@
-<?php
-
-namespace app\common\model;
-
-use think\db\Query;
-use think\Model;
-
-/**
- */
-class Favourite Extends Model
-{
-
-    // 开启自动写入时间戳字段
-    protected $autoWriteTimestamp = true;
-    protected $createTime='created_at';
-    protected $updateTime=false;
-    protected $append=['fav'];
-
-    public function fav(){
-        return $this->morphTo('fav',[
-            'video'=>Video::class,
-        ]);
-    }
-    public function scopeUser(Query $query,User $user){
-        $query->where('user_id',$user['id']);
-    }
-    public function user(){
-        return $this->belongsTo(User::class);
-    }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-    protected static function init()
-    {
-        self::afterInsert(function (self $like){
-            if($like['fav'] instanceof Video){
-                $like['fav']->setInc('fav_num');
-                /*if($like->user_id!=$like->like->user_id) {
-                    Notification::create([
-                        'notice_type'=>'like',
-                        'notice_id'=>$like->id,
-                        'title'=>"{$like->user->nickname}点赞了您发布的资讯",
-                        'user_id'=>$like->like->user_id,
-                        'from_user_id'=>$like->user_id,
-                        'object'=>$like->like->toArray()
-                    ]);
-                }*/
-            }
-            redis()->hSet($like->key(),"{$like['fav_id']}_{$like['user_id']}",time());
-        });
-        self::afterDelete(function (self $like){
-            if($like['fav'] instanceof Video){
-                $like['fav']->setDec('fav_num');
-            }
-            redis()->hDel($like->key(),"{$like['fav_id']}_{$like['user_id']}");
-        });
-    }
-
-    protected function key(){
-        return "favourite:{$this['fav_type']}";
-    }
-}

+ 0 - 76
application/common/model/Guest.php

@@ -1,76 +0,0 @@
-<?php
-
-namespace app\common\model;
-
-use think\db\Query;
-use think\Model;
-use think\model\Collection;
-use think\model\relation\BelongsToMany;
-
-/**
- * Class Guest
- * @property Collection|Video[] video
- * @method Query|static guest($id)
- * @package app\common\model
- */
-class Guest extends Model
-{
-    protected $hidden=[
-        'pivot',
-        'name',
-        'logo',
-    ];
-    protected $append=[
-        'nickname',
-        'avatar',
-        'has_follow',
-    ];
-    public function video(){
-        return $this->hasMany(Video::class);
-    }
-    public function scopeGuest(Query $query,$id){
-        return $query->where("{$this->getTable()}.id",$id);
-    }
-    /**
-     * 关注我的人
-     *@return User|BelongsToMany
-     */
-    public function follower(){
-        return $this->belongsToMany(User::class,'user_follow');
-    }
-
-
-
-
-
-
-
-
-
-    protected static function init()
-    {
-        self::afterDelete(function (self $guest){
-            foreach ($guest->video as $video){
-                $video->delete();
-            }
-            UserFollow::where('guest_id',$guest['id'])->delete();
-        });
-    }
-    protected function getNicknameAttr($a,$b){
-        return $b['name'];
-    }
-    protected function getAvatarAttr($a,$b){
-        return $b['logo'];
-    }
-    public function getHasFollowAttr($a,$b){
-        $user=request()->_user;
-        if(!$user){
-            return false;
-        }
-        static $follow=[];
-        if(!isset($follow[$b['id']])){
-            $follow[$b['id']]=(bool)UserFollow::where('user_id',$user['id'])->where('guest_id',$b['id'])->value('id');
-        }
-        return $follow[$b['id']];
-    }
-}

+ 0 - 93
application/common/model/Like.php

@@ -1,93 +0,0 @@
-<?php
-
-namespace app\common\model;
-
-use think\db\Query;
-use think\Model;
-
-/**
- */
-class Like Extends Model
-{
-
-    // 开启自动写入时间戳字段
-    protected $autoWriteTimestamp = true;
-    protected $createTime='created_at';
-    protected $updateTime=false;
-    protected $append=['like'];
-
-    public function like(){
-        return $this->morphTo('like',[
-            'video'=>Video::class,
-        ]);
-    }
-    public function scopeUser(Query $query,User $user){
-        $query->where('user_id',$user['id']);
-    }
-    public function user(){
-        return $this->belongsTo(User::class);
-    }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-    protected static function init()
-    {
-        self::afterInsert(function (self $like){
-            if($like->like instanceof Video){
-                $like->like->setInc('like_num');
-                /*if($like->user_id!=$like->like->user_id) {
-                    Notification::create([
-                        'notice_type'=>'like',
-                        'notice_id'=>$like->id,
-                        'title'=>"{$like->user->nickname}点赞了您发布的资讯",
-                        'user_id'=>$like->like->user_id,
-                        'from_user_id'=>$like->user_id,
-                        'object'=>$like->like->toArray()
-                    ]);
-                }*/
-            }
-            redis()->hSet($like->key(),"{$like['like_id']}_{$like['user_id']}",time());
-        });
-        self::afterDelete(function (self $like){
-            if($like->like instanceof Video){
-                $like->like->setDec('like_num');
-            }
-            redis()->hDel($like->key(),"{$like['like_id']}_{$like['user_id']}");
-        });
-    }
-
-    protected function key(){
-        return "like:{$this['like_type']}";
-    }
-}

+ 0 - 47
application/common/model/MallGoods.php

@@ -1,47 +0,0 @@
-<?php
-
-namespace app\common\model;
-
-use think\db\Query;
-use think\Model;
-use traits\model\SoftDelete;
-
-/**
- *@method static Query|self show()
- */
-class MallGoods extends Model
-{
-    use SoftDelete;
-
-    protected $hidden=[
-        'content'
-    ];
-    
-    // 自动写入时间戳字段
-    protected $autoWriteTimestamp = true;
-
-    // 定义时间戳字段名
-    protected $createTime = 'created_at';
-    protected $updateTime = 'updated_at';
-    protected $deleteTime = 'deleted_at';
-
-    public function orders(){
-        return $this->hasMany(MallOrder::class,'good_id');
-    }
-
-
-
-
-
-
-
-
-
-    /**  */
-    public function scopeShow(Query $query){
-        $query->where('is_down',0);
-    }
-    public function getImageAttr($a){
-        return array_filter(explode(',',$a))?:[];
-    }
-}

+ 0 - 66
application/common/model/MallOrder.php

@@ -1,66 +0,0 @@
-<?php
-
-namespace app\common\model;
-
-use think\Model;
-
-/**
- *@property User user
- *@property MallGoods goods
- */
-class MallOrder extends Model
-{
-    protected $type=[
-        'addr'=>'json',
-    ];
-    // 自动写入时间戳字段
-    protected $autoWriteTimestamp = true;
-
-    // 定义时间戳字段名
-    protected $createTime = TIME_C;
-    protected $updateTime = TIME_U;
-
-    const STATUS_WAIT_SEND=0;
-    const STATUS_WAIT_GET=1;
-    public static $statusList=[
-        self::STATUS_WAIT_SEND=>'待发货',
-        self::STATUS_WAIT_GET=>'待收货',
-    ];
-
-    public function goods(){
-        return $this->belongsTo(MallGoods::class,'good_id')->removeOption('soft_delete');
-    }
-    public function user(){
-        return $this->belongsTo(User::class);
-    }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-    protected static function init()
-    {
-        self::beforeInsert(function (self $order){
-            $order['no']=order_no();
-        });
-        self::afterInsert(function (self $order){
-            $order->goods()->setInc('sell_count',$order['num']);
-        });
-        self::beforeUpdate(function (self $order){
-            $data=$order->getChangedData();
-            if(isset($data['send_com']) && !empty($data['send_com']) && $order['status']==self::STATUS_WAIT_SEND){
-                $order['status']=self::STATUS_WAIT_GET;
-            }
-        });
-    }
-}

+ 46 - 0
application/common/model/Mobile.php

@@ -0,0 +1,46 @@
+<?php
+
+namespace app\common\model;
+
+use think\Model;
+
+/**
+ * 配置模型
+ */
+class Mobile extends Model
+{
+    public function info(){
+        return $this->hasOne(MobileInfo::class);
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+    public static function init()
+    {
+        self::beforeWrite(function (self $mobile){
+            $mobile['amount']=$mobile['amount_base']+$mobile['amount_charge'];
+        });
+    }
+}

+ 15 - 0
application/common/model/MobileInfo.php

@@ -0,0 +1,15 @@
+<?php
+
+namespace app\common\model;
+
+use think\Model;
+
+/**
+ * 配置模型
+ */
+class MobileInfo extends Model
+{
+    public function mobile(){
+        return $this->belongsTo(Mobile::class);
+    }
+}

+ 0 - 36
application/common/model/Notification.php

@@ -1,36 +0,0 @@
-<?php
-
-namespace app\common\model;
-
-use think\Model;
-
-/**
- * 短信验证码
- */
-class Notification Extends Model
-{
-
-    // 开启自动写入时间戳字段
-    protected $autoWriteTimestamp = true;
-    // 定义时间戳字段名
-    protected $createTime = 'created_at';
-    protected $updateTime = false;
-    // 追加属性
-    protected $append = [
-    ];
-    protected $type=[
-        'data'=>'json',
-    ];
-
-    const TYPE_VIDEO='video';
-
-    public static function multi($data){
-        return (new static)->saveAll($data);
-    }
-
-    /** relation */
-    public function user(){
-        return $this->belongsTo(User::class);
-    }
-    /** attr */
-}

+ 0 - 32
application/common/model/Search.php

@@ -1,32 +0,0 @@
-<?php
-
-namespace app\common\model;
-
-use think\Model;
-
-
-class Search extends Model
-{
-    // 自动写入时间戳字段
-    protected $autoWriteTimestamp = true;
-
-    // 定义时间戳字段名
-    protected $createTime = 'created_at';
-    protected $updateTime = false;
-
-    // 追加属性
-    protected $append = [
-    ];
-    protected static function init()
-    {
-        self::beforeWrite(function (self $search){
-            $query=self::where('name',$search['name']);
-            if(isset($search['id'])){
-                $query->where('id','<>',$search['id']);
-            }
-            if(($query->find())){
-                throw_user('搜索词已存在');
-            }
-        });
-    }
-}

+ 0 - 19
application/common/model/UserArea.php

@@ -1,19 +0,0 @@
-<?php
-
-namespace app\common\model;
-
-use think\Model;
-
-/**
- * 会员模型
- */
-class UserArea extends Model
-{
-    public static function hasArea($area_id,$user_id=null){
-        $q=self::where('area_id',$area_id);
-        if($user_id){
-            $q->where('user_id','<>',$user_id);
-        }
-        return $q->find();
-    }
-}

+ 0 - 20
application/common/model/UserCorrectRate.php

@@ -1,20 +0,0 @@
-<?php
-
-namespace app\common\model;
-
-use think\db\Query;
-use think\Model;
-
-/**
- * 会员模型
- * @property
- */
-class UserCorrectRate extends Model
-{
-    public function user(){
-        return $this->belongsTo(User::class);
-    }
-    protected static function init()
-    {
-    }
-}

+ 0 - 16
application/common/model/UserFollow.php

@@ -1,16 +0,0 @@
-<?php
-
-namespace app\common\model;
-
-use think\db\Query;
-use think\Model;
-
-/**
- * 短信验证码
- * @method Query|static follow($id)
- */
-class UserFollow Extends Model
-{
-    // 开启自动写入时间戳字段
-    protected $autoWriteTimestamp = false;
-}

+ 0 - 55
application/common/model/UserQuestion.php

@@ -1,55 +0,0 @@
-<?php
-
-namespace app\common\model;
-
-use think\Model;
-
-
-class UserQuestion extends Model
-{
-    protected $autoWriteTimestamp=true;
-    protected $createTime='created_at';
-    protected $updateTime=false;
-    protected $type=[
-        'key_desc'=>'json',
-    ];
-
-    public function isRight($key){
-        if($this['type']=='decide') {
-            return $this['key'] == $key;
-        }elseif ($this['type']=='choose'){
-            return empty(array_diff($this['key'],$key));
-        }elseif ($this['type']=='wenda'){
-            return true;
-        }
-        return false;
-    }
-
-
-
-    protected static function init()
-    {
-        self::beforeInsert(function (self $point){
-            if(is_array($point['key']) && count($point['key'])===1){
-                $point['is_single']=1;
-            }
-        });
-    }
-    public function getKeyAttr($data){
-        $type=$this['type'];
-        if(in_array($type,['choose'])){
-            return array_filter(explode(',',$data));
-        }
-        return $data;
-    }
-    public function setItemsAttr($value){
-        if(!$value){
-            return null;
-        }
-
-        return json_encode($value,JSON_UNESCAPED_UNICODE);
-    }
-    public function getItemsAttr($value){
-        return json_decode($value,true);
-    }
-}

+ 0 - 53
application/common/model/UserRights.php

@@ -1,53 +0,0 @@
-<?php
-
-namespace app\common\model;
-
-use think\Db;
-use think\db\Query;
-use think\Model;
-
-/**
- * 会员模型
- */
-class UserRights extends Model
-{
-    protected $append=[];
-    protected $hidden=[
-    ];
-    public function getLevelsAttr($v,$data): string
-    {
-        $levels=explode(',',$data['levels']);
-        $names=[];
-        foreach ($levels as $level){
-            $names[]=User::$levels[$level];
-        }
-        return implode(',',$names);
-    }
-    public function setLevelsAttr($v,$data): string
-    {
-        return implode(',',$data['levels']);
-    }
-    public function getLevelsOldAttr($v,$data)
-    {
-        $level=$this->origin['levels'];
-        return explode(',',$level);
-    }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-    public function scopeLevel(Query $query,$level){
-        $query
-            ->whereRaw("FIND_IN_SET($level,levels)");
-    }
-}

+ 0 - 27
application/common/model/UserRule.php

@@ -1,27 +0,0 @@
-<?php
-
-namespace app\common\model;
-
-use think\Model;
-
-class UserRule extends Model
-{
-
-    // 表名
-    protected $name = 'user_rule';
-    // 自动写入时间戳字段
-    protected $autoWriteTimestamp = 'int';
-    // 定义时间戳字段名
-    protected $createTime = 'createtime';
-    protected $updateTime = 'updatetime';
-    // 追加属性
-    protected $append = [
-    ];
-
-    public function getNameAttr($v){
-        if(strpos($v,'/')===0){
-            return substr($v,1);
-        }
-        return $v;
-    }
-}

+ 0 - 16
application/common/model/UserSend.php

@@ -1,16 +0,0 @@
-<?php
-
-namespace app\common\model;
-
-use think\Db;
-use think\Model;
-
-/**
- * 会员模型
- */
-class UserSend extends Model
-{
-    public function user(){
-        return $this->belongsTo(User::class);
-    }
-}

+ 0 - 36
application/common/model/UserSign.php

@@ -1,36 +0,0 @@
-<?php
-
-namespace app\common\model;
-
-use think\Model;
-
-/**
- * 短信验证码
- * @method
- */
-class UserSign Extends Model
-{
-    // 开启自动写入时间戳字段
-    protected $autoWriteTimestamp = true;
-    protected $createTime='created_at';
-    protected $updateTime=false;
-
-    public function user(){
-        return $this->belongsTo(User::class);
-    }
-
-    protected static function init()
-    {
-        self::beforeInsert(function (self $sign){
-            $prevSign=self::where('date','<',$sign['date'])->order('id','desc')->find();
-            if(!$prevSign){
-                $sign['row']=1;
-            }
-            if($prevSign['date']==date('Y-m-d',strtotime('-1day',strtotime($sign['date'])))){
-                $sign['row']=$prevSign['row']+1;
-            }else{
-                $sign['row']=1;
-            }
-        });
-    }
-}

+ 0 - 147
application/common/model/Video.php

@@ -1,147 +0,0 @@
-<?php
-
-namespace app\common\model;
-
-use think\Db;
-use think\db\Query;
-use think\Model;
-use think\model\relation\MorphMany;
-
-/**
- * @method static Query|self user(User $user)
- * @method Query|self open(User $user)
- * @property \think\model\Collection comments
- */
-class Video extends Model
-{
-    protected $autoWriteTimestamp=true;
-    protected $createTime='created_at';
-    protected $updateTime=false;
-    protected $append=[
-        'liked',
-        'favourited',
-    ];
-
-    public function tag(){
-        return $this->belongsToMany(Tag::class,'video_tag');
-    }
-    public function guest(){
-        return $this->belongsTo(Guest::class);
-    }
-    public function point(){
-        return $this->hasMany(VideoPoint::class);
-    }
-    public function viewUser(){
-        return $this->belongsToMany(User::class,'video_user_view');
-    }
-    public function scopeUser(Query $query,User $user){
-        if(!$user->level){
-            $query->where('is_open',1);
-        }
-    }
-    /**
-     *@return MorphMany|Like
-     */
-    public function like(){
-        return $this->morphMany(Like::class,'like','video');
-    }
-    /**
-     *@return MorphMany|Favourite
-     */
-    public function favourite(){
-        return $this->morphMany(Favourite::class,'fav','video');
-    }
-    /**
-     *@return MorphMany|Comment
-     */
-    public function comments(){
-        return $this->morphMany(Comment::class,'commentable','video');
-    }
-
-
-
-
-
-
-
-    protected static function init()
-    {
-        self::afterDelete(function (self $video){
-            VideoTag::video($video['id'])->delete();
-            $video->viewUser()->sync([]);
-            VideoUserLog::where('video_id',$video['id'])->delete();
-            $pointIds=$video->point()->column('id');
-            $video->point()->delete();
-            VideoPointUser::whereIn('video_point_id',$pointIds)->delete();
-            $video->favourite()->delete();
-            $video->like()->delete();
-            $list=redis()->hGetAll($hashKey='favourite:video');
-            if($list){
-                foreach ($list as $key=>$__){
-                    list($videoId,$_)=explode('_',$key);
-                    if($videoId==$video['id']){
-                        redis()->hDel($hashKey,$key);
-                    }
-                }
-            }
-            $list=redis()->hGetAll($hashKey='like:video');
-            if($list){
-                foreach ($list as $key=>$__){
-                    list($videoId,$_)=explode('_',$key);
-                    if($videoId==$video['id']){
-                        redis()->hDel($hashKey,$key);
-                    }
-                }
-            }
-            $video->comments()->delete();
-            VideoUserView::where('video_id',$video['id'])->delete();
-        });
-        self::afterInsert(function (self $video){
-            #发送消息
-            $user_id=$video->guest_id;
-            $videoOwner=Guest::find($user_id);
-            $users=UserFollow::where('guest_id',$user_id)->column('user_id');
-            $notifications=[];
-            foreach ($users as $user){
-                $_temp=[
-                    'user_id'=>$user,
-                    'title'=>sprintf("您关注的%s发布了新的动态",$videoOwner['name']),
-                    'type'=>Notification::TYPE_VIDEO,
-                    'data'=>[
-                        'id'=>$video['id'],
-                    ],
-                    'created_at'=>time(),
-                ];
-                $notifications[]=$_temp;
-            }
-            if($notifications){
-                Notification::multi($notifications);
-            }
-        });
-    }
-    /**
-     *是否已喜欢
-     */
-    public function getLikedAttr($v,$data){
-        $user=request()->_user;
-        if(!$user){
-            return false;
-        }
-        return redis()->hExists('like:video',"{$this['id']}_{$user['id']}");
-    }
-    /**
-     *是否已收藏
-     */
-    public function getFavouritedAttr($v,$data){
-        $user=request()->_user;
-        if(!$user){
-            return false;
-        }
-        return redis()->hExists('favourite:video',"{$this['id']}_{$user['id']}");
-    }
-    public function scopeOpen(Query $query,User $user){
-        if(!$user->level){
-            $query->where('a.is_open',1);
-        }
-    }
-}

+ 0 - 104
application/common/model/VideoPoint.php

@@ -1,104 +0,0 @@
-<?php
-
-namespace app\common\model;
-
-use think\Model;
-use think\model\relation\HasMany;
-
-/**
- */
-class VideoPoint extends Model
-{
-    protected $hidden=[
-        //'key',
-    ];
-    protected $type=[
-    ];
-    public function video(){
-        return $this->belongsTo(Video::class);
-    }
-    /**
-     *@return VideoPointUser|HasMany
-     */
-    public function user(){
-        return $this->hasMany(VideoPointUser::class);
-    }
-    public function setItemsAttr($value){
-        if(!$value){
-            return null;
-        }
-        return json_encode($value,JSON_UNESCAPED_UNICODE);
-    }
-    public function getItemsAttr($value){
-        return json_decode($value,true);
-    }
-    public function checkResult($data){
-        $items=$this['items'];
-        if($this['type']=='vote'){
-            if(!is_array($data)){
-                throw_user('答案必须是数组');
-            }
-            if(array_diff($data,array_keys($items))){
-                throw_user('投票结果有误');
-            }
-            return $data;
-        }elseif ($this['type']=='choose'){
-            if(!is_array($data)){
-                throw_user('答案必须是数组');
-            }
-            if(array_diff($data,array_keys($items))){
-                throw_user('选择结果有误');
-            }
-            return $data;
-        }elseif ($this['type']=='decide'){
-            return $data;
-        }elseif ($this['type']=='wenda'){
-            if(mb_strlen($data)>250){
-                throw_user('回答不能超过250字符');
-            }
-            return $data;
-        }
-        return false;
-    }
-    public function isRight($data){
-        if($this['type']=='choose'){
-            return array_diff($this['key'],$data)?0:1;
-        }elseif ($this['type']=='decide'){
-            return $this['key']==$data?1:0;
-        }
-        return 1;
-    }
-
-
-
-
-
-
-
-
-
-    protected static function init()
-    {
-        self::beforeInsert(function (self $point){
-            if(in_array($point['type'],['choose']) && count($point['key'])==1){
-                $point['is_single']=1;
-            }
-            if($point['type']=='decide'){
-                $point['is_single']=1;
-            }
-            if(empty($point['item_type'])){
-                $point['item_type']='txt';
-            }
-        });
-        self::afterDelete(function (self $videoPoint){
-            $videoPoint->user()->delete();
-        });
-    }
-    public function getKeyAttr($data){
-        $type=$this['type'];
-        if(in_array($type,['choose'])){
-            return array_filter(explode(',',$data));
-        }
-        return $data;
-    }
-}

+ 0 - 183
application/common/model/VideoPointUser.php

@@ -1,183 +0,0 @@
-<?php
-
-namespace app\common\model;
-
-use think\db\Query;
-use think\Model;
-
-/**
- * @method Model|static getByVideoPointId($id)
- * @method Query|self onlyUser(User $user)
- * @method Query|self check()
- * @method Query|self first($alias=null)
- * @method Query|self day(array $day)
- * @method Query|self sex($sex='')
- * @method Query|self isFirst($pointId)
- * @method Query|self filterUserAge($age_start,$age_end)
- * @method Query|self filterUserArea($province=null,$city=null)
- * @property  User user
- * @property  VideoPoint point
- */
-class VideoPointUser extends Model
-{
-    protected $autoWriteTimestamp=true;
-    protected $createTime='created_at';
-    protected $updateTime=false;
-    protected $hidden=[
-    ];
-    public function point(){
-        return $this->belongsTo(VideoPoint::class);
-    }
-    public function user(){
-        return $this->belongsTo(User::class);
-    }
-    public function setKeyAttr($data){
-        if(is_array($data)){
-            sort($data);
-            return implode(',',$data);
-        }
-        return $data;
-    }
-    public function getKeyAttr($data){
-        $type=$this['point']['type'];
-        if(in_array($type,['choose','vote'])){
-            return array_filter(explode(',',$data));
-        }
-        /*if($type=='decide'){
-            return $data=='true';
-        }*/
-        return $data;
-    }
-
-
-
-
-
-
-
-    protected static function init()
-    {
-        self::afterInsert(function (self $pointUser){
-            #增加答题总数目
-            $user=$pointUser->user;
-            $point=$pointUser->point;
-            $type=$point['type'];
-            if(in_array($type,['choose','decide'])){
-                #用户正确率
-                $userinfo=$user->userinfo()->lock(true)->find();
-                $userinfo['hd_num']=$userinfo['hd_num']+1;
-                if($pointUser['is_right']){
-                    $userinfo['hd_right_num']=$userinfo['hd_right_num']+1;
-                }else{
-                    $userinfo['hd_wrong_num']=$userinfo['hd_wrong_num']+1;
-                }
-                $userinfo['right_per']=bcmul(bcdiv($userinfo['hd_right_num'],$userinfo['hd_num'],2),100,2);
-                $userinfo['wrong_per']=bcmul(bcdiv($userinfo['hd_wrong_num'],$userinfo['hd_num'],2),100,2);
-                $userinfo->save();
-
-                /*$rate=new UserCorrectRate();
-                $rate->replace();
-                $rate->save([
-                    'user_id'=>$user->id,
-                    'day'=>strtotime(date('Y-m-d 00:00:00')),
-                    'right_per'=>$userinfo['right_per'],
-                ]);*/
-               /* $time=strtotime(date('Y-m-d 00:00:00'));
-                $newRate=$user->crate()->where($time)->find();
-                if(!$newRate){
-                    $newRate=new UserCorrectRate();
-                    $newRate->save([
-                        'user_id'=>$user->id,
-                        'day'=>$time,
-                        'right_per'=>$userinfo['right_per'],
-                        'hd_num'=>1,
-                        'hd_right_num'=>$pointUser['is_right']?1:0,
-                    ]);
-                }else{
-                    $newRate['hd_num']=$newRate['hd_num']+1;
-                    $newRate['hd_right_num']=$newRate['hd_right_num']+($pointUser['is_right']?1:0);
-                }
-
-                $newRate['right_per']=bcmul(bcdiv($newRate['hd_right_num'],$newRate['hd_num'],2),100,2);*/
-                #沿用上一次的正确率
-                $time=strtotime(date('Y-m-d 00:00:00'));
-                $newRate=$user->crate()->where($time)->find();
-                if(!$newRate){
-                    $newRate=new UserCorrectRate();
-                    $newRate->save([
-                        'user_id'=>$user->id,
-                        'day'=>$time,
-                        'right_per'=>$userinfo['right_per'],
-                        'hd_num'=>1,
-                        'hd_right_num'=>$pointUser['is_right']?1:0,
-                    ]);
-                }else{
-                    $newRate['hd_num']=$newRate['hd_num']+1;
-                    $newRate['hd_right_num']=$newRate['hd_right_num']+($pointUser['is_right']?1:0);
-                    $newRate['right_per']=$userinfo['right_per'];
-                }
-
-                $newRate->save();
-            }
-            #总耗时
-            $point['total_time']=$point['total_time']+$pointUser['time'];
-            #平均耗时
-            $point['ave_time']=$point->user()->avg('time');
-            $point->save();
-        });
-        self::beforeInsert(function (self $pointUser){
-            $pointUser['day']=strtotime(date('Y-m-d'));
-            $pointUser['month']=strtotime(date('Y-m-01'));
-            $pointUser['year']=strtotime(date('Y-01-01'));
-        });
-    }
-    public function scopeOnlyUser(Query $query,User $user){
-        $day=strtotime(date('Y-m-d 00:00:00'));
-        $query->where('user_id',$user->id)->where('day','>=',$day);
-    }
-    /** 检查需要判断的因素 */
-    public function scopeCheck(Query $query){
-        $day=strtotime(date('Y-m-d 00:00:00'));
-        $query->where('day',$day);
-    }
-    /** 是不是第一次答题 */
-    public function scopeIsFirst(Query $query,$pointId){
-        $query->first()->where('video_point_id',$pointId);
-    }
-    /** 第一次 */
-    public function scopeFirst(Query $query,$alias=null){
-        $table=$this->getTable();
-        if($alias){
-            $table=$alias;
-        }
-        $query->where("{$table}.is_first",1);
-    }
-    /** day */
-    public function scopeDay(Query $query,$day){
-        $query->whereBetween('day',$day);
-    }
-    #根据性别筛选
-    public function scopeSex(Query $query,$sex){
-        if(!$sex){
-            return;
-        }
-        $query->whereExists("select * from user where gender={$sex} and user.id=video_point_user.user_id");
-    }
-    #年龄筛选
-    public function scopeFilterUserAge(Query $query,$age_start,$age_end){
-        if(!is_null($age_start) && $age_start!==''){
-            $query->whereExists("select * from user where age>={$age_start} and user.id=video_point_user.user_id");
-        }
-        if(!is_null($age_end) && $age_end!==''){
-            $query->whereExists("select * from user where age<={$age_end} and user.id=video_point_user.user_id");
-        }
-    }
-    public function scopeFilterUserArea(Query $query,$province=null,$city=null){
-        if($city){
-            $query->whereExists("select id from user where id=video_point_user.user_id and user.city_id={$city}");
-        }
-        elseif($province){
-            $query->whereExists("select id from user where id=video_point_user.user_id and user.province_id={$province}");
-        }
-    }
-}

+ 0 - 17
application/common/model/VideoTag.php

@@ -1,17 +0,0 @@
-<?php
-
-namespace app\common\model;
-
-use think\Model;
-
-/**
- */
-class VideoTag extends Model
-{
-    public static function video($id){
-        return self::where('video_id',$id);
-    }
-    public static function tag($id){
-        return self::where('tag_id',$id);
-    }
-}

+ 0 - 27
application/common/model/VideoUserLog.php

@@ -1,27 +0,0 @@
-<?php
-
-namespace app\common\model;
-
-use think\db\Query;
-use think\Model;
-
-/**
- * @method static Query|self exists(User $user,$video,$type)
- */
-class VideoUserLog extends Model
-{
-    protected $autoWriteTimestamp=true;
-    protected $createTime='created_at';
-    protected $updateTime=false;
-    public function video(){
-        return $this->belongsTo(Video::class);
-    }
-    public function user(){
-        return $this->belongsTo(User::class);
-    }
-    public function scopeExists(Query $query,User $user,$video,$type){
-        $query->where('user_id',$user['id'])
-            ->where('video_id',$video)
-            ->where('type',$type);
-    }
-}

+ 0 - 11
application/common/model/VideoUserView.php

@@ -1,11 +0,0 @@
-<?php
-
-namespace app\common\model;
-
-use think\Model;
-
-/**
- */
-class VideoUserView extends Model
-{
-}

+ 3 - 3
public/api.html

@@ -755,7 +755,7 @@
                                                         <td>id</td>
                                                         <td>int</td>
                                                         <td>是</td>
-                                                        <td>1入网许可协议2个人信息收集证明3查询订单说明4商务合作说明</td>
+                                                        <td>1入网许可协议2个人信息收集证明3查询订单说明4商务合作说明5隐私权政策6法律责任风险提示告知书</td>
                                                     </tr>
                                                                                                     </tbody>
                                             </table>
@@ -781,7 +781,7 @@
                                                     <form enctype="application/x-www-form-urlencoded" role="form" action="/api/common/agreement" method="get" name="form2" id="form2">
                                                                                                                 <div class="form-group">
                                                             <label class="control-label" for="id">id</label>
-                                                            <input type="int" class="form-control input-sm" id="id" required placeholder="1入网许可协议2个人信息收集证明3查询订单说明4商务合作说明" name="id">
+                                                            <input type="int" class="form-control input-sm" id="id" required placeholder="1入网许可协议2个人信息收集证明3查询订单说明4商务合作说明5隐私权政策6法律责任风险提示告知书" name="id">
                                                         </div>
                                                                                                                 <div class="form-group form-group-submit">
                                                             <button type="submit" class="btn btn-success send" rel="2">提交</button>
@@ -7597,7 +7597,7 @@
 
                 </div>
                 <div class="col-md-6" align="right">
-                    Generated on 2022-03-28 16:29:58 <a href="./" target="_blank">靓号</a>
+                    Generated on 2022-03-29 09:49:38 <a href="./" target="_blank">靓号</a>
                 </div>
             </div>