|
|
@@ -12,13 +12,17 @@ use common\components\util;
|
|
|
class CategoryController extends BaseController
|
|
|
{
|
|
|
|
|
|
- public $guestAccess = ['list', 'use-case-list']; // 'goods-list' ---- 为什么不用认证
|
|
|
+ /**
|
|
|
+ * 游客可浏览分类与商品列表(商城分类页未登录浏览);下单/建客仍走登录后流程
|
|
|
+ * buildRelation 对空 user 直接 return,游客不会建客
|
|
|
+ */
|
|
|
+ public $guestAccess = ['list', 'use-case-list', 'goods-list'];
|
|
|
|
|
|
- //获取分类 ssh 2019.12.2
|
|
|
+ //获取分类 ssh 2019.12.2(游客可浏览,不依赖 user;无店铺上下文时返回空)
|
|
|
public function actionList()
|
|
|
{
|
|
|
- $user = $this->user;
|
|
|
- if (empty($user)) {
|
|
|
+ // 未登录场景必须有 account→mainId,否则无法定位门店分类
|
|
|
+ if (empty($this->shop) || empty($this->mainId)) {
|
|
|
util::success([]);
|
|
|
}
|
|
|
|
|
|
@@ -37,7 +41,7 @@ class CategoryController extends BaseController
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //建立客户关系
|
|
|
+ //建立客户关系(未登录时 buildRelation 直接返回,不建客)
|
|
|
CustomClass::buildRelation($this->shop, $this->user);
|
|
|
$mainId = $this->mainId ?? 0;
|
|
|
$where = ['mainId' => $mainId, 'delStatus' => 0, 'status' => 1];
|
|
|
@@ -50,17 +54,15 @@ class CategoryController extends BaseController
|
|
|
util::success($return);
|
|
|
}
|
|
|
|
|
|
- //取分类下商品 ssh 2019.12.2
|
|
|
+ //取分类下商品 ssh 2019.12.2(游客可浏览,custom 为空时按散客价组装)
|
|
|
public function actionGoodsList()
|
|
|
{
|
|
|
- $user = $this->user;
|
|
|
- if (empty($user)) {
|
|
|
- util::success(['list' => []]);
|
|
|
- }
|
|
|
-
|
|
|
$get = Yii::$app->request->get();
|
|
|
$shop = $this->shop;
|
|
|
- $custom = $this->custom;
|
|
|
+ if (empty($shop)) {
|
|
|
+ util::success(['list' => []]);
|
|
|
+ }
|
|
|
+ $custom = !empty($this->custom) ? $this->custom : [];
|
|
|
$params = [];
|
|
|
//调用花店端的方法,后面再分离 (为了代码维护可以不分离,免得一处改了,另一处没修改到。--- 所以分离好后,又还原了)
|
|
|
$data = \bizHd\goods\classes\GoodsCategoryClass::getGoodsList($get, $shop, $custom, $params);
|