AuthService.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. namespace common\components\delivery\services;
  3. use common\components\util;
  4. Class AuthService{
  5. // ------------------ 授权(账号绑定) ---------------------
  6. //授权
  7. public function shansongAuth($mainId)
  8. {
  9. //闪送授权(商户授权:授权后能为商户下所有门店发单)
  10. $auth = new \common\components\delivery\platform\shansong\Auth();
  11. if(getenv('YII_ENV') == 'production') {
  12. //$apiHost = Yii::$app->params['ghsHost'];
  13. // TODO 暂时修改为测试环境
  14. $apiHost = 'https://api.shop.hzghd.com';
  15. } else {
  16. $apiHost = Yii::$app->params['ghsHost'];
  17. }
  18. $redirectUrl = $apiHost . '/delivery/shansong-auth-callback';
  19. $authUrl = $auth->generateMerchantAuthUrl($mainId, $redirectUrl);
  20. // 重定向用户
  21. //header('Location: ' . $authUrl);
  22. util::success(['url'=>$authUrl]);
  23. }
  24. public function huolalaAuth($mainId)
  25. {
  26. $huoLalaAuth = new \common\components\delivery\platform\huolala\Auth();
  27. // $apiHost = Yii::$app->params['ghsHost'];
  28. // TODO 暂时修改为测试环境
  29. $apiHost = 'https://api.shop.hzghd.com';
  30. $redirectUrl = $apiHost . '/delivery/huolala-auth-callback' . '?mainId=' . $mainId;
  31. $authUrl = $huoLalaAuth->generateAuthUrl($redirectUrl);
  32. //header('Location: ' . $authUrl);
  33. util::success(['url'=>$authUrl]);
  34. }
  35. public function fengniaoAuth($mainId)
  36. {
  37. $fengnaioAuth = new \common\components\delivery\platform\fengniao\Auth();
  38. // $apiHost = Yii::$app->params['ghsHost'];
  39. // TODO 暂时修改为测试环境
  40. $apiHost = 'https://api.shop.hzghd.com';
  41. $redirectUrl = $apiHost . '/delivery/fengniao-auth-callback' . '?main_id=' . $mainId;
  42. $authUrl = $fengnaioAuth->generateAuthUrl($redirectUrl);
  43. util::success(['url'=>$authUrl]);
  44. }
  45. public function dadaAuth($mainId)
  46. {
  47. $dadaAuth = new \common\components\delivery\platform\dada\Auth();
  48. $ticket = $dadaAuth->getTicket();
  49. $redirectUrl = Yii::$app->params['ghsHost'] . '/delivery/dada-auth-callback' . '?mainId=' . $mainId;
  50. $shopNumber = '40d8391f9b05477b';
  51. $state = 'huidiao_biaoshi';
  52. $authUrl = $dadaAuth->generateAuthUrl($ticket, $state, $shopNumber);
  53. //header('Location: ' . $authUrl);
  54. util::success(['url'=>$authUrl]);
  55. }
  56. public function shunfengAuth($mainId)
  57. {
  58. $shunfengAuth = new \common\components\delivery\platform\shunfeng\Auth();
  59. $authUrl = $shunfengAuth->generateAuthUrl($mainId);
  60. util::success(['url'=>$authUrl]);
  61. }
  62. }