diff --git a/app/Controller/PurchaseLimitController.php b/app/Controller/PurchaseLimitController.php index 7bb2d22..570fa06 100644 --- a/app/Controller/PurchaseLimitController.php +++ b/app/Controller/PurchaseLimitController.php @@ -22,6 +22,12 @@ class PurchaseLimitController extends BaseController return $this->success($res); } + public function getBannerByMarketId() + { + $res = $this->purchaseLimitService->getBannerByMarketId($this->request->all()); + return $this->success($res); + } + public function ssdbPurchaseRecord() { $res = $this->purchaseLimitService->ssdbPurchaseRecord($this->request->all(),214,156813021196050432); diff --git a/app/Service/PurchaseLimitService.php b/app/Service/PurchaseLimitService.php index 3c7c2bd..9d43838 100644 --- a/app/Service/PurchaseLimitService.php +++ b/app/Service/PurchaseLimitService.php @@ -24,31 +24,76 @@ class PurchaseLimitService implements PurchaseLimitServiceInterface */ protected $paramsTokenService; + /** + * @Inject + * @var AdServiceInterface + */ + protected $adService; + public function getStoreIdByMarketId($params) { $market_id = $params['market_id']; + $res = []; //获取ssdb上的首页banner logo 列表 $logo_list = $this->paramsTokenService->analyze('banner_logo_list'); + if (false === $logo_list) { + return $res; + } //获取ssdb上的首页banner 市场 列表 $market_list = $this->paramsTokenService->analyze('banner_market_list'); + if (false === $market_list) { + return $res; + } //根据前端指定的指获取店铺id 字符串 并拆分成数组 - $store_list = $market_list['market_id_'.$market_id]; - $store_list = explode(',',$store_list); - //遍历店铺 - foreach ($store_list as $store_id){ - $res[] = [ - 'id' => 7, - 'item' => 1, - 'item_text' => 'page', - 'logo' => $logo_list['store_id_'.$store_id], - 'redirect_url' => '/zh_cjdianc/pages/takeout/takeoutindex?storeid='.$store_id, - 'src' => '/zh_cjdianc/pages/takeout/takeoutindex?storeid='.$store_id, - 'src2' => '/zh_cjdianc/pages/takeout/takeoutindex?storeid='.$store_id, - ]; + if(isset($market_list['market_id_'.$market_id])) { + $store_list = $market_list['market_id_' . $market_id]; + $store_list = explode(',', $store_list); + //遍历店铺 + foreach ($store_list as $store_id) { + $res[] = [ + 'id' => $store_id, + 'item' => 1, + 'item_text' => 'page', + 'logo' => $logo_list['store_id_' . $store_id], + 'redirect_url' => '/zh_cjdianc/pages/takeout/takeoutindex?storeid=' . $store_id, + 'src' => '/zh_cjdianc/pages/takeout/takeoutindex?storeid=' . $store_id, + 'src2' => '/zh_cjdianc/pages/takeout/takeoutindex?storeid=' . $store_id, + ]; + } + } return $res; } + public function getBannerByMarketId($params) + { + $market_id = $params['market_id']; + //获取ssdb上的首页banner logo 列表 + $logo_list = $this->paramsTokenService->analyze('banner_logo_list'); + //获取ssdb上的首页banner 市场 列表 + $market_list = $this->paramsTokenService->analyze('banner_market_list'); + //根据前端指定的指获取店铺id 字符串 并拆分成数组 + if(isset($market_list['market_id_'.$market_id])) { + $store_list = $market_list['market_id_' . $market_id]; + $store_list = explode(',', $store_list); + //遍历店铺 + foreach ($store_list as $store_id) { + $banners[] = [ + 'id' => $store_id, + 'item' => 1, + 'item_text' => 'page', + 'logo' => $logo_list['store_id_' . $store_id], + 'redirect_url' => '/zh_cjdianc/pages/takeout/takeoutindex?storeid=' . $store_id, + 'src' => '/zh_cjdianc/pages/takeout/takeoutindex?storeid=' . $store_id, + 'src2' => '/zh_cjdianc/pages/takeout/takeoutindex?storeid=' . $store_id, + ]; + } + }else{ + $banners = $this->adService->banners(); + } + return $banners; + } + public function ssdbPurchaseRecord($data,$user_id,$global_order_id) { foreach ($data as $k => $v){ diff --git a/app/Service/PurchaseLimitServiceInterface.php b/app/Service/PurchaseLimitServiceInterface.php index 9ff3184..dcbd1a2 100644 --- a/app/Service/PurchaseLimitServiceInterface.php +++ b/app/Service/PurchaseLimitServiceInterface.php @@ -8,6 +8,8 @@ interface PurchaseLimitServiceInterface { public function getStoreIdByMarketId($params); + public function getBannerByMarketId($params); + public function ssdbPurchaseRecord($params,$user_id,$global_order_id); public function delSsdbPurchaseRecord($global_order_id); diff --git a/config/routes.php b/config/routes.php index 659680f..048141d 100644 --- a/config/routes.php +++ b/config/routes.php @@ -66,6 +66,7 @@ Router::addGroup('/v1/',function (){ Router::post('PurchaseLimit/getStoreIdByMarketId', 'App\Controller\PurchaseLimitController@getStoreIdByMarketId'); Router::post('OrderList/storeOrderList', 'App\Controller\OrderListController@storeOrderList'); Router::post('OrderList/userOrderList', 'App\Controller\OrderListController@userOrderList'); + Router::post('PurchaseLimit/getBannerByMarketId', 'App\Controller\PurchaseLimitController@getBannerByMarketId'); },['middleware' => [\App\Middleware\Auth\ApiMiddleware::class]]);