<?php
defined( 'IN_WEB') or die( 'Include Error!');
/**
 * 分享接口
 */
class Share {
    /**
     * 分享次数
     * @param $param $shareType 分享类型 $uid 用户ID
     * @return string
     * Created by: Hss
     * Created on: 2019/12/11 17:09
     */
    public function shareNumber($param){
        $uid = oo::functions()->uint($param['uid']);
        $rewardId = oo::functions()->escape($param['rewardId']);
        $rewardData = oo::commonOprRedis('common')->get(okeys::ShareRewardIdData($rewardId));

        if(!empty($rewardData)){
            $rewardData = json_decode($rewardData,true);
            oo::commonOprRedis('Statistics')->hIncrBy(okeys::todayShareStatistics($rewardData['type'],'selfType'),'total',1);
            //索取卡片
            if($rewardData['type'] == 'askforCard'){

            }
        }

        return oo::response(1,$rewardId);
    }

    /**
     * 点击次数
     * @param $param $shareType 分享类型 $uid 用户ID
     * @return string
     * Created by: Hss
     * Created on: 2019/12/11 17:09
     */
    public function clickNumber($param){
        $uid = oo::functions()->uint($param['uid']);
        $rewardId = oo::functions()->escape($param['rewardId']);
        $rewardData = oo::commonOprRedis('common')->get(okeys::ShareRewardIdData($rewardId));

        if(!empty($rewardData)){
            $rewardData = json_decode($rewardData,true);
            oo::commonOprRedis('Statistics')->hIncrBy(okeys::todayShareStatistics($rewardData['type'],'otherType'),'total',1);
        }

        return oo::response(1,$rewardId);
    }
}