|
@@ -66,17 +66,17 @@ class minutesControl extends BaseCronControl
|
|
|
wcache("merchant-notify", ['data' => serialize($new_caches)], 'refill-');
|
|
|
}
|
|
|
|
|
|
- private function _check_refill_order_limit()
|
|
|
+ public function check_refill_order_limit()
|
|
|
{
|
|
|
- $mch_cache = rcache("order_limit" , 'merchant-');
|
|
|
+ $mch_cache = rcache("storge_limit" , 'merchant-');
|
|
|
$caches = empty($mch_cache['data']) ? [] : unserialize($mch_cache['data']);
|
|
|
|
|
|
- $reader = function ($mchid,$time)
|
|
|
+ $reader = function ($mchid,$time,$curtime)
|
|
|
{
|
|
|
$cond['mchid'] = $mchid;
|
|
|
$cond['inner_status'] = 0;
|
|
|
$cond['order_state'] = ORDER_STATE_SUCCESS;
|
|
|
- $cond['refill_order.order_time'] = ['ge', $time];
|
|
|
+ $cond['refill_order.order_time'] = [['egt', $time],['lt', $curtime],'and'];
|
|
|
|
|
|
$items = Model('')->table('refill_order,vr_order')->join('inner')
|
|
|
->on('refill_order.order_id=vr_order.order_id')
|
|
@@ -87,13 +87,19 @@ class minutesControl extends BaseCronControl
|
|
|
return $items;
|
|
|
};
|
|
|
|
|
|
+ $curtime = time();
|
|
|
$new_caches = [];
|
|
|
$card_type = [1 => 'petrochina' , 2 => 'sinopec'];
|
|
|
foreach ($caches as $cache)
|
|
|
{
|
|
|
- $items = $reader($cache['mchid'],$cache['time']);
|
|
|
+ $mchid = intval($cache['mchid']);
|
|
|
+ $start = $cache['time'];
|
|
|
+ $end = $curtime;
|
|
|
+
|
|
|
+ $items = $reader($mchid,$start,$end);
|
|
|
foreach ($items as $item) {
|
|
|
//指定card_type,refill_amount的单数比缓存中设置单数大,设置对应缓存能否下单为false,key为商户ID-卡类型-额度
|
|
|
+
|
|
|
$cache_num = $cache[$card_type[$item['card_type']]][$item['refill_amount']];
|
|
|
$can_add = true;
|
|
|
if ($cache_num < $item['num']) {
|