|
@@ -13,16 +13,24 @@ use Main\Lib\Core;
|
|
|
class Card
|
|
|
{
|
|
|
public $lock = 'cardv1';
|
|
|
- public function test()
|
|
|
+ public function len($id = false)
|
|
|
{
|
|
|
- $len = Dever::queue($this->lock, 'len');
|
|
|
+ $id = Dever::input('id', $id);
|
|
|
+ $len = Dever::queue($this->lock . '_' . $id, 'len');
|
|
|
return $len;
|
|
|
}
|
|
|
|
|
|
public function total()
|
|
|
{
|
|
|
- $total = Dever::db('youzan/card_list')->total(array('option_state' => 1, 'option_status' => 1));
|
|
|
- return Dever::lock($this->lock, $total);
|
|
|
+ $info = Dever::db('youzan/card')->state();
|
|
|
+ if ($info) {
|
|
|
+ foreach ($info as $k => $v) {
|
|
|
+ $total = Dever::db('youzan/card_list')->total(array('option_state' => 1, 'option_status' => 1, 'option_card_id' => $v['id']));
|
|
|
+ Dever::lock($this->lock . '_' . $v['id'], $total);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
# 分配优惠券,此处需要做高并发处理
|
|
@@ -39,7 +47,7 @@ class Card
|
|
|
if ($one) {
|
|
|
return $one;
|
|
|
} else {
|
|
|
- $state = Dever::lock($this->lock);
|
|
|
+ $state = Dever::lock($this->lock . '_' . $info['id']);
|
|
|
if (!$state) {
|
|
|
Dever::alert('error');
|
|
|
} else {
|