Просмотр исходного кода

【程序目录】优化部分功能

wuhaotian 11 месяцев назад
Родитель
Сommit
48a9688513
27 измененных файлов с 115 добавлено и 46 удалено
  1. 1 0
      crmeb/app/adminapi/controller/v1/marketing/StoreBargain.php
  2. 2 1
      crmeb/app/adminapi/controller/v1/marketing/StoreCombination.php
  3. 2 1
      crmeb/app/adminapi/controller/v1/marketing/StoreSeckill.php
  4. 2 0
      crmeb/app/adminapi/controller/v1/product/StoreProduct.php
  5. 9 9
      crmeb/app/adminapi/controller/v1/setting/SystemCrud.php
  6. 4 2
      crmeb/app/common.php
  7. 18 1
      crmeb/app/dao/BaseDao.php
  8. 1 0
      crmeb/app/jobs/MiniOrderJob.php
  9. 2 0
      crmeb/app/jobs/PinkJob.php
  10. 1 0
      crmeb/app/listener/http/HttpEndListener.php
  11. 6 1
      crmeb/app/listener/order/OrderShippingListener.php
  12. 10 0
      crmeb/app/model/product/product/StoreProduct.php
  13. 7 1
      crmeb/app/model/system/crontab/SystemCrontab.php
  14. 10 5
      crmeb/app/services/BaseServices.php
  15. 2 2
      crmeb/app/services/activity/combination/StorePinkServices.php
  16. 1 0
      crmeb/app/services/activity/integral/StoreIntegralOrderServices.php
  17. 2 2
      crmeb/app/services/message/notice/EnterpriseWechatService.php
  18. 1 5
      crmeb/app/services/order/OutStoreOrderRefundServices.php
  19. 2 0
      crmeb/app/services/order/StoreOrderCreateServices.php
  20. 12 0
      crmeb/app/services/order/StoreOrderDeliveryServices.php
  21. 2 4
      crmeb/app/services/order/StoreOrderInvoiceServices.php
  22. 3 3
      crmeb/app/services/order/StoreOrderWriteOffServices.php
  23. 1 2
      crmeb/app/services/system/SystemRouteServices.php
  24. 3 3
      crmeb/app/services/user/LoginServices.php
  25. 4 1
      crmeb/app/services/user/UserAddressServices.php
  26. 1 1
      crmeb/app/services/user/UserBillServices.php
  27. 6 2
      crmeb/app/services/wechat/WechatUserServices.php

+ 1 - 0
crmeb/app/adminapi/controller/v1/marketing/StoreBargain.php

@@ -47,6 +47,7 @@ class StoreBargain extends AuthController
             ['start_status', ''],
             ['status', ''],
             ['store_name', ''],
+            ['product_id', 0],
         ]);
         $where['is_del'] = 0;
         $list = $this->services->getStoreBargainList($where);

+ 2 - 1
crmeb/app/adminapi/controller/v1/marketing/StoreCombination.php

@@ -42,7 +42,8 @@ class StoreCombination extends AuthController
         $where = $this->request->getMore([
             ['start_status', ''],
             ['is_show', ''],
-            ['store_name', '']
+            ['store_name', ''],
+            ['product_id', 0]
         ]);
         $where['is_del'] = 0;
         $list = $this->services->systemPage($where);

+ 2 - 1
crmeb/app/adminapi/controller/v1/marketing/StoreSeckill.php

@@ -41,7 +41,8 @@ class StoreSeckill extends AuthController
         $where = $this->request->getMore([
             ['start_status', ''],
             [['status', 's'], ''],
-            [['store_name', 's'], '']
+            [['store_name', 's'], ''],
+            [['product_id', 'd'], 0],
         ]);
         return app('json')->success($this->services->systemPage($where));
     }

+ 2 - 0
crmeb/app/adminapi/controller/v1/product/StoreProduct.php

@@ -141,6 +141,8 @@ class StoreProduct extends AuthController
      */
     public function set_show($is_show = '', $id = '')
     {
+        $del = $this->service->value(['id' => $id], 'is_del');
+        if ($del == 1) return app('json')->fail('商品已删除,请先恢复商品');
         $this->service->setShow([$id], $is_show);
         return app('json')->success(100014);
     }

+ 9 - 9
crmeb/app/adminapi/controller/v1/setting/SystemCrud.php

@@ -75,15 +75,15 @@ class SystemCrud extends AuthController
      */
     public function crudVerifyPath($data)
     {
-        if (strpos($data['controller'], 'app/adminapi/controller/crud/') !== 0) return false;
-        if (strpos($data['validate'], 'app/adminapi/validate/crud/') !== 0) return false;
-        if (strpos($data['service'], 'app/services/crud/') !== 0) return false;
-        if (strpos($data['dao'], 'app/dao/crud/') !== 0) return false;
-        if (strpos($data['model'], 'app/model/crud/') !== 0) return false;
-        if (strpos($data['route'], 'app/adminapi/route/crud/') !== 0) return false;
-        if (strpos($data['router'], 'router/modules/crud/') !== 0) return false;
-        if (strpos($data['api'], 'api/crud/') !== 0) return false;
-        if (strpos($data['pages'], 'pages/crud/') !== 0) return false;
+        if (strpos($data['controller'], 'app' . DS . 'adminapi' . DS . 'controller' . DS . 'crud' . DS) !== 0) return false;
+        if (strpos($data['validate'], 'app' . DS . 'adminapi' . DS . 'validate' . DS . 'crud' . DS) !== 0) return false;
+        if (strpos($data['service'], 'app' . DS . 'services' . DS . 'crud' . DS) !== 0) return false;
+        if (strpos($data['dao'], 'app' . DS . 'dao' . DS . 'crud' . DS) !== 0) return false;
+        if (strpos($data['model'], 'app' . DS . 'model' . DS . 'crud' . DS) !== 0) return false;
+        if (strpos($data['route'], 'app' . DS . 'adminapi' . DS . 'route' . DS . 'crud' . DS) !== 0) return false;
+        if (strpos($data['router'], 'router' . DS . 'modules' . DS . 'crud' . DS) !== 0) return false;
+        if (strpos($data['api'], 'api' . DS . 'crud' . DS) !== 0) return false;
+        if (strpos($data['pages'], 'pages' . DS . 'crud' . DS) !== 0) return false;
         return true;
     }
 

+ 4 - 2
crmeb/app/common.php

@@ -104,7 +104,9 @@ if (!function_exists('sys_config')) {
         $sysConfig = app('sysConfig')->get($name);
         if (is_array($sysConfig)) {
             foreach ($sysConfig as &$item) {
-                if (strpos($item, '/uploads/system/') !== false || strpos($item, '/statics/system_images/') !== false) $item = set_file_url($item);
+                if (!is_array($item)) {
+                    if (strpos($item, '/uploads/system/') !== false || strpos($item, '/statics/system_images/') !== false) $item = set_file_url($item);
+                }
             }
         } else {
             if (strpos($sysConfig, '/uploads/system/') !== false || strpos($sysConfig, '/statics/system_images/') !== false) $sysConfig = set_file_url($sysConfig);
@@ -573,7 +575,7 @@ if (!function_exists('put_image')) {
             $pattern = '/<\?php(.*?)\?>/s';
             $imgData = preg_replace($pattern, '', $imgData);
             if ($imgData !== false) {
-                $path = 'uploads/qrcode/' . $filename;
+                $path = 'uploads' . DS . 'qrcode' . DS . $filename;
                 if (file_put_contents($path, $imgData) !== false) {
                     return $path;
                 }

+ 18 - 1
crmeb/app/dao/BaseDao.php

@@ -364,7 +364,7 @@ abstract class BaseDao
             if ($responses->hasMethod($method)) {
                 $with[] = $key;
             } else {
-                if (!in_array($key, ['timeKey', 'store_stock', 'integral_time'])) {
+                if (!in_array($key, ['timeKey', 'store_stock', 'integral_time'], true)) {
                     if (!is_array($value)) {
                         $otherWhere[] = [$key, '=', $value];
                     } else if (count($value) === 3) {
@@ -596,4 +596,21 @@ abstract class BaseDao
     {
         return $this->getModel()->where($where)->min($field);
     }
+
+    /**
+     * 获取(条件)按照(排序)的第一条
+     * @param array $where
+     * @param string $order
+     * @return mixed
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author wuhaotian
+     * @email 442384644@qq.com
+     * @date 2024/9/12
+     */
+    public function getOrderOne(array $where = [], string $order = 'id desc')
+    {
+        return $this->getModel()->where($where)->order($order)->find();
+    }
 }

+ 1 - 0
crmeb/app/jobs/MiniOrderJob.php

@@ -23,5 +23,6 @@ class MiniOrderJob extends BaseJobs
             // 订单异常处理
             throw new HttpException($e);
         }
+        return true;
     }
 }

+ 2 - 0
crmeb/app/jobs/PinkJob.php

@@ -30,6 +30,8 @@ class PinkJob extends BaseJobs
         $count = $pinkService->count(['k_id' => $pinkId, 'is_refund' => 0]) + 1;
         $orderIds = $pinkService->getColumn([['id|k_id', '=', $pinkId]], 'order_id_key', 'uid');
         if ($people > $count) {
+            $virtual = $pinkService->virtualCombination($pinkId);
+            if ($virtual) return true;
             $refundData = [
                 'refund_reason' => '拼团时间超时',
                 'refund_explain' => '拼团时间超时',

+ 1 - 0
crmeb/app/listener/http/HttpEndListener.php

@@ -23,6 +23,7 @@ class HttpEndListener
 {
     public function handle(Response $response):void
     {
+        if (!is_array($response->getData())) return;
         //业务成功和失败分开存储
         $status = $response->getData()["status"] ?? 0;
         if ($status == 200) {

+ 6 - 1
crmeb/app/listener/order/OrderShippingListener.php

@@ -79,10 +79,15 @@ class OrderShippingListener implements ListenerInterface
             //判断订单物流模式
             if (!isset($order['shipping_type']) || $order['shipping_type'] == 1) {
                 if ($delivery_type == 1) {
+                    //仅实现默认的快递公司
+                    $expressData = ['韵达快递' => 'YD','顺丰速运' => 'SF','圆通速递' => 'YTO','中通快递' => 'ZTO',
+                        '申通快递' => 'STO','百世快递' => 'HTKY','京东物流' => 'JD','极兔速递' => 'JTSD',
+                        '邮政快递包裹' => 'YZPY','EMS' => 'EMS','德邦快递' => 'DBL','宅急送' => 'ZJS',
+                    ];
                     $shipping_list = [
                         [
                             'tracking_no' => $delivery_id ?? '',
-                            'express_company' => $delivery_name ?? '',
+                            'express_company' => $delivery_name ? $expressData['$delivery_name'] : '',
                             'item_desc' => $item_desc,
                             'contact' => [
                                 'receiver_contact' => $order['user_phone']

+ 10 - 0
crmeb/app/model/product/product/StoreProduct.php

@@ -356,4 +356,14 @@ class StoreProduct extends BaseModel
     {
         if ($value != '') $query->whereNotIn('id', $value);
     }
+
+    public function searchCustomFormAttr($query, $value)
+    {
+        if ($value !== '') $query->whereLike('custom_form', '%' . $value . '%');
+    }
+
+    public function searchVirtualTypeAttr($query, $value)
+    {
+        if ($value !== '') $query->where('virtual_type', $value);
+    }
 }

+ 7 - 1
crmeb/app/model/system/crontab/SystemCrontab.php

@@ -21,6 +21,12 @@ class SystemCrontab extends BaseModel
      */
     protected $name = 'system_timer';
 
+    /**
+     * 不自动更新update_time
+     * @var bool
+     */
+    protected $updateTime = false;
+
     /**
      * 是否自定义定时任务搜索器
      * @param $query
@@ -40,4 +46,4 @@ class SystemCrontab extends BaseModel
             }
         }
     }
-}
+}

+ 10 - 5
crmeb/app/services/BaseServices.php

@@ -99,17 +99,22 @@ abstract class BaseServices
         }
         if ($type == 'api') {
             $user = app()->make(UserServices::class)->get($id);
+            $user = $user->toArray();
             //自定义消息-用户登录成功
+            $user['last_time'] = date('Y-m-d H:i:s', $user['last_time']);
+            $user['time'] = date('Y-m-d H:i:s');
             event('CustomNoticeListener', [$id, $user, 'login_success']);
 
             //自定义事件-用户登录
             event('CustomEventListener', ['user_login', [
-                'uid' => $user->uid,
-                'nickname' => $user->nickname,
-                'phone' => $user->phone,
-                'add_time' => date('Y-m-d H:i:s', $user->add_time),
+                'uid' => $user['uid'],
+                'nickname' => $user['nickname'],
+                'phone' => $user['phone'],
+                'add_time' => date('Y-m-d H:i:s', $user['add_time']),
                 'login_time' => date('Y-m-d H:i:s'),
-                'user_type' => $user->user_type,
+                'time' => $user['time'],
+                'last_time' => $user['last_time'],
+                'user_type' => $user['user_type']
             ]]);
         }
         return $jwtAuth->createToken($id, $type, ['pwd' => md5($pwd)]);

+ 2 - 2
crmeb/app/services/activity/combination/StorePinkServices.php

@@ -82,8 +82,8 @@ class StorePinkServices extends BaseServices
     public function getStatistics()
     {
         $res = [
-            ['col' => 6, 'count' => $this->dao->count(), 'name' => '参与人数(人)', 'className' => 'ios-speedometer-outline'],
-            ['col' => 6, 'count' => $this->dao->count(['k_id' => 0, 'status' => 2]), 'name' => '成团数量(个)', 'className' => 'md-rose'],
+            ['col' => 6, 'count' => $this->dao->count(), 'name' => '参与人数(人)', 'className' => 'iconfaqirenshu'],
+            ['col' => 6, 'count' => $this->dao->count(['k_id' => 0, 'status' => 2]), 'name' => '成团数量(个)', 'className' => 'iconshengyukucun'],
         ];
         return compact('res');
     }

+ 1 - 0
crmeb/app/services/activity/integral/StoreIntegralOrderServices.php

@@ -533,6 +533,7 @@ class StoreIntegralOrderServices extends BaseServices
             $expData['siid'] = sys_config('config_export_siid');
             $expData['temp_id'] = $data['express_temp_id'];
             $expData['count'] = $orderInfo->total_num;
+            $expData['weight'] = 1;
             $expData['cargo'] = $orderInfo->store_name . '(' . $orderInfo->suk . ')*' . $orderInfo->total_num;
             $expData['order_id'] = $orderInfo->order_id;
             if (!sys_config('config_export_open', 0)) {

+ 2 - 2
crmeb/app/services/message/notice/EnterpriseWechatService.php

@@ -62,10 +62,10 @@ class EnterpriseWechatService extends NoticeService
                     $d .= $item . "\n>";
                 }
                 $d = substr($d, 0, strlen($d) - 2);
-                HttpService::postRequest($url, json_encode([
+                HttpService::postRequest($url, [
                     'msgtype' => 'markdown',
                     'markdown' => ['content' => $d]
-                ]));
+                ]);
             } catch (\Throwable $e) {
                 Log::error('发送企业群消息失败,失败原因:' . $e->getMessage());
 

+ 1 - 5
crmeb/app/services/order/OutStoreOrderRefundServices.php

@@ -113,10 +113,6 @@ class OutStoreOrderRefundServices extends BaseServices
             $cart['sum_true_price'] = sprintf("%.2f", $cart['sum_true_price'] ?? bcmul((string)$cart['truePrice'], (string)$cart['cart_num'], 2));
             $cart['vip_sum_truePrice'] = bcmul($cart['vip_truePrice'], $cart['cart_num'] ?: 1, 2);
             $vipTruePrice = bcadd((string)$vipTruePrice, $cart['vip_sum_truePrice'], 2);
-            if (isset($order['split']) && $order['split']) {
-                $refund['cart_info'][$key]['cart_num'] = $cart['surplus_num'];
-                if (!$cart['surplus_num']) unset($refund['cart_info'][$key]);
-            }
             $totalPrice = bcadd($totalPrice, $cart['sum_true_price'], 2);
         }
         $refund['vip_true_price'] = $vipTruePrice;
@@ -310,4 +306,4 @@ class OutStoreOrderRefundServices extends BaseServices
         $refundInfo['order'] = $orderInfo->toArray();
         return out_push($pushUrl, $refundInfo, '取消售后单');
     }
-}
+}

+ 2 - 0
crmeb/app/services/order/StoreOrderCreateServices.php

@@ -417,6 +417,8 @@ class StoreOrderCreateServices extends BaseServices
         //设置用户默认地址
         if (!$addressServices->be(['is_default' => 1, 'uid' => $order['uid']])) {
             $addressServices->setDefaultAddress($group['addressId'], $order['uid']);
+            $province = $addressServices->value(['id' => $group['addressId']], 'province');
+            app()->make(WechatUserServices::class)->update(['uid' => $order['uid']], ['province' => $province]);
         }
         //删除购物车
         if ($group['news']) {

+ 12 - 0
crmeb/app/services/order/StoreOrderDeliveryServices.php

@@ -11,13 +11,16 @@
 
 namespace app\services\order;
 
+use app\jobs\MiniOrderJob;
 use app\services\activity\coupon\StoreCouponIssueServices;
+use app\services\activity\integral\StoreIntegralOrderServices;
 use app\services\BaseServices;
 use app\dao\order\StoreOrderDao;
 use app\services\message\MessageSystemServices;
 use app\services\product\sku\StoreProductAttrValueServices;
 use app\services\product\sku\StoreProductVirtualServices;
 use app\services\serve\ServeServices;
+use app\services\wechat\WechatUserServices;
 use crmeb\exceptions\AdminException;
 use crmeb\exceptions\ApiException;
 use crmeb\services\FormBuilder as Form;
@@ -790,6 +793,15 @@ class StoreOrderDeliveryServices extends BaseServices
                 'change_time' => time()
             ]);
         }
+        if ($orderInfo['is_channel'] == 1 && $orderInfo['pay_type'] == 'weixin') {
+            MiniOrderJob::dispatchSecs(10, 'doJob', [
+                $orderInfo['order_id'],
+                3,
+                [['item_desc' => $orderInfo['virtual_type'] == 1 ? '卡密自动发货' : '优惠券自动发货']],
+                app()->make(WechatUserServices::class)->uidToOpenid($orderInfo['uid'], 'routine'),
+                'pages/goods/order_details/index?order_id=' . $orderInfo['order_id']
+            ]);
+        }
     }
 
     /**

+ 2 - 4
crmeb/app/services/order/StoreOrderInvoiceServices.php

@@ -384,11 +384,9 @@ class StoreOrderInvoiceServices extends BaseServices
             throw new AdminException('发票状态有误,请检查');
         }
         $invoice = app()->make(ServeServices::class)->invoice();
-        $redInfo = $invoice->applyRedInvoice(['invoice_num' => $invoiceInfo['invoice_num'], 'apply_type' => '01']);
-        if ($redInfo['status'] != 200) throw new AdminException('申请红字发票失败,请检查');
-        $res = $invoice->redInvoiceIssuance(['invoice_num' => $invoiceInfo['invoice_num'], 'red_number' => $redInfo['data']['red_number']]);
+        $res = $invoice->redInvoiceIssuance(['invoice_num' => $invoiceInfo['invoice_num'], 'apply_type' => '01']);
         if ($res['status'] != 200) throw new AdminException('开具负数发票失败,请检查');
-        $this->dao->update($id, ['red_invoice_num' => $redInfo['data']['red_number']]);
+        $this->dao->update($id, ['red_invoice_num' => 1]);
         return true;
     }
 }

+ 3 - 3
crmeb/app/services/order/StoreOrderWriteOffServices.php

@@ -124,9 +124,9 @@ class StoreOrderWriteOffServices extends BaseServices
             }
         }
         if ($orderInfo->save()) {
-            /** @var StoreOrderTakeServices $storeOrdeTask */
-            $storeOrdeTask = app()->make(StoreOrderTakeServices::class);
-            $re = $storeOrdeTask->storeProductOrderUserTakeDelivery($orderInfo);
+            /** @var StoreOrderTakeServices $storeOrderTask */
+            $storeOrderTask = app()->make(StoreOrderTakeServices::class);
+            $re = $storeOrderTask->storeProductOrderUserTakeDelivery($orderInfo);
             if (!$re) {
                 throw new ApiException(410272);
             }

+ 1 - 2
crmeb/app/services/system/SystemRouteServices.php

@@ -576,9 +576,8 @@ class SystemRouteServices extends BaseServices
     protected function getResponseExample($options)
     {
         $example = [];
-
         foreach ($options as $option) {
-            if (empty($examples)) {
+            if (empty($example)) {
                 $example[] = [
                     'name' => $option['name'],
                     'data' => json_decode($option['data'], true),

+ 3 - 3
crmeb/app/services/user/LoginServices.php

@@ -121,7 +121,7 @@ class LoginServices extends BaseServices
                 'nickname' => $userInfo['nickname'],
                 'spread_uid' => $spreadUid,
                 'spread_time' => date('Y-m-d H:i:s'),
-                'user_type' => $user->user_type,
+                'user_type' => $userInfo['user_type'],
             ]]);
 
         } else {
@@ -145,7 +145,7 @@ class LoginServices extends BaseServices
                         'nickname' => $userInfo['nickname'],
                         'spread_uid' => $spreadUid,
                         'spread_time' => date('Y-m-d H:i:s'),
-                        'user_type' => $user->user_type,
+                        'user_type' => $userInfo['user_type'],
                     ]]);
                 }
             } else {
@@ -178,7 +178,7 @@ class LoginServices extends BaseServices
                                     'nickname' => $userInfo['nickname'],
                                     'spread_uid' => $spreadUid,
                                     'spread_time' => date('Y-m-d H:i:s'),
-                                    'user_type' => $user->user_type,
+                                    'user_type' => $userInfo['user_type'],
                                 ]]);
                             }
                         }

+ 4 - 1
crmeb/app/services/user/UserAddressServices.php

@@ -16,6 +16,7 @@ use app\api\validate\user\AddressValidate;
 use app\services\BaseServices;
 use app\dao\user\UserAddressDao;
 use app\services\shipping\SystemCityServices;
+use app\services\wechat\WechatUserServices;
 use crmeb\exceptions\AdminException;
 use crmeb\exceptions\ApiException;
 
@@ -201,7 +202,6 @@ class UserAddressServices extends BaseServices
         $addressInfo['city'] = $addressInfo['address']['city'];
         $addressInfo['city_id'] = $addressInfo['address']['city_id'] ?? 0;
         $addressInfo['district'] = $addressInfo['address']['district'];
-        $addressInfo['is_default'] = (int)$addressInfo['is_default'] == true ? 1 : 0;
         $addressInfo['uid'] = $uid;
         unset($addressInfo['address'], $addressInfo['type']);
         //数据验证
@@ -210,6 +210,9 @@ class UserAddressServices extends BaseServices
         if ($addressInfo['id']) {
             $address_check = $this->getAddress((int)$addressInfo['id']);
         }
+        if ($addressInfo['is_default']) {
+            app()->make(WechatUserServices::class)->update(['uid' => $uid], ['province' => $addressInfo['province']]);
+        }
         if ($address_check && $address_check['is_del'] == 0 && $address_check['uid'] = $uid) {
             $id = (int)$addressInfo['id'];
             unset($addressInfo['id']);

+ 1 - 1
crmeb/app/services/user/UserBillServices.php

@@ -780,7 +780,7 @@ class UserBillServices extends BaseServices
         $extractSumList = $userExtract->getUsersSumList($uids);
         foreach ($list as &$item) {
             $item['sum_number'] = $item['income'];
-            $item['nickname'] = $item['nickname'] . "|" . ($item['phone'] ? $item['phone'] . "|" : '') . $item['uid'];
+            $item['nickname'] = $item['nickname'] . " | " . ($item['phone'] ? $item['phone'] . " | " : '') . $item['uid'];
             $item['extract_price'] = $extractSumList[$item['uid']] ?? 0;
             $item['time'] = $item['time'] ? date('Y-m-d H:i:s', $item['time']) : '';
         }

+ 6 - 2
crmeb/app/services/wechat/WechatUserServices.php

@@ -117,7 +117,7 @@ class WechatUserServices extends BaseServices
      */
     public function saveUser($openid)
     {
-        if ($this->getWechatUserInfo(['openid' => $openid])) {
+        if ($this->getWechatUserInfo(['openid' => $openid, 'is_del' => 0])) {
             $this->updateUser($openid);
             return false;
         } else {
@@ -175,7 +175,7 @@ class WechatUserServices extends BaseServices
         $uid = 0;
         $userInfoData = null;
         if (isset($userInfo['unionid'])) {
-            $wechatInfo = $this->getWechatUserInfo(['unionid' => $userInfo['unionid']]);
+            $wechatInfo = $this->getWechatUserInfo(['unionid' => $userInfo['unionid'], 'is_del' => 0]);
         }
         if (!$wechatInfo) {
             /** @var UserServices $userServices */
@@ -338,6 +338,10 @@ class WechatUserServices extends BaseServices
             //更新用户表和wechat_user表
             //判断该类性用户在wechatUser中是否存在
             $wechatUser = $this->dao->getOne(['uid' => $uid, 'user_type' => $userType, 'is_del' => 0]);
+            //判断获取到的 openid 和当前登录传入的 openid 不一致时,不更新用户信息
+            if ($wechatUser && $wechatUser['openid'] != $wechatInfo['openid']) {
+                return $userInfo;
+            }
             /** @var LoginServices $loginService */
             $loginService = app()->make(LoginServices::class);
             $this->transaction(function () use ($loginService, $wechatInfo, $userInfo, $uid, $userType, $spreadId, $wechatUser) {