Kaynağa Gözat

Merge branch 'refill_queue' of 39.97.239.116:gyfl/xyzshop into refill_queue

stanley-king 4 yıl önce
ebeveyn
işleme
e89ab1f323
2 değiştirilmiş dosya ile 28 ekleme ve 13 silme
  1. 4 4
      admin/control/merchant.php
  2. 24 9
      crontab/control/minutes.php

+ 4 - 4
admin/control/merchant.php

@@ -174,10 +174,10 @@ class merchantControl extends SystemControl
         }
         $default = function ($merchant) {
             $amount = [
-                '100' => 0,
-                '200' => 0,
-                '500' => 0,
-                '1000' => 0
+                '100' => -1,
+                '200' => -1,
+                '500' => -1,
+                '1000' => -1
             ];
             $data['mchid'] = $merchant['mchid'];
             $data['petrochina'] = $data['sinopec'] = $amount;

+ 24 - 9
crontab/control/minutes.php

@@ -34,7 +34,7 @@ class minutesControl extends BaseCronControl
         foreach ($merchants as $merchant)
         {
             $mchid = $merchant['mchid'];
-            $phone = $merchant['contact_phone'] ?? "";
+            $phones = empty($merchant['warning_phone']) ? [] : unserialize($merchant['warning_phone']);
             $available_pd = intval($merchant['available_predeposit']);
             $alarm_pd = intval($merchant['alarm_amount']);
 
@@ -44,15 +44,17 @@ class minutesControl extends BaseCronControl
             else {
                 $mch_cache = ['last_time' => 0, 'send_count' => 0];
             }
-
-            if(!empty($phone) && ($available_pd < $alarm_pd || $available_pd < 10000))
+            if($available_pd < $alarm_pd || $available_pd < 10000)
             {
                 $counts =  $mch_cache['send_count'];
                 if(($mch_cache['last_time'] + 300 < time()) && $counts < 5) {
                     $mch_cache = ['last_time' => time(), 'send_count' => $counts + 1];
-                    QueueClient::push('sendSMS', ['mobile'=>$merchant['contact_phone'],
-                        'type'=>'balance_warning','datas' => [date("m月d日H时") , $merchant['available_predeposit']]]);
-
+                    foreach ($phones as $phone) {
+                        if(!empty($phone)){
+                            QueueClient::push('sendSMS', ['mobile'=>$phone,
+                                'type'=>'balance_warning','datas' => [date("m月d日H时") , $merchant['available_predeposit']]]);
+                        }
+                    }
                 }
             }
             else {
@@ -84,9 +86,22 @@ class minutesControl extends BaseCronControl
 
             return $items;
         };
-
-        foreach ($caches as $cache) {
-            $item = $reader($cache['mchid'],$cache['time']);
+        $new_caches = [];
+        $card_type = [1 => 'petrochina' , 2 => 'sinopec'];
+        foreach ($caches as $cache)
+        {
+            $items = $reader($cache['mchid'],$cache['time']);
+            foreach ($items as $item) {
+                //指定card_type,refill_amount的单数比缓存中设置单数大,设置对应缓存能否下单为false,key为商户ID-卡类型-额度
+                $cache_num = $cache[$card_type[$item['card_type']]][$item['refill_amount']];
+                if ($cache_num < $item['num']) {
+                    $can_add = $cache_num == -1;
+                }
+                $new_caches["{$cache['mchid']}-{$item['card_type']}-{$item['refill_amount']}"] = false;
+            }
+        }
+        if(!empty($new_caches)) {
+            wcache("mch_can_order" , ['data' => serialize($new_caches)] , 'merchant-');
         }
     }