<?php

class GroupController extends \Our\Controller_AbstractIndex {

    private $GroupSaleService ;
    public function init(){
        parent::init();
        $this->GroupSaleService = \Business\Goods\GroupSaleServiceModel::getInstance();
        $this->memberId=$this->sess->get('member_id');
    }


    public function getGroupGoodsAction(){

//        $goodsInfo = $this->GroupSaleService->getGroupGoods($this->req[\Our\NameConst::data],$this->memberId);
//        $this->success($goodsInfo);
        $data = $this->GroupSaleService->getGroupGoods($this->req[\Our\NameConst::data]);
        $this->success($data);
    }

    public function getAction(){
        $address = \Business\User\AddressServiceModel::getInstance()->getMyAddress($this->req[\Our\NameConst::data],$this->memberId,false);
        $goods = $this->GroupSaleService->getGroupGoods($this->req[\Our\NameConst::data],$address);
//        $data = $this->GroupSaleService->getOnePBundingCache($this->req[\Our\NameConst::data]['groupId']);
//        $this->GroupSaleService->handleData($data);
        $storeInfo = \Business\Goods\GoodsCommonServiceModel::getInstance()->getStore($goods['store_id'],false);
        unset($storeInfo['freeShippingPrice']);unset($storeInfo['isQuality']);unset($storeInfo['shareDesc']);
        $otherGroups = \Business\Goods\GroupSaleServiceModel::getInstance()->getOtherGroup($goods['store_id'],$this->req[\Our\NameConst::data]['groupId']);
        \Business\Goods\GroupSaleServiceModel::getInstance()->addBrowseRecord($this->req[\Our\NameConst::data],$this->memberId);
        unset($goods['store_id']);
        $this->success(array_merge($goods,array('storeInfo'=>$storeInfo,'otherGroups'=>$otherGroups)));
    }

    public function testAction(){
        //var_dump($this->GroupSaleService->getOnePBundingCache(24));
        var_dump($this->GroupSaleService->getOtherGroup(11,33));
    }
}