ayHaru hace 4 años
padre
commit
29a8a34a25
Se han modificado 2 ficheros con 13 adiciones y 7 borrados
  1. 4 4
      admin/control/merchant.php
  2. 9 3
      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;

+ 9 - 3
crontab/control/minutes.php

@@ -83,17 +83,23 @@ class minutesControl extends BaseCronControl
 
             return $items;
         };
+        $new_caches = [];
         $card_type = [1 => 'petrochina' , 2 => 'sinopec'];
         foreach ($caches as $cache)
         {
             $items = $reader($cache['mchid'],$cache['time']);
             foreach ($items as $item) {
-                if ($cache[$card_type[$item['card_type']]][$item['refill_amount']] < $item['num']) {
-                    //指定card_type,refill_amount的单数比缓存中设置单数大,设置对应缓存能否下单为false,key为商户ID-卡类型-额度
-                    wcache("{$cache['mchid']}-{$item['card_type']}-{$item['refill_amount']}" , ['can_add' => false] , 'merchant-');
+                //指定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-');
+        }
     }
 
     /**