DeliveryShopController.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace ghs\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 actionList()
  16. // {
  17. // $platformList = [];
  18. // $platformLogos = [
  19. // 'data' => ['name'=>'达达', 'logo'=>'📦'],
  20. // 'shunfeng' => ['name'=>'顺丰同城', 'logo'=>'🚚'],
  21. // 'meituan' => ['name'=>'美团', 'logo'=>'🍱'] ,
  22. // 'fengniao' => ['name'=>'蜂鸟', 'logo'=>'🍜'],
  23. // 'huolala' => ['name'=>'货拉拉跑腿', 'logo'=>'🚛'],
  24. // 'shansong' => ['name'=>'闪送', 'logo'=>'⚡'],
  25. // 'didi' => ['name'=>'滴滴', 'logo'=>'🚗'],
  26. // 'uu' => ['name'=>'UU跑腿', 'logo'=>'🛵']
  27. // ];
  28. // $mainId = $this->mainId;
  29. // $allDeliveries = DeliveryAuthTokenClass::getAllByCondition(['mainId'=>$mainId]);
  30. // foreach($allDeliveries as $d){
  31. // $item = [
  32. // 'id'=>$d['platform'],
  33. // 'logo'=>$platformLogos[$d['platform']]['logo'],
  34. // 'name'=>$platformLogos[$d['platform']]['name'],
  35. // 'is_authorized' => true,
  36. // 'balance' => $d['balance']/100.0,
  37. // 'access_type' => 'oauth'
  38. // ];
  39. // $platformList[] = $item;
  40. // }
  41. // util::success(['platformList'=>$platformList]);
  42. // }
  43. public function actionBalance()
  44. {
  45. $get = Yii::$app->request->get();
  46. $platform = $get['platform'];
  47. $ShopService = new ShopService($this->mainId, $platform);
  48. $balance = $ShopService->getBalance($platform);
  49. $deliveryAuthToken = DeliveryAuthTokenClass::getByCondition(['platform'=>$platform, 'mainId'=>$this->mainId], true);
  50. if(!$deliveryAuthToken){
  51. util::fail('配送平台未授权');
  52. }
  53. $deliveryAuthToken->balance = $balance;
  54. $deliveryAuthToken->save();
  55. util::success(['balance'=>$balance]);
  56. }
  57. public function actionStore()
  58. {
  59. $get = Yii::$app->request->get();
  60. $platform = $get['platform'];
  61. $ShopService = new ShopService($this->mainId, $platform);
  62. }
  63. }