<?php
/**
 * 商品相关
 */
defined('IN_WEB') or die('Include Error!');
class Goods
{
    /**
     * 获取商品列表
     * @param $param
     * @return false|string
     * Created by: Owen
     * Created on: 2020/3/27 17:42
     */
    public function listFunction($param){
        $uid = oo::functions()->uint($param['uid']);
        if(empty($uid)){
            return oo::response(-1,[],'参数错误');
        }
        $sid = (!empty($param['sid']) && in_array($param['sid'], [1, 2])) ? $param['sid'] : '';
        $data = oo::commonOprModel('goods')->getCrazyGodGood($uid, $sid);
        return json_encode($data,JSON_NUMERIC_CHECK);
    }

    /**
     * 获取充值后商品列表可能产生变更的商品列表
     */
    public function extraList($param) {
        $uid = oo::functions()->uint($param['uid']);
        if(empty($uid)){
            return oo::response(-1,[],'参数错误');
        }
        $sid = (!empty($param['sid']) && in_array($param['sid'], [1, 2])) ? $param['sid'] : '';
        $data = oo::commonOprModel('goods')->getextraCrazyGodGood($uid, $sid);
        return json_encode($data,JSON_NUMERIC_CHECK);       
    }

    /**
     * 升级之后商品数据
     * @param $param
     * @return false|string
     * Created by: Owen
     * Created on: 2020/12/10 16:49
     */
    public function listByUpLevel($param){
        $uid = oo::functions()->uint($param['uid']);
        if(empty($uid)){
            return oo::response(-1,[],'参数错误');
        }
        return oo::commonOprModel('goods')->getGoodInfoByUpLevel($uid);
    }

    /**
     * 限时特惠
     * @param $param
     * @return string
     * Created by: Owen
     * Created on: 2020/3/27 17:42
     */
  	public function specialOffer($param){
        $uid = oo::functions()->uint($param['uid']);
        if( empty($uid) ){
            return oo::response(-1,[],'参数错误');
        }
        $data['goods']   = oo::commonOprModel('goods')->specialOffer($uid);
        $data['offerLv'] = oo::commonOprModel('goods')->specialOfferLv($uid);
        return oo::response(1,$data,'',true);
    }

    /**
     * 商店横条
     * @param $param
     * @return string
     * Created by: Owen
     * Created on: 2021/1/21 21:05
     */
    public function freeBar($param){
        $uid = oo::functions()->uint($param['uid']);
        if( empty($uid) ){
            return oo::response(-1,[],'参数错误');
        }
        return oo::commonOprModel('goods')->getFreeBarData($uid);
    }

    /**
     * Notes:根据类型获取商品列表
     * User: wsc
     * Time: 2021/4/21 20:22
     * @param $param
     * @return string
     */
    public function getGoodListByType($param){
        $uid = oo::functions()->uint($param['uid']);
        $type= $param['type'];
        if(empty($uid)||!in_array($type,["super_serial_pack","chain_gift","super_serial_pack2","chooseOne","onePlusGift","safeSurprise"])){
            return oo::response(-1,[],'参数错误');
        }
        return oo::commonOprModel('goods')->getGoodListByType($uid,$type);
    }
}
