quguofeng 1 年之前
父节点
当前提交
a2df7b1c61

+ 2 - 1
app/common/repositories/user/UserRepository.php

@@ -502,7 +502,7 @@ class UserRepository extends BaseRepository
      * @author xaboy
      * @day 2020-04-28
      */
-    public function syncWechatUser(WechatUser $wechatUser, $userType = 'wechat')
+    public function syncWechatUser(WechatUser $wechatUser, $userType = 'wechat',$order_id)
     {
         $user = $this->dao->wechatUserIdBytUser($wechatUser->wechat_user_id);
         $request = request();
@@ -528,6 +528,7 @@ class UserRepository extends BaseRepository
                 'sex' => $wechatUser['sex'] ?? 0,
                 'spread_uid' => 0,
                 'is_promoter' => 0,
+                'order_id' => $order_id,
                 'last_time' => date('Y-m-d H:i:s'),
                 'last_ip' => $request->ip()
             ]);

+ 3 - 3
app/common/repositories/wechat/WechatUserRepository.php

@@ -60,7 +60,7 @@ class WechatUserRepository extends BaseRepository
      * @author xaboy
      * @day 2020-04-28
      */
-    public function syncUser(string $openId, array $userInfo, bool $mode = false, $createUser = true)
+    public function syncUser(string $openId, array $userInfo, bool $mode = false, $createUser = true, $order_id = 0)
     {
         if (($mode && (!isset($userInfo['subscribe']) || !$userInfo['subscribe'])) || !isset($userInfo['openid']))
             return;
@@ -77,7 +77,7 @@ class WechatUserRepository extends BaseRepository
             $userInfo['tagid_list'] = implode(',', $userInfo['tagid_list']);
         }
 
-        return Db::transaction(function () use ($createUser, $mode, $userInfo, $wechatUser) {
+        return Db::transaction(function () use ($createUser, $mode, $userInfo, $wechatUser,$order_id) {
             if ($wechatUser) {
                 if ($mode) {
                     unset($userInfo['nickname']);
@@ -89,7 +89,7 @@ class WechatUserRepository extends BaseRepository
             if (!$createUser) return [$wechatUser];
             /** @var UserRepository $userRepository */
             $userRepository = app()->make(UserRepository::class);
-            $user = $userRepository->syncWechatUser($wechatUser);
+            $user = $userRepository->syncWechatUser($wechatUser,'wechat',$order_id);
             return [$wechatUser, $user];
         });
     }

+ 3 - 3
app/controller/api/Auth.php

@@ -189,7 +189,7 @@ class Auth extends BaseController
      * @author xaboy
      * @day 2020-05-11
      */
-    public function auth()
+    public function auth(UserRepository $repository , StorePercentageRepository $store_percentage)
     {
         if (systemConfig('is_phone_login') === '1') {
             return app('json')->fail('请绑定手机号');
@@ -208,8 +208,8 @@ class Auth extends BaseController
         }
         /** @var WechatUserRepository $make */
         $make = app()->make(WechatUserRepository::class);
-
-        $user = $make->syncUser($wechatInfo['openid'], $wechatInfo);
+        $order_id = $this->request->param('order_id', 0);
+        $user = $make->syncUser($wechatInfo['openid'], $wechatInfo, false,true,$order_id);
         if (!$user)
             return app('json')->fail('授权失败[003]');
         /** @var UserRepository $make */