zhaojs
2023-08-22 c5855f5eb22d2dd1d30d32d1d4f06a566b532a98
application/api/controller/Activity.php
@@ -6,11 +6,14 @@
use app\api\logic\taoke\device\Haodanku;
use app\common\model\FqbCate;
use app\api\logic\taoke\device\Jd as LogicJd;
use app\api\logic\Banner as LogicBanner;
use app\api\logic\ActivityInfo as ActInfo;
header("Access-Control-Allow-Origin:*");
class Activity extends Api
{
    protected $noNeedLogin = ['fqb_plat_cate'];
    protected $noNeedLogin = ['UpWxImg','recordItemClick','fqb_plat_cate','run_countRecruitAct','test'];
    protected $noNeedRight = '*';
    /**
     * 获取疯抢榜
@@ -173,4 +176,163 @@
        $this->success('获取成功',$list);
    }
    /**
     * 获取活动信息
     *
     */
    public function getActInfo()
    {
        $actid=request()->param('actid');
        if(empty($actid)) $this->error('参数错误');
        $actInfo=new ActInfo();
        $user = $this->auth->getUser();
        $res=$actInfo->getActInfo($actid,$user->id);
        $this->success('获取成功',$res);
    }
    /**
     * 参加活动
     */
    public function attendAct()
    {
        $actid=request()->param('actid');
        if(empty($actid)) $this->error('参数错误');
        $actInfo=new ActInfo();
        $user = $this->auth->getUser();
        $res=$actInfo->attendAct($actid,$user->id);
        $res?$this->success('成功',$res):  $this->error('活动异常');;
    }
    /**
     * 获取活动已邀请人数
     *
     */
    public function getActRecruitCount()
    {
        $actid=request()->param('actid');
        if(empty($actid)) $this->error('参数错误');
        $actInfo=new ActInfo();
        $user = $this->auth->getUser();
        $res=$actInfo->getActRecruitCount($actid,$user->id);
        $this->success('获取成功',$res);
    }
    /**
     * 获取排名
     */
    public function getRankingList()
    {
        $actid=request()->param('actid');
        if(empty($actid)) $this->error('参数错误');
        $actInfo=new ActInfo();
        $user = $this->auth->getUser();
        $res=$actInfo->getRankingList($actid,$user->id);
        $this->success('获取成功',$res);
    }
    public function test()
    {
        $actInfo=new ActInfo();
        $res=$actInfo->updateRecruitCount(2);
    }
    /**
     * 招募活动计算
     */
    public function run_countRecruitAct()
    {
        $actInfo=new ActInfo();
        $res=$actInfo->run_countRecruitAct();
        $this->success('执行完成',$res);
    }
    /**
     * 获取邀请码
     */
    public function getInviteUrl()
    {
        $user = $this->auth->getUser();
        $this->success('获取成功',$user->invitation_code);
    }
    /**
     * 获取自定义弹窗
     *
     */
    public function getCustomizePopup()
    {
        $LogicBanner = new LogicBanner();
        $list = $LogicBanner->getList('20,21');
        if(!$list||$list['customizePop']==null||count($list['customizePop'])==0)
        {
            $this->success('获取成功',[]);
        }
        $user = $this->auth->getUser();
        $actInfo=new ActInfo();
        foreach ($list['customizePop'] as $vaule) {
            $paraJson=json_decode($vaule->note);
            $isPop=false;
            switch($paraJson->poptype)
            {
                case 'freebuy'://0元购弹窗
                    $isPop=$actInfo->popupcus_freebuy($user);
                    break;
                default:
                    break;
            }
            if($isPop)
            {
                $this->success('获取成功',['haspop'=>true,'info'=>$vaule]);
                break;
            }
        }
        $this->success('获取成功',['haspop'=>false]);
    }
    /**
     *
     * 记录商品点击
     */
    public function recordItemClick()
    {
        $goodsid=request()->param('goodsid');
        $plat=request()->param('plat');
        $title=request()->param('title');
        $act_price=request()->param('act_price');
        $actInfo=new ActInfo();
        $actInfo->recordItemClick($goodsid,$plat,$title,$act_price);
        $this->success('成功',['success'=>true]);
    }
    public function UpWxImg()
    {
        $token=request()->param('token');
        $picPath=request()->param('picPath');
        //上传永久素材
        $url="https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=".$token."&type=image";
        //2、同步到微信服务器
        if(class_exists('\CURLFile')){  //7.0
            $data = ['media' => new \CURLFile($picPath)];
        }else{  //5.6以及5.6以下
            $data = array('media' => '@'.$picPath);
        }
        $ch  = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER , true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER , false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST , false);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        $res  = curl_exec($ch);
        curl_close($ch);
        $wxrs_id_card=json_decode($res,true);
        $id_card =$wxrs_id_card['media_id'];  //得到media_id
    }
}