DeliveryShopController.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace hd\controllers;
  3. use bizGhs\express\classes\DeliveryAuthTokenClass;
  4. use common\components\util;
  5. use common\components\delivery\services\ShopService;
  6. use Yii;
  7. /**
  8. * 聚合配送 -- 门店相关接口
  9. * Class DeliveryController
  10. * @package ghs\controllers
  11. */
  12. class DeliveryShopController extends BaseController
  13. {
  14. public $guestAccess = [];
  15. public function actionBalance()
  16. {
  17. $get = Yii::$app->request->get();
  18. $platform = $get['platform'];
  19. $ShopService = new ShopService($this->mainId, $platform);
  20. $balance = $ShopService->getBalance($platform);
  21. $deliveryAuthToken = DeliveryAuthTokenClass::getByCondition(['platform'=>$platform, 'mainId'=>$this->mainId], true);
  22. if(!$deliveryAuthToken){
  23. util::fail('配送平台未授权');
  24. }
  25. $deliveryAuthToken->balance = $balance;
  26. $deliveryAuthToken->save();
  27. util::success(['balance'=>$balance]);
  28. }
  29. public function actionStoreList()
  30. {
  31. $get = Yii::$app->request->get();
  32. $platform = $get['platform'];
  33. $ShopService = new ShopService($this->mainId, $platform);
  34. $stores = $ShopService->getMerchantStores($platform);
  35. util::success($stores);
  36. }
  37. public function actionBindStore(){
  38. $post = Yii::$app->request->post();
  39. $platform = $post['platform'];
  40. $storeId = $post['shopId'];
  41. $ShopService = new ShopService($this->mainId, $platform);
  42. $re = $ShopService->bindStore($this->mainId, $platform, $storeId);
  43. if(!$re){
  44. util::fail('绑定门店失败');
  45. }
  46. util::success('绑定成功');
  47. }
  48. public function actionUnbindStore(){
  49. $post = Yii::$app->request->post();
  50. $platform = $post['platform'];
  51. $storeId = $post['shopId'];
  52. $ShopService = new ShopService($this->mainId, $platform);
  53. $re = $ShopService->unbindStore($this->mainId, $platform, $storeId);
  54. if(!$re){
  55. util::fail('解绑门店失败');
  56. }
  57. util::success('解绑门店成功');
  58. }
  59. }