|
|
@@ -2,11 +2,13 @@
|
|
|
namespace common\components\delivery\services;
|
|
|
|
|
|
//商户账号绑定管理
|
|
|
+use Yii;
|
|
|
use bizGhs\express\classes\DeliveryAuthTokenClass;
|
|
|
use common\components\delivery\platform\fengniao\Shop as FengniaoShop;
|
|
|
use common\components\delivery\platform\huolala\Shop as HuolalaShop;
|
|
|
use common\components\delivery\platform\shansong\Shop as ShansongShop;
|
|
|
use common\components\delivery\platform\shunfeng\Shop as ShunfengShop;
|
|
|
+use common\components\delivery\services\adapter\FengniaoAdapter;
|
|
|
|
|
|
/**
|
|
|
* 聚合调度逻辑(平台选择/优先级)
|
|
|
@@ -98,8 +100,71 @@ class ShopService
|
|
|
/**
|
|
|
* 获取商家的所有门店
|
|
|
*/
|
|
|
- public function getMerchantStores()
|
|
|
+ public function getMerchantStores($platform)
|
|
|
{
|
|
|
-
|
|
|
+ $storeDatas = [];
|
|
|
+ switch($platform) {
|
|
|
+ case 'fengniao':
|
|
|
+ /** @var FengniaoShop $shop */
|
|
|
+ $shop = $this->adapters[$platform];
|
|
|
+ $ret = $shop->chainstoreQueryList();
|
|
|
+ $stores = $ret['data']['list'];
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ if($platform == 'fengniao') {
|
|
|
+ $bindShopId = $shop->getShopId();
|
|
|
+ foreach($stores as $store) {
|
|
|
+ $storeDatas[] = [
|
|
|
+ 'id' => $store['chain_store_id'],
|
|
|
+ 'merchant_id' => $store['merchant_id'],
|
|
|
+ 'out_shop_code' => $store['out_shop_code'],
|
|
|
+ 'name' => $store['name'],
|
|
|
+ 'address' => $store['address'],
|
|
|
+ 'status' => $store['status'],
|
|
|
+ 'status_desc' => $store['status'],
|
|
|
+ 'latitude' => $store['latitude'],
|
|
|
+ 'longitude' => $store['longitude'],
|
|
|
+ 'bindStatus' => $bindShopId == $store['chain_store_id'] ? true : false,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $storeDatas;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function bindStore($mainId, $platform, $storeId)
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ switch($platform) {
|
|
|
+ case 'fengniao':
|
|
|
+ /** @var FengniaoShop $shop */
|
|
|
+ $shop = $this->adapters[$platform];
|
|
|
+ $shop->bindStore($mainId, $storeId);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ } catch(\Exception $e) {
|
|
|
+ Yii::error('绑定门店失败: ' . $e->getMessage());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function unbindStore($mainId, $platform, $storeId)
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ switch($platform) {
|
|
|
+ case 'fengniao':
|
|
|
+ /** @var FengniaoShop $shop */
|
|
|
+ $shop = $this->adapters[$platform];
|
|
|
+ $shop->unbindStore($mainId, $storeId);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ } catch(\Exception $e) {
|
|
|
+ Yii::error('解绑门店失败: ' . $e->getMessage());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
}
|
|
|
}
|