Browse Source

支付后获取unionid

master
weigang 5 years ago
parent
commit
b0eb7c426a
  1. 13
      app/Controller/v3/NotifyController.php
  2. 9
      app/Service/v3/Implementations/UserInfoService.php
  3. 2
      app/Service/v3/Interfaces/UserInfoServiceInterface.php

13
app/Controller/v3/NotifyController.php

@ -12,6 +12,7 @@ use App\Model\v3\GoodsActivity;
use App\Model\v3\Order;
use App\Model\v3\OrderGoods;
use App\Model\v3\OrderMain;
use App\Model\v3\User;
use App\Service\v3\Interfaces\BadgeServiceInterface;
use App\Service\v3\Interfaces\CouponRebateServiceInterface;
use App\Service\v3\Interfaces\CouponServiceInterface;
@ -25,6 +26,7 @@ use App\Service\v3\Interfaces\OrderOfflineServiceInterface;
use App\Service\v3\Interfaces\OrderOnlineServiceInterface;
use App\Service\v3\Interfaces\OrderStatisticsServiceInterface;
use App\Service\v3\Interfaces\SeparateAccountsServiceInterface;
use App\Service\v3\Interfaces\UserInfoServiceInterface;
use EasyWeChat\Factory;
use Hyperf\DbConnection\Db;
use Hyperf\Guzzle\CoroutineHandler;
@ -114,6 +116,12 @@ class NotifyController extends BaseController
*/
protected $orderStatisticsService;
/**
* @Inject
* @var UserInfoServiceInterface
*/
protected $userInfoService;
public function wxminiOnline()
{
@ -276,6 +284,11 @@ class NotifyController extends BaseController
// 公众号模板消息
$res = $this->miniprogramService->sendTemMsgForOfflineOrder($orderMain->global_order_id);
$openid = User::query()->where(['id' => $orderMain->user_id])->value('openid');
$res = $this->userInfoService->getPaidUnionId($openid);
$this->log->event('test_get_paid_unionid', ['res' => $res]);
return true;
} catch (Exception $e) {

9
app/Service/v3/Implementations/UserInfoService.php

@ -102,5 +102,12 @@ class UserInfoService implements UserInfoServiceInterface
})->first();
return $employees;
}
public function getPaidUnionId($openid)
{
$config = config('applet');
$app = Factory::miniProgram($config);
$app['guzzle_handler'] = CoroutineHandler::class;
return $app->base->getPaidUnionid($openid);
}
}

2
app/Service/v3/Interfaces/UserInfoServiceInterface.php

@ -10,5 +10,5 @@ interface UserInfoServiceInterface
public function detail($userId);
public function getStoreByUID($userId);
public function getEmployeesByUID($userId);
public function getPaidUnionId($openid);
}
Loading…
Cancel
Save