| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- <?php
- namespace ghs\controllers;
- use bizGhs\express\classes\DeliveryAuthTokenClass;
- use common\components\util;
- use common\components\delivery\services\ShopService;
- use Yii;
- /**
- * 聚合配送 -- 门店相关接口
- * Class DeliveryController
- * @package ghs\controllers
- */
- class DeliveryShopController extends BaseController
- {
- public $guestAccess = [];
- // public function actionList()
- // {
- // $platformList = [];
- // $platformLogos = [
- // 'data' => ['name'=>'达达', 'logo'=>'📦'],
- // 'shunfeng' => ['name'=>'顺丰同城', 'logo'=>'🚚'],
- // 'meituan' => ['name'=>'美团', 'logo'=>'🍱'] ,
- // 'fengniao' => ['name'=>'蜂鸟', 'logo'=>'🍜'],
- // 'huolala' => ['name'=>'货拉拉跑腿', 'logo'=>'🚛'],
- // 'shansong' => ['name'=>'闪送', 'logo'=>'⚡'],
- // 'didi' => ['name'=>'滴滴', 'logo'=>'🚗'],
- // 'uu' => ['name'=>'UU跑腿', 'logo'=>'🛵']
- // ];
- // $mainId = $this->mainId;
- // $allDeliveries = DeliveryAuthTokenClass::getAllByCondition(['mainId'=>$mainId]);
- // foreach($allDeliveries as $d){
- // $item = [
- // 'id'=>$d['platform'],
- // 'logo'=>$platformLogos[$d['platform']]['logo'],
- // 'name'=>$platformLogos[$d['platform']]['name'],
- // 'is_authorized' => true,
- // 'balance' => $d['balance']/100.0,
- // 'access_type' => 'oauth'
- // ];
- // $platformList[] = $item;
- // }
- // util::success(['platformList'=>$platformList]);
- // }
- public function actionBalance()
- {
- $get = Yii::$app->request->get();
- $platform = $get['platform'];
- $ShopService = new ShopService($this->mainId, $platform);
- $balance = $ShopService->getBalance($platform);
-
- $deliveryAuthToken = DeliveryAuthTokenClass::getByCondition(['platform'=>$platform, 'mainId'=>$this->mainId], true);
- if(!$deliveryAuthToken){
- util::fail('配送平台未授权');
- }
- $deliveryAuthToken->balance = $balance;
- $deliveryAuthToken->save();
- util::success(['balance'=>$balance]);
- }
- public function actionStoreList()
- {
- $get = Yii::$app->request->get();
- $platform = $get['platform'];
- $ShopService = new ShopService($this->mainId, $platform);
- $stores = $ShopService->getMerchantStores($platform);
- util::success($stores);
- }
- public function actionBindStore(){
- $post = Yii::$app->request->post();
- $platform = $post['platform'];
- $storeId = $post['shopId'];
- $ShopService = new ShopService($this->mainId, $platform);
- $re = $ShopService->bindStore($this->mainId, $platform, $storeId);
- if(!$re){
- util::fail('绑定门店失败');
- }
- util::success('绑定成功');
- }
- public function actionUnbindStore(){
- $post = Yii::$app->request->post();
- $platform = $post['platform'];
- $storeId = $post['shopId'];
- $ShopService = new ShopService($this->mainId, $platform);
- $re = $ShopService->unbindStore($this->mainId, $platform, $storeId);
- if(!$re){
- util::fail('解绑门店失败');
- }
- util::success('解绑门店成功');
- }
- }
|