* @version : HUOSDK 8.0 */ namespace huo\controller\shop; use huo\controller\common\Base; use huo\controller\gift\Gift; use huo\controller\member\MemCache; use huo\logic\shop\GoodsLogic; use huolib\constant\MemItgConst; use huolib\status\CommonStatus; use huolib\status\ShopStatus; class Goods extends Base { /** * 获取商品 * * @param array $where * @param string $page * * @param $mem_id * @param bool $can_ex * * @return array */ public function getList($where = [], $page = '1,10', $mem_id, $can_ex = false) { $_order = '-list_order'; $_map['is_real'] = $this->getVal($where, 'is_real', 0); if (isset($where['flag'])) { $_map['flag'] = $where['flag']; } $_integral = 0; if (!empty($mem_id) && true == $can_ex) { $_me_data = MemCache::ins()->getMeInfoById($mem_id); if (!empty($_me_data['my_integral'])) { $_integral = $_me_data['my_integral']; } } if (!empty($_integral)) { $_map['integral'] = ['gt', 0]; } $_data = (new GoodsLogic())->getList($_map, $page, $_order); if (is_numeric($_data)) { return $this->huoError($_data, ShopStatus::getMsg($_data)); } /*替换积分礼包相关信息*/ if (!empty($_data['count'])) { foreach ($_data['list'] as $key => $goods) { if (MemItgConst::GOODS_IS_GIFT == $goods['object_name']) { $_gift_class = new Gift(); $_gift_data = $_gift_class->getGiftDetail($goods['object_id'], $mem_id); if (CommonStatus::NO_ERROR == $_gift_data['code']) { $goods['integral'] = $_gift_data['data']['condition']; $goods['remain_cnt'] = $_gift_data['data']['remain_cnt']; $_data['list'][$key] = $goods; } } $_data['list'][$key]['integral'] = (int)$_data['list'][$key]['integral']; } } return $this->retSucMsg(CommonStatus::NO_ERROR, $_data); } /** * @param int $goods_id * * @return array */ public function getDetail($goods_id = 0) { if (empty($goods_id)) { return $this->retErrMsg(CommonStatus::INVALID_PARAMS); } $_data = GoodsCache::ins()->getInfoByGoodsId($goods_id); return $this->retSucMsg(CommonStatus::NO_ERROR, $_data); } }