request; if ($request->isGet) { try { $get = $request->get(); $res = Yii::$app->services->validate->validate($get, [ [['cate_id', 'page', 'store_id', 'limit'], 'integer'], [['keyword'], 'string'], [['type'],'safe'] ]); if (!$res) throw new Exception(Yii::$app->services->validate->getErrorMessage()); $list = (new GoodsService(['mall_id' => $this->mall_id, 'user_id' => $this->user_id]))->cateGoodsList($get); $this->success('获取成功', $list); } catch (\Exception $e) { return $this->error($e->getMessage()); } } } //最近的门店商品 public function actionGetNearStoreGoodsList() { $request = Yii::$app->request; if ($request->isGet) { try { $get = $request->get(); $res = Yii::$app->services->validate->validate($get, [ [['longitude', 'latitude', 'shipping_type', 'attr_id', 'attr_ids', 'goods_ids'], 'string'], ]); if (!$res) throw new Exception(Yii::$app->services->validate->getErrorMessage()); $get['mall_id'] = $this->mall_id; $get['user_id'] = $this->user_id; if (!empty($get['attr_ids'])) $get['attr_ids'] = explode(',', $get['attr_ids']); if (!empty($get['goods_ids'])) $get['goods_ids'] = explode(',', $get['goods_ids']); $info = (new StoreService())->getStore($get); $search['store_id']= $info['id']; $search['page'] = $get['page']; $search['limit'] = $get['limit']; if (!$res) throw new Exception(Yii::$app->services->validate->getErrorMessage()); $list = (new GoodsService(['mall_id' => $this->mall_id, 'user_id' => $this->user_id]))->cateGoodsList ($search); $list['store']=(new StoreService(['mall_id' => $this->mall_id]))->getStoreDetail(['store_id'=>$info['id']]); $this->success('获取成功', $list); } catch (\Exception $e) { return $this->error($e->getMessage()); } } } /** * 首页 * * @return string */ public function actionDetail() { $params = \Yii::$app->request->get(); $res = \Yii::$app->services->validate->validate($params, [ [['goods_id'], 'integer'], [['scene'], 'string'], ['store_id', 'integer'], [['addonsFields','latitude','longitude'], 'safe'] ]); if ($res === false) return $this->error(\Yii::$app->services->validate->getErrorMessage()); $goods = GoodsLogic::GetDetail($this->mall_id, $params, $this->user); if (empty($goods)) return $this->error(GoodsLogic::getStaticError()); if ($params['addonsFields']) { if($this->platform == User::PLATFORM_MP_WX){ is_string($params['addonsFields']) && $params['addonsFields'] = json_decode($params['addonsFields'], true); }else{ $params['addonsFields'] = is_string($params['addonsFields']) ? explode(',', $params['addonsFields']) : $params['addonsFields']; } $goods = Goods::getAddonsGoodsSetting($this->mall_id, $params['addonsFields'], $goods, 'detail'); } $goods['is_bind_popups'] = UserPartitionRelationship::getIsNeedPopups($this->mall_id, $this->user_id ?? 0); //浏览 if ($goods) { $event = new ViewsEvent($this->mall_id); $data['mall_id'] = $this->mall_id; $data['user_id'] = $this->user_id; $data['goods_id'] = $params['goods_id']; \Yii::$app->services->events->dispatch($event, $data, $event->listeners); $smart_form_template = GlobalInvoke::exec(GlobalInvoke::GOODS_NEED_SMARTFORM, $this->mall_id, ['user_id' => $this->user_id, 'mall_id' => $this->mall_id, 'goods_id' => $params['goods_id']]); if (!empty($smart_form_template)) $goods = array_merge($goods, $smart_form_template); // 商品详情公共调用 $invoke_data = GlobalInvoke::exec( GlobalInvoke::API_GOODS_DETAIL, $this->mall_id, ['mall_id' => $this->mall_id, 'goods' => $goods, 'user' => $this->user,'latitude'=>$params['latitude']??0,'longitude'=>$params['longitude']??0] ); if (!empty($invoke_data['goods'])) $goods = $invoke_data['goods']; } // 首页文本命名 $home_text = Yii::$app->services->setting->mall->get($this->mall_id, "goodsdetail.home_text"); $goods['home_text'] = !empty($home_text) ? $home_text : '首页'; $res = GoodsLogic::getGoodsAssociationList($this->mall_id,$params['goods_id']); $goods['extra1_goods_list'] = $res['extra1_goods_list']??[]; $goods['extra2_goods_list'] = $res['extra2_goods_list']??[]; $pension_scale = \Yii::$app->services->setting->addons->get($this->mall_id, HappinessEnum::ADDONS_NAME, 'basic.pension_scale')??0; $goods['pension_price']=bcmul($goods['price'],bcdiv($pension_scale,100,4),2); return $this->success('获取成功', $goods); } }