| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <?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 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('解绑门店成功');
- }
- public function actionStoreDetail()
- {
- $post = Yii::$app->request->post();
- $platform = $post['platform'];
- $delivery = DeliveryAuthTokenClass::getByCondition(['platform'=>$platform, 'mainId'=>$this->mainId], true);
- if(!$delivery){
- util::fail('配送平台不存在');
- }
- $ShopService = new ShopService($this->mainId, $platform);
- $re = $ShopService->storeDetail($this->mainId, $platform, $delivery->shopId);
- if(!$re){
- util::fail('获取门店详情失败');
- }
- util::success($re, '获取门店详情成功');
- }
- public function actionUpdateStore()
- {
- $post = Yii::$app->request->post();
- $platform = $post['platform'];
- $delivery = DeliveryAuthTokenClass::getByCondition(['platform'=>$platform, 'mainId'=>$this->mainId], true);
- if(!$delivery){
- util::fail('配送平台不存在');
- }
- $ShopService = new ShopService($this->mainId, $platform);
- $re = $ShopService->updateStore($delivery->shopId, $platform, $post);
- if(!$re){
- util::fail('修改门店详情失败');
- }
- util::success($re, '修改门店详情成功');
- }
- }
|