Kirin 3 éve
szülő
commit
d6f89131e6

+ 1 - 1
crmeb/repositories/NoticeRepositories.php

@@ -76,7 +76,7 @@ class NoticeRepositories
                     $value['productInfo']['store_name'] = StoreOrderCartInfo::getSubstrUTf8($value['productInfo']['store_name'], 10, 'UTF-8', '');
                     $product[] = $value;
                 }
-                YLYService::instance($order['store_id'])->setContent(sys_config('site_name'), is_object($order) ? $order->toArray() : $order, $product)->orderPrinting();
+                YLYService::instance()->selectStore($order['store_id'])->setContent(sys_config('site_name'), is_object($order) ? $order->toArray() : $order, $product)->orderPrinting();
             } catch (\Exception $e) {
                 Log::error('小票打印出现错误,错误原因:' . $e->getMessage());
             }

+ 11 - 2
crmeb/services/YLYService.php

@@ -3,6 +3,7 @@
 namespace crmeb\services;
 
 use app\models\system\Cache as CacheModel;
+use app\models\system\SystemStore;
 use crmeb\exceptions\AuthException;
 use crmeb\interfaces\ProviderInterface;
 use crmeb\traits\LogicTrait;
@@ -82,12 +83,20 @@ class YLYService extends HttpService implements ProviderInterface
         $this->getAccessToken();
     }
 
+    public function selectStore($store_id)
+    {
+        $terminal_number = SystemStore::where('id',$store_id)->value('terminal_number');
+        $this->terminal = $terminal_number;
+        $this->getAccessToken($store_id);
+        return $this;
+    }
+
     /**
      * 获取AccessToken
      * */
-    protected function getAccessToken()
+    protected function getAccessToken($store_id=0)
     {
-        $this->access_token = CacheModel::getDbCache('YLY_access_token', function () {
+        $this->access_token = CacheModel::getDbCache('YLY_access_token'.$store_id, function () {
             $request = self::postRequest($this->apiUrl . 'oauth/oauth', [
                 'client_id' => $this->client_id,
                 'grant_type' => 'client_credentials',