Kirin 3 years ago
parent
commit
c5f6d003f8
1 changed files with 14 additions and 14 deletions
  1. 14 14
      crmeb/services/YLYService.php

+ 14 - 14
crmeb/services/YLYService.php

@@ -46,6 +46,8 @@ class YLYService extends HttpService implements ProviderInterface
      */
     protected $order_id = null;
 
+    protected $store_id = 0;
+
     /**
      *  终端号码
      * @var string
@@ -82,20 +84,22 @@ class YLYService extends HttpService implements ProviderInterface
         $this->terminal = $system['terminal_number'] ?? '';
         $this->getAccessToken();
     }
+
     public function selectStore($store_id)
     {
-        $terminal_number = SystemStore::where('id',$store_id)->value('terminal_number');
+        $this->store_id = $store_id;
+        $terminal_number = SystemStore::where('id', $store_id)->value('terminal_number');
         $this->terminal = $terminal_number;
-        $this->getAccessToken();
+        $this->getAccessToken($store_id);
         return $this;
     }
 
     /**
      * 获取AccessToken
      * */
-    protected function getAccessToken($store_id=0)
+    protected function getAccessToken($store_id = 0)
     {
-        $this->access_token = CacheModel::getDbCache('YLY_access_token'.$store_id, 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',
@@ -147,7 +151,7 @@ class YLYService extends HttpService implements ProviderInterface
         if ($request === false) return false;
         $request = json_decode($request, true);
         if (isset($request['error']) && in_array($request['error'], [18, 14]) && $errorCount == 0) {
-            CacheModel::delectDbCache('YLY_access_token');
+            CacheModel::delectDbCache('YLY_access_token' . $this->store_id);
             $this->getAccessToken();
             return $this->orderPrinting($order_id, 1);
         }
@@ -195,15 +199,11 @@ class YLYService extends HttpService implements ProviderInterface
         $goodsStr .= '</table>';
         $this->order_id = $orderInfo['order_id'];
         $order_type = "普通订单";
-        if($orderInfo['is_consumer']==1)
-        {
-            $order_type ="消费券订单";
-        }
-        else
-        {
-            if($orderInfo['use_integral']>0)
-            {
-                $order_type ="积分订单";
+        if ($orderInfo['is_consumer'] == 1) {
+            $order_type = "消费券订单";
+        } else {
+            if ($orderInfo['use_integral'] > 0) {
+                $order_type = "积分订单";
             }
         }
         $count = <<<CONTENT